<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[242664] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/242664">242664</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2019-03-08 16:30:45 -0800 (Fri, 08 Mar 2019)</dd>
</dl>

<h3>Log Message</h3>
<pre>Add support for Device Orientation / Motion permission API
https://bugs.webkit.org/show_bug.cgi?id=195329
<rdar://problem/47645367>

Reviewed by Geoffrey Garen.

Source/WebCore:

Add support for Device Orientation / Motion permission API:
- https://github.com/w3c/deviceorientation/issues/57

Pages can add event listeners for 'deviceorientation' / 'devicemotion' events but
such events will not be fired until the page's JavaScript calls
DeviceOrientationEvent.requestPermission() / DeviceMotionEvent.requestPermission()
and the user grants the request.

The feature is currently behind an experimental feature flag, off by default.

Tests: fast/device-orientation/device-motion-request-permission-denied.html
       fast/device-orientation/device-motion-request-permission-granted.html
       fast/device-orientation/device-motion-request-permission-user-gesture.html
       fast/device-orientation/device-orientation-request-permission-denied.html
       fast/device-orientation/device-orientation-request-permission-granted.html
       fast/device-orientation/device-orientation-request-permission-user-gesture.html

* CMakeLists.txt:
* DerivedSources-input.xcfilelist:
* DerivedSources-output.xcfilelist:
* DerivedSources.make:
* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* dom/DeviceMotionEvent.h:
* dom/DeviceMotionEvent.idl:
* dom/DeviceOrientationAndMotionAccessController.cpp: Added.
(WebCore::DeviceOrientationAndMotionAccessController::DeviceOrientationAndMotionAccessController):
(WebCore::DeviceOrientationAndMotionAccessController::shouldAllowAccess):
(WebCore::DeviceOrientationAndMotionAccessController::setAccessState):
* dom/DeviceOrientationAndMotionAccessController.h: Added.
(WebCore::DeviceOrientationAndMotionAccessController::accessState const):
* dom/DeviceOrientationEvent.h:
* dom/DeviceOrientationEvent.idl:
* dom/DeviceOrientationOrMotionEvent.cpp: Added.
(WebCore::DeviceOrientationOrMotionEvent::requestPermission):
* dom/DeviceOrientationOrMotionEvent.h: Added.
* dom/DeviceOrientationOrMotionEvent.idl: Added.
* dom/DeviceOrientationOrMotionPermissionState.h: Added.
* dom/DeviceOrientationOrMotionPermissionState.idl: Added.
* dom/Document.cpp:
(WebCore::Document::deviceOrientationAndMotionAccessController):
* dom/Document.h:
* dom/Event.cpp:
* dom/MessagePort.cpp:
* dom/Microtasks.cpp:
* page/ChromeClient.h:
* page/DOMWindow.cpp:
(WebCore::DOMWindow::addEventListener):
(WebCore::DOMWindow::deviceOrientationController const):
(WebCore::DOMWindow::deviceMotionController const):
(WebCore::DOMWindow::isAllowedToUseDeviceMotionOrientation const):
(WebCore::DOMWindow::isAllowedToAddDeviceMotionOrientationListener const):
(WebCore::DOMWindow::startListeningForDeviceOrientationIfNecessary):
(WebCore::DOMWindow::stopListeningForDeviceOrientationIfNecessary):
(WebCore::DOMWindow::startListeningForDeviceMotionIfNecessary):
(WebCore::DOMWindow::stopListeningForDeviceMotionIfNecessary):
(WebCore::DOMWindow::removeEventListener):
(WebCore::DOMWindow::removeAllEventListeners):
* page/DOMWindow.h:
* page/DeviceController.cpp:
(WebCore::DeviceController::hasDeviceEventListener const):
* page/DeviceController.h:
* page/Settings.yaml:

Source/WebKit:

Add support for Device Orientation / Motion permission API:
- https://github.com/w3c/deviceorientation/issues/57

This adds new SPI to WKUIDelegatePrivate, until we can make this API.

* Shared/WebPreferences.yaml:
* UIProcess/API/APIUIClient.h:
(API::UIClient::shouldAllowDeviceOrientationAndMotionAccess):
* UIProcess/API/C/WKPage.cpp:
(WKPageSetPageUIClient):
* UIProcess/API/C/WKPageUIClient.h:
* UIProcess/API/Cocoa/WKUIDelegate.h:
* UIProcess/API/Cocoa/WKUIDelegatePrivate.h:
* UIProcess/Cocoa/UIDelegate.h:
* UIProcess/Cocoa/UIDelegate.mm:
(WebKit::UIDelegate::setDelegate):
(WebKit::UIDelegate::UIClient::shouldAllowDeviceOrientationAndMotionAccess):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::requestDeviceOrientationAndMotionAccess):
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::shouldAllowDeviceOrientationAndMotionAccess):
* WebProcess/WebCoreSupport/WebChromeClient.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::nextDeviceOrientationAndMotionPermissionCallbackID):
(WebKit::WebPage::shouldAllowDeviceOrientationAndMotionAccess):
(WebKit::WebPage::didReceiveDeviceOrientationAndMotionAccessDecision):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:

Tools:

Add test infrastructure to help test the Device Orientation / Motion permission API.

* WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::setShouldAllowDeviceOrientationAndMotionAccess):
* WebKitTestRunner/InjectedBundle/TestRunner.h:
* WebKitTestRunner/TestController.cpp:
(WTR::shouldAllowDeviceOrientationAndMotionAccess):
(WTR::TestController::createWebViewWithOptions):
(WTR::TestController::resetStateToConsistentValues):
(WTR::TestController::handleDeviceOrientationAndMotionAccessRequest):
* WebKitTestRunner/TestController.h:
(WTR::TestController::setShouldAllowDeviceOrientationAndMotionAccess):
* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::didReceiveMessageFromInjectedBundle):

LayoutTests:

Add layout test coverage.

* TestExpectations:
* fast/device-orientation/device-motion-request-permission-denied-expected.txt: Added.
* fast/device-orientation/device-motion-request-permission-denied.html: Added.
* fast/device-orientation/device-motion-request-permission-granted-expected.txt: Added.
* fast/device-orientation/device-motion-request-permission-granted.html: Added.
* fast/device-orientation/device-motion-request-permission-user-gesture-expected.txt: Added.
* fast/device-orientation/device-motion-request-permission-user-gesture.html: Added.
* fast/device-orientation/device-orientation-request-permission-denied-expected.txt: Added.
* fast/device-orientation/device-orientation-request-permission-denied.html: Added.
* fast/device-orientation/device-orientation-request-permission-granted-expected.txt: Added.
* fast/device-orientation/device-orientation-request-permission-granted.html: Added.
* fast/device-orientation/device-orientation-request-permission-user-gesture-expected.txt: Added.
* fast/device-orientation/device-orientation-request-permission-user-gesture.html: Added.
* http/tests/events/device-orientation-motion-non-secure-context.html:
* http/tests/events/device-orientation-motion-secure-context-expected.txt:
* http/tests/events/device-orientation-motion-secure-context.html:
* platform/ios-wk2/TestExpectations:
* platform/ios/http/tests/events/device-orientation-motion-non-secure-context-expected.txt:
* platform/ios/http/tests/events/device-orientation-motion-secure-context-expected.txt:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsTestExpectations">trunk/LayoutTests/TestExpectations</a></li>
<li><a href="#trunkLayoutTestshttptestseventsdeviceorientationmotionnonsecurecontexthtml">trunk/LayoutTests/http/tests/events/device-orientation-motion-non-secure-context.html</a></li>
<li><a href="#trunkLayoutTestshttptestseventsdeviceorientationmotionsecurecontextexpectedtxt">trunk/LayoutTests/http/tests/events/device-orientation-motion-secure-context-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestseventsdeviceorientationmotionsecurecontexthtml">trunk/LayoutTests/http/tests/events/device-orientation-motion-secure-context.html</a></li>
<li><a href="#trunkLayoutTestsplatformioshttptestseventsdeviceorientationmotionnonsecurecontextexpectedtxt">trunk/LayoutTests/platform/ios/http/tests/events/device-orientation-motion-non-secure-context-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformioshttptestseventsdeviceorientationmotionsecurecontextexpectedtxt">trunk/LayoutTests/platform/ios/http/tests/events/device-orientation-motion-secure-context-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformioswk2TestExpectations">trunk/LayoutTests/platform/ios-wk2/TestExpectations</a></li>
<li><a href="#trunkSourceWebCoreCMakeListstxt">trunk/Source/WebCore/CMakeLists.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreDerivedSourcesinputxcfilelist">trunk/Source/WebCore/DerivedSources-input.xcfilelist</a></li>
<li><a href="#trunkSourceWebCoreDerivedSourcesoutputxcfilelist">trunk/Source/WebCore/DerivedSources-output.xcfilelist</a></li>
<li><a href="#trunkSourceWebCoreDerivedSourcesmake">trunk/Source/WebCore/DerivedSources.make</a></li>
<li><a href="#trunkSourceWebCoreSourcestxt">trunk/Source/WebCore/Sources.txt</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCoredomDeviceMotionEventh">trunk/Source/WebCore/dom/DeviceMotionEvent.h</a></li>
<li><a href="#trunkSourceWebCoredomDeviceMotionEventidl">trunk/Source/WebCore/dom/DeviceMotionEvent.idl</a></li>
<li><a href="#trunkSourceWebCoredomDeviceOrientationEventh">trunk/Source/WebCore/dom/DeviceOrientationEvent.h</a></li>
<li><a href="#trunkSourceWebCoredomDeviceOrientationEventidl">trunk/Source/WebCore/dom/DeviceOrientationEvent.idl</a></li>
<li><a href="#trunkSourceWebCoredomDocumentcpp">trunk/Source/WebCore/dom/Document.cpp</a></li>
<li><a href="#trunkSourceWebCoredomDocumenth">trunk/Source/WebCore/dom/Document.h</a></li>
<li><a href="#trunkSourceWebCoredomEventcpp">trunk/Source/WebCore/dom/Event.cpp</a></li>
<li><a href="#trunkSourceWebCoredomMessagePortcpp">trunk/Source/WebCore/dom/MessagePort.cpp</a></li>
<li><a href="#trunkSourceWebCoredomMicrotaskscpp">trunk/Source/WebCore/dom/Microtasks.cpp</a></li>
<li><a href="#trunkSourceWebCorepageChromeClienth">trunk/Source/WebCore/page/ChromeClient.h</a></li>
<li><a href="#trunkSourceWebCorepageDOMWindowcpp">trunk/Source/WebCore/page/DOMWindow.cpp</a></li>
<li><a href="#trunkSourceWebCorepageDOMWindowh">trunk/Source/WebCore/page/DOMWindow.h</a></li>
<li><a href="#trunkSourceWebCorepageDeviceControllercpp">trunk/Source/WebCore/page/DeviceController.cpp</a></li>
<li><a href="#trunkSourceWebCorepageDeviceControllerh">trunk/Source/WebCore/page/DeviceController.h</a></li>
<li><a href="#trunkSourceWebCorepageSettingsyaml">trunk/Source/WebCore/page/Settings.yaml</a></li>
<li><a href="#trunkSourceWebKitChangeLog">trunk/Source/WebKit/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitSharedWebPreferencesyaml">trunk/Source/WebKit/Shared/WebPreferences.yaml</a></li>
<li><a href="#trunkSourceWebKitSharedWebPreferencesDefaultValuescpp">trunk/Source/WebKit/Shared/WebPreferencesDefaultValues.cpp</a></li>
<li><a href="#trunkSourceWebKitSharedWebPreferencesDefaultValuesh">trunk/Source/WebKit/Shared/WebPreferencesDefaultValues.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPIAPIUIClienth">trunk/Source/WebKit/UIProcess/API/APIUIClient.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPICWKPagecpp">trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPICWKPageUIClienth">trunk/Source/WebKit/UIProcess/API/C/WKPageUIClient.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPICocoaWKUIDelegateh">trunk/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegate.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPICocoaWKUIDelegatePrivateh">trunk/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessCocoaUIDelegateh">trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessCocoaUIDelegatemm">trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm</a></li>
<li><a href="#trunkSourceWebKitUIProcessCocoaVersionChecksh">trunk/Source/WebKit/UIProcess/Cocoa/VersionChecks.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessWebPageProxycpp">trunk/Source/WebKit/UIProcess/WebPageProxy.cpp</a></li>
<li><a href="#trunkSourceWebKitUIProcessWebPageProxyh">trunk/Source/WebKit/UIProcess/WebPageProxy.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessWebPageProxymessagesin">trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebCoreSupportWebChromeClientcpp">trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebCoreSupportWebChromeClienth">trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebPageWebPagecpp">trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebPageWebPageh">trunk/Source/WebKit/WebProcess/WebPage/WebPage.h</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebPageWebPagemessagesin">trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsWebKitTestRunnerInjectedBundleBindingsTestRunneridl">trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl</a></li>
<li><a href="#trunkToolsWebKitTestRunnerInjectedBundleTestRunnercpp">trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp</a></li>
<li><a href="#trunkToolsWebKitTestRunnerInjectedBundleTestRunnerh">trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h</a></li>
<li><a href="#trunkToolsWebKitTestRunnerTestControllercpp">trunk/Tools/WebKitTestRunner/TestController.cpp</a></li>
<li><a href="#trunkToolsWebKitTestRunnerTestControllerh">trunk/Tools/WebKitTestRunner/TestController.h</a></li>
<li><a href="#trunkToolsWebKitTestRunnerTestInvocationcpp">trunk/Tools/WebKitTestRunner/TestInvocation.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li>trunk/LayoutTests/fast/device-orientation/</li>
<li><a href="#trunkLayoutTestsfastdeviceorientationdevicemotionrequestpermissiondeniedexpectedtxt">trunk/LayoutTests/fast/device-orientation/device-motion-request-permission-denied-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastdeviceorientationdevicemotionrequestpermissiondeniedhtml">trunk/LayoutTests/fast/device-orientation/device-motion-request-permission-denied.html</a></li>
<li><a href="#trunkLayoutTestsfastdeviceorientationdevicemotionrequestpermissiongrantedexpectedtxt">trunk/LayoutTests/fast/device-orientation/device-motion-request-permission-granted-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastdeviceorientationdevicemotionrequestpermissiongrantedhtml">trunk/LayoutTests/fast/device-orientation/device-motion-request-permission-granted.html</a></li>
<li><a href="#trunkLayoutTestsfastdeviceorientationdevicemotionrequestpermissionusergestureexpectedtxt">trunk/LayoutTests/fast/device-orientation/device-motion-request-permission-user-gesture-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastdeviceorientationdevicemotionrequestpermissionusergesturehtml">trunk/LayoutTests/fast/device-orientation/device-motion-request-permission-user-gesture.html</a></li>
<li><a href="#trunkLayoutTestsfastdeviceorientationdeviceorientationrequestpermissiondeniedexpectedtxt">trunk/LayoutTests/fast/device-orientation/device-orientation-request-permission-denied-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastdeviceorientationdeviceorientationrequestpermissiondeniedhtml">trunk/LayoutTests/fast/device-orientation/device-orientation-request-permission-denied.html</a></li>
<li><a href="#trunkLayoutTestsfastdeviceorientationdeviceorientationrequestpermissiongrantedexpectedtxt">trunk/LayoutTests/fast/device-orientation/device-orientation-request-permission-granted-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastdeviceorientationdeviceorientationrequestpermissiongrantedhtml">trunk/LayoutTests/fast/device-orientation/device-orientation-request-permission-granted.html</a></li>
<li><a href="#trunkLayoutTestsfastdeviceorientationdeviceorientationrequestpermissionusergestureexpectedtxt">trunk/LayoutTests/fast/device-orientation/device-orientation-request-permission-user-gesture-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastdeviceorientationdeviceorientationrequestpermissionusergesturehtml">trunk/LayoutTests/fast/device-orientation/device-orientation-request-permission-user-gesture.html</a></li>
<li><a href="#trunkSourceWebCoredomDeviceOrientationAndMotionAccessControllercpp">trunk/Source/WebCore/dom/DeviceOrientationAndMotionAccessController.cpp</a></li>
<li><a href="#trunkSourceWebCoredomDeviceOrientationAndMotionAccessControllerh">trunk/Source/WebCore/dom/DeviceOrientationAndMotionAccessController.h</a></li>
<li><a href="#trunkSourceWebCoredomDeviceOrientationOrMotionEventcpp">trunk/Source/WebCore/dom/DeviceOrientationOrMotionEvent.cpp</a></li>
<li><a href="#trunkSourceWebCoredomDeviceOrientationOrMotionEventh">trunk/Source/WebCore/dom/DeviceOrientationOrMotionEvent.h</a></li>
<li><a href="#trunkSourceWebCoredomDeviceOrientationOrMotionEventidl">trunk/Source/WebCore/dom/DeviceOrientationOrMotionEvent.idl</a></li>
<li><a href="#trunkSourceWebCoredomDeviceOrientationOrMotionPermissionStateh">trunk/Source/WebCore/dom/DeviceOrientationOrMotionPermissionState.h</a></li>
<li><a href="#trunkSourceWebCoredomDeviceOrientationOrMotionPermissionStateidl">trunk/Source/WebCore/dom/DeviceOrientationOrMotionPermissionState.idl</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (242663 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog      2019-03-09 00:17:37 UTC (rev 242663)
+++ trunk/LayoutTests/ChangeLog 2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -1,3 +1,33 @@
</span><ins>+2019-03-08  Chris Dumez  <cdumez@apple.com>
+
+        Add support for Device Orientation / Motion permission API
+        https://bugs.webkit.org/show_bug.cgi?id=195329
+        <rdar://problem/47645367>
+
+        Reviewed by Geoffrey Garen.
+
+        Add layout test coverage.
+
+        * TestExpectations:
+        * fast/device-orientation/device-motion-request-permission-denied-expected.txt: Added.
+        * fast/device-orientation/device-motion-request-permission-denied.html: Added.
+        * fast/device-orientation/device-motion-request-permission-granted-expected.txt: Added.
+        * fast/device-orientation/device-motion-request-permission-granted.html: Added.
+        * fast/device-orientation/device-motion-request-permission-user-gesture-expected.txt: Added.
+        * fast/device-orientation/device-motion-request-permission-user-gesture.html: Added.
+        * fast/device-orientation/device-orientation-request-permission-denied-expected.txt: Added.
+        * fast/device-orientation/device-orientation-request-permission-denied.html: Added.
+        * fast/device-orientation/device-orientation-request-permission-granted-expected.txt: Added.
+        * fast/device-orientation/device-orientation-request-permission-granted.html: Added.
+        * fast/device-orientation/device-orientation-request-permission-user-gesture-expected.txt: Added.
+        * fast/device-orientation/device-orientation-request-permission-user-gesture.html: Added.
+        * http/tests/events/device-orientation-motion-non-secure-context.html:
+        * http/tests/events/device-orientation-motion-secure-context-expected.txt:
+        * http/tests/events/device-orientation-motion-secure-context.html:
+        * platform/ios-wk2/TestExpectations:
+        * platform/ios/http/tests/events/device-orientation-motion-non-secure-context-expected.txt:
+        * platform/ios/http/tests/events/device-orientation-motion-secure-context-expected.txt:
+
</ins><span class="cx"> 2019-03-08  Zalan Bujtas  <zalan@apple.com>
</span><span class="cx"> 
</span><span class="cx">         [ContentChangeObserver] Expand "isConsideredClickable" to descendants
</span></span></pre></div>
<a id="trunkLayoutTestsTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/TestExpectations (242663 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/TestExpectations       2019-03-09 00:17:37 UTC (rev 242663)
+++ trunk/LayoutTests/TestExpectations  2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -33,6 +33,7 @@
</span><span class="cx"> fast/forms/ios [ Skip ]
</span><span class="cx"> fast/viewport/ios [ Skip ]
</span><span class="cx"> fast/visual-viewport/ios/ [ Skip ]
</span><ins>+fast/device-orientation [ Skip ]
</ins><span class="cx"> fast/events/ios [ Skip ]
</span><span class="cx"> fast/events/watchos [ Skip ]
</span><span class="cx"> fast/events/pointer/ios [ Skip ]
</span></span></pre></div>
<a id="trunkLayoutTestsfastdeviceorientationdevicemotionrequestpermissiondeniedexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/device-orientation/device-motion-request-permission-denied-expected.txt (0 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/device-orientation/device-motion-request-permission-denied-expected.txt                           (rev 0)
+++ trunk/LayoutTests/fast/device-orientation/device-motion-request-permission-denied-expected.txt      2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -0,0 +1,14 @@
</span><ins>+CONSOLE MESSAGE: line 12: No device motion or orientation events will be fired until permission has been requested and granted.
+Received device orientation & motion access request for security origin "".
+CONSOLE MESSAGE: line 19: No device motion or orientation events will be fired because permission to use the API was denied.
+Basic testing for DeviceMotionEvent.requestPermission().
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS result is "denied"
+PASS result is "denied"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastdeviceorientationdevicemotionrequestpermissiondeniedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/device-orientation/device-motion-request-permission-denied.html (0 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/device-orientation/device-motion-request-permission-denied.html                           (rev 0)
+++ trunk/LayoutTests/fast/device-orientation/device-motion-request-permission-denied.html      2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -0,0 +1,32 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<body>
+<script src="../../resources/js-test.js"></script>
+<script>
+description("Basic testing for DeviceMotionEvent.requestPermission().");
+jsTestIsAsync = true;
+
+if (window.testRunner)
+    testRunner.setShouldAllowDeviceOrientationAndMotionAccess(false);
+
+addEventListener("devicemotion", () => {});
+
+internals.withUserGesture(() => {
+    DeviceMotionEvent.requestPermission().then((_result) => {
+        result = _result;
+        shouldBeEqualToString("result", "denied");
+
+        addEventListener("devicemotion", () => {});
+
+        internals.withUserGesture(() => {
+            DeviceMotionEvent.requestPermission().then((_result) => {
+                result = _result;
+                shouldBeEqualToString("result", "denied");
+                finishJSTest();
+            });
+        });
+    });
+});
+</script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsfastdeviceorientationdevicemotionrequestpermissiongrantedexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/device-orientation/device-motion-request-permission-granted-expected.txt (0 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/device-orientation/device-motion-request-permission-granted-expected.txt                          (rev 0)
+++ trunk/LayoutTests/fast/device-orientation/device-motion-request-permission-granted-expected.txt     2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -0,0 +1,13 @@
</span><ins>+CONSOLE MESSAGE: line 12: No device motion or orientation events will be fired until permission has been requested and granted.
+Received device orientation & motion access request for security origin "".
+Basic testing for DeviceMotionEvent.requestPermission().
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS result is "granted"
+PASS result is "granted"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastdeviceorientationdevicemotionrequestpermissiongrantedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/device-orientation/device-motion-request-permission-granted.html (0 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/device-orientation/device-motion-request-permission-granted.html                          (rev 0)
+++ trunk/LayoutTests/fast/device-orientation/device-motion-request-permission-granted.html     2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -0,0 +1,32 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<body>
+<script src="../../resources/js-test.js"></script>
+<script>
+description("Basic testing for DeviceMotionEvent.requestPermission().");
+jsTestIsAsync = true;
+
+if (window.testRunner)
+    testRunner.setShouldAllowDeviceOrientationAndMotionAccess(true);
+
+addEventListener("devicemotion", () => {});
+
+internals.withUserGesture(() => {
+    DeviceMotionEvent.requestPermission().then((_result) => {
+        result = _result;
+        shouldBeEqualToString("result", "granted");
+
+        addEventListener("devicemotion", () => {});
+
+        internals.withUserGesture(() => {
+            DeviceMotionEvent.requestPermission().then((_result) => {
+                result = _result;
+                shouldBeEqualToString("result", "granted");
+                finishJSTest();
+            });
+        });
+    });
+});
+</script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsfastdeviceorientationdevicemotionrequestpermissionusergestureexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/device-orientation/device-motion-request-permission-user-gesture-expected.txt (0 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/device-orientation/device-motion-request-permission-user-gesture-expected.txt                             (rev 0)
+++ trunk/LayoutTests/fast/device-orientation/device-motion-request-permission-user-gesture-expected.txt        2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+CONSOLE MESSAGE: line 14: NotAllowedError: Calling requestPermission() requires a user gesture
+Tests that DeviceMotionEvent.requestPermission() requires a user gesture.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS e.name is "NotAllowedError"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastdeviceorientationdevicemotionrequestpermissionusergesturehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/device-orientation/device-motion-request-permission-user-gesture.html (0 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/device-orientation/device-motion-request-permission-user-gesture.html                             (rev 0)
+++ trunk/LayoutTests/fast/device-orientation/device-motion-request-permission-user-gesture.html        2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -0,0 +1,20 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<body>
+<script src="../../resources/js-test.js"></script>
+<script>
+description("Tests that DeviceMotionEvent.requestPermission() requires a user gesture.");
+jsTestIsAsync = true;
+
+
+DeviceMotionEvent.requestPermission().then((result) => {
+    testFailed("requestPermission promise was not rejected");
+}, (_e) => {
+    e = _e;
+    console.log(e);
+    shouldBeEqualToString("e.name", "NotAllowedError");
+    finishJSTest();
+});
+</script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsfastdeviceorientationdeviceorientationrequestpermissiondeniedexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/device-orientation/device-orientation-request-permission-denied-expected.txt (0 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/device-orientation/device-orientation-request-permission-denied-expected.txt                              (rev 0)
+++ trunk/LayoutTests/fast/device-orientation/device-orientation-request-permission-denied-expected.txt 2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -0,0 +1,14 @@
</span><ins>+CONSOLE MESSAGE: line 12: No device motion or orientation events will be fired until permission has been requested and granted.
+Received device orientation & motion access request for security origin "".
+CONSOLE MESSAGE: line 19: No device motion or orientation events will be fired because permission to use the API was denied.
+Basic testing for DeviceOrientationEvent.requestPermission().
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS result is "denied"
+PASS result is "denied"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastdeviceorientationdeviceorientationrequestpermissiondeniedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/device-orientation/device-orientation-request-permission-denied.html (0 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/device-orientation/device-orientation-request-permission-denied.html                              (rev 0)
+++ trunk/LayoutTests/fast/device-orientation/device-orientation-request-permission-denied.html 2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -0,0 +1,32 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<body>
+<script src="../../resources/js-test.js"></script>
+<script>
+description("Basic testing for DeviceOrientationEvent.requestPermission().");
+jsTestIsAsync = true;
+
+if (window.testRunner)
+    testRunner.setShouldAllowDeviceOrientationAndMotionAccess(false);
+
+addEventListener("deviceorientation", () => {});
+
+internals.withUserGesture(() => {
+    DeviceOrientationEvent.requestPermission().then((_result) => {
+        result = _result;
+        shouldBeEqualToString("result", "denied");
+
+        addEventListener("deviceorientation", () => {});
+
+        internals.withUserGesture(() => {
+            DeviceOrientationEvent.requestPermission().then((_result) => {
+                result = _result;
+                shouldBeEqualToString("result", "denied");
+                finishJSTest();
+            });
+        });
+    });
+});
+</script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsfastdeviceorientationdeviceorientationrequestpermissiongrantedexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/device-orientation/device-orientation-request-permission-granted-expected.txt (0 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/device-orientation/device-orientation-request-permission-granted-expected.txt                             (rev 0)
+++ trunk/LayoutTests/fast/device-orientation/device-orientation-request-permission-granted-expected.txt        2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -0,0 +1,13 @@
</span><ins>+CONSOLE MESSAGE: line 12: No device motion or orientation events will be fired until permission has been requested and granted.
+Received device orientation & motion access request for security origin "".
+Basic testing for DeviceOrientationEvent.requestPermission().
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS result is "granted"
+PASS result is "granted"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastdeviceorientationdeviceorientationrequestpermissiongrantedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/device-orientation/device-orientation-request-permission-granted.html (0 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/device-orientation/device-orientation-request-permission-granted.html                             (rev 0)
+++ trunk/LayoutTests/fast/device-orientation/device-orientation-request-permission-granted.html        2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -0,0 +1,32 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<body>
+<script src="../../resources/js-test.js"></script>
+<script>
+description("Basic testing for DeviceOrientationEvent.requestPermission().");
+jsTestIsAsync = true;
+
+if (window.testRunner)
+    testRunner.setShouldAllowDeviceOrientationAndMotionAccess(true);
+
+addEventListener("deviceorientation", () => {});
+
+internals.withUserGesture(() => {
+    DeviceOrientationEvent.requestPermission().then((_result) => {
+        result = _result;
+        shouldBeEqualToString("result", "granted");
+
+        addEventListener("deviceorientation", () => {});
+
+        internals.withUserGesture(() => {
+            DeviceOrientationEvent.requestPermission().then((_result) => {
+                result = _result;
+                shouldBeEqualToString("result", "granted");
+                finishJSTest();
+            });
+        });
+    });
+});
+</script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsfastdeviceorientationdeviceorientationrequestpermissionusergestureexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/device-orientation/device-orientation-request-permission-user-gesture-expected.txt (0 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/device-orientation/device-orientation-request-permission-user-gesture-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/device-orientation/device-orientation-request-permission-user-gesture-expected.txt   2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+CONSOLE MESSAGE: line 14: NotAllowedError: Calling requestPermission() requires a user gesture
+Tests that DeviceOrientationEvent.requestPermission() requires a user gesture.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS e.name is "NotAllowedError"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastdeviceorientationdeviceorientationrequestpermissionusergesturehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/device-orientation/device-orientation-request-permission-user-gesture.html (0 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/device-orientation/device-orientation-request-permission-user-gesture.html                                (rev 0)
+++ trunk/LayoutTests/fast/device-orientation/device-orientation-request-permission-user-gesture.html   2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -0,0 +1,20 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<body>
+<script src="../../resources/js-test.js"></script>
+<script>
+description("Tests that DeviceOrientationEvent.requestPermission() requires a user gesture.");
+jsTestIsAsync = true;
+
+
+DeviceOrientationEvent.requestPermission().then((result) => {
+    testFailed("requestPermission promise was not rejected");
+}, (_e) => {
+    e = _e;
+    console.log(e);
+    shouldBeEqualToString("e.name", "NotAllowedError");
+    finishJSTest();
+});
+</script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestseventsdeviceorientationmotionnonsecurecontexthtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/events/device-orientation-motion-non-secure-context.html (242663 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/events/device-orientation-motion-non-secure-context.html    2019-03-09 00:17:37 UTC (rev 242663)
+++ trunk/LayoutTests/http/tests/events/device-orientation-motion-non-secure-context.html       2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -27,7 +27,7 @@
</span><span class="cx">     debug("* Registering device motion listener");
</span><span class="cx">     addEventListener("devicemotion", function() { });
</span><span class="cx">     internals.postTask(() => {
</span><del>-        shouldBeEqualToString("lastConsoleMessage", "Blocked attempt to add a device motion or orientation listener because the browsing context is not secure.");
</del><ins>+        shouldBeEqualToString("lastConsoleMessage", "Blocked attempt to add a device motion or orientation event listener, reason: Browsing context is not secure.");
</ins><span class="cx">         finishJSTest();
</span><span class="cx">     });
</span><span class="cx"> }
</span><span class="lines">@@ -44,7 +44,7 @@
</span><span class="cx">     debug("* Registering device orientation listener");
</span><span class="cx">     addEventListener("deviceorientation", function() { });
</span><span class="cx">     internals.postTask(() => {
</span><del>-        shouldBeEqualToString("lastConsoleMessage", "Blocked attempt to add a device motion or orientation listener because the browsing context is not secure.");
</del><ins>+        shouldBeEqualToString("lastConsoleMessage", "Blocked attempt to add a device motion or orientation event listener, reason: Browsing context is not secure.");
</ins><span class="cx">         runDeviceMotionTest();
</span><span class="cx">     });
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkLayoutTestshttptestseventsdeviceorientationmotionsecurecontextexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/events/device-orientation-motion-secure-context-expected.txt (242663 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/events/device-orientation-motion-secure-context-expected.txt        2019-03-09 00:17:37 UTC (rev 242663)
+++ trunk/LayoutTests/http/tests/events/device-orientation-motion-secure-context-expected.txt   2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -1,10 +1,11 @@
</span><del>-CONSOLE MESSAGE: line 37: Device Orientation API is not supported
-CONSOLE MESSAGE: line 19: Device Motion API is not supported
</del><ins>+CONSOLE MESSAGE: line 50: Device Orientation API is not supported
+CONSOLE MESSAGE: line 25: Device Motion API is not supported
</ins><span class="cx"> Tests that trying to set an event listener for deviceorientation and deviceorientation does not log an error in secure contexts.
</span><span class="cx"> 
</span><span class="cx"> On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+
</ins><span class="cx"> PASS successfullyParsed is true
</span><span class="cx"> 
</span><span class="cx"> TEST COMPLETE
</span></span></pre></div>
<a id="trunkLayoutTestshttptestseventsdeviceorientationmotionsecurecontexthtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/events/device-orientation-motion-secure-context.html (242663 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/events/device-orientation-motion-secure-context.html        2019-03-09 00:17:37 UTC (rev 242663)
+++ trunk/LayoutTests/http/tests/events/device-orientation-motion-secure-context.html   2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -6,6 +6,11 @@
</span><span class="cx"> description("Tests that trying to set an event listener for deviceorientation and deviceorientation does not log an error in secure contexts.");
</span><span class="cx"> jsTestIsAsync = true;
</span><span class="cx"> 
</span><ins>+if (window.testRunner) {
+    if (testRunner.setShouldAllowDeviceOrientationAndMotionAccess)
+        testRunner.setShouldAllowDeviceOrientationAndMotionAccess(true);
+}
+
</ins><span class="cx"> // localhost is secure by default.
</span><span class="cx"> 
</span><span class="cx"> let lastConsoleMessage = null;
</span><span class="lines">@@ -15,6 +20,7 @@
</span><span class="cx"> 
</span><span class="cx"> function runDeviceMotionTest()
</span><span class="cx"> {
</span><ins>+    debug("");
</ins><span class="cx">     if (!window.DeviceMotionEvent) {
</span><span class="cx">         console.log("Device Motion API is not supported");
</span><span class="cx">         finishJSTest();
</span><span class="lines">@@ -21,13 +27,20 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    lastConsoleMessage = null;
-    debug("");
-    debug("* Registering device motion listener");
-    addEventListener("devicemotion", function() { });
-    internals.postTask(() => {
-        shouldBeNull("lastConsoleMessage");
-        finishJSTest();
</del><ins>+    debug("* Requesting device motion access...");
+    internals.withUserGesture(() => {
+        DeviceMotionEvent.requestPermission().then((_result) => {
+            result = _result;
+            shouldBeEqualToString("result", "granted");
+
+            lastConsoleMessage = null;
+            debug("* Registering device motion listener");
+            addEventListener("devicemotion", function() { });
+            internals.postTask(() => {
+                shouldBeNull("lastConsoleMessage");
+                finishJSTest();
+            });
+        });
</ins><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -39,12 +52,20 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    lastConsoleMessage = null;
-    debug("* Registering device orientation listener");
-    addEventListener("deviceorientation", function() { });
-    internals.postTask(() => {
-        shouldBeNull("lastConsoleMessage");
-        runDeviceMotionTest();
</del><ins>+    debug("* Requesting device orientation access...");
+    internals.withUserGesture(() => {
+        DeviceOrientationEvent.requestPermission().then((_result) => {
+            result = _result;
+            shouldBeEqualToString("result", "granted");
+
+            lastConsoleMessage = null;
+            debug("* Registering device orientation listener");
+            addEventListener("deviceorientation", function() { });
+            internals.postTask(() => {
+                shouldBeNull("lastConsoleMessage");
+                runDeviceMotionTest();
+            });
+        });
</ins><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsplatformioshttptestseventsdeviceorientationmotionnonsecurecontextexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/ios/http/tests/events/device-orientation-motion-non-secure-context-expected.txt (242663 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/ios/http/tests/events/device-orientation-motion-non-secure-context-expected.txt       2019-03-09 00:17:37 UTC (rev 242663)
+++ trunk/LayoutTests/platform/ios/http/tests/events/device-orientation-motion-non-secure-context-expected.txt  2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><del>-CONSOLE MESSAGE: line 45: Blocked attempt to add a device motion or orientation listener because the browsing context is not secure.
-CONSOLE MESSAGE: line 28: Blocked attempt to add a device motion or orientation listener because the browsing context is not secure.
</del><ins>+CONSOLE MESSAGE: line 45: Blocked attempt to add a device motion or orientation event listener, reason: Browsing context is not secure.
+CONSOLE MESSAGE: line 28: Blocked attempt to add a device motion or orientation event listener, reason: Browsing context is not secure.
</ins><span class="cx"> Tests that trying to set an event listener for deviceorientation and deviceorientation logs an error in non-secure contexts.
</span><span class="cx"> 
</span><span class="cx"> On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
</span><span class="lines">@@ -6,10 +6,10 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> * Registering device orientation listener
</span><del>-PASS lastConsoleMessage is "Blocked attempt to add a device motion or orientation listener because the browsing context is not secure."
</del><ins>+PASS lastConsoleMessage is "Blocked attempt to add a device motion or orientation event listener, reason: Browsing context is not secure."
</ins><span class="cx"> 
</span><span class="cx"> * Registering device motion listener
</span><del>-PASS lastConsoleMessage is "Blocked attempt to add a device motion or orientation listener because the browsing context is not secure."
</del><ins>+PASS lastConsoleMessage is "Blocked attempt to add a device motion or orientation event listener, reason: Browsing context is not secure."
</ins><span class="cx"> PASS successfullyParsed is true
</span><span class="cx"> 
</span><span class="cx"> TEST COMPLETE
</span></span></pre></div>
<a id="trunkLayoutTestsplatformioshttptestseventsdeviceorientationmotionsecurecontextexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/ios/http/tests/events/device-orientation-motion-secure-context-expected.txt (242663 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/ios/http/tests/events/device-orientation-motion-secure-context-expected.txt   2019-03-09 00:17:37 UTC (rev 242663)
+++ trunk/LayoutTests/platform/ios/http/tests/events/device-orientation-motion-secure-context-expected.txt      2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -1,11 +1,16 @@
</span><ins>+Received device orientation & motion access request for security origin "http://127.0.0.1:8000".
</ins><span class="cx"> Tests that trying to set an event listener for deviceorientation and deviceorientation does not log an error in secure contexts.
</span><span class="cx"> 
</span><span class="cx"> On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+* Requesting device orientation access...
+PASS result is "granted"
</ins><span class="cx"> * Registering device orientation listener
</span><span class="cx"> PASS lastConsoleMessage is null
</span><span class="cx"> 
</span><ins>+* Requesting device motion access...
+PASS result is "granted"
</ins><span class="cx"> * Registering device motion listener
</span><span class="cx"> PASS lastConsoleMessage is null
</span><span class="cx"> PASS successfullyParsed is true
</span></span></pre></div>
<a id="trunkLayoutTestsplatformioswk2TestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/ios-wk2/TestExpectations (242663 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/ios-wk2/TestExpectations      2019-03-09 00:17:37 UTC (rev 242663)
+++ trunk/LayoutTests/platform/ios-wk2/TestExpectations 2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -7,6 +7,7 @@
</span><span class="cx"> #//////////////////////////////////////////////////////////////////////////////////////////
</span><span class="cx"> 
</span><span class="cx"> compositing/ios [ Pass ]
</span><ins>+fast/device-orientation [ Pass ]
</ins><span class="cx"> fast/history/ios [ Pass ]
</span><span class="cx"> fast/scrolling/ios [ Pass ]
</span><span class="cx"> fast/viewport/ios [ Pass ]
</span></span></pre></div>
<a id="trunkSourceWebCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/CMakeLists.txt (242663 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/CMakeLists.txt      2019-03-09 00:17:37 UTC (rev 242663)
+++ trunk/Source/WebCore/CMakeLists.txt 2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -671,6 +671,8 @@
</span><span class="cx">     dom/DataTransferItemList.idl
</span><span class="cx">     dom/DeviceMotionEvent.idl
</span><span class="cx">     dom/DeviceOrientationEvent.idl
</span><ins>+    dom/DeviceOrientationOrMotionEvent.idl
+    dom/DeviceOrientationOrMotionPermissionState.idl
</ins><span class="cx">     dom/Document.idl
</span><span class="cx">     dom/DocumentAndElementEventHandlers.idl
</span><span class="cx">     dom/DocumentFragment.idl
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (242663 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2019-03-09 00:17:37 UTC (rev 242663)
+++ trunk/Source/WebCore/ChangeLog      2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -1,3 +1,75 @@
</span><ins>+2019-03-08  Chris Dumez  <cdumez@apple.com>
+
+        Add support for Device Orientation / Motion permission API
+        https://bugs.webkit.org/show_bug.cgi?id=195329
+        <rdar://problem/47645367>
+
+        Reviewed by Geoffrey Garen.
+
+        Add support for Device Orientation / Motion permission API:
+        - https://github.com/w3c/deviceorientation/issues/57
+
+        Pages can add event listeners for 'deviceorientation' / 'devicemotion' events but
+        such events will not be fired until the page's JavaScript calls
+        DeviceOrientationEvent.requestPermission() / DeviceMotionEvent.requestPermission()
+        and the user grants the request.
+
+        The feature is currently behind an experimental feature flag, off by default.
+
+        Tests: fast/device-orientation/device-motion-request-permission-denied.html
+               fast/device-orientation/device-motion-request-permission-granted.html
+               fast/device-orientation/device-motion-request-permission-user-gesture.html
+               fast/device-orientation/device-orientation-request-permission-denied.html
+               fast/device-orientation/device-orientation-request-permission-granted.html
+               fast/device-orientation/device-orientation-request-permission-user-gesture.html
+
+        * CMakeLists.txt:
+        * DerivedSources-input.xcfilelist:
+        * DerivedSources-output.xcfilelist:
+        * DerivedSources.make:
+        * Sources.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * dom/DeviceMotionEvent.h:
+        * dom/DeviceMotionEvent.idl:
+        * dom/DeviceOrientationAndMotionAccessController.cpp: Added.
+        (WebCore::DeviceOrientationAndMotionAccessController::DeviceOrientationAndMotionAccessController):
+        (WebCore::DeviceOrientationAndMotionAccessController::shouldAllowAccess):
+        (WebCore::DeviceOrientationAndMotionAccessController::setAccessState):
+        * dom/DeviceOrientationAndMotionAccessController.h: Added.
+        (WebCore::DeviceOrientationAndMotionAccessController::accessState const):
+        * dom/DeviceOrientationEvent.h:
+        * dom/DeviceOrientationEvent.idl:
+        * dom/DeviceOrientationOrMotionEvent.cpp: Added.
+        (WebCore::DeviceOrientationOrMotionEvent::requestPermission):
+        * dom/DeviceOrientationOrMotionEvent.h: Added.
+        * dom/DeviceOrientationOrMotionEvent.idl: Added.
+        * dom/DeviceOrientationOrMotionPermissionState.h: Added.
+        * dom/DeviceOrientationOrMotionPermissionState.idl: Added.
+        * dom/Document.cpp:
+        (WebCore::Document::deviceOrientationAndMotionAccessController):
+        * dom/Document.h:
+        * dom/Event.cpp:
+        * dom/MessagePort.cpp:
+        * dom/Microtasks.cpp:
+        * page/ChromeClient.h:
+        * page/DOMWindow.cpp:
+        (WebCore::DOMWindow::addEventListener):
+        (WebCore::DOMWindow::deviceOrientationController const):
+        (WebCore::DOMWindow::deviceMotionController const):
+        (WebCore::DOMWindow::isAllowedToUseDeviceMotionOrientation const):
+        (WebCore::DOMWindow::isAllowedToAddDeviceMotionOrientationListener const):
+        (WebCore::DOMWindow::startListeningForDeviceOrientationIfNecessary):
+        (WebCore::DOMWindow::stopListeningForDeviceOrientationIfNecessary):
+        (WebCore::DOMWindow::startListeningForDeviceMotionIfNecessary):
+        (WebCore::DOMWindow::stopListeningForDeviceMotionIfNecessary):
+        (WebCore::DOMWindow::removeEventListener):
+        (WebCore::DOMWindow::removeAllEventListeners):
+        * page/DOMWindow.h:
+        * page/DeviceController.cpp:
+        (WebCore::DeviceController::hasDeviceEventListener const):
+        * page/DeviceController.h:
+        * page/Settings.yaml:
+
</ins><span class="cx"> 2019-03-08  Zalan Bujtas  <zalan@apple.com>
</span><span class="cx"> 
</span><span class="cx">         [ContentChangeObserver] Expand "isConsideredClickable" to descendants
</span></span></pre></div>
<a id="trunkSourceWebCoreDerivedSourcesinputxcfilelist"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/DerivedSources-input.xcfilelist (242663 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/DerivedSources-input.xcfilelist     2019-03-09 00:17:37 UTC (rev 242663)
+++ trunk/Source/WebCore/DerivedSources-input.xcfilelist        2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -564,6 +564,8 @@
</span><span class="cx"> $(PROJECT_DIR)/dom/DataTransferItemList.idl
</span><span class="cx"> $(PROJECT_DIR)/dom/DeviceMotionEvent.idl
</span><span class="cx"> $(PROJECT_DIR)/dom/DeviceOrientationEvent.idl
</span><ins>+$(PROJECT_DIR)/dom/DeviceOrientationOrMotionEvent.idl
+$(PROJECT_DIR)/dom/DeviceOrientationOrMotionPermissionState.idl
</ins><span class="cx"> $(PROJECT_DIR)/dom/Document.idl
</span><span class="cx"> $(PROJECT_DIR)/dom/DocumentAndElementEventHandlers.idl
</span><span class="cx"> $(PROJECT_DIR)/dom/DocumentFragment.idl
</span></span></pre></div>
<a id="trunkSourceWebCoreDerivedSourcesoutputxcfilelist"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/DerivedSources-output.xcfilelist (242663 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/DerivedSources-output.xcfilelist    2019-03-09 00:17:37 UTC (rev 242663)
+++ trunk/Source/WebCore/DerivedSources-output.xcfilelist       2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -459,6 +459,10 @@
</span><span class="cx"> $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSDeviceMotionEvent.h
</span><span class="cx"> $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSDeviceOrientationEvent.cpp
</span><span class="cx"> $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSDeviceOrientationEvent.h
</span><ins>+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSDeviceOrientationOrMotionEvent.cpp
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSDeviceOrientationOrMotionEvent.h
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSDeviceOrientationOrMotionPermissionState.cpp
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSDeviceOrientationOrMotionPermissionState.h
</ins><span class="cx"> $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSDocument.cpp
</span><span class="cx"> $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSDocument.h
</span><span class="cx"> $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSDocumentAndElementEventHandlers.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreDerivedSourcesmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/DerivedSources.make (242663 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/DerivedSources.make 2019-03-09 00:17:37 UTC (rev 242663)
+++ trunk/Source/WebCore/DerivedSources.make    2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -571,6 +571,8 @@
</span><span class="cx">     $(WebCore)/dom/DataTransferItemList.idl \
</span><span class="cx">     $(WebCore)/dom/DeviceMotionEvent.idl \
</span><span class="cx">     $(WebCore)/dom/DeviceOrientationEvent.idl \
</span><ins>+    $(WebCore)/dom/DeviceOrientationOrMotionEvent.idl \
+    $(WebCore)/dom/DeviceOrientationOrMotionPermissionState.idl \
</ins><span class="cx">     $(WebCore)/dom/Document.idl \
</span><span class="cx">     $(WebCore)/dom/DocumentAndElementEventHandlers.idl \
</span><span class="cx">     $(WebCore)/dom/DocumentFragment.idl \
</span></span></pre></div>
<a id="trunkSourceWebCoreSourcestxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Sources.txt (242663 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Sources.txt 2019-03-09 00:17:37 UTC (rev 242663)
+++ trunk/Source/WebCore/Sources.txt    2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -820,9 +820,11 @@
</span><span class="cx"> dom/DeviceMotionController.cpp
</span><span class="cx"> dom/DeviceMotionData.cpp
</span><span class="cx"> dom/DeviceMotionEvent.cpp
</span><ins>+dom/DeviceOrientationAndMotionAccessController.cpp
</ins><span class="cx"> dom/DeviceOrientationController.cpp
</span><span class="cx"> dom/DeviceOrientationData.cpp
</span><span class="cx"> dom/DeviceOrientationEvent.cpp
</span><ins>+dom/DeviceOrientationOrMotionEvent.cpp
</ins><span class="cx"> dom/Document.cpp
</span><span class="cx"> dom/DocumentEventQueue.cpp
</span><span class="cx"> dom/DocumentFragment.cpp
</span><span class="lines">@@ -2723,6 +2725,8 @@
</span><span class="cx"> JSDeprecatedCSSOMValueList.cpp
</span><span class="cx"> JSDeviceMotionEvent.cpp
</span><span class="cx"> JSDeviceOrientationEvent.cpp
</span><ins>+JSDeviceOrientationOrMotionPermissionState.cpp
+JSDeviceOrientationOrMotionEvent.cpp
</ins><span class="cx"> JSDocument.cpp
</span><span class="cx"> JSDocumentAndElementEventHandlers.cpp
</span><span class="cx"> JSDocumentFragment.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (242663 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj   2019-03-09 00:17:37 UTC (rev 242663)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj      2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -1254,6 +1254,8 @@
</span><span class="cx">          45FEA5D0156DDE8C00654101 /* Decimal.h in Headers */ = {isa = PBXBuildFile; fileRef = 45FEA5CE156DDE8C00654101 /* Decimal.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">          460BB6161D0A1BF000221812 /* Base64Utilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 460BB6141D0A1BEC00221812 /* Base64Utilities.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">          460CBF361D4BCD0E0092E88E /* JSDOMWindowProperties.h in Headers */ = {isa = PBXBuildFile; fileRef = 460CBF341D4BCCFE0092E88E /* JSDOMWindowProperties.h */; };
</span><ins>+               460E3075222F4EFD009A0606 /* DeviceOrientationOrMotionEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 461DA52A222F486F00D05A87 /* DeviceOrientationOrMotionEvent.h */; };
+               460E3077222F4F03009A0606 /* DeviceOrientationOrMotionPermissionState.h in Headers */ = {isa = PBXBuildFile; fileRef = 465EDD9F222F4EC300B46E16 /* DeviceOrientationOrMotionPermissionState.h */; };
</ins><span class="cx">           46218ACB1F72D64E00574FBE /* DOMHighResTimeStamp.h in Headers */ = {isa = PBXBuildFile; fileRef = 46E016AD1F72D61E00282B2C /* DOMHighResTimeStamp.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">          463521AD2081092A00C28922 /* WindowProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 463521AA2081090B00C28922 /* WindowProxy.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">          463EB6231B8789E00096ED51 /* TagCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = 463EB6211B8789CB0096ED51 /* TagCollection.h */; };
</span><span class="lines">@@ -1271,6 +1273,7 @@
</span><span class="cx">          46B95198207D634700A7D2DD /* GlobalFrameIdentifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 46B95191207D632D00A7D2DD /* GlobalFrameIdentifier.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">          46B95199207D634D00A7D2DD /* RemoteDOMWindow.h in Headers */ = {isa = PBXBuildFile; fileRef = 46B9518E207D632A00A7D2DD /* RemoteDOMWindow.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">          46B9519A207D635400A7D2DD /* RemoteFrame.h in Headers */ = {isa = PBXBuildFile; fileRef = 46B95192207D632E00A7D2DD /* RemoteFrame.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><ins>+               46B95BF52231CFD60053A504 /* DeviceOrientationAndMotionAccessController.h in Headers */ = {isa = PBXBuildFile; fileRef = 46B95BF42231CFB80053A504 /* DeviceOrientationAndMotionAccessController.h */; };
</ins><span class="cx">           46BCBBC22085008F00710638 /* JSRemoteDOMWindowBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 46BCBBC02085007F00710638 /* JSRemoteDOMWindowBase.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">          46C376622085177D00C73829 /* JSRemoteDOMWindow.h in Headers */ = {isa = PBXBuildFile; fileRef = 46C376612085176D00C73829 /* JSRemoteDOMWindow.h */; };
</span><span class="cx">          46C696CB1E7205F700597937 /* CPUMonitor.h in Headers */ = {isa = PBXBuildFile; fileRef = 46C696C91E7205E400597937 /* CPUMonitor.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="lines">@@ -7725,6 +7728,8 @@
</span><span class="cx">          460CBF331D4BCCFE0092E88E /* JSDOMWindowProperties.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMWindowProperties.cpp; sourceTree = "<group>"; };
</span><span class="cx">          460CBF341D4BCCFE0092E88E /* JSDOMWindowProperties.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDOMWindowProperties.h; sourceTree = "<group>"; };
</span><span class="cx">          460D19441FCE21DD00C3DB85 /* JSServiceWorkerGlobalScopeCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSServiceWorkerGlobalScopeCustom.cpp; sourceTree = "<group>"; };
</span><ins>+               461DA52A222F486F00D05A87 /* DeviceOrientationOrMotionEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DeviceOrientationOrMotionEvent.h; sourceTree = "<group>"; };
+               461DA52C222F486F00D05A87 /* DeviceOrientationOrMotionEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DeviceOrientationOrMotionEvent.cpp; sourceTree = "<group>"; };
</ins><span class="cx">           4634592B1AC2271000ECB71C /* PowerObserverMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PowerObserverMac.cpp; sourceTree = "<group>"; };
</span><span class="cx">          463521AA2081090B00C28922 /* WindowProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WindowProxy.h; sourceTree = "<group>"; };
</span><span class="cx">          463521AC2081090E00C28922 /* WindowProxy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WindowProxy.cpp; sourceTree = "<group>"; };
</span><span class="lines">@@ -7732,6 +7737,9 @@
</span><span class="cx">          463EB6211B8789CB0096ED51 /* TagCollection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TagCollection.h; sourceTree = "<group>"; };
</span><span class="cx">          4642404520EAF0ED00B29FD2 /* DatabaseManagerCocoa.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = DatabaseManagerCocoa.mm; sourceTree = "<group>"; };
</span><span class="cx">          465A8E781C8A24CE00E7D3E4 /* RuntimeApplicationChecksCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RuntimeApplicationChecksCocoa.mm; sourceTree = "<group>"; };
</span><ins>+               465EDD9D222F4EC300B46E16 /* DeviceOrientationOrMotionEvent.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = DeviceOrientationOrMotionEvent.idl; sourceTree = "<group>"; };
+               465EDD9F222F4EC300B46E16 /* DeviceOrientationOrMotionPermissionState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DeviceOrientationOrMotionPermissionState.h; sourceTree = "<group>"; };
+               465EDDA0222F4EC400B46E16 /* DeviceOrientationOrMotionPermissionState.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = DeviceOrientationOrMotionPermissionState.idl; sourceTree = "<group>"; };
</ins><span class="cx">           466DC6AB1EDE021D00746224 /* JSDOMRectList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMRectList.cpp; sourceTree = "<group>"; };
</span><span class="cx">          466ED8D21EDE0135005E43F6 /* JSDOMRectList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDOMRectList.h; sourceTree = "<group>"; };
</span><span class="cx">          4671E0631D67A57B00C6B497 /* CanvasPath.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CanvasPath.cpp; sourceTree = "<group>"; };
</span><span class="lines">@@ -7754,6 +7762,8 @@
</span><span class="cx">          46B95192207D632E00A7D2DD /* RemoteFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteFrame.h; sourceTree = "<group>"; };
</span><span class="cx">          46B95193207D632F00A7D2DD /* AbstractDOMWindow.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AbstractDOMWindow.cpp; sourceTree = "<group>"; };
</span><span class="cx">          46B95194207D633000A7D2DD /* AbstractFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AbstractFrame.cpp; sourceTree = "<group>"; };
</span><ins>+               46B95BF22231CFB80053A504 /* DeviceOrientationAndMotionAccessController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DeviceOrientationAndMotionAccessController.cpp; sourceTree = "<group>"; };
+               46B95BF42231CFB80053A504 /* DeviceOrientationAndMotionAccessController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DeviceOrientationAndMotionAccessController.h; sourceTree = "<group>"; };
</ins><span class="cx">           46BCBBBE2085005B00710638 /* JSRemoteDOMWindowCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSRemoteDOMWindowCustom.cpp; sourceTree = "<group>"; };
</span><span class="cx">          46BCBBC02085007F00710638 /* JSRemoteDOMWindowBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSRemoteDOMWindowBase.h; sourceTree = "<group>"; };
</span><span class="cx">          46BCBBC12085008000710638 /* JSRemoteDOMWindowBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSRemoteDOMWindowBase.cpp; sourceTree = "<group>"; };
</span><span class="lines">@@ -27498,6 +27508,8 @@
</span><span class="cx">                          31FB1A54120A5D0600DC02A0 /* DeviceMotionEvent.cpp */,
</span><span class="cx">                          31FB1A55120A5D0600DC02A0 /* DeviceMotionEvent.h */,
</span><span class="cx">                          31FB1A56120A5D0600DC02A0 /* DeviceMotionEvent.idl */,
</span><ins>+                               46B95BF22231CFB80053A504 /* DeviceOrientationAndMotionAccessController.cpp */,
+                               46B95BF42231CFB80053A504 /* DeviceOrientationAndMotionAccessController.h */,
</ins><span class="cx">                           59A8F1D711A69520001AC34A /* DeviceOrientationClient.h */,
</span><span class="cx">                          59A8F1D311A69508001AC34A /* DeviceOrientationController.cpp */,
</span><span class="cx">                          59A8F1D511A69513001AC34A /* DeviceOrientationController.h */,
</span><span class="lines">@@ -27506,6 +27518,11 @@
</span><span class="cx">                          59A85EA1119D68D900DEF1EF /* DeviceOrientationEvent.cpp */,
</span><span class="cx">                          59A85EA3119D68EC00DEF1EF /* DeviceOrientationEvent.h */,
</span><span class="cx">                          59A85EAA119D7B6E00DEF1EF /* DeviceOrientationEvent.idl */,
</span><ins>+                               461DA52C222F486F00D05A87 /* DeviceOrientationOrMotionEvent.cpp */,
+                               461DA52A222F486F00D05A87 /* DeviceOrientationOrMotionEvent.h */,
+                               465EDD9D222F4EC300B46E16 /* DeviceOrientationOrMotionEvent.idl */,
+                               465EDD9F222F4EC300B46E16 /* DeviceOrientationOrMotionPermissionState.h */,
+                               465EDDA0222F4EC400B46E16 /* DeviceOrientationOrMotionPermissionState.idl */,
</ins><span class="cx">                           A8185F3409765765005826D9 /* Document.cpp */,
</span><span class="cx">                          A8185F3809765765005826D9 /* Document.h */,
</span><span class="cx">                          6548E24809E1E04D00AF8020 /* Document.idl */,
</span><span class="lines">@@ -29030,6 +29047,7 @@
</span><span class="cx">                          31FB1A59120A5D0600DC02A0 /* DeviceMotionController.h in Headers */,
</span><span class="cx">                          31FB1A5B120A5D0600DC02A0 /* DeviceMotionData.h in Headers */,
</span><span class="cx">                          31FB1A5D120A5D0600DC02A0 /* DeviceMotionEvent.h in Headers */,
</span><ins>+                               46B95BF52231CFD60053A504 /* DeviceOrientationAndMotionAccessController.h in Headers */,
</ins><span class="cx">                           59A8F1D811A69520001AC34A /* DeviceOrientationClient.h in Headers */,
</span><span class="cx">                          3140379D124BEA7F00AF40E4 /* DeviceOrientationClientIOS.h in Headers */,
</span><span class="cx">                          59309A1311F4AE6A00250603 /* DeviceOrientationClientMock.h in Headers */,
</span><span class="lines">@@ -29036,6 +29054,8 @@
</span><span class="cx">                          59A8F1D611A69513001AC34A /* DeviceOrientationController.h in Headers */,
</span><span class="cx">                          590E1B4911E4EF4B0069F784 /* DeviceOrientationData.h in Headers */,
</span><span class="cx">                          59A85EA4119D68EC00DEF1EF /* DeviceOrientationEvent.h in Headers */,
</span><ins>+                               460E3075222F4EFD009A0606 /* DeviceOrientationOrMotionEvent.h in Headers */,
+                               460E3077222F4F03009A0606 /* DeviceOrientationOrMotionPermissionState.h in Headers */,
</ins><span class="cx">                           572B401F21757A64000AD43E /* DeviceRequestConverter.h in Headers */,
</span><span class="cx">                          572B403A21772581000AD43E /* DeviceResponseConverter.h in Headers */,
</span><span class="cx">                          267725FD1A5B3AD9003C24DD /* DFA.h in Headers */,
</span></span></pre></div>
<a id="trunkSourceWebCoredomDeviceMotionEventh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/DeviceMotionEvent.h (242663 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/DeviceMotionEvent.h     2019-03-09 00:17:37 UTC (rev 242663)
+++ trunk/Source/WebCore/dom/DeviceMotionEvent.h        2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -25,6 +25,7 @@
</span><span class="cx"> 
</span><span class="cx"> #pragma once
</span><span class="cx"> 
</span><ins>+#include "DeviceOrientationOrMotionEvent.h"
</ins><span class="cx"> #include "Event.h"
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -31,7 +32,7 @@
</span><span class="cx"> 
</span><span class="cx"> class DeviceMotionData;
</span><span class="cx"> 
</span><del>-class DeviceMotionEvent final : public Event {
</del><ins>+class DeviceMotionEvent final : public Event, public DeviceOrientationOrMotionEvent {
</ins><span class="cx"> public:
</span><span class="cx">     virtual ~DeviceMotionEvent();
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoredomDeviceMotionEventidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/DeviceMotionEvent.idl (242663 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/DeviceMotionEvent.idl   2019-03-09 00:17:37 UTC (rev 242663)
+++ trunk/Source/WebCore/dom/DeviceMotionEvent.idl      2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -57,3 +57,5 @@
</span><span class="cx">     double? beta;
</span><span class="cx">     double? gamma;
</span><span class="cx"> };
</span><ins>+
+DeviceMotionEvent implements DeviceOrientationOrMotionEvent;
</ins></span></pre></div>
<a id="trunkSourceWebCoredomDeviceOrientationAndMotionAccessControllercpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/dom/DeviceOrientationAndMotionAccessController.cpp (0 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/DeviceOrientationAndMotionAccessController.cpp                          (rev 0)
+++ trunk/Source/WebCore/dom/DeviceOrientationAndMotionAccessController.cpp     2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -0,0 +1,86 @@
</span><ins>+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "DeviceOrientationAndMotionAccessController.h"
+
+#if ENABLE(DEVICE_ORIENTATION)
+
+#include "Chrome.h"
+#include "ChromeClient.h"
+#include "DOMWindow.h"
+#include "Document.h"
+#include "Frame.h"
+#include "Page.h"
+
+namespace WebCore {
+
+DeviceOrientationAndMotionAccessController::DeviceOrientationAndMotionAccessController(Document& document)
+    : m_document(document)
+{
+    ASSERT(&m_document.topDocument() == &m_document);
+}
+
+void DeviceOrientationAndMotionAccessController::shouldAllowAccess(Function<void(bool granted)>&& callback)
+{
+    if (m_accessState)
+        return callback(*m_accessState);
+
+    auto* page = m_document.page();
+    if (!page)
+        return callback(false);
+
+    m_pendingRequests.append(WTFMove(callback));
+    if (m_pendingRequests.size() > 1)
+        return;
+
+    page->chrome().client().shouldAllowDeviceOrientationAndMotionAccess(m_document.securityOrigin(), [this, weakThis = makeWeakPtr(*this)](bool granted) mutable {
+        if (weakThis)
+            setAccessState(granted);
+    });
+}
+
+void DeviceOrientationAndMotionAccessController::setAccessState(bool granted)
+{
+    ASSERT(!m_accessState);
+
+    m_accessState = granted;
+
+    auto pendingRequests = WTFMove(m_pendingRequests);
+    for (auto& request : pendingRequests)
+        request(granted);
+
+    if (!granted)
+        return;
+
+    for (auto* frame = m_document.frame(); frame && frame->window(); frame = frame->tree().traverseNext(m_document.frame())) {
+        frame->window()->startListeningForDeviceOrientationIfNecessary();
+        frame->window()->startListeningForDeviceMotionIfNecessary();
+    }
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(DEVICE_ORIENTATION)
</ins></span></pre></div>
<a id="trunkSourceWebCoredomDeviceOrientationAndMotionAccessControllerh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/dom/DeviceOrientationAndMotionAccessController.h (0 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/DeviceOrientationAndMotionAccessController.h                            (rev 0)
+++ trunk/Source/WebCore/dom/DeviceOrientationAndMotionAccessController.h       2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -0,0 +1,56 @@
</span><ins>+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(DEVICE_ORIENTATION)
+
+#include <wtf/Function.h>
+#include <wtf/Vector.h>
+#include <wtf/WeakPtr.h>
+
+namespace WebCore {
+
+class Document;
+
+class DeviceOrientationAndMotionAccessController : public CanMakeWeakPtr<DeviceOrientationAndMotionAccessController> {
+    WTF_MAKE_FAST_ALLOCATED;
+public:
+    explicit DeviceOrientationAndMotionAccessController(Document&);
+
+    const Optional<bool>& accessState() const { return m_accessState; }
+    void shouldAllowAccess(Function<void(bool granted)>&&);
+
+private:
+    void setAccessState(bool);
+
+    Document& m_document;
+    Optional<bool> m_accessState;
+    Vector<Function<void(bool)>> m_pendingRequests;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(DEVICE_ORIENTATION)
</ins></span></pre></div>
<a id="trunkSourceWebCoredomDeviceOrientationEventh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/DeviceOrientationEvent.h (242663 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/DeviceOrientationEvent.h        2019-03-09 00:17:37 UTC (rev 242663)
+++ trunk/Source/WebCore/dom/DeviceOrientationEvent.h   2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -25,6 +25,7 @@
</span><span class="cx"> 
</span><span class="cx"> #pragma once
</span><span class="cx"> 
</span><ins>+#include "DeviceOrientationOrMotionEvent.h"
</ins><span class="cx"> #include "Event.h"
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -31,7 +32,7 @@
</span><span class="cx"> 
</span><span class="cx"> class DeviceOrientationData;
</span><span class="cx"> 
</span><del>-class DeviceOrientationEvent final : public Event {
</del><ins>+class DeviceOrientationEvent final : public Event, public DeviceOrientationOrMotionEvent {
</ins><span class="cx"> public:
</span><span class="cx">     static Ref<DeviceOrientationEvent> create(const AtomicString& eventType, DeviceOrientationData* orientation)
</span><span class="cx">     {
</span></span></pre></div>
<a id="trunkSourceWebCoredomDeviceOrientationEventidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/DeviceOrientationEvent.idl (242663 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/DeviceOrientationEvent.idl      2019-03-09 00:17:37 UTC (rev 242663)
+++ trunk/Source/WebCore/dom/DeviceOrientationEvent.idl 2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -55,3 +55,4 @@
</span><span class="cx"> #endif
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+DeviceOrientationEvent implements DeviceOrientationOrMotionEvent;
</ins></span></pre></div>
<a id="trunkSourceWebCoredomDeviceOrientationOrMotionEventcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/dom/DeviceOrientationOrMotionEvent.cpp (0 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/DeviceOrientationOrMotionEvent.cpp                              (rev 0)
+++ trunk/Source/WebCore/dom/DeviceOrientationOrMotionEvent.cpp 2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -0,0 +1,56 @@
</span><ins>+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "DeviceOrientationOrMotionEvent.h"
+
+#include "Document.h"
+#include "UserGestureIndicator.h"
+
+namespace WebCore {
+
+#if ENABLE(DEVICE_ORIENTATION)
+void DeviceOrientationOrMotionEvent::requestPermission(Document& document, PermissionPromise&& promise)
+{
+    auto* window = document.domWindow();
+    if (!window)
+        return promise.reject(Exception { InvalidStateError, "No browsing context"_s });
+
+    if (!UserGestureIndicator::processingUserGesture())
+        return promise.reject(Exception { NotAllowedError, "Calling requestPermission() requires a user gesture"_s });
+
+    String errorMessage;
+    if (!window->isAllowedToUseDeviceMotionOrientation(errorMessage)) {
+        document.addConsoleMessage(MessageSource::JS, MessageLevel::Warning, makeString("Call to requestPermission() failed, reason: ", errorMessage, "."));
+        return promise.resolve(PermissionState::Denied);
+    }
+
+    document.deviceOrientationAndMotionAccessController().shouldAllowAccess([promise = WTFMove(promise)](bool granted) mutable {
+        promise.resolve(granted ? PermissionState::Granted : PermissionState::Denied);
+    });
+}
+#endif
+
+} // namespace WebCore
</ins></span></pre></div>
<a id="trunkSourceWebCoredomDeviceOrientationOrMotionEventh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/dom/DeviceOrientationOrMotionEvent.h (0 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/DeviceOrientationOrMotionEvent.h                                (rev 0)
+++ trunk/Source/WebCore/dom/DeviceOrientationOrMotionEvent.h   2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -0,0 +1,49 @@
</span><ins>+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "DeviceOrientationOrMotionPermissionState.h"
+#include "JSDOMPromiseDeferred.h"
+
+namespace WebCore {
+
+class Document;
+
+class DeviceOrientationOrMotionEvent {
+public:
+
+#if ENABLE(DEVICE_ORIENTATION)
+    using PermissionState = DeviceOrientationOrMotionPermissionState;
+    using PermissionPromise = DOMPromiseDeferred<IDLEnumeration<PermissionState>>;
+    static void requestPermission(Document&, PermissionPromise&&);
+#endif
+
+protected:
+    DeviceOrientationOrMotionEvent() = default;
+    ~DeviceOrientationOrMotionEvent() = default;
+};
+
+} // namespace WebCore
</ins></span></pre></div>
<a id="trunkSourceWebCoredomDeviceOrientationOrMotionEventidl"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/dom/DeviceOrientationOrMotionEvent.idl (0 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/DeviceOrientationOrMotionEvent.idl                              (rev 0)
+++ trunk/Source/WebCore/dom/DeviceOrientationOrMotionEvent.idl 2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -0,0 +1,31 @@
</span><ins>+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+[
+    Conditional=DEVICE_ORIENTATION,
+    NoInterfaceObject
+] interface DeviceOrientationOrMotionEvent {
+    [CallWith=Document, EnabledBySetting=DeviceOrientationPermissionAPI] static Promise<DeviceOrientationOrMotionPermissionState> requestPermission();
+};
</ins></span></pre></div>
<a id="trunkSourceWebCoredomDeviceOrientationOrMotionPermissionStateh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/dom/DeviceOrientationOrMotionPermissionState.h (0 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/DeviceOrientationOrMotionPermissionState.h                              (rev 0)
+++ trunk/Source/WebCore/dom/DeviceOrientationOrMotionPermissionState.h 2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -0,0 +1,32 @@
</span><ins>+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+namespace WebCore {
+
+enum class DeviceOrientationOrMotionPermissionState { Granted, Denied };
+
+}
</ins></span></pre></div>
<a id="trunkSourceWebCoredomDeviceOrientationOrMotionPermissionStateidl"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/dom/DeviceOrientationOrMotionPermissionState.idl (0 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/DeviceOrientationOrMotionPermissionState.idl                            (rev 0)
+++ trunk/Source/WebCore/dom/DeviceOrientationOrMotionPermissionState.idl       2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -0,0 +1,26 @@
</span><ins>+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+enum DeviceOrientationOrMotionPermissionState { "granted", "denied" };
</ins></span></pre></div>
<a id="trunkSourceWebCoredomDocumentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Document.cpp (242663 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Document.cpp    2019-03-09 00:17:37 UTC (rev 242663)
+++ trunk/Source/WebCore/dom/Document.cpp       2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -244,6 +244,7 @@
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(DEVICE_ORIENTATION)
</span><span class="cx"> #include "DeviceMotionEvent.h"
</span><ins>+#include "DeviceOrientationAndMotionAccessController.h"
</ins><span class="cx"> #include "DeviceOrientationEvent.h"
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="lines">@@ -8611,6 +8612,20 @@
</span><span class="cx">     detachFromFrame();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#if ENABLE(DEVICE_ORIENTATION)
+
+DeviceOrientationAndMotionAccessController& Document::deviceOrientationAndMotionAccessController()
+{
+    if (&topDocument() != this)
+        return topDocument().deviceOrientationAndMotionAccessController();
+
+    if (!m_deviceOrientationAndMotionAccessController)
+        m_deviceOrientationAndMotionAccessController = std::make_unique<DeviceOrientationAndMotionAccessController>(*this);
+    return *m_deviceOrientationAndMotionAccessController;
+}
+
+#endif
+
</ins><span class="cx"> #if ENABLE(CSS_PAINTING_API)
</span><span class="cx"> Worklet& Document::ensurePaintWorklet()
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebCoredomDocumenth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Document.h (242663 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Document.h      2019-03-09 00:17:37 UTC (rev 242663)
+++ trunk/Source/WebCore/dom/Document.h 2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -224,6 +224,7 @@
</span><span class="cx"> class TouchList;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if ENABLE(DEVICE_ORIENTATION)
</ins><span class="cx"> #if PLATFORM(IOS_FAMILY)
</span><span class="cx"> class DeviceMotionClient;
</span><span class="cx"> class DeviceMotionController;
</span><span class="lines">@@ -230,6 +231,8 @@
</span><span class="cx"> class DeviceOrientationClient;
</span><span class="cx"> class DeviceOrientationController;
</span><span class="cx"> #endif
</span><ins>+class DeviceOrientationAndMotionAccessController;
+#endif
</ins><span class="cx"> 
</span><span class="cx"> #if ENABLE(TEXT_AUTOSIZING)
</span><span class="cx"> class TextAutoSizing;
</span><span class="lines">@@ -1216,12 +1219,16 @@
</span><span class="cx"> #include <WebKitAdditions/DocumentIOS.h>
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-#if ENABLE(DEVICE_ORIENTATION) && PLATFORM(IOS_FAMILY)
</del><ins>+#if ENABLE(DEVICE_ORIENTATION)
+#if PLATFORM(IOS_FAMILY)
</ins><span class="cx">     DeviceMotionController& deviceMotionController() const;
</span><span class="cx">     DeviceOrientationController& deviceOrientationController() const;
</span><span class="cx">     WEBCORE_EXPORT void simulateDeviceOrientationChange(double alpha, double beta, double gamma);
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+    DeviceOrientationAndMotionAccessController& deviceOrientationAndMotionAccessController();
+#endif // ENABLE(DEVICE_ORIENTATION)
+
</ins><span class="cx">     const DocumentTiming& timing() const { return m_documentTiming; }
</span><span class="cx"> 
</span><span class="cx">     WEBCORE_EXPORT double monotonicTimestamp() const;
</span><span class="lines">@@ -1869,12 +1876,15 @@
</span><span class="cx">     void setHasFrameSpecificStorageAccess(bool);
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-#if ENABLE(DEVICE_ORIENTATION) && PLATFORM(IOS_FAMILY)
</del><ins>+#if ENABLE(DEVICE_ORIENTATION)
+#if PLATFORM(IOS_FAMILY)
</ins><span class="cx">     std::unique_ptr<DeviceMotionClient> m_deviceMotionClient;
</span><span class="cx">     std::unique_ptr<DeviceMotionController> m_deviceMotionController;
</span><span class="cx">     std::unique_ptr<DeviceOrientationClient> m_deviceOrientationClient;
</span><span class="cx">     std::unique_ptr<DeviceOrientationController> m_deviceOrientationController;
</span><span class="cx"> #endif
</span><ins>+    std::unique_ptr<DeviceOrientationAndMotionAccessController> m_deviceOrientationAndMotionAccessController;
+#endif
</ins><span class="cx"> 
</span><span class="cx">     GenericTaskQueue<Timer> m_logMessageTaskQueue;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoredomEventcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Event.cpp (242663 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Event.cpp       2019-03-09 00:17:37 UTC (rev 242663)
+++ trunk/Source/WebCore/dom/Event.cpp  2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx"> #include "EventNames.h"
</span><span class="cx"> #include "EventPath.h"
</span><span class="cx"> #include "EventTarget.h"
</span><ins>+#include "InspectorInstrumentation.h"
</ins><span class="cx"> #include "Performance.h"
</span><span class="cx"> #include "UserGestureIndicator.h"
</span><span class="cx"> #include "WorkerGlobalScope.h"
</span></span></pre></div>
<a id="trunkSourceWebCoredomMessagePortcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/MessagePort.cpp (242663 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/MessagePort.cpp 2019-03-09 00:17:37 UTC (rev 242663)
+++ trunk/Source/WebCore/dom/MessagePort.cpp    2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -35,6 +35,7 @@
</span><span class="cx"> #include "MessageWithMessagePorts.h"
</span><span class="cx"> #include "WorkerGlobalScope.h"
</span><span class="cx"> #include "WorkerThread.h"
</span><ins>+#include <wtf/CompletionHandler.h>
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoredomMicrotaskscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Microtasks.cpp (242663 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Microtasks.cpp  2019-03-09 00:17:37 UTC (rev 242663)
+++ trunk/Source/WebCore/dom/Microtasks.cpp     2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -22,6 +22,7 @@
</span><span class="cx"> #include "config.h"
</span><span class="cx"> #include "Microtasks.h"
</span><span class="cx"> 
</span><ins>+#include "WorkerGlobalScope.h"
</ins><span class="cx"> #include <wtf/MainThread.h>
</span><span class="cx"> #include <wtf/NeverDestroyed.h>
</span><span class="cx"> #include <wtf/SetForScope.h>
</span></span></pre></div>
<a id="trunkSourceWebCorepageChromeClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/ChromeClient.h (242663 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/ChromeClient.h 2019-03-09 00:17:37 UTC (rev 242663)
+++ trunk/Source/WebCore/page/ChromeClient.h    2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -482,6 +482,10 @@
</span><span class="cx">     virtual void hasStorageAccess(String&& /*subFrameHost*/, String&& /*topFrameHost*/, uint64_t /*frameID*/, uint64_t /*pageID*/, WTF::CompletionHandler<void (bool)>&& callback) { callback(false); }
</span><span class="cx">     virtual void requestStorageAccess(String&& /*subFrameHost*/, String&& /*topFrameHost*/, uint64_t /*frameID*/, uint64_t /*pageID*/, WTF::CompletionHandler<void (bool)>&& callback) { callback(false); }
</span><span class="cx"> 
</span><ins>+#if ENABLE(DEVICE_ORIENTATION)
+    virtual void shouldAllowDeviceOrientationAndMotionAccess(const SecurityOrigin&, WTF::CompletionHandler<void(bool)>&& callback) { callback(true); }
+#endif
+
</ins><span class="cx">     virtual void didInsertMenuElement(HTMLMenuElement&) { }
</span><span class="cx">     virtual void didRemoveMenuElement(HTMLMenuElement&) { }
</span><span class="cx">     virtual void didInsertMenuItemElement(HTMLMenuItemElement&) { }
</span></span></pre></div>
<a id="trunkSourceWebCorepageDOMWindowcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/DOMWindow.cpp (242663 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/DOMWindow.cpp  2019-03-09 00:17:37 UTC (rev 242663)
+++ trunk/Source/WebCore/page/DOMWindow.cpp     2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -49,6 +49,7 @@
</span><span class="cx"> #include "DeviceMotionController.h"
</span><span class="cx"> #include "DeviceMotionData.h"
</span><span class="cx"> #include "DeviceMotionEvent.h"
</span><ins>+#include "DeviceOrientationAndMotionAccessController.h"
</ins><span class="cx"> #include "DeviceOrientationController.h"
</span><span class="cx"> #include "Document.h"
</span><span class="cx"> #include "DocumentLoader.h"
</span><span class="lines">@@ -1826,51 +1827,135 @@
</span><span class="cx">     else if (eventNames().isGamepadEventType(eventType))
</span><span class="cx">         incrementGamepadEventListenerCount();
</span><span class="cx"> #endif
</span><ins>+#if ENABLE(DEVICE_ORIENTATION)
+    else if (eventType == eventNames().deviceorientationEvent)
+        startListeningForDeviceOrientationIfNecessary();
+    else if (eventType == eventNames().devicemotionEvent)
+        startListeningForDeviceMotionIfNecessary();
+#endif
</ins><span class="cx"> 
</span><ins>+    return true;
+}
+
</ins><span class="cx"> #if ENABLE(DEVICE_ORIENTATION)
</span><del>-    if (frame() && frame()->settings().deviceOrientationEventEnabled() && document() && document()->loader() && document()->loader()->deviceOrientationEventEnabled()) {
</del><ins>+
+DeviceOrientationController* DOMWindow::deviceOrientationController() const
+{
</ins><span class="cx"> #if PLATFORM(IOS_FAMILY)
</span><del>-        if ((eventType == eventNames().devicemotionEvent || eventType == eventNames().deviceorientationEvent)) {
-            if (isSameSecurityOriginAsMainFrame() && isSecureContext()) {
-                if (eventType == eventNames().deviceorientationEvent)
-                    document()->deviceOrientationController().addDeviceEventListener(*this);
-                else
-                    document()->deviceMotionController().addDeviceEventListener(*this);
-            } else if (document()) {
-                if (isSecureContext())
-                    document()->addConsoleMessage(MessageSource::JS, MessageLevel::Warning, "Blocked attempt to add a device motion or orientation listener from child frame that wasn't the same security origin as the main page."_s);
-                else
-                    document()->addConsoleMessage(MessageSource::JS, MessageLevel::Warning, "Blocked attempt to add a device motion or orientation listener because the browsing context is not secure."_s);
-            }
-        }
</del><ins>+    return document() ? &document()->deviceOrientationController() : nullptr;
</ins><span class="cx"> #else
</span><del>-        if (eventType == eventNames().devicemotionEvent) {
-            if (isSameSecurityOriginAsMainFrame() && isSecureContext()) {
-                if (DeviceMotionController* controller = DeviceMotionController::from(page()))
-                    controller->addDeviceEventListener(*this);
-            } 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 (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
-                    document()->addConsoleMessage(MessageSource::JS, MessageLevel::Warning, "Blocked attempt to add a device motion or orientation listener because the browsing context is not secure."_s);
-            }
</del><ins>+    return DeviceOrientationController::from(page());
+#endif
+}
+
+DeviceMotionController* DOMWindow::deviceMotionController() const
+{
+#if PLATFORM(IOS_FAMILY)
+    return document() ? &document()->deviceMotionController() : nullptr;
+#else
+    return DeviceMotionController::from(page());
+#endif
+}
+
+bool DOMWindow::isAllowedToUseDeviceMotionOrientation(String& message) const
+{
+    if (!frame() || !frame()->settings().deviceOrientationEventEnabled() || !document() || !document()->loader() || !document()->loader()->deviceOrientationEventEnabled()) {
+        message = "API is disabled"_s;
+        return false;
+    }
+
+    if (!isSecureContext()) {
+        message = "Browsing context is not secure"_s;
+        return false;
+    }
+
+    if (!isSameSecurityOriginAsMainFrame()) {
+        message = "Source frame did not have the same security origin as the main page"_s;
+        return false;
+    }
+    return true;
+}
+
+bool DOMWindow::isAllowedToAddDeviceMotionOrientationListener(String& message) const
+{
+    String innerMessage;
+    if (!isAllowedToUseDeviceMotionOrientation(innerMessage)) {
+        message = makeString("Blocked attempt to add a device motion or orientation event listener, reason: ", innerMessage, ".");
+        return false;
+    }
+
+    if (frame()->settings().deviceOrientationPermissionAPIEnabled()) {
+        auto accessState = document()->deviceOrientationAndMotionAccessController().accessState();
+        if (accessState && !*accessState) {
+            message = "No device motion or orientation events will be fired because permission to use the API was denied."_s;
+            return false;
</ins><span class="cx">         }
</span><del>-#endif // PLATFORM(IOS_FAMILY)
-    } else if (eventType == eventNames().devicemotionEvent)
-        failedToRegisterDeviceMotionEventListener();
-#endif // ENABLE(DEVICE_ORIENTATION)
</del><ins>+        if (!accessState) {
+            message = "No device motion or orientation events will be fired until permission has been requested and granted."_s;
+            return false;
+        }
+    }
</ins><span class="cx"> 
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-#if ENABLE(DEVICE_ORIENTATION)
</del><ins>+void DOMWindow::startListeningForDeviceOrientationIfNecessary()
+{
+    if (!hasEventListeners(eventNames().deviceorientationEvent))
+        return;
</ins><span class="cx"> 
</span><ins>+    auto* deviceController = deviceOrientationController();
+    if (!deviceController || deviceController->hasDeviceEventListener(*this))
+        return;
+
+    String errorMessage;
+    if (!isAllowedToAddDeviceMotionOrientationListener(errorMessage)) {
+        if (auto* document = this->document())
+            document->addConsoleMessage(MessageSource::JS, MessageLevel::Warning, errorMessage);
+        return;
+    }
+
+    deviceController->addDeviceEventListener(*this);
+}
+
+void DOMWindow::stopListeningForDeviceOrientationIfNecessary()
+{
+    if (hasEventListeners(eventNames().deviceorientationEvent))
+        return;
+
+    if (auto* deviceController = deviceOrientationController())
+        deviceController->removeDeviceEventListener(*this);
+}
+
+void DOMWindow::startListeningForDeviceMotionIfNecessary()
+{
+    if (!hasEventListeners(eventNames().devicemotionEvent))
+        return;
+
+    auto* deviceController = deviceMotionController();
+    if (!deviceController || deviceController->hasDeviceEventListener(*this))
+        return;
+
+    String errorMessage;
+    if (!isAllowedToAddDeviceMotionOrientationListener(errorMessage)) {
+        failedToRegisterDeviceMotionEventListener();
+        if (auto* document = this->document())
+            document->addConsoleMessage(MessageSource::JS, MessageLevel::Warning, errorMessage);
+        return;
+    }
+
+    deviceController->addDeviceEventListener(*this);
+}
+
+void DOMWindow::stopListeningForDeviceMotionIfNecessary()
+{
+    if (hasEventListeners(eventNames().devicemotionEvent))
+        return;
+
+    if (auto* deviceController = deviceMotionController())
+        deviceController->removeDeviceEventListener(*this);
+}
+
</ins><span class="cx"> void DOMWindow::failedToRegisterDeviceMotionEventListener()
</span><span class="cx"> {
</span><span class="cx"> #if PLATFORM(IOS_FAMILY)
</span><span class="lines">@@ -1941,23 +2026,7 @@
</span><span class="cx">         removeUnloadEventListener(this);
</span><span class="cx">     else if (eventType == eventNames().beforeunloadEvent && allowsBeforeUnloadListeners(this))
</span><span class="cx">         removeBeforeUnloadEventListener(this);
</span><del>-#if ENABLE(DEVICE_ORIENTATION)
</del><span class="cx"> #if PLATFORM(IOS_FAMILY)
</span><del>-    else if (eventType == eventNames().devicemotionEvent && document())
-        document()->deviceMotionController().removeDeviceEventListener(*this);
-    else if (eventType == eventNames().deviceorientationEvent && document())
-        document()->deviceOrientationController().removeDeviceEventListener(*this);
-#else
-    else if (eventType == eventNames().devicemotionEvent) {
-        if (DeviceMotionController* controller = DeviceMotionController::from(page()))
-            controller->removeDeviceEventListener(*this);
-    } else if (eventType == eventNames().deviceorientationEvent) {
-        if (DeviceOrientationController* controller = DeviceOrientationController::from(page()))
-            controller->removeDeviceEventListener(*this);
-    }
-#endif // PLATFORM(IOS_FAMILY)
-#endif // ENABLE(DEVICE_ORIENTATION)
-#if PLATFORM(IOS_FAMILY)
</del><span class="cx">     else if (eventType == eventNames().scrollEvent)
</span><span class="cx">         decrementScrollEventListenersCount();
</span><span class="cx"> #endif
</span><span class="lines">@@ -1977,6 +2046,12 @@
</span><span class="cx">     else if (eventNames().isGamepadEventType(eventType))
</span><span class="cx">         decrementGamepadEventListenerCount();
</span><span class="cx"> #endif
</span><ins>+#if ENABLE(DEVICE_ORIENTATION)
+    else if (eventType == eventNames().deviceorientationEvent)
+        stopListeningForDeviceOrientationIfNecessary();
+    else if (eventType == eventNames().devicemotionEvent)
+        stopListeningForDeviceMotionIfNecessary();
+#endif
</ins><span class="cx"> 
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="lines">@@ -2059,18 +2134,9 @@
</span><span class="cx">     EventTarget::removeAllEventListeners();
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(DEVICE_ORIENTATION)
</span><del>-#if PLATFORM(IOS_FAMILY)
-    if (Document* document = this->document()) {
-        document->deviceMotionController().removeAllDeviceEventListeners(*this);
-        document->deviceOrientationController().removeAllDeviceEventListeners(*this);
-    }
-#else
-    if (DeviceMotionController* controller = DeviceMotionController::from(page()))
-        controller->removeAllDeviceEventListeners(*this);
-    if (DeviceOrientationController* controller = DeviceOrientationController::from(page()))
-        controller->removeAllDeviceEventListeners(*this);
-#endif // PLATFORM(IOS_FAMILY)
-#endif // ENABLE(DEVICE_ORIENTATION)
</del><ins>+        stopListeningForDeviceOrientationIfNecessary();
+        stopListeningForDeviceMotionIfNecessary();
+#endif
</ins><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS_FAMILY)
</span><span class="cx">     if (m_scrollEventListenerCount) {
</span></span></pre></div>
<a id="trunkSourceWebCorepageDOMWindowh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/DOMWindow.h (242663 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/DOMWindow.h    2019-03-09 00:17:37 UTC (rev 242663)
+++ trunk/Source/WebCore/page/DOMWindow.h       2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -82,6 +82,11 @@
</span><span class="cx"> class WebKitNamespace;
</span><span class="cx"> class WebKitPoint;
</span><span class="cx"> 
</span><ins>+#if ENABLE(DEVICE_ORIENTATION)
+class DeviceMotionController;
+class DeviceOrientationController;
+#endif
+
</ins><span class="cx"> struct ImageBitmapOptions;
</span><span class="cx"> struct WindowFeatures;
</span><span class="cx"> 
</span><span class="lines">@@ -311,6 +316,19 @@
</span><span class="cx">     unsigned scrollEventListenerCount() const { return m_scrollEventListenerCount; }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if ENABLE(DEVICE_ORIENTATION)
+    void startListeningForDeviceOrientationIfNecessary();
+    void stopListeningForDeviceOrientationIfNecessary();
+    void startListeningForDeviceMotionIfNecessary();
+    void stopListeningForDeviceMotionIfNecessary();
+
+    bool isAllowedToUseDeviceMotionOrientation(String& message) const;
+    bool isAllowedToAddDeviceMotionOrientationListener(String& message) const;
+
+    DeviceOrientationController* deviceOrientationController() const;
+    DeviceMotionController* deviceMotionController() const;
+#endif
+
</ins><span class="cx">     void resetAllGeolocationPermission();
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(IOS_TOUCH_EVENTS) || ENABLE(IOS_GESTURE_EVENTS)
</span></span></pre></div>
<a id="trunkSourceWebCorepageDeviceControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/DeviceController.cpp (242663 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/DeviceController.cpp   2019-03-09 00:17:37 UTC (rev 242663)
+++ trunk/Source/WebCore/page/DeviceController.cpp      2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -69,6 +69,11 @@
</span><span class="cx">         m_client.stopUpdating();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool DeviceController::hasDeviceEventListener(DOMWindow& window) const
+{
+    return m_listeners.contains(&window);
+}
+
</ins><span class="cx"> void DeviceController::dispatchDeviceEvent(Event& event)
</span><span class="cx"> {
</span><span class="cx">     for (auto& listener : copyToVector(m_listeners.values())) {
</span></span></pre></div>
<a id="trunkSourceWebCorepageDeviceControllerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/DeviceController.h (242663 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/DeviceController.h     2019-03-09 00:17:37 UTC (rev 242663)
+++ trunk/Source/WebCore/page/DeviceController.h        2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -46,6 +46,7 @@
</span><span class="cx">     void addDeviceEventListener(DOMWindow&);
</span><span class="cx">     void removeDeviceEventListener(DOMWindow&);
</span><span class="cx">     void removeAllDeviceEventListeners(DOMWindow&);
</span><ins>+    bool hasDeviceEventListener(DOMWindow&) const;
</ins><span class="cx"> 
</span><span class="cx">     void dispatchDeviceEvent(Event&);
</span><span class="cx">     bool isActive() { return !m_listeners.isEmpty(); }
</span></span></pre></div>
<a id="trunkSourceWebCorepageSettingsyaml"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/Settings.yaml (242663 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/Settings.yaml  2019-03-09 00:17:37 UTC (rev 242663)
+++ trunk/Source/WebCore/page/Settings.yaml     2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -767,6 +767,11 @@
</span><span class="cx">   initial: true
</span><span class="cx">   conditional: DEVICE_ORIENTATION
</span><span class="cx"> 
</span><ins>+deviceOrientationPermissionAPIEnabled:
+  type: bool
+  initial: false
+  conditional: DEVICE_ORIENTATION
+
</ins><span class="cx"> shouldEnableTextAutosizingBoost:
</span><span class="cx">   type: bool
</span><span class="cx">   initial: false
</span></span></pre></div>
<a id="trunkSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ChangeLog (242663 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ChangeLog    2019-03-09 00:17:37 UTC (rev 242663)
+++ trunk/Source/WebKit/ChangeLog       2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -1,3 +1,42 @@
</span><ins>+2019-03-08  Chris Dumez  <cdumez@apple.com>
+
+        Add support for Device Orientation / Motion permission API
+        https://bugs.webkit.org/show_bug.cgi?id=195329
+        <rdar://problem/47645367>
+
+        Reviewed by Geoffrey Garen.
+
+        Add support for Device Orientation / Motion permission API:
+        - https://github.com/w3c/deviceorientation/issues/57
+
+        This adds new SPI to WKUIDelegatePrivate, until we can make this API.
+
+        * Shared/WebPreferences.yaml:
+        * UIProcess/API/APIUIClient.h:
+        (API::UIClient::shouldAllowDeviceOrientationAndMotionAccess):
+        * UIProcess/API/C/WKPage.cpp:
+        (WKPageSetPageUIClient):
+        * UIProcess/API/C/WKPageUIClient.h:
+        * UIProcess/API/Cocoa/WKUIDelegate.h:
+        * UIProcess/API/Cocoa/WKUIDelegatePrivate.h:
+        * UIProcess/Cocoa/UIDelegate.h:
+        * UIProcess/Cocoa/UIDelegate.mm:
+        (WebKit::UIDelegate::setDelegate):
+        (WebKit::UIDelegate::UIClient::shouldAllowDeviceOrientationAndMotionAccess):
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::requestDeviceOrientationAndMotionAccess):
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebPageProxy.messages.in:
+        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+        (WebKit::WebChromeClient::shouldAllowDeviceOrientationAndMotionAccess):
+        * WebProcess/WebCoreSupport/WebChromeClient.h:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::nextDeviceOrientationAndMotionPermissionCallbackID):
+        (WebKit::WebPage::shouldAllowDeviceOrientationAndMotionAccess):
+        (WebKit::WebPage::didReceiveDeviceOrientationAndMotionAccessDecision):
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/WebPage.messages.in:
+
</ins><span class="cx"> 2019-03-08  Brady Eidson  <beidson@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Have the UIProcess take the UnboundedNetworking assertion when downloads are in progress.
</span></span></pre></div>
<a id="trunkSourceWebKitSharedWebPreferencesyaml"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/Shared/WebPreferences.yaml (242663 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/Shared/WebPreferences.yaml   2019-03-09 00:17:37 UTC (rev 242663)
+++ trunk/Source/WebKit/Shared/WebPreferences.yaml      2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -12,6 +12,15 @@
</span><span class="cx">   condition: ENABLE(DEVICE_ORIENTATION)
</span><span class="cx">   webcoreName: deviceOrientationEventEnabled
</span><span class="cx"> 
</span><ins>+DeviceOrientationPermissionAPIEnabled:
+  type: bool
+  defaultValue: defaultDeviceOrientationPermissionAPIEnabled()
+  condition: ENABLE(DEVICE_ORIENTATION)
+  webcoreName: deviceOrientationPermissionAPIEnabled
+  humanReadableName: "Permission API for device orientation / motion access."
+  humanReadableDescription: "DeviceOrientationEvent.requestPermission() / DeviceMotionEvent.requestPermission()"
+  category: experimental
+
</ins><span class="cx"> JavaScriptEnabled:
</span><span class="cx">   type: bool
</span><span class="cx">   defaultValue: true
</span></span></pre></div>
<a id="trunkSourceWebKitSharedWebPreferencesDefaultValuescpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/Shared/WebPreferencesDefaultValues.cpp (242663 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/Shared/WebPreferencesDefaultValues.cpp       2019-03-09 00:17:37 UTC (rev 242663)
+++ trunk/Source/WebKit/Shared/WebPreferencesDefaultValues.cpp  2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -44,6 +44,15 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool defaultDeviceOrientationPermissionAPIEnabled()
+{
+#if PLATFORM(IOS) && ENABLE(DEVICE_ORIENTATION)
+    return linkedOnOrAfter(WebKit::SDKVersion::FirstWithDeviceOrientationAndMotionPermissionAPI);
+#else
+    return false;
+#endif
+}
+
</ins><span class="cx"> bool defaultCustomPasteboardDataEnabled()
</span><span class="cx"> {
</span><span class="cx"> #if PLATFORM(IOSMAC)
</span></span></pre></div>
<a id="trunkSourceWebKitSharedWebPreferencesDefaultValuesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/Shared/WebPreferencesDefaultValues.h (242663 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/Shared/WebPreferencesDefaultValues.h 2019-03-09 00:17:37 UTC (rev 242663)
+++ trunk/Source/WebKit/Shared/WebPreferencesDefaultValues.h    2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -227,6 +227,7 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> bool defaultPassiveTouchListenersAsDefaultOnDocument();
</span><ins>+bool defaultDeviceOrientationPermissionAPIEnabled();
</ins><span class="cx"> bool defaultCustomPasteboardDataEnabled();
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(MAC)
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPIAPIUIClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/API/APIUIClient.h (242663 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/APIUIClient.h  2019-03-09 00:17:37 UTC (rev 242663)
+++ trunk/Source/WebKit/UIProcess/API/APIUIClient.h     2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -173,6 +173,10 @@
</span><span class="cx">     virtual void didLosePointerLock(WebKit::WebPageProxy*) { }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if ENABLE(DEVICE_ORIENTATION)
+    virtual void shouldAllowDeviceOrientationAndMotionAccess(WebKit::WebPageProxy&, SecurityOrigin&, CompletionHandler<void(bool)>&& completionHandler) { completionHandler(true); }
+#endif
+
</ins><span class="cx">     virtual void didClickAutoFillButton(WebKit::WebPageProxy&, Object*) { }
</span><span class="cx"> 
</span><span class="cx">     virtual void didResignInputElementStrongPasswordAppearance(WebKit::WebPageProxy&, Object*) { }
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPICWKPagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp (242663 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp   2019-03-09 00:17:37 UTC (rev 242663)
+++ trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp      2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -115,7 +115,7 @@
</span><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> template<> struct ClientTraits<WKPageUIClientBase> {
</span><del>-    typedef std::tuple<WKPageUIClientV0, WKPageUIClientV1, WKPageUIClientV2, WKPageUIClientV3, WKPageUIClientV4, WKPageUIClientV5, WKPageUIClientV6, WKPageUIClientV7, WKPageUIClientV8, WKPageUIClientV9, WKPageUIClientV10, WKPageUIClientV11, WKPageUIClientV12> Versions;
</del><ins>+    typedef std::tuple<WKPageUIClientV0, WKPageUIClientV1, WKPageUIClientV2, WKPageUIClientV3, WKPageUIClientV4, WKPageUIClientV5, WKPageUIClientV6, WKPageUIClientV7, WKPageUIClientV8, WKPageUIClientV9, WKPageUIClientV10, WKPageUIClientV11, WKPageUIClientV12, WKPageUIClientV13> Versions;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(CONTEXT_MENUS)
</span><span class="lines">@@ -1903,6 +1903,16 @@
</span><span class="cx">             m_client.requestStorageAccessConfirm(toAPI(&page), toAPI(frame), toAPI(requestingDomain.impl()), toAPI(currentDomain.impl()), toAPI(listener.ptr()), m_client.base.clientInfo);
</span><span class="cx">         }
</span><span class="cx"> 
</span><ins>+#if ENABLE(DEVICE_ORIENTATION)
+        void shouldAllowDeviceOrientationAndMotionAccess(WebPageProxy& page, API::SecurityOrigin& origin, CompletionHandler<void(bool)>&& completionHandler) final
+        {
+            if (!m_client.shouldAllowDeviceOrientationAndMotionAccess)
+                return completionHandler(true);
+
+            completionHandler(m_client.shouldAllowDeviceOrientationAndMotionAccess(toAPI(&page), toAPI(&origin), m_client.base.clientInfo));
+        }
+#endif
+
</ins><span class="cx">         // Printing.
</span><span class="cx">         float headerHeight(WebPageProxy& page, WebFrameProxy& frame) final
</span><span class="cx">         {
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPICWKPageUIClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/API/C/WKPageUIClient.h (242663 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/C/WKPageUIClient.h     2019-03-09 00:17:37 UTC (rev 242663)
+++ trunk/Source/WebKit/UIProcess/API/C/WKPageUIClient.h        2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -134,6 +134,7 @@
</span><span class="cx"> typedef void (*WKHasVideoInPictureInPictureDidChangeCallback)(WKPageRef page, bool hasVideoInPictureInPicture, const void* clientInfo);
</span><span class="cx"> typedef void (*WKDidExceedBackgroundResourceLimitWhileInForegroundCallback)(WKPageRef page, WKResourceLimit limit, const void* clientInfo);
</span><span class="cx"> typedef void (*WKPageDidResignInputElementStrongPasswordAppearanceCallback)(WKPageRef page, WKTypeRef userData, const void *clientInfo);
</span><ins>+typedef bool (*WKPageShouldAllowDeviceOrientationAndMotionAccessCallback)(WKPageRef page, WKSecurityOriginRef securityOrigin, const void *clientInfo);
</ins><span class="cx"> 
</span><span class="cx"> // Deprecated
</span><span class="cx"> typedef WKPageRef (*WKPageCreateNewPageCallback_deprecatedForUseWithV0)(WKPageRef page, WKDictionaryRef features, WKEventModifiers modifiers, WKEventMouseButton mouseButton, const void *clientInfo);
</span><span class="lines">@@ -1140,6 +1141,110 @@
</span><span class="cx">     WKPageRequestStorageAccessConfirmCallback                           requestStorageAccessConfirm;
</span><span class="cx"> } WKPageUIClientV12;
</span><span class="cx"> 
</span><ins>+typedef struct WKPageUIClientV13 {
+    WKPageUIClientBase                                                  base;
+
+    // Version 0.
+    WKPageCreateNewPageCallback_deprecatedForUseWithV0                  createNewPage_deprecatedForUseWithV0;
+    WKPageUIClientCallback                                              showPage;
+    WKPageUIClientCallback                                              close;
+    WKPageTakeFocusCallback                                             takeFocus;
+    WKPageFocusCallback                                                 focus;
+    WKPageUnfocusCallback                                               unfocus;
+    WKPageRunJavaScriptAlertCallback_deprecatedForUseWithV0             runJavaScriptAlert_deprecatedForUseWithV0;
+    WKPageRunJavaScriptConfirmCallback_deprecatedForUseWithV0           runJavaScriptConfirm_deprecatedForUseWithV0;
+    WKPageRunJavaScriptPromptCallback_deprecatedForUseWithV0            runJavaScriptPrompt_deprecatedForUseWithV0;
+    WKPageSetStatusTextCallback                                         setStatusText;
+    WKPageMouseDidMoveOverElementCallback_deprecatedForUseWithV0        mouseDidMoveOverElement_deprecatedForUseWithV0;
+    WKPageMissingPluginButtonClickedCallback_deprecatedForUseWithV0     missingPluginButtonClicked_deprecatedForUseWithV0;
+    WKPageDidNotHandleKeyEventCallback                                  didNotHandleKeyEvent;
+    WKPageDidNotHandleWheelEventCallback                                didNotHandleWheelEvent;
+    WKPageGetToolbarsAreVisibleCallback                                 toolbarsAreVisible;
+    WKPageSetToolbarsAreVisibleCallback                                 setToolbarsAreVisible;
+    WKPageGetMenuBarIsVisibleCallback                                   menuBarIsVisible;
+    WKPageSetMenuBarIsVisibleCallback                                   setMenuBarIsVisible;
+    WKPageGetStatusBarIsVisibleCallback                                 statusBarIsVisible;
+    WKPageSetStatusBarIsVisibleCallback                                 setStatusBarIsVisible;
+    WKPageGetIsResizableCallback                                        isResizable;
+    WKPageSetIsResizableCallback                                        setIsResizable;
+    WKPageGetWindowFrameCallback                                        getWindowFrame;
+    WKPageSetWindowFrameCallback                                        setWindowFrame;
+    WKPageRunBeforeUnloadConfirmPanelCallback_deprecatedForUseWithV6    runBeforeUnloadConfirmPanel_deprecatedForUseWithV6;
+    WKPageUIClientCallback                                              didDraw;
+    WKPageUIClientCallback                                              pageDidScroll;
+    WKPageExceededDatabaseQuotaCallback                                 exceededDatabaseQuota;
+    WKPageRunOpenPanelCallback                                          runOpenPanel;
+    WKPageDecidePolicyForGeolocationPermissionRequestCallback           decidePolicyForGeolocationPermissionRequest;
+    WKPageHeaderHeightCallback                                          headerHeight;
+    WKPageFooterHeightCallback                                          footerHeight;
+    WKPageDrawHeaderCallback                                            drawHeader;
+    WKPageDrawFooterCallback                                            drawFooter;
+    WKPagePrintFrameCallback                                            printFrame;
+    WKPageUIClientCallback                                              runModal;
+    void*                                                               unused1; // Used to be didCompleteRubberBandForMainFrame
+    WKPageSaveDataToFileInDownloadsFolderCallback                       saveDataToFileInDownloadsFolder;
+    void*                                                               shouldInterruptJavaScript_unavailable;
+
+    // Version 1.
+    WKPageCreateNewPageCallback_deprecatedForUseWithV1                  createNewPage_deprecatedForUseWithV1;
+    WKPageMouseDidMoveOverElementCallback                               mouseDidMoveOverElement;
+    WKPageDecidePolicyForNotificationPermissionRequestCallback          decidePolicyForNotificationPermissionRequest;
+    WKPageUnavailablePluginButtonClickedCallback_deprecatedForUseWithV1 unavailablePluginButtonClicked_deprecatedForUseWithV1;
+
+    // Version 2.
+    WKPageShowColorPickerCallback                                       showColorPicker;
+    WKPageHideColorPickerCallback                                       hideColorPicker;
+    WKPageUnavailablePluginButtonClickedCallback                        unavailablePluginButtonClicked;
+
+    // Version 3.
+    WKPagePinnedStateDidChangeCallback                                  pinnedStateDidChange;
+
+    // Version 4.
+    void*                                                               unused2; // Used to be didBeginTrackingPotentialLongMousePress.
+    void*                                                               unused3; // Used to be didRecognizeLongMousePress.
+    void*                                                               unused4; // Used to be didCancelTrackingPotentialLongMousePress.
+    WKPageIsPlayingAudioDidChangeCallback                               isPlayingAudioDidChange;
+
+    // Version 5.
+    WKPageDecidePolicyForUserMediaPermissionRequestCallback             decidePolicyForUserMediaPermissionRequest;
+    WKPageDidClickAutoFillButtonCallback                                didClickAutoFillButton;
+    WKPageRunJavaScriptAlertCallback_deprecatedForUseWithV5             runJavaScriptAlert_deprecatedForUseWithV5;
+    WKPageRunJavaScriptConfirmCallback_deprecatedForUseWithV5           runJavaScriptConfirm_deprecatedForUseWithV5;
+    WKPageRunJavaScriptPromptCallback_deprecatedForUseWithV5            runJavaScriptPrompt_deprecatedForUseWithV5;
+    WKPageMediaSessionMetadataDidChangeCallback                         mediaSessionMetadataDidChange;
+
+    // Version 6.
+    WKPageCreateNewPageCallback                                         createNewPage;
+    WKPageRunJavaScriptAlertCallback                                    runJavaScriptAlert;
+    WKPageRunJavaScriptConfirmCallback                                  runJavaScriptConfirm;
+    WKPageRunJavaScriptPromptCallback                                   runJavaScriptPrompt;
+    WKCheckUserMediaPermissionCallback                                  checkUserMediaPermissionForOrigin;
+
+    // Version 7.
+    WKPageRunBeforeUnloadConfirmPanelCallback                           runBeforeUnloadConfirmPanel;
+    WKFullscreenMayReturnToInlineCallback                               fullscreenMayReturnToInline;
+
+    // Version 8.
+    WKRequestPointerLockCallback                                        requestPointerLock;
+    WKDidLosePointerLockCallback                                        didLosePointerLock;
+
+    // Version 9.
+    WKHandleAutoplayEventCallback                                       handleAutoplayEvent;
+
+    // Version 10.
+    WKHasVideoInPictureInPictureDidChangeCallback                       hasVideoInPictureInPictureDidChange;
+    WKDidExceedBackgroundResourceLimitWhileInForegroundCallback         didExceedBackgroundResourceLimitWhileInForeground;
+
+    // Version 11.
+    WKPageDidResignInputElementStrongPasswordAppearanceCallback         didResignInputElementStrongPasswordAppearance;
+
+    // Version 12.
+    WKPageRequestStorageAccessConfirmCallback                           requestStorageAccessConfirm;
+
+    // Version 13.
+    WKPageShouldAllowDeviceOrientationAndMotionAccessCallback           shouldAllowDeviceOrientationAndMotionAccess;
+} WKPageUIClientV13;
+
</ins><span class="cx"> #ifdef __cplusplus
</span><span class="cx"> }
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPICocoaWKUIDelegateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegate.h (242663 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegate.h   2019-03-09 00:17:37 UTC (rev 242663)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegate.h      2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -34,6 +34,7 @@
</span><span class="cx"> @class WKNavigationAction;
</span><span class="cx"> @class WKOpenPanelParameters;
</span><span class="cx"> @class WKPreviewElementInfo;
</span><ins>+@class WKSecurityOrigin;
</ins><span class="cx"> @class WKWebView;
</span><span class="cx"> @class WKWebViewConfiguration;
</span><span class="cx"> @class WKWindowFeatures;
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPICocoaWKUIDelegatePrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h (242663 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h    2019-03-09 00:17:37 UTC (rev 242663)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h       2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -171,6 +171,15 @@
</span><span class="cx"> - (void)_webView:(WKWebView *)webView didChangeSafeAreaShouldAffectObscuredInsets:(BOOL)safeAreaShouldAffectObscuredInsets WK_API_AVAILABLE(ios(11.0));
</span><span class="cx"> - (void)_webView:(WKWebView *)webView didPresentFocusedElementViewController:(UIViewController *)controller WK_API_AVAILABLE(ios(12.0));
</span><span class="cx"> - (void)_webView:(WKWebView *)webView didDismissFocusedElementViewController:(UIViewController *)controller WK_API_AVAILABLE(ios(12.0));
</span><ins>+
+/*! @abstract Allows your app to determine whether or not the given security origin should have access to the device's orientation and motion.
+ @param securityOrigin The security origin which requested access to the device's orientation and motion.
+ @param decisionHandler The decision handler to call once the app has made its decision. Pass YES to allow the origin access, NO otherwise.
+
+ If you do not implement this method, access to the device's orientation and motion will be granted.
+ */
+- (void)_webView:(WKWebView *)webView shouldAllowDeviceOrientationAndMotionAccessForSecurityOrigin:(WKSecurityOrigin *)securityOrigin decisionHandler:(void (^)(BOOL))decisionHandler WK_API_AVAILABLE(ios(WK_IOS_TBA));
+
</ins><span class="cx"> #else // TARGET_OS_IPHONE
</span><span class="cx"> - (void)_prepareForImmediateActionAnimationForWebView:(WKWebView *)webView WK_API_AVAILABLE(macosx(10.13.4));
</span><span class="cx"> - (void)_cancelImmediateActionAnimationForWebView:(WKWebView *)webView WK_API_AVAILABLE(macosx(10.13.4));
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessCocoaUIDelegateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.h (242663 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.h 2019-03-09 00:17:37 UTC (rev 242663)
+++ trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.h    2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -120,6 +120,9 @@
</span><span class="cx">         void didExceedBackgroundResourceLimitWhileInForeground(WebPageProxy&, WKResourceLimit) final;
</span><span class="cx">         void saveDataToFileInDownloadsFolder(WebPageProxy*, const WTF::String&, const WTF::String&, const URL&, API::Data&) final;
</span><span class="cx"> #endif
</span><ins>+#if ENABLE(DEVICE_ORIENTATION)
+        void shouldAllowDeviceOrientationAndMotionAccess(WebKit::WebPageProxy&, API::SecurityOrigin&, CompletionHandler<void(bool)>&&) final;
+#endif
</ins><span class="cx">         bool needsFontAttributes() const final { return m_uiDelegate.m_delegateMethods.webViewDidChangeFontAttributes; }
</span><span class="cx">         void didChangeFontAttributes(const WebCore::FontAttributes&) final;
</span><span class="cx">         void decidePolicyForUserMediaPermissionRequest(WebPageProxy&, WebFrameProxy&, API::SecurityOrigin&, API::SecurityOrigin&, UserMediaPermissionRequestProxy&) final;
</span><span class="lines">@@ -188,6 +191,9 @@
</span><span class="cx">         bool webViewRunOpenPanelWithParametersInitiatedByFrameCompletionHandler : 1;
</span><span class="cx">         bool webViewRequestNotificationPermissionForSecurityOriginDecisionHandler : 1;
</span><span class="cx"> #endif
</span><ins>+#if ENABLE(DEVICE_ORIENTATION)
+        bool webViewShouldAllowDeviceOrientationAndMotionAccessForSecurityOriginDecisionHandler : 1;
+#endif
</ins><span class="cx">         bool webViewDecideDatabaseQuotaForSecurityOriginCurrentQuotaCurrentOriginUsageCurrentDatabaseUsageExpectedUsageDecisionHandler : 1;
</span><span class="cx">         bool webViewDecideDatabaseQuotaForSecurityOriginDatabaseNameDisplayNameCurrentQuotaCurrentOriginUsageCurrentDatabaseUsageExpectedUsageDecisionHandler : 1;
</span><span class="cx">         bool webViewDecideWebApplicationCacheQuotaForSecurityOriginCurrentQuotaTotalBytesNeeded : 1;
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessCocoaUIDelegatemm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm (242663 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm        2019-03-09 00:17:37 UTC (rev 242663)
+++ trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm   2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -133,6 +133,9 @@
</span><span class="cx">     m_delegateMethods.webViewRunOpenPanelWithParametersInitiatedByFrameCompletionHandler = [delegate respondsToSelector:@selector(webView:runOpenPanelWithParameters:initiatedByFrame:completionHandler:)];
</span><span class="cx">     m_delegateMethods.webViewRequestNotificationPermissionForSecurityOriginDecisionHandler = [delegate respondsToSelector:@selector(_webView:requestNotificationPermissionForSecurityOrigin:decisionHandler:)];
</span><span class="cx"> #endif
</span><ins>+#if ENABLE(DEVICE_ORIENTATION)
+    m_delegateMethods.webViewShouldAllowDeviceOrientationAndMotionAccessForSecurityOriginDecisionHandler = [delegate respondsToSelector:@selector(_webView:shouldAllowDeviceOrientationAndMotionAccessForSecurityOrigin:decisionHandler:)];
+#endif
</ins><span class="cx">     m_delegateMethods.webViewDecideDatabaseQuotaForSecurityOriginCurrentQuotaCurrentOriginUsageCurrentDatabaseUsageExpectedUsageDecisionHandler = [delegate respondsToSelector:@selector(_webView:decideDatabaseQuotaForSecurityOrigin:currentQuota:currentOriginUsage:currentDatabaseUsage:expectedUsage:decisionHandler:)];
</span><span class="cx">     m_delegateMethods.webViewDecideDatabaseQuotaForSecurityOriginDatabaseNameDisplayNameCurrentQuotaCurrentOriginUsageCurrentDatabaseUsageExpectedUsageDecisionHandler = [delegate respondsToSelector:@selector(_webView:decideDatabaseQuotaForSecurityOrigin:databaseName:displayName:currentQuota:currentOriginUsage:currentDatabaseUsage:expectedUsage:decisionHandler:)];
</span><span class="cx">     m_delegateMethods.webViewDecideWebApplicationCacheQuotaForSecurityOriginCurrentQuotaTotalBytesNeeded = [delegate respondsToSelector:@selector(_webView:decideWebApplicationCacheQuotaForSecurityOrigin:currentQuota:totalBytesNeeded:decisionHandler:)];
</span><span class="lines">@@ -844,6 +847,26 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if ENABLE(DEVICE_ORIENTATION)
+void UIDelegate::UIClient::shouldAllowDeviceOrientationAndMotionAccess(WebKit::WebPageProxy&, API::SecurityOrigin& securityOrigin, CompletionHandler<void(bool)>&& completionHandler)
+{
+    if (!m_uiDelegate.m_delegateMethods.webViewShouldAllowDeviceOrientationAndMotionAccessForSecurityOriginDecisionHandler)
+        return completionHandler(true);
+
+    auto delegate = m_uiDelegate.m_delegate.get();
+    if (!delegate)
+        return completionHandler(true);
+
+    auto checker = CompletionHandlerCallChecker::create(delegate.get(), @selector(_webView:shouldAllowDeviceOrientationAndMotionAccessForSecurityOrigin:decisionHandler:));
+    [(id <WKUIDelegatePrivate>)delegate _webView:m_uiDelegate.m_webView shouldAllowDeviceOrientationAndMotionAccessForSecurityOrigin:wrapper(securityOrigin) decisionHandler:makeBlockPtr([completionHandler = WTFMove(completionHandler), checker = WTFMove(checker)] (BOOL granted) mutable {
+        if (checker->completionHandlerHasBeenCalled())
+            return;
+        checker->didCallCompletionHandler();
+        completionHandler(granted);
+    }).get()];
+}
+#endif
+
</ins><span class="cx"> void UIDelegate::UIClient::didChangeFontAttributes(const WebCore::FontAttributes& fontAttributes)
</span><span class="cx"> {
</span><span class="cx">     if (!needsFontAttributes())
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessCocoaVersionChecksh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/Cocoa/VersionChecks.h (242663 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/Cocoa/VersionChecks.h      2019-03-09 00:17:37 UTC (rev 242663)
+++ trunk/Source/WebKit/UIProcess/Cocoa/VersionChecks.h 2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -38,6 +38,10 @@
</span><span class="cx"> #define DYLD_MACOS_VERSION_FIRST_WHERE_DOWNLOAD_ATTRIBUTE_DOES_NOT_OVERRIDE_NAVIGATION_DELEGATE 0
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#ifndef DYLD_IOS_VERSION_FIRST_WITH_DEVICE_ORIENTATION_AND_MOTION_PERMISSION_API
+#define DYLD_IOS_VERSION_FIRST_WITH_DEVICE_ORIENTATION_AND_MOTION_PERMISSION_API 0
+#endif
+
</ins><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><span class="cx"> enum class SDKVersion : uint32_t {
</span><span class="lines">@@ -56,6 +60,7 @@
</span><span class="cx">     FirstWithProcessSwapOnCrossSiteNavigation = DYLD_IOS_VERSION_FIRST_WITH_PROCESS_SWAP_ON_CROSS_SITE_NAVIGATION,
</span><span class="cx">     FirstWithSnapshotAfterScreenUpdates = DYLD_IOS_VERSION_FIRST_WITH_SNAPSHOT_AFTER_SCREEN_UPDATES,
</span><span class="cx">     FirstWhereDownloadAttributeDoesNotOverrideNavigationDelegate = DYLD_IOS_VERSION_FIRST_WHERE_DOWNLOAD_ATTRIBUTE_DOES_NOT_OVERRIDE_NAVIGATION_DELEGATE,
</span><ins>+    FirstWithDeviceOrientationAndMotionPermissionAPI = DYLD_IOS_VERSION_FIRST_WITH_DEVICE_ORIENTATION_AND_MOTION_PERMISSION_API,
</ins><span class="cx"> #elif PLATFORM(MAC)
</span><span class="cx">     FirstWithNetworkCache = DYLD_MACOSX_VERSION_10_11,
</span><span class="cx">     FirstWithExceptionsForDuplicateCompletionHandlerCalls = DYLD_MACOSX_VERSION_10_13,
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessWebPageProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (242663 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp   2019-03-09 00:17:37 UTC (rev 242663)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp      2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -7174,6 +7174,18 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#if ENABLE(DEVICE_ORIENTATION)
+void WebPageProxy::requestDeviceOrientationAndMotionAccess(WebCore::SecurityOriginData&& originData, uint64_t callbackID)
+{
+    auto origin = API::SecurityOrigin::create(originData.securityOrigin());
+    m_uiClient->shouldAllowDeviceOrientationAndMotionAccess(*this, origin.get(), [this, weakThis = makeWeakPtr(*this), callbackID](bool granted) {
+        if (!weakThis || !isValid())
+            return;
+        m_process->send(Messages::WebPage::DidReceiveDeviceOrientationAndMotionAccessDecision(callbackID, granted), m_pageID);
+    });
+}
+#endif
+
</ins><span class="cx"> void WebPageProxy::requestNotificationPermission(uint64_t requestID, const String& originString)
</span><span class="cx"> {
</span><span class="cx">     if (!isRequestIDValid(requestID))
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessWebPageProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (242663 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/WebPageProxy.h     2019-03-09 00:17:37 UTC (rev 242663)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h        2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -1401,6 +1401,10 @@
</span><span class="cx">     void requestStorageAccessConfirm(const WebCore::RegistrableDomain& subFrameDomain, const WebCore::RegistrableDomain& topFrameDomain, uint64_t frameID, CompletionHandler<void(bool)>&&);
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if ENABLE(DEVICE_ORIENTATION)
+    void requestDeviceOrientationAndMotionAccess(WebCore::SecurityOriginData&&, uint64_t callbackID);
+#endif
+
</ins><span class="cx">     static WebPageProxy* nonEphemeralWebPageProxy();
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(ATTACHMENT_ELEMENT)
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessWebPageProxymessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in (242663 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in   2019-03-09 00:17:37 UTC (rev 242663)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in      2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -533,6 +533,10 @@
</span><span class="cx">     StopURLSchemeTask(uint64_t handlerIdentifier, uint64_t taskIdentifier)
</span><span class="cx">     LoadSynchronousURLSchemeTask(struct WebKit::URLSchemeTaskParameters parameters) -> (WebCore::ResourceResponse response, WebCore::ResourceError error, IPC::DataReference data) Delayed
</span><span class="cx"> 
</span><ins>+#if ENABLE(DEVICE_ORIENTATION)
+    RequestDeviceOrientationAndMotionAccess(struct WebCore::SecurityOriginData origin, uint64_t callbackID);
+#endif
+
</ins><span class="cx"> #if ENABLE(ATTACHMENT_ELEMENT)
</span><span class="cx">     RegisterAttachmentIdentifierFromData(String identifier, String contentType, String preferredFileName, IPC::SharedBufferDataReference data)
</span><span class="cx">     RegisterAttachmentIdentifierFromFilePath(String identifier, String contentType, String filePath)
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebCoreSupportWebChromeClientcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp (242663 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp        2019-03-09 00:17:37 UTC (rev 242663)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp   2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -1320,4 +1320,11 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if ENABLE(DEVICE_ORIENTATION)
+void WebChromeClient::shouldAllowDeviceOrientationAndMotionAccess(const SecurityOrigin& origin, CompletionHandler<void(bool)>&& callback)
+{
+    m_page.shouldAllowDeviceOrientationAndMotionAccess(origin, WTFMove(callback));
+}
+#endif
+
</ins><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebCoreSupportWebChromeClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h (242663 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h  2019-03-09 00:17:37 UTC (rev 242663)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h     2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -366,6 +366,10 @@
</span><span class="cx">     void requestStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, WTF::CompletionHandler<void (bool)>&&) final;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if ENABLE(DEVICE_ORIENTATION)
+    void shouldAllowDeviceOrientationAndMotionAccess(const WebCore::SecurityOrigin&, CompletionHandler<void(bool)>&&) final;
+#endif
+
</ins><span class="cx">     String m_cachedToolTip;
</span><span class="cx">     mutable RefPtr<WebFrame> m_cachedFrameSetLargestFrame;
</span><span class="cx">     mutable bool m_cachedMainFrameHasHorizontalScrollbar { false };
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebPageWebPagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (242663 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp       2019-03-09 00:17:37 UTC (rev 242663)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp  2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -6339,6 +6339,30 @@
</span><span class="cx">     WebProcess::singleton().ensureNetworkProcessConnection().connection().sendWithAsyncReply(Messages::NetworkConnectionToWebProcess::RequestStorageAccess(sessionID(), RegistrableDomain::uncheckedCreateFromHost(subFrameHost), RegistrableDomain::uncheckedCreateFromHost(topFrameHost), frameID, m_pageID, promptEnabled), WTFMove(completionHandler));
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><ins>+
+#if ENABLE(DEVICE_ORIENTATION)
+static uint64_t nextDeviceOrientationAndMotionPermissionCallbackID()
+{
+    static uint64_t nextCallbackID = 0;
+    return ++nextCallbackID;
+}
+
+void WebPage::shouldAllowDeviceOrientationAndMotionAccess(const WebCore::SecurityOrigin& origin, CompletionHandler<void(bool)>&& callback)
+{
+    auto callbackID = nextDeviceOrientationAndMotionPermissionCallbackID();
+    ASSERT(!m_deviceOrientationAndMotionPermissionCallbackMap.contains(callbackID));
+    m_deviceOrientationAndMotionPermissionCallbackMap.add(callbackID, WTFMove(callback));
+
+    send(Messages::WebPageProxy::RequestDeviceOrientationAndMotionAccess(origin.data(), callbackID));
+}
+
+void WebPage::didReceiveDeviceOrientationAndMotionAccessDecision(uint64_t callbackID, bool granted)
+{
+    auto callback = m_deviceOrientationAndMotionPermissionCallbackMap.take(callbackID);
+    ASSERT(callback);
+    callback(granted);
+}
+#endif
</ins><span class="cx">     
</span><span class="cx"> static ShareSheetCallbackID nextShareSheetCallbackID()
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebPageWebPageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (242663 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2019-03-09 00:17:37 UTC (rev 242663)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h    2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -1110,6 +1110,10 @@
</span><span class="cx">     void requestStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, CompletionHandler<void(bool)>&& callback);
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if ENABLE(DEVICE_ORIENTATION)
+    void shouldAllowDeviceOrientationAndMotionAccess(const WebCore::SecurityOrigin&, CompletionHandler<void(bool)>&&);
+#endif
+
</ins><span class="cx">     void showShareSheet(WebCore::ShareDataWithParsedURL&, WTF::CompletionHandler<void(bool)>&& callback);
</span><span class="cx">     void didCompleteShareSheet(bool wasCompleted, ShareSheetCallbackID contextId);
</span><span class="cx">     
</span><span class="lines">@@ -1206,6 +1210,10 @@
</span><span class="cx">     void requestAdditionalItemsForDragSession(const WebCore::IntPoint& clientPosition, const WebCore::IntPoint& globalPosition);
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if ENABLE(DEVICE_ORIENTATION)
+    void didReceiveDeviceOrientationAndMotionAccessDecision(uint64_t callbackID, bool granted);
+#endif
+
</ins><span class="cx"> #if !PLATFORM(COCOA) && !PLATFORM(WPE)
</span><span class="cx">     static const char* interpretKeyEvent(const WebCore::KeyboardEvent*);
</span><span class="cx"> #endif
</span><span class="lines">@@ -1836,6 +1844,10 @@
</span><span class="cx">     HashMap<uint64_t, WTF::Function<void(bool granted)>> m_storageAccessResponseCallbackMap;
</span><span class="cx">     HashMap<ShareSheetCallbackID, WTF::Function<void(bool completed)>> m_shareSheetResponseCallbackMap;
</span><span class="cx"> 
</span><ins>+#if ENABLE(DEVICE_ORIENTATION)
+    HashMap<uint64_t, WTF::CompletionHandler<void(bool granted)>> m_deviceOrientationAndMotionPermissionCallbackMap;
+#endif
+
</ins><span class="cx"> #if ENABLE(APPLICATION_MANIFEST)
</span><span class="cx">     HashMap<uint64_t, uint64_t> m_applicationManifestFetchCallbackMap;
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebPageWebPagemessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in (242663 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in       2019-03-09 00:17:37 UTC (rev 242663)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in  2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -363,6 +363,10 @@
</span><span class="cx">     # Notification
</span><span class="cx">     DidReceiveNotificationPermissionDecision(uint64_t notificationID, bool allowed)
</span><span class="cx"> 
</span><ins>+#if ENABLE(DEVICE_ORIENTATION)
+    DidReceiveDeviceOrientationAndMotionAccessDecision(uint64_t callbackID, bool granted)
+#endif
+
</ins><span class="cx">     # Printing.
</span><span class="cx">     BeginPrinting(uint64_t frameID, struct WebKit::PrintInfo printInfo)
</span><span class="cx">     EndPrinting()
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (242663 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog    2019-03-09 00:17:37 UTC (rev 242663)
+++ trunk/Tools/ChangeLog       2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -1,3 +1,27 @@
</span><ins>+2019-03-08  Chris Dumez  <cdumez@apple.com>
+
+        Add support for Device Orientation / Motion permission API
+        https://bugs.webkit.org/show_bug.cgi?id=195329
+        <rdar://problem/47645367>
+
+        Reviewed by Geoffrey Garen.
+
+        Add test infrastructure to help test the Device Orientation / Motion permission API.
+
+        * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
+        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
+        (WTR::TestRunner::setShouldAllowDeviceOrientationAndMotionAccess):
+        * WebKitTestRunner/InjectedBundle/TestRunner.h:
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::shouldAllowDeviceOrientationAndMotionAccess):
+        (WTR::TestController::createWebViewWithOptions):
+        (WTR::TestController::resetStateToConsistentValues):
+        (WTR::TestController::handleDeviceOrientationAndMotionAccessRequest):
+        * WebKitTestRunner/TestController.h:
+        (WTR::TestController::setShouldAllowDeviceOrientationAndMotionAccess):
+        * WebKitTestRunner/TestInvocation.cpp:
+        (WTR::TestInvocation::didReceiveMessageFromInjectedBundle):
+
</ins><span class="cx"> 2019-03-08  Saam barati  <sbarati@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Add a compare-results script to compare benchmark results
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerInjectedBundleBindingsTestRunneridl"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl (242663 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl      2019-03-09 00:17:37 UTC (rev 242663)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl 2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -104,6 +104,9 @@
</span><span class="cx">     boolean isCommandEnabled(DOMString name);
</span><span class="cx">     unsigned long windowCount();
</span><span class="cx"> 
</span><ins>+    // Device Orientation Motion.
+    void setShouldAllowDeviceOrientationAndMotionAccess(boolean value);
+
</ins><span class="cx">     // Special DOM variables.
</span><span class="cx">     attribute boolean globalFlag;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerInjectedBundleTestRunnercpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp (242663 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp       2019-03-09 00:17:37 UTC (rev 242663)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp  2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -1294,6 +1294,13 @@
</span><span class="cx">     WKBundlePagePostMessage(InjectedBundle::singleton().page()->page(), messageName.get(), messageBody.get());
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void TestRunner::setShouldAllowDeviceOrientationAndMotionAccess(bool value)
+{
+    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetShouldAllowDeviceOrientationAndMotionAccess"));
+    WKRetainPtr<WKBooleanRef> messageBody(AdoptWK, WKBooleanCreate(value));
+    WKBundlePagePostMessage(InjectedBundle::singleton().page()->page(), messageName.get(), messageBody.get());
+}
+
</ins><span class="cx"> void TestRunner::terminateNetworkProcess()
</span><span class="cx"> {
</span><span class="cx">     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("TerminateNetworkProcess"));
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerInjectedBundleTestRunnerh"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h (242663 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h 2019-03-09 00:17:37 UTC (rev 242663)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h    2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -348,6 +348,7 @@
</span><span class="cx">     void setNavigationGesturesEnabled(bool);
</span><span class="cx">     void setIgnoresViewportScaleLimits(bool);
</span><span class="cx">     void setShouldDownloadUndisplayableMIMETypes(bool);
</span><ins>+    void setShouldAllowDeviceOrientationAndMotionAccess(bool);
</ins><span class="cx"> 
</span><span class="cx">     bool didCancelClientRedirect() const { return m_didCancelClientRedirect; }
</span><span class="cx">     void setDidCancelClientRedirect(bool value) { m_didCancelClientRedirect = value; }
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerTestControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/TestController.cpp (242663 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/TestController.cpp  2019-03-09 00:17:37 UTC (rev 242663)
+++ trunk/Tools/WebKitTestRunner/TestController.cpp     2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -262,6 +262,11 @@
</span><span class="cx">     WKPageDidAllowPointerLock(page);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static bool shouldAllowDeviceOrientationAndMotionAccess(WKPageRef, WKSecurityOriginRef origin, const void*)
+{
+    return TestController::singleton().handleDeviceOrientationAndMotionAccessRequest(origin);
+}
+
</ins><span class="cx"> WKPageRef TestController::createOtherPage(WKPageRef, WKPageConfigurationRef configuration, WKNavigationActionRef navigationAction, WKWindowFeaturesRef windowFeatures, const void *clientInfo)
</span><span class="cx"> {
</span><span class="cx">     PlatformWebView* parentView = static_cast<PlatformWebView*>(const_cast<void*>(clientInfo));
</span><span class="lines">@@ -570,8 +575,8 @@
</span><span class="cx">     resetPreferencesToConsistentValues(options);
</span><span class="cx"> 
</span><span class="cx">     platformCreateWebView(configuration.get(), options);
</span><del>-    WKPageUIClientV8 pageUIClient = {
-        { 8, m_mainWebView.get() },
</del><ins>+    WKPageUIClientV13 pageUIClient = {
+        { 13, m_mainWebView.get() },
</ins><span class="cx">         0, // createNewPage_deprecatedForUseWithV0
</span><span class="cx">         0, // showPage
</span><span class="cx">         0, // close
</span><span class="lines">@@ -637,7 +642,13 @@
</span><span class="cx">         0, // runBeforeUnloadConfirmPanel
</span><span class="cx">         0, // fullscreenMayReturnToInline
</span><span class="cx">         requestPointerLock,
</span><del>-        0,
</del><ins>+        0, // didLosePointerLock
+        0, // handleAutoplayEvent
+        0, // hasVideoInPictureInPictureDidChange
+        0, // didExceedBackgroundResourceLimitWhileInForeground
+        0, // didResignInputElementStrongPasswordAppearance
+        0, // requestStorageAccessConfirm
+        shouldAllowDeviceOrientationAndMotionAccess
</ins><span class="cx">     };
</span><span class="cx">     WKPageSetPageUIClient(m_mainWebView->page(), &pageUIClient.base);
</span><span class="cx"> 
</span><span class="lines">@@ -943,6 +954,8 @@
</span><span class="cx"> 
</span><span class="cx">     m_shouldDownloadUndisplayableMIMETypes = false;
</span><span class="cx"> 
</span><ins>+    m_shouldAllowDeviceOrientationAndMotionAccess = false;
+
</ins><span class="cx">     m_workQueueManager.clearWorkQueue();
</span><span class="cx"> 
</span><span class="cx">     m_rejectsProtectionSpaceAndContinueForAuthenticationChallenges = false;
</span><span class="lines">@@ -2548,6 +2561,12 @@
</span><span class="cx">     WKUserMediaPermissionCheckSetUserMediaAccessInfo(checkRequest, saltString.get(), settingsForOrigin(originHash).persistentPermission());
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool TestController::handleDeviceOrientationAndMotionAccessRequest(WKSecurityOriginRef origin)
+{
+    m_currentInvocation->outputText(makeString("Received device orientation & motion access request for security origin \"", originUserVisibleName(origin), "\".\n"));
+    return m_shouldAllowDeviceOrientationAndMotionAccess;
+}
+
</ins><span class="cx"> void TestController::handleUserMediaPermissionRequest(WKFrameRef frame, WKSecurityOriginRef userMediaDocumentOrigin, WKSecurityOriginRef topLevelDocumentOrigin, WKUserMediaPermissionRequestRef request)
</span><span class="cx"> {
</span><span class="cx">     auto originHash = userMediaOriginHash(userMediaDocumentOrigin, topLevelDocumentOrigin);
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerTestControllerh"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/TestController.h (242663 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/TestController.h    2019-03-09 00:17:37 UTC (rev 242663)
+++ trunk/Tools/WebKitTestRunner/TestController.h       2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -150,6 +150,9 @@
</span><span class="cx">     unsigned userMediaPermissionRequestCountForOrigin(WKStringRef userMediaDocumentOriginString, WKStringRef topLevelDocumentOriginString);
</span><span class="cx">     void resetUserMediaPermissionRequestCountForOrigin(WKStringRef userMediaDocumentOriginString, WKStringRef topLevelDocumentOriginString);
</span><span class="cx"> 
</span><ins>+    // Device Orientation / Motion.
+    bool handleDeviceOrientationAndMotionAccessRequest(WKSecurityOriginRef);
+
</ins><span class="cx">     // Content Extensions.
</span><span class="cx">     void configureContentExtensionForTest(const TestInvocation&);
</span><span class="cx">     void resetContentExtensions();
</span><span class="lines">@@ -199,6 +202,7 @@
</span><span class="cx">     void setIgnoresViewportScaleLimits(bool);
</span><span class="cx"> 
</span><span class="cx">     void setShouldDownloadUndisplayableMIMETypes(bool value) { m_shouldDownloadUndisplayableMIMETypes = value; }
</span><ins>+    void setShouldAllowDeviceOrientationAndMotionAccess(bool value) { m_shouldAllowDeviceOrientationAndMotionAccess = value; }
</ins><span class="cx"> 
</span><span class="cx">     void setStatisticsDebugMode(bool value);
</span><span class="cx">     void setStatisticsPrevalentResourceForDebugMode(WKStringRef hostName);
</span><span class="lines">@@ -509,6 +513,7 @@
</span><span class="cx">     bool m_policyDelegateEnabled { false };
</span><span class="cx">     bool m_policyDelegatePermissive { false };
</span><span class="cx">     bool m_shouldDownloadUndisplayableMIMETypes { false };
</span><ins>+    bool m_shouldAllowDeviceOrientationAndMotionAccess { false };
</ins><span class="cx"> 
</span><span class="cx">     bool m_rejectsProtectionSpaceAndContinueForAuthenticationChallenges { false };
</span><span class="cx">     bool m_handlesAuthenticationChallenges { false };
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerTestInvocationcpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/TestInvocation.cpp (242663 => 242664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/TestInvocation.cpp  2019-03-09 00:17:37 UTC (rev 242663)
+++ trunk/Tools/WebKitTestRunner/TestInvocation.cpp     2019-03-09 00:30:45 UTC (rev 242664)
</span><span class="lines">@@ -747,6 +747,13 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    if (WKStringIsEqualToUTF8CString(messageName, "SetShouldAllowDeviceOrientationAndMotionAccess")) {
+        ASSERT(WKGetTypeID(messageBody) == WKBooleanGetTypeID());
+        WKBooleanRef value = static_cast<WKBooleanRef>(messageBody);
+        TestController::singleton().setShouldAllowDeviceOrientationAndMotionAccess(WKBooleanGetValue(value));
+        return;
+    }
+
</ins><span class="cx">     if (WKStringIsEqualToUTF8CString(messageName, "RunUIProcessScript")) {
</span><span class="cx">         WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody);
</span><span class="cx">         WKRetainPtr<WKStringRef> scriptKey(AdoptWK, WKStringCreateWithUTF8CString("Script"));
</span></span></pre>
</div>
</div>

</body>
</html>