Title: [280586] trunk
Revision
280586
Author
[email protected]
Date
2021-08-03 00:38:08 -0700 (Tue, 03 Aug 2021)

Log Message

Check that shadow root is connected in invalidateStyleAfterStyleSheetChange
https://bugs.webkit.org/show_bug.cgi?id=227383

Patch by Rob Buis <[email protected]> on 2021-08-03
Reviewed by Antti Koivisto.

Source/WebCore:

Check that shadow root is connected in invalidateStyleAfterStyleSheetChange.

Test: fast/shadow-dom/shadow-tree-removal-crash.html

* style/StyleScope.cpp:
(WebCore::Style::Scope::updateActiveStyleSheets):

LayoutTests:

Add test for this.

* fast/shadow-dom/shadow-tree-removal-crash-expected.txt: Added.
* fast/shadow-dom/shadow-tree-removal-crash.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (280585 => 280586)


--- trunk/LayoutTests/ChangeLog	2021-08-03 06:54:03 UTC (rev 280585)
+++ trunk/LayoutTests/ChangeLog	2021-08-03 07:38:08 UTC (rev 280586)
@@ -1,3 +1,15 @@
+2021-08-03  Rob Buis  <[email protected]>
+
+        Check that shadow root is connected in invalidateStyleAfterStyleSheetChange
+        https://bugs.webkit.org/show_bug.cgi?id=227383
+
+        Reviewed by Antti Koivisto.
+
+        Add test for this.
+
+        * fast/shadow-dom/shadow-tree-removal-crash-expected.txt: Added.
+        * fast/shadow-dom/shadow-tree-removal-crash.html: Added.
+
 2021-08-02  Jean-Yves Avenard  <[email protected]>
 
         https://bugs.webkit.org/show_bug.cgi?id=228140

Added: trunk/LayoutTests/fast/shadow-dom/shadow-tree-removal-crash-expected.txt (0 => 280586)


--- trunk/LayoutTests/fast/shadow-dom/shadow-tree-removal-crash-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/shadow-dom/shadow-tree-removal-crash-expected.txt	2021-08-03 07:38:08 UTC (rev 280586)
@@ -0,0 +1 @@
+Test passes if there is no crash.

Added: trunk/LayoutTests/fast/shadow-dom/shadow-tree-removal-crash.html (0 => 280586)


--- trunk/LayoutTests/fast/shadow-dom/shadow-tree-removal-crash.html	                        (rev 0)
+++ trunk/LayoutTests/fast/shadow-dom/shadow-tree-removal-crash.html	2021-08-03 07:38:08 UTC (rev 280586)
@@ -0,0 +1,16 @@
+<script>
+  _onload_ = () => {
+    if (window.testRunner)
+      testRunner.dumpAsText();
+    let div0 = document.createElement('div');
+    document.body.appendChild(div0);
+    document.body.appendChild(document.createTextNode("Test passes if there is no crash."));
+    div0.append(document.createElementNS('http://www.w3.org/2000/svg', 'font-face'));
+    let shadowRoot = div0.attachShadow({mode: 'open'});
+    div0.remove();
+    shadowRoot.styleSheets;
+    queueMicrotask(() => {
+      GCController.collect();
+    });
+  };
+</script>

Modified: trunk/Source/WebCore/ChangeLog (280585 => 280586)


--- trunk/Source/WebCore/ChangeLog	2021-08-03 06:54:03 UTC (rev 280585)
+++ trunk/Source/WebCore/ChangeLog	2021-08-03 07:38:08 UTC (rev 280586)
@@ -1,3 +1,17 @@
+2021-08-03  Rob Buis  <[email protected]>
+
+        Check that shadow root is connected in invalidateStyleAfterStyleSheetChange
+        https://bugs.webkit.org/show_bug.cgi?id=227383
+
+        Reviewed by Antti Koivisto.
+
+        Check that shadow root is connected in invalidateStyleAfterStyleSheetChange.
+
+        Test: fast/shadow-dom/shadow-tree-removal-crash.html
+
+        * style/StyleScope.cpp:
+        (WebCore::Style::Scope::updateActiveStyleSheets):
+
 2021-08-02  Frédéric Wang  <[email protected]>
 
         Align implementation of PositionIterator::isCandidate() on Position::isCandidate()

Modified: trunk/Source/WebCore/style/StyleScope.cpp (280585 => 280586)


--- trunk/Source/WebCore/style/StyleScope.cpp	2021-08-03 06:54:03 UTC (rev 280585)
+++ trunk/Source/WebCore/style/StyleScope.cpp	2021-08-03 07:38:08 UTC (rev 280586)
@@ -524,6 +524,9 @@
 
 void Scope::invalidateStyleAfterStyleSheetChange(const StyleSheetChange& styleSheetChange)
 {
+    if (m_shadowRoot && !m_shadowRoot->isConnected())
+        return;
+
     // If we are already parsing the body and so may have significant amount of elements, put some effort into trying to avoid style recalcs.
     bool invalidateAll = !m_document.bodyOrFrameset() || m_document.hasNodesWithNonFinalStyle() || m_document.hasNodesWithMissingStyle();
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to