Add a runtime flag for SubtleCrypto
authorjiewen_tan@apple.com <jiewen_tan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 2 Dec 2016 03:30:37 +0000 (03:30 +0000)
committerjiewen_tan@apple.com <jiewen_tan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 2 Dec 2016 03:30:37 +0000 (03:30 +0000)
https://bugs.webkit.org/show_bug.cgi?id=164982

Reviewed by Brent Fulgham.

Source/WebCore:

* bindings/generic/RuntimeEnabledFeatures.h:
(WebCore::RuntimeEnabledFeatures::setSubtleCryptoEnabled):
(WebCore::RuntimeEnabledFeatures::subtleCryptoEnabled):
* page/Crypto.idl:

Source/WebKit/mac:

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

Source/WebKit2:

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

Tools:

* DumpRenderTree/mac/DumpRenderTree.mm:
(resetWebPreferencesToConsistentValues):
* WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
(WTR::InjectedBundle::beginTesting):
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::setSubtleCryptoEnabled):
* WebKitTestRunner/InjectedBundle/TestRunner.h:

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

19 files changed:
Source/WebCore/ChangeLog
Source/WebCore/bindings/generic/RuntimeEnabledFeatures.h
Source/WebCore/page/Crypto.idl
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebView/WebPreferenceKeysPrivate.h
Source/WebKit/mac/WebView/WebPreferences.mm
Source/WebKit/mac/WebView/WebPreferencesPrivate.h
Source/WebKit/mac/WebView/WebView.mm
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/WebPreferencesDefinitions.h
Source/WebKit2/UIProcess/API/C/WKPreferences.cpp
Source/WebKit2/UIProcess/API/C/WKPreferencesRefPrivate.h
Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Tools/ChangeLog
Tools/DumpRenderTree/mac/DumpRenderTree.mm
Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp
Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
Tools/WebKitTestRunner/InjectedBundle/TestRunner.h

index 457f863..3e5fd6b 100644 (file)
@@ -1,3 +1,15 @@
+2016-12-01  Jiewen Tan  <jiewen_tan@apple.com>
+
+        Add a runtime flag for SubtleCrypto
+        https://bugs.webkit.org/show_bug.cgi?id=164982
+
+        Reviewed by Brent Fulgham.
+
+        * bindings/generic/RuntimeEnabledFeatures.h:
+        (WebCore::RuntimeEnabledFeatures::setSubtleCryptoEnabled):
+        (WebCore::RuntimeEnabledFeatures::subtleCryptoEnabled):
+        * page/Crypto.idl:
+
 2016-12-01  Saam Barati  <sbarati@apple.com>
 
         Rename CallFrame::callee() to CallFrame::jsCallee()
index 47219e5..9ba0825 100644 (file)
@@ -240,6 +240,11 @@ public:
     bool encryptedMediaAPIEnabled() const { return m_encryptedMediaAPIEnabled; }
 #endif
 
+#if ENABLE(SUBTLE_CRYPTO)
+    void setSubtleCryptoEnabled(bool isEnabled) { m_isSubtleCryptoEnabled = isEnabled; }
+    bool subtleCryptoEnabled() const { return m_isSubtleCryptoEnabled; }
+#endif
+
     WEBCORE_EXPORT static RuntimeEnabledFeatures& sharedFeatures();
 
     WEBCORE_EXPORT void reset();
@@ -362,6 +367,10 @@ private:
     bool m_intersectionObserverEnabled { false };
 #endif
 
+#if ENABLE(SUBTLE_CRYPTO)
+    bool m_isSubtleCryptoEnabled;
+#endif
+
     friend class WTF::NeverDestroyed<RuntimeEnabledFeatures>;
 };
 
index 24fb5cb..05dbee1 100644 (file)
@@ -31,7 +31,7 @@
     Exposed=(Window,Worker),
     GenerateIsReachable=ImplScriptExecutionContext,
 ] interface Crypto {
-    [Conditional=SUBTLE_CRYPTO] readonly attribute SubtleCrypto subtle;
+    [Conditional=SUBTLE_CRYPTO, EnabledAtRuntime=SubtleCrypto] readonly attribute SubtleCrypto subtle;
     [Custom, MayThrowException] ArrayBufferView getRandomValues(ArrayBufferView array);
 
     // Will be deprecated.
index 4a7d7f6..f86ce66 100644 (file)
@@ -1,3 +1,19 @@
+2016-12-01  Jiewen Tan  <jiewen_tan@apple.com>
+
+        Add a runtime flag for SubtleCrypto
+        https://bugs.webkit.org/show_bug.cgi?id=164982
+
+        Reviewed by Brent Fulgham.
+
+        * WebView/WebPreferenceKeysPrivate.h:
+        * WebView/WebPreferences.mm:
+        (+[WebPreferences initialize]):
+        (-[WebPreferences subtleCryptoEnabled]):
+        (-[WebPreferences setSubtleCryptoEnabled:]):
+        * WebView/WebPreferencesPrivate.h:
+        * WebView/WebView.mm:
+        (-[WebView _preferencesChanged:]):
+
 2016-11-30  Said Abou-Hallawa  <sabouhallawa@apple.com>
 
         Add separate settings and preferences to enable/disable async decoding for large images and animated images
index f3538ea..1f968f1 100644 (file)
 #define WebKitVisualViewportEnabledPreferenceKey @"WebKitVisualViewportEnabled"
 #define WebKitModernMediaControlsEnabledPreferenceKey @"WebKitModernMediaControlsEnabled"
 #define WebKitPointerLockEnabledPreferenceKey @"WebKitPointerLockEnabled"
+#define WebKitSubtleCryptoEnabledPreferenceKey @"WebKitSubtleCryptoEnabled"
 
 #if !TARGET_OS_IPHONE
 // These are private both because callers should be using the cover methods and because the
index 0130524..d398af5 100644 (file)
@@ -630,6 +630,9 @@ public:
 #endif
         [NSNumber numberWithBool:NO], WebKitVisualViewportEnabledPreferenceKey,
         [NSNumber numberWithBool:YES], WebKitNeedsStorageAccessFromFileURLsQuirkKey,
+#if ENABLE(SUBTLE_CRYPTO)
+        [NSNumber numberWithBool:YES], WebKitSubtleCryptoEnabledPreferenceKey,
+#endif
         nil];
 
 #if !PLATFORM(IOS)
@@ -2680,6 +2683,17 @@ static NSString *classIBCreatorID = nil;
     [self _setStringValue:directory forKey:WebKitMediaKeysStorageDirectoryKey];
 }
 
+- (BOOL)subtleCryptoEnabled
+{
+    return [self _boolValueForKey:WebKitSubtleCryptoEnabledPreferenceKey];
+}
+
+- (void)setSubtleCryptoEnabled:(BOOL)flag
+{
+    [self _setBoolValue:flag forKey:WebKitSubtleCryptoEnabledPreferenceKey];
+}
+
+
 - (void)setMetaRefreshEnabled:(BOOL)enabled
 {
     [self setHTTPEquivEnabled:enabled];
index 45bc2f5..2518c26 100644 (file)
@@ -160,6 +160,9 @@ extern NSString *WebPreferencesCacheModelChangedInternalNotification;
 - (BOOL)isSpatialNavigationEnabled;
 - (void)setSpatialNavigationEnabled:(BOOL)flag;
 
+- (void)setSubtleCryptoEnabled:(BOOL)flag;
+- (BOOL)subtleCryptoEnabled;
+
 #if !TARGET_OS_IPHONE
 // zero means do AutoScale
 - (float)PDFScaleFactor;
index b322ae0..20a8780 100644 (file)
@@ -2866,6 +2866,10 @@ static bool needsSelfRetainWhileLoadingQuirk()
     RuntimeEnabledFeatures::sharedFeatures().setIntersectionObserverEnabled(preferences.intersectionObserverEnabled);
 #endif
 
+#if ENABLE(SUBTLE_CRYPTO)
+    RuntimeEnabledFeatures::sharedFeatures().setSubtleCryptoEnabled([preferences subtleCryptoEnabled]);
+#endif
+
     NSTimeInterval timeout = [preferences incrementalRenderingSuppressionTimeoutInSeconds];
     if (timeout > 0)
         settings.setIncrementalRenderingSuppressionTimeoutInSeconds(timeout);
index 63f79b8..f66f051 100644 (file)
@@ -1,3 +1,20 @@
+2016-12-01  Jiewen Tan  <jiewen_tan@apple.com>
+
+        Add a runtime flag for SubtleCrypto
+        https://bugs.webkit.org/show_bug.cgi?id=164982
+
+        Reviewed by Brent Fulgham.
+
+        * Shared/WebPreferencesDefinitions.h:
+        * UIProcess/API/C/WKPreferences.cpp:
+        (WKPreferencesSetSubtleCryptoEnabled):
+        (WKPreferencesGetSubtleCryptoEnabled):
+        * UIProcess/API/C/WKPreferencesRefPrivate.h:
+        * WebProcess/InjectedBundle/InjectedBundle.cpp:
+        (WebKit::InjectedBundle::overrideBoolPreferenceForTestRunner):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::updatePreferences):
+
 2016-12-01  Saam Barati  <sbarati@apple.com>
 
         Rename CallFrame::callee() to CallFrame::jsCallee()
index cb776e5..dfa85a3 100644 (file)
     macro(ModernMediaControlsEnabled, modernMediaControlsEnabled, Bool, bool, false, "Modern Media Controls", "Use modern media controls look") \
     macro(VariationFontsEnabled, variationFontsEnabled, Bool, bool, DEFAULT_EXPERIMENTAL_FEATURES_ENABLED, "Variation Fonts", "Enable variation fonts") \
     macro(InputEventsEnabled, inputEventsEnabled, Bool, bool, DEFAULT_EXPERIMENTAL_FEATURES_ENABLED, "Input Events", "Enable InputEvents support") \
+    macro(SubtleCryptoEnabled, subtleCryptoEnabled, Bool, bool, DEFAULT_EXPERIMENTAL_FEATURES_ENABLED, "SubtleCrypto", "Enable SubtleCrypto support") \
     macro(WebGL2Enabled, webGL2Enabled, Bool, bool, DEFAULT_EXPERIMENTAL_FEATURES_ENABLED, "WebGL 2.0", "WebGL 2 prototype") \
     macro(ES6ModulesEnabled, es6ModulesEnabled, Bool, bool, DEFAULT_EXPERIMENTAL_FEATURES_ENABLED, "ES6 Modules", "Enable ES6 Modules support") \
     macro(PointerLockEnabled, pointerLockEnabled, Bool, bool, DEFAULT_EXPERIMENTAL_FEATURES_ENABLED, "PointerLock", "Pointer Lock API support") \
index 76e9b4d..bdfbd76 100644 (file)
@@ -1611,3 +1611,12 @@ void WKPreferencesSetApplePayCapabilityDisclosureAllowed(WKPreferencesRef prefer
     WebKit::toImpl(preferencesRef)->setApplePayCapabilityDisclosureAllowed(allowed);
 }
 
+void WKPreferencesSetSubtleCryptoEnabled(WKPreferencesRef preferencesRef, bool flag)
+{
+    toImpl(preferencesRef)->setSubtleCryptoEnabled(flag);
+}
+
+bool WKPreferencesGetSubtleCryptoEnabled(WKPreferencesRef preferencesRef)
+{
+    return toImpl(preferencesRef)->subtleCryptoEnabled();
+}
index 6cd3cbf..4940b20 100644 (file)
@@ -450,6 +450,10 @@ WK_EXPORT bool WKPreferencesGetES6ModulesEnabled(WKPreferencesRef);
 WK_EXPORT void WKPreferencesSetIntersectionObserverEnabled(WKPreferencesRef, bool flag);
 WK_EXPORT bool WKPreferencesGetIntersectionObserverEnabled(WKPreferencesRef);
 
+// Defaults to true
+WK_EXPORT void WKPreferencesSetSubtleCryptoEnabled(WKPreferencesRef, bool flag);
+WK_EXPORT bool WKPreferencesGetSubtleCryptoEnabled(WKPreferencesRef);
+
 #ifdef __cplusplus
 }
 #endif
index 0043a0a..3e7ff0e 100644 (file)
@@ -221,6 +221,11 @@ void InjectedBundle::overrideBoolPreferenceForTestRunner(WebPageGroupProxy* page
         RuntimeEnabledFeatures::sharedFeatures().setEncryptedMediaAPIEnabled(enabled);
 #endif
 
+#if ENABLE(SUBTLE_CRYPTO)
+    if (preference == "WebKitSubtleCryptoEnabled")
+        RuntimeEnabledFeatures::sharedFeatures().setSubtleCryptoEnabled(enabled);
+#endif
+
     // Map the names used in LayoutTests with the names used in WebCore::Settings and WebPreferencesStore.
 #define FOR_EACH_OVERRIDE_BOOL_PREFERENCE(macro) \
     macro(WebKitAcceleratedCompositingEnabled, AcceleratedCompositingEnabled, acceleratedCompositingEnabled) \
index f5b4d34..12f41aa 100644 (file)
@@ -3209,6 +3209,10 @@ void WebPage::updatePreferences(const WebPreferencesStore& store)
         updateThrottleState();
     }
 
+#if ENABLE(SUBTLE_CRYPTO)
+    RuntimeEnabledFeatures::sharedFeatures().setSubtleCryptoEnabled(store.getBoolValueForKey(WebPreferencesKey::subtleCryptoEnabledKey()));
+#endif
+
     platformPreferencesDidChange(store);
 
     if (m_drawingArea)
index dc38ec7..dd4bbb0 100644 (file)
@@ -1,3 +1,18 @@
+2016-12-01  Jiewen Tan  <jiewen_tan@apple.com>
+
+        Add a runtime flag for SubtleCrypto
+        https://bugs.webkit.org/show_bug.cgi?id=164982
+
+        Reviewed by Brent Fulgham.
+
+        * DumpRenderTree/mac/DumpRenderTree.mm:
+        (resetWebPreferencesToConsistentValues):
+        * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
+        (WTR::InjectedBundle::beginTesting):
+        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
+        (WTR::TestRunner::setSubtleCryptoEnabled):
+        * WebKitTestRunner/InjectedBundle/TestRunner.h:
+
 2016-12-01  Alexey Proskuryakov  <ap@apple.com>
 
         Remove webkitpy dependency on Eliza
index 98b915e..dc5817e 100644 (file)
@@ -1001,6 +1001,8 @@ static void resetWebPreferencesToConsistentValues(const TestOptions& options)
     preferences.intersectionObserverEnabled = options.enableIntersectionObserver;
     preferences.modernMediaControlsEnabled = options.enableModernMediaControls;
 
+    [preferences setSubtleCryptoEnabled:YES];
+
     [WebPreferences _clearNetworkLoaderSession];
     [WebPreferences _setCurrentNetworkLoaderSessionCookieAcceptPolicy:NSHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain];
 }
index 27e2ade..f4ff648 100644 (file)
@@ -335,6 +335,8 @@ void InjectedBundle::beginTesting(WKDictionaryRef settings)
     m_testRunner->setTabKeyCyclesThroughElements(true);
     m_testRunner->clearTestRunnerCallbacks();
 
+    m_testRunner->setSubtleCryptoEnabled(true);
+
     if (m_timeout > 0)
         m_testRunner->setCustomTimeout(m_timeout);
 
index d93fc15..51a74ac 100644 (file)
@@ -354,6 +354,13 @@ void TestRunner::setCustomElementsEnabled(bool enabled)
     WKBundleOverrideBoolPreferenceForTestRunner(injectedBundle.bundle(), injectedBundle.pageGroup(), key.get(), enabled);
 }
 
+void TestRunner::setSubtleCryptoEnabled(bool enabled)
+{
+    WKRetainPtr<WKStringRef> key(AdoptWK, WKStringCreateWithUTF8CString("WebKitSubtleCryptoEnabled"));
+    auto& injectedBundle = InjectedBundle::singleton();
+    WKBundleOverrideBoolPreferenceForTestRunner(injectedBundle.bundle(), injectedBundle.pageGroup(), key.get(), enabled);
+}
+
 void TestRunner::setDOMIteratorEnabled(bool enabled)
 {
     WKRetainPtr<WKStringRef> key(AdoptWK, WKStringCreateWithUTF8CString("WebKitDOMIteratorEnabled"));
index 132af23..b89fcda 100644 (file)
@@ -129,6 +129,7 @@ public:
     void setAllowsAnySSLCertificate(bool);
     void setES6ModulesEnabled(bool);
     void setEncryptedMediaAPIEnabled(bool);
+    void setSubtleCryptoEnabled(bool);
 
     // Special DOM functions.
     void clearBackForwardList();