[WK2] Add proper layout test support for ephemeral sessions
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 5 Sep 2019 21:12:05 +0000 (21:12 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 5 Sep 2019 21:12:05 +0000 (21:12 +0000)
https://bugs.webkit.org/show_bug.cgi?id=201475

Reviewed by Antti Koivisto.

LayoutTests/imported/w3c:

* IndexedDB-private-browsing/support.js:

Tools:

Add proper layout test support for ephemeral sessions via:
<!-- webkit-test-runner [ useEphemeralSession=true ] -->

This actually creates a new WebView using an ephemeral data store to load the test which
is *true* private browsing.

testRunner.setPrivateBrowsingEnabled() merely overrides the Page's sessionID in the WebContent
process, which is a hack and does not truly enable private browsing because the UIProcess and
the NetworkProcess are not properly updated on WK2. This patch renames testRunner.setPrivateBrowsingEnabled()
to testRunner.setPrivateBrowsingEnabled_DEPRECATED() to discourage its use since I am try to
get rid of it.

Note that WK2 does not support using a WebContent process for different sessions / data stores.
Each WebContent process has a single associated data store and testRunner.setPrivateBrowsingEnabled()
is currently the only exception to that. This leads to additional complexity in our code base (e.g. in ITP),
simply to support testRunner.setPrivateBrowsingEnabled().

* DumpRenderTree/TestOptions.cpp:
(TestOptions::TestOptions):
* DumpRenderTree/TestOptions.h:
* DumpRenderTree/TestRunner.cpp:
(TestRunner::staticFunctions):
* DumpRenderTree/mac/DumpRenderTree.mm:
(setWebPreferencesForTestOptions):
* WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::setPrivateBrowsingEnabled_DEPRECATED):
* WebKitTestRunner/InjectedBundle/TestRunner.h:
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::generatePageConfiguration):
(WTR::updateTestOptionsFromTestHeader):
* WebKitTestRunner/TestOptions.h:
(WTR::TestOptions::hasSameInitializationOptions const):
* WebKitTestRunner/cocoa/TestControllerCocoa.mm:
(WTR::TestController::platformCreateWebView):

LayoutTests:

Update existing layout tests to either switch to the new mechanism when trivial or to rename
setPrivateBrowsingEnabled() to setPrivateBrowsingEnabled_DEPRECATED() when it is not.

* crypto/subtle/rsa-indexeddb-non-exportable-private.html:
* crypto/subtle/rsa-indexeddb-private.html:
* http/tests/adClickAttribution/conversion-disabled-in-ephemeral-session.html:
* http/tests/adClickAttribution/resources/util.js:
(tearDownAndFinish):
* http/tests/adClickAttribution/store-disabled-in-ephemeral-session.html:
* http/tests/cache-storage/cache-persistency.https.html:
* http/tests/cache-storage/cache-representation.https.html:
* http/tests/cache/disk-cache/disk-cache-vary-cookie.html:
* http/tests/cookies/private-cookie-storage.html:
* http/tests/media/now-playing-info-private-browsing.html:
* http/tests/security/appcache-in-private-browsing.html:
* http/tests/security/appcache-switching-private-browsing.html:
* http/tests/security/contentSecurityPolicy/report-cross-origin-no-cookies-when-private-browsing-enabled-expected.txt:
* http/tests/security/contentSecurityPolicy/report-cross-origin-no-cookies-when-private-browsing-enabled.php:
* http/tests/security/contentSecurityPolicy/report-cross-origin-no-cookies-when-private-browsing-toggled.php:
* http/tests/security/contentSecurityPolicy/report-same-origin-no-cookies-when-private-browsing-toggled.php:
* http/tests/security/contentSecurityPolicy/report-same-origin-with-cookies-when-private-browsing-enabled-expected.txt:
* http/tests/security/contentSecurityPolicy/report-same-origin-with-cookies-when-private-browsing-enabled.php:
* http/tests/security/cookies/resources/first-party-cookie-allow.xsl:
* http/tests/security/cookies/resources/third-party-cookie-blocking.xsl:
* http/tests/security/cookies/third-party-cookie-blocking-main-frame.html:
* http/tests/security/cookies/third-party-cookie-blocking-redirect.html:
* http/tests/security/cookies/third-party-cookie-blocking-user-action.html:
* http/tests/security/cookies/third-party-cookie-blocking.html:
* http/tests/security/cross-frame-access-private-browsing.html:
* http/tests/security/cross-origin-plugin-private-browsing-toggled-allowed.html:
* http/tests/security/cross-origin-plugin-private-browsing-toggled.html:
* http/tests/security/private-browsing-http-auth.html:
* http/tests/security/storage-blocking-loosened-private-browsing-plugin.html:
* http/tests/security/storage-blocking-strengthened-private-browsing-plugin.html:
* http/tests/security/strip-referrer-to-origin-for-third-party-redirects-in-private-mode.html:
* http/tests/security/strip-referrer-to-origin-for-third-party-requests-in-private-mode.html:
* http/tests/storageAccess/has-storage-access-true-if-feature-off.html:
* http/tests/workers/service/resources/basic-register.js:
(async.test):
* http/tests/workers/service/serviceworker-private-browsing.https.html:
* http/wpt/fetch/dnt-header-after-redirection.html:
* platform/wk2/TestExpectations:
* plugins/private-browsing-mode-2.html:
* plugins/private-browsing-mode.html:
* resources/js-test.js:
* storage/domstorage/localstorage/private-browsing-affects-storage.html:
* storage/domstorage/localstorage/resources/private-browsing-1.html:
* storage/domstorage/localstorage/resources/private-browsing-2.html:
* storage/indexeddb/open-db-private-browsing.html:
* storage/indexeddb/resources/open-db-private-browsing.js:
* storage/websql/private-browsing-noread-nowrite.html:
* storage/websql/private-browsing-open-disabled.html:

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

62 files changed:
LayoutTests/ChangeLog
LayoutTests/crypto/subtle/rsa-indexeddb-non-exportable-private.html
LayoutTests/crypto/subtle/rsa-indexeddb-private.html
LayoutTests/http/tests/adClickAttribution/conversion-disabled-in-ephemeral-session.html
LayoutTests/http/tests/adClickAttribution/resources/util.js
LayoutTests/http/tests/adClickAttribution/store-disabled-in-ephemeral-session.html
LayoutTests/http/tests/cache-storage/cache-persistency.https.html
LayoutTests/http/tests/cache-storage/cache-representation.https.html
LayoutTests/http/tests/cache/disk-cache/disk-cache-vary-cookie.html
LayoutTests/http/tests/cookies/private-cookie-storage.html
LayoutTests/http/tests/media/now-playing-info-private-browsing.html
LayoutTests/http/tests/security/appcache-in-private-browsing.html
LayoutTests/http/tests/security/appcache-switching-private-browsing.html
LayoutTests/http/tests/security/contentSecurityPolicy/report-cross-origin-no-cookies-when-private-browsing-enabled-expected.txt
LayoutTests/http/tests/security/contentSecurityPolicy/report-cross-origin-no-cookies-when-private-browsing-enabled.php
LayoutTests/http/tests/security/contentSecurityPolicy/report-cross-origin-no-cookies-when-private-browsing-toggled.php
LayoutTests/http/tests/security/contentSecurityPolicy/report-same-origin-no-cookies-when-private-browsing-toggled.php
LayoutTests/http/tests/security/contentSecurityPolicy/report-same-origin-with-cookies-when-private-browsing-enabled-expected.txt
LayoutTests/http/tests/security/contentSecurityPolicy/report-same-origin-with-cookies-when-private-browsing-enabled.php
LayoutTests/http/tests/security/cookies/resources/first-party-cookie-allow.xsl
LayoutTests/http/tests/security/cookies/resources/third-party-cookie-blocking.xsl
LayoutTests/http/tests/security/cookies/third-party-cookie-blocking-main-frame.html
LayoutTests/http/tests/security/cookies/third-party-cookie-blocking-redirect.html
LayoutTests/http/tests/security/cookies/third-party-cookie-blocking-user-action.html
LayoutTests/http/tests/security/cookies/third-party-cookie-blocking.html
LayoutTests/http/tests/security/cross-frame-access-private-browsing.html
LayoutTests/http/tests/security/cross-origin-plugin-private-browsing-toggled-allowed.html
LayoutTests/http/tests/security/cross-origin-plugin-private-browsing-toggled.html
LayoutTests/http/tests/security/private-browsing-http-auth.html
LayoutTests/http/tests/security/storage-blocking-loosened-private-browsing-plugin.html
LayoutTests/http/tests/security/storage-blocking-strengthened-private-browsing-plugin.html
LayoutTests/http/tests/security/strip-referrer-to-origin-for-third-party-redirects-in-private-mode.html
LayoutTests/http/tests/security/strip-referrer-to-origin-for-third-party-requests-in-private-mode.html
LayoutTests/http/tests/storageAccess/has-storage-access-true-if-feature-off.html
LayoutTests/http/tests/workers/service/resources/basic-register.js
LayoutTests/http/tests/workers/service/serviceworker-private-browsing.https.html
LayoutTests/http/wpt/fetch/dnt-header-after-redirection.html
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/IndexedDB-private-browsing/support.js
LayoutTests/platform/mac-wk2/TestExpectations
LayoutTests/platform/wk2/TestExpectations
LayoutTests/plugins/private-browsing-mode-2.html
LayoutTests/plugins/private-browsing-mode.html
LayoutTests/resources/js-test.js
LayoutTests/storage/domstorage/localstorage/private-browsing-affects-storage.html
LayoutTests/storage/domstorage/localstorage/resources/private-browsing-1.html
LayoutTests/storage/domstorage/localstorage/resources/private-browsing-2.html
LayoutTests/storage/indexeddb/open-db-private-browsing.html
LayoutTests/storage/indexeddb/resources/open-db-private-browsing.js
LayoutTests/storage/websql/private-browsing-noread-nowrite.html
LayoutTests/storage/websql/private-browsing-open-disabled.html
Tools/ChangeLog
Tools/DumpRenderTree/TestOptions.cpp
Tools/DumpRenderTree/TestOptions.h
Tools/DumpRenderTree/TestRunner.cpp
Tools/DumpRenderTree/mac/DumpRenderTree.mm
Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl
Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
Tools/WebKitTestRunner/InjectedBundle/TestRunner.h
Tools/WebKitTestRunner/TestController.cpp
Tools/WebKitTestRunner/TestOptions.h
Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm

index 548ad60..c89d468 100644 (file)
@@ -1,3 +1,63 @@
+2019-09-05  Chris Dumez  <cdumez@apple.com>
+
+        [WK2] Add proper layout test support for ephemeral sessions
+        https://bugs.webkit.org/show_bug.cgi?id=201475
+
+        Reviewed by Antti Koivisto.
+
+        Update existing layout tests to either switch to the new mechanism when trivial or to rename
+        setPrivateBrowsingEnabled() to setPrivateBrowsingEnabled_DEPRECATED() when it is not.
+
+        * crypto/subtle/rsa-indexeddb-non-exportable-private.html:
+        * crypto/subtle/rsa-indexeddb-private.html:
+        * http/tests/adClickAttribution/conversion-disabled-in-ephemeral-session.html:
+        * http/tests/adClickAttribution/resources/util.js:
+        (tearDownAndFinish):
+        * http/tests/adClickAttribution/store-disabled-in-ephemeral-session.html:
+        * http/tests/cache-storage/cache-persistency.https.html:
+        * http/tests/cache-storage/cache-representation.https.html:
+        * http/tests/cache/disk-cache/disk-cache-vary-cookie.html:
+        * http/tests/cookies/private-cookie-storage.html:
+        * http/tests/media/now-playing-info-private-browsing.html:
+        * http/tests/security/appcache-in-private-browsing.html:
+        * http/tests/security/appcache-switching-private-browsing.html:
+        * http/tests/security/contentSecurityPolicy/report-cross-origin-no-cookies-when-private-browsing-enabled-expected.txt:
+        * http/tests/security/contentSecurityPolicy/report-cross-origin-no-cookies-when-private-browsing-enabled.php:
+        * http/tests/security/contentSecurityPolicy/report-cross-origin-no-cookies-when-private-browsing-toggled.php:
+        * http/tests/security/contentSecurityPolicy/report-same-origin-no-cookies-when-private-browsing-toggled.php:
+        * http/tests/security/contentSecurityPolicy/report-same-origin-with-cookies-when-private-browsing-enabled-expected.txt:
+        * http/tests/security/contentSecurityPolicy/report-same-origin-with-cookies-when-private-browsing-enabled.php:
+        * http/tests/security/cookies/resources/first-party-cookie-allow.xsl:
+        * http/tests/security/cookies/resources/third-party-cookie-blocking.xsl:
+        * http/tests/security/cookies/third-party-cookie-blocking-main-frame.html:
+        * http/tests/security/cookies/third-party-cookie-blocking-redirect.html:
+        * http/tests/security/cookies/third-party-cookie-blocking-user-action.html:
+        * http/tests/security/cookies/third-party-cookie-blocking.html:
+        * http/tests/security/cross-frame-access-private-browsing.html:
+        * http/tests/security/cross-origin-plugin-private-browsing-toggled-allowed.html:
+        * http/tests/security/cross-origin-plugin-private-browsing-toggled.html:
+        * http/tests/security/private-browsing-http-auth.html:
+        * http/tests/security/storage-blocking-loosened-private-browsing-plugin.html:
+        * http/tests/security/storage-blocking-strengthened-private-browsing-plugin.html:
+        * http/tests/security/strip-referrer-to-origin-for-third-party-redirects-in-private-mode.html:
+        * http/tests/security/strip-referrer-to-origin-for-third-party-requests-in-private-mode.html:
+        * http/tests/storageAccess/has-storage-access-true-if-feature-off.html:
+        * http/tests/workers/service/resources/basic-register.js:
+        (async.test):
+        * http/tests/workers/service/serviceworker-private-browsing.https.html:
+        * http/wpt/fetch/dnt-header-after-redirection.html:
+        * platform/wk2/TestExpectations:
+        * plugins/private-browsing-mode-2.html:
+        * plugins/private-browsing-mode.html:
+        * resources/js-test.js:
+        * storage/domstorage/localstorage/private-browsing-affects-storage.html:
+        * storage/domstorage/localstorage/resources/private-browsing-1.html:
+        * storage/domstorage/localstorage/resources/private-browsing-2.html:
+        * storage/indexeddb/open-db-private-browsing.html:
+        * storage/indexeddb/resources/open-db-private-browsing.js:
+        * storage/websql/private-browsing-noread-nowrite.html:
+        * storage/websql/private-browsing-open-disabled.html:
+
 2019-09-05  Justin Fan  <justin_fan@apple.com>
 
         [WebGPU] Implement GPUUncapturedErrorEvent
index 9fa1ba8..2ebb919 100644 (file)
@@ -1,10 +1,7 @@
+<!-- webkit-test-runner [ useEphemeralSession=true ] -->
 <!DOCTYPE html>
 <html>
 <head>
-<script>
-if (window.testRunner)
-    testRunner.setPrivateBrowsingEnabled(true);
-</script>
 <script src="../../resources/js-test-pre.js"></script>
 <script src="../resources/common.js"></script>
 </head>
index 72dfd78..688fcce 100644 (file)
@@ -1,10 +1,7 @@
+<!-- webkit-test-runner [ useEphemeralSession=true ] -->
 <!DOCTYPE html>
 <html>
 <head>
-<script>
-if (window.testRunner)
-    testRunner.setPrivateBrowsingEnabled(true);
-</script>
 <script src="../../resources/js-test-pre.js"></script>
 <script src="../resources/common.js"></script>
 </head>
index d6c97dc..669c1bd 100644 (file)
@@ -55,7 +55,7 @@
     function runTest() {
         if (window.testRunner) {
             if (window.location.search === "?stepTwo") {
-                testRunner.setPrivateBrowsingEnabled(true);
+                testRunner.setPrivateBrowsingEnabled_DEPRECATED(true);
                 let imageElement = document.createElement("img");
                 imageElement.src = "https://127.0.0.1:8443/adClickAttribution/resources/redirectToConversion.php?conversionData=12&nonce=" + nonce;
                 imageElement.id = "pixel";
index 3f30c8c..2b62545 100644 (file)
@@ -12,7 +12,6 @@ function tearDownAndFinish() {
         testRunner.setAllowsAnySSLCertificate(false);
         testRunner.setAdClickAttributionOverrideTimerForTesting(false);
         testRunner.setAdClickAttributionConversionURLForTesting("");
-        testRunner.setPrivateBrowsingEnabled(false);
         testRunner.notifyDone();
     }
-}
\ No newline at end of file
+}
index 28fea7b..b7c0077 100644 (file)
@@ -1,4 +1,4 @@
-<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true useEphemeralSession=true ] -->
 <html lang="en">
 <head>
     <meta charset="UTF-8">
@@ -13,9 +13,6 @@
 <script>
     prepareTest();
 
-    if (window.testRunner)
-        testRunner.setPrivateBrowsingEnabled(true);
-
     function activateElement(elementID) {
         var element = document.getElementById(elementID);
         var centerX = element.offsetLeft + element.offsetWidth / 2;
index dc9e96b..7714294 100644 (file)
@@ -21,7 +21,7 @@
         if (!window.internals || !window.testRunner)
             return Promise.reject("Test requires internals");
 
-        testRunner.setPrivateBrowsingEnabled(true);
+        testRunner.setPrivateBrowsingEnabled_DEPRECATED(true);
 
         return new Promise((resolve, reject) => {
             window.addEventListener("message", test.step_func((event) => {
@@ -32,7 +32,7 @@
                     return;
                 }
                 assert_true(event.data === false, "No cache object should be found");
-                testRunner.setPrivateBrowsingEnabled(false);
+                testRunner.setPrivateBrowsingEnabled_DEPRECATED(false);
                 resolve();
             }));
             check.innerHTML = "<iframe src='resources/cache-persistency-iframe.html'></iframe>";
@@ -41,7 +41,7 @@
 
     promise_test(test => {
         if (window.testRunner)
-            testRunner.setPrivateBrowsingEnabled(false);
+            testRunner.setPrivateBrowsingEnabled_DEPRECATED(false);
 
         return Promise.resolve().then(() => {
             if (window.internals)
index 61c0f8d..3d26aec 100644 (file)
@@ -1,3 +1,4 @@
+<!-- webkit-test-runner [ useEphemeralSession=true ] -->
 <!DOCTYPE html>
 <html>
 <head>
@@ -9,9 +10,6 @@
 <body>
     <div id="check"></div>
     <script>
-    if (window.testRunner)
-        testRunner.setPrivateBrowsingEnabled(true);
-
     function checkCaches(hasPersistent, hasRemoved, name, value) {
         test(() => {
             var results = JSON.parse(value).origins;
index 4da9fe4..289ac8f 100644 (file)
@@ -40,7 +40,7 @@ testCookies(true, function () {
     debug("Testing memory cache");
     testCookies(false, function () {
         debug("Testing memory cache in private browsing");
-        testRunner.setPrivateBrowsingEnabled(true);
+        testRunner.setPrivateBrowsingEnabled_DEPRECATED(true);
         testCookies(false, function () {
             finishJSTest();
         });
index 72b90df..6fb9b36 100644 (file)
@@ -8,7 +8,7 @@ document.cookie = "key1=value1";
 debug("Cookies before enabling private browsing (should be key1=value1):" + document.cookie);
 testCookies("key1=value1");
 
-if (window.testRunner) { testRunner.setPrivateBrowsingEnabled(true); }
+if (window.testRunner) { testRunner.setPrivateBrowsingEnabled_DEPRECATED(true); }
 
 debug("Cookies after enabling private browsing (should be empty):" + document.cookie);
 testCookies(""); // We're using a different cookie storage now.  key1=value1 is still in the default cookie storage.
@@ -17,7 +17,7 @@ debug("Cookies after setting in private browsing (should be key2=value2):" + doc
 testCookies("key2=value2");
 clearCookies();
 
-if (window.testRunner) { testRunner.setPrivateBrowsingEnabled(false); }
+if (window.testRunner) { testRunner.setPrivateBrowsingEnabled_DEPRECATED(false); }
 
 debug("Cookies after disabling private browsing (should be key1=value1):" + document.cookie);
 testCookies("key1=value1");
index c0a3991..86bab53 100644 (file)
@@ -1,3 +1,4 @@
+<!-- webkit-test-runner [ useEphemeralSession=true ] -->
 <!DOCTYPE html>
 <html>
     <head>
@@ -9,9 +10,6 @@
             let nowPlayingState;
             let previousNowPlayingState; 
 
-            if (window.testRunner)
-                testRunner.setPrivateBrowsingEnabled(true);
-
             async function waitForAttributeToChange(attribute, expected) {
                 let start = new Date().getTime();
                 do {
index edb9ac6..0b683e2 100644 (file)
@@ -8,15 +8,13 @@ if (window.testRunner) {
 }
 
 function finishTest(frame) {
-       if (window.testRunner) {
-               testRunner.setPrivateBrowsingEnabled(false);
+       if (window.testRunner)
                testRunner.notifyDone();
-       }
 }
 
 function enterPrivateBrowsing(frame) {
        if (window.testRunner)
-               testRunner.setPrivateBrowsingEnabled(true);
+               testRunner.setPrivateBrowsingEnabled_DEPRECATED(true);
        frame.onload = finishTest;
        frame.contentWindow.location.reload();
 }
index c7a3a45..ef2f44d 100644 (file)
@@ -10,11 +10,11 @@ if (window.testRunner) {
 
 function enterPrivateBrowsing(frame) {
        if (window.testRunner)
-               testRunner.setPrivateBrowsingEnabled(true);
+               testRunner.setPrivateBrowsingEnabled_DEPRECATED(true);
        frame.contentWindow.appCacheCallback = function(result) {
                frame.contentWindow.updateAppCache(function(result) {
-                       if (window.testRunner)
-                               testRunner.setPrivateBrowsingEnabled(false);
+                        if (window.testRunner)
+                               testRunner.setPrivateBrowsingEnabled_DEPRECATED(false);
                        console.log(result ? 'FAIL' : 'PASS');
                        if (window.testRunner)
                                testRunner.notifyDone();
index d091e4a..eb7821e 100644 (file)
@@ -1,13 +1,11 @@
 <?php
     header("Content-Security-Policy: img-src 'none'; report-uri http://localhost:8080/security/contentSecurityPolicy/resources/save-report.php");
 ?>
+<!-- webkit-test-runner [ useEphemeralSession=true ] -->
 <!DOCTYPE html>
 <html>
 <body>
 <script>
-    if (window.testRunner)
-        testRunner.setPrivateBrowsingEnabled(true);
-
     var xhr = new XMLHttpRequest();
     xhr.open("GET", "http://localhost:8080/cookies/resources/setCookies.cgi", false);
     xhr.setRequestHeader("SET-COOKIE", "hello=world;path=/");
index 555e907..5c56155 100644 (file)
@@ -12,7 +12,7 @@
     xhr.send(null);
 
     if (window.testRunner)
-        testRunner.setPrivateBrowsingEnabled(true);
+        testRunner.setPrivateBrowsingEnabled_DEPRECATED(true);
 </script>
 
 <!-- This image will generate a CSP violation report. -->
index eb73320..038af23 100644 (file)
@@ -12,7 +12,7 @@
     xhr.send(null);
 
     if (window.testRunner)
-        testRunner.setPrivateBrowsingEnabled(true);
+        testRunner.setPrivateBrowsingEnabled_DEPRECATED(true);
 </script>
 
 <!-- This image will generate a CSP violation report. -->
index 77eb7e0..2685a73 100644 (file)
@@ -1,13 +1,11 @@
 <?php
     header("Content-Security-Policy: img-src 'none'; report-uri /security/contentSecurityPolicy/resources/save-report.php");
 ?>
+<!-- webkit-test-runner [ useEphemeralSession=true ] -->
 <!DOCTYPE html>
 <html>
 <body>
 <script>
-    if (window.testRunner)
-        testRunner.setPrivateBrowsingEnabled(true);
-
     var xhr = new XMLHttpRequest();
     xhr.open("GET", "/cookies/resources/setCookies.cgi", false);
     xhr.setRequestHeader("SET-COOKIE", "hello=world;path=/");
index c2eb513..56bae5d 100644 (file)
@@ -8,12 +8,6 @@ if (window.testRunner) {
     testRunner.waitUntilDone();
     testRunner.dumpAsText();
     testRunner.dumpChildFramesAsText();
-
-    // Start with a clean state, as otherwise an expired cookie for this domain could affect behavior with CFNetwork.
-    // Can be removed once rdar://problem/10080130 is fixed.
-    if (testRunner.setPrivateBrowsingEnabled)
-        testRunner.setPrivateBrowsingEnabled(true);
-
     testRunner.setAlwaysAcceptCookies(false);
 }
       </script>
index b99e981..d7b44b7 100644 (file)
@@ -8,12 +8,6 @@ if (window.testRunner) {
     testRunner.waitUntilDone();
     testRunner.dumpAsText();
     testRunner.dumpChildFramesAsText();
-
-    // Start with a clean state, as otherwise an expired cookie for this domain could affect behavior with CFNetwork.
-    // Can be removed once rdar://problem/10080130 is fixed.
-    if (testRunner.setPrivateBrowsingEnabled)
-        testRunner.setPrivateBrowsingEnabled(true);
-
     testRunner.setAlwaysAcceptCookies(false);
 }
       </script>
index 643b4ca..4f02406 100644 (file)
@@ -1,3 +1,4 @@
+<!-- webkit-test-runner [ useEphemeralSession=true ] -->
 <!DOCTYPE html>
 <html>
 <title>Checks that a POST resulting in a main frame navigation is not affected by third-party cookie rules</title>
@@ -6,12 +7,6 @@ if (window.testRunner) {
     testRunner.waitUntilDone();
     testRunner.dumpAsText();
     testRunner.dumpChildFramesAsText();
-
-    // Start with a clean state, as otherwise an expired cookie for this domain could affect behavior with CFNetwork.
-    // Can be removed once <rdar://problem/10080130> is fixed.
-    if (testRunner.setPrivateBrowsingEnabled)
-        testRunner.setPrivateBrowsingEnabled(true);
-
     testRunner.setAlwaysAcceptCookies(false);
 }
 
index 793941b..e083651 100644 (file)
@@ -1,3 +1,4 @@
+<!-- webkit-test-runner [ useEphemeralSession=true ] -->
 <!DOCTYPE html>
 <script>
 function test() {
@@ -9,10 +10,6 @@ if (window.testRunner) {
     testRunner.waitUntilDone();
     testRunner.dumpAsText();
     testRunner.dumpChildFramesAsText();
-
-    if (testRunner.setPrivateBrowsingEnabled)
-        testRunner.setPrivateBrowsingEnabled(true);
-
     testRunner.setAlwaysAcceptCookies(false);
 }
 </script>
index 4721244..47085d2 100644 (file)
@@ -1,3 +1,4 @@
+<!-- webkit-test-runner [ useEphemeralSession=true ] -->
 <!DOCTYPE html>
 <html>
 <title>Checks that a user generated POST request does not circumvent third-party cookie rules</title>
@@ -8,12 +9,6 @@ if (window.testRunner) {
     testRunner.waitUntilDone();
     testRunner.dumpAsText();
     testRunner.dumpChildFramesAsText();
-
-    // Start with a clean state, as otherwise an expired cookie for this domain could affect behavior with CFNetwork.
-    // Can be removed once <rdar://problem/10080130> is fixed.
-    if (testRunner.setPrivateBrowsingEnabled)
-        testRunner.setPrivateBrowsingEnabled(true);
-
     testRunner.setAlwaysAcceptCookies(false);
 }
 
index f169cd4..6f1f190 100644 (file)
@@ -1,3 +1,4 @@
+<!-- webkit-test-runner [ useEphemeralSession=true ] -->
 <!DOCTYPE html>
 <html>
 <title>Checks that a script generated POST request does not circumvent third-party cookie rules</title>
@@ -7,11 +8,6 @@ if (window.testRunner) {
     testRunner.dumpAsText();
     testRunner.dumpChildFramesAsText();
 
-    // Start with a clean state, as otherwise an expired cookie for this domain could affect behavior with CFNetwork.
-    // Can be removed once <rdar://problem/10080130> is fixed.
-    if (testRunner.setPrivateBrowsingEnabled)
-        testRunner.setPrivateBrowsingEnabled(true);
-
     testRunner.setAlwaysAcceptCookies(false);
 }
 
index 24f34db..9a19080 100644 (file)
@@ -1,3 +1,4 @@
+<!-- webkit-test-runner [ useEphemeralSession=true ] -->
 <html>
 <head>
     <script src="resources/cross-frame-access.js"></script>
@@ -25,7 +26,6 @@
 
         function runTest() {
             var subFrame = window.frames[0];
-            testRunner.setPrivateBrowsingEnabled(true);
 
             try {
                 log("Attempting to violate the same-origin policy with private browsing enabled.  If this succeeds the console should not log the violation.");
index f7fa079..1746220 100644 (file)
@@ -5,7 +5,7 @@ var frames = 2;
 if (window.testRunner) {
        testRunner.dumpAsText();
        testRunner.dumpChildFramesAsText();
-       testRunner.setPrivateBrowsingEnabled(true);
+       testRunner.setPrivateBrowsingEnabled_DEPRECATED(true);
        testRunner.waitUntilDone();
 }
 
@@ -13,7 +13,7 @@ function decrement() {
        --frames;
        if (!frames) {
                if (window.testRunner)
-                       testRunner.setPrivateBrowsingEnabled(false);
+                       testRunner.setPrivateBrowsingEnabled_DEPRECATED(false);
                for (var i = 0; i < 2; ++i) {
                        var frame = document.getElementsByTagName('iframe')[i].contentWindow;
                        frame.postMessage('loaded', '*');
index 1471251..3f19593 100644 (file)
@@ -5,7 +5,7 @@ var frames = 2;
 if (window.testRunner) {
        testRunner.dumpAsText();
        testRunner.dumpChildFramesAsText();
-       testRunner.setPrivateBrowsingEnabled(true);
+       testRunner.setPrivateBrowsingEnabled_DEPRECATED(true);
        testRunner.waitUntilDone();
        internals.settings.setStorageBlockingPolicy('BlockThirdParty');
 }
@@ -14,7 +14,7 @@ function decrement() {
        --frames;
        if (!frames) {
                if (window.testRunner)
-                       testRunner.setPrivateBrowsingEnabled(false);
+                       testRunner.setPrivateBrowsingEnabled_DEPRECATED(false);
                for (var i = 0; i < 2; ++i) {
                        var frame = document.getElementsByTagName('iframe')[i].contentWindow;
                        frame.postMessage('loaded', '*');
index 064462e..b72e2c6 100644 (file)
@@ -6,14 +6,14 @@ if (window.testRunner) {
     testRunner.setHandlesAuthenticationChallenges(true);
     testRunner.setAuthenticationUsername("webkit");
     testRunner.setAuthenticationPassword("rocks");
-    testRunner.setPrivateBrowsingEnabled(true);
+    testRunner.setPrivateBrowsingEnabled_DEPRECATED(true);
     testRunner.waitUntilDone();
 }
 
 function firstFrameLoaded() {
     if (window.testRunner) {
         testRunner.setHandlesAuthenticationChallenges(false);
-       testRunner.setPrivateBrowsingEnabled(false);
+       testRunner.setPrivateBrowsingEnabled_DEPRECATED(false);
     }
 
     // If the username and password were in the WebCore CredentialStorage, WebKit would automatically send them out for this resource.
index 8fa3c78..78688f2 100644 (file)
@@ -10,7 +10,7 @@ if (window.testRunner) {
 
 function decrement() {
        if (window.testRunner) {
-               testRunner.setPrivateBrowsingEnabled(true);
+               testRunner.setPrivateBrowsingEnabled_DEPRECATED(true);
                internals.settings.setStorageBlockingPolicy('AllowAll');
        }
        for (var i = 0; i < window.frames.length; ++i)
@@ -18,10 +18,8 @@ function decrement() {
 }
 
 window.onmessage = function() {
-       if (window.testRunner) {
+       if (window.testRunner)
                testRunner.notifyDone();
-               testRunner.setPrivateBrowsingEnabled(false);
-       }
 }
 </script>
 </head>
index e89c982..de1570b 100644 (file)
@@ -5,13 +5,13 @@ if (window.testRunner) {
        testRunner.waitUntilDone();
        testRunner.dumpAsText();
        testRunner.dumpChildFramesAsText();
-       testRunner.setPrivateBrowsingEnabled(true);
+       testRunner.setPrivateBrowsingEnabled_DEPRECATED(true);
 }
 
 function decrement() {
        if (window.testRunner) {
                internals.settings.setStorageBlockingPolicy('BlockAll');
-               testRunner.setPrivateBrowsingEnabled(false);
+               testRunner.setPrivateBrowsingEnabled_DEPRECATED(false);
        }
        for (var i = 0; i < window.frames.length; ++i)
                window.frames[i].postMessage('blocked', '*');
index b26b8ad..f815054 100644 (file)
@@ -1,3 +1,4 @@
+<!-- webkit-test-runner [ useEphemeralSession=true ] -->
 <!DOCTYPE html>
 <html>
 <head>
@@ -8,7 +9,6 @@
     description("Tests that only the origin is sent as referrer for third-party redirects in private browsing mode.");
     jsTestIsAsync = true;
 
-    testRunner.setPrivateBrowsingEnabled(true);
     testRunner.dumpChildFramesAsText();
 
     function openIframe(url, onLoadHandler) {
index 283e0c7..9fafa27 100644 (file)
@@ -1,3 +1,4 @@
+<!-- webkit-test-runner [ useEphemeralSession=true ] -->
 <!DOCTYPE html>
 <html>
 <head>
@@ -8,7 +9,6 @@
     description("Tests that only the origin is sent as referrer for third-party resources in private browsing mode.");
     jsTestIsAsync = true;
 
-    testRunner.setPrivateBrowsingEnabled(true);
     testRunner.dumpChildFramesAsText();
 
     function openIframe(url, onLoadHandler) {
index acaf052..a660bea 100644 (file)
@@ -1,3 +1,4 @@
+<!-- webkit-test-runner [ useEphemeralSession=true ] -->
 <!DOCTYPE html>
 <html>
 <head>
@@ -8,9 +9,6 @@
         description("Tests that document.hasStorageAccess() returns true for a 3rd-party iframe if there is no way to request access (feature off).");
         jsTestIsAsync = true;
 
-        if (window.testRunner)
-            testRunner.setPrivateBrowsingEnabled(true);
-
         window.addEventListener("message", receiveMessage, false);
 
         function receiveMessage(event) {
@@ -38,4 +36,4 @@
 </head>
 <body onload="runTest()">
 </body>
-</html>
\ No newline at end of file
+</html>
index a825790..2b792d7 100644 (file)
@@ -10,14 +10,14 @@ async function test()
     else
         log("FAIL: A service worker is initially registered for this origin");
 
-    testRunner.setPrivateBrowsingEnabled(true);
+    testRunner.setPrivateBrowsingEnabled_DEPRECATED(true);
 
     if (!await internals.hasServiceWorkerRegistration(self.origin))
         log("PASS: No service worker is initially registered for this origin in private session");
     else
         log("FAIL: A service worker is initially registered for this origin in private session");
 
-    testRunner.setPrivateBrowsingEnabled(false);
+    testRunner.setPrivateBrowsingEnabled_DEPRECATED(false);
     try {
         r = await navigator.serviceWorker.register("resources/empty-worker.js", { scope: "/workers/service/resources/test", updateViaCache: "none" })
         log("Registered!");
@@ -37,14 +37,14 @@ async function test()
         else
             log("FAIL: No service worker is registered for this origin");
 
-        testRunner.setPrivateBrowsingEnabled(true);
+        testRunner.setPrivateBrowsingEnabled_DEPRECATED(true);
 
         if (!await internals.hasServiceWorkerRegistration("/test"))
             log("PASS: No service worker is registered for this origin in private session");
         else
             log("FAIL: A service worker is registered for this origin in private session");
 
-        testRunner.setPrivateBrowsingEnabled(false);
+        testRunner.setPrivateBrowsingEnabled_DEPRECATED(false);
     } catch (e) {
         log("Exception registering: " + e);
     }
index 48b38dd..62d3f62 100644 (file)
@@ -14,7 +14,7 @@ promise_test(async (test) => {
 
     if (!window.testRunner)
        return Promise.reject("test requires internals API");
-    testRunner.setPrivateBrowsingEnabled(true);
+    testRunner.setPrivateBrowsingEnabled_DEPRECATED(true);
 
     var registration = await navigator.serviceWorker.getRegistration(scope);
     if (registration && registration.scope === scope)
index b169b5e..3c34ef5 100644 (file)
@@ -1,3 +1,4 @@
+<!-- webkit-test-runner [ useEphemeralSession=true ] -->
 <!DOCTYPE html>
 <html>
 <head>
@@ -28,9 +29,7 @@ async function checkDNTHeader(test, token)
     return false;
 }
 
-if (window.testRunner)
-    testRunner.setPrivateBrowsingEnabled(true);
-else
+if (!window.testRunner)
     alert("Make sure to run this test in Private Browsing Mode");
 
 promise_test(async (test) => {
index 961e74e..db1b513 100644 (file)
@@ -1,3 +1,12 @@
+2019-09-05  Chris Dumez  <cdumez@apple.com>
+
+        [WK2] Add proper layout test support for ephemeral sessions
+        https://bugs.webkit.org/show_bug.cgi?id=201475
+
+        Reviewed by Antti Koivisto.
+
+        * IndexedDB-private-browsing/support.js:
+
 2019-09-05  Youenn Fablet  <youenn@apple.com>
 
         Introduce WorkerSWClientConnection to make SWClientConnection mono-thread
index 7e61147..0f8dee9 100644 (file)
@@ -1,7 +1,8 @@
 // WebKit changes: this file is the same as "IndexedDB/support.js" found in W3C web-platform-tests repo,
 // except for the following lines that activate private browsing
+// FIXME: Update WKTR / DRT to enable private browsing for this folder instead.
 if (window.testRunner)
-    testRunner.setPrivateBrowsingEnabled(true);
+    testRunner.setPrivateBrowsingEnabled_DEPRECATED(true);
 //End of WebKit changes
 
 var databaseName = "database";
index 58e8210..15acbb6 100644 (file)
@@ -477,15 +477,11 @@ webkit.org/b/71298 accessibility/mac/iframe-with-title-correct-hierarchy.html
 ### START OF (5) Features that are not supported when NetworkProcess is enabled (i.e. they only work on Mountain Lion, and not on newer OS versions).
 
 # https://bugs.webkit.org/show_bug.cgi?id=115274
-# PPT: testRunner.setPrivateBrowsingEnabled doesn't work with NetworkProcess
+# PPT: testRunner.setPrivateBrowsingEnabled_DEPRECATED() doesn't work with NetworkProcess
 http/tests/security/appcache-in-private-browsing.html [ Skip ]
 http/tests/security/appcache-switching-private-browsing.html [ Skip ]
 http/tests/security/cookies/first-party-cookie-allow-xslt.xml [ Skip ]
-http/tests/security/cookies/third-party-cookie-blocking-main-frame.html [ Skip ]
-http/tests/security/cookies/third-party-cookie-blocking-user-action.html [ Skip ]
 http/tests/security/cookies/third-party-cookie-blocking-xslt.xml [ Skip ]
-http/tests/security/cookies/third-party-cookie-blocking.html [ Skip ]
-http/tests/security/cross-frame-access-private-browsing.html [ Skip ]
 http/tests/security/cross-origin-plugin-private-browsing-toggled-allowed.html [ Skip ]
 http/tests/security/cross-origin-plugin-private-browsing-toggled.html [ Skip ]
 http/tests/security/storage-blocking-loosened-private-browsing-plugin.html [ Skip ]
index 108540f..ba6c3bd 100644 (file)
@@ -678,13 +678,11 @@ fast/events/drag-display-none-element.html
 # Skip tests in fast/text/shaping
 fast/text/shaping
 
-# WebKitTestRunner testRunner.setPrivateBrowsingEnabled doesn't work with NetworkProcess.
+# WebKitTestRunner testRunner.setPrivateBrowsingEnabled_DEPRECATED() doesn't work with NetworkProcess.
 # We explicitly Skip the following tests instead of marking them as Failure because some of these tests will naturally pass
-# as a consequence of testRunner.setPrivateBrowsingEnabled() effectively being a no-op as of the time of writing (07/08/2015).
-webkit.org/b/115274 http/tests/security/contentSecurityPolicy/report-cross-origin-no-cookies-when-private-browsing-enabled.php [ Skip ]
+# as a consequence of testRunner.setPrivateBrowsingEnabled_DEPRECATED() effectively being a no-op as of the time of writing (07/08/2015).
 webkit.org/b/115274 http/tests/security/contentSecurityPolicy/report-cross-origin-no-cookies-when-private-browsing-toggled.php [ Skip ]
 webkit.org/b/115274 http/tests/security/contentSecurityPolicy/report-same-origin-no-cookies-when-private-browsing-toggled.php [ Skip ]
-webkit.org/b/115274 http/tests/security/contentSecurityPolicy/report-same-origin-with-cookies-when-private-browsing-enabled.php [ Skip ]
 
 ### END OF (4) Features that are not supported in WebKit2 and likely never will be
 ########################################
index 1d8b806..2970877 100644 (file)
@@ -20,7 +20,7 @@ function runTest()
     shouldBe("plugin1.privateBrowsingEnabled", "false");
 
     // Now enable private browsing
-    testRunner.setPrivateBrowsingEnabled(true);
+    testRunner.setPrivateBrowsingEnabled_DEPRECATED(true);
 
     shouldBe("plugin1.privateBrowsingEnabled", "true");
     
@@ -30,7 +30,7 @@ function runTest()
     document.body.appendChild(plugin2);
     
     shouldBe("plugin2.privateBrowsingEnabled", "true");
-    testRunner.setPrivateBrowsingEnabled(false);
+    testRunner.setPrivateBrowsingEnabled_DEPRECATED(false);
     shouldBe("plugin1.privateBrowsingEnabled", "false");
     shouldBe("plugin2.privateBrowsingEnabled", "false");
 }
index f860608..f6eb964 100644 (file)
@@ -21,7 +21,7 @@ function runTest()
     shouldBe("plugin1.cachedPrivateBrowsingEnabled", "false");
 
     // Now enable private browsing
-    testRunner.setPrivateBrowsingEnabled(true);
+    testRunner.setPrivateBrowsingEnabled_DEPRECATED(true);
 
     shouldBe("plugin1.privateBrowsingEnabled", "true");
     shouldBe("plugin1.cachedPrivateBrowsingEnabled", "true");
index 58bb131..57293d6 100644 (file)
@@ -6,8 +6,9 @@ if (self.testRunner) {
         testRunner.dumpAsText();
 
     // If the test file URL ends in "-private.html", enable private browsing.
+    // FIXME: Update WKTR / DRT to do this automatically based on the test name.
     if (window.location.href.endsWith("-private.html") || self.enablePrivateBrowsing)
-        testRunner.setPrivateBrowsingEnabled(true);
+        testRunner.setPrivateBrowsingEnabled_DEPRECATED(true);
 }
 
 var description, debug, didFailSomeTests, successfullyParsed;
index ed58a60..98a32d6 100644 (file)
@@ -22,7 +22,7 @@ function runTest()
     localStorage.setItem("testItem", "Persistent item!");
     log("Persistent localStorage testItem is: " + localStorage.getItem("testItem"));
     
-    testRunner.setPrivateBrowsingEnabled(true);
+    testRunner.setPrivateBrowsingEnabled_DEPRECATED(true);
     testRunner.setCanOpenWindows();
     
     window.location.href = "resources/private-browsing-1.html"
index e4101e3..5a1962a 100644 (file)
@@ -19,7 +19,7 @@ function runTest()
         log("Back in parent window, localStorage's length is: " + localStorage.length);
         log("Back in parent window, testItem is: " + localStorage.getItem("testItem"));
         
-        testRunner.setPrivateBrowsingEnabled(false);
+        testRunner.setPrivateBrowsingEnabled_DEPRECATED(false);
 
         window.location.href = "private-browsing-3.html";
     }
index 0b6b7f2..d96ab7e 100644 (file)
@@ -14,7 +14,7 @@ function runTest()
         return;
     }
 
-    testRunner.setPrivateBrowsingEnabled(true);
+    testRunner.setPrivateBrowsingEnabled_DEPRECATED(true);
     
     log("localStorage's length is: " + localStorage.length);
     log("The item in new window starts out as: " + localStorage.getItem("testItem"));
index 245d9e3..5fbd99f 100644 (file)
@@ -1,3 +1,4 @@
+<!-- webkit-test-runner [ useEphemeralSession=true ] -->
 <html>
 <head>
 <script src="../../resources/js-test.js"></script>
index c2cbad9..ab43d0c 100644 (file)
@@ -5,7 +5,6 @@ if (this.importScripts) {
 
 description("Simple test to open IndexedDB database in private browsing mode.");
 
-testRunner.setPrivateBrowsingEnabled(true);
 removeVendorPrefixes();
 shouldBeNull("indexedDB.open('db')");
 finishJSTest();
index 673a613..5f84ac2 100644 (file)
@@ -68,7 +68,7 @@ function runPrivateBrowsingTests()
     completed = 0;
 
     if (window.testRunner)
-        testRunner.setPrivateBrowsingEnabled(true);
+        testRunner.setPrivateBrowsingEnabled_DEPRECATED(true);
     
     for (i in privateBrowsingStatements)
         theTransaction.executeSql(privateBrowsingStatements[i], [], privateBrowsingSuccessFunction, privateBrowsingErrorFunction);
index 70a7783..f1f9950 100644 (file)
@@ -1,3 +1,4 @@
+<!-- webkit-test-runner [ useEphemeralSession=true ] -->
 <body>
 <div id="logger"></div>
 <script>
@@ -5,7 +6,6 @@
 if (window.testRunner) {
     testRunner.dumpAsText();
     testRunner.waitUntilDone();
-    testRunner.setPrivateBrowsingEnabled(true);
 }
 
 var logger = document.getElementById("logger");
index 80c3db2..ee1f2b2 100644 (file)
@@ -1,3 +1,46 @@
+2019-09-05  Chris Dumez  <cdumez@apple.com>
+
+        [WK2] Add proper layout test support for ephemeral sessions
+        https://bugs.webkit.org/show_bug.cgi?id=201475
+
+        Reviewed by Antti Koivisto.
+
+        Add proper layout test support for ephemeral sessions via:
+        <!-- webkit-test-runner [ useEphemeralSession=true ] -->
+
+        This actually creates a new WebView using an ephemeral data store to load the test which
+        is *true* private browsing.
+
+        testRunner.setPrivateBrowsingEnabled() merely overrides the Page's sessionID in the WebContent
+        process, which is a hack and does not truly enable private browsing because the UIProcess and
+        the NetworkProcess are not properly updated on WK2. This patch renames testRunner.setPrivateBrowsingEnabled()
+        to testRunner.setPrivateBrowsingEnabled_DEPRECATED() to discourage its use since I am try to
+        get rid of it.
+
+        Note that WK2 does not support using a WebContent process for different sessions / data stores.
+        Each WebContent process has a single associated data store and testRunner.setPrivateBrowsingEnabled()
+        is currently the only exception to that. This leads to additional complexity in our code base (e.g. in ITP),
+        simply to support testRunner.setPrivateBrowsingEnabled().
+
+        * DumpRenderTree/TestOptions.cpp:
+        (TestOptions::TestOptions):
+        * DumpRenderTree/TestOptions.h:
+        * DumpRenderTree/TestRunner.cpp:
+        (TestRunner::staticFunctions):
+        * DumpRenderTree/mac/DumpRenderTree.mm:
+        (setWebPreferencesForTestOptions):
+        * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
+        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
+        (WTR::TestRunner::setPrivateBrowsingEnabled_DEPRECATED):
+        * WebKitTestRunner/InjectedBundle/TestRunner.h:
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::generatePageConfiguration):
+        (WTR::updateTestOptionsFromTestHeader):
+        * WebKitTestRunner/TestOptions.h:
+        (WTR::TestOptions::hasSameInitializationOptions const):
+        * WebKitTestRunner/cocoa/TestControllerCocoa.mm:
+        (WTR::TestController::platformCreateWebView):
+
 2019-09-05  Ryosuke Niwa  <rniwa@webkit.org>
 
         REGRESSION (iOS 13): Bulleted list copied from Notes to Mail results in Times New Roman
index 4ad6897..70ade5e 100644 (file)
@@ -79,6 +79,8 @@ TestOptions::TestOptions(const std::string& pathOrURL, const std::string& absolu
             useAcceleratedDrawing = parseBooleanTestHeaderValue(value);
         else if (key == "enableIntersectionObserver")
             enableIntersectionObserver = parseBooleanTestHeaderValue(value);
+        else if (key == "useEphemeralSession")
+            useEphemeralSession = parseBooleanTestHeaderValue(value);
         else if (key == "enableMenuItemElement")
             enableMenuItemElement = parseBooleanTestHeaderValue(value);
         else if (key == "enableKeygenElement")
index 3cb916a..e67351a 100644 (file)
@@ -32,6 +32,7 @@ struct TestOptions {
     bool enableWebAnimationsCSSIntegration { true };
     bool useAcceleratedDrawing { false };
     bool enableIntersectionObserver { false };
+    bool useEphemeralSession { false };
     bool enableMenuItemElement { false };
     bool enableKeygenElement { false };
     bool enableModernMediaControls { true };
index 7c1c581..61bf083 100644 (file)
@@ -2219,7 +2219,7 @@ JSStaticFunction* TestRunner::staticFunctions()
         { "setPopupBlockingEnabled", setPopupBlockingEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setPluginsEnabled", setPluginsEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setPrinting", setPrintingCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
-        { "setPrivateBrowsingEnabled", setPrivateBrowsingEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "setPrivateBrowsingEnabled_DEPRECATED", setPrivateBrowsingEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setSerializeHTTPLoads", setSerializeHTTPLoadsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setSpatialNavigationEnabled", setSpatialNavigationEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setStopProvisionalFrameLoads", setStopProvisionalFrameLoadsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
index e597827..b4b6530 100644 (file)
@@ -1028,6 +1028,7 @@ static void setWebPreferencesForTestOptions(const TestOptions& options)
     preferences.resizeObserverEnabled = options.enableResizeObserver;
     preferences.coreMathMLEnabled = options.enableCoreMathML;
     preferences.lazyImageLoadingEnabled = options.enableLazyImageLoading;
+    preferences.privateBrowsingEnabled = options.useEphemeralSession;
 }
 
 // Called once on DumpRenderTree startup.
index 0750962..b949dc7 100644 (file)
@@ -85,7 +85,6 @@ interface TestRunner {
     void setNeedsStorageAccessFromFileURLsQuirk(boolean value);
     void setPluginsEnabled(boolean value);
     void setJavaScriptCanAccessClipboard(boolean value);
-    void setPrivateBrowsingEnabled(boolean value);
     void setPopupBlockingEnabled(boolean value);
     void setAuthorAndUserStylesEnabled(boolean value);
     void setCustomPolicyDelegate(boolean enabled, boolean permissive);
@@ -105,6 +104,9 @@ interface TestRunner {
     void setNavigationGesturesEnabled(boolean value);
     void setIgnoresViewportScaleLimits(boolean value);
     void setShouldDownloadUndisplayableMIMETypes(boolean value);
+    
+    // DEPRECATED: Use <!-- webkit-test-runner [ useEphemeralSession=true ] --> instead.
+    void setPrivateBrowsingEnabled_DEPRECATED(boolean value);
 
     // Special DOM functions.
     void clearBackForwardList();
index f66c2ac..2b310a4 100644 (file)
@@ -531,7 +531,7 @@ void TestRunner::setJavaScriptCanAccessClipboard(bool enabled)
     WKBundleSetJavaScriptCanAccessClipboard(injectedBundle.bundle(), injectedBundle.pageGroup(), enabled);
 }
 
-void TestRunner::setPrivateBrowsingEnabled(bool enabled)
+void TestRunner::setPrivateBrowsingEnabled_DEPRECATED(bool enabled)
 {
     auto& injectedBundle = InjectedBundle::singleton();
     WKBundleSetPrivateBrowsingEnabled(injectedBundle.bundle(), injectedBundle.pageGroup(), enabled);
index 146e91f..1d32307 100644 (file)
@@ -112,7 +112,7 @@ public:
     void setNeedsStorageAccessFromFileURLsQuirk(bool);
     void setPluginsEnabled(bool);
     void setJavaScriptCanAccessClipboard(bool);
-    void setPrivateBrowsingEnabled(bool);
+    void setPrivateBrowsingEnabled_DEPRECATED(bool);
     void setPopupBlockingEnabled(bool);
     void setAuthorAndUserStylesEnabled(bool);
     void setCustomPolicyDelegate(bool enabled, bool permissive = false);
index fb4bd47..5dd210d 100644 (file)
@@ -584,6 +584,11 @@ WKRetainPtr<WKPageConfigurationRef> TestController::generatePageConfiguration(co
     auto pageConfiguration = adoptWK(WKPageConfigurationCreate());
     WKPageConfigurationSetContext(pageConfiguration.get(), m_context.get());
     WKPageConfigurationSetPageGroup(pageConfiguration.get(), m_pageGroup.get());
+    
+    if (options.useEphemeralSession) {
+        auto ephemeralDataStore = adoptWK(WKWebsiteDataStoreCreateNonPersistentDataStore());
+        WKPageConfigurationSetWebsiteDataStore(pageConfiguration.get(), ephemeralDataStore.get());
+    }
 
     m_userContentController = adoptWK(WKUserContentControllerCreate());
     WKPageConfigurationSetUserContentController(pageConfiguration.get(), userContentController());
@@ -1338,6 +1343,8 @@ static void updateTestOptionsFromTestHeader(TestOptions& testOptions, const std:
             testOptions.enableAttachmentElement = parseBooleanTestHeaderValue(value);
         else if (key == "enableIntersectionObserver")
             testOptions.enableIntersectionObserver = parseBooleanTestHeaderValue(value);
+        else if (key == "useEphemeralSession")
+            testOptions.useEphemeralSession = parseBooleanTestHeaderValue(value);
         else if (key == "enableMenuItemElement")
             testOptions.enableMenuItemElement = parseBooleanTestHeaderValue(value);
         else if (key == "enableKeygenElement")
index 352a626..cb6a5d5 100644 (file)
@@ -69,6 +69,7 @@ struct TestOptions {
     bool useCharacterSelectionGranularity { false };
     bool enableAttachmentElement { false };
     bool enableIntersectionObserver { false };
+    bool useEphemeralSession { false };
     bool enableMenuItemElement { false };
     bool enableKeygenElement { false };
     bool enableModernMediaControls { true };
@@ -124,6 +125,7 @@ struct TestOptions {
             || useCharacterSelectionGranularity != options.useCharacterSelectionGranularity
             || enableAttachmentElement != options.enableAttachmentElement
             || enableIntersectionObserver != options.enableIntersectionObserver
+            || useEphemeralSession != options.useEphemeralSession
             || enableMenuItemElement != options.enableMenuItemElement
             || enableKeygenElement != options.enableKeygenElement
             || enableModernMediaControls != options.enableModernMediaControls
index 9a55824..6e4f5c8 100644 (file)
@@ -160,6 +160,9 @@ void TestController::platformCreateWebView(WKPageConfigurationRef, const TestOpt
 
     if (options.enableUndoManagerAPI)
         [copiedConfiguration _setUndoManagerAPIEnabled:YES];
+        
+    if (options.useEphemeralSession)
+        [copiedConfiguration setWebsiteDataStore:[WKWebsiteDataStore nonPersistentDataStore]];
 
     configureContentMode(copiedConfiguration.get(), options);