Title: [293427] trunk
Revision
293427
Author
[email protected]
Date
2022-04-26 09:28:41 -0700 (Tue, 26 Apr 2022)

Log Message

Remove WebArchiveDebugMode
https://bugs.webkit.org/show_bug.cgi?id=239738
<rdar://problem/88406961>

Reviewed by Tim Horton.

Source/WebCore:

Remove use case of WebArchiveDebugMode and deprecate it now that it
is no longer in use. Add a new temporary flag WebArchiveTestMode
that is more aptly named and will maintain existing behavior for
internal tests temporarily.

* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::commitData):
(WebCore::DocumentLoader::scheduleArchiveLoad):

Source/WebKit:

* UIProcess/API/C/WKPreferences.cpp:
(WKPreferencesSetWebArchiveTestingModeEnabled):
(WKPreferencesGetWebArchiveTestingModeEnabled):
(WKPreferencesSetWebArchiveDebugModeEnabled):
(WKPreferencesGetWebArchiveDebugModeEnabled):
* UIProcess/API/C/WKPreferencesRefPrivate.h:
* UIProcess/API/Cocoa/WKPreferences.mm:
(-[WKPreferences _setWebArchiveTestingModeEnabled:]):
(-[WKPreferences _webArchiveTestingModeEnabled]):
(-[WKPreferences _setWebArchiveDebugModeEnabled:]):
(-[WKPreferences _webArchiveDebugModeEnabled]):
* UIProcess/API/Cocoa/WKPreferencesPrivate.h:

Source/WTF:

* Scripts/Preferences/WebPreferences.yaml:

Tools:

* TestWebKitAPI/Tests/mac/LoadWebArchive.mm:
(TestWebKitAPI::TEST):
(TestWebKitAPI::constructArchive):

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (293426 => 293427)


--- trunk/Source/WTF/ChangeLog	2022-04-26 15:59:25 UTC (rev 293426)
+++ trunk/Source/WTF/ChangeLog	2022-04-26 16:28:41 UTC (rev 293427)
@@ -1,3 +1,13 @@
+2022-04-26  Kate Cheney  <[email protected]>
+
+        Remove WebArchiveDebugMode
+        https://bugs.webkit.org/show_bug.cgi?id=239738
+        <rdar://problem/88406961>
+
+        Reviewed by Tim Horton.
+
+        * Scripts/Preferences/WebPreferences.yaml:
+
 2022-04-23  Wenson Hsieh  <[email protected]>
 
         Remove the `PreferInlineTextSelectionInImages` internal feature flag

Modified: trunk/Source/WTF/Scripts/Preferences/WebPreferences.yaml (293426 => 293427)


--- trunk/Source/WTF/Scripts/Preferences/WebPreferences.yaml	2022-04-26 15:59:25 UTC (rev 293426)
+++ trunk/Source/WTF/Scripts/Preferences/WebPreferences.yaml	2022-04-26 16:28:41 UTC (rev 293427)
@@ -2545,6 +2545,17 @@
     WebCore:
       default: false
 
+WebArchiveTestingModeEnabled:
+  type: bool
+  condition: ENABLE(WEB_ARCHIVE)
+  defaultValue:
+    WebKitLegacy:
+      default: false
+    WebKit:
+      default: false
+    WebCore:
+      default: false
+
 WebAudioEnabled:
   type: bool
   condition: ENABLE(WEB_AUDIO)

Modified: trunk/Source/WebCore/ChangeLog (293426 => 293427)


--- trunk/Source/WebCore/ChangeLog	2022-04-26 15:59:25 UTC (rev 293426)
+++ trunk/Source/WebCore/ChangeLog	2022-04-26 16:28:41 UTC (rev 293427)
@@ -1,3 +1,20 @@
+2022-04-26  Kate Cheney  <[email protected]>
+
+        Remove WebArchiveDebugMode
+        https://bugs.webkit.org/show_bug.cgi?id=239738
+        <rdar://problem/88406961>
+
+        Reviewed by Tim Horton.
+
+        Remove use case of WebArchiveDebugMode and deprecate it now that it
+        is no longer in use. Add a new temporary flag WebArchiveTestMode
+        that is more aptly named and will maintain existing behavior for
+        internal tests temporarily.
+
+        * loader/DocumentLoader.cpp:
+        (WebCore::DocumentLoader::commitData):
+        (WebCore::DocumentLoader::scheduleArchiveLoad):
+
 2022-04-26  Claudio Saavedra  <[email protected]>
 
         [DatabaseTracker] Use PRIu64 for logging for portability

Modified: trunk/Source/WebCore/loader/DocumentLoader.cpp (293426 => 293427)


--- trunk/Source/WebCore/loader/DocumentLoader.cpp	2022-04-26 15:59:25 UTC (rev 293426)
+++ trunk/Source/WebCore/loader/DocumentLoader.cpp	2022-04-26 16:28:41 UTC (rev 293427)
@@ -1215,9 +1215,14 @@
 
 void DocumentLoader::commitData(const SharedBuffer& data)
 {
+#if ENABLE(WEB_ARCHIVE)
+    URL documentOrEmptyURL = m_archive && !m_frame->settings().webArchiveTestingModeEnabled() ? URL() : documentURL();
+#else
+    URL documentOrEmptyURL = documentURL();
+#endif
     if (!m_gotFirstByte) {
         m_gotFirstByte = true;
-        bool hasBegun = m_writer.begin(documentURL(), false, nullptr, m_resultingClientId);
+        bool hasBegun = m_writer.begin(documentOrEmptyURL, false, nullptr, m_resultingClientId);
         if (!hasBegun)
             return;
 
@@ -1239,9 +1244,12 @@
         if (frameLoader()->stateMachine().creatingInitialEmptyDocument())
             return;
 
-#if ENABLE(WEB_ARCHIVE) || ENABLE(MHTML)
-        if (m_archive && m_archive->shouldOverrideBaseURL())
+#if ENABLE(WEB_ARCHIVE)
+        if (m_archive && !m_frame->settings().webArchiveTestingModeEnabled()) {
             document.setBaseURLOverride(m_archive->mainResource()->url());
+            if (LegacySchemeRegistry::shouldTreatURLSchemeAsLocal(documentURL().protocol().toStringWithoutCopying()))
+                document.securityOrigin().grantLoadLocalResources();
+        }
 #endif
 #if ENABLE(SERVICE_WORKER)
         if (m_canUseServiceWorkers) {
@@ -1793,14 +1801,15 @@
         return false;
 
 #if ENABLE(WEB_ARCHIVE)
-    // The idea of WebArchiveDebugMode is that we should fail instead of trying to fetch from the network.
-    // Returning true ensures the caller will not try to fetch from the network.
-    if (m_frame->settings().webArchiveDebugModeEnabled() && responseMIMEType() == "application/x-webarchive")
+    if (!m_frame->settings().webArchiveTestingModeEnabled()) {
+        DOCUMENTLOADER_RELEASE_LOG("scheduleArchiveLoad: Failed to unarchive subresource");
+        loader.didFail(ResourceError(errorDomainWebKitInternal, 0, request.url(), "Failed to unarchive subresource"_s));
         return true;
+    }
 #endif
 
     // If we want to load from the archive only, then we should always return true so that the caller
-    // does not try to fetch form the network.
+    // does not try to fetch from the network.
     return m_archive->shouldLoadFromArchiveOnly();
 }
 

Modified: trunk/Source/WebKit/ChangeLog (293426 => 293427)


--- trunk/Source/WebKit/ChangeLog	2022-04-26 15:59:25 UTC (rev 293426)
+++ trunk/Source/WebKit/ChangeLog	2022-04-26 16:28:41 UTC (rev 293427)
@@ -1,3 +1,24 @@
+2022-04-26  Kate Cheney  <[email protected]>
+
+        Remove WebArchiveDebugMode
+        https://bugs.webkit.org/show_bug.cgi?id=239738
+        <rdar://problem/88406961>
+
+        Reviewed by Tim Horton.
+
+        * UIProcess/API/C/WKPreferences.cpp:
+        (WKPreferencesSetWebArchiveTestingModeEnabled):
+        (WKPreferencesGetWebArchiveTestingModeEnabled):
+        (WKPreferencesSetWebArchiveDebugModeEnabled):
+        (WKPreferencesGetWebArchiveDebugModeEnabled):
+        * UIProcess/API/C/WKPreferencesRefPrivate.h:
+        * UIProcess/API/Cocoa/WKPreferences.mm:
+        (-[WKPreferences _setWebArchiveTestingModeEnabled:]):
+        (-[WKPreferences _webArchiveTestingModeEnabled]):
+        (-[WKPreferences _setWebArchiveDebugModeEnabled:]):
+        (-[WKPreferences _webArchiveDebugModeEnabled]):
+        * UIProcess/API/Cocoa/WKPreferencesPrivate.h:
+
 2022-04-26  Simon Fraser  <[email protected]>
 
         Add object addresses to IPC logging

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


--- trunk/Source/WebKit/UIProcess/API/C/WKPreferences.cpp	2022-04-26 15:59:25 UTC (rev 293426)
+++ trunk/Source/WebKit/UIProcess/API/C/WKPreferences.cpp	2022-04-26 16:28:41 UTC (rev 293427)
@@ -575,14 +575,14 @@
     return toImpl(preferencesRef)->domTimersThrottlingEnabled();
 }
 
-void WKPreferencesSetWebArchiveDebugModeEnabled(WKPreferencesRef preferencesRef, bool enabled)
+void WKPreferencesSetWebArchiveTestingModeEnabled(WKPreferencesRef preferencesRef, bool enabled)
 {
-    toImpl(preferencesRef)->setWebArchiveDebugModeEnabled(enabled);
+    toImpl(preferencesRef)->setWebArchiveTestingModeEnabled(enabled);
 }
 
-bool WKPreferencesGetWebArchiveDebugModeEnabled(WKPreferencesRef preferencesRef)
+bool WKPreferencesGetWebArchiveTestingModeEnabled(WKPreferencesRef preferencesRef)
 {
-    return toImpl(preferencesRef)->webArchiveDebugModeEnabled();
+    return toImpl(preferencesRef)->webArchiveTestingModeEnabled();
 }
 
 void WKPreferencesSetLocalFileContentSniffingEnabled(WKPreferencesRef preferencesRef, bool enabled)
@@ -2213,3 +2213,12 @@
 {
     return false;
 }
+
+void WKPreferencesSetWebArchiveDebugModeEnabled(WKPreferencesRef preferencesRef, bool enabled)
+{
+}
+
+bool WKPreferencesGetWebArchiveDebugModeEnabled(WKPreferencesRef preferencesRef)
+{
+    return false;
+}

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


--- trunk/Source/WebKit/UIProcess/API/C/WKPreferencesRefPrivate.h	2022-04-26 15:59:25 UTC (rev 293426)
+++ trunk/Source/WebKit/UIProcess/API/C/WKPreferencesRefPrivate.h	2022-04-26 16:28:41 UTC (rev 293427)
@@ -124,8 +124,8 @@
 WK_EXPORT bool WKPreferencesGetDOMTimersThrottlingEnabled(WKPreferencesRef preferences);
 
 // Defaults to false.
-WK_EXPORT void WKPreferencesSetWebArchiveDebugModeEnabled(WKPreferencesRef preferences, bool enabled);
-WK_EXPORT bool WKPreferencesGetWebArchiveDebugModeEnabled(WKPreferencesRef preferences);
+WK_EXPORT void WKPreferencesSetWebArchiveTestingModeEnabled(WKPreferencesRef preferences, bool enabled);
+WK_EXPORT bool WKPreferencesGetWebArchiveTestingModeEnabled(WKPreferencesRef preferences);
 
 // Defaults to false.
 WK_EXPORT void WKPreferencesSetLocalFileContentSniffingEnabled(WKPreferencesRef preferences, bool enabled);
@@ -587,6 +587,8 @@
 WK_EXPORT bool WKPreferencesGetResourceTimingEnabled(WKPreferencesRef) WK_C_API_DEPRECATED;
 WK_EXPORT void WKPreferencesSetSubpixelCSSOMElementMetricsEnabled(WKPreferencesRef, bool) WK_C_API_DEPRECATED;
 WK_EXPORT bool WKPreferencesGetSubpixelCSSOMElementMetricsEnabled(WKPreferencesRef) WK_C_API_DEPRECATED;
+WK_EXPORT void WKPreferencesSetWebArchiveDebugModeEnabled(WKPreferencesRef preferences, bool enabled) WK_C_API_DEPRECATED;
+WK_EXPORT bool WKPreferencesGetWebArchiveDebugModeEnabled(WKPreferencesRef preferences) WK_C_API_DEPRECATED;
 
 #ifdef __cplusplus
 }

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


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKPreferences.mm	2022-04-26 15:59:25 UTC (rev 293426)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKPreferences.mm	2022-04-26 16:28:41 UTC (rev 293427)
@@ -1004,14 +1004,14 @@
     return _preferences->domTimersThrottlingEnabled();
 }
 
-- (void)_setWebArchiveDebugModeEnabled:(BOOL)enabled
+- (void)_setWebArchiveTestingModeEnabled:(BOOL)enabled
 {
-    _preferences->setWebArchiveDebugModeEnabled(enabled);
+    _preferences->setWebArchiveTestingModeEnabled(enabled);
 }
 
-- (BOOL)_webArchiveDebugModeEnabled
+- (BOOL)_webArchiveTestingModeEnabled
 {
-    return _preferences->webArchiveDebugModeEnabled();
+    return _preferences->webArchiveTestingModeEnabled();
 }
 
 - (void)_setLocalFileContentSniffingEnabled:(BOOL)enabled
@@ -1643,6 +1643,15 @@
     return NO;
 }
 
+- (void)_setWebArchiveDebugModeEnabled:(BOOL)enabled
+{
+}
+
+- (BOOL)_webArchiveDebugModeEnabled
+{
+    return NO;
+}
+
 #endif
 
 @end

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


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKPreferencesPrivate.h	2022-04-26 15:59:25 UTC (rev 293426)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKPreferencesPrivate.h	2022-04-26 16:28:41 UTC (rev 293427)
@@ -188,7 +188,7 @@
 @property (nonatomic, setter=_setDefaultTextEncodingName:) NSString *_defaultTextEncodingName WK_API_AVAILABLE(macos(10.13.4));
 @property (nonatomic, setter=_setAuthorAndUserStylesEnabled:) BOOL _authorAndUserStylesEnabled WK_API_AVAILABLE(macos(10.13.4));
 @property (nonatomic, setter=_setDOMTimersThrottlingEnabled:) BOOL _domTimersThrottlingEnabled WK_API_AVAILABLE(macos(10.13.4));
-@property (nonatomic, setter=_setWebArchiveDebugModeEnabled:) BOOL _webArchiveDebugModeEnabled WK_API_AVAILABLE(macos(10.13.4));
+@property (nonatomic, setter=_setWebArchiveTestingModeEnabled:) BOOL _webArchiveTestingModeEnabled WK_API_AVAILABLE(macos(WK_MAC_TBA));
 @property (nonatomic, setter=_setLocalFileContentSniffingEnabled:) BOOL _localFileContentSniffingEnabled WK_API_AVAILABLE(macos(10.13.4));
 @property (nonatomic, setter=_setUsesPageCache:) BOOL _usesPageCache WK_API_AVAILABLE(macos(10.13.4));
 @property (nonatomic, setter=_setPageCacheSupportsPlugins:) BOOL _pageCacheSupportsPlugins WK_API_AVAILABLE(macos(10.13.4));
@@ -233,6 +233,6 @@
 @property (nonatomic, setter=_setRequestAnimationFrameEnabled:) BOOL _requestAnimationFrameEnabled WK_API_DEPRECATED("requestAnimationFrame is always enabled", macos(10.15.4, WK_MAC_TBA), ios(13.4, WK_IOS_TBA));
 #if !TARGET_OS_IPHONE
 @property (nonatomic, setter=_setSubpixelCSSOMElementMetricsEnabled:) BOOL _subpixelCSSOMElementMetricsEnabled WK_API_DEPRECATED("Subpixel CSSOM element metrics are no longer supported", macos(10.13.4, 10.15));
+@property (nonatomic, setter=_setWebArchiveDebugModeEnabled:) BOOL _webArchiveDebugModeEnabled WK_API_DEPRECATED("WebArchive Debug Mode is no longer supported", macos(10.13.4, WK_MAC_TBA));
 #endif
-
 @end

Modified: trunk/Tools/ChangeLog (293426 => 293427)


--- trunk/Tools/ChangeLog	2022-04-26 15:59:25 UTC (rev 293426)
+++ trunk/Tools/ChangeLog	2022-04-26 16:28:41 UTC (rev 293427)
@@ -1,3 +1,15 @@
+2022-04-26  Kate Cheney  <[email protected]>
+
+        Remove WebArchiveDebugMode
+        https://bugs.webkit.org/show_bug.cgi?id=239738
+        <rdar://problem/88406961>
+
+        Reviewed by Tim Horton.
+
+        * TestWebKitAPI/Tests/mac/LoadWebArchive.mm:
+        (TestWebKitAPI::TEST):
+        (TestWebKitAPI::constructArchive):
+
 2022-04-25  Jonathan Bedard  <[email protected]>
 
         [ews-build.webkit.org] Specify repository when sending emails

Modified: trunk/Tools/TestWebKitAPI/Tests/mac/LoadWebArchive.mm (293426 => 293427)


--- trunk/Tools/TestWebKitAPI/Tests/mac/LoadWebArchive.mm	2022-04-26 15:59:25 UTC (rev 293426)
+++ trunk/Tools/TestWebKitAPI/Tests/mac/LoadWebArchive.mm	2022-04-26 16:28:41 UTC (rev 293427)
@@ -32,6 +32,7 @@
 #import "TestWKWebView.h"
 #import <WebKit/WKDragDestinationAction.h>
 #import <WebKit/WKNavigationPrivate.h>
+#import <WebKit/WKPreferencesPrivate.h>
 #import <WebKit/WKWebView.h>
 #import <WebKit/WKWebViewConfigurationPrivate.h>
 #import <WebKit/WKWebViewPrivate.h>
@@ -205,9 +206,9 @@
     EXPECT_WK_STREQ(finalURL, "");
 }
 
-static NSData* constructArchive()
+static NSData* constructArchive(const char *script)
 {
-    NSString *js = @"alert('loaded http subresource successfully')";
+    auto *js = [NSString stringWithUTF8String:script];
     auto response = adoptNS([[NSURLResponse alloc] initWithURL:[NSURL URLWithString:@"http://download/script.js"] MIMEType:@"application/_javascript_" expectedContentLength:js.length textEncodingName:@"utf-8"]);
     auto responseArchiver = adoptNS([[NSKeyedArchiver alloc] initRequiringSecureCoding:YES]);
     [responseArchiver encodeObject:response.get() forKey:@"WebResourceResponse"];
@@ -232,7 +233,7 @@
 
 TEST(LoadWebArchive, HTTPSUpgrade)
 {
-    NSData *data = ""
+    NSData *data = "" http subresource successfully')");
 
     auto webView = adoptNS([WKWebView new]);
     [webView loadData:data MIMEType:@"application/x-webarchive" characterEncodingName:@"utf-8" baseURL:[NSURL URLWithString:@"http://download/"]];
@@ -241,7 +242,7 @@
 
 TEST(LoadWebArchive, DisallowedNetworkHosts)
 {
-    NSData *data = ""
+    NSData *data = "" http subresource successfully')");
 
     auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
     configuration.get()._allowedNetworkHosts = [NSSet set];
@@ -252,3 +253,7 @@
 }
 
 } // namespace TestWebKitAPI
+
+#if USE(APPLE_INTERNAL_SDK)
+#import <WebKitAdditions/LoadWebArchiveAdditions.mm>
+#endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to