Title: [230087] trunk
Revision
230087
Author
wenson_hs...@apple.com
Date
2018-03-29 16:05:06 -0700 (Thu, 29 Mar 2018)

Log Message

FrameSelection::appearanceUpdateTimerFired should be robust against layout passes underneath it
https://bugs.webkit.org/show_bug.cgi?id=183395
<rdar://problem/38055732>

Reviewed by Zalan Bujtas.

Source/WebCore:

In the case where a FrameSelection updates its appearance when m_appearanceUpdateTimer is fired, the
FrameSelection's Frame is unprotected, and can be removed by arbitrary script. This patch applies a simple
mitigation by wrapping the Frame in a Ref when firing the appearance update timer, and ensuring that layout is
really up to date before calling updateAppearanceAfterLayoutOrStyleChange() from the timer.

Test: editing/selection/iframe-update-selection-appearance.html

* editing/FrameSelection.cpp:
(WebCore::FrameSelection::appearanceUpdateTimerFired):

LayoutTests:

Add a new layout test that passes if we didn't crash.

* editing/selection/iframe-update-selection-appearance-expected.txt: Added.
* editing/selection/iframe-update-selection-appearance.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (230086 => 230087)


--- trunk/LayoutTests/ChangeLog	2018-03-29 23:02:09 UTC (rev 230086)
+++ trunk/LayoutTests/ChangeLog	2018-03-29 23:05:06 UTC (rev 230087)
@@ -1,3 +1,16 @@
+2018-03-29  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        FrameSelection::appearanceUpdateTimerFired should be robust against layout passes underneath it
+        https://bugs.webkit.org/show_bug.cgi?id=183395
+        <rdar://problem/38055732>
+
+        Reviewed by Zalan Bujtas.
+
+        Add a new layout test that passes if we didn't crash.
+
+        * editing/selection/iframe-update-selection-appearance-expected.txt: Added.
+        * editing/selection/iframe-update-selection-appearance.html: Added.
+
 2018-03-29  Per Arne Vollan  <pvol...@apple.com>
 
         The test http/tests/websocket/tests/hybi/websocket-cookie-overwrite-behavior.html is failing on Windows.

Added: trunk/LayoutTests/editing/selection/iframe-update-selection-appearance-expected.txt (0 => 230087)


--- trunk/LayoutTests/editing/selection/iframe-update-selection-appearance-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/editing/selection/iframe-update-selection-appearance-expected.txt	2018-03-29 23:05:06 UTC (rev 230087)
@@ -0,0 +1,4 @@
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/editing/selection/iframe-update-selection-appearance.html (0 => 230087)


--- trunk/LayoutTests/editing/selection/iframe-update-selection-appearance.html	                        (rev 0)
+++ trunk/LayoutTests/editing/selection/iframe-update-selection-appearance.html	2018-03-29 23:05:06 UTC (rev 230087)
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <style>
+        body { -webkit-user-modify: read-only; }
+    </style>
+    <script src=""
+    <script>
+    function reconnectSubframe() {
+        document.body.appendChild(document.querySelector("iframe"));
+    }
+
+    function go() {
+        jsTestIsAsync = true;
+        if (window.finishJSTest)
+            setTimeout(() => setTimeout(finishJSTest));
+
+        getSelection().setPosition(document.body);
+
+        if (window.internals)
+            setTimeout(() => internals.setCaptionsStyleSheetOverride("* { }"));
+
+        reconnectSubframe();
+    }
+    </script>
+</head>
+
+<body _onload_="go()">
+    <iframe hidden="true"></iframe>
+    <embed type="foobar" _onbeforeload_="reconnectSubframe()"></embed>
+</body>
+</html>
\ No newline at end of file

Modified: trunk/Source/WebCore/ChangeLog (230086 => 230087)


--- trunk/Source/WebCore/ChangeLog	2018-03-29 23:02:09 UTC (rev 230086)
+++ trunk/Source/WebCore/ChangeLog	2018-03-29 23:05:06 UTC (rev 230087)
@@ -1,3 +1,21 @@
+2018-03-29  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        FrameSelection::appearanceUpdateTimerFired should be robust against layout passes underneath it
+        https://bugs.webkit.org/show_bug.cgi?id=183395
+        <rdar://problem/38055732>
+
+        Reviewed by Zalan Bujtas.
+
+        In the case where a FrameSelection updates its appearance when m_appearanceUpdateTimer is fired, the
+        FrameSelection's Frame is unprotected, and can be removed by arbitrary script. This patch applies a simple
+        mitigation by wrapping the Frame in a Ref when firing the appearance update timer, and ensuring that layout is
+        really up to date before calling updateAppearanceAfterLayoutOrStyleChange() from the timer.
+
+        Test: editing/selection/iframe-update-selection-appearance.html
+
+        * editing/FrameSelection.cpp:
+        (WebCore::FrameSelection::appearanceUpdateTimerFired):
+
 2018-03-29  Daniel Bates  <daba...@apple.com>
 
         Substitute ArchiveFactory::isArchiveMIMEType() for ArchiveFactory::isArchiveMimeType().

Modified: trunk/Source/WebCore/editing/FrameSelection.cpp (230086 => 230087)


--- trunk/Source/WebCore/editing/FrameSelection.cpp	2018-03-29 23:02:09 UTC (rev 230086)
+++ trunk/Source/WebCore/editing/FrameSelection.cpp	2018-03-29 23:05:06 UTC (rev 230087)
@@ -2441,6 +2441,10 @@
 
 void FrameSelection::appearanceUpdateTimerFired()
 {
+    Ref<Frame> protectedFrame(*m_frame);
+    if (auto* document = protectedFrame->document())
+        document->updateLayoutIgnorePendingStylesheets();
+
     updateAppearanceAfterLayoutOrStyleChange();
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to