Title: [211254] trunk
Revision
211254
Author
cdu...@apple.com
Date
2017-01-26 21:36:19 -0800 (Thu, 26 Jan 2017)

Log Message

Crash when navigating back to a page in PacheCache when one of its frames has been removed
https://bugs.webkit.org/show_bug.cgi?id=167421
<rdar://problem/30188490>

Reviewed by Darin Adler.

Source/WebCore:

Disallow page caching of a page if:
1. The main window has an opener (i.e. it was opened via window.open)
2. It has ever used window.open()

This is because allowing page caching in this case would allow such
windows to script each other even after one of them entered Page
Cache. Allowing this is dangerous and easily causes crashes.

This is a short term workaround until we find a better solution to
the problem. One issue is this workaround is that navigating back
to a page that has an opener or used window.open() will not longer
get the page from PageCache. As a result, state may be lost upon
navigating back. However, we never guarantee that pages get page
cached, and Chrome does not have a PageCache.

Tests: fast/history/page-cache-after-window-open.html
       fast/history/page-cache-back-navigation-crash.html
       fast/history/page-cache-with-opener.html

* dom/Document.cpp:
(WebCore::Document::hasEverCalledWindowOpen):
(WebCore::Document::markHasCalledWindowOpen):
* dom/Document.h:
* history/PageCache.cpp:
(WebCore::canCachePage):
* page/DOMWindow.cpp:
(WebCore::DOMWindow::createWindow):
* page/DiagnosticLoggingKeys.cpp:
(WebCore::DiagnosticLoggingKeys::hasCalledWindowOpenKey):
(WebCore::DiagnosticLoggingKeys::hasOpenerKey):
* page/DiagnosticLoggingKeys.h:
* page/Page.cpp:
(WebCore::Page::openedByWindowOpen):
* page/Page.h:
* page/Settings.in:

Source/WebKit/mac:

Add a new setting allowing layout tests to enable PageCache in a window
that has an opener, for convenience.

* WebView/WebPreferenceKeysPrivate.h:
* WebView/WebPreferences.mm:
(+[WebPreferences initialize]):
(-[WebPreferences allowsPageCacheWithWindowOpener]):
(-[WebPreferences setAllowsPageCacheWithWindowOpener:]):
* WebView/WebPreferencesPrivate.h:
* WebView/WebView.mm:
(-[WebView _preferencesChanged:]):

Source/WebKit/win:

Add a new setting allowing layout tests to enable PageCache in a window
that has an opener, for convenience.

* WebPreferenceKeysPrivate.h:
* WebPreferences.cpp:
(WebPreferences::initializeDefaultSettings):
* WebPreferences.h:

Source/WebKit2:

Add a new setting allowing layout tests to enable PageCache in a window
that has an opener, for convenience.

* Shared/WebPreferencesDefinitions.h:
* UIProcess/API/C/WKPreferences.cpp:
(WKPreferencesSetAllowsPageCacheWithWindowOpener):
(WKPreferencesGetAllowsPageCacheWithWindowOpener):
* UIProcess/API/C/WKPreferencesRefPrivate.h:
* WebProcess/InjectedBundle/InjectedBundle.cpp:
(WebKit::InjectedBundle::overrideBoolPreferenceForTestRunner):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::updatePreferences):

Tools:

Add a new setting allowing layout tests to enable PageCache in a window
that has an opener, for convenience.

* DumpRenderTree/mac/DumpRenderTree.mm:
(resetWebPreferencesToConsistentValues):
* DumpRenderTree/win/DumpRenderTree.cpp:
(resetWebPreferencesToConsistentValues):
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::resetPreferencesToConsistentValues):

LayoutTests:

* fast/history/page-cache-after-window-open-expected.txt: Added.
* fast/history/page-cache-after-window-open.html: Added.
* fast/history/page-cache-back-navigation-crash-expected.txt: Added.
* fast/history/page-cache-back-navigation-crash.html: Added.
* fast/history/page-cache-with-opener-expected.txt: Added.
* fast/history/page-cache-with-opener.html: Added.
* fast/history/resources/page-cache-window-with-iframe.html: Added.
* fast/history/resources/page-cache-window-with-opener.html: Added.
Add layout test coverage.

* editing/mac/input/unconfirmed-text-navigation-with-page-cache.html:
* fast/harness/page-cache-crash-on-data-urls.html:
* fast/harness/use-page-cache.html:
* fast/history/page-cache-after-window-open-expected.txt: Added.
* fast/history/page-cache-after-window-open.html: Added.
* fast/history/page-cache-with-opener-expected.txt: Added.
* fast/history/page-cache-with-opener.html: Added.
* fast/history/resources/page-cache-window-with-opener.html: Added.
* fast/loader/stateobjects/no-popstate-when-back-to-stateless-entry-with-page-cache.html:
* fast/loader/stateobjects/popstate-fires-with-page-cache.html:
* tiled-drawing/tiled-drawing-scroll-position-page-cache-restoration.html:
These tests relied on using window.open() to test PageCache for convenience. They now
need to override a setting in order to be allowed to do so.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (211253 => 211254)


--- trunk/LayoutTests/ChangeLog	2017-01-27 04:54:09 UTC (rev 211253)
+++ trunk/LayoutTests/ChangeLog	2017-01-27 05:36:19 UTC (rev 211254)
@@ -1,3 +1,35 @@
+2017-01-26  Chris Dumez  <cdu...@apple.com>
+
+        Crash when navigating back to a page in PacheCache when one of its frames has been removed
+        https://bugs.webkit.org/show_bug.cgi?id=167421
+        <rdar://problem/30188490>
+
+        Reviewed by Darin Adler.
+
+        * fast/history/page-cache-after-window-open-expected.txt: Added.
+        * fast/history/page-cache-after-window-open.html: Added.
+        * fast/history/page-cache-back-navigation-crash-expected.txt: Added.
+        * fast/history/page-cache-back-navigation-crash.html: Added.
+        * fast/history/page-cache-with-opener-expected.txt: Added.
+        * fast/history/page-cache-with-opener.html: Added.
+        * fast/history/resources/page-cache-window-with-iframe.html: Added.
+        * fast/history/resources/page-cache-window-with-opener.html: Added.
+        Add layout test coverage.
+
+        * editing/mac/input/unconfirmed-text-navigation-with-page-cache.html:
+        * fast/harness/page-cache-crash-on-data-urls.html:
+        * fast/harness/use-page-cache.html:
+        * fast/history/page-cache-after-window-open-expected.txt: Added.
+        * fast/history/page-cache-after-window-open.html: Added.
+        * fast/history/page-cache-with-opener-expected.txt: Added.
+        * fast/history/page-cache-with-opener.html: Added.
+        * fast/history/resources/page-cache-window-with-opener.html: Added.
+        * fast/loader/stateobjects/no-popstate-when-back-to-stateless-entry-with-page-cache.html:
+        * fast/loader/stateobjects/popstate-fires-with-page-cache.html:
+        * tiled-drawing/tiled-drawing-scroll-position-page-cache-restoration.html:
+        These tests relied on using window.open() to test PageCache for convenience. They now
+        need to override a setting in order to be allowed to do so.
+
 2017-01-26  Youenn Fablet  <youe...@gmail.com>
 
         [WebRTC] Add a LibWebRTC mock for testing

Modified: trunk/LayoutTests/editing/mac/input/unconfirmed-text-navigation-with-page-cache.html (211253 => 211254)


--- trunk/LayoutTests/editing/mac/input/unconfirmed-text-navigation-with-page-cache.html	2017-01-27 04:54:09 UTC (rev 211253)
+++ trunk/LayoutTests/editing/mac/input/unconfirmed-text-navigation-with-page-cache.html	2017-01-27 05:36:19 UTC (rev 211254)
@@ -10,6 +10,7 @@
 if (window.testRunner) {
     testRunner.setCanOpenWindows();
     testRunner.overridePreference("WebKitUsesPageCachePreferenceKey", 1);
+    testRunner.overridePreference("WebKitAllowsPageCacheWithWindowOpenerKey", 1);
 }
 
 // Window we will be controlling.

Modified: trunk/LayoutTests/fast/harness/page-cache-crash-on-data-urls.html (211253 => 211254)


--- trunk/LayoutTests/fast/harness/page-cache-crash-on-data-urls.html	2017-01-27 04:54:09 UTC (rev 211253)
+++ trunk/LayoutTests/fast/harness/page-cache-crash-on-data-urls.html	2017-01-27 05:36:19 UTC (rev 211254)
@@ -22,6 +22,7 @@
         testRunner.waitUntilDone();
         testRunner.setCanOpenWindows();
         testRunner.overridePreference("WebKitUsesPageCachePreferenceKey", 1);
+        testRunner.overridePreference("WebKitAllowsPageCacheWithWindowOpenerKey", 1);
     }
     log("open page with data urls");
     window.open("resources/cached-page-with-data-urls.html");

Modified: trunk/LayoutTests/fast/harness/use-page-cache.html (211253 => 211254)


--- trunk/LayoutTests/fast/harness/use-page-cache.html	2017-01-27 04:54:09 UTC (rev 211253)
+++ trunk/LayoutTests/fast/harness/use-page-cache.html	2017-01-27 05:36:19 UTC (rev 211254)
@@ -28,6 +28,7 @@
         testRunner.waitUntilDone();
         testRunner.setCanOpenWindows();
         testRunner.overridePreference("WebKitUsesPageCachePreferenceKey", 1);
+        testRunner.overridePreference("WebKitAllowsPageCacheWithWindowOpenerKey", 1);
     }
     log("open page-1");
     window.open("resources/cached-page-1.html");

Added: trunk/LayoutTests/fast/history/page-cache-after-window-open-expected.txt (0 => 211254)


--- trunk/LayoutTests/fast/history/page-cache-after-window-open-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/history/page-cache-after-window-open-expected.txt	2017-01-27 05:36:19 UTC (rev 211254)
@@ -0,0 +1,11 @@
+Tests that a page that has called window.open() does not go into the page cache.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+pageshow - not from cache
+PASS Page was not restored from page cache
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/history/page-cache-after-window-open.html (0 => 211254)


--- trunk/LayoutTests/fast/history/page-cache-after-window-open.html	                        (rev 0)
+++ trunk/LayoutTests/fast/history/page-cache-after-window-open.html	2017-01-27 05:36:19 UTC (rev 211254)
@@ -0,0 +1,52 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<script>
+description('Tests that a page that has called window.open() does not go into the page cache.');
+window.jsTestIsAsync = true;
+
+if (window.testRunner) {
+    testRunner.overridePreference("WebKitUsesPageCachePreferenceKey", 1);
+    testRunner.setCanOpenWindows();
+}
+
+window.addEventListener("pageshow", function(event) {
+    debug("pageshow - " + (event.persisted ? "" : "not ") + "from cache");
+
+    if (!window.sessionStorage.page_cache_after_window_open_test_started)
+        return;
+
+    delete window.sessionStorage.page_cache_after_window_open_test_started;
+
+    if (event.persisted)
+        testFailed("Page did enter and was restored from the page cache");
+    else
+        testPassed("Page was not restored from page cache");
+
+    finishJSTest();
+}, false);
+
+window.addEventListener("pagehide", function(event) {
+    debug("pagehide - " + (event.persisted ? "" : "not ") + "entering cache");
+    if (event.persisted) {
+        testFailed("Page entered the page cache.");
+        finishJSTest();
+    }
+}, false);
+
+window.addEventListener('load', function() {
+    newWindow = open("about:blank", "one");
+    otherWindowDocument = newWindow.document;
+
+    setTimeout(function() {
+        // Force a back navigation back to this page.
+        window.sessionStorage.page_cache_after_window_open_test_started = true;
+        window.location.href = ""
+    }, 0);
+}, false);
+
+</script>
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/fast/history/page-cache-back-navigation-crash-expected.txt (0 => 211254)


--- trunk/LayoutTests/fast/history/page-cache-back-navigation-crash-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/history/page-cache-back-navigation-crash-expected.txt	2017-01-27 05:36:19 UTC (rev 211254)
@@ -0,0 +1,9 @@
+Tests that removing a frame in a detached document after navigation does not cause a crash on navigating back
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/history/page-cache-back-navigation-crash.html (0 => 211254)


--- trunk/LayoutTests/fast/history/page-cache-back-navigation-crash.html	                        (rev 0)
+++ trunk/LayoutTests/fast/history/page-cache-back-navigation-crash.html	2017-01-27 05:36:19 UTC (rev 211254)
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<script>
+description('Tests that removing a frame in a detached document after navigation does not cause a crash on navigating back');
+window.jsTestIsAsync = true;
+
+if (window.testRunner) {
+    testRunner.overridePreference("WebKitUsesPageCachePreferenceKey", 1);
+    testRunner.setCanOpenWindows();
+}
+
+function removeFrameInChild()
+{
+    setTimeout(function() {
+        testFrame.remove();
+    }, 0);
+}
+
+window.addEventListener('load', function() {
+    newWindow = open("resources/page-cache-window-with-iframe.html", "one");
+    newWindow._onload_ = function () {
+        newWindow._onload_ = null;
+        otherWindowDocument = newWindow.document;
+        testFrame = otherWindowDocument.getElementsByTagName("iframe")[0];
+    }
+}, false);
+</script>
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/fast/history/page-cache-with-opener-expected.txt (0 => 211254)


--- trunk/LayoutTests/fast/history/page-cache-with-opener-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/history/page-cache-with-opener-expected.txt	2017-01-27 05:36:19 UTC (rev 211254)
@@ -0,0 +1,10 @@
+Tests that a page that has a window opener does not go into the page cache.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS Page was not restored from page cache
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/history/page-cache-with-opener.html (0 => 211254)


--- trunk/LayoutTests/fast/history/page-cache-with-opener.html	                        (rev 0)
+++ trunk/LayoutTests/fast/history/page-cache-with-opener.html	2017-01-27 05:36:19 UTC (rev 211254)
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<script>
+description('Tests that a page that has a window opener does not go into the page cache.');
+window.jsTestIsAsync = true;
+
+if (window.testRunner) {
+    testRunner.overridePreference("WebKitUsesPageCachePreferenceKey", 1);
+    testRunner.setCanOpenWindows();
+}
+
+window.addEventListener('load', function() {
+    newWindow = open("resources/page-cache-window-with-opener.html", "one");
+    otherWindowDocument = newWindow.document;
+}, false);
+</script>
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/fast/history/resources/page-cache-window-with-iframe.html (0 => 211254)


--- trunk/LayoutTests/fast/history/resources/page-cache-window-with-iframe.html	                        (rev 0)
+++ trunk/LayoutTests/fast/history/resources/page-cache-window-with-iframe.html	2017-01-27 05:36:19 UTC (rev 211254)
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<iframe src=""
+<script>
+if (window.testRunner)
+    testRunner.overridePreference("WebKitUsesPageCachePreferenceKey", 1);
+
+window.addEventListener("pageshow", function(event) {
+    debug("pageshow - " + (event.persisted ? "" : "not ") + "from cache");
+
+    if (!window.sessionStorage.page_cache_window_iframe_removed_test_started)
+        return;
+
+    delete window.sessionStorage.page_cache_window_iframe_removed_test_started;
+
+    setTimeout(function() {
+        window.opener.finishJSTest();
+    }, 0);
+}, false);
+
+window.addEventListener("pagehide", function(event) {
+    debug("pagehide - " + (event.persisted ? "" : "not ") + "entering cache");
+}, false);
+
+window.addEventListener('load', function() {
+    setTimeout(function() {
+         window.opener.removeFrameInChild();
+        // Force a back navigation back to this page.
+        window.sessionStorage.page_cache_window_iframe_removed_test_started = true;
+        window.location.href = ""
+    }, 0);
+}, false);
+</script>
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/fast/history/resources/page-cache-window-with-opener.html (0 => 211254)


--- trunk/LayoutTests/fast/history/resources/page-cache-window-with-opener.html	                        (rev 0)
+++ trunk/LayoutTests/fast/history/resources/page-cache-window-with-opener.html	2017-01-27 05:36:19 UTC (rev 211254)
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<script>
+if (window.testRunner)
+    testRunner.overridePreference("WebKitUsesPageCachePreferenceKey", 1);
+
+window.addEventListener("pageshow", function(event) {
+    debug("pageshow - " + (event.persisted ? "" : "not ") + "from cache");
+
+    if (!window.sessionStorage.page_cache_window_opener_test_started)
+        return;
+
+    delete window.sessionStorage.page_cache_window_opener_test_started;
+
+    if (event.persisted)
+        window.opener.testFailed("Page did enter and was restored from the page cache");
+    else
+        window.opener.testPassed("Page was not restored from page cache");
+
+    window.opener.finishJSTest();
+}, false);
+
+window.addEventListener("pagehide", function(event) {
+    debug("pagehide - " + (event.persisted ? "" : "not ") + "entering cache");
+    if (event.persisted) {
+        window.opener.testFailed("Page entered the page cache.");
+        window.opener.finishJSTest();
+    }
+}, false);
+
+window.addEventListener('load', function() {
+    setTimeout(function() {
+        // Force a back navigation back to this page.
+        window.sessionStorage.page_cache_window_opener_test_started = true;
+        window.location.href = ""
+    }, 0);
+}, false);
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/LayoutTests/fast/loader/stateobjects/no-popstate-when-back-to-stateless-entry-with-page-cache.html (211253 => 211254)


--- trunk/LayoutTests/fast/loader/stateobjects/no-popstate-when-back-to-stateless-entry-with-page-cache.html	2017-01-27 04:54:09 UTC (rev 211253)
+++ trunk/LayoutTests/fast/loader/stateobjects/no-popstate-when-back-to-stateless-entry-with-page-cache.html	2017-01-27 05:36:19 UTC (rev 211254)
@@ -14,6 +14,7 @@
     if (window.testRunner) {
         testRunner.setCanOpenWindows();
         testRunner.overridePreference('WebKitUsesPageCachePreferenceKey', 1);
+        testRunner.overridePreference("WebKitAllowsPageCacheWithWindowOpenerKey", 1);
     }
     testWindow = window.open('resources/no-popstate-when-back-to-stateless-entry-1.html');
     if (!testWindow)
@@ -62,4 +63,4 @@
 var jsTestIsAsync = true;
 </script>
 <script src=""
-</html>
\ No newline at end of file
+</html>

Modified: trunk/LayoutTests/fast/loader/stateobjects/popstate-fires-with-page-cache.html (211253 => 211254)


--- trunk/LayoutTests/fast/loader/stateobjects/popstate-fires-with-page-cache.html	2017-01-27 04:54:09 UTC (rev 211253)
+++ trunk/LayoutTests/fast/loader/stateobjects/popstate-fires-with-page-cache.html	2017-01-27 05:36:19 UTC (rev 211254)
@@ -14,6 +14,7 @@
     if (window.testRunner) {
         testRunner.setCanOpenWindows();
         testRunner.overridePreference('WebKitUsesPageCachePreferenceKey', 1);
+        testRunner.overridePreference("WebKitAllowsPageCacheWithWindowOpenerKey", 1);
     }
     testWindow = window.open('resources/popstate-fires-with-page-cache-1.html');
     if (!testWindow)

Modified: trunk/LayoutTests/tiled-drawing/tiled-drawing-scroll-position-page-cache-restoration.html (211253 => 211254)


--- trunk/LayoutTests/tiled-drawing/tiled-drawing-scroll-position-page-cache-restoration.html	2017-01-27 04:54:09 UTC (rev 211253)
+++ trunk/LayoutTests/tiled-drawing/tiled-drawing-scroll-position-page-cache-restoration.html	2017-01-27 05:36:19 UTC (rev 211254)
@@ -7,6 +7,7 @@
             testRunner.waitUntilDone();
             testRunner.setCanOpenWindows();
             testRunner.overridePreference("WebKitUsesPageCachePreferenceKey", 1);
+            testRunner.overridePreference("WebKitAllowsPageCacheWithWindowOpenerKey", 1);
         }
 
         window.finishedTest = function (layerTree)

Modified: trunk/Source/WebCore/ChangeLog (211253 => 211254)


--- trunk/Source/WebCore/ChangeLog	2017-01-27 04:54:09 UTC (rev 211253)
+++ trunk/Source/WebCore/ChangeLog	2017-01-27 05:36:19 UTC (rev 211254)
@@ -1,3 +1,47 @@
+2017-01-26  Chris Dumez  <cdu...@apple.com>
+
+        Crash when navigating back to a page in PacheCache when one of its frames has been removed
+        https://bugs.webkit.org/show_bug.cgi?id=167421
+        <rdar://problem/30188490>
+
+        Reviewed by Darin Adler.
+
+        Disallow page caching of a page if:
+        1. The main window has an opener (i.e. it was opened via window.open)
+        2. It has ever used window.open()
+
+        This is because allowing page caching in this case would allow such
+        windows to script each other even after one of them entered Page
+        Cache. Allowing this is dangerous and easily causes crashes.
+
+        This is a short term workaround until we find a better solution to
+        the problem. One issue is this workaround is that navigating back
+        to a page that has an opener or used window.open() will not longer
+        get the page from PageCache. As a result, state may be lost upon
+        navigating back. However, we never guarantee that pages get page
+        cached, and Chrome does not have a PageCache.
+
+        Tests: fast/history/page-cache-after-window-open.html
+               fast/history/page-cache-back-navigation-crash.html
+               fast/history/page-cache-with-opener.html
+
+        * dom/Document.cpp:
+        (WebCore::Document::hasEverCalledWindowOpen):
+        (WebCore::Document::markHasCalledWindowOpen):
+        * dom/Document.h:
+        * history/PageCache.cpp:
+        (WebCore::canCachePage):
+        * page/DOMWindow.cpp:
+        (WebCore::DOMWindow::createWindow):
+        * page/DiagnosticLoggingKeys.cpp:
+        (WebCore::DiagnosticLoggingKeys::hasCalledWindowOpenKey):
+        (WebCore::DiagnosticLoggingKeys::hasOpenerKey):
+        * page/DiagnosticLoggingKeys.h:
+        * page/Page.cpp:
+        (WebCore::Page::openedByWindowOpen):
+        * page/Page.h:
+        * page/Settings.in:
+
 2017-01-26  Youenn Fablet  <youe...@gmail.com>
 
         [WebRTC] Add a LibWebRTC mock for testing

Modified: trunk/Source/WebCore/dom/Document.cpp (211253 => 211254)


--- trunk/Source/WebCore/dom/Document.cpp	2017-01-27 04:54:09 UTC (rev 211253)
+++ trunk/Source/WebCore/dom/Document.cpp	2017-01-27 05:36:19 UTC (rev 211254)
@@ -835,6 +835,23 @@
     return documentElement() && documentElement()->hasTagName(htmlTag) && documentElement()->hasAttributeWithoutSynchronization(manifestAttr);
 }
 
+bool Document::hasEverCalledWindowOpen() const
+{
+    auto& topDocument = this->topDocument();
+    if (&topDocument == this)
+        return m_hasEverCalledWindowOpen;
+    return topDocument.hasEverCalledWindowOpen();
+}
+
+void Document::markHasCalledWindowOpen()
+{
+    auto& topDocument = this->topDocument();
+    if (&topDocument == this)
+        m_hasEverCalledWindowOpen = true;
+    else
+        topDocument.markHasCalledWindowOpen();
+}
+
 DocumentType* Document::doctype() const
 {
     for (Node* node = firstChild(); node; node = node->nextSibling()) {

Modified: trunk/Source/WebCore/dom/Document.h (211253 => 211254)


--- trunk/Source/WebCore/dom/Document.h	2017-01-27 04:54:09 UTC (rev 211253)
+++ trunk/Source/WebCore/dom/Document.h	2017-01-27 05:36:19 UTC (rev 211254)
@@ -367,6 +367,9 @@
     WEBCORE_EXPORT bool hasFocus() const;
 
     bool hasManifest() const;
+
+    bool hasEverCalledWindowOpen() const;
+    void markHasCalledWindowOpen();
     
     WEBCORE_EXPORT ExceptionOr<Ref<Element>> createElementForBindings(const AtomicString& tagName);
     WEBCORE_EXPORT Ref<DocumentFragment> createDocumentFragment();
@@ -1469,6 +1472,7 @@
     bool m_bParsing;
 
     Timer m_styleRecalcTimer;
+    bool m_hasEverCalledWindowOpen { false };
     bool m_pendingStyleRecalcShouldForce;
     bool m_inStyleRecalc;
     bool m_closeAfterStyleRecalc;

Modified: trunk/Source/WebCore/history/PageCache.cpp (211253 => 211254)


--- trunk/Source/WebCore/history/PageCache.cpp	2017-01-27 04:54:09 UTC (rev 211253)
+++ trunk/Source/WebCore/history/PageCache.cpp	2017-01-27 05:36:19 UTC (rev 211254)
@@ -191,6 +191,19 @@
 
     DiagnosticLoggingClient& diagnosticLoggingClient = page.diagnosticLoggingClient();
     bool isCacheable = canCacheFrame(page.mainFrame(), diagnosticLoggingClient, indentLevel + 1);
+
+    if (page.openedByWindowOpen() && !page.settings().allowsPageCacheWithWindowOpener()) {
+        PCLOG("   -Page has been opened via window.open()");
+        logPageCacheFailureDiagnosticMessage(diagnosticLoggingClient, DiagnosticLoggingKeys::hasOpenerKey());
+        isCacheable = false;
+    }
+
+    auto* topDocument = page.mainFrame().document();
+    if (topDocument && topDocument->hasEverCalledWindowOpen()) {
+        PCLOG("   -Page has called window.open()");
+        logPageCacheFailureDiagnosticMessage(diagnosticLoggingClient, DiagnosticLoggingKeys::hasCalledWindowOpenKey());
+        isCacheable = false;
+    }
     
     if (!page.settings().usesPageCache() || page.isResourceCachingDisabled()) {
         PCLOG("   -Page settings says b/f cache disabled");

Modified: trunk/Source/WebCore/page/DOMWindow.cpp (211253 => 211254)


--- trunk/Source/WebCore/page/DOMWindow.cpp	2017-01-27 04:54:09 UTC (rev 211253)
+++ trunk/Source/WebCore/page/DOMWindow.cpp	2017-01-27 05:36:19 UTC (rev 211254)
@@ -2195,6 +2195,8 @@
 
     newFrame->loader().setOpener(&openerFrame);
     newFrame->page()->setOpenedByDOM();
+    if (auto* openerDocument = openerFrame.document())
+        openerDocument->markHasCalledWindowOpen();
 
     if (newFrame->document()->domWindow()->isInsecureScriptAccess(activeWindow, completedURL))
         return newFrame;

Modified: trunk/Source/WebCore/page/DiagnosticLoggingKeys.cpp (211253 => 211254)


--- trunk/Source/WebCore/page/DiagnosticLoggingKeys.cpp	2017-01-27 04:54:09 UTC (rev 211253)
+++ trunk/Source/WebCore/page/DiagnosticLoggingKeys.cpp	2017-01-27 05:36:19 UTC (rev 211254)
@@ -663,6 +663,16 @@
     return ASCIILiteral("font");
 }
 
+String DiagnosticLoggingKeys::hasCalledWindowOpenKey()
+{
+    return ASCIILiteral("hasCalledWindowOpen");
+}
+
+String DiagnosticLoggingKeys::hasOpenerKey()
+{
+    return ASCIILiteral("hasOpener");
+}
+
 String DiagnosticLoggingKeys::prunedDueToMemoryPressureKey()
 {
     return ASCIILiteral("pruned.memoryPressure");

Modified: trunk/Source/WebCore/page/DiagnosticLoggingKeys.h (211253 => 211254)


--- trunk/Source/WebCore/page/DiagnosticLoggingKeys.h	2017-01-27 04:54:09 UTC (rev 211253)
+++ trunk/Source/WebCore/page/DiagnosticLoggingKeys.h	2017-01-27 05:36:19 UTC (rev 211254)
@@ -55,6 +55,8 @@
     WEBCORE_EXPORT static String entryWronglyNotWarmedUpKey();
     static String expiredKey();
     static String fontKey();
+    static String hasCalledWindowOpenKey();
+    static String hasOpenerKey();
     static String hasPluginsKey();
     static String httpsNoStoreKey();
     static String imageKey();

Modified: trunk/Source/WebCore/page/Page.cpp (211253 => 211254)


--- trunk/Source/WebCore/page/Page.cpp	2017-01-27 04:54:09 UTC (rev 211253)
+++ trunk/Source/WebCore/page/Page.cpp	2017-01-27 05:36:19 UTC (rev 211254)
@@ -467,6 +467,17 @@
     m_openedByDOM = true;
 }
 
+bool Page::openedByWindowOpen() const
+{
+    auto* document = m_mainFrame->document();
+    if (!document)
+        return false;
+    auto* window = document->domWindow();
+    if (!window)
+        return false;
+    return window->opener();
+}
+
 void Page::goToItem(HistoryItem& item, FrameLoadType type)
 {
     // stopAllLoaders may end up running onload handlers, which could cause further history traversals that may lead to the passed in HistoryItem

Modified: trunk/Source/WebCore/page/Page.h (211253 => 211254)


--- trunk/Source/WebCore/page/Page.h	2017-01-27 04:54:09 UTC (rev 211253)
+++ trunk/Source/WebCore/page/Page.h	2017-01-27 05:36:19 UTC (rev 211254)
@@ -179,6 +179,8 @@
     bool openedByDOM() const;
     void setOpenedByDOM();
 
+    bool openedByWindowOpen() const;
+
     WEBCORE_EXPORT void goToItem(HistoryItem&, FrameLoadType);
 
     WEBCORE_EXPORT void setGroupName(const String&);

Modified: trunk/Source/WebCore/page/Settings.in (211253 => 211254)


--- trunk/Source/WebCore/page/Settings.in	2017-01-27 04:54:09 UTC (rev 211253)
+++ trunk/Source/WebCore/page/Settings.in	2017-01-27 05:36:19 UTC (rev 211254)
@@ -285,3 +285,5 @@
 shouldSuppressKeyboardInputDuringProvisionalNavigation initial=false
 
 langAttributeAwareFormControlUIEnabled initial=false
+
+allowsPageCacheWithWindowOpener initial=false

Modified: trunk/Source/WebKit/mac/ChangeLog (211253 => 211254)


--- trunk/Source/WebKit/mac/ChangeLog	2017-01-27 04:54:09 UTC (rev 211253)
+++ trunk/Source/WebKit/mac/ChangeLog	2017-01-27 05:36:19 UTC (rev 211254)
@@ -1,3 +1,23 @@
+2017-01-26  Chris Dumez  <cdu...@apple.com>
+
+        Crash when navigating back to a page in PacheCache when one of its frames has been removed
+        https://bugs.webkit.org/show_bug.cgi?id=167421
+        <rdar://problem/30188490>
+
+        Reviewed by Darin Adler.
+
+        Add a new setting allowing layout tests to enable PageCache in a window
+        that has an opener, for convenience.
+
+        * WebView/WebPreferenceKeysPrivate.h:
+        * WebView/WebPreferences.mm:
+        (+[WebPreferences initialize]):
+        (-[WebPreferences allowsPageCacheWithWindowOpener]):
+        (-[WebPreferences setAllowsPageCacheWithWindowOpener:]):
+        * WebView/WebPreferencesPrivate.h:
+        * WebView/WebView.mm:
+        (-[WebView _preferencesChanged:]):
+
 2017-01-26  Keith Miller  <keith_mil...@apple.com>
 
         classInfo should take a VM so it is not materialized from the object on each call

Modified: trunk/Source/WebKit/mac/WebView/WebPreferenceKeysPrivate.h (211253 => 211254)


--- trunk/Source/WebKit/mac/WebView/WebPreferenceKeysPrivate.h	2017-01-27 04:54:09 UTC (rev 211253)
+++ trunk/Source/WebKit/mac/WebView/WebPreferenceKeysPrivate.h	2017-01-27 05:36:19 UTC (rev 211254)
@@ -83,6 +83,7 @@
 #define WebAutomaticSpellingCorrectionEnabled @"WebAutomaticSpellingCorrectionEnabled"
 #define WebKitDOMPasteAllowedPreferenceKey @"WebKitDOMPasteAllowedPreferenceKey"
 #define WebKitUsesPageCachePreferenceKey @"WebKitUsesPageCachePreferenceKey"
+#define WebKitAllowsPageCacheWithWindowOpenerKey @"WebKitAllowsPageCacheWithWindowOpenerKey"
 #define WebKitPageCacheSupportsPluginsPreferenceKey @"WebKitPageCacheSupportsPluginsPreferenceKey"
 #define WebKitFTPDirectoryTemplatePath @"WebKitFTPDirectoryTemplatePath"
 #define WebKitForceFTPDirectoryListings @"WebKitForceFTPDirectoryListings"

Modified: trunk/Source/WebKit/mac/WebView/WebPreferences.mm (211253 => 211254)


--- trunk/Source/WebKit/mac/WebView/WebPreferences.mm	2017-01-27 04:54:09 UTC (rev 211253)
+++ trunk/Source/WebKit/mac/WebView/WebPreferences.mm	2017-01-27 05:36:19 UTC (rev 211254)
@@ -478,6 +478,7 @@
         [NSNumber numberWithBool:NO],   WebKitDOMPasteAllowedPreferenceKey,
 #endif
         [NSNumber numberWithBool:YES],  WebKitUsesPageCachePreferenceKey,
+        [NSNumber numberWithBool:NO],   WebKitAllowsPageCacheWithWindowOpenerKey,
         [NSNumber numberWithInt:cacheModelForMainBundle()], WebKitCacheModelPreferenceKey,
         [NSNumber numberWithBool:YES],  WebKitPageCacheSupportsPluginsPreferenceKey,
         [NSNumber numberWithBool:NO],   WebKitDeveloperExtrasEnabledPreferenceKey,
@@ -2445,6 +2446,16 @@
 
 }
 
+- (BOOL)allowsPageCacheWithWindowOpener
+{
+    return [self _boolValueForKey:WebKitAllowsPageCacheWithWindowOpenerKey];
+}
+
+- (void)setAllowsPageCacheWithWindowOpener:(BOOL)flag
+{
+    [self _setBoolValue:flag forKey:WebKitAllowsPageCacheWithWindowOpenerKey];
+}
+
 #if PLATFORM(IOS)
 - (void)_invalidateCachedPreferences
 {

Modified: trunk/Source/WebKit/mac/WebView/WebPreferencesPrivate.h (211253 => 211254)


--- trunk/Source/WebKit/mac/WebView/WebPreferencesPrivate.h	2017-01-27 04:54:09 UTC (rev 211253)
+++ trunk/Source/WebKit/mac/WebView/WebPreferencesPrivate.h	2017-01-27 05:36:19 UTC (rev 211254)
@@ -298,6 +298,9 @@
 - (NSString *)pictographFontFamily;
 - (void)setPictographFontFamily:(NSString *)family;
 
+- (BOOL)allowsPageCacheWithWindowOpener;
+- (void)setAllowsPageCacheWithWindowOpener:(BOOL)flag;
+
 - (BOOL)pageCacheSupportsPlugins;
 - (void)setPageCacheSupportsPlugins:(BOOL)flag;
 

Modified: trunk/Source/WebKit/mac/WebView/WebView.mm (211253 => 211254)


--- trunk/Source/WebKit/mac/WebView/WebView.mm	2017-01-27 04:54:09 UTC (rev 211253)
+++ trunk/Source/WebKit/mac/WebView/WebView.mm	2017-01-27 05:36:19 UTC (rev 211254)
@@ -2670,6 +2670,7 @@
     settings.setTextDirectionSubmenuInclusionBehavior(core([preferences textDirectionSubmenuInclusionBehavior]));
     settings.setDOMPasteAllowed([preferences isDOMPasteAllowed]);
     settings.setUsesPageCache([self usesPageCache]);
+    settings.setAllowsPageCacheWithWindowOpener([preferences allowsPageCacheWithWindowOpener]);
     settings.setPageCacheSupportsPlugins([preferences pageCacheSupportsPlugins]);
     settings.setBackForwardCacheExpirationInterval([preferences _backForwardCacheExpirationInterval]);
 

Modified: trunk/Source/WebKit/win/ChangeLog (211253 => 211254)


--- trunk/Source/WebKit/win/ChangeLog	2017-01-27 04:54:09 UTC (rev 211253)
+++ trunk/Source/WebKit/win/ChangeLog	2017-01-27 05:36:19 UTC (rev 211254)
@@ -1,3 +1,19 @@
+2017-01-26  Chris Dumez  <cdu...@apple.com>
+
+        Crash when navigating back to a page in PacheCache when one of its frames has been removed
+        https://bugs.webkit.org/show_bug.cgi?id=167421
+        <rdar://problem/30188490>
+
+        Reviewed by Darin Adler.
+
+        Add a new setting allowing layout tests to enable PageCache in a window
+        that has an opener, for convenience.
+
+        * WebPreferenceKeysPrivate.h:
+        * WebPreferences.cpp:
+        (WebPreferences::initializeDefaultSettings):
+        * WebPreferences.h:
+
 2017-01-26  Keith Miller  <keith_mil...@apple.com>
 
         classInfo should take a VM so it is not materialized from the object on each call

Modified: trunk/Source/WebKit/win/Interfaces/IWebPreferencesPrivate.idl (211253 => 211254)


--- trunk/Source/WebKit/win/Interfaces/IWebPreferencesPrivate.idl	2017-01-27 04:54:09 UTC (rev 211253)
+++ trunk/Source/WebKit/win/Interfaces/IWebPreferencesPrivate.idl	2017-01-27 05:36:19 UTC (rev 211254)
@@ -91,6 +91,9 @@
     HRESULT experimentalNotificationsEnabled([out, retval] BOOL *enabled);
     HRESULT setExperimentalNotificationsEnabled([in] BOOL enabled);
 
+    HRESULT allowsPageCacheWithWindowOpener([out, retval] BOOL* usesPageCache);
+    HRESULT setAllowsPageCacheWithWindowOpener([in] BOOL usesPageCache);
+
     HRESULT setShouldUseHighResolutionTimers([in] BOOL useHighResolutionTimers);
     HRESULT shouldUseHighResolutionTimers([out, retval] BOOL* useHighResolutionTimers);
 

Modified: trunk/Source/WebKit/win/WebPreferenceKeysPrivate.h (211253 => 211254)


--- trunk/Source/WebKit/win/WebPreferenceKeysPrivate.h	2017-01-27 04:54:09 UTC (rev 211253)
+++ trunk/Source/WebKit/win/WebPreferenceKeysPrivate.h	2017-01-27 05:36:19 UTC (rev 211254)
@@ -68,6 +68,7 @@
 #define WebKitIconDatabaseLocationKey "WebKitIconDatabaseLocation"
 #define WebKitIconDatabaseEnabledPreferenceKey "WebKitIconDatabaseEnabled"
 #define WebKitUsesPageCachePreferenceKey "WebKitUsesPageCachePreferenceKey"
+#define WebKitAllowsPageCacheWithWindowOpenerKey "WebKitAllowsPageCacheWithWindowOpenerKey"
 #define WebKitCacheModelPreferenceKey "WebKitCacheModelPreferenceKey"
 #define WebKitLocalStorageDatabasePathPreferenceKey "WebKitLocalStorageDatabasePath"
 #define WebKitHyperlinkAuditingEnabledPreferenceKey "WebKitHyperlinkAuditingEnabled"

Modified: trunk/Source/WebKit/win/WebPreferences.cpp (211253 => 211254)


--- trunk/Source/WebKit/win/WebPreferences.cpp	2017-01-27 04:54:09 UTC (rev 211253)
+++ trunk/Source/WebKit/win/WebPreferences.cpp	2017-01-27 05:36:19 UTC (rev 211254)
@@ -262,6 +262,7 @@
     CFDictionaryAddValue(defaults, CFSTR(WebGrammarCheckingEnabledPreferenceKey), kCFBooleanFalse);
     CFDictionaryAddValue(defaults, CFSTR(AllowContinuousSpellCheckingPreferenceKey), kCFBooleanTrue);
     CFDictionaryAddValue(defaults, CFSTR(WebKitUsesPageCachePreferenceKey), kCFBooleanTrue);
+    CFDictionaryAddValue(defaults, CFSTR(WebKitAllowsPageCacheWithWindowOpenerKey), kCFBooleanFalse);
     CFDictionaryAddValue(defaults, CFSTR(WebKitLocalStorageDatabasePathPreferenceKey), CFSTR(""));
 
     RetainPtr<CFStringRef> cacheModelRef = adoptCF(CFStringCreateWithFormat(0, 0, CFSTR("%d"), WebCacheModelDocumentViewer));
@@ -1606,6 +1607,20 @@
     return S_OK;
 }
 
+HRESULT WebPreferences::setAllowsPageCacheWithWindowOpener(BOOL value)
+{
+    setBoolValue(WebKitAllowsPageCacheWithWindowOpenerKey, value);
+    return S_OK;
+}
+
+HRESULT WebPreferences::allowsPageCacheWithWindowOpener(_Out_ BOOL* enabled)
+{
+    if (!enabled)
+        return E_POINTER;
+    *enabled = boolValueForKey(WebKitAllowsPageCacheWithWindowOpenerKey);
+    return S_OK;
+}
+
 HRESULT WebPreferences::setZoomsTextOnly(BOOL zoomsTextOnly)
 {
     setBoolValue(WebKitZoomsTextOnlyPreferenceKey, zoomsTextOnly);

Modified: trunk/Source/WebKit/win/WebPreferences.h (211253 => 211254)


--- trunk/Source/WebKit/win/WebPreferences.h	2017-01-27 04:54:09 UTC (rev 211253)
+++ trunk/Source/WebKit/win/WebPreferences.h	2017-01-27 05:36:19 UTC (rev 211254)
@@ -159,6 +159,8 @@
     virtual HRESULT STDMETHODCALLTYPE setLocalStorageDatabasePath(_In_ BSTR);
     virtual HRESULT STDMETHODCALLTYPE experimentalNotificationsEnabled(_Out_ BOOL*);
     virtual HRESULT STDMETHODCALLTYPE setExperimentalNotificationsEnabled(BOOL);
+    virtual HRESULT STDMETHODCALLTYPE allowsPageCacheWithWindowOpener(_Out_ BOOL*);
+    virtual HRESULT STDMETHODCALLTYPE setAllowsPageCacheWithWindowOpener(BOOL);
 
     // These two methods are no-ops, and only retained to keep
     // the Interface consistent. DO NOT USE THEM.

Modified: trunk/Source/WebKit/win/WebView.cpp (211253 => 211254)


--- trunk/Source/WebKit/win/WebView.cpp	2017-01-27 04:54:09 UTC (rev 211253)
+++ trunk/Source/WebKit/win/WebView.cpp	2017-01-27 05:36:19 UTC (rev 211254)
@@ -5404,6 +5404,11 @@
         return hr;
     settings.setExperimentalNotificationsEnabled(enabled);
 
+    hr = prefsPrivate->allowsPageCacheWithWindowOpener(&enabled);
+    if (FAILED(hr))
+        return hr;
+    settings.setAllowsPageCacheWithWindowOpener(enabled);
+
     hr = prefsPrivate->isWebSecurityEnabled(&enabled);
     if (FAILED(hr))
         return hr;

Modified: trunk/Source/WebKit2/ChangeLog (211253 => 211254)


--- trunk/Source/WebKit2/ChangeLog	2017-01-27 04:54:09 UTC (rev 211253)
+++ trunk/Source/WebKit2/ChangeLog	2017-01-27 05:36:19 UTC (rev 211254)
@@ -1,3 +1,24 @@
+2017-01-26  Chris Dumez  <cdu...@apple.com>
+
+        Crash when navigating back to a page in PacheCache when one of its frames has been removed
+        https://bugs.webkit.org/show_bug.cgi?id=167421
+        <rdar://problem/30188490>
+
+        Reviewed by Darin Adler.
+
+        Add a new setting allowing layout tests to enable PageCache in a window
+        that has an opener, for convenience.
+
+        * Shared/WebPreferencesDefinitions.h:
+        * UIProcess/API/C/WKPreferences.cpp:
+        (WKPreferencesSetAllowsPageCacheWithWindowOpener):
+        (WKPreferencesGetAllowsPageCacheWithWindowOpener):
+        * UIProcess/API/C/WKPreferencesRefPrivate.h:
+        * WebProcess/InjectedBundle/InjectedBundle.cpp:
+        (WebKit::InjectedBundle::overrideBoolPreferenceForTestRunner):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::updatePreferences):
+
 2017-01-26  Keith Miller  <keith_mil...@apple.com>
 
         classInfo should take a VM so it is not materialized from the object on each call

Modified: trunk/Source/WebKit2/Shared/WebPreferencesDefinitions.h (211253 => 211254)


--- trunk/Source/WebKit2/Shared/WebPreferencesDefinitions.h	2017-01-27 04:54:09 UTC (rev 211253)
+++ trunk/Source/WebKit2/Shared/WebPreferencesDefinitions.h	2017-01-27 05:36:19 UTC (rev 211254)
@@ -137,6 +137,7 @@
     macro(WebArchiveDebugModeEnabled, webArchiveDebugModeEnabled, Bool, bool, false, "", "") \
     macro(LocalFileContentSniffingEnabled, localFileContentSniffingEnabled, Bool, bool, false, "", "") \
     macro(UsesPageCache, usesPageCache, Bool, bool, true, "", "") \
+    macro(AllowsPageCacheWithWindowOpener, allowsPageCacheWithWindowOpener, Bool, bool, false, "", "") \
     macro(PageCacheSupportsPlugins, pageCacheSupportsPlugins, Bool, bool, true, "", "") \
     macro(AuthorAndUserStylesEnabled, authorAndUserStylesEnabled, Bool, bool, true, "", "") \
     macro(PaginateDuringLayoutEnabled, paginateDuringLayoutEnabled, Bool, bool, false, "", "") \

Modified: trunk/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp (211253 => 211254)


--- trunk/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp	2017-01-27 04:54:09 UTC (rev 211253)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp	2017-01-27 05:36:19 UTC (rev 211254)
@@ -623,6 +623,16 @@
     return toImpl(preferencesRef)->usesPageCache();
 }
 
+void WKPreferencesSetAllowsPageCacheWithWindowOpener(WKPreferencesRef preferencesRef, bool enabled)
+{
+    toImpl(preferencesRef)->setAllowsPageCacheWithWindowOpener(enabled);
+}
+
+bool WKPreferencesGetAllowsPageCacheWithWindowOpener(WKPreferencesRef preferencesRef)
+{
+    return toImpl(preferencesRef)->allowsPageCacheWithWindowOpener();
+}
+
 void WKPreferencesSetPageCacheSupportsPlugins(WKPreferencesRef preferencesRef, bool pageCacheSupportsPlugins)
 {
     toImpl(preferencesRef)->setPageCacheSupportsPlugins(pageCacheSupportsPlugins);

Modified: trunk/Source/WebKit2/UIProcess/API/C/WKPreferencesRefPrivate.h (211253 => 211254)


--- trunk/Source/WebKit2/UIProcess/API/C/WKPreferencesRefPrivate.h	2017-01-27 04:54:09 UTC (rev 211253)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPreferencesRefPrivate.h	2017-01-27 05:36:19 UTC (rev 211254)
@@ -143,6 +143,10 @@
 WK_EXPORT void WKPreferencesSetPageCacheEnabled(WKPreferencesRef preferences, bool enabled);
 WK_EXPORT bool WKPreferencesGetPageCacheEnabled(WKPreferencesRef preferences);
 
+// Defaults to false.
+WK_EXPORT void WKPreferencesSetAllowsPageCacheWithWindowOpener(WKPreferencesRef preferences, bool enabled);
+WK_EXPORT bool WKPreferencesGetAllowsPageCacheWithWindowOpener(WKPreferencesRef preferences);
+
 // Defaults to true.
 WK_EXPORT void WKPreferencesSetPageCacheSupportsPlugins(WKPreferencesRef preferences, bool pageCacheSupportsPlugins);
 WK_EXPORT bool WKPreferencesGetPageCacheSupportsPlugins(WKPreferencesRef preferences);

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp (211253 => 211254)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp	2017-01-27 04:54:09 UTC (rev 211253)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp	2017-01-27 05:36:19 UTC (rev 211254)
@@ -246,6 +246,7 @@
     macro(WebKitPageCacheSupportsPluginsPreferenceKey, PageCacheSupportsPlugins, pageCacheSupportsPlugins) \
     macro(WebKitPluginsEnabled, PluginsEnabled, pluginsEnabled) \
     macro(WebKitUsesPageCachePreferenceKey, UsesPageCache, usesPageCache) \
+    macro(WebKitAllowsPageCacheWithWindowOpenerKey, AllowsPageCacheWithWindowOpener, allowsPageCacheWithWindowOpener) \
     macro(WebKitWebAudioEnabled, WebAudioEnabled, webAudioEnabled) \
     macro(WebKitWebGLEnabled, WebGLEnabled, webGLEnabled) \
     macro(WebKitXSSAuditorEnabled, XSSAuditorEnabled, xssAuditorEnabled) \

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (211253 => 211254)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2017-01-27 04:54:09 UTC (rev 211253)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2017-01-27 05:36:19 UTC (rev 211254)
@@ -2995,6 +2995,7 @@
 #endif
     settings.setLocalFileContentSniffingEnabled(store.getBoolValueForKey(WebPreferencesKey::localFileContentSniffingEnabledKey()));
     settings.setUsesPageCache(store.getBoolValueForKey(WebPreferencesKey::usesPageCacheKey()));
+    settings.setAllowsPageCacheWithWindowOpener(store.getBoolValueForKey(WebPreferencesKey::allowsPageCacheWithWindowOpenerKey()));
     settings.setPageCacheSupportsPlugins(store.getBoolValueForKey(WebPreferencesKey::pageCacheSupportsPluginsKey()));
     settings.setAuthorAndUserStylesEnabled(store.getBoolValueForKey(WebPreferencesKey::authorAndUserStylesEnabledKey()));
     settings.setPaginateDuringLayoutEnabled(store.getBoolValueForKey(WebPreferencesKey::paginateDuringLayoutEnabledKey()));

Modified: trunk/Tools/ChangeLog (211253 => 211254)


--- trunk/Tools/ChangeLog	2017-01-27 04:54:09 UTC (rev 211253)
+++ trunk/Tools/ChangeLog	2017-01-27 05:36:19 UTC (rev 211254)
@@ -1,3 +1,21 @@
+2017-01-26  Chris Dumez  <cdu...@apple.com>
+
+        Crash when navigating back to a page in PacheCache when one of its frames has been removed
+        https://bugs.webkit.org/show_bug.cgi?id=167421
+        <rdar://problem/30188490>
+
+        Reviewed by Darin Adler.
+
+        Add a new setting allowing layout tests to enable PageCache in a window
+        that has an opener, for convenience.
+
+        * DumpRenderTree/mac/DumpRenderTree.mm:
+        (resetWebPreferencesToConsistentValues):
+        * DumpRenderTree/win/DumpRenderTree.cpp:
+        (resetWebPreferencesToConsistentValues):
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::resetPreferencesToConsistentValues):
+
 2017-01-26  Keith Miller  <keith_mil...@apple.com>
 
         classInfo should take a VM so it is not materialized from the object on each call

Modified: trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm (211253 => 211254)


--- trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm	2017-01-27 04:54:09 UTC (rev 211253)
+++ trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm	2017-01-27 05:36:19 UTC (rev 211254)
@@ -980,6 +980,7 @@
     // The back/forward cache is causing problems due to layouts during transition from one page to another.
     // So, turn it off for now, but we might want to turn it back on some day.
     [preferences setUsesPageCache:NO];
+    [preferences setAllowsPageCacheWithWindowOpener:NO];
     [preferences setAcceleratedCompositingEnabled:YES];
 #if USE(CA)
     [preferences setCanvasUsesAcceleratedDrawing:YES];

Modified: trunk/Tools/DumpRenderTree/win/DumpRenderTree.cpp (211253 => 211254)


--- trunk/Tools/DumpRenderTree/win/DumpRenderTree.cpp	2017-01-27 04:54:09 UTC (rev 211253)
+++ trunk/Tools/DumpRenderTree/win/DumpRenderTree.cpp	2017-01-27 05:36:19 UTC (rev 211254)
@@ -834,6 +834,7 @@
     preferences->setPlugInsEnabled(TRUE);
     preferences->setTextAreasAreResizable(TRUE);
     preferences->setUsesPageCache(FALSE);
+    prefsPrivate->setAllowsPageCacheWithWindowOpener(FALSE);
 
     preferences->setPrivateBrowsingEnabled(FALSE);
     prefsPrivate->setAuthorAndUserStylesEnabled(TRUE);

Modified: trunk/Tools/WebKitTestRunner/TestController.cpp (211253 => 211254)


--- trunk/Tools/WebKitTestRunner/TestController.cpp	2017-01-27 04:54:09 UTC (rev 211253)
+++ trunk/Tools/WebKitTestRunner/TestController.cpp	2017-01-27 05:36:19 UTC (rev 211254)
@@ -655,6 +655,7 @@
     WKPreferencesSetFullScreenEnabled(preferences, true);
 #endif
     WKPreferencesSetPageCacheEnabled(preferences, false);
+    WKPreferencesSetAllowsPageCacheWithWindowOpener(preferences, false);
     WKPreferencesSetAsynchronousPluginInitializationEnabled(preferences, false);
     WKPreferencesSetAsynchronousPluginInitializationEnabledForAllPlugins(preferences, false);
     WKPreferencesSetArtificialPluginInitializationDelayEnabled(preferences, false);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to