Diff
Modified: trunk/LayoutTests/ChangeLog (248171 => 248172)
--- trunk/LayoutTests/ChangeLog 2019-08-02 19:46:45 UTC (rev 248171)
+++ trunk/LayoutTests/ChangeLog 2019-08-02 19:58:50 UTC (rev 248172)
@@ -1,3 +1,16 @@
+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-08-02 Andres Gonzalez <[email protected]>
Add accessibility object method to determine whether an element is inside a table cell. Needed for iOS accessibility client.
Added: trunk/LayoutTests/fast/frames/restoring-page-cache-should-not-run-scripts-expected.txt (0 => 248172)
--- trunk/LayoutTests/fast/frames/restoring-page-cache-should-not-run-scripts-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/frames/restoring-page-cache-should-not-run-scripts-expected.txt 2019-08-02 19:58:50 UTC (rev 248172)
@@ -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: trunk/LayoutTests/fast/frames/restoring-page-cache-should-not-run-scripts.html (0 => 248172)
--- trunk/LayoutTests/fast/frames/restoring-page-cache-should-not-run-scripts.html (rev 0)
+++ trunk/LayoutTests/fast/frames/restoring-page-cache-should-not-run-scripts.html 2019-08-02 19:58:50 UTC (rev 248172)
@@ -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: trunk/LayoutTests/platform/win/TestExpectations (248171 => 248172)
--- trunk/LayoutTests/platform/win/TestExpectations 2019-08-02 19:46:45 UTC (rev 248171)
+++ trunk/LayoutTests/platform/win/TestExpectations 2019-08-02 19:58:50 UTC (rev 248172)
@@ -2296,6 +2296,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: trunk/Source/WebCore/ChangeLog (248171 => 248172)
--- trunk/Source/WebCore/ChangeLog 2019-08-02 19:46:45 UTC (rev 248171)
+++ trunk/Source/WebCore/ChangeLog 2019-08-02 19:58:50 UTC (rev 248172)
@@ -1,3 +1,20 @@
+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-08-02 Youenn Fablet <[email protected]>
[iOS] Directly use RealtimeMediaSourceCenter to compute the media capture state
Modified: trunk/Source/WebCore/html/HTMLFormElement.cpp (248171 => 248172)
--- trunk/Source/WebCore/html/HTMLFormElement.cpp 2019-08-02 19:46:45 UTC (rev 248171)
+++ trunk/Source/WebCore/html/HTMLFormElement.cpp 2019-08-02 19:58:50 UTC (rev 248172)
@@ -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: trunk/Source/WebCore/html/HTMLInputElement.cpp (248171 => 248172)
--- trunk/Source/WebCore/html/HTMLInputElement.cpp 2019-08-02 19:46:45 UTC (rev 248171)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp 2019-08-02 19:58:50 UTC (rev 248172)
@@ -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)