Title: [230513] trunk
Revision
230513
Author
wenson_hs...@apple.com
Date
2018-04-10 20:44:00 -0700 (Tue, 10 Apr 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.

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 (230512 => 230513)


--- trunk/LayoutTests/ChangeLog	2018-04-11 02:49:10 UTC (rev 230512)
+++ trunk/LayoutTests/ChangeLog	2018-04-11 03:44:00 UTC (rev 230513)
@@ -1,3 +1,16 @@
+2018-04-10  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-04-10  Nan Wang  <n_w...@apple.com>
 
         AX: Expose strong password fields on iOS

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


--- trunk/LayoutTests/editing/selection/iframe-update-selection-appearance-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/editing/selection/iframe-update-selection-appearance-expected.txt	2018-04-11 03:44:00 UTC (rev 230513)
@@ -0,0 +1,4 @@
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

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


--- trunk/LayoutTests/editing/selection/iframe-update-selection-appearance.html	                        (rev 0)
+++ trunk/LayoutTests/editing/selection/iframe-update-selection-appearance.html	2018-04-11 03:44:00 UTC (rev 230513)
@@ -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 (230512 => 230513)


--- trunk/Source/WebCore/ChangeLog	2018-04-11 02:49:10 UTC (rev 230512)
+++ trunk/Source/WebCore/ChangeLog	2018-04-11 03:44:00 UTC (rev 230513)
@@ -1,3 +1,20 @@
+2018-04-10  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.
+
+        Test: editing/selection/iframe-update-selection-appearance.html
+
+        * editing/FrameSelection.cpp:
+        (WebCore::FrameSelection::appearanceUpdateTimerFired):
+
 2018-04-10  Brent Fulgham  <bfulg...@apple.com>
 
         Unreviewed follow-up to r230468.

Modified: trunk/Source/WebCore/editing/FrameSelection.cpp (230512 => 230513)


--- trunk/Source/WebCore/editing/FrameSelection.cpp	2018-04-11 02:49:10 UTC (rev 230512)
+++ trunk/Source/WebCore/editing/FrameSelection.cpp	2018-04-11 03:44:00 UTC (rev 230513)
@@ -2441,6 +2441,7 @@
 
 void FrameSelection::appearanceUpdateTimerFired()
 {
+    Ref<Frame> protectedFrame(*m_frame);
     updateAppearanceAfterLayoutOrStyleChange();
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to