WebKit Bugzilla
Attachment 358321 Details for
Bug 193143
: Add support for toggling device orientation API support per site
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-193143-20190104085908.patch (text/plain), 27.28 KB, created by
Chris Dumez
on 2019-01-04 08:59:09 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Chris Dumez
Created:
2019-01-04 08:59:09 PST
Size:
27.28 KB
patch
obsolete
>Subversion Revision: 239596 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index dc1f8d982cc8394940734728052ad8004df6fa69..c62a3cf0c51e4f8721c75ec5f123cdd71210c45e 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,22 @@ >+2019-01-04 Chris Dumez <cdumez@apple.com> >+ >+ Add support for toggling device orientation API support per site >+ https://bugs.webkit.org/show_bug.cgi?id=193143 >+ <rdar://problem/46605724> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add support for toggling device orientation API support per site via _WKWebsitePolicies. >+ >+ * dom/Document.cpp: >+ (WebCore::Document::simulateDeviceOrientationChange): >+ * dom/Document.h: >+ * loader/DocumentLoader.h: >+ (WebCore::DocumentLoader::deviceOrientationEventEnabled const): >+ (WebCore::DocumentLoader::setDeviceOrientationEventEnabled): >+ * page/DOMWindow.cpp: >+ (WebCore::DOMWindow::addEventListener): >+ > 2019-01-02 Simon Fraser <simon.fraser@apple.com> > > REGRESSION (r239306): Don't disable font smoothing in transparent layers on macOS Mojave and later >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index a4835ba42b6cfd6fdc471db3989d1a8e4f216af9..94e48e4c6f6e520a3956753a3136f7dd5aef72eb 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,36 @@ >+2019-01-04 Chris Dumez <cdumez@apple.com> >+ >+ Add support for toggling device orientation API support per site >+ https://bugs.webkit.org/show_bug.cgi?id=193143 >+ <rdar://problem/46605724> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add support for toggling device orientation API support per site via _WKWebsitePolicies. >+ >+ * 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/WKWebView.mm: >+ (-[WKWebView _simulateDeviceOrientationChangeWithAlpha:beta:gamma:]): >+ * UIProcess/API/Cocoa/WKWebViewPrivate.h: >+ * UIProcess/API/Cocoa/_WKWebsitePolicies.h: >+ * UIProcess/API/Cocoa/_WKWebsitePolicies.mm: >+ (-[_WKWebsitePolicies setDeviceOrientationEventEnabled:]): >+ (-[_WKWebsitePolicies deviceOrientationEventEnabled]): >+ * UIProcess/WebPageProxy.cpp: >+ (WebKit::WebPageProxy::simulateDeviceOrientationChange): >+ * UIProcess/WebPageProxy.h: >+ * WebProcess/WebPage/WebPage.cpp: >+ (WebKit::WebPage::simulateDeviceOrientationChange): >+ * WebProcess/WebPage/WebPage.h: >+ * WebProcess/WebPage/WebPage.messages.in: >+ > 2019-01-03 Brent Fulgham <bfulgham@apple.com> > > Remove logic handling DNT header during redirects >diff --git a/Source/WebCore/dom/Document.cpp b/Source/WebCore/dom/Document.cpp >index ec66be7661d21606e57cd1f749cdcd42c17f5edc..78d0f444434f08f585dd11333fe1d08eaa7f11a7 100644 >--- a/Source/WebCore/dom/Document.cpp >+++ b/Source/WebCore/dom/Document.cpp >@@ -6230,6 +6230,12 @@ DeviceOrientationController* Document::deviceOrientationController() const > return m_deviceOrientationController.get(); > } > >+void Document::simulateDeviceOrientationChange(double alpha, double beta, double gamma) >+{ >+ auto orientation = DeviceOrientationData::create(alpha, beta, gamma, WTF::nullopt, WTF::nullopt); >+ deviceOrientationController()->didChangeDeviceOrientation(orientation.ptr()); >+} >+ > #endif > > #if ENABLE(FULLSCREEN_API) >diff --git a/Source/WebCore/dom/Document.h b/Source/WebCore/dom/Document.h >index 8a0ffe10b459712274de7d7242860290737cf9ea..6bedf75cfbe29670ebfbb51163e0100326fda2f2 100644 >--- a/Source/WebCore/dom/Document.h >+++ b/Source/WebCore/dom/Document.h >@@ -1229,6 +1229,7 @@ public: > #if ENABLE(DEVICE_ORIENTATION) && PLATFORM(IOS_FAMILY) > DeviceMotionController* deviceMotionController() const; > DeviceOrientationController* deviceOrientationController() const; >+ WEBCORE_EXPORT void simulateDeviceOrientationChange(double alpha, double beta, double gamma); > #endif > > const DocumentTiming& timing() const { return m_documentTiming; } >diff --git a/Source/WebCore/loader/DocumentLoader.h b/Source/WebCore/loader/DocumentLoader.h >index bc3b1961980a70a42c1ea5d4641fda87cc24c3fd..f4c637739a3594db19a3d5ded204fbd3ee2f70fe 100644 >--- a/Source/WebCore/loader/DocumentLoader.h >+++ b/Source/WebCore/loader/DocumentLoader.h >@@ -261,6 +261,9 @@ public: > bool userContentExtensionsEnabled() const { return m_userContentExtensionsEnabled; } > void setUserContentExtensionsEnabled(bool enabled) { m_userContentExtensionsEnabled = enabled; } > >+ bool deviceOrientationEventEnabled() const { return m_deviceOrientationEventEnabled; } >+ void setDeviceOrientationEventEnabled(bool enabled) { m_deviceOrientationEventEnabled = enabled; } >+ > AutoplayPolicy autoplayPolicy() const { return m_autoplayPolicy; } > void setAutoplayPolicy(AutoplayPolicy policy) { m_autoplayPolicy = policy; } > >@@ -541,6 +544,7 @@ private: > String m_customUserAgent; > String m_customNavigatorPlatform; > bool m_userContentExtensionsEnabled { true }; >+ bool m_deviceOrientationEventEnabled { true }; > AutoplayPolicy m_autoplayPolicy { AutoplayPolicy::Default }; > OptionSet<AutoplayQuirk> m_allowedAutoplayQuirks; > PopUpPolicy m_popUpPolicy { PopUpPolicy::Default }; >diff --git a/Source/WebCore/page/DOMWindow.cpp b/Source/WebCore/page/DOMWindow.cpp >index 19f8f5275ace6ba27fc452c6ff7b68c37351c38d..1759defc070a43d4b6fa2b5fb7618cad1aa43755 100644 >--- a/Source/WebCore/page/DOMWindow.cpp >+++ b/Source/WebCore/page/DOMWindow.cpp >@@ -1839,9 +1839,9 @@ bool DOMWindow::addEventListener(const AtomicString& eventType, Ref<EventListene > #endif > > #if ENABLE(DEVICE_ORIENTATION) >- if (frame() && frame()->settings().deviceOrientationEventEnabled()) { >+ if (frame() && frame()->settings().deviceOrientationEventEnabled() && document() && document()->loader() && document()->loader()->deviceOrientationEventEnabled()) { > #if PLATFORM(IOS_FAMILY) >- if ((eventType == eventNames().devicemotionEvent || eventType == eventNames().deviceorientationEvent) && document()) { >+ if ((eventType == eventNames().devicemotionEvent || eventType == eventNames().deviceorientationEvent)) { > if (isSameSecurityOriginAsMainFrame() && isSecureContext()) { > if (eventType == eventNames().deviceorientationEvent) > document()->deviceOrientationController()->addDeviceEventListener(this); >@@ -1859,13 +1859,13 @@ bool DOMWindow::addEventListener(const AtomicString& eventType, Ref<EventListene > if (isSameSecurityOriginAsMainFrame() && isSecureContext()) { > if (DeviceMotionController* controller = DeviceMotionController::from(page())) > controller->addDeviceEventListener(this); >- } else if (document()) >+ } else > document()->addConsoleMessage(MessageSource::JS, MessageLevel::Warning, "Blocked attempt to add a device motion listener from child frame that wasn't the same security origin as the main page."_s); > } else if (eventType == eventNames().deviceorientationEvent) { > if (isSameSecurityOriginAsMainFrame() && isSecureContext()) { > if (DeviceOrientationController* controller = DeviceOrientationController::from(page())) > controller->addDeviceEventListener(this); >- } else if (document()) { >+ } else { > if (isSecureContext()) > document()->addConsoleMessage(MessageSource::JS, MessageLevel::Warning, "Blocked attempt to add a device orientation listener from child frame that wasn't the same security origin as the main page."_s); > else >diff --git a/Source/WebKit/Shared/WebsitePoliciesData.cpp b/Source/WebKit/Shared/WebsitePoliciesData.cpp >index 414cb425affd4a097442b6f1c0b53274bb7ac0d7..b734f0e3f820968af482379c50079fa819a93bf1 100644 >--- a/Source/WebKit/Shared/WebsitePoliciesData.cpp >+++ b/Source/WebKit/Shared/WebsitePoliciesData.cpp >@@ -37,6 +37,7 @@ namespace WebKit { > void WebsitePoliciesData::encode(IPC::Encoder& encoder) const > { > encoder << contentBlockersEnabled; >+ encoder << deviceOrientationEventEnabled; > encoder << autoplayPolicy; > encoder << allowedAutoplayQuirks; > encoder << customHeaderFields; >@@ -52,6 +53,11 @@ Optional<WebsitePoliciesData> WebsitePoliciesData::decode(IPC::Decoder& decoder) > decoder >> contentBlockersEnabled; > if (!contentBlockersEnabled) > return WTF::nullopt; >+ >+ Optional<bool> deviceOrientationEventEnabled; >+ decoder >> deviceOrientationEventEnabled; >+ if (!deviceOrientationEventEnabled) >+ return WTF::nullopt; > > Optional<WebsiteAutoplayPolicy> autoplayPolicy; > decoder >> autoplayPolicy; >@@ -90,6 +96,7 @@ Optional<WebsitePoliciesData> WebsitePoliciesData::decode(IPC::Decoder& decoder) > > return { { > WTFMove(*contentBlockersEnabled), >+ WTFMove(*deviceOrientationEventEnabled), > WTFMove(*allowedAutoplayQuirks), > WTFMove(*autoplayPolicy), > WTFMove(*customHeaderFields), >@@ -105,6 +112,7 @@ void WebsitePoliciesData::applyToDocumentLoader(WebsitePoliciesData&& websitePol > documentLoader.setCustomHeaderFields(WTFMove(websitePolicies.customHeaderFields)); > documentLoader.setCustomUserAgent(websitePolicies.customUserAgent); > documentLoader.setCustomNavigatorPlatform(websitePolicies.customNavigatorPlatform); >+ documentLoader.setDeviceOrientationEventEnabled(websitePolicies.deviceOrientationEventEnabled); > > // Only setUserContentExtensionsEnabled if it hasn't already been disabled by reloading without content blockers. > if (documentLoader.userContentExtensionsEnabled()) >diff --git a/Source/WebKit/Shared/WebsitePoliciesData.h b/Source/WebKit/Shared/WebsitePoliciesData.h >index a7ab13a0b74dcf227422033238eda7a27818e9a9..fcaed27c4039c8112b22e1c300000782908d413f 100644 >--- a/Source/WebKit/Shared/WebsitePoliciesData.h >+++ b/Source/WebKit/Shared/WebsitePoliciesData.h >@@ -47,6 +47,7 @@ struct WebsitePoliciesData { > static void applyToDocumentLoader(WebsitePoliciesData&&, WebCore::DocumentLoader&); > > bool contentBlockersEnabled { true }; >+ bool deviceOrientationEventEnabled { true }; > OptionSet<WebsiteAutoplayQuirk> allowedAutoplayQuirks; > WebsiteAutoplayPolicy autoplayPolicy { WebsiteAutoplayPolicy::Default }; > Vector<WebCore::HTTPHeaderField> customHeaderFields; >diff --git a/Source/WebKit/UIProcess/API/APIWebsitePolicies.cpp b/Source/WebKit/UIProcess/API/APIWebsitePolicies.cpp >index 65918a8b489d9f5d3ebeda46a9df325e79c42959..8447696e3e246ba9b95dcbb2f5caf52368d9794c 100644 >--- a/Source/WebKit/UIProcess/API/APIWebsitePolicies.cpp >+++ b/Source/WebKit/UIProcess/API/APIWebsitePolicies.cpp >@@ -56,7 +56,7 @@ WebKit::WebsitePoliciesData WebsitePolicies::data() > Optional<WebKit::WebsiteDataStoreParameters> parameters; > if (m_websiteDataStore) > parameters = m_websiteDataStore->websiteDataStore().parameters(); >- return { contentBlockersEnabled(), allowedAutoplayQuirks(), autoplayPolicy(), customHeaderFields(), popUpPolicy(), WTFMove(parameters), m_customUserAgent, m_customNavigatorPlatform }; >+ return { contentBlockersEnabled(), deviceOrientationEventEnabled(), allowedAutoplayQuirks(), autoplayPolicy(), customHeaderFields(), popUpPolicy(), WTFMove(parameters), m_customUserAgent, m_customNavigatorPlatform }; > } > > } >diff --git a/Source/WebKit/UIProcess/API/APIWebsitePolicies.h b/Source/WebKit/UIProcess/API/APIWebsitePolicies.h >index 3f7aa061bf182c0c66f79ad997fa7ed9a3a320ad..718c755f6f3c1c668522c504bc062c7d8d4ba8fb 100644 >--- a/Source/WebKit/UIProcess/API/APIWebsitePolicies.h >+++ b/Source/WebKit/UIProcess/API/APIWebsitePolicies.h >@@ -50,6 +50,9 @@ public: > > bool contentBlockersEnabled() const { return m_contentBlockersEnabled; } > void setContentBlockersEnabled(bool enabled) { m_contentBlockersEnabled = enabled; } >+ >+ bool deviceOrientationEventEnabled() const { return m_deviceOrientationEventEnabled; } >+ void setDeviceOrientationEventEnabled(bool enabled) { m_deviceOrientationEventEnabled = enabled; } > > OptionSet<WebKit::WebsiteAutoplayQuirk> allowedAutoplayQuirks() const { return m_allowedAutoplayQuirks; } > void setAllowedAutoplayQuirks(OptionSet<WebKit::WebsiteAutoplayQuirk> quirks) { m_allowedAutoplayQuirks = quirks; } >@@ -79,6 +82,7 @@ private: > WebsitePolicies(bool contentBlockersEnabled, OptionSet<WebKit::WebsiteAutoplayQuirk>, WebKit::WebsiteAutoplayPolicy, Vector<WebCore::HTTPHeaderField>&&, WebKit::WebsitePopUpPolicy, RefPtr<WebsiteDataStore>&&); > > bool m_contentBlockersEnabled { true }; >+ bool m_deviceOrientationEventEnabled { true }; > OptionSet<WebKit::WebsiteAutoplayQuirk> m_allowedAutoplayQuirks; > WebKit::WebsiteAutoplayPolicy m_autoplayPolicy { WebKit::WebsiteAutoplayPolicy::Default }; > Vector<WebCore::HTTPHeaderField> m_customHeaderFields; >diff --git a/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm b/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm >index 3c5bebf27b42fb9456fedd0e9ae133e75bda6dc9..844364347bb9875340ba2ca049ce4086200472d2 100644 >--- a/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm >+++ b/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm >@@ -4806,6 +4806,11 @@ - (_WKAttachment *)_attachmentForIdentifier:(NSString *)identifier > return nil; > } > >+- (void)_simulateDeviceOrientationChangeWithAlpha:(double)alpha beta:(double)beta gamma:(double)gamma >+{ >+ _page->simulateDeviceOrientationChange(alpha, beta, gamma); >+} >+ > + (BOOL)_handlesSafeBrowsing > { > return true; >diff --git a/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h b/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h >index e709409fb4a66834f5cb2fa3967a393af5986050..079a8125a32e892d0914f8a675546474b71d6150 100644 >--- a/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h >+++ b/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h >@@ -190,6 +190,8 @@ typedef NS_OPTIONS(NSUInteger, _WKRectEdge) { > - (_WKAttachment *)_insertAttachmentWithFileWrapper:(NSFileWrapper *)fileWrapper contentType:(NSString *)contentType completion:(void(^)(BOOL success))completionHandler WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); > - (_WKAttachment *)_attachmentForIdentifier:(NSString *)identifier WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); > >+- (void)_simulateDeviceOrientationChangeWithAlpha:(double)alpha beta:(double)beta gamma:(double)gamma WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); >+ > + (BOOL)_handlesSafeBrowsing WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); > + (NSURL *)_confirmMalwareSentinel WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); > + (NSURL *)_visitUnsafeWebsiteSentinel WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); >diff --git a/Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePolicies.h b/Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePolicies.h >index 621a1564bf648f1ae265038a9553bbb92df393d6..6a2d32f25cec49fe24b3a0d26baf7835480497b3 100644 >--- a/Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePolicies.h >+++ b/Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePolicies.h >@@ -59,6 +59,7 @@ WK_CLASS_AVAILABLE(macosx(10.12.3), ios(10.3)) > @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 *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)); > > @end > >diff --git a/Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePolicies.mm b/Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePolicies.mm >index 7f3c8225449a78e9e15482846874f2464016c805..46286cdbf9b2656ed5420d1bdff270bf96f715b3 100644 >--- a/Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePolicies.mm >+++ b/Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePolicies.mm >@@ -59,6 +59,16 @@ - (BOOL)contentBlockersEnabled > return _websitePolicies->contentBlockersEnabled(); > } > >+- (void)setDeviceOrientationEventEnabled:(BOOL)deviceOrientationEventEnabled >+{ >+ _websitePolicies->setDeviceOrientationEventEnabled(deviceOrientationEventEnabled); >+} >+ >+- (BOOL)deviceOrientationEventEnabled >+{ >+ return _websitePolicies->deviceOrientationEventEnabled(); >+} >+ > - (void)setAllowedAutoplayQuirks:(_WKWebsiteAutoplayQuirk)allowedQuirks > { > OptionSet<WebKit::WebsiteAutoplayQuirk> quirks; >diff --git a/Source/WebKit/UIProcess/WebPageProxy.cpp b/Source/WebKit/UIProcess/WebPageProxy.cpp >index da7a94a33d81935ca14320734688cc98973a5482..6f3f55c498b4f6dd86cbfeea3703b7e07ceeedf6 100644 >--- a/Source/WebKit/UIProcess/WebPageProxy.cpp >+++ b/Source/WebKit/UIProcess/WebPageProxy.cpp >@@ -8480,6 +8480,11 @@ void WebPageProxy::willAcquireUniversalFileReadSandboxExtension() > process().willAcquireUniversalFileReadSandboxExtension(); > } > >+void WebPageProxy::simulateDeviceOrientationChange(double alpha, double beta, double gamma) >+{ >+ m_process->send(Messages::WebPage::SimulateDeviceOrientationChange(alpha, beta, gamma), m_pageID); >+} >+ > #if ENABLE(DATA_DETECTION) > > void WebPageProxy::detectDataInAllFrames(WebCore::DataDetectorTypes types, CompletionHandler<void(const DataDetectionResult&)>&& completionHandler) >diff --git a/Source/WebKit/UIProcess/WebPageProxy.h b/Source/WebKit/UIProcess/WebPageProxy.h >index 18bf8101a0edd2b4a0fe98760def4388b3403018..c1fd15afba447ca37e1ad7fc77b5468ef698ab75 100644 >--- a/Source/WebKit/UIProcess/WebPageProxy.h >+++ b/Source/WebKit/UIProcess/WebPageProxy.h >@@ -487,6 +487,8 @@ public: > void loadWebArchiveData(API::Data*, API::Object* userData = nullptr); > void navigateToPDFLinkWithSimulatedClick(const String& url, WebCore::IntPoint documentPoint, WebCore::IntPoint screenPoint); > >+ void simulateDeviceOrientationChange(double alpha, double beta, double gamma); >+ > void stopLoading(); > RefPtr<API::Navigation> reload(OptionSet<WebCore::ReloadOption>); > >diff --git a/Source/WebKit/WebProcess/WebPage/WebPage.cpp b/Source/WebKit/WebProcess/WebPage/WebPage.cpp >index a97901d3e207dd4d95e92c19c8d95c9625e02759..dba444728a9cfc3413ab1d846837e41421b836b7 100644 >--- a/Source/WebKit/WebProcess/WebPage/WebPage.cpp >+++ b/Source/WebKit/WebProcess/WebPage/WebPage.cpp >@@ -6385,6 +6385,17 @@ void WebPage::didCompleteShareSheet(bool wasGranted, ShareSheetCallbackID callba > callback(wasGranted); > } > >+void WebPage::simulateDeviceOrientationChange(double alpha, double beta, double gamma) >+{ >+#if ENABLE(DEVICE_ORIENTATION) && PLATFORM(IOS_FAMILY) >+ auto* frame = mainFrame(); >+ if (!frame || !frame->document()) >+ return; >+ >+ frame->document()->simulateDeviceOrientationChange(alpha, beta, gamma); >+#endif >+} >+ > #if ENABLE(ATTACHMENT_ELEMENT) > > void WebPage::insertAttachment(const String& identifier, Optional<uint64_t>&& fileSize, const String& fileName, const String& contentType, CallbackID callbackID) >diff --git a/Source/WebKit/WebProcess/WebPage/WebPage.h b/Source/WebKit/WebProcess/WebPage/WebPage.h >index 0b42a617ccc1098a575eb47cc641f60355e68db6..e3d15c3587dae28ac28558ad59c5723652625402 100644 >--- a/Source/WebKit/WebProcess/WebPage/WebPage.h >+++ b/Source/WebKit/WebProcess/WebPage/WebPage.h >@@ -1459,6 +1459,8 @@ private: > void didReceivePasswordForQuickLookDocument(const String&); > #endif > >+ void simulateDeviceOrientationChange(double alpha, double beta, double gamma); >+ > void frameBecameRemote(uint64_t frameID, WebCore::GlobalFrameIdentifier&& remoteFrameIdentifier, WebCore::GlobalWindowIdentifier&& remoteWindowIdentifier); > > void registerURLSchemeHandler(uint64_t identifier, const String& scheme); >diff --git a/Source/WebKit/WebProcess/WebPage/WebPage.messages.in b/Source/WebKit/WebProcess/WebPage/WebPage.messages.in >index e2654d943cf4c4f6b5e497eb792fb8d5d65cbbf4..34be71c9562c0703d8478b088194337919a95e53 100644 >--- a/Source/WebKit/WebProcess/WebPage/WebPage.messages.in >+++ b/Source/WebKit/WebProcess/WebPage/WebPage.messages.in >@@ -543,4 +543,5 @@ messages -> WebPage LegacyReceiver { > SetDefersLoading(bool defersLoading) > > UpdateCurrentModifierState(OptionSet<WebCore::PlatformEvent::Modifier> modifiers) >+ SimulateDeviceOrientationChange(double alpha, double beta, double gamma) > } >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 3ea765f6438546d0a15a61707c4be6cec6ee635f..5b520eafa603a32e9a8ee8ea6a2878a83c320d8f 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,20 @@ >+2019-01-04 Chris Dumez <cdumez@apple.com> >+ >+ Add support for toggling device orientation API support per site >+ https://bugs.webkit.org/show_bug.cgi?id=193143 >+ <rdar://problem/46605724> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add API test coverage. >+ >+ * TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm: >+ (-[DataMappingSchemeHandler setTaskHandler:]): >+ (-[DataMappingSchemeHandler webView:startURLSchemeTask:]): >+ (-[WebsitePoliciesDeviceOrientationDelegate initWithDeviceOrientationEventEnabled:]): >+ (-[WebsitePoliciesDeviceOrientationDelegate _webView:decidePolicyForNavigationAction:userInfo:decisionHandler:]): >+ (-[WebsitePoliciesDeviceOrientationDelegate webView:didFinishNavigation:]): >+ > 2019-01-03 Michael Catanzaro <mcatanzaro@igalia.com> > > UserMedia test should use WKPageNavigationClient >diff --git a/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm b/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm >index 708b072805e7ce360eff75a5df7e653d83ce70d9..9d23d5bf8ff1ea6f68a26f122ddeb680ec29e97a 100644 >--- a/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm >+++ b/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm >@@ -38,6 +38,7 @@ > #import <WebKit/_WKUserContentExtensionStorePrivate.h> > #import <WebKit/_WKWebsiteDataStoreConfiguration.h> > #import <WebKit/_WKWebsitePolicies.h> >+#import <wtf/Function.h> > #import <wtf/HashMap.h> > #import <wtf/MainThread.h> > #import <wtf/RetainPtr.h> >@@ -866,8 +867,10 @@ static unsigned loadCount; > > @interface DataMappingSchemeHandler : NSObject <WKURLSchemeHandler> { > HashMap<String, RetainPtr<NSData *>> _dataMappings; >+ Function<void(id <WKURLSchemeTask>)> _taskHandler; > } > - (void)addMappingFromURLString:(NSString *)urlString toData:(const char*)data; >+- (void)setTaskHandler:(Function<void(id <WKURLSchemeTask>)>&&)handler; > @end > > @implementation DataMappingSchemeHandler >@@ -877,12 +880,18 @@ - (void)addMappingFromURLString:(NSString *)urlString toData:(const char*)data > _dataMappings.set(urlString, [NSData dataWithBytesNoCopy:(void*)data length:strlen(data) freeWhenDone:NO]); > } > >+- (void)setTaskHandler:(Function<void(id <WKURLSchemeTask>)>&&)handler >+{ >+ _taskHandler = WTFMove(handler); >+} >+ > - (void)webView:(WKWebView *)webView startURLSchemeTask:(id <WKURLSchemeTask>)task > { > NSURL *finalURL = task.request.URL; > > ++loadCount; >- EXPECT_STREQ("Foo Custom UserAgent", [[task.request valueForHTTPHeaderField:@"User-Agent"] UTF8String]); >+ if (_taskHandler) >+ _taskHandler(task); > > auto response = adoptNS([[NSURLResponse alloc] initWithURL:finalURL MIMEType:@"text/html" expectedContentLength:1 textEncodingName:nil]); > [task didReceiveResponse:response.get()]; >@@ -955,6 +964,9 @@ TEST(WebKit, WebsitePoliciesCustomUserAgent) > auto schemeHandler = adoptNS([[DataMappingSchemeHandler alloc] init]); > [schemeHandler addMappingFromURLString:@"test://www.webkit.org/main.html" toData:customUserAgentMainFrameTestBytes]; > [schemeHandler addMappingFromURLString:@"test://www.apple.com/subframe.html" toData:customUserAgentSubFrameTestBytes]; >+ [schemeHandler setTaskHandler:[](id <WKURLSchemeTask> task) { >+ EXPECT_STREQ("Foo Custom UserAgent", [[task.request valueForHTTPHeaderField:@"User-Agent"] UTF8String]); >+ }]; > [configuration setURLSchemeHandler:schemeHandler.get() forURLScheme:@"test"]; > > auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]); >@@ -1023,6 +1035,90 @@ TEST(WebKit, WebsitePoliciesCustomNavigatorPlatform) > EXPECT_STREQ("Test Custom Platform", [[webView stringByEvaluatingJavaScript:@"navigator.platform"] UTF8String]); > } > >+#if PLATFORM(IOS_FAMILY) >+ >+static const char* deviceOrientationEventTestBytes = R"TESTRESOURCE( >+<script> >+addEventListener("deviceorientation", (event) => { >+ webkit.messageHandlers.testHandler.postMessage("received-device-orientation-event"); >+}); >+</script> >+)TESTRESOURCE"; >+ >+@interface WebsitePoliciesDeviceOrientationDelegate : NSObject <WKNavigationDelegate> { >+ BOOL _deviceOrientationEventEnabled; >+} >+- (instancetype)initWithDeviceOrientationEventEnabled:(BOOL)enabled; >+@end >+ >+@implementation WebsitePoliciesDeviceOrientationDelegate >+ >+- (instancetype)initWithDeviceOrientationEventEnabled:(BOOL)enabled >+{ >+ self = [super init]; >+ _deviceOrientationEventEnabled = enabled; >+ return self; >+} >+ >+- (void)_webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction userInfo:(id <NSSecureCoding>)userInfo decisionHandler:(void (^)(WKNavigationActionPolicy, _WKWebsitePolicies *))decisionHandler >+{ >+ _WKWebsitePolicies *websitePolicies = [[[_WKWebsitePolicies alloc] init] autorelease]; >+ [websitePolicies setDeviceOrientationEventEnabled:_deviceOrientationEventEnabled]; >+ >+ decisionHandler(WKNavigationActionPolicyAllow, websitePolicies); >+} >+ >+- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation >+{ >+ finishedNavigation = true; >+} >+ >+@end >+ >+static void runWebsitePoliciesDeviceOrientationEventTest(bool websitePolicyValue) >+{ >+ auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]); >+ >+ auto schemeHandler = adoptNS([[DataMappingSchemeHandler alloc] init]); >+ [schemeHandler addMappingFromURLString:@"test://localhost/main.html" toData:deviceOrientationEventTestBytes]; >+ [configuration setURLSchemeHandler:schemeHandler.get() forURLScheme:@"test"]; >+ >+ auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]); >+ >+ auto delegate = adoptNS([[WebsitePoliciesDeviceOrientationDelegate alloc] initWithDeviceOrientationEventEnabled:websitePolicyValue]); >+ [webView setNavigationDelegate:delegate.get()]; >+ >+ NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"test://localhost/main.html"]]; >+ [webView loadRequest:request]; >+ TestWebKitAPI::Util::run(&finishedNavigation); >+ finishedNavigation = false; >+ >+ __block bool didReceiveMessage = false; >+ [webView performAfterReceivingMessage:@"received-device-orientation-event" action:^{ >+ didReceiveMessage = true; >+ }]; >+ >+ [webView _simulateDeviceOrientationChangeWithAlpha:1.0 beta:2.0 gamma:3.0]; >+ >+ if (websitePolicyValue) >+ TestWebKitAPI::Util::run(&didReceiveMessage); >+ else { >+ TestWebKitAPI::Util::sleep(0.1); >+ EXPECT_FALSE(didReceiveMessage); >+ } >+} >+ >+TEST(WebKit, WebsitePoliciesDeviceOrientationEventEnabled) >+{ >+ runWebsitePoliciesDeviceOrientationEventTest(true); >+} >+ >+TEST(WebKit, WebsitePoliciesDeviceOrientationEventDisabled) >+{ >+ runWebsitePoliciesDeviceOrientationEventTest(false); >+} >+ >+#endif // PLATFORM(IOS_FAMILY) > > @interface PopUpPoliciesDelegate : NSObject <WKNavigationDelegate, WKUIDelegatePrivate> > @property (nonatomic, copy) _WKWebsitePopUpPolicy(^popUpPolicyForURL)(NSURL *);
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 193143
: 358321