Title: [250501] branches/safari-608-branch
Revision
250501
Author
[email protected]
Date
2019-09-30 01:30:28 -0700 (Mon, 30 Sep 2019)

Log Message

Cherry-pick r248172. rdar://problem/55826873

    Document::resume should delay resetting of form control elements.
    https://bugs.webkit.org/show_bug.cgi?id=200376

    Reviewed by Geoffrey Garen.

    Source/WebCore:

    Delay the execution of form control element resets until the next task
    to avoid synchronously mutating DOM during page cache restoration.

    Test: fast/frames/restoring-page-cache-should-not-run-scripts.html

    * html/HTMLFormElement.cpp:
    (WebCore::HTMLFormElement::resumeFromDocumentSuspension):
    * html/HTMLInputElement.cpp:
    (WebCore::HTMLInputElement::resumeFromDocumentSuspension):

    LayoutTests:

    Added a regression test.

    * fast/frames/restoring-page-cache-should-not-run-scripts-expected.txt: Added.
    * fast/frames/restoring-page-cache-should-not-run-scripts.html: Added.
    * platform/win/TestExpectations: Skip this test on Windows since navigating to blob fails on Windows.

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

Modified Paths

Added Paths

Diff

Modified: branches/safari-608-branch/LayoutTests/ChangeLog (250500 => 250501)


--- branches/safari-608-branch/LayoutTests/ChangeLog	2019-09-30 08:30:23 UTC (rev 250500)
+++ branches/safari-608-branch/LayoutTests/ChangeLog	2019-09-30 08:30:28 UTC (rev 250501)
@@ -1,3 +1,48 @@
+2019-09-30  Babak Shafiei  <[email protected]>
+
+        Cherry-pick r248172. rdar://problem/55826873
+
+    Document::resume should delay resetting of form control elements.
+    https://bugs.webkit.org/show_bug.cgi?id=200376
+    
+    Reviewed by Geoffrey Garen.
+    
+    Source/WebCore:
+    
+    Delay the execution of form control element resets until the next task
+    to avoid synchronously mutating DOM during page cache restoration.
+    
+    Test: fast/frames/restoring-page-cache-should-not-run-scripts.html
+    
+    * html/HTMLFormElement.cpp:
+    (WebCore::HTMLFormElement::resumeFromDocumentSuspension):
+    * html/HTMLInputElement.cpp:
+    (WebCore::HTMLInputElement::resumeFromDocumentSuspension):
+    
+    LayoutTests:
+    
+    Added a regression test.
+    
+    * fast/frames/restoring-page-cache-should-not-run-scripts-expected.txt: Added.
+    * fast/frames/restoring-page-cache-should-not-run-scripts.html: Added.
+    * platform/win/TestExpectations: Skip this test on Windows since navigating to blob fails on Windows.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248172 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2019-08-02  Ryosuke Niwa  <[email protected]>
+
+            Document::resume should delay resetting of form control elements.
+            https://bugs.webkit.org/show_bug.cgi?id=200376
+
+            Reviewed by Geoffrey Garen.
+
+            Added a regression test.
+
+            * fast/frames/restoring-page-cache-should-not-run-scripts-expected.txt: Added.
+            * fast/frames/restoring-page-cache-should-not-run-scripts.html: Added.
+            * platform/win/TestExpectations: Skip this test on Windows since navigating to blob fails on Windows.
+
 2019-09-29  Alan Coon  <[email protected]>
 
         Cherry-pick r249893. rdar://problem/55825342

Added: branches/safari-608-branch/LayoutTests/fast/frames/restoring-page-cache-should-not-run-scripts-expected.txt (0 => 250501)


--- branches/safari-608-branch/LayoutTests/fast/frames/restoring-page-cache-should-not-run-scripts-expected.txt	                        (rev 0)
+++ branches/safari-608-branch/LayoutTests/fast/frames/restoring-page-cache-should-not-run-scripts-expected.txt	2019-09-30 08:30:28 UTC (rev 250501)
@@ -0,0 +1,3 @@
+This tests that pageshow event is fired before the focus elements are reset when a document in the page cache is restored.
+
+PASS

Added: branches/safari-608-branch/LayoutTests/fast/frames/restoring-page-cache-should-not-run-scripts.html (0 => 250501)


--- branches/safari-608-branch/LayoutTests/fast/frames/restoring-page-cache-should-not-run-scripts.html	                        (rev 0)
+++ branches/safari-608-branch/LayoutTests/fast/frames/restoring-page-cache-should-not-run-scripts.html	2019-09-30 08:30:28 UTC (rev 250501)
@@ -0,0 +1,73 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p>This tests that pageshow event is fired before the focus elements are reset when a document in the page cache is restored.</p>
+<div id="result"></div>
+<script>
+
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+    testRunner.setCanOpenWindows();
+    testRunner.overridePreference("WebKitUsesPageCachePreferenceKey", 1);
+}
+
+let newWindow;
+function start() {
+    result.textContent = 'Running...';
+    newWindow = window.open(URL.createObjectURL(newPage));
+}
+
+const newPage = new Blob([`<!DOCTYPE html>
+<html>
+<body>
+<p>hello, this is a test.</p>
+<form autocomplete="off"><output id="output"></output></form>
+<script>
+output.value = 'foo';
+_onload_ = () => opener.postMessage({step: 'opened'}, '*');
+_onmessage_ = () => {
+    let pageShowed = false;
+    document.addEventListener('DOMSubtreeModified', () => opener.postMessage({step: 'check', pageShowed}, '*'), {once: true});
+    window.addEventListener('pageshow', () => pageShowed = true);
+    opener.postMessage({step: 'ready'}, '*');
+}
+</scr` + `ipt>
+</body>
+</html>`], {'type': 'text/html'});
+
+const secondPage = new Blob([`<!DOCTYPE html>
+<html>
+<body _onload_="opener.postMessage({step: 'navigated'}, '*')">
+<p>second page.</p>
+</body>
+</html>`], {'type': 'text/html'});
+
+_onmessage_ = (event) => {
+    switch (event.data.step) {
+    case 'opened':
+        newWindow.postMessage('getready', '*');
+        break;
+    case 'ready':
+        newWindow.location = URL.createObjectURL(secondPage);
+        break;
+    case 'navigated':
+        newWindow.history.back();
+        break;
+    case 'check':
+        result.textContent = event.data.pageShowed ? 'PASS' : 'FAIL';
+        newWindow.close();
+        if (window.testRunner)
+            testRunner.notifyDone();
+        break;
+    }
+}
+
+if (window.testRunner)
+    start();
+else
+    document.write('<button _onclick_="start()">Start</button>');
+
+</script>
+</body>
+</html>

Modified: branches/safari-608-branch/LayoutTests/platform/win/TestExpectations (250500 => 250501)


--- branches/safari-608-branch/LayoutTests/platform/win/TestExpectations	2019-09-30 08:30:23 UTC (rev 250500)
+++ branches/safari-608-branch/LayoutTests/platform/win/TestExpectations	2019-09-30 08:30:28 UTC (rev 250501)
@@ -2295,6 +2295,7 @@
 http/tests/history/back-during-onload-triggered-by-back.html [ Skip ] # Timeout
 
 # FIXME: Navigating to blob URLs timeout
+fast/frames/restoring-page-cache-should-not-run-scripts.html [ Skip ]
 http/tests/security/mixedContent/blob-url-in-iframe.html [ Skip ]
 http/tests/security/contentSecurityPolicy/navigate-self-to-blob.html [ Skip ]
 

Modified: branches/safari-608-branch/Source/WebCore/ChangeLog (250500 => 250501)


--- branches/safari-608-branch/Source/WebCore/ChangeLog	2019-09-30 08:30:23 UTC (rev 250500)
+++ branches/safari-608-branch/Source/WebCore/ChangeLog	2019-09-30 08:30:28 UTC (rev 250501)
@@ -1,5 +1,54 @@
 2019-09-30  Babak Shafiei  <[email protected]>
 
+        Cherry-pick r248172. rdar://problem/55826873
+
+    Document::resume should delay resetting of form control elements.
+    https://bugs.webkit.org/show_bug.cgi?id=200376
+    
+    Reviewed by Geoffrey Garen.
+    
+    Source/WebCore:
+    
+    Delay the execution of form control element resets until the next task
+    to avoid synchronously mutating DOM during page cache restoration.
+    
+    Test: fast/frames/restoring-page-cache-should-not-run-scripts.html
+    
+    * html/HTMLFormElement.cpp:
+    (WebCore::HTMLFormElement::resumeFromDocumentSuspension):
+    * html/HTMLInputElement.cpp:
+    (WebCore::HTMLInputElement::resumeFromDocumentSuspension):
+    
+    LayoutTests:
+    
+    Added a regression test.
+    
+    * fast/frames/restoring-page-cache-should-not-run-scripts-expected.txt: Added.
+    * fast/frames/restoring-page-cache-should-not-run-scripts.html: Added.
+    * platform/win/TestExpectations: Skip this test on Windows since navigating to blob fails on Windows.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248172 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2019-08-02  Ryosuke Niwa  <[email protected]>
+
+            Document::resume should delay resetting of form control elements.
+            https://bugs.webkit.org/show_bug.cgi?id=200376
+
+            Reviewed by Geoffrey Garen.
+
+            Delay the execution of form control element resets until the next task
+            to avoid synchronously mutating DOM during page cache restoration.
+
+            Test: fast/frames/restoring-page-cache-should-not-run-scripts.html
+
+            * html/HTMLFormElement.cpp:
+            (WebCore::HTMLFormElement::resumeFromDocumentSuspension):
+            * html/HTMLInputElement.cpp:
+            (WebCore::HTMLInputElement::resumeFromDocumentSuspension):
+
+2019-09-30  Babak Shafiei  <[email protected]>
+
         Revert r250483. rdar://problem/55825351
 
 2019-09-29  Alan Coon  <[email protected]>

Modified: branches/safari-608-branch/Source/WebCore/html/HTMLFormElement.cpp (250500 => 250501)


--- branches/safari-608-branch/Source/WebCore/html/HTMLFormElement.cpp	2019-09-30 08:30:23 UTC (rev 250500)
+++ branches/safari-608-branch/Source/WebCore/html/HTMLFormElement.cpp	2019-09-30 08:30:28 UTC (rev 250501)
@@ -836,9 +836,9 @@
 {
     ASSERT(!shouldAutocomplete());
 
-    Ref<HTMLFormElement> protectedThis(*this);
-
-    resetAssociatedFormControlElements();
+    document().postTask([formElement = makeRef(*this)] (ScriptExecutionContext&) {
+        formElement->resetAssociatedFormControlElements();
+    });
 }
 
 void HTMLFormElement::didMoveToNewDocument(Document& oldDocument, Document& newDocument)

Modified: branches/safari-608-branch/Source/WebCore/html/HTMLInputElement.cpp (250500 => 250501)


--- branches/safari-608-branch/Source/WebCore/html/HTMLInputElement.cpp	2019-09-30 08:30:23 UTC (rev 250500)
+++ branches/safari-608-branch/Source/WebCore/html/HTMLInputElement.cpp	2019-09-30 08:30:28 UTC (rev 250501)
@@ -1486,10 +1486,12 @@
 #if ENABLE(INPUT_TYPE_COLOR)
     // <input type=color> uses prepareForDocumentSuspension to detach the color picker UI,
     // so it should not be reset when being loaded from page cache.
-    if (isColorControl()) 
+    if (isColorControl())
         return;
 #endif // ENABLE(INPUT_TYPE_COLOR)
-    reset();
+    document().postTask([inputElement = makeRef(*this)] (ScriptExecutionContext&) {
+        inputElement->reset();
+    });
 }
 
 #if ENABLE(INPUT_TYPE_COLOR)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to