Title: [255961] trunk
Revision
255961
Author
[email protected]
Date
2020-02-06 09:32:18 -0800 (Thu, 06 Feb 2020)

Log Message

Prevent navigating top level frames to Data URLs
https://bugs.webkit.org/show_bug.cgi?id=206962
<rdar://problem/56770676>

Source/WebCore:

Reviewed by Youenn Fablet.

Revise our loading behavior to match Chrome and Firefox by blocking
top level frame navigations to Data URLs.

Test: fast/loader/data-url-frame-allowed.html, fast/loader/data-url-load-denied.html

* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::disallowDataRequest const): Added,
(WebCore::DocumentLoader::continueAfterContentPolicy): Validate whether the load should
continue if it is a Data URL.
* loader/DocumentLoader.h:
(WebCore::DocumentLoader::setAllowsDataURLForMainFrame): Added.
(WebCore::DocumentLoader::allowsDataURLForMainFrame const): Added.
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::load): If the main frame loader as triggered by user action, or
direct call to the client API, allow top-frame navigation to Data URLs.
(WebCore::FrameLoader::reload): If the original load allowed top-frame navigation to Data
URLs, continue to do so in the reload.
* loader/FrameLoader.h:

Source/WebKit:

Reviewed by Youenn Fablet.

Expose a new off-by-default preference to allow top-level navigation to Data URIs.

Tests:  fast/loader/data-url-frame-allowed.html, fast/loader/data-url-load-denied.html

* Shared/WebPreferences.yaml:
* UIProcess/API/C/WKPreferences.cpp:
(WKPreferencesSetTopNavigationToDataURLsAllowed):
(WKPreferencesGetTopNavigationToDataURLsAllowed):
* UIProcess/API/C/WKPreferencesRefPrivate.h:
* UIProcess/API/Cocoa/WKPreferences.mm:
(-[WKPreferences _setTopNavigationToDataURLsAllowed:]):
(-[WKPreferences _topNavigationToDataURLsAllowed]):
* UIProcess/API/Cocoa/WKPreferencesPrivate.h:
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _setupPageConfiguration:]):
* UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
(-[WKWebViewConfiguration init]):
(-[WKWebViewConfiguration copyWithZone:]):
(-[WKWebViewConfiguration _allowTopNavigationToDataURLs]):
(-[WKWebViewConfiguration _setAllowTopNavigationToDataURLs:]):
* UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h:
* UIProcess/Inspector/mac/WKInspectorViewController.mm:
(-[WKInspectorViewController configuration]):

Source/WebKitLegacy/mac:

Reviewed by Youenn Fablet.

Expose a new off-by-default preference to allow top-level navigation to Data URIs.

Tests:  fast/loader/data-url-frame-allowed.html, fast/loader/data-url-load-denied.html

* WebCoreSupport/WebInspectorClient.mm:
(-[WebInspectorWindowController init]):
* WebView/WebPreferenceKeysPrivate.h:
* WebView/WebPreferences.mm:
(+[WebPreferences initialize]):
(-[WebPreferences allowTopNavigationToDataURLs]):
(-[WebPreferences setAllowTopNavigationToDataURLs:]):
* WebView/WebPreferencesPrivate.h:
* WebView/WebView.mm:
(-[WebView _preferencesChanged:]):

Source/WebKitLegacy/win:

Reviewed by Youenn Fablet.

Expose a new off-by-default preference to allow top-level navigation to Data URIs.

* Interfaces/WebKit.idl: Touch file to trigger a build.
* Interfaces/IWebPreferences.idl: Ditto.
* Interfaces/IWebPreferencesPrivate.idl: Expose new API version to avoid breaking shipping binaries.
* WebPreferenceKeysPrivate.h:
* WebPreferences.cpp:
(WebPreferences::initializeDefaultSettings): Update for new setting.
(WebPreferences::QueryInterface): Add support for IWebPreferencesPrivate8 interface.
(WebPreferences::allowTopNavigationToDataURLs): Added.
(WebPreferences::setAllowTopNavigationToDataURLs): Added.
* WebPreferences.h:
* WebView.cpp:
(WebView::notifyPreferencesChanged): Update to handle Data URL setting.

Tools:

Reviewed by Youenn Fablet.

Revise test running code to allow data URL navigations by default, since they are so frequently
used in testing. However, provide a flag to turn this off in tests so we can confirm proper
function.

* DumpRenderTree/TestOptions.cpp:
(TestOptions::TestOptions):
* DumpRenderTree/TestOptions.h:
* DumpRenderTree/mac/DumpRenderTree.mm:
(setWebPreferencesForTestOptions):
* TestWebKitAPI/Tests/WebKitCocoa/Download.mm:
(DownloadAttributeDoesNotStartDownloads): Revise configuration to allow script navigation of the main frame to a Data URL.
(StartDownloadWithDownloadAttribute): Ditto.
* TestWebKitAPI/Tests/WebKitCocoa/Navigation.mm:
(WebViewWillPerformClientRedirect): Ditto.
(WebViewDidCancelClientRedirect): Ditto.
* TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:
(NavigateToDataURLThenBack): Ditto.
(ContentExtensionBlocksMainLoadThenReloadWithoutExtensions): Ditto.
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::resetPreferencesToConsistentValues):
(WTR::updateTestOptionsFromTestHeader):
* WebKitTestRunner/TestOptions.h:
(WTR::TestOptions::hasSameInitializationOptions const):
* WebKitTestRunner/cocoa/TestControllerCocoa.mm:
(WTR::initializeWebViewConfiguration):
(WTR::TestController::platformCreateWebView):

LayoutTests:

Reviewed by Youenn Fablet."

Revise our loading behavior to match Chrome and Firefox by blocking
top level frame navigations to Data URLs.

* fast/loader/data-url-frame-allowed.html: Added.
* fast/loader/data-url-frame-allowed-expected.txt : Added.
* fast/loader/data-url-load-denied.html: Added.
* fast/loader/data-url-load-denied-expected.txt: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (255960 => 255961)


--- trunk/LayoutTests/ChangeLog	2020-02-06 17:12:22 UTC (rev 255960)
+++ trunk/LayoutTests/ChangeLog	2020-02-06 17:32:18 UTC (rev 255961)
@@ -1,3 +1,19 @@
+2020-02-06  Brent Fulgham  <[email protected]>
+
+        Prevent navigating top level frames to Data URLs
+        https://bugs.webkit.org/show_bug.cgi?id=206962
+        <rdar://problem/56770676>
+
+        Reviewed by Youenn Fablet."
+
+        Revise our loading behavior to match Chrome and Firefox by blocking
+        top level frame navigations to Data URLs.
+
+        * fast/loader/data-url-frame-allowed.html: Added.
+        * fast/loader/data-url-frame-allowed-expected.txt : Added.
+        * fast/loader/data-url-load-denied.html: Added.
+        * fast/loader/data-url-load-denied-expected.txt: Added.
+
 2020-02-06  Truitt Savell  <[email protected]>
 
         REGRESSION: (r255821) [ iOS Mac wk1 ] imported/w3c/web-platform-tests/web-animations/timing-model/animations/finishing-an-animation.html

Added: trunk/LayoutTests/fast/loader/data-url-frame-allowed-expected.txt (0 => 255961)


--- trunk/LayoutTests/fast/loader/data-url-frame-allowed-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/loader/data-url-frame-allowed-expected.txt	2020-02-06 17:32:18 UTC (rev 255961)
@@ -0,0 +1,11 @@
+Tests that we can load an iframe from a data URL.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+
+
+--------
+Frame: '<!--frame1-->'
+--------
+PASS: Load succeeded.

Added: trunk/LayoutTests/fast/loader/data-url-frame-allowed.html (0 => 255961)


--- trunk/LayoutTests/fast/loader/data-url-frame-allowed.html	                        (rev 0)
+++ trunk/LayoutTests/fast/loader/data-url-frame-allowed.html	2020-02-06 17:32:18 UTC (rev 255961)
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script>
+jsTestIsAsync = true;
+
+description("Tests that we can load an iframe from a data URL.");
+
+function runTest() {
+    if (window.testRunner) {
+        testRunner.dumpAsText();
+        testRunner.dumpChildFramesAsText();
+    }
+
+    var frame = document.createElement('iframe');
+    document.body.appendChild(frame);
+
+    frame.src = "" Load succeeded.<script>window.testRunner && window.testRunner.notifyDone()</" + "script>";
+}
+</script>
+</head>
+<body _onload_=runTest()>
+</body>
+</html>
\ No newline at end of file

Added: trunk/LayoutTests/fast/loader/data-url-load-denied-expected.txt (0 => 255961)


--- trunk/LayoutTests/fast/loader/data-url-load-denied-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/loader/data-url-load-denied-expected.txt	2020-02-06 17:32:18 UTC (rev 255961)
@@ -0,0 +1,11 @@
+CONSOLE MESSAGE: Not allowed to navigate top frame to data URL 'data:text/html,<body _onload_='testRunner.notifyDone()'>FAIL: This should not have loaded.'.
+Tests that we do not redirect to a data URL. This test PASSED if you see an entry in the dumped frame load callbacks of the form: "willPerformClientRedirectToURL: data:text/html,<body _onload_=...b" followed by "didCancelClientRedirectForFrame" followed by didFailProvisionalLoadWithError.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS testRunner.didCancelClientRedirect became true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/loader/data-url-load-denied.html (0 => 255961)


--- trunk/LayoutTests/fast/loader/data-url-load-denied.html	                        (rev 0)
+++ trunk/LayoutTests/fast/loader/data-url-load-denied.html	2020-02-06 17:32:18 UTC (rev 255961)
@@ -0,0 +1,19 @@
+<!-- webkit-test-runner [ allowTopNavigationToDataURLs=false ] -->
+<html>
+<head>
+<meta http-equiv="refresh" content="0; url="" _onload_='testRunner.notifyDone()'>FAIL: This should not have loaded.">
+<script src=""
+<script>
+if (window.testRunner)
+    testRunner.dumpAsText();
+jsTestIsAsync = true;
+</script>
+</head>
+<body>
+<script>
+description("Tests that we do not redirect to a data URL. This test PASSED if you see an entry in the dumped frame load callbacks of the form: &quot;willPerformClientRedirectToURL: data:text/html,&lt;body _onload_=...b&quot; followed by &quot;didCancelClientRedirectForFrame&quot; followed by didFailProvisionalLoadWithError.");
+
+shouldBecomeEqual("testRunner.didCancelClientRedirect", "true", finishJSTest);
+</script>
+</body>
+</html>
\ No newline at end of file

Modified: trunk/Source/WebCore/ChangeLog (255960 => 255961)


--- trunk/Source/WebCore/ChangeLog	2020-02-06 17:12:22 UTC (rev 255960)
+++ trunk/Source/WebCore/ChangeLog	2020-02-06 17:32:18 UTC (rev 255961)
@@ -1,3 +1,30 @@
+2020-02-06  Brent Fulgham  <[email protected]>
+
+        Prevent navigating top level frames to Data URLs
+        https://bugs.webkit.org/show_bug.cgi?id=206962
+        <rdar://problem/56770676>
+
+        Reviewed by Youenn Fablet.
+
+        Revise our loading behavior to match Chrome and Firefox by blocking
+        top level frame navigations to Data URLs.
+
+        Test: fast/loader/data-url-frame-allowed.html, fast/loader/data-url-load-denied.html
+
+        * loader/DocumentLoader.cpp:
+        (WebCore::DocumentLoader::disallowDataRequest const): Added,
+        (WebCore::DocumentLoader::continueAfterContentPolicy): Validate whether the load should
+        continue if it is a Data URL.
+        * loader/DocumentLoader.h:
+        (WebCore::DocumentLoader::setAllowsDataURLForMainFrame): Added.
+        (WebCore::DocumentLoader::allowsDataURLForMainFrame const): Added.
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::load): If the main frame loader as triggered by user action, or
+        direct call to the client API, allow top-frame navigation to Data URLs.
+        (WebCore::FrameLoader::reload): If the original load allowed top-frame navigation to Data
+        URLs, continue to do so in the reload.
+        * loader/FrameLoader.h:
+
 2020-02-06  Cathie Chen  <[email protected]>
 
         Add support for scroll behavior relies on ScrollAnimation of the Web process

Modified: trunk/Source/WebCore/loader/DocumentLoader.cpp (255960 => 255961)


--- trunk/Source/WebCore/loader/DocumentLoader.cpp	2020-02-06 17:12:22 UTC (rev 255960)
+++ trunk/Source/WebCore/loader/DocumentLoader.cpp	2020-02-06 17:32:18 UTC (rev 255961)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006-2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2006-2020 Apple Inc. All rights reserved.
  * Copyright (C) 2011 Google Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -908,6 +908,26 @@
     return true;
 }
 
+// Prevent data URIs from loading as the main frame unless the result of user action.
+bool DocumentLoader::disallowDataRequest() const
+{
+    if (!m_response.url().protocolIsData())
+        return false;
+
+    if (!frame() || !frame()->isMainFrame() || m_allowsDataURLsForMainFrame || frame()->settings().allowTopNavigationToDataURLs())
+        return false;
+
+    if (auto* currentDocument = frame()->document()) {
+        unsigned long identifier = m_identifierForLoadWithoutResourceLoader ? m_identifierForLoadWithoutResourceLoader : m_mainResource->identifier();
+        ASSERT(identifier);
+
+        currentDocument->addConsoleMessage(MessageSource::Security, MessageLevel::Error, makeString("Not allowed to navigate top frame to data URL '", m_response.url().stringCenterEllipsizedToLength(), "'."), identifier);
+    }
+    RELEASE_LOG_IF_ALLOWED("continueAfterContentPolicy: cannot show URL (frame = %p, main = %d)", m_frame, m_frame->isMainFrame());
+
+    return true;
+}
+
 void DocumentLoader::continueAfterContentPolicy(PolicyAction policy)
 {
     ASSERT(m_waitingForContentPolicy);
@@ -922,7 +942,7 @@
 
     switch (policy) {
     case PolicyAction::Use: {
-        if (!frameLoader()->client().canShowMIMEType(m_response.mimeType()) || disallowWebArchive()) {
+        if (!frameLoader()->client().canShowMIMEType(m_response.mimeType()) || disallowWebArchive() || disallowDataRequest()) {
             frameLoader()->policyChecker().cannotShowMIMEType(m_response);
             // Check reachedTerminalState since the load may have already been canceled inside of _handleUnimplementablePolicyWithErrorCode::.
             stopLoadingForPolicyChange();

Modified: trunk/Source/WebCore/loader/DocumentLoader.h (255960 => 255961)


--- trunk/Source/WebCore/loader/DocumentLoader.h	2020-02-06 17:12:22 UTC (rev 255960)
+++ trunk/Source/WebCore/loader/DocumentLoader.h	2020-02-06 17:32:18 UTC (rev 255961)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2006-2020 Apple Inc. All rights reserved.
  * Copyright (C) 2011 Google Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -394,6 +394,9 @@
     void setAllowsWebArchiveForMainFrame(bool allowsWebArchiveForMainFrame) { m_allowsWebArchiveForMainFrame = allowsWebArchiveForMainFrame; }
     bool allowsWebArchiveForMainFrame() const { return m_allowsWebArchiveForMainFrame; }
 
+    void setAllowsDataURLsForMainFrame(bool allowsDataURLsForMainFrame) { m_allowsDataURLsForMainFrame = allowsDataURLsForMainFrame; }
+    bool allowsDataURLsForMainFrame() const { return m_allowsDataURLsForMainFrame; }
+
     void setDownloadAttribute(const String& attribute) { m_downloadAttribute = attribute; }
     const String& downloadAttribute() const { return m_downloadAttribute; }
 
@@ -502,6 +505,7 @@
     WEBCORE_EXPORT void enqueueSecurityPolicyViolationEvent(SecurityPolicyViolationEvent::Init&&) final;
 
     bool disallowWebArchive() const;
+    bool disallowDataRequest() const;
 
     Ref<CachedResourceLoader> m_cachedResourceLoader;
 
@@ -640,6 +644,7 @@
 #endif
 
     bool m_allowsWebArchiveForMainFrame { false };
+    bool m_allowsDataURLsForMainFrame { false };
     String m_downloadAttribute;
 };
 

Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (255960 => 255961)


--- trunk/Source/WebCore/loader/FrameLoader.cpp	2020-02-06 17:12:22 UTC (rev 255960)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp	2020-02-06 17:32:18 UTC (rev 255961)
@@ -1479,6 +1479,7 @@
 
     Ref<DocumentLoader> loader = m_client.createDocumentLoader(request.resourceRequest(), request.substituteData());
     loader->setAllowsWebArchiveForMainFrame(request.isRequestFromClientOrUserInput());
+    loader->setAllowsDataURLsForMainFrame(request.isRequestFromClientOrUserInput());
     addSameSiteInfoToRequestIfNeeded(loader->request());
     applyShouldOpenExternalURLsPolicyToNewDocumentLoader(m_frame, loader, request);
 
@@ -1779,6 +1780,7 @@
     // but first it has to be the "policy" document loader, and then the "provisional" document loader.
     Ref<DocumentLoader> loader = m_client.createDocumentLoader(initialRequest, defaultSubstituteDataForURL(initialRequest.url()));
     loader->setAllowsWebArchiveForMainFrame(m_documentLoader->allowsWebArchiveForMainFrame());
+    loader->setAllowsDataURLsForMainFrame(m_documentLoader->allowsDataURLsForMainFrame());
     applyShouldOpenExternalURLsPolicyToNewDocumentLoader(m_frame, loader, InitiatedByMainFrame::Unknown, m_documentLoader->shouldOpenExternalURLsPolicyToPropagate());
 
     loader->setUserContentExtensionsEnabled(!options.contains(ReloadOption::DisableContentBlockers));

Modified: trunk/Source/WebCore/page/Settings.yaml (255960 => 255961)


--- trunk/Source/WebCore/page/Settings.yaml	2020-02-06 17:12:22 UTC (rev 255960)
+++ trunk/Source/WebCore/page/Settings.yaml	2020-02-06 17:32:18 UTC (rev 255961)
@@ -107,6 +107,8 @@
   initial: false
 allowCrossOriginSubresourcesToAskForCredentials:
   initial: false
+allowTopNavigationToDataURLs:
+  initial: false
 needsStorageAccessFromFileURLsQuirk:
   initial: true
 needsFrameNameFallbackToIdQuirk:

Modified: trunk/Source/WebKit/ChangeLog (255960 => 255961)


--- trunk/Source/WebKit/ChangeLog	2020-02-06 17:12:22 UTC (rev 255960)
+++ trunk/Source/WebKit/ChangeLog	2020-02-06 17:32:18 UTC (rev 255961)
@@ -1,3 +1,35 @@
+2020-02-06  Brent Fulgham  <[email protected]>
+
+        Prevent navigating top level frames to Data URLs
+        https://bugs.webkit.org/show_bug.cgi?id=206962
+        <rdar://problem/56770676>
+
+        Reviewed by Youenn Fablet.
+
+        Expose a new off-by-default preference to allow top-level navigation to Data URIs.
+
+        Tests:  fast/loader/data-url-frame-allowed.html, fast/loader/data-url-load-denied.html
+
+        * Shared/WebPreferences.yaml:
+        * UIProcess/API/C/WKPreferences.cpp:
+        (WKPreferencesSetTopNavigationToDataURLsAllowed):
+        (WKPreferencesGetTopNavigationToDataURLsAllowed):
+        * UIProcess/API/C/WKPreferencesRefPrivate.h:
+        * UIProcess/API/Cocoa/WKPreferences.mm:
+        (-[WKPreferences _setTopNavigationToDataURLsAllowed:]):
+        (-[WKPreferences _topNavigationToDataURLsAllowed]):
+        * UIProcess/API/Cocoa/WKPreferencesPrivate.h:
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _setupPageConfiguration:]):
+        * UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
+        (-[WKWebViewConfiguration init]):
+        (-[WKWebViewConfiguration copyWithZone:]):
+        (-[WKWebViewConfiguration _allowTopNavigationToDataURLs]):
+        (-[WKWebViewConfiguration _setAllowTopNavigationToDataURLs:]):
+        * UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h:
+        * UIProcess/Inspector/mac/WKInspectorViewController.mm:
+        (-[WKInspectorViewController configuration]):
+
 2020-02-06  Alex Christensen  <[email protected]>
 
         Remove unused SPI WKWebViewConfiguration._treatsSHA1SignedCertificatesAsInsecure

Modified: trunk/Source/WebKit/Shared/WebPreferences.yaml (255960 => 255961)


--- trunk/Source/WebKit/Shared/WebPreferences.yaml	2020-02-06 17:12:22 UTC (rev 255960)
+++ trunk/Source/WebKit/Shared/WebPreferences.yaml	2020-02-06 17:32:18 UTC (rev 255961)
@@ -219,6 +219,10 @@
   type: bool
   defaultValue: false
 
+AllowTopNavigationToDataURLs:
+  type: bool
+  defaultValue: false
+
 AVFoundationEnabled:
   type: bool
   defaultValue: DEFAULT_AVFOUNDATION_ENABLED

Modified: trunk/Source/WebKit/UIProcess/API/C/WKPreferences.cpp (255960 => 255961)


--- trunk/Source/WebKit/UIProcess/API/C/WKPreferences.cpp	2020-02-06 17:12:22 UTC (rev 255960)
+++ trunk/Source/WebKit/UIProcess/API/C/WKPreferences.cpp	2020-02-06 17:32:18 UTC (rev 255961)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010-2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2010-2020 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -738,6 +738,16 @@
     return toImpl(preferencesRef)->allowFileAccessFromFileURLs();
 }
 
+void WKPreferencesSetTopNavigationToDataURLsAllowed(WKPreferencesRef preferencesRef, bool allowed)
+{
+    toImpl(preferencesRef)->setAllowTopNavigationToDataURLs(allowed);
+}
+
+bool WKPreferencesGetTopNavigationToDataURLsAllowed(WKPreferencesRef preferencesRef)
+{
+    return toImpl(preferencesRef)->allowTopNavigationToDataURLs();
+}
+
 void WKPreferencesSetNeedsStorageAccessFromFileURLsQuirk(WKPreferencesRef preferencesRef, bool needsQuirk)
 {
     toImpl(preferencesRef)->setNeedsStorageAccessFromFileURLsQuirk(needsQuirk);

Modified: trunk/Source/WebKit/UIProcess/API/C/WKPreferencesRefPrivate.h (255960 => 255961)


--- trunk/Source/WebKit/UIProcess/API/C/WKPreferencesRefPrivate.h	2020-02-06 17:12:22 UTC (rev 255960)
+++ trunk/Source/WebKit/UIProcess/API/C/WKPreferencesRefPrivate.h	2020-02-06 17:32:18 UTC (rev 255961)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010-2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2010-2020 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -154,6 +154,10 @@
 WK_EXPORT void WKPreferencesSetFileAccessFromFileURLsAllowed(WKPreferencesRef preferences, bool allowed);
 WK_EXPORT bool WKPreferencesGetFileAccessFromFileURLsAllowed(WKPreferencesRef preferences);
 
+// Defaults to false.
+WK_EXPORT void WKPreferencesSetTopNavigationToDataURLsAllowed(WKPreferencesRef preferences, bool allowed);
+WK_EXPORT bool WKPreferencesGetTopNavigationToDataURLsAllowed(WKPreferencesRef preferences);
+
 // Defaults to true
 WK_EXPORT void WKPreferencesSetNeedsStorageAccessFromFileURLsQuirk(WKPreferencesRef preferences, bool needsQuirk);
 WK_EXPORT bool WKPreferencesGetNeedsStorageAccessFromFileURLsQuirk(WKPreferencesRef preferences);

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKPreferences.mm (255960 => 255961)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKPreferences.mm	2020-02-06 17:12:22 UTC (rev 255960)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKPreferences.mm	2020-02-06 17:32:18 UTC (rev 255961)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2014-2020 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -1028,6 +1028,16 @@
     return _preferences->allowUniversalAccessFromFileURLs();
 }
 
+- (void)_setTopNavigationToDataURLsAllowed:(BOOL)enabled
+{
+    _preferences->setAllowTopNavigationToDataURLs(enabled);
+}
+
+- (BOOL)_topNavigationToDataURLsAllowed
+{
+    return _preferences->allowTopNavigationToDataURLs();
+}
+
 - (void)_setSuppressesIncrementalRendering:(BOOL)enabled
 {
     _preferences->setSuppressesIncrementalRendering(enabled);

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKPreferencesPrivate.h (255960 => 255961)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKPreferencesPrivate.h	2020-02-06 17:12:22 UTC (rev 255960)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKPreferencesPrivate.h	2020-02-06 17:32:18 UTC (rev 255961)
@@ -178,6 +178,7 @@
 @property (nonatomic, setter=_setShouldPrintBackgrounds:) BOOL _shouldPrintBackgrounds WK_API_AVAILABLE(macos(10.13.4));
 @property (nonatomic, setter=_setWebSecurityEnabled:) BOOL _webSecurityEnabled WK_API_AVAILABLE(macos(10.13.4));
 @property (nonatomic, setter=_setUniversalAccessFromFileURLsAllowed:) BOOL _universalAccessFromFileURLsAllowed WK_API_AVAILABLE(macos(10.13.4));
+@property (nonatomic, setter=_setTopNavigationToDataURLsAllowed:) BOOL _topNavigationToDataURLsAllowed WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
 @property (nonatomic, setter=_setSuppressesIncrementalRendering:) BOOL _suppressesIncrementalRendering WK_API_AVAILABLE(macos(10.13.4));
 @property (nonatomic, setter=_setAsynchronousPluginInitializationEnabled:) BOOL _asynchronousPluginInitializationEnabled WK_API_AVAILABLE(macos(10.13.4));
 @property (nonatomic, setter=_setArtificialPluginInitializationDelayEnabled:) BOOL _artificialPluginInitializationDelayEnabled WK_API_AVAILABLE(macos(10.13.4));

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (255960 => 255961)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2020-02-06 17:12:22 UTC (rev 255960)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2020-02-06 17:32:18 UTC (rev 255961)
@@ -437,6 +437,7 @@
     pageConfiguration->preferenceValues().set(WebKit::WebPreferencesKey::shouldConvertPositionStyleOnCopyKey(), WebKit::WebPreferencesStore::Value(!![_configuration _convertsPositionStyleOnCopy]));
     pageConfiguration->preferenceValues().set(WebKit::WebPreferencesKey::httpEquivEnabledKey(), WebKit::WebPreferencesStore::Value(!![_configuration _allowsMetaRefresh]));
     pageConfiguration->preferenceValues().set(WebKit::WebPreferencesKey::allowUniversalAccessFromFileURLsKey(), WebKit::WebPreferencesStore::Value(!![_configuration _allowUniversalAccessFromFileURLs]));
+    pageConfiguration->preferenceValues().set(WebKit::WebPreferencesKey::allowTopNavigationToDataURLsKey(), WebKit::WebPreferencesStore::Value(!![_configuration _allowTopNavigationToDataURLs]));
     pageConfiguration->setWaitsForPaintAfterViewDidMoveToWindow([_configuration _waitsForPaintAfterViewDidMoveToWindow]);
     pageConfiguration->setDrawsBackground([_configuration _drawsBackground]);
     pageConfiguration->setControlledByAutomation([_configuration _isControlledByAutomation]);

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm (255960 => 255961)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm	2020-02-06 17:12:22 UTC (rev 255960)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm	2020-02-06 17:32:18 UTC (rev 255961)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2014-2020 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -131,6 +131,7 @@
     BOOL _convertsPositionStyleOnCopy;
     BOOL _allowsMetaRefresh;
     BOOL _allowUniversalAccessFromFileURLs;
+    BOOL _allowTopNavigationToDataURLs;
 
 #if PLATFORM(IOS_FAMILY)
     LazyInitialized<RetainPtr<WKWebViewContentProviderRegistry>> _contentProviderRegistry;
@@ -235,6 +236,7 @@
     _convertsPositionStyleOnCopy = NO;
     _allowsMetaRefresh = YES;
     _allowUniversalAccessFromFileURLs = NO;
+    _allowTopNavigationToDataURLs = NO;
     _needsStorageAccessFromFileURLsQuirk = YES;
 
 #if PLATFORM(IOS_FAMILY)
@@ -382,6 +384,7 @@
     configuration->_convertsPositionStyleOnCopy = self->_convertsPositionStyleOnCopy;
     configuration->_allowsMetaRefresh = self->_allowsMetaRefresh;
     configuration->_allowUniversalAccessFromFileURLs = self->_allowUniversalAccessFromFileURLs;
+    configuration->_allowTopNavigationToDataURLs = self->_allowTopNavigationToDataURLs;
 
     configuration->_invisibleAutoplayNotPermitted = self->_invisibleAutoplayNotPermitted;
     configuration->_mediaDataLoadsAutomatically = self->_mediaDataLoadsAutomatically;
@@ -671,6 +674,16 @@
     _allowUniversalAccessFromFileURLs = allowUniversalAccessFromFileURLs;
 }
 
+- (BOOL)_allowTopNavigationToDataURLs
+{
+    return _allowTopNavigationToDataURLs;
+}
+
+- (void)_setAllowTopNavigationToDataURLs:(BOOL)allowTopNavigationToDataURLs
+{
+    _allowTopNavigationToDataURLs = allowTopNavigationToDataURLs;
+}
+
 - (BOOL)_convertsPositionStyleOnCopy
 {
     return _convertsPositionStyleOnCopy;

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h (255960 => 255961)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h	2020-02-06 17:12:22 UTC (rev 255960)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h	2020-02-06 17:32:18 UTC (rev 255961)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014, 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2014-2020 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -64,6 +64,7 @@
 @property (nonatomic, setter=_setConvertsPositionStyleOnCopy:) BOOL _convertsPositionStyleOnCopy WK_API_AVAILABLE(macos(10.12), ios(10.0));
 @property (nonatomic, setter=_setAllowsMetaRefresh:) BOOL _allowsMetaRefresh WK_API_AVAILABLE(macos(10.12), ios(10.0));
 @property (nonatomic, setter=_setAllowUniversalAccessFromFileURLs:) BOOL _allowUniversalAccessFromFileURLs WK_API_AVAILABLE(macos(10.12), ios(10.0));
+@property (nonatomic, setter=_setAllowTopNavigationToDataURLs:) BOOL _allowTopNavigationToDataURLs WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
 @property (nonatomic, setter=_setNeedsStorageAccessFromFileURLsQuirk:) BOOL _needsStorageAccessFromFileURLsQuirk WK_API_AVAILABLE(macos(10.12.3), ios(10.3));
 @property (nonatomic, setter=_setMainContentUserGestureOverrideEnabled:) BOOL _mainContentUserGestureOverrideEnabled WK_API_AVAILABLE(macos(10.12), ios(10.0));
 @property (nonatomic, setter=_setInvisibleAutoplayNotPermitted:) BOOL _invisibleAutoplayNotPermitted WK_API_AVAILABLE(macos(10.12), ios(10.0));

Modified: trunk/Source/WebKit/UIProcess/Inspector/mac/WKInspectorViewController.mm (255960 => 255961)


--- trunk/Source/WebKit/UIProcess/Inspector/mac/WKInspectorViewController.mm	2020-02-06 17:12:22 UTC (rev 255960)
+++ trunk/Source/WebKit/UIProcess/Inspector/mac/WKInspectorViewController.mm	2020-02-06 17:32:18 UTC (rev 255961)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2017-2020 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -111,6 +111,7 @@
     WKPreferences *preferences = configuration.get().preferences;
     preferences._allowFileAccessFromFileURLs = YES;
     [configuration _setAllowUniversalAccessFromFileURLs:YES];
+    [configuration _setAllowTopNavigationToDataURLs:YES];
     preferences._storageBlockingPolicy = _WKStorageBlockingPolicyAllowAll;
     preferences._javaScriptRuntimeFlags = 0;
 

Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (255960 => 255961)


--- trunk/Source/WebKitLegacy/mac/ChangeLog	2020-02-06 17:12:22 UTC (rev 255960)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog	2020-02-06 17:32:18 UTC (rev 255961)
@@ -1,3 +1,26 @@
+2020-02-06  Brent Fulgham  <[email protected]>
+
+        Prevent navigating top level frames to Data URLs
+        https://bugs.webkit.org/show_bug.cgi?id=206962
+        <rdar://problem/56770676>
+
+        Reviewed by Youenn Fablet.
+
+        Expose a new off-by-default preference to allow top-level navigation to Data URIs.
+
+        Tests:  fast/loader/data-url-frame-allowed.html, fast/loader/data-url-load-denied.html
+
+        * WebCoreSupport/WebInspectorClient.mm:
+        (-[WebInspectorWindowController init]):
+        * WebView/WebPreferenceKeysPrivate.h:
+        * WebView/WebPreferences.mm:
+        (+[WebPreferences initialize]):
+        (-[WebPreferences allowTopNavigationToDataURLs]):
+        (-[WebPreferences setAllowTopNavigationToDataURLs:]):
+        * WebView/WebPreferencesPrivate.h:
+        * WebView/WebView.mm:
+        (-[WebView _preferencesChanged:]):
+
 2020-02-01  Devin Rousso  <[email protected]>
 
         Web Inspector: move the items in the toolbar into the tab bar to save vertical space

Modified: trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebInspectorClient.mm (255960 => 255961)


--- trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebInspectorClient.mm	2020-02-06 17:12:22 UTC (rev 255960)
+++ trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebInspectorClient.mm	2020-02-06 17:32:18 UTC (rev 255961)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006-2008, 2015 Apple Inc.  All rights reserved.
+ * Copyright (C) 2006-2020 Apple Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -450,6 +450,7 @@
     [preferences setUserStyleSheetEnabled:NO];
     [preferences setAllowFileAccessFromFileURLs:YES];
     [preferences setAllowUniversalAccessFromFileURLs:YES];
+    [preferences setAllowTopNavigationToDataURLs:YES];
     [preferences setStorageBlockingPolicy:WebAllowAllStorage];
 
     _frontendWebView = [[WebView alloc] init];

Modified: trunk/Source/WebKitLegacy/mac/WebView/WebPreferenceKeysPrivate.h (255960 => 255961)


--- trunk/Source/WebKitLegacy/mac/WebView/WebPreferenceKeysPrivate.h	2020-02-06 17:12:22 UTC (rev 255960)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebPreferenceKeysPrivate.h	2020-02-06 17:32:18 UTC (rev 255961)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2005-2020 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -61,6 +61,7 @@
 #define WebKitAllowUniversalAccessFromFileURLsPreferenceKey @"WebKitAllowUniversalAccessFromFileURLs"
 #define WebKitAllowFileAccessFromFileURLsPreferenceKey @"WebKitAllowFileAccessFromFileURLs"
 #define WebKitAllowCrossOriginSubresourcesToAskForCredentialsKey @"WebKitAllowCrossOriginSubresourcesToAskForCredentials"
+#define WebKitAllowTopNavigationToDataURLsPreferenceKey @"WebKitAllowTopNavigationToDataURLs"
 #define WebKitNeedsStorageAccessFromFileURLsQuirkKey @"WebKitNeedsStorageAccessFromFileURLsQuirk"
 #define WebKitJavaScriptCanOpenWindowsAutomaticallyPreferenceKey @"WebKitJavaScriptCanOpenWindowsAutomatically"
 #define WebKitPluginsEnabledPreferenceKey @"WebKitPluginsEnabled"

Modified: trunk/Source/WebKitLegacy/mac/WebView/WebPreferences.mm (255960 => 255961)


--- trunk/Source/WebKitLegacy/mac/WebView/WebPreferences.mm	2020-02-06 17:12:22 UTC (rev 255960)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebPreferences.mm	2020-02-06 17:32:18 UTC (rev 255961)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2005-2020 Apple Inc. All rights reserved.
  *           (C) 2006 Graham Dennis ([email protected])
  *
  * Redistribution and use in source and binary forms, with or without
@@ -433,6 +433,7 @@
         @YES, WebKitWebSecurityEnabledPreferenceKey,
         @YES, WebKitAllowUniversalAccessFromFileURLsPreferenceKey,
         @YES, WebKitAllowFileAccessFromFileURLsPreferenceKey,
+        @YES, WebKitAllowTopNavigationToDataURLsPreferenceKey,
 #if PLATFORM(IOS_FAMILY)
         @NO, WebKitJavaScriptCanOpenWindowsAutomaticallyPreferenceKey,
 #else
@@ -1570,6 +1571,16 @@
     [self _setBoolValue: flag forKey: WebKitAllowFileAccessFromFileURLsPreferenceKey];
 }
 
+- (BOOL)allowTopNavigationToDataURLs
+{
+    return [self _boolValueForKey: WebKitAllowTopNavigationToDataURLsPreferenceKey];
+}
+
+- (void)setAllowTopNavigationToDataURLs:(BOOL)flag
+{
+    [self _setBoolValue: flag forKey: WebKitAllowTopNavigationToDataURLsPreferenceKey];
+}
+
 - (BOOL)allowCrossOriginSubresourcesToAskForCredentials
 {
     return [self _boolValueForKey:WebKitAllowCrossOriginSubresourcesToAskForCredentialsKey];

Modified: trunk/Source/WebKitLegacy/mac/WebView/WebPreferencesPrivate.h (255960 => 255961)


--- trunk/Source/WebKitLegacy/mac/WebView/WebPreferencesPrivate.h	2020-02-06 17:12:22 UTC (rev 255960)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebPreferencesPrivate.h	2020-02-06 17:32:18 UTC (rev 255961)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2005-2020 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -153,6 +153,9 @@
 - (BOOL)allowFileAccessFromFileURLs;
 - (void)setAllowFileAccessFromFileURLs:(BOOL)flag;
 
+- (BOOL)allowTopNavigationToDataURLs;
+- (void)setAllowTopNavigationToDataURLs:(BOOL)flag;
+
 - (BOOL)allowCrossOriginSubresourcesToAskForCredentials;
 - (void)setAllowCrossOriginSubresourcesToAskForCredentials:(BOOL)flag;
 

Modified: trunk/Source/WebKitLegacy/mac/WebView/WebView.mm (255960 => 255961)


--- trunk/Source/WebKitLegacy/mac/WebView/WebView.mm	2020-02-06 17:12:22 UTC (rev 255960)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebView.mm	2020-02-06 17:32:18 UTC (rev 255961)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005-2019 Apple Inc. All rights reserved.
+ * Copyright (C) 2005-2020 Apple Inc. All rights reserved.
  * Copyright (C) 2006 David Smith ([email protected])
  * Copyright (C) 2010 Igalia S.L
  *
@@ -2887,6 +2887,7 @@
     settings.setAllowUniversalAccessFromFileURLs([preferences allowUniversalAccessFromFileURLs]);
     settings.setAllowFileAccessFromFileURLs([preferences allowFileAccessFromFileURLs]);
     settings.setAllowCrossOriginSubresourcesToAskForCredentials([preferences allowCrossOriginSubresourcesToAskForCredentials]);
+    settings.setAllowTopNavigationToDataURLs([preferences allowTopNavigationToDataURLs]);
     settings.setNeedsStorageAccessFromFileURLsQuirk([preferences needsStorageAccessFromFileURLsQuirk]);
     settings.setMinimumFontSize([preferences minimumFontSize]);
     settings.setMinimumLogicalFontSize([preferences minimumLogicalFontSize]);

Modified: trunk/Source/WebKitLegacy/win/ChangeLog (255960 => 255961)


--- trunk/Source/WebKitLegacy/win/ChangeLog	2020-02-06 17:12:22 UTC (rev 255960)
+++ trunk/Source/WebKitLegacy/win/ChangeLog	2020-02-06 17:32:18 UTC (rev 255961)
@@ -1,3 +1,26 @@
+2020-02-06  Brent Fulgham  <[email protected]>
+
+        Prevent navigating top level frames to Data URLs
+        https://bugs.webkit.org/show_bug.cgi?id=206962
+        <rdar://problem/56770676>
+
+        Reviewed by Youenn Fablet.
+
+        Expose a new off-by-default preference to allow top-level navigation to Data URIs.
+
+        * Interfaces/WebKit.idl: Touch file to trigger a build.
+        * Interfaces/IWebPreferences.idl: Ditto.
+        * Interfaces/IWebPreferencesPrivate.idl: Expose new API version to avoid breaking shipping binaries.
+        * WebPreferenceKeysPrivate.h:
+        * WebPreferences.cpp:
+        (WebPreferences::initializeDefaultSettings): Update for new setting.
+        (WebPreferences::QueryInterface): Add support for IWebPreferencesPrivate8 interface.
+        (WebPreferences::allowTopNavigationToDataURLs): Added.
+        (WebPreferences::setAllowTopNavigationToDataURLs): Added.
+        * WebPreferences.h:
+        * WebView.cpp:
+        (WebView::notifyPreferencesChanged): Update to handle Data URL setting.
+
 2020-01-31  Wenson Hsieh  <[email protected]>
 
         Add support for specifying background colors when setting marked text

Modified: trunk/Source/WebKitLegacy/win/Interfaces/IWebPreferences.idl (255960 => 255961)


--- trunk/Source/WebKitLegacy/win/Interfaces/IWebPreferences.idl	2020-02-06 17:12:22 UTC (rev 255960)
+++ trunk/Source/WebKitLegacy/win/Interfaces/IWebPreferences.idl	2020-02-06 17:32:18 UTC (rev 255961)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006, 2007, 2008 Apple Inc.  All rights reserved.
+ * Copyright (C) 2006-2020 Apple Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions

Modified: trunk/Source/WebKitLegacy/win/Interfaces/IWebPreferencesPrivate.idl (255960 => 255961)


--- trunk/Source/WebKitLegacy/win/Interfaces/IWebPreferencesPrivate.idl	2020-02-06 17:12:22 UTC (rev 255960)
+++ trunk/Source/WebKitLegacy/win/Interfaces/IWebPreferencesPrivate.idl	2020-02-06 17:32:18 UTC (rev 255961)
@@ -261,3 +261,10 @@
     HRESULT setRenderingUpdateThrottlingEnabled([in] BOOL enabled);
     HRESULT renderingUpdateThrottlingEnabled([out, retval] BOOL* enabled);
 }
+
+[uuid(04D4AAE1-5D01-4CCD-B46E-C022F10A6826)]
+interface IWebPreferencesPrivate8 : IWebPreferencesPrivate7
+{
+    HRESULT allowTopNavigationToDataURLs([out, retval] BOOL* enabled);
+    HRESULT setAllowTopNavigationToDataURLs([in] BOOL enabled);
+}

Modified: trunk/Source/WebKitLegacy/win/Interfaces/WebKit.idl (255960 => 255961)


--- trunk/Source/WebKitLegacy/win/Interfaces/WebKit.idl	2020-02-06 17:12:22 UTC (rev 255960)
+++ trunk/Source/WebKitLegacy/win/Interfaces/WebKit.idl	2020-02-06 17:32:18 UTC (rev 255961)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006-2010, 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2006-2020 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions

Modified: trunk/Source/WebKitLegacy/win/WebPreferenceKeysPrivate.h (255960 => 255961)


--- trunk/Source/WebKitLegacy/win/WebPreferenceKeysPrivate.h	2020-02-06 17:12:22 UTC (rev 255960)
+++ trunk/Source/WebKitLegacy/win/WebPreferenceKeysPrivate.h	2020-02-06 17:32:18 UTC (rev 255961)
@@ -52,6 +52,7 @@
 #define WebKitJavaScriptEnabledPreferenceKey "WebKitJavaScriptEnabled"
 #define WebKitJavaScriptRuntimeFlagsPreferenceKey "WebKitJavaScriptRuntimeFlags"
 #define WebKitWebSecurityEnabledPreferenceKey "WebKitWebSecurityEnabled"
+#define WebKitAllowTopNavigationToDataURLsPreferenceKey "WebKitAllowTopNavigationToDataURLs"
 #define WebKitAllowUniversalAccessFromFileURLsPreferenceKey "WebKitAllowUniversalAccessFromFileURLs"
 #define WebKitAllowFileAccessFromFileURLsPreferenceKey "WebKitAllowFileAccessFromFileURLs"
 #define WebKitJavaScriptCanOpenWindowsAutomaticallyPreferenceKey "WebKitJavaScriptCanOpenWindowsAutomatically"
@@ -228,3 +229,5 @@
 #define WebKitWebSQLEnabledPreferenceKey "WebKitWebSQLEnabled"
 
 #define WebKitRenderingUpdateThrottlingEnabledPreferenceKey "WebKitRenderingUpdateThrottlingEnabled"
+
+#define WebKitRenderingUpdateThrottlingEnabledPreferenceKey "WebKitRenderingUpdateThrottlingEnabled"

Modified: trunk/Source/WebKitLegacy/win/WebPreferences.cpp (255960 => 255961)


--- trunk/Source/WebKitLegacy/win/WebPreferences.cpp	2020-02-06 17:12:22 UTC (rev 255960)
+++ trunk/Source/WebKitLegacy/win/WebPreferences.cpp	2020-02-06 17:32:18 UTC (rev 255961)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006-2011, 2014-2015 Apple Inc.  All rights reserved.
+ * Copyright (C) 2006-2020 Apple Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -231,6 +231,7 @@
     CFDictionaryAddValue(defaults, CFSTR(WebKitJavaScriptEnabledPreferenceKey), kCFBooleanTrue);
     CFDictionaryAddValue(defaults, CFSTR(WebKitJavaScriptRuntimeFlagsPreferenceKey), CFSTR("0"));
     CFDictionaryAddValue(defaults, CFSTR(WebKitWebSecurityEnabledPreferenceKey), kCFBooleanTrue);
+    CFDictionaryAddValue(defaults, CFSTR(WebKitAllowTopNavigationToDataURLsPreferenceKey), kCFBooleanFalse);
     CFDictionaryAddValue(defaults, CFSTR(WebKitAllowUniversalAccessFromFileURLsPreferenceKey), kCFBooleanFalse);
     CFDictionaryAddValue(defaults, CFSTR(WebKitAllowFileAccessFromFileURLsPreferenceKey), kCFBooleanTrue);
     CFDictionaryAddValue(defaults, CFSTR(WebKitJavaScriptCanAccessClipboardPreferenceKey), kCFBooleanFalse);
@@ -646,6 +647,8 @@
         *ppvObject = static_cast<IWebPreferencesPrivate6*>(this);
     else if (IsEqualGUID(riid, IID_IWebPreferencesPrivate7))
         *ppvObject = static_cast<IWebPreferencesPrivate7*>(this);
+    else if (IsEqualGUID(riid, IID_IWebPreferencesPrivate8))
+        *ppvObject = static_cast<IWebPreferencesPrivate8*>(this);
     else if (IsEqualGUID(riid, CLSID_WebPreferences))
         *ppvObject = this;
     else
@@ -2483,3 +2486,16 @@
     return S_OK;
 }
 
+HRESULT WebPreferences::allowTopNavigationToDataURLs(_Out_ BOOL* allowAccess)
+{
+    if (!allowAccess)
+        return E_POINTER;
+    *allowAccess = boolValueForKey(WebKitAllowTopNavigationToDataURLsPreferenceKey);
+    return S_OK;
+}
+
+HRESULT WebPreferences::setAllowTopNavigationToDataURLs(BOOL allowAccess)
+{
+    setBoolValue(WebKitAllowTopNavigationToDataURLsPreferenceKey, allowAccess);
+    return S_OK;
+}

Modified: trunk/Source/WebKitLegacy/win/WebPreferences.h (255960 => 255961)


--- trunk/Source/WebKitLegacy/win/WebPreferences.h	2020-02-06 17:12:22 UTC (rev 255960)
+++ trunk/Source/WebKitLegacy/win/WebPreferences.h	2020-02-06 17:32:18 UTC (rev 255961)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006-2009, 2015 Apple Inc.  All rights reserved.
+ * Copyright (C) 2006-2020 Apple Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -30,7 +30,7 @@
 #include <WebCore/BString.h>
 #include <wtf/RetainPtr.h>
 
-class WebPreferences final : public IWebPreferences, public IWebPreferencesPrivate7 {
+class WebPreferences final : public IWebPreferences, public IWebPreferencesPrivate8 {
 public:
     static WebPreferences* createInstance();
 protected:
@@ -306,6 +306,10 @@
     virtual HRESULT STDMETHODCALLTYPE renderingUpdateThrottlingEnabled(_Out_ BOOL*);
     virtual HRESULT STDMETHODCALLTYPE setRenderingUpdateThrottlingEnabled(BOOL);
 
+    // IWebPreferencesPrivate8
+    virtual HRESULT STDMETHODCALLTYPE allowTopNavigationToDataURLs(_Out_ BOOL*);
+    virtual HRESULT STDMETHODCALLTYPE setAllowTopNavigationToDataURLs(BOOL);
+
     // WebPreferences
 
     // This method accesses a different preference key than developerExtrasEnabled.

Modified: trunk/Source/WebKitLegacy/win/WebView.cpp (255960 => 255961)


--- trunk/Source/WebKitLegacy/win/WebView.cpp	2020-02-06 17:12:22 UTC (rev 255960)
+++ trunk/Source/WebKitLegacy/win/WebView.cpp	2020-02-06 17:32:18 UTC (rev 255961)
@@ -5177,7 +5177,7 @@
     settings.setShouldDisplayTextDescriptions(enabled);
 #endif
 
-    COMPtr<IWebPreferencesPrivate7> prefsPrivate { Query, preferences };
+    COMPtr<IWebPreferencesPrivate8> prefsPrivate { Query, preferences };
     if (prefsPrivate) {
         hr = prefsPrivate->localStorageDatabasePath(&str);
         if (FAILED(hr))
@@ -5487,6 +5487,11 @@
         return hr;
     settings.setWebSecurityEnabled(!!enabled);
 
+    hr = prefsPrivate->allowTopNavigationToDataURLs(&enabled);
+    if (FAILED(hr))
+        return hr;
+    settings.setAllowTopNavigationToDataURLs(!!enabled);
+
     hr = prefsPrivate->allowUniversalAccessFromFileURLs(&enabled);
     if (FAILED(hr))
         return hr;

Modified: trunk/Source/cmake/OptionsAppleWin.cmake (255960 => 255961)


--- trunk/Source/cmake/OptionsAppleWin.cmake	2020-02-06 17:12:22 UTC (rev 255960)
+++ trunk/Source/cmake/OptionsAppleWin.cmake	2020-02-06 17:32:18 UTC (rev 255961)
@@ -2,6 +2,21 @@
 # being compiled with a static runtime.
 set(MSVC_STATIC_RUNTIME ON)
 
+if (DEFINED ENV{AppleApplicationSupportSDK})
+    file(TO_CMAKE_PATH "$ENV{AppleApplicationSupportSDK}/AppleInternal" WEBKIT_LIBRARIES_DIR)
+    set(WEBKIT_LIBRARIES_INCLUDE_DIR "${WEBKIT_LIBRARIES_DIR}/include")
+    include_directories(${WEBKIT_LIBRARIES_INCLUDE_DIR})
+    set(APPLE_BUILD 1)
+endif ()
+
+if (NOT WEBKIT_LIBRARIES_DIR)
+    if (DEFINED ENV{WEBKIT_LIBRARIES})
+        file(TO_CMAKE_PATH "$ENV{WEBKIT_LIBRARIES}" WEBKIT_LIBRARIES_DIR)
+    else ()
+        file(TO_CMAKE_PATH "${CMAKE_SOURCE_DIR}/WebKitLibraries/win" WEBKIT_LIBRARIES_DIR)
+    endif ()
+endif ()
+
 include(OptionsWin)
 
 set(ENABLE_WEBCORE ON)

Modified: trunk/Tools/ChangeLog (255960 => 255961)


--- trunk/Tools/ChangeLog	2020-02-06 17:12:22 UTC (rev 255960)
+++ trunk/Tools/ChangeLog	2020-02-06 17:32:18 UTC (rev 255961)
@@ -1,3 +1,38 @@
+2020-02-06  Brent Fulgham  <[email protected]>
+
+        Prevent navigating top level frames to Data URLs
+        https://bugs.webkit.org/show_bug.cgi?id=206962
+        <rdar://problem/56770676>
+
+        Reviewed by Youenn Fablet.
+
+        Revise test running code to allow data URL navigations by default, since they are so frequently
+        used in testing. However, provide a flag to turn this off in tests so we can confirm proper
+        function.
+
+        * DumpRenderTree/TestOptions.cpp:
+        (TestOptions::TestOptions):
+        * DumpRenderTree/TestOptions.h:
+        * DumpRenderTree/mac/DumpRenderTree.mm:
+        (setWebPreferencesForTestOptions):
+        * TestWebKitAPI/Tests/WebKitCocoa/Download.mm:
+        (DownloadAttributeDoesNotStartDownloads): Revise configuration to allow script navigation of the main frame to a Data URL.
+        (StartDownloadWithDownloadAttribute): Ditto.
+        * TestWebKitAPI/Tests/WebKitCocoa/Navigation.mm:
+        (WebViewWillPerformClientRedirect): Ditto.
+        (WebViewDidCancelClientRedirect): Ditto.
+        * TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:
+        (NavigateToDataURLThenBack): Ditto.
+        (ContentExtensionBlocksMainLoadThenReloadWithoutExtensions): Ditto.
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::resetPreferencesToConsistentValues):
+        (WTR::updateTestOptionsFromTestHeader):
+        * WebKitTestRunner/TestOptions.h:
+        (WTR::TestOptions::hasSameInitializationOptions const):
+        * WebKitTestRunner/cocoa/TestControllerCocoa.mm:
+        (WTR::initializeWebViewConfiguration):
+        (WTR::TestController::platformCreateWebView):
+
 2020-02-05  Wenson Hsieh  <[email protected]>
 
         [iOS] Provide a way to suppress software keyboards on WKWebView's WKContentView

Modified: trunk/Tools/DumpRenderTree/TestOptions.cpp (255960 => 255961)


--- trunk/Tools/DumpRenderTree/TestOptions.cpp	2020-02-06 17:12:22 UTC (rev 255960)
+++ trunk/Tools/DumpRenderTree/TestOptions.cpp	2020-02-06 17:32:18 UTC (rev 255961)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016-2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2016-2020 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -154,6 +154,8 @@
             layoutFormattingContextIntegrationEnabled = parseBooleanTestHeaderValue(value);
         else if (key == "experimental:AspectRatioOfImgFromWidthAndHeightEnabled")
             enableAspectRatioOfImgFromWidthAndHeight = parseBooleanTestHeaderValue(value);
+        else if (key == "allowTopNavigationToDataURLs")
+            allowTopNavigationToDataURLs = parseBooleanTestHeaderValue(value);
         pairStart = pairEnd + 1;
     }
 }

Modified: trunk/Tools/DumpRenderTree/TestOptions.h (255960 => 255961)


--- trunk/Tools/DumpRenderTree/TestOptions.h	2020-02-06 17:12:22 UTC (rev 255960)
+++ trunk/Tools/DumpRenderTree/TestOptions.h	2020-02-06 17:32:18 UTC (rev 255961)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016-2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2016-2020 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -57,6 +57,7 @@
     bool layoutFormattingContextIntegrationEnabled { true };
     bool enableAspectRatioOfImgFromWidthAndHeight { false };
     bool enableWebSQL { true };
+    bool allowTopNavigationToDataURLs { true };
     std::string jscOptions;
     std::string additionalSupportedImageTypes;
 

Modified: trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm (255960 => 255961)


--- trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm	2020-02-06 17:12:22 UTC (rev 255960)
+++ trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm	2020-02-06 17:32:18 UTC (rev 255961)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005-2019 Apple Inc. All rights reserved.
+ * Copyright (C) 2005-2020 Apple Inc. All rights reserved.
  *           (C) 2007 Graham Dennis ([email protected])
  *
  * Redistribution and use in source and binary forms, with or without
@@ -1044,6 +1044,7 @@
     preferences.usesPageCache = options.enableBackForwardCache;
     preferences.layoutFormattingContextIntegrationEnabled = options.layoutFormattingContextIntegrationEnabled;
     preferences.aspectRatioOfImgFromWidthAndHeightEnabled = options.enableAspectRatioOfImgFromWidthAndHeight;
+    preferences.allowTopNavigationToDataURLs = options.allowTopNavigationToDataURLs;
 }
 
 // Called once on DumpRenderTree startup.

Modified: trunk/Tools/DumpRenderTree/win/DumpRenderTree.cpp (255960 => 255961)


--- trunk/Tools/DumpRenderTree/win/DumpRenderTree.cpp	2020-02-06 17:12:22 UTC (rev 255960)
+++ trunk/Tools/DumpRenderTree/win/DumpRenderTree.cpp	2020-02-06 17:32:18 UTC (rev 255961)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005-2015 Apple Inc.  All rights reserved.
+ * Copyright (C) 2005-2020 Apple Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -814,7 +814,7 @@
 
     preferences->setAutosaves(FALSE);
 
-    COMPtr<IWebPreferencesPrivate6> prefsPrivate(Query, preferences);
+    COMPtr<IWebPreferencesPrivate8> prefsPrivate(Query, preferences);
     ASSERT(prefsPrivate);
     prefsPrivate->setFullScreenEnabled(TRUE);
 
@@ -834,6 +834,7 @@
     static _bstr_t pictographFamily(TEXT("Segoe UI Symbol"));
 #endif
 
+    prefsPrivate->setAllowTopNavigationToDataURLs(TRUE);
     prefsPrivate->setAllowUniversalAccessFromFileURLs(TRUE);
     prefsPrivate->setAllowFileAccessFromFileURLs(TRUE);
     preferences->setStandardFontFamily(standardFamily);
@@ -907,7 +908,7 @@
 
 static void setWebPreferencesForTestOptions(IWebPreferences* preferences, const TestOptions& options)
 {
-    COMPtr<IWebPreferencesPrivate7> prefsPrivate { Query, preferences };
+    COMPtr<IWebPreferencesPrivate8> prefsPrivate { Query, preferences };
 
     prefsPrivate->setWebAnimationsCSSIntegrationEnabled(options.enableWebAnimationsCSSIntegration);
     prefsPrivate->setMenuItemElementEnabled(options.enableMenuItemElement);
@@ -918,6 +919,7 @@
     prefsPrivate->setRequestIdleCallbackEnabled(options.enableRequestIdleCallback);
     prefsPrivate->setAsyncClipboardAPIEnabled(options.enableAsyncClipboardAPI);
     prefsPrivate->setWebSQLEnabled(options.enableWebSQL);
+    prefsPrivate->setAllowTopNavigationToDataURLs(options.allowTopNavigationToDataURLs);
     preferences->setPrivateBrowsingEnabled(options.useEphemeralSession);
     preferences->setUsesPageCache(options.enableBackForwardCache);
 }

Modified: trunk/Tools/DumpRenderTree/win/TestRunnerWin.cpp (255960 => 255961)


--- trunk/Tools/DumpRenderTree/win/TestRunnerWin.cpp	2020-02-06 17:12:22 UTC (rev 255960)
+++ trunk/Tools/DumpRenderTree/win/TestRunnerWin.cpp	2020-02-06 17:32:18 UTC (rev 255961)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006-2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2006-2020 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/Download.mm (255960 => 255961)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/Download.mm	2020-02-06 17:12:22 UTC (rev 255960)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/Download.mm	2020-02-06 17:32:18 UTC (rev 255961)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2014-2020 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -40,6 +40,7 @@
 #import <WebKit/WKUIDelegatePrivate.h>
 #import <WebKit/WKWebView.h>
 #import <WebKit/WKWebViewConfiguration.h>
+#import <WebKit/WKWebViewConfigurationPrivate.h>
 #import <WebKit/WKWebsiteDataStorePrivate.h>
 #import <WebKit/_WKDownload.h>
 #import <WebKit/_WKDownloadDelegate.h>
@@ -716,7 +717,11 @@
 TEST(_WKDownload, DownloadAttributeDoesNotStartDownloads)
 {
     auto delegate = adoptNS([[DownloadAttributeTestDelegate alloc] init]);
-    auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
+
+    auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+    configuration.get()._allowTopNavigationToDataURLs = YES;
+    auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
+
     [webView setNavigationDelegate:delegate.get()];
     [webView configuration].processPool._downloadDelegate = delegate.get();
 
@@ -731,7 +736,11 @@
 TEST(_WKDownload, StartDownloadWithDownloadAttribute)
 {
     auto delegate = adoptNS([[DownloadAttributeTestDelegate alloc] init]);
-    auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
+
+    auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+    configuration.get()._allowTopNavigationToDataURLs = YES;
+    auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
+
     [webView setNavigationDelegate:delegate.get()];
     [webView configuration].processPool._downloadDelegate = delegate.get();
 

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/Navigation.mm (255960 => 255961)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/Navigation.mm	2020-02-06 17:12:22 UTC (rev 255960)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/Navigation.mm	2020-02-06 17:32:18 UTC (rev 255961)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2014-2020 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -30,6 +30,7 @@
 #import <WebKit/WKNavigationDelegatePrivate.h>
 #import <WebKit/WKNavigationPrivate.h>
 #import <WebKit/WKWebView.h>
+#import <WebKit/WKWebViewConfigurationPrivate.h>
 #import <wtf/RetainPtr.h>
 #import "PlatformUtilities.h"
 #import "Test.h"
@@ -273,7 +274,9 @@
 
 TEST(WKNavigation, WebViewWillPerformClientRedirect)
 {
-    auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
+    auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+    configuration.get()._allowTopNavigationToDataURLs = YES;
+    auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
 
     auto delegate = adoptNS([[ClientRedirectNavigationDelegate alloc] init]);
     [webView setNavigationDelegate:delegate.get()];
@@ -302,7 +305,9 @@
 
 TEST(WKNavigation, WebViewDidCancelClientRedirect)
 {
-    auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
+    auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+    configuration.get()._allowTopNavigationToDataURLs = YES;
+    auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
 
     auto delegate = adoptNS([[ClientRedirectNavigationDelegate alloc] init]);
     [webView setNavigationDelegate:delegate.get()];

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm (255960 => 255961)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm	2020-02-06 17:12:22 UTC (rev 255960)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm	2020-02-06 17:32:18 UTC (rev 255961)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017-2019 Apple Inc. All rights reserved.
+ * Copyright (C) 2017-2020 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -4361,6 +4361,7 @@
 
     auto webViewConfiguration = adoptNS([[WKWebViewConfiguration alloc] init]);
     [webViewConfiguration setProcessPool:processPool.get()];
+    webViewConfiguration.get()._allowTopNavigationToDataURLs = YES;
     auto handler = adoptNS([[PSONScheme alloc] initWithBytes:navigateToDataURLThenBackBytes]);
     [webViewConfiguration setURLSchemeHandler:handler.get() forURLScheme:@"PSON"];
 
@@ -6179,6 +6180,7 @@
 
     auto webViewConfiguration = adoptNS([[WKWebViewConfiguration alloc] init]);
     [webViewConfiguration setProcessPool:processPool.get()];
+    webViewConfiguration.get()._allowTopNavigationToDataURLs = YES;
 
     RetainPtr<PSONMessageHandler> messageHandler = adoptNS([[PSONMessageHandler alloc] init]);
     [[webViewConfiguration userContentController] addScriptMessageHandler:messageHandler.get() name:@"pson"];

Modified: trunk/Tools/WebKitTestRunner/TestController.cpp (255960 => 255961)


--- trunk/Tools/WebKitTestRunner/TestController.cpp	2020-02-06 17:12:22 UTC (rev 255960)
+++ trunk/Tools/WebKitTestRunner/TestController.cpp	2020-02-06 17:32:18 UTC (rev 255961)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010-2019 Apple Inc. All rights reserved.
+ * Copyright (C) 2010-2020 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -852,6 +852,7 @@
     WKPreferencesSetDOMPasteAllowed(preferences, options.domPasteAllowed);
     WKPreferencesSetUniversalAccessFromFileURLsAllowed(preferences, true);
     WKPreferencesSetFileAccessFromFileURLsAllowed(preferences, true);
+    WKPreferencesSetTopNavigationToDataURLsAllowed(preferences, options.allowTopNavigationToDataURLs);
 #if ENABLE(FULLSCREEN_API)
     WKPreferencesSetFullScreenEnabled(preferences, true);
 #endif
@@ -1489,6 +1490,9 @@
             testOptions.enableCaptureVideoInGPUProcess = parseBooleanTestHeaderValue(value);
         else if (key == "enableCaptureAudioInGPUProcess")
             testOptions.enableCaptureAudioInGPUProcess = parseBooleanTestHeaderValue(value);
+        else if (key == "allowTopNavigationToDataURLs")
+            testOptions.allowTopNavigationToDataURLs = parseBooleanTestHeaderValue(value);
+        
         pairStart = pairEnd + 1;
     }
 }

Modified: trunk/Tools/WebKitTestRunner/TestOptions.h (255960 => 255961)


--- trunk/Tools/WebKitTestRunner/TestOptions.h	2020-02-06 17:12:22 UTC (rev 255960)
+++ trunk/Tools/WebKitTestRunner/TestOptions.h	2020-02-06 17:32:18 UTC (rev 255961)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015-2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2015-2020 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -102,6 +102,7 @@
     bool enableCaptureVideoInUIProcess { false };
     bool enableCaptureVideoInGPUProcess { false };
     bool enableCaptureAudioInGPUProcess { false };
+    bool allowTopNavigationToDataURLs { true };
 
     double contentInsetTop { 0 };
 
@@ -166,7 +167,8 @@
             || allowsLinkPreview != options.allowsLinkPreview
             || enableCaptureVideoInUIProcess != options.enableCaptureVideoInUIProcess
             || enableCaptureVideoInGPUProcess != options.enableCaptureVideoInGPUProcess
-            || enableCaptureAudioInGPUProcess != options.enableCaptureAudioInGPUProcess)
+            || enableCaptureAudioInGPUProcess != options.enableCaptureAudioInGPUProcess
+            || allowTopNavigationToDataURLs != options.allowTopNavigationToDataURLs)
             return false;
 
         if (!contextOptions.hasSameInitializationOptions(options.contextOptions))

Modified: trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm (255960 => 255961)


--- trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm	2020-02-06 17:12:22 UTC (rev 255960)
+++ trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm	2020-02-06 17:32:18 UTC (rev 255961)
@@ -67,6 +67,7 @@
     globalWebViewConfiguration.processPool = (__bridge WKProcessPool *)context;
     globalWebViewConfiguration.websiteDataStore = (__bridge WKWebsiteDataStore *)TestController::websiteDataStore();
     globalWebViewConfiguration._allowUniversalAccessFromFileURLs = YES;
+    globalWebViewConfiguration._allowTopNavigationToDataURLs = YES;
     globalWebViewConfiguration._applePayEnabled = YES;
 
     WKContextSetStorageAccessAPIEnabled(context, true);
@@ -154,6 +155,8 @@
     if (options.useEphemeralSession)
         [copiedConfiguration setWebsiteDataStore:[WKWebsiteDataStore nonPersistentDataStore]];
 
+    [copiedConfiguration _setAllowTopNavigationToDataURLs:options.allowTopNavigationToDataURLs];
+
     configureContentMode(copiedConfiguration.get(), options);
 
     if (options.applicationManifest.length()) {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to