Title: [288362] trunk
Revision
288362
Author
[email protected]
Date
2022-01-21 07:08:18 -0800 (Fri, 21 Jan 2022)

Log Message

WPT version of css/css-cascade/parsing/layer-import-parsing.html crashes with nullptr
https://bugs.webkit.org/show_bug.cgi?id=235434
rdar://87832940

Reviewed by Alan Bujtas.

LayoutTests/imported/w3c:

* web-platform-tests/css/css-cascade/parsing/layer-import-parsing.html:

Update to WPT version.

Source/WebCore:

Test: fast/css/insert-import-rule-crash.html

* css/StyleRuleImport.cpp:
(WebCore::StyleRuleImport::setCSSStyleSheet):

Null check the parent stylesheet. It can be null if the rule has been removed.

* dom/InlineStyleSheetOwner.cpp:
(WebCore::InlineStyleSheetOwner::startLoadingDynamicSheet):

Also fix a debug assert in addPendingSheet, this can get called multiple times.

LayoutTests:

* fast/css/insert-import-rule-crash-expected.txt: Added.
* fast/css/insert-import-rule-crash.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (288361 => 288362)


--- trunk/LayoutTests/ChangeLog	2022-01-21 13:11:33 UTC (rev 288361)
+++ trunk/LayoutTests/ChangeLog	2022-01-21 15:08:18 UTC (rev 288362)
@@ -1,3 +1,14 @@
+2022-01-21  Antti Koivisto  <[email protected]>
+
+        WPT version of css/css-cascade/parsing/layer-import-parsing.html crashes with nullptr
+        https://bugs.webkit.org/show_bug.cgi?id=235434
+        rdar://87832940
+
+        Reviewed by Alan Bujtas.
+
+        * fast/css/insert-import-rule-crash-expected.txt: Added.
+        * fast/css/insert-import-rule-crash.html: Added.
+
 2022-01-21  Martin Robinson  <[email protected]>
 
         element.scrollIntoView() sometimes doesn't scroll

Added: trunk/LayoutTests/fast/css/insert-import-rule-crash-expected.txt (0 => 288362)


--- trunk/LayoutTests/fast/css/insert-import-rule-crash-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/css/insert-import-rule-crash-expected.txt	2022-01-21 15:08:18 UTC (rev 288362)
@@ -0,0 +1 @@
+This test passes if it doesn't crash.

Added: trunk/LayoutTests/fast/css/insert-import-rule-crash.html (0 => 288362)


--- trunk/LayoutTests/fast/css/insert-import-rule-crash.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/insert-import-rule-crash.html	2022-01-21 15:08:18 UTC (rev 288362)
@@ -0,0 +1,13 @@
+This test passes if it doesn't crash.
+<script>
+if (window.testRunner)
+    testRunner.dumpAsText();
+
+const style = document.createElement("style");
+document.head.append(style);
+
+style.sheet.insertRule('@import url(data:,foo)');
+style.sheet.cssRules[0];
+style.sheet.deleteRule(0);
+style.sheet.insertRule('@import url(data:,bar)');
+</script>

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (288361 => 288362)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2022-01-21 13:11:33 UTC (rev 288361)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2022-01-21 15:08:18 UTC (rev 288362)
@@ -1,3 +1,15 @@
+2022-01-21  Antti Koivisto  <[email protected]>
+
+        WPT version of css/css-cascade/parsing/layer-import-parsing.html crashes with nullptr
+        https://bugs.webkit.org/show_bug.cgi?id=235434
+        rdar://87832940
+
+        Reviewed by Alan Bujtas.
+
+        * web-platform-tests/css/css-cascade/parsing/layer-import-parsing.html:
+
+        Update to WPT version.
+
 2022-01-21  Martin Robinson  <[email protected]>
 
         element.scrollIntoView() sometimes doesn't scroll

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-cascade/parsing/layer-import-parsing.html (288361 => 288362)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-cascade/parsing/layer-import-parsing.html	2022-01-21 13:11:33 UTC (rev 288361)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-cascade/parsing/layer-import-parsing.html	2022-01-21 15:08:18 UTC (rev 288362)
@@ -10,7 +10,6 @@
     const style = document.createElement("style");
     document.head.append(style);
     const {sheet} = style;
-    document.head.removeChild(style);
     const {cssRules} = sheet;
 
     assert_equals(cssRules.length, 0, "Sheet should have no rules");

Modified: trunk/Source/WebCore/ChangeLog (288361 => 288362)


--- trunk/Source/WebCore/ChangeLog	2022-01-21 13:11:33 UTC (rev 288361)
+++ trunk/Source/WebCore/ChangeLog	2022-01-21 15:08:18 UTC (rev 288362)
@@ -1,3 +1,23 @@
+2022-01-21  Antti Koivisto  <[email protected]>
+
+        WPT version of css/css-cascade/parsing/layer-import-parsing.html crashes with nullptr
+        https://bugs.webkit.org/show_bug.cgi?id=235434
+        rdar://87832940
+
+        Reviewed by Alan Bujtas.
+
+        Test: fast/css/insert-import-rule-crash.html
+
+        * css/StyleRuleImport.cpp:
+        (WebCore::StyleRuleImport::setCSSStyleSheet):
+
+        Null check the parent stylesheet. It can be null if the rule has been removed.
+
+        * dom/InlineStyleSheetOwner.cpp:
+        (WebCore::InlineStyleSheetOwner::startLoadingDynamicSheet):
+
+        Also fix a debug assert in addPendingSheet, this can get called multiple times.
+
 2022-01-21  Lauro Moura  <[email protected]>
 
         [CMake] Cannot link libTestRunnerInjectedBundle.so in non unified build

Modified: trunk/Source/WebCore/css/StyleRuleImport.cpp (288361 => 288362)


--- trunk/Source/WebCore/css/StyleRuleImport.cpp	2022-01-21 13:11:33 UTC (rev 288361)
+++ trunk/Source/WebCore/css/StyleRuleImport.cpp	2022-01-21 15:08:18 UTC (rev 288362)
@@ -72,7 +72,7 @@
 
     Document* document = m_parentStyleSheet ? m_parentStyleSheet->singleOwnerDocument() : nullptr;
     m_styleSheet = StyleSheetContents::create(this, href, context);
-    if (m_parentStyleSheet->isContentOpaque() || !cachedStyleSheet->isCORSSameOrigin())
+    if ((m_parentStyleSheet && m_parentStyleSheet->isContentOpaque()) || !cachedStyleSheet->isCORSSameOrigin())
         m_styleSheet->setAsOpaque();
 
     bool parseSucceeded = m_styleSheet->parseAuthorStyleSheet(cachedStyleSheet, document ? &document->securityOrigin() : nullptr);

Modified: trunk/Source/WebCore/dom/InlineStyleSheetOwner.cpp (288361 => 288362)


--- trunk/Source/WebCore/dom/InlineStyleSheetOwner.cpp	2022-01-21 13:11:33 UTC (rev 288361)
+++ trunk/Source/WebCore/dom/InlineStyleSheetOwner.cpp	2022-01-21 15:08:18 UTC (rev 288362)
@@ -242,7 +242,7 @@
 
 void InlineStyleSheetOwner::startLoadingDynamicSheet(Element& element)
 {
-    if (m_styleScope)
+    if (m_styleScope && !m_styleScope->hasPendingSheet(element))
         m_styleScope->addPendingSheet(element);
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to