Blank page except for inner iframes because pending stylesheets cause style.isNotFina...
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 Jan 2018 19:27:34 +0000 (19:27 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 Jan 2018 19:27:34 +0000 (19:27 +0000)
https://bugs.webkit.org/show_bug.cgi?id=180940
<rdar://problem/36116507>

Reviewed by Darin Adler.

Source/WebCore:

Test: http/tests/local/loading-stylesheet-import-remove.html

If a <link> referencing a stylesheet containing an @import that was still loading was removed
from the document, the loading state was never cleared. For head stylesheets this blocked
rendering permanently.

Test reduction by Justin Ridgewell.

* html/HTMLLinkElement.cpp:
(WebCore::HTMLLinkElement::removedFromAncestor):

Test if the stylesheet it loading before clearing the pointer.

LayoutTests:

* http/tests/local/loading-stylesheet-import-remove.html: Added.
* http/tests/local/loading-stylesheet-import-remove-expected.html: Added.
* http/tests/local/resources/slow-import.css: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226653 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/http/tests/local/loading-stylesheet-import-remove-expected.html [new file with mode: 0644]
LayoutTests/http/tests/local/loading-stylesheet-import-remove.html [new file with mode: 0644]
LayoutTests/http/tests/local/resources/slow-import.css [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLLinkElement.cpp

index ce19e18..272c5ac 100644 (file)
@@ -1,3 +1,15 @@
+2018-01-09  Antti Koivisto  <antti@apple.com>
+
+        Blank page except for inner iframes because pending stylesheets cause style.isNotFinal() to be true
+        https://bugs.webkit.org/show_bug.cgi?id=180940
+        <rdar://problem/36116507>
+
+        Reviewed by Darin Adler.
+
+        * http/tests/local/loading-stylesheet-import-remove.html: Added.
+        * http/tests/local/loading-stylesheet-import-remove-expected.html: Added.
+        * http/tests/local/resources/slow-import.css: Added.
+
 2018-01-09  Youenn Fablet  <youenn@apple.com>
 
         Make imported/w3c/web-platform-tests/service-workers/service-worker/fetch-canvas-tainting-cache.https.html robust to quota error
diff --git a/LayoutTests/http/tests/local/loading-stylesheet-import-remove-expected.html b/LayoutTests/http/tests/local/loading-stylesheet-import-remove-expected.html
new file mode 100644 (file)
index 0000000..429113a
--- /dev/null
@@ -0,0 +1,6 @@
+<!doctype html>
+<html>
+<body>
+<h1>CAN YOU SEE ME NOW?</h1>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/local/loading-stylesheet-import-remove.html b/LayoutTests/http/tests/local/loading-stylesheet-import-remove.html
new file mode 100644 (file)
index 0000000..26cf633
--- /dev/null
@@ -0,0 +1,19 @@
+<!doctype html>
+<html>
+<head>
+<script>
+if (window.testRunner)
+    testRunner.waitUntilDone();
+setTimeout(() => {
+    const stylesheet = document.querySelector('link');
+    stylesheet.remove();
+    if (window.testRunner)
+        testRunner.notifyDone();
+}, 100);
+</script>
+<link rel="stylesheet" href="http://127.0.0.1:8000/local/resources/slow-import.css">
+</head>
+<body>
+<h1>CAN YOU SEE ME NOW?</h1>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/local/resources/slow-import.css b/LayoutTests/http/tests/local/resources/slow-import.css
new file mode 100644 (file)
index 0000000..e362cfb
--- /dev/null
@@ -0,0 +1 @@
+@import url("../slow-css-pass.cgi");
index 43d3e4f..34757f9 100644 (file)
@@ -1,3 +1,24 @@
+2018-01-09  Antti Koivisto  <antti@apple.com>
+
+        Blank page except for inner iframes because pending stylesheets cause style.isNotFinal() to be true
+        https://bugs.webkit.org/show_bug.cgi?id=180940
+        <rdar://problem/36116507>
+
+        Reviewed by Darin Adler.
+
+        Test: http/tests/local/loading-stylesheet-import-remove.html
+
+        If a <link> referencing a stylesheet containing an @import that was still loading was removed
+        from the document, the loading state was never cleared. For head stylesheets this blocked
+        rendering permanently.
+
+        Test reduction by Justin Ridgewell.
+
+        * html/HTMLLinkElement.cpp:
+        (WebCore::HTMLLinkElement::removedFromAncestor):
+
+        Test if the stylesheet it loading before clearing the pointer.
+
 2018-01-09  Dan Bernstein  <mitz@apple.com>
 
         Removed some empty directories that were left behind
index 1584014..8404e34 100644 (file)
@@ -365,10 +365,12 @@ void HTMLLinkElement::removedFromAncestor(RemovalType removalType, ContainerNode
 
     m_linkLoader.cancelLoad();
 
+    bool wasLoading = styleSheetIsLoading();
+
     if (m_sheet)
         clearSheet();
 
-    if (styleSheetIsLoading())
+    if (wasLoading)
         removePendingSheet();
     
     if (m_styleScope) {