Implement W3C Secure Contexts Draft Specification
authordbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Jun 2017 20:21:00 +0000 (20:21 +0000)
committerdbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Jun 2017 20:21:00 +0000 (20:21 +0000)
https://bugs.webkit.org/show_bug.cgi?id=158121
<rdar://problem/26012994>

Reviewed by Brent Fulgham.

Part 4

Source/JavaScriptCore:

Adds isSecureContext to the list of common identifiers as needed to support
toggling its exposure from a runtime enabled feature flag.

* runtime/CommonIdentifiers.h:

Source/WebCore:

Adds runtime enabled feature flag, isSecureContextAttributeEnabled, to toggle exposing
the global object property isSecureContext (defaults: true - expose the property).

Test: security/isSecureContext-disabled.html

* page/RuntimeEnabledFeatures.h:
(WebCore::RuntimeEnabledFeatures::setIsSecureContextAttributeEnabled):
(WebCore::RuntimeEnabledFeatures::isSecureContextAttributeEnabled):
* page/WindowOrWorkerGlobalScope.idl:

Source/WebKit/mac:

Adds a preference to toggle the runtime enabled feature flag isSecureContextAttributeEnabled.

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

Source/WebKit/win:

Adds a preference to toggle the runtime enabled feature flag isSecureContextAttributeEnabled.

* Interfaces/IWebPreferencesPrivate.idl: Bump the version.
* WebPreferenceKeysPrivate.h:
* WebPreferences.cpp:
(WebPreferences::initializeDefaultSettings):
(WebPreferences::QueryInterface):
(WebPreferences::setIsSecureContextAttributeEnabled):
(WebPreferences::isSecureContextAttributeEnabled):
* WebPreferences.h:
* WebView.cpp:
(WebView::notifyPreferencesChanged):

Source/WebKit2:

Adds a preference to toggle the runtime enabled feature flag isSecureContextAttributeEnabled.

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

Tools:

Expose the isSecureContext attribute by default in DumpRenderTree and WebKitTestRunner.
Teach DumpRenderTree for Mac and WebKitTestRunner to parse the test option enableIsSecureContextAttribute
to toggle the runtime enabled feature flag isSecureContextAttributeEnabled.

* DumpRenderTree/TestOptions.h:
* DumpRenderTree/TestOptions.mm:
(TestOptions::TestOptions):
* DumpRenderTree/mac/DumpRenderTree.mm:
(setWebPreferencesForTestOptions):
* DumpRenderTree/win/DumpRenderTree.cpp:
(enableExperimentalFeatures):
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::resetPreferencesToConsistentValues):
(WTR::updateTestOptionsFromTestHeader):
* WebKitTestRunner/TestOptions.h:
(WTR::TestOptions::hasSameInitializationOptions):

LayoutTests:

Adds a test to ensure that the global object property isSecureContext is not
exposed (is undefined) when the runtime enabled feature flag isSecureContextAttributeEnabled
is disabled.

* platform/win/TestExpectations: Skip the test as DumpRenderTree on Windows does not support
parsing of test options. See <https://bugs.webkit.org/show_bug.cgi?id=173281> for more details.
* security/isSecureContext-disabled-expected.txt: Added.
* security/isSecureContext-disabled.html: Added.
* security/resources/worker-isSecureContext-disabled.js: Added.

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

34 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/win/TestExpectations
LayoutTests/security/isSecureContext-disabled-expected.txt [new file with mode: 0644]
LayoutTests/security/isSecureContext-disabled.html [new file with mode: 0644]
LayoutTests/security/resources/worker-isSecureContext-disabled.js [new file with mode: 0644]
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/runtime/CommonIdentifiers.h
Source/WebCore/ChangeLog
Source/WebCore/page/RuntimeEnabledFeatures.h
Source/WebCore/page/WindowOrWorkerGlobalScope.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/WebKit/win/ChangeLog
Source/WebKit/win/Interfaces/IWebPreferencesPrivate.idl
Source/WebKit/win/WebPreferenceKeysPrivate.h
Source/WebKit/win/WebPreferences.cpp
Source/WebKit/win/WebPreferences.h
Source/WebKit/win/WebView.cpp
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/TestOptions.h
Tools/DumpRenderTree/TestOptions.mm
Tools/DumpRenderTree/mac/DumpRenderTree.mm
Tools/DumpRenderTree/win/DumpRenderTree.cpp
Tools/WebKitTestRunner/TestController.cpp
Tools/WebKitTestRunner/TestOptions.h

index e948faf..8d74bf8 100644 (file)
@@ -1,3 +1,23 @@
+2017-06-13  Daniel Bates  <dabates@apple.com>
+
+        Implement W3C Secure Contexts Draft Specification
+        https://bugs.webkit.org/show_bug.cgi?id=158121
+        <rdar://problem/26012994>
+
+        Reviewed by Brent Fulgham.
+
+        Part 4
+
+        Adds a test to ensure that the global object property isSecureContext is not
+        exposed (is undefined) when the runtime enabled feature flag isSecureContextAttributeEnabled
+        is disabled.
+
+        * platform/win/TestExpectations: Skip the test as DumpRenderTree on Windows does not support
+        parsing of test options. See <https://bugs.webkit.org/show_bug.cgi?id=173281> for more details.
+        * security/isSecureContext-disabled-expected.txt: Added.
+        * security/isSecureContext-disabled.html: Added.
+        * security/resources/worker-isSecureContext-disabled.js: Added.
+
 2017-06-13  Youenn Fablet  <youenn@apple.com>
 
         getReceivers() should return transceivers that have only an active receiver
index f4921ff..8442d6f 100644 (file)
@@ -84,6 +84,10 @@ fast/css/text-overflow-ellipsis-strict.html [ Skip ]
 ################################################################################
 ##############    Missing Functionality Prevents Testing        ################
 ################################################################################
+
+# FIXME: Implement test options parsing (<!-- webkit-test-runner [ ... ] -->).
+webkit.org/b/173281 security/isSecureContext-disabled.html [ Skip ]
+
 # TODO HW filters not yet supported on Windows
 webkit.org/b/74716 css3/filters/effect-blur-hw.html [ Skip ]
 webkit.org/b/74716 css3/filters/effect-combined-hw.html [ Skip ]
diff --git a/LayoutTests/security/isSecureContext-disabled-expected.txt b/LayoutTests/security/isSecureContext-disabled-expected.txt
new file mode 100644 (file)
index 0000000..a8f7059
--- /dev/null
@@ -0,0 +1,12 @@
+Tests that global property isSecureContexts is undefined when the Setting isSecureContextAttributeEnabled is disabled.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS window.isSecureContext is undefined.
+Starting worker: resources/worker-isSecureContext-disabled.js
+PASS [Worker] self.isSecureContext is undefined.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/security/isSecureContext-disabled.html b/LayoutTests/security/isSecureContext-disabled.html
new file mode 100644 (file)
index 0000000..128ba27
--- /dev/null
@@ -0,0 +1,16 @@
+<!DOCTYPE html><!-- webkit-test-runner [ enableIsSecureContextAttribute=false ] -->
+<html>
+<head>
+<script src="../resources/js-test.js"></script>
+</head>
+<body>
+<script>
+window.jsTestIsAsync = true;
+
+description("Tests that global property isSecureContexts is undefined when the Setting isSecureContextAttributeEnabled is disabled.");
+
+shouldBeUndefined("window.isSecureContext");
+startWorker("resources/worker-isSecureContext-disabled.js");
+</script>
+</body>
+</html>
diff --git a/LayoutTests/security/resources/worker-isSecureContext-disabled.js b/LayoutTests/security/resources/worker-isSecureContext-disabled.js
new file mode 100644 (file)
index 0000000..7a66ea8
--- /dev/null
@@ -0,0 +1,7 @@
+importScripts("../../resources/js-test.js");
+
+if (typeof(self.isSecureContext) === 'undefined')
+    testPassed("self.isSecureContext is undefined.");
+else
+    testFailed("self.isSecureContext is defined.");
+finishJSTest();
index b89055e..fecede4 100644 (file)
@@ -1,3 +1,18 @@
+2017-06-13  Daniel Bates  <dabates@apple.com>
+
+        Implement W3C Secure Contexts Draft Specification
+        https://bugs.webkit.org/show_bug.cgi?id=158121
+        <rdar://problem/26012994>
+
+        Reviewed by Brent Fulgham.
+
+        Part 4
+
+        Adds isSecureContext to the list of common identifiers as needed to support
+        toggling its exposure from a runtime enabled feature flag.
+
+        * runtime/CommonIdentifiers.h:
+
 2017-06-13  Don Olmstead  <don.olmstead@sony.com>
 
         [JSC] Remove redundant includes in config.h
index bf106ab..9241b3e 100644 (file)
     macro(isArray) \
     macro(isEnabled) \
     macro(isPrototypeOf) \
+    macro(isSecureContext) \
     macro(isView) \
     macro(isWatchpoint) \
     macro(jettisonReason) \
index c083464..fddc6cb 100644 (file)
@@ -1,3 +1,23 @@
+2017-06-13  Daniel Bates  <dabates@apple.com>
+
+        Implement W3C Secure Contexts Draft Specification
+        https://bugs.webkit.org/show_bug.cgi?id=158121
+        <rdar://problem/26012994>
+
+        Reviewed by Brent Fulgham.
+
+        Part 4
+
+        Adds runtime enabled feature flag, isSecureContextAttributeEnabled, to toggle exposing
+        the global object property isSecureContext (defaults: true - expose the property).
+
+        Test: security/isSecureContext-disabled.html
+
+        * page/RuntimeEnabledFeatures.h:
+        (WebCore::RuntimeEnabledFeatures::setIsSecureContextAttributeEnabled):
+        (WebCore::RuntimeEnabledFeatures::isSecureContextAttributeEnabled):
+        * page/WindowOrWorkerGlobalScope.idl:
+
 2017-06-13  Jer Noble  <jer.noble@apple.com>
 
         Protect lifetime of media element during HTMLMediaElement::notifyAboutPlaying()
index e730fc7..8b0bd25 100644 (file)
@@ -78,6 +78,9 @@ public:
     void setCredentialManagementEnabled(bool isEnabled) { m_isCredentialManagementEnabled = isEnabled; }
     bool credentialManagementEnabled() const { return m_isCredentialManagementEnabled; }
 
+    void setIsSecureContextAttributeEnabled(bool isEnabled) { m_isSecureContextAttributeEnabled = isEnabled; }
+    bool isSecureContextAttributeEnabled() const { return m_isSecureContextAttributeEnabled; }
+
 #if ENABLE(INDEXED_DATABASE_IN_WORKERS)
     void setIndexedDBWorkersEnabled(bool isEnabled) { m_isIndexedDBWorkersEnabled = isEnabled; }
     bool indexedDBWorkersEnabled() const { return m_isIndexedDBWorkersEnabled; }
@@ -209,6 +212,7 @@ private:
     bool m_isUserTimingEnabled { false };
     bool m_isInteractiveFormValidationEnabled { false };
     bool m_isCredentialManagementEnabled { false };
+    bool m_isSecureContextAttributeEnabled { false };
 
     bool m_isDisplayContentsEnabled { false };
     bool m_isShadowDOMEnabled { true };
index 6eae562..8f1f6e8 100644 (file)
@@ -41,5 +41,5 @@
     [MayThrowException] DOMString btoa(DOMString string);
 
     // Secure Contexts
-    readonly attribute boolean isSecureContext;
+    [EnabledAtRuntime=IsSecureContextAttribute] readonly attribute boolean isSecureContext;
 };
index 1b01eee..45956f5 100644 (file)
@@ -1,3 +1,24 @@
+2017-06-13  Daniel Bates  <dabates@apple.com>
+
+        Implement W3C Secure Contexts Draft Specification
+        https://bugs.webkit.org/show_bug.cgi?id=158121
+        <rdar://problem/26012994>
+
+        Reviewed by Brent Fulgham.
+
+        Part 4
+
+        Adds a preference to toggle the runtime enabled feature flag isSecureContextAttributeEnabled.
+
+        * WebView/WebPreferenceKeysPrivate.h:
+        * WebView/WebPreferences.mm:
+        (+[WebPreferences initialize]):
+        (-[WebPreferences isSecureContextAttributeEnabled]):
+        (-[WebPreferences setIsSecureContextAttributeEnabled:]):
+        * WebView/WebPreferencesPrivate.h:
+        * WebView/WebView.mm:
+        (-[WebView _preferencesChanged:]):
+
 2017-06-13  Sam Weinig  <sam@webkit.org>
 
         Rename JSDOMWindowShell to JSDOMWindowProxy to match the HTML5 spec.
index 3779cbe..ea46ad1 100644 (file)
 #define WebKitMediaPreloadingEnabledPreferenceKey @"WebKitMediaPreloadingEnabled"
 #define WebKitCredentialManagementEnabledPreferenceKey @"WebKitCredentialManagementEnabled"
 #define WebKitMediaUserGestureInheritsFromDocument @"WebKitMediaUserGestureInheritsFromDocument"
+#define WebKitIsSecureContextAttributeEnabledPreferenceKey @"WebKitIsSecureContextAttributeEnabled"
 
 #if !TARGET_OS_IPHONE
 // These are private both because callers should be using the cover methods and because the
index 8366fa9..3e4bce2 100644 (file)
@@ -668,6 +668,7 @@ public:
         @NO, WebKitResourceTimingEnabledPreferenceKey,
         @NO, WebKitCredentialManagementEnabledPreferenceKey,
         @NO, WebKitMediaUserGestureInheritsFromDocument,
+        @NO, WebKitIsSecureContextAttributeEnabledPreferenceKey,
         (NSString *)Settings::defaultMediaContentTypesRequiringHardwareSupport(), WebKitMediaContentTypesRequiringHardwareSupportPreferenceKey,
         nil];
 
@@ -3103,6 +3104,17 @@ static NSString *classIBCreatorID = nil;
 {
     [self _setStringValue:value forKey:WebKitMediaContentTypesRequiringHardwareSupportPreferenceKey];
 }
+
+- (BOOL)isSecureContextAttributeEnabled
+{
+    return [self _boolValueForKey:WebKitIsSecureContextAttributeEnabledPreferenceKey];
+}
+
+- (void)setIsSecureContextAttributeEnabled:(BOOL)flag
+{
+    [self _setBoolValue:flag forKey:WebKitIsSecureContextAttributeEnabledPreferenceKey];
+}
+
 @end
 
 @implementation WebPreferences (WebInternal)
index 592f308..2e08b59 100644 (file)
@@ -547,6 +547,9 @@ extern NSString *WebPreferencesCacheModelChangedInternalNotification;
 - (void)setCredentialManagementEnabled:(BOOL)flag;
 - (BOOL)credentialManagementEnabled;
 
+- (void)setIsSecureContextAttributeEnabled:(BOOL)flag;
+- (BOOL)isSecureContextAttributeEnabled;
+
 @property (nonatomic) BOOL visualViewportEnabled;
 @property (nonatomic) BOOL largeImageAsyncDecodingEnabled;
 @property (nonatomic) BOOL animatedImageAsyncDecodingEnabled;
@@ -561,6 +564,7 @@ extern NSString *WebPreferencesCacheModelChangedInternalNotification;
 @property (nonatomic) BOOL linkPreloadEnabled;
 @property (nonatomic) BOOL credentialManagementEnabled;
 @property (nonatomic) BOOL mediaUserGestureInheritsFromDocument;
+@property (nonatomic) BOOL isSecureContextAttributeEnabled;
 
 #if TARGET_OS_IPHONE
 @property (nonatomic) BOOL quickLookDocumentSavingEnabled;
index 5cec238..ed9aa2d 100644 (file)
@@ -3057,6 +3057,7 @@ static bool needsSelfRetainWhileLoadingQuirk()
     RuntimeEnabledFeatures::sharedFeatures().setLinkPreloadEnabled(preferences.linkPreloadEnabled);
     RuntimeEnabledFeatures::sharedFeatures().setMediaPreloadingEnabled(preferences.mediaPreloadingEnabled);
     RuntimeEnabledFeatures::sharedFeatures().setCredentialManagementEnabled(preferences.credentialManagementEnabled);
+    RuntimeEnabledFeatures::sharedFeatures().setIsSecureContextAttributeEnabled(preferences.isSecureContextAttributeEnabled);
 
     NSTimeInterval timeout = [preferences incrementalRenderingSuppressionTimeoutInSeconds];
     if (timeout > 0)
index 2396bd1..2fea6ec 100644 (file)
@@ -1,3 +1,26 @@
+2017-06-13  Daniel Bates  <dabates@apple.com>
+
+        Implement W3C Secure Contexts Draft Specification
+        https://bugs.webkit.org/show_bug.cgi?id=158121
+        <rdar://problem/26012994>
+
+        Reviewed by Brent Fulgham.
+
+        Part 4
+
+        Adds a preference to toggle the runtime enabled feature flag isSecureContextAttributeEnabled.
+
+        * Interfaces/IWebPreferencesPrivate.idl: Bump the version.
+        * WebPreferenceKeysPrivate.h:
+        * WebPreferences.cpp:
+        (WebPreferences::initializeDefaultSettings):
+        (WebPreferences::QueryInterface):
+        (WebPreferences::setIsSecureContextAttributeEnabled):
+        (WebPreferences::isSecureContextAttributeEnabled):
+        * WebPreferences.h:
+        * WebView.cpp:
+        (WebView::notifyPreferencesChanged):
+
 2017-06-13  Per Arne Vollan  <pvollan@apple.com>
 
         [Win] WebKit fails to paint the bottom lines of the window at 125% scale.
index e75bcc7..7443394 100644 (file)
@@ -202,3 +202,10 @@ interface IWebPreferencesPrivate4 : IWebPreferencesPrivate3
     HRESULT clearNetworkLoaderSession();
     HRESULT switchNetworkLoaderToNewTestingSession();
 }
+
+[uuid(9C4CBF53-19BC-46B3-831E-6A8B88200F20)]
+interface IWebPreferencesPrivate5 : IWebPreferencesPrivate4
+{
+    HRESULT isSecureContextAttributeEnabled([out, retval] BOOL*);
+    HRESULT setIsSecureContextAttributeEnabled([in] BOOL enabled);
+}
index 6029d6c..c8c705e 100644 (file)
 #define WebKitLinkPreloadEnabledPreferenceKey "WebKitLinkPreloadEnabled"
 
 #define WebKitMediaPreloadingEnabledPreferenceKey "WebKitMediaPreloadingEnabled"
+
+#define WebKitIsSecureContextAttributeEnabledPreferenceKey "WebKitIsSecureContextAttributeEnabled"
index 9397044..0772f2d 100644 (file)
@@ -316,6 +316,8 @@ void WebPreferences::initializeDefaultSettings()
 
     CFDictionaryAddValue(defaults, CFSTR(WebKitMediaPreloadingEnabledPreferenceKey), kCFBooleanFalse);
 
+    CFDictionaryAddValue(defaults, CFSTR(WebKitIsSecureContextAttributeEnabledPreferenceKey), kCFBooleanFalse);
+
     defaultSettings = defaults;
 }
 
@@ -561,6 +563,8 @@ HRESULT WebPreferences::QueryInterface(_In_ REFIID riid, _COM_Outptr_ void** ppv
         *ppvObject = static_cast<IWebPreferencesPrivate3*>(this);
     else if (IsEqualGUID(riid, IID_IWebPreferencesPrivate4))
         *ppvObject = static_cast<IWebPreferencesPrivate4*>(this);
+    else if (IsEqualGUID(riid, IID_IWebPreferencesPrivate5))
+        *ppvObject = static_cast<IWebPreferencesPrivate5*>(this);
     else if (IsEqualGUID(riid, CLSID_WebPreferences))
         *ppvObject = this;
     else
@@ -2041,6 +2045,20 @@ HRESULT WebPreferences::switchNetworkLoaderToNewTestingSession()
     return S_OK;
 }
 
+HRESULT WebPreferences::setIsSecureContextAttributeEnabled(BOOL enabled)
+{
+    setBoolValue(WebKitIsSecureContextAttributeEnabledPreferenceKey, enabled);
+    return S_OK;
+}
+
+HRESULT WebPreferences::isSecureContextAttributeEnabled(_Out_ BOOL* enabled)
+{
+    if (!enabled)
+        return E_POINTER;
+    *enabled = boolValueForKey(WebKitIsSecureContextAttributeEnabledPreferenceKey);
+    return S_OK;
+}
+
 HRESULT WebPreferences::setApplicationId(BSTR applicationId)
 {
     m_applicationId = String(applicationId).createCFString();
index 2d5d287..cf70321 100644 (file)
@@ -30,7 +30,7 @@
 #include <WebCore/BString.h>
 #include <wtf/RetainPtr.h>
 
-class WebPreferences : public IWebPreferences, public IWebPreferencesPrivate4 {
+class WebPreferences : public IWebPreferences, public IWebPreferencesPrivate5 {
 public:
     static WebPreferences* createInstance();
 protected:
@@ -256,6 +256,10 @@ public:
     virtual HRESULT STDMETHODCALLTYPE clearNetworkLoaderSession();
     virtual HRESULT STDMETHODCALLTYPE switchNetworkLoaderToNewTestingSession();
 
+    // IWebPreferencesPrivate5
+    virtual HRESULT STDMETHODCALLTYPE isSecureContextAttributeEnabled(_Out_ BOOL*);
+    virtual HRESULT STDMETHODCALLTYPE setIsSecureContextAttributeEnabled(BOOL);
+
     // WebPreferences
 
     // This method accesses a different preference key than developerExtrasEnabled.
index 0b76b48..60b1df5 100644 (file)
@@ -5190,7 +5190,7 @@ HRESULT WebView::notifyPreferencesChanged(IWebNotification* notification)
     settings.setShouldDisplayTextDescriptions(enabled);
 #endif
 
-    COMPtr<IWebPreferencesPrivate4> prefsPrivate(Query, preferences);
+    COMPtr<IWebPreferencesPrivate5> prefsPrivate { Query, preferences };
     if (prefsPrivate) {
         hr = prefsPrivate->localStorageDatabasePath(&str);
         if (FAILED(hr))
@@ -5286,6 +5286,11 @@ HRESULT WebView::notifyPreferencesChanged(IWebNotification* notification)
         return hr;
     RuntimeEnabledFeatures::sharedFeatures().setMediaPreloadingEnabled(!!enabled);
 
+    hr = prefsPrivate->isSecureContextAttributeEnabled(&enabled);
+    if (FAILED(hr))
+        return hr;
+    RuntimeEnabledFeatures::sharedFeatures().setIsSecureContextAttributeEnabled(!!enabled);
+
     hr = preferences->privateBrowsingEnabled(&enabled);
     if (FAILED(hr))
         return hr;
index 1e406fa..d289859 100644 (file)
@@ -1,3 +1,25 @@
+2017-06-13  Daniel Bates  <dabates@apple.com>
+
+        Implement W3C Secure Contexts Draft Specification
+        https://bugs.webkit.org/show_bug.cgi?id=158121
+        <rdar://problem/26012994>
+
+        Reviewed by Brent Fulgham.
+
+        Part 4
+
+        Adds a preference to toggle the runtime enabled feature flag isSecureContextAttributeEnabled.
+
+        * Shared/WebPreferencesDefinitions.h:
+        * UIProcess/API/C/WKPreferences.cpp:
+        (WKPreferencesSetIsSecureContextAttributeEnabled):
+        (WKPreferencesGetIsSecureContextAttributeEnabled):
+        * UIProcess/API/C/WKPreferencesRefPrivate.h:
+        * WebProcess/InjectedBundle/InjectedBundle.cpp:
+        (WebKit::InjectedBundle::overrideBoolPreferenceForTestRunner):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::updatePreferences):
+
 2017-06-13  Brent Fulgham  <bfulgham@apple.com>
 
         [WK2][macOS] Allow AppleEvents in Citrix View Plugin
index da91516..3ef1ed5 100644 (file)
     macro(ConstantPropertiesEnabled, constantPropertiesEnabled, Bool, bool, DEFAULT_EXPERIMENTAL_FEATURES_ENABLED, "Constant Properties", "Enable CSS constant() properties") \
     macro(DisplayContentsEnabled, displayContentsEnabled, Bool, bool, false, "CSS display: contents", "Enable CSS display: contents support") \
     macro(SpringTimingFunctionEnabled, springTimingFunctionEnabled, Bool, bool, DEFAULT_EXPERIMENTAL_FEATURES_ENABLED, "CSS Spring Animations", "CSS Spring Animation prototype") \
+    macro(IsSecureContextAttributeEnabled, isSecureContextAttributeEnabled, Bool, bool, DEFAULT_EXPERIMENTAL_FEATURES_ENABLED, "isSecureContext attribute", "Enable isSecureContext attribute") \
     macro(LinkPreloadEnabled, linkPreloadEnabled, Bool, bool, DEFAULT_EXPERIMENTAL_FEATURES_ENABLED, "Link Preload", "Link preload support") \
     macro(WebRTCLegacyAPIDisabled, webRTCLegacyAPIDisabled, Bool, bool, DEFAULT_EXPERIMENTAL_FEATURES_ENABLED, "Remove Legacy WebRTC API", "Remove Legacy WebRTC API") \
     macro(SubresourceIntegrityEnabled, subresourceIntegrityEnabled, Bool, bool, DEFAULT_EXPERIMENTAL_FEATURES_ENABLED, "SubresourceIntegrity", "Enable SubresourceIntegrity") \
index f8f8254..72480ae 100644 (file)
@@ -1781,3 +1781,12 @@ WKStringRef WKPreferencesCopyMediaContentTypesRequiringHardwareSupport(WKPrefere
     return toCopiedAPI(toImpl(preferencesRef)->mediaContentTypesRequiringHardwareSupport());
 }
 
+void WKPreferencesSetIsSecureContextAttributeEnabled(WKPreferencesRef preferencesRef, bool flag)
+{
+    toImpl(preferencesRef)->setIsSecureContextAttributeEnabled(flag);
+}
+
+bool WKPreferencesGetIsSecureContextAttributeEnabled(WKPreferencesRef preferencesRef)
+{
+    return toImpl(preferencesRef)->isSecureContextAttributeEnabled();
+}
index b328156..31e5bf6 100644 (file)
@@ -501,6 +501,10 @@ WK_EXPORT bool WKPreferencesGetMediaUserGestureInheritsFromDocument(WKPreference
 WK_EXPORT void WKPreferencesSetMediaContentTypesRequiringHardwareSupport(WKPreferencesRef, WKStringRef);
 WK_EXPORT WKStringRef WKPreferencesCopyMediaContentTypesRequiringHardwareSupport(WKPreferencesRef);
 
+// Defaults to false.
+WK_EXPORT void WKPreferencesSetIsSecureContextAttributeEnabled(WKPreferencesRef, bool flag);
+WK_EXPORT bool WKPreferencesGetIsSecureContextAttributeEnabled(WKPreferencesRef);
+
 #ifdef __cplusplus
 }
 #endif
index 212a190..391604c 100644 (file)
@@ -224,6 +224,11 @@ void InjectedBundle::overrideBoolPreferenceForTestRunner(WebPageGroupProxy* page
         RuntimeEnabledFeatures::sharedFeatures().setWebRTCLegacyAPIEnabled(enabled);
 #endif
 
+    if (preference == "WebKitIsSecureContextAttributeEnabled") {
+        WebPreferencesStore::overrideBoolValueForKey(WebPreferencesKey::isSecureContextAttributeEnabledKey(), enabled);
+        RuntimeEnabledFeatures::sharedFeatures().setIsSecureContextAttributeEnabled(enabled);
+    }
+
     // 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 4da3195..ca5e488 100644 (file)
@@ -3364,6 +3364,7 @@ void WebPage::updatePreferences(const WebPreferencesStore& store)
     RuntimeEnabledFeatures::sharedFeatures().setLinkPreloadEnabled(store.getBoolValueForKey(WebPreferencesKey::linkPreloadEnabledKey()));
     RuntimeEnabledFeatures::sharedFeatures().setMediaPreloadingEnabled(store.getBoolValueForKey(WebPreferencesKey::mediaPreloadingEnabledKey()));
     RuntimeEnabledFeatures::sharedFeatures().setCredentialManagementEnabled(store.getBoolValueForKey(WebPreferencesKey::credentialManagementEnabledKey()));
+    RuntimeEnabledFeatures::sharedFeatures().setIsSecureContextAttributeEnabled(store.getBoolValueForKey(WebPreferencesKey::isSecureContextAttributeEnabledKey()));
 
     bool processSuppressionEnabled = store.getBoolValueForKey(WebPreferencesKey::pageVisibilityBasedProcessSuppressionEnabledKey());
     if (m_processSuppressionEnabled != processSuppressionEnabled) {
index db560f3..e96e538 100644 (file)
@@ -1,3 +1,30 @@
+2017-06-13  Daniel Bates  <dabates@apple.com>
+
+        Implement W3C Secure Contexts Draft Specification
+        https://bugs.webkit.org/show_bug.cgi?id=158121
+        <rdar://problem/26012994>
+
+        Reviewed by Brent Fulgham.
+
+        Part 4
+
+        Expose the isSecureContext attribute by default in DumpRenderTree and WebKitTestRunner.
+        Teach DumpRenderTree for Mac and WebKitTestRunner to parse the test option enableIsSecureContextAttribute
+        to toggle the runtime enabled feature flag isSecureContextAttributeEnabled.
+
+        * DumpRenderTree/TestOptions.h:
+        * DumpRenderTree/TestOptions.mm:
+        (TestOptions::TestOptions):
+        * DumpRenderTree/mac/DumpRenderTree.mm:
+        (setWebPreferencesForTestOptions):
+        * DumpRenderTree/win/DumpRenderTree.cpp:
+        (enableExperimentalFeatures):
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::resetPreferencesToConsistentValues):
+        (WTR::updateTestOptionsFromTestHeader):
+        * WebKitTestRunner/TestOptions.h:
+        (WTR::TestOptions::hasSameInitializationOptions):
+
 2017-06-13  Alex Christensen  <achristensen@webkit.org>
 
         Test persistent WKHTTPCookieStorages on iOS
index 2f0fc64..0924520 100644 (file)
@@ -35,6 +35,7 @@ struct TestOptions {
     bool enableCredentialManagement { false };
     bool enableDragDestinationActionLoad { false };
     bool layerBackedWebView { false };
+    bool enableIsSecureContextAttribute { true };
 
     TestOptions(NSURL*, const TestCommand&);
     bool webViewIsCompatibleWithOptions(const TestOptions&) const;
index 42d98f4..911da37 100644 (file)
@@ -92,6 +92,8 @@ TestOptions::TestOptions(NSURL *testURL, const TestCommand& command)
             this->enableDragDestinationActionLoad = parseBooleanTestHeaderValue(value);
         else if (key == "layerBackedWebView")
             this->layerBackedWebView = parseBooleanTestHeaderValue(value);
+        else if (key == "enableIsSecureContextAttribute")
+            this->enableIsSecureContextAttribute = parseBooleanTestHeaderValue(value);
         pairStart = pairEnd + 1;
     }
 }
index 8b65145..00f1740 100644 (file)
@@ -974,6 +974,7 @@ static void setWebPreferencesForTestOptions(const TestOptions& options)
     preferences.intersectionObserverEnabled = options.enableIntersectionObserver;
     preferences.modernMediaControlsEnabled = options.enableModernMediaControls;
     preferences.credentialManagementEnabled = options.enableCredentialManagement;
+    preferences.isSecureContextAttributeEnabled = options.enableIsSecureContextAttribute;
 }
 
 // Called once on DumpRenderTree startup.
index 8d0c99c..78d7565 100644 (file)
@@ -768,19 +768,20 @@ static bool shouldEnableDeveloperExtras(const char* pathOrURL)
 
 static void enableExperimentalFeatures(IWebPreferences* preferences)
 {
-    COMPtr<IWebPreferencesPrivate4> prefsPrivate4(Query, preferences);    
+    COMPtr<IWebPreferencesPrivate5> prefsPrivate { Query, preferences };
 
     // FIXME: CSSGridLayout
     // FIXME: SpringTimingFunction
     // FIXME: Gamepads
-    prefsPrivate4->setLinkPreloadEnabled(TRUE);
-    prefsPrivate4->setMediaPreloadingEnabled(TRUE);
+    prefsPrivate->setLinkPreloadEnabled(TRUE);
+    prefsPrivate->setMediaPreloadingEnabled(TRUE);
     // FIXME: ModernMediaControls
     // FIXME: InputEvents
     // FIXME: SubtleCrypto
-    prefsPrivate4->setWebAnimationsEnabled(TRUE);
+    prefsPrivate->setWebAnimationsEnabled(TRUE);
     // FIXME: WebGL2
     // FIXME: WebRTC
+    prefsPrivate->setIsSecureContextAttributeEnabled(TRUE);
 }
 
 static void resetWebPreferencesToConsistentValues(IWebPreferences* preferences)
index 04e4825..8765146 100644 (file)
@@ -682,6 +682,7 @@ void TestController::resetPreferencesToConsistentValues(const TestOptions& optio
     WKPreferencesSetIntersectionObserverEnabled(preferences, options.enableIntersectionObserver);
     WKPreferencesSetModernMediaControlsEnabled(preferences, options.enableModernMediaControls);
     WKPreferencesSetCredentialManagementEnabled(preferences, options.enableCredentialManagement);
+    WKPreferencesSetIsSecureContextAttributeEnabled(preferences, options.enableIsSecureContextAttribute);
 
     static WKStringRef defaultTextEncoding = WKStringCreateWithUTF8CString("ISO-8859-1");
     WKPreferencesSetDefaultTextEncodingName(preferences, defaultTextEncoding);
@@ -1016,6 +1017,8 @@ static void updateTestOptionsFromTestHeader(TestOptions& testOptions, const std:
             testOptions.enablePointerLock = parseBooleanTestHeaderValue(value);
         if (key == "enableCredentialManagement")
             testOptions.enableCredentialManagement = parseBooleanTestHeaderValue(value);
+        if (key == "enableIsSecureContextAttribute")
+            testOptions.enableIsSecureContextAttribute = parseBooleanTestHeaderValue(value);
         pairStart = pairEnd + 1;
     }
 }
index 1820375..1c4179d 100644 (file)
@@ -47,6 +47,7 @@ struct TestOptions {
     bool enableModernMediaControls { true };
     bool enablePointerLock { false };
     bool enableCredentialManagement { false };
+    bool enableIsSecureContextAttribute { true };
 
     float deviceScaleFactor { 1 };
     Vector<String> overrideLanguages;
@@ -67,7 +68,8 @@ struct TestOptions {
             || enableIntersectionObserver != options.enableIntersectionObserver
             || enableModernMediaControls != options.enableModernMediaControls
             || enablePointerLock != options.enablePointerLock
-            || enableCredentialManagement != options.enableCredentialManagement)
+            || enableCredentialManagement != options.enableCredentialManagement
+            || enableIsSecureContextAttribute != options.enableIsSecureContextAttribute)
             return false;
 
         return true;