Diff
Modified: trunk/Source/WebCore/ChangeLog (240645 => 240646)
--- trunk/Source/WebCore/ChangeLog 2019-01-29 06:59:13 UTC (rev 240645)
+++ trunk/Source/WebCore/ChangeLog 2019-01-29 07:15:00 UTC (rev 240646)
@@ -1,3 +1,23 @@
+2019-01-28 Ryosuke Niwa <[email protected]>
+
+ User agent string override for navigator.userAgent should be site specific quirks
+ https://bugs.webkit.org/show_bug.cgi?id=193950
+
+ Reviewed by Brent Fulgham.
+
+ In order to make it possible to toggle the UA string override just for navigator.userAgent via Web Inspector,
+ we need to put this override behind the site specific quirks. Because WebInspector overrides Page's setting
+ without updating WKPreferences, there is no way for WKWebView client's to know whether the site specific quirks
+ had been disabled or not.
+
+ * loader/DocumentLoader.h:
+ (WebCore::DocumentLoader::setCustomJavaScriptUserAgentAsSiteSpecificQuirks):
+ (WebCore::DocumentLoader::customJavaScriptUserAgentAsSiteSpecificQuirks const):
+ (WebCore::DocumentLoader::setCustomJavaScriptUserAgent): Deleted.
+ (WebCore::DocumentLoader::customJavaScriptUserAgent const): Deleted.
+ * loader/FrameLoader.cpp:
+ (WebCore::FrameLoader::userAgentForJavaScript const):
+
2019-01-28 Devin Rousso <[email protected]>
Web Inspector: provide a way to edit page WebRTC settings on a remote target
Modified: trunk/Source/WebCore/loader/DocumentLoader.h (240645 => 240646)
--- trunk/Source/WebCore/loader/DocumentLoader.h 2019-01-29 06:59:13 UTC (rev 240645)
+++ trunk/Source/WebCore/loader/DocumentLoader.h 2019-01-29 07:15:00 UTC (rev 240646)
@@ -271,8 +271,8 @@
void setCustomUserAgent(const String& customUserAgent) { m_customUserAgent = customUserAgent; }
const String& customUserAgent() const { return m_customUserAgent; }
- void setCustomJavaScriptUserAgent(const String& customJavaScriptUserAgent) { m_customJavaScriptUserAgent = customJavaScriptUserAgent; }
- const String& customJavaScriptUserAgent() const { return m_customJavaScriptUserAgent; }
+ void setCustomJavaScriptUserAgentAsSiteSpecificQuirks(const String& customUserAgent) { m_customJavaScriptUserAgentAsSiteSpecificQuirks = customUserAgent; }
+ const String& customJavaScriptUserAgentAsSiteSpecificQuirks() const { return m_customJavaScriptUserAgentAsSiteSpecificQuirks; }
void setCustomNavigatorPlatform(const String& customNavigatorPlatform) { m_customNavigatorPlatform = customNavigatorPlatform; }
const String& customNavigatorPlatform() const { return m_customNavigatorPlatform; }
@@ -546,7 +546,7 @@
HashMap<String, Vector<std::pair<String, uint32_t>>> m_pendingContentExtensionDisplayNoneSelectors;
#endif
String m_customUserAgent;
- String m_customJavaScriptUserAgent;
+ String m_customJavaScriptUserAgentAsSiteSpecificQuirks;
String m_customNavigatorPlatform;
bool m_userContentExtensionsEnabled { true };
bool m_deviceOrientationEventEnabled { true };
Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (240645 => 240646)
--- trunk/Source/WebCore/loader/FrameLoader.cpp 2019-01-29 06:59:13 UTC (rev 240645)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp 2019-01-29 07:15:00 UTC (rev 240646)
@@ -2715,7 +2715,8 @@
String userAgent;
if (auto* documentLoader = m_frame.mainFrame().loader().activeDocumentLoader()) {
- userAgent = documentLoader->customJavaScriptUserAgent();
+ if (m_frame.settings().needsSiteSpecificQuirks())
+ userAgent = documentLoader->customJavaScriptUserAgentAsSiteSpecificQuirks();
if (userAgent.isEmpty())
userAgent = documentLoader->customUserAgent();
}
Modified: trunk/Source/WebKit/ChangeLog (240645 => 240646)
--- trunk/Source/WebKit/ChangeLog 2019-01-29 06:59:13 UTC (rev 240645)
+++ trunk/Source/WebKit/ChangeLog 2019-01-29 07:15:00 UTC (rev 240646)
@@ -1,3 +1,25 @@
+2019-01-28 Ryosuke Niwa <[email protected]>
+
+ User agent string override for navigator.userAgent should be site specific quirks
+ https://bugs.webkit.org/show_bug.cgi?id=193950
+
+ Reviewed by Brent Fulgham.
+
+ Renamed the various member variables, functions, properties and selectors.
+
+ * Shared/WebsitePoliciesData.cpp:
+ (WebKit::WebsitePoliciesData::encode const):
+ (WebKit::WebsitePoliciesData::decode):
+ (WebKit::WebsitePoliciesData::applyToDocumentLoader):
+ * Shared/WebsitePoliciesData.h:
+ * UIProcess/API/APIWebsitePolicies.cpp:
+ (API::WebsitePolicies::data):
+ * UIProcess/API/APIWebsitePolicies.h:
+ * UIProcess/API/Cocoa/_WKWebsitePolicies.h:
+ * UIProcess/API/Cocoa/_WKWebsitePolicies.mm:
+ (-[_WKWebsitePolicies setCustomJavaScriptUserAgentAsSiteSpecificQuirks:]): Renamed from setCustomJavaScriptUserAgent.
+ (-[_WKWebsitePolicies customJavaScriptUserAgentAsSiteSpecificQuirks]): Renamed from customJavaScriptUserAgent.
+
2019-01-28 Commit Queue <[email protected]>
Unreviewed, rolling out r240630.
Modified: trunk/Source/WebKit/Shared/WebsitePoliciesData.cpp (240645 => 240646)
--- trunk/Source/WebKit/Shared/WebsitePoliciesData.cpp 2019-01-29 06:59:13 UTC (rev 240645)
+++ trunk/Source/WebKit/Shared/WebsitePoliciesData.cpp 2019-01-29 07:15:00 UTC (rev 240646)
@@ -44,7 +44,7 @@
encoder << popUpPolicy;
encoder << websiteDataStoreParameters;
encoder << customUserAgent;
- encoder << customJavaScriptUserAgent;
+ encoder << customJavaScriptUserAgentAsSiteSpecificQuirks;
encoder << customNavigatorPlatform;
}
@@ -90,9 +90,9 @@
if (!customUserAgent)
return WTF::nullopt;
- Optional<String> customJavaScriptUserAgent;
- decoder >> customJavaScriptUserAgent;
- if (!customJavaScriptUserAgent)
+ Optional<String> customJavaScriptUserAgentAsSiteSpecificQuirks;
+ decoder >> customJavaScriptUserAgentAsSiteSpecificQuirks;
+ if (!customJavaScriptUserAgentAsSiteSpecificQuirks)
return WTF::nullopt;
Optional<String> customNavigatorPlatform;
@@ -109,7 +109,7 @@
WTFMove(*popUpPolicy),
WTFMove(*websiteDataStoreParameters),
WTFMove(*customUserAgent),
- WTFMove(*customJavaScriptUserAgent),
+ WTFMove(*customJavaScriptUserAgentAsSiteSpecificQuirks),
WTFMove(*customNavigatorPlatform),
} };
}
@@ -118,7 +118,7 @@
{
documentLoader.setCustomHeaderFields(WTFMove(websitePolicies.customHeaderFields));
documentLoader.setCustomUserAgent(websitePolicies.customUserAgent);
- documentLoader.setCustomJavaScriptUserAgent(websitePolicies.customJavaScriptUserAgent);
+ documentLoader.setCustomJavaScriptUserAgentAsSiteSpecificQuirks(websitePolicies.customJavaScriptUserAgentAsSiteSpecificQuirks);
documentLoader.setCustomNavigatorPlatform(websitePolicies.customNavigatorPlatform);
documentLoader.setDeviceOrientationEventEnabled(websitePolicies.deviceOrientationEventEnabled);
Modified: trunk/Source/WebKit/Shared/WebsitePoliciesData.h (240645 => 240646)
--- trunk/Source/WebKit/Shared/WebsitePoliciesData.h 2019-01-29 06:59:13 UTC (rev 240645)
+++ trunk/Source/WebKit/Shared/WebsitePoliciesData.h 2019-01-29 07:15:00 UTC (rev 240646)
@@ -54,7 +54,7 @@
WebsitePopUpPolicy popUpPolicy { WebsitePopUpPolicy::Default };
Optional<WebsiteDataStoreParameters> websiteDataStoreParameters;
String customUserAgent;
- String customJavaScriptUserAgent;
+ String customJavaScriptUserAgentAsSiteSpecificQuirks;
String customNavigatorPlatform;
void encode(IPC::Encoder&) const;
Modified: trunk/Source/WebKit/UIProcess/API/APIWebsitePolicies.cpp (240645 => 240646)
--- trunk/Source/WebKit/UIProcess/API/APIWebsitePolicies.cpp 2019-01-29 06:59:13 UTC (rev 240645)
+++ trunk/Source/WebKit/UIProcess/API/APIWebsitePolicies.cpp 2019-01-29 07:15:00 UTC (rev 240646)
@@ -57,7 +57,7 @@
if (m_websiteDataStore)
parameters = m_websiteDataStore->websiteDataStore().parameters();
return { contentBlockersEnabled(), deviceOrientationEventEnabled(), allowedAutoplayQuirks(), autoplayPolicy(),
- customHeaderFields(), popUpPolicy(), WTFMove(parameters), m_customUserAgent, m_customJavaScriptUserAgent, m_customNavigatorPlatform };
+ customHeaderFields(), popUpPolicy(), WTFMove(parameters), m_customUserAgent, m_customJavaScriptUserAgentAsSiteSpecificQuirks, m_customNavigatorPlatform };
}
}
Modified: trunk/Source/WebKit/UIProcess/API/APIWebsitePolicies.h (240645 => 240646)
--- trunk/Source/WebKit/UIProcess/API/APIWebsitePolicies.h 2019-01-29 06:59:13 UTC (rev 240645)
+++ trunk/Source/WebKit/UIProcess/API/APIWebsitePolicies.h 2019-01-29 07:15:00 UTC (rev 240646)
@@ -75,8 +75,8 @@
void setCustomUserAgent(const WTF::String& customUserAgent) { m_customUserAgent = customUserAgent; }
const WTF::String& customUserAgent() const { return m_customUserAgent; }
- void setCustomJavaScriptUserAgent(const WTF::String& customJavaScriptUserAgent) { m_customJavaScriptUserAgent = customJavaScriptUserAgent; }
- const WTF::String& customJavaScriptUserAgent() const { return m_customJavaScriptUserAgent; }
+ void setCustomJavaScriptUserAgentAsSiteSpecificQuirks(const WTF::String& customUserAgent) { m_customJavaScriptUserAgentAsSiteSpecificQuirks = customUserAgent; }
+ const WTF::String& customJavaScriptUserAgentAsSiteSpecificQuirks() const { return m_customJavaScriptUserAgentAsSiteSpecificQuirks; }
void setCustomNavigatorPlatform(const WTF::String& customNavigatorPlatform) { m_customNavigatorPlatform = customNavigatorPlatform; }
const WTF::String& customNavigatorPlatform() const { return m_customNavigatorPlatform; }
@@ -92,7 +92,7 @@
WebKit::WebsitePopUpPolicy m_popUpPolicy { WebKit::WebsitePopUpPolicy::Default };
RefPtr<WebsiteDataStore> m_websiteDataStore;
WTF::String m_customUserAgent;
- WTF::String m_customJavaScriptUserAgent;
+ WTF::String m_customJavaScriptUserAgentAsSiteSpecificQuirks;
WTF::String m_customNavigatorPlatform;
};
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePolicies.h (240645 => 240646)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePolicies.h 2019-01-29 06:59:13 UTC (rev 240645)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePolicies.h 2019-01-29 07:15:00 UTC (rev 240646)
@@ -59,7 +59,7 @@
@property (nonatomic) _WKWebsitePopUpPolicy popUpPolicy WK_API_AVAILABLE(macosx(10.14), ios(12.0));
@property (nonatomic, strong) WKWebsiteDataStore *websiteDataStore WK_API_AVAILABLE(macosx(10.13.4), ios(11.3));
@property (nonatomic, copy) NSString *customUserAgent WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
-@property (nonatomic, copy) NSString *customJavaScriptUserAgent WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
+@property (nonatomic, copy) NSString *customJavaScriptUserAgentAsSiteSpecificQuirks WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
@property (nonatomic, copy) NSString *customNavigatorPlatform WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
@property (nonatomic) BOOL deviceOrientationEventEnabled WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePolicies.mm (240645 => 240646)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePolicies.mm 2019-01-29 06:59:13 UTC (rev 240645)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePolicies.mm 2019-01-29 07:15:00 UTC (rev 240646)
@@ -209,14 +209,14 @@
return _websitePolicies->customUserAgent();
}
-- (void)setCustomJavaScriptUserAgent:(NSString *)customUserAgent
+- (void)setCustomJavaScriptUserAgentAsSiteSpecificQuirks:(NSString *)customUserAgent
{
- _websitePolicies->setCustomJavaScriptUserAgent(customUserAgent);
+ _websitePolicies->setCustomJavaScriptUserAgentAsSiteSpecificQuirks(customUserAgent);
}
-- (NSString *)customJavaScriptUserAgent
+- (NSString *)customJavaScriptUserAgentAsSiteSpecificQuirks
{
- return _websitePolicies->customJavaScriptUserAgent();
+ return _websitePolicies->customJavaScriptUserAgentAsSiteSpecificQuirks();
}
- (void)setCustomNavigatorPlatform:(NSString *)customNavigatorPlatform
Modified: trunk/Tools/ChangeLog (240645 => 240646)
--- trunk/Tools/ChangeLog 2019-01-29 06:59:13 UTC (rev 240645)
+++ trunk/Tools/ChangeLog 2019-01-29 07:15:00 UTC (rev 240646)
@@ -1,3 +1,15 @@
+2019-01-28 Ryosuke Niwa <[email protected]>
+
+ User agent string override for navigator.userAgent should be site specific quirks
+ https://bugs.webkit.org/show_bug.cgi?id=193950
+
+ Reviewed by Brent Fulgham.
+
+ Updated per the _WKWebsitePolicies rename.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm:
+ (-[CustomJavaScriptUserAgentDelegate _webView:decidePolicyForNavigationAction:userInfo:decisionHandler:]):
+
2019-01-28 Ross Kirsling <[email protected]>
Remove unnecessary `using namespace WTF`s (or at least restrict their scope).
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm (240645 => 240646)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm 2019-01-29 06:59:13 UTC (rev 240645)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm 2019-01-29 07:15:00 UTC (rev 240646)
@@ -29,6 +29,7 @@
#import "TestWKWebView.h"
#import <WebKit/WKNavigationDelegatePrivate.h>
#import <WebKit/WKPagePrivate.h>
+#import <WebKit/WKPreferencesPrivate.h>
#import <WebKit/WKPreferencesRefPrivate.h>
#import <WebKit/WKUIDelegatePrivate.h>
#import <WebKit/WKURLSchemeTaskPrivate.h>
@@ -1114,7 +1115,7 @@
{
_WKWebsitePolicies *websitePolicies = [[[_WKWebsitePolicies alloc] init] autorelease];
if (navigationAction.targetFrame.mainFrame) {
- [websitePolicies setCustomJavaScriptUserAgent:@"Foo Custom _javascript_ UserAgent"];
+ [websitePolicies setCustomJavaScriptUserAgentAsSiteSpecificQuirks:@"Foo Custom _javascript_ UserAgent"];
if (_setCustomUserAgent)
[websitePolicies setCustomUserAgent:@"Foo Custom Request UserAgent"];
}
@@ -1142,6 +1143,7 @@
EXPECT_TRUE([userAgentString hasSuffix:@"(KHTML, like Gecko)"]);
}];
[configuration setURLSchemeHandler:schemeHandler.get() forURLScheme:@"test"];
+ [configuration preferences]._needsSiteSpecificQuirks = YES;
auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
@@ -1173,6 +1175,7 @@
EXPECT_STREQ("Foo Custom Request UserAgent", [[task.request valueForHTTPHeaderField:@"User-Agent"] UTF8String]);
}];
[configuration setURLSchemeHandler:schemeHandler.get() forURLScheme:@"test"];
+ [configuration preferences]._needsSiteSpecificQuirks = YES;
auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);