Make process-swap-on-navigation an experimental feature.
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 12 Jul 2018 23:37:10 +0000 (23:37 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 12 Jul 2018 23:37:10 +0000 (23:37 +0000)
<rdar://problem/41995053> and https://bugs.webkit.org/show_bug.cgi?id=187558

Reviewed by Chris Dumez.

Source/WebKit:

* Shared/WebPreferences.yaml:

* UIProcess/API/C/WKPreferences.cpp:
(WKPreferencesSetProcessSwapOnNavigationEnabled):
(WKPreferencesGetProcessSwapOnNavigationEnabled):
* UIProcess/API/C/WKPreferencesRef.h:

* UIProcess/WebPreferences.cpp:
(WebKit::WebPreferences::updateBoolValueForExperimentalFeatureKey):

* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::createWebPage): If the new web page has PSON enabled via WebPreferences,
  absorb that setting into this process pool's configuration.

Tools:

Make sure WKTR doesn't enable ProcessSwapOnNavigation by default simply because it's an experimental feature.

* WebKitTestRunner/TestController.cpp:
(WTR::TestController::createWebViewWithOptions):
(WTR::TestController::resetPreferencesToConsistentValues):

* WebKitTestRunner/TestOptions.h:
(WTR::TestOptions::shouldEnableProcessSwapOnNavigation const):

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

Source/WebKit/ChangeLog
Source/WebKit/Shared/WebPreferences.yaml
Source/WebKit/UIProcess/API/C/WKPreferences.cpp
Source/WebKit/UIProcess/API/C/WKPreferencesRef.h
Source/WebKit/UIProcess/WebPreferences.cpp
Source/WebKit/UIProcess/WebProcessPool.cpp
Tools/ChangeLog
Tools/WebKitTestRunner/TestController.cpp
Tools/WebKitTestRunner/TestOptions.h

index 21fea94..8b36cfb 100644 (file)
@@ -1,3 +1,24 @@
+2018-07-12  Brady Eidson  <beidson@apple.com>
+
+        Make process-swap-on-navigation an experimental feature.
+        <rdar://problem/41995053> and https://bugs.webkit.org/show_bug.cgi?id=187558
+
+        Reviewed by Chris Dumez.
+
+        * Shared/WebPreferences.yaml:
+        
+        * UIProcess/API/C/WKPreferences.cpp:
+        (WKPreferencesSetProcessSwapOnNavigationEnabled):
+        (WKPreferencesGetProcessSwapOnNavigationEnabled):
+        * UIProcess/API/C/WKPreferencesRef.h:
+        
+        * UIProcess/WebPreferences.cpp:
+        (WebKit::WebPreferences::updateBoolValueForExperimentalFeatureKey):
+        
+        * UIProcess/WebProcessPool.cpp:
+        (WebKit::WebProcessPool::createWebPage): If the new web page has PSON enabled via WebPreferences,
+          absorb that setting into this process pool's configuration.
+
 2018-07-12  Chris Dumez  <cdumez@apple.com>
 
         Simplify code in NetworkConnectionToWebProcess::didReceiveMessage()
index dcddd78..cfa8b1a 100644 (file)
@@ -1283,3 +1283,12 @@ EncryptedMediaAPIEnabled:
   webcoreBinding: RuntimeEnabledFeatures
   category: experimental
   condition: ENABLE(ENCRYPTED_MEDIA)
+
+ProcessSwapOnNavigationEnabled:
+  type: bool
+  defaultValue: false
+  humanReadableName: "Swap Processes on Navigation"
+  humanReadableDescription: "Swap WebContent processes on cross-origin navigations"
+  category: experimental
+  webcoreBinding: none
+
index 11ee25f..8944d83 100644 (file)
@@ -2023,3 +2023,13 @@ bool WKPreferencesGetColorFilterEnabled(WKPreferencesRef preferencesRef)
 {
     return toImpl(preferencesRef)->colorFilterEnabled();
 }
+
+void WKPreferencesSetProcessSwapOnNavigationEnabled(WKPreferencesRef preferencesRef, bool flag)
+{
+    toImpl(preferencesRef)->setProcessSwapOnNavigationEnabled(flag);
+}
+
+bool WKPreferencesGetProcessSwapOnNavigationEnabled(WKPreferencesRef preferencesRef)
+{
+    return toImpl(preferencesRef)->processSwapOnNavigationEnabled();
+}
index d2ce2a1..5fd8c93 100644 (file)
@@ -327,6 +327,10 @@ WK_EXPORT void WKPreferencesSetCrossOriginResourcePolicyEnabled(WKPreferencesRef
 WK_EXPORT bool WKPreferencesGetCrossOriginWindowPolicyEnabled(WKPreferencesRef preferencesRef);
 WK_EXPORT void WKPreferencesSetCrossOriginWindowPolicyEnabled(WKPreferencesRef preferencesRef, bool enabled);
 
+// Defaults to false.
+WK_EXPORT bool WKPreferencesGetProcessSwapOnNavigationEnabled(WKPreferencesRef preferencesRef);
+WK_EXPORT void WKPreferencesSetProcessSwapOnNavigationEnabled(WKPreferencesRef preferencesRef, bool enabled);
+
 #ifdef __cplusplus
 }
 #endif
index 830e0d7..62cadec 100644 (file)
@@ -133,6 +133,13 @@ void WebPreferences::updateBoolValueForKey(const String& key, bool value)
 
 void WebPreferences::updateBoolValueForExperimentalFeatureKey(const String& key, bool value)
 {
+    if (key == WebPreferencesKey::processSwapOnNavigationEnabledKey()) {
+        for (auto* page : m_pages)
+            page->process().processPool().configuration().setProcessSwapsOnNavigation(value);
+
+        return;
+    }
+
     update(); // FIXME: Only send over the changed key and value.
 }
 
index 6991438..e81e20b 100644 (file)
@@ -1149,7 +1149,11 @@ Ref<WebPageProxy> WebProcessPool::createWebPage(PageClient& pageClient, Ref<API:
     ASSERT(!is<ServiceWorkerProcessProxy>(*process));
 #endif
 
-    return process->createWebPage(pageClient, WTFMove(pageConfiguration));
+    auto page = process->createWebPage(pageClient, WTFMove(pageConfiguration));
+    if (page->preferences().processSwapOnNavigationEnabled())
+        m_configuration->setProcessSwapsOnNavigation(true);
+
+    return page;
 }
 
 #if ENABLE(SERVICE_WORKER)
index 845d258..0a5b650 100644 (file)
@@ -1,3 +1,19 @@
+2018-07-12  Brady Eidson  <beidson@apple.com>
+
+        Make process-swap-on-navigation an experimental feature.
+        <rdar://problem/41995053> and https://bugs.webkit.org/show_bug.cgi?id=187558
+
+        Reviewed by Chris Dumez.
+
+        Make sure WKTR doesn't enable ProcessSwapOnNavigation by default simply because it's an experimental feature.
+
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::createWebViewWithOptions):
+        (WTR::TestController::resetPreferencesToConsistentValues):
+
+        * WebKitTestRunner/TestOptions.h:
+        (WTR::TestOptions::shouldEnableProcessSwapOnNavigation const):
+
 2018-07-12  Youenn Fablet  <youenn@apple.com>
 
         Add a FrameLoaderClient willInjectUserScriptForFrame callback
index e772aeb..221b6af 100644 (file)
@@ -507,7 +507,7 @@ void TestController::createWebViewWithOptions(const TestOptions& options)
         WKArrayAppendItem(overrideLanguages.get(), adoptWK(WKStringCreateWithUTF8CString(language.utf8().data())).get());
     WKContextConfigurationSetOverrideLanguages(contextConfiguration.get(), overrideLanguages.get());
 
-    if (options.enableProcessSwapOnNavigation || options.enableProcessSwapOnWindowOpen) {
+    if (options.shouldEnableProcessSwapOnNavigation()) {
         WKContextConfigurationSetProcessSwapsOnNavigation(contextConfiguration.get(), true);
         if (options.enableProcessSwapOnWindowOpen)
             WKContextConfigurationSetProcessSwapsOnWindowOpenWithOpener(contextConfiguration.get(), true);
@@ -679,6 +679,7 @@ void TestController::resetPreferencesToConsistentValues(const TestOptions& optio
     WKPreferencesRef preferences = platformPreferences();
     WKPreferencesResetTestRunnerOverrides(preferences);
     WKPreferencesEnableAllExperimentalFeatures(preferences);
+    WKPreferencesSetProcessSwapOnNavigationEnabled(preferences, options.shouldEnableProcessSwapOnNavigation());
     WKPreferencesSetPageVisibilityBasedProcessSuppressionEnabled(preferences, false);
     WKPreferencesSetOfflineWebApplicationCacheEnabled(preferences, true);
     WKPreferencesSetFontSmoothingLevel(preferences, kWKFontSmoothingLevelNoSubpixelAntiAliasing);
index 6586357..516d3e9 100644 (file)
@@ -101,6 +101,11 @@ struct TestOptions {
 
         return true;
     }
+    
+    bool shouldEnableProcessSwapOnNavigation() const
+    {
+        return enableProcessSwapOnNavigation || enableProcessSwapOnWindowOpen;
+    }
 };
 
 }