WebKit Bugzilla
Attachment 360430 Details for
Bug 193950
: User agent string override for navigator.userAgent should be site specific quirks
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch for landing
bug-193950-20190128205023.patch (text/plain), 14.90 KB, created by
Ryosuke Niwa
on 2019-01-28 20:50:24 PST
(
hide
)
Description:
Patch for landing
Filename:
MIME Type:
Creator:
Ryosuke Niwa
Created:
2019-01-28 20:50:24 PST
Size:
14.90 KB
patch
obsolete
>Index: Source/WebCore/ChangeLog >=================================================================== >--- Source/WebCore/ChangeLog (revision 240635) >+++ Source/WebCore/ChangeLog (working copy) >@@ -1,3 +1,23 @@ >+2019-01-28 Ryosuke Niwa <rniwa@webkit.org> >+ >+ 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 Antoine Quint <graouts@apple.com> > > Implement capture for Pointer Events on iOS >Index: Source/WebCore/loader/DocumentLoader.h >=================================================================== >--- Source/WebCore/loader/DocumentLoader.h (revision 240635) >+++ Source/WebCore/loader/DocumentLoader.h (working copy) >@@ -271,8 +271,8 @@ public: > 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 @@ private: > 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 }; >Index: Source/WebCore/loader/FrameLoader.cpp >=================================================================== >--- Source/WebCore/loader/FrameLoader.cpp (revision 240635) >+++ Source/WebCore/loader/FrameLoader.cpp (working copy) >@@ -2715,7 +2715,8 @@ String FrameLoader::userAgentForJavaScri > 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(); > } >Index: Source/WebKit/ChangeLog >=================================================================== >--- Source/WebKit/ChangeLog (revision 240635) >+++ Source/WebKit/ChangeLog (working copy) >@@ -1,3 +1,25 @@ >+2019-01-28 Ryosuke Niwa <rniwa@webkit.org> >+ >+ 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 Jon Lee <jonlee@apple.com> > > Update Screen Capture preference >Index: Source/WebKit/Shared/WebsitePoliciesData.cpp >=================================================================== >--- Source/WebKit/Shared/WebsitePoliciesData.cpp (revision 240635) >+++ Source/WebKit/Shared/WebsitePoliciesData.cpp (working copy) >@@ -44,7 +44,7 @@ void WebsitePoliciesData::encode(IPC::En > encoder << popUpPolicy; > encoder << websiteDataStoreParameters; > encoder << customUserAgent; >- encoder << customJavaScriptUserAgent; >+ encoder << customJavaScriptUserAgentAsSiteSpecificQuirks; > encoder << customNavigatorPlatform; > } > >@@ -90,9 +90,9 @@ Optional<WebsitePoliciesData> WebsitePol > 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 @@ Optional<WebsitePoliciesData> WebsitePol > WTFMove(*popUpPolicy), > WTFMove(*websiteDataStoreParameters), > WTFMove(*customUserAgent), >- WTFMove(*customJavaScriptUserAgent), >+ WTFMove(*customJavaScriptUserAgentAsSiteSpecificQuirks), > WTFMove(*customNavigatorPlatform), > } }; > } >@@ -118,7 +118,7 @@ void WebsitePoliciesData::applyToDocumen > { > 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); > >Index: Source/WebKit/Shared/WebsitePoliciesData.h >=================================================================== >--- Source/WebKit/Shared/WebsitePoliciesData.h (revision 240635) >+++ Source/WebKit/Shared/WebsitePoliciesData.h (working copy) >@@ -54,7 +54,7 @@ struct WebsitePoliciesData { > WebsitePopUpPolicy popUpPolicy { WebsitePopUpPolicy::Default }; > Optional<WebsiteDataStoreParameters> websiteDataStoreParameters; > String customUserAgent; >- String customJavaScriptUserAgent; >+ String customJavaScriptUserAgentAsSiteSpecificQuirks; > String customNavigatorPlatform; > > void encode(IPC::Encoder&) const; >Index: Source/WebKit/UIProcess/API/APIWebsitePolicies.cpp >=================================================================== >--- Source/WebKit/UIProcess/API/APIWebsitePolicies.cpp (revision 240635) >+++ Source/WebKit/UIProcess/API/APIWebsitePolicies.cpp (working copy) >@@ -57,7 +57,7 @@ WebKit::WebsitePoliciesData WebsitePolic > 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 }; > } > > } >Index: Source/WebKit/UIProcess/API/APIWebsitePolicies.h >=================================================================== >--- Source/WebKit/UIProcess/API/APIWebsitePolicies.h (revision 240635) >+++ Source/WebKit/UIProcess/API/APIWebsitePolicies.h (working copy) >@@ -75,8 +75,8 @@ public: > 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 @@ private: > 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; > }; > >Index: Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePolicies.h >=================================================================== >--- Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePolicies.h (revision 240635) >+++ Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePolicies.h (working copy) >@@ -59,7 +59,7 @@ WK_CLASS_AVAILABLE(macosx(10.12.3), ios( > @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)); > >Index: Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePolicies.mm >=================================================================== >--- Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePolicies.mm (revision 240635) >+++ Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePolicies.mm (working copy) >@@ -209,14 +209,14 @@ - (NSString *)customUserAgent > 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 >Index: Tools/ChangeLog >=================================================================== >--- Tools/ChangeLog (revision 240635) >+++ Tools/ChangeLog (working copy) >@@ -1,3 +1,15 @@ >+2019-01-28 Ryosuke Niwa <rniwa@webkit.org> >+ >+ 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 Andy Estes <aestes@apple.com> > > [watchOS] Enable Parental Controls content filtering >Index: Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm >=================================================================== >--- Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm (revision 240635) >+++ Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm (working copy) >@@ -1114,7 +1114,7 @@ - (void)_webView:(WKWebView *)webView de > { > _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"]; > } >@@ -1145,6 +1145,10 @@ TEST(WebKit, WebsitePoliciesCustomJavaSc > > auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]); > >+ WKRetainPtr<WKPreferencesRef> preferences(AdoptWK, WKPreferencesCreate()); >+ WKPreferencesSetNeedsSiteSpecificQuirks(preferences.get(), true); >+ WKPageGroupSetPreferences(WKPageGetPageGroup([webView _pageForTesting]), preferences.get()); >+ > auto delegate = adoptNS([[CustomJavaScriptUserAgentDelegate alloc] init]); > [webView setNavigationDelegate:delegate.get()]; > >@@ -1176,6 +1180,10 @@ TEST(WebKit, WebsitePoliciesCustomUserAg > > auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]); > >+ WKRetainPtr<WKPreferencesRef> preferences(AdoptWK, WKPreferencesCreate()); >+ WKPreferencesSetNeedsSiteSpecificQuirks(preferences.get(), true); >+ WKPageGroupSetPreferences(WKPageGetPageGroup([webView _pageForTesting]), preferences.get()); >+ > auto delegate = adoptNS([[CustomJavaScriptUserAgentDelegate alloc] init]); > delegate.get().setCustomUserAgent = YES; > [webView setNavigationDelegate:delegate.get()];
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 193950
:
360425
|
360429
|
360430
|
360437