Bug 235930

Summary: Blank page when removing CSS @import
Product: WebKit Reporter: Oriol Brufau <obrufau>
Component: CSSAssignee: Oriol Brufau <obrufau>
Status: RESOLVED FIXED    
Severity: Normal CC: clopez, esprehn+autocc, ews-watchlist, glenn, gyuyoung.kim, koivisto, macpherson, menard, webkit-bug-importer, youennf
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=235434
https://github.com/web-platform-tests/wpt/pull/32626
Attachments:
Description Flags
Patch
none
Patch none

Description Oriol Brufau 2022-01-31 17:04:28 PST
Run the script from bug 235434:

```html
You should see this text!!!
<script>
const style = document.createElement("style");
document.head.append(style);

style.sheet.insertRule('@import url("nonexist.css")');
style.sheet.cssRules[0];
style.sheet.deleteRule(0);
</script>
```

Actual: completely blank page

Expected: page with "You should see this text!!!"

Reason: the import rule is removed before it finishes loading, and the hasPendingSheet() flag is not cleared.
Comment 1 Oriol Brufau 2022-01-31 17:11:18 PST
Created attachment 450478 [details]
Patch
Comment 2 EWS Watchlist 2022-01-31 17:14:14 PST
This patch modifies the imported WPT tests. Please ensure that any changes on the tests (not coming from a WPT import) are exported to WPT. Please see https://trac.webkit.org/wiki/WPTExportProcess
Comment 3 Antti Koivisto 2022-01-31 23:45:16 PST
Comment on attachment 450478 [details]
Patch

looks like the debug bot is hitting assert under StyleRuleImport::cancelLoad
Comment 4 Antti Koivisto 2022-01-31 23:46:10 PST
in imported/w3c/web-platform-tests/css/cssom/cssimportrule-parent.html sonf inspector/css/stylesheet-events-imports.html
Comment 5 Oriol Brufau 2022-02-01 04:29:35 PST
Created attachment 450515 [details]
Patch
Comment 6 Oriol Brufau 2022-02-01 04:31:39 PST
Should work now. It's just that cancelLoad() shouldn't do anything if it had already loaded.
Comment 7 Antti Koivisto 2022-02-01 04:33:51 PST
Comment on attachment 450515 [details]
Patch

Good find, thanks!
Comment 8 Radar WebKit Bug Importer 2022-02-01 04:52:45 PST
<rdar://problem/88322836>
Comment 9 EWS 2022-02-01 08:42:56 PST
Committed r288879 (246631@main): <https://commits.webkit.org/246631@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 450515 [details].