Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 48c02ec687e49dda437bfdc3d32d3a83112631b2
https://github.com/WebKit/WebKit/commit/48c02ec687e49dda437bfdc3d32d3a83112631b2
Author: Rupin Mittal <[email protected]>
Date: 2025-12-06 (Sat, 06 Dec 2025)
Changed paths:
M Source/WebCore/dom/Document.cpp
M Source/WebCore/dom/Document.h
M Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
M Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h
M Source/WebKit/UIProcess/WebPageProxy.cpp
M Source/WebKit/UIProcess/WebPageProxy.h
M Source/WebKit/UIProcess/ios/WebDeviceOrientationUpdateProviderProxy.mm
M Source/WebKit/WebProcess/WebPage/WebPage.cpp
M Source/WebKit/WebProcess/WebPage/WebPage.h
M Source/WebKit/WebProcess/WebPage/WebPage.messages.in
M Tools/TestWebKitAPI/Tests/WebKitCocoa/SiteIsolation.mm
Log Message:
-----------
[Site Isolation] Cross-site iframes don't receive DeviceMotionEvents
https://bugs.webkit.org/show_bug.cgi?id=303670
rdar://165950593
Reviewed by Brady Eidson.
With site isolation on, cross-site iframes don't receive DeviceMotionEvents.
https://commits.webkit.org/304018@main already fixed one issue, which was that
the WebKit was not listening to events from CoreMotion.
So the issue now is just that when the event from CoreMotion is received, it
is sent to only the main frame's Web Process. To fix this, we ensure that
WebDeviceOrientationUpdateProviderProxy::motionChanged() sends the event to
all Web Processes (one of which is the Web Process corresponding to the
cross-site iframe). We made this exact same change for DeviceOrientationEvents
in the commit linked above.
In order to test this, we introduce a new API test and a function
_simulateDeviceMotionChangeWithXAcceleration which simulates the device motion
changing (identical to the already existing
_simulateDeviceOrientationChangeWithAlpha
which simulates the device orientation changing).
* Source/WebCore/dom/Document.cpp:
(WebCore::Document::simulateDeviceMotionChange):
(WebCore::Document::simulateDeviceOrientationChange):
* Source/WebCore/dom/Document.h:
* Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView
_simulateDeviceMotionChangeWithXAcceleration:yAcceleration:zAcceleration:xAccelerationIncludingGravity:yAccelerationIncludingGravity:zAccelerationIncludingGravity:xRotationRate:yRotationRate:zRotationRate:]):
This is used to simulate the device motion changing so the API test can test
the DeviceMotionEvent. It's identical to the already existing
_simulateDeviceOrientationChangeWithAlpha which is used to test
DeviceOrientationEvent.
* Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h:
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::simulateDeviceMotionChange):
* Source/WebKit/UIProcess/WebPageProxy.h:
* Source/WebKit/UIProcess/ios/WebDeviceOrientationUpdateProviderProxy.mm:
(WebKit::WebDeviceOrientationUpdateProviderProxy::motionChanged):
Notify each Web Process of the device motion change, not just the main frame's
Web Process.
* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::simulateDeviceMotionChange):
* Source/WebKit/WebProcess/WebPage/WebPage.h:
* Source/WebKit/WebProcess/WebPage/WebPage.messages.in:
* Tools/TestWebKitAPI/Tests/WebKitCocoa/SiteIsolation.mm:
(TestWebKitAPI::(SiteIsolation, CrossSiteIFrameCanReceiveDeviceMotionEvents)):
New API test.
Canonical link: https://commits.webkit.org/304059@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications