| Differences between
and this patch
- a/Source/WebCore/ChangeLog +55 lines
Lines 1-3 a/Source/WebCore/ChangeLog_sec1
1
2019-03-05  Chris Dumez  <cdumez@apple.com>
2
3
        Add support for Device Orientation / Motion permission API
4
        https://bugs.webkit.org/show_bug.cgi?id=195329
5
        <rdar://problem/47645367>
6
7
        Reviewed by NOBODY (OOPS!).
8
9
        Add support for Device Orientation / Motion permission API:
10
        - https://github.com/w3c/deviceorientation/issues/57
11
12
        Pages can add event listeners for 'deviceorientation' / 'devicemotion' events but
13
        such events will not be fired until the page's JavaScript calls
14
        DeviceOrientationEvent.requestPermission() / DeviceMotionEvent.requestPermission()
15
        and the user grants the request.
16
17
        The feature is currently behind an experimental feature flag, off by default.
18
19
        Tests: fast/device-orientation/device-motion-request-permission-denied.html
20
               fast/device-orientation/device-motion-request-permission-granted.html
21
               fast/device-orientation/device-orientation-request-permission-denied.html
22
               fast/device-orientation/device-orientation-request-permission-granted.html
23
24
        * dom/DeviceMotionEvent.cpp:
25
        (WebCore::DeviceMotionEvent::requestPermission):
26
        * dom/DeviceMotionEvent.h:
27
        * dom/DeviceMotionEvent.idl:
28
        * dom/DeviceOrientationEvent.cpp:
29
        (WebCore::DeviceOrientationEvent::requestPermission):
30
        * dom/DeviceOrientationEvent.h:
31
        * dom/DeviceOrientationEvent.idl:
32
        * dom/Document.cpp:
33
        (WebCore::Document::deviceOrientationAccessState const):
34
        (WebCore::Document::setDeviceOrientationAccessState):
35
        (WebCore::Document::deviceMotionAccessState const):
36
        (WebCore::Document::setDeviceMotionAccessState):
37
        * dom/Document.h:
38
        * page/ChromeClient.h:
39
        * page/DOMWindow.cpp:
40
        (WebCore::DOMWindow::addEventListener):
41
        (WebCore::DOMWindow::deviceOrientationController const):
42
        (WebCore::DOMWindow::deviceMotionController const):
43
        (WebCore::DOMWindow::isAllowedToUseDeviceMotionOrientation const):
44
        (WebCore::DOMWindow::startListeningForDeviceOrientationIfNecessary):
45
        (WebCore::DOMWindow::stopListeningForDeviceOrientationIfNecessary):
46
        (WebCore::DOMWindow::startListeningForDeviceMotionIfNecessary):
47
        (WebCore::DOMWindow::stopListeningForDeviceMotionIfNecessary):
48
        (WebCore::DOMWindow::removeEventListener):
49
        (WebCore::DOMWindow::removeAllEventListeners):
50
        * page/DOMWindow.h:
51
        * page/DeviceController.cpp:
52
        (WebCore::DeviceController::hasDeviceEventListener const):
53
        * page/DeviceController.h:
54
        * page/Settings.yaml:
55
1
2019-03-04  Chris Dumez  <cdumez@apple.com>
56
2019-03-04  Chris Dumez  <cdumez@apple.com>
2
57
3
        [iOS] Improve our file picker
58
        [iOS] Improve our file picker
- a/Source/WebKit/ChangeLog +43 lines
Lines 1-3 a/Source/WebKit/ChangeLog_sec1
1
2019-03-05  Chris Dumez  <cdumez@apple.com>
2
3
        Add support for Device Orientation / Motion permission API
4
        https://bugs.webkit.org/show_bug.cgi?id=195329
5
        <rdar://problem/47645367>
6
7
        Reviewed by NOBODY (OOPS!).
8
9
        Add support for Device Orientation / Motion permission API:
10
        - https://github.com/w3c/deviceorientation/issues/57
11
12
        This adds new public API on WKUIDelegate.
13
14
        * Shared/WebPreferences.yaml:
15
        * UIProcess/API/APIUIClient.h:
16
        (API::UIClient::requestDeviceOrientationAccessPermission):
17
        (API::UIClient::requestDeviceMotionAccessPermission):
18
        * UIProcess/API/C/WKPage.cpp:
19
        (WKPageSetPageUIClient):
20
        * UIProcess/API/C/WKPageUIClient.h:
21
        * UIProcess/API/Cocoa/WKUIDelegate.h:
22
        * UIProcess/Cocoa/UIDelegate.h:
23
        * UIProcess/Cocoa/UIDelegate.mm:
24
        (WebKit::UIDelegate::setDelegate):
25
        (WebKit::UIDelegate::UIClient::requestDeviceOrientationAccessPermission):
26
        (WebKit::UIDelegate::UIClient::requestDeviceMotionAccessPermission):
27
        * UIProcess/WebPageProxy.cpp:
28
        (WebKit::WebPageProxy::requestDeviceOrientationAccessPermission):
29
        (WebKit::WebPageProxy::requestDeviceMotionAccessPermission):
30
        * UIProcess/WebPageProxy.h:
31
        * UIProcess/WebPageProxy.messages.in:
32
        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
33
        (WebKit::WebChromeClient::requestDeviceOrientationAccessPermission):
34
        (WebKit::WebChromeClient::requestDeviceMotionAccessPermission):
35
        * WebProcess/WebCoreSupport/WebChromeClient.h:
36
        * WebProcess/WebPage/WebPage.cpp:
37
        (WebKit::nextDeviceOrientationMotionPermissionCallbackID):
38
        (WebKit::WebPage::requestDeviceOrientationAccessPermission):
39
        (WebKit::WebPage::requestDeviceMotionAccessPermission):
40
        (WebKit::WebPage::didReceiveDeviceOrientationMotionAccessPermissionDecision):
41
        * WebProcess/WebPage/WebPage.h:
42
        * WebProcess/WebPage/WebPage.messages.in:
43
1
2019-03-04  Chris Dumez  <cdumez@apple.com>
44
2019-03-04  Chris Dumez  <cdumez@apple.com>
2
45
3
        Do not share WebProcesses between private and regular sessions
46
        Do not share WebProcesses between private and regular sessions
- a/Source/WebCore/dom/DeviceMotionEvent.cpp +32 lines
Lines 26-32 a/Source/WebCore/dom/DeviceMotionEvent.cpp_sec1
26
#include "config.h"
26
#include "config.h"
27
#include "DeviceMotionEvent.h"
27
#include "DeviceMotionEvent.h"
28
28
29
#include "Chrome.h"
30
#include "ChromeClient.h"
29
#include "DeviceMotionData.h"
31
#include "DeviceMotionData.h"
32
#include "Document.h"
33
#include "SecurityOrigin.h"
30
34
31
namespace WebCore {
35
namespace WebCore {
32
36
Lines 122-125 EventInterface DeviceMotionEvent::eventInterface() const a/Source/WebCore/dom/DeviceMotionEvent.cpp_sec2
122
#endif
126
#endif
123
}
127
}
124
128
129
#if ENABLE(DEVICE_ORIENTATION)
130
void DeviceMotionEvent::requestPermission(Document& document, PermissionPromise&& promise)
131
{
132
    auto* window = document.domWindow();
133
    if (!window)
134
        return promise.resolve(PermissionState::Denied);
135
136
    String errorMessage;
137
    if (!window->isAllowedToUseDeviceMotionOrientation(errorMessage)) {
138
        document.addConsoleMessage(MessageSource::JS, MessageLevel::Warning, makeString("Call to DeviceMotionEvent.requestPermission() failed, reason: ", errorMessage, "."));
139
        return promise.resolve(PermissionState::Denied);
140
    }
141
142
    if (auto permissionState = document.deviceMotionAccessState())
143
        return promise.resolve(*permissionState ? PermissionState::Granted : PermissionState::Denied);
144
145
    auto* page = document.page();
146
    if (!page)
147
        return promise.resolve(PermissionState::Denied);
148
149
    page->chrome().client().requestDeviceMotionAccessPermission(document.topOrigin(), [document = makeWeakPtr(document), promise = WTFMove(promise)](bool granted) mutable {
150
        if (document)
151
            document->setDeviceMotionAccessState(granted);
152
        promise.resolve(granted ? PermissionState::Granted : PermissionState::Denied);
153
    });
154
}
155
#endif
156
125
} // namespace WebCore
157
} // namespace WebCore
- a/Source/WebCore/dom/DeviceMotionEvent.h +8 lines
Lines 26-35 a/Source/WebCore/dom/DeviceMotionEvent.h_sec1
26
#pragma once
26
#pragma once
27
27
28
#include "Event.h"
28
#include "Event.h"
29
#include "JSDOMPromiseDeferred.h"
29
30
30
namespace WebCore {
31
namespace WebCore {
31
32
32
class DeviceMotionData;
33
class DeviceMotionData;
34
class Document;
33
35
34
class DeviceMotionEvent final : public Event {
36
class DeviceMotionEvent final : public Event {
35
public:
37
public:
Lines 66-71 public: a/Source/WebCore/dom/DeviceMotionEvent.h_sec2
66
68
67
    void initDeviceMotionEvent(const AtomicString& type, bool bubbles, bool cancelable, Optional<Acceleration>&&, Optional<Acceleration>&&, Optional<RotationRate>&&, Optional<double>);
69
    void initDeviceMotionEvent(const AtomicString& type, bool bubbles, bool cancelable, Optional<Acceleration>&&, Optional<Acceleration>&&, Optional<RotationRate>&&, Optional<double>);
68
70
71
#if ENABLE(DEVICE_ORIENTATION)
72
    enum class PermissionState { Granted, Denied };
73
    using PermissionPromise = DOMPromiseDeferred<IDLEnumeration<PermissionState>>;
74
    static void requestPermission(Document&, PermissionPromise&&);
75
#endif
76
69
private:
77
private:
70
    DeviceMotionEvent();
78
    DeviceMotionEvent();
71
    DeviceMotionEvent(const AtomicString& eventType, DeviceMotionData*);
79
    DeviceMotionEvent(const AtomicString& eventType, DeviceMotionData*);
- a/Source/WebCore/dom/DeviceMotionEvent.idl +4 lines
Lines 31-36 a/Source/WebCore/dom/DeviceMotionEvent.idl_sec1
31
    readonly attribute RotationRate? rotationRate;
31
    readonly attribute RotationRate? rotationRate;
32
    readonly attribute unrestricted double? interval;
32
    readonly attribute unrestricted double? interval;
33
33
34
    [CallWith=Document, EnabledBySetting=DeviceOrientationPermissionAPI] static Promise<PermissionState> requestPermission();
35
34
    void initDeviceMotionEvent(optional DOMString type = "",
36
    void initDeviceMotionEvent(optional DOMString type = "",
35
                               optional boolean bubbles = false,
37
                               optional boolean bubbles = false,
36
                               optional boolean cancelable = false,
38
                               optional boolean cancelable = false,
Lines 57-59 a/Source/WebCore/dom/DeviceMotionEvent.idl_sec2
57
    double? beta;
59
    double? beta;
58
    double? gamma;
60
    double? gamma;
59
};
61
};
62
63
enum PermissionState { "granted", "denied" };
- a/Source/WebCore/dom/DeviceOrientationEvent.cpp +32 lines
Lines 26-32 a/Source/WebCore/dom/DeviceOrientationEvent.cpp_sec1
26
#include "config.h"
26
#include "config.h"
27
#include "DeviceOrientationEvent.h"
27
#include "DeviceOrientationEvent.h"
28
28
29
#include "Chrome.h"
30
#include "ChromeClient.h"
29
#include "DeviceOrientationData.h"
31
#include "DeviceOrientationData.h"
32
#include "Document.h"
33
#include "SecurityOrigin.h"
30
34
31
namespace WebCore {
35
namespace WebCore {
32
36
Lines 109-112 EventInterface DeviceOrientationEvent::eventInterface() const a/Source/WebCore/dom/DeviceOrientationEvent.cpp_sec2
109
#endif
113
#endif
110
}
114
}
111
115
116
#if ENABLE(DEVICE_ORIENTATION)
117
void DeviceOrientationEvent::requestPermission(Document& document, PermissionPromise&& promise)
118
{
119
    auto* window = document.domWindow();
120
    if (!window)
121
        return promise.resolve(PermissionState::Denied);
122
123
    String errorMessage;
124
    if (!window->isAllowedToUseDeviceMotionOrientation(errorMessage)) {
125
        document.addConsoleMessage(MessageSource::JS, MessageLevel::Warning, makeString("Call to DeviceOrientationEvent.requestPermission() failed, reason: ", errorMessage, "."));
126
        return promise.resolve(PermissionState::Denied);
127
    }
128
129
    if (auto permissionState = document.deviceOrientationAccessState())
130
        return promise.resolve(*permissionState ? PermissionState::Granted : PermissionState::Denied);
131
132
    auto* page = document.page();
133
    if (!page)
134
        return promise.resolve(PermissionState::Denied);
135
136
    page->chrome().client().requestDeviceOrientationAccessPermission(document.topOrigin(), [document = makeWeakPtr(document), promise = WTFMove(promise)](bool granted) mutable {
137
        if (document)
138
            document->setDeviceOrientationAccessState(granted);
139
        promise.resolve(granted ? PermissionState::Granted : PermissionState::Denied);
140
    });
141
}
142
#endif
143
112
} // namespace WebCore
144
} // namespace WebCore
- a/Source/WebCore/dom/DeviceOrientationEvent.h +8 lines
Lines 26-35 a/Source/WebCore/dom/DeviceOrientationEvent.h_sec1
26
#pragma once
26
#pragma once
27
27
28
#include "Event.h"
28
#include "Event.h"
29
#include "JSDOMPromiseDeferred.h"
29
30
30
namespace WebCore {
31
namespace WebCore {
31
32
32
class DeviceOrientationData;
33
class DeviceOrientationData;
34
class Document;
33
35
34
class DeviceOrientationEvent final : public Event {
36
class DeviceOrientationEvent final : public Event {
35
public:
37
public:
Lines 60-65 public: a/Source/WebCore/dom/DeviceOrientationEvent.h_sec2
60
    void initDeviceOrientationEvent(const AtomicString& type, bool bubbles, bool cancelable, Optional<double> alpha, Optional<double> beta, Optional<double> gamma, Optional<bool> absolute);
62
    void initDeviceOrientationEvent(const AtomicString& type, bool bubbles, bool cancelable, Optional<double> alpha, Optional<double> beta, Optional<double> gamma, Optional<bool> absolute);
61
#endif
63
#endif
62
64
65
#if ENABLE(DEVICE_ORIENTATION)
66
    enum class PermissionState { Granted, Denied };
67
    using PermissionPromise = DOMPromiseDeferred<IDLEnumeration<PermissionState>>;
68
    static void requestPermission(Document&, PermissionPromise&&);
69
#endif
70
63
private:
71
private:
64
    DeviceOrientationEvent();
72
    DeviceOrientationEvent();
65
    DeviceOrientationEvent(const AtomicString& eventType, DeviceOrientationData*);
73
    DeviceOrientationEvent(const AtomicString& eventType, DeviceOrientationData*);
- a/Source/WebCore/dom/DeviceOrientationEvent.idl +3 lines
Lines 30-35 a/Source/WebCore/dom/DeviceOrientationEvent.idl_sec1
30
    readonly attribute unrestricted double? beta;
30
    readonly attribute unrestricted double? beta;
31
    readonly attribute unrestricted double? gamma;
31
    readonly attribute unrestricted double? gamma;
32
32
33
    [CallWith=Document, EnabledBySetting=DeviceOrientationPermissionAPI] static Promise<PermissionState> requestPermission();
34
33
    // FIXME: Consider defining an ENABLE macro for iOS device orientation code and/or modifying
35
    // FIXME: Consider defining an ENABLE macro for iOS device orientation code and/or modifying
34
    // the bindings scripts to support generating more complicated conditional code.
36
    // the bindings scripts to support generating more complicated conditional code.
35
#if defined(WTF_PLATFORM_IOS_FAMILY) && WTF_PLATFORM_IOS_FAMILY
37
#if defined(WTF_PLATFORM_IOS_FAMILY) && WTF_PLATFORM_IOS_FAMILY
Lines 55-57 a/Source/WebCore/dom/DeviceOrientationEvent.idl_sec2
55
#endif
57
#endif
56
};
58
};
57
59
60
enum PermissionState { "granted", "denied" };
- a/Source/WebCore/dom/Document.cpp +52 lines
Lines 8638-8643 void Document::frameWasDisconnectedFromOwner() a/Source/WebCore/dom/Document.cpp_sec1
8638
    detachFromFrame();
8638
    detachFromFrame();
8639
}
8639
}
8640
8640
8641
#if ENABLE(DEVICE_ORIENTATION)
8642
8643
const Optional<bool>& Document::deviceOrientationAccessState() const
8644
{
8645
    if (&topDocument() != this)
8646
        return topDocument().deviceOrientationAccessState();
8647
8648
    return m_deviceOrientationAccessState;
8649
}
8650
8651
void Document::setDeviceOrientationAccessState(bool granted)
8652
{
8653
    if (&topDocument() != this) {
8654
        topDocument().setDeviceOrientationAccessState(granted);
8655
        return;
8656
    }
8657
8658
    m_deviceOrientationAccessState = granted;
8659
8660
    if (!granted)
8661
        return;
8662
8663
    for (auto* frame = m_frame; frame && frame->window(); frame = frame->tree().traverseNext(m_frame))
8664
        frame->window()->startListeningForDeviceOrientationIfNecessary();
8665
}
8666
8667
const Optional<bool>& Document::deviceMotionAccessState() const
8668
{
8669
    if (&topDocument() != this)
8670
        return topDocument().deviceMotionAccessState();
8671
8672
    return m_deviceMotionAccessState;
8673
}
8674
8675
void Document::setDeviceMotionAccessState(bool granted)
8676
{
8677
    if (&topDocument() != this) {
8678
        topDocument().setDeviceMotionAccessState(granted);
8679
        return;
8680
    }
8681
8682
    m_deviceMotionAccessState = granted;
8683
8684
    if (!granted)
8685
        return;
8686
8687
    for (auto* frame = m_frame; frame && frame->window(); frame = frame->tree().traverseNext(m_frame))
8688
        frame->window()->startListeningForDeviceMotionIfNecessary();
8689
}
8690
8691
#endif
8692
8641
#if ENABLE(CSS_PAINTING_API)
8693
#if ENABLE(CSS_PAINTING_API)
8642
Worklet& Document::ensurePaintWorklet()
8694
Worklet& Document::ensurePaintWorklet()
8643
{
8695
{
- a/Source/WebCore/dom/Document.h -1 / +13 lines
Lines 1214-1225 public: a/Source/WebCore/dom/Document.h_sec1
1214
#include <WebKitAdditions/DocumentIOS.h>
1214
#include <WebKitAdditions/DocumentIOS.h>
1215
#endif
1215
#endif
1216
1216
1217
#if ENABLE(DEVICE_ORIENTATION) && PLATFORM(IOS_FAMILY)
1217
#if ENABLE(DEVICE_ORIENTATION)
1218
#if PLATFORM(IOS_FAMILY)
1218
    DeviceMotionController& deviceMotionController() const;
1219
    DeviceMotionController& deviceMotionController() const;
1219
    DeviceOrientationController& deviceOrientationController() const;
1220
    DeviceOrientationController& deviceOrientationController() const;
1220
    WEBCORE_EXPORT void simulateDeviceOrientationChange(double alpha, double beta, double gamma);
1221
    WEBCORE_EXPORT void simulateDeviceOrientationChange(double alpha, double beta, double gamma);
1221
#endif
1222
#endif
1222
1223
1224
    const Optional<bool>& deviceOrientationAccessState() const;
1225
    void setDeviceOrientationAccessState(bool granted);
1226
    const Optional<bool>& deviceMotionAccessState() const;
1227
    void setDeviceMotionAccessState(bool granted);
1228
#endif // ENABLE(DEVICE_ORIENTATION)
1229
1223
    const DocumentTiming& timing() const { return m_documentTiming; }
1230
    const DocumentTiming& timing() const { return m_documentTiming; }
1224
1231
1225
    WEBCORE_EXPORT double monotonicTimestamp() const;
1232
    WEBCORE_EXPORT double monotonicTimestamp() const;
Lines 1831-1836 private: a/Source/WebCore/dom/Document.h_sec2
1831
    bool m_areFullscreenControlsHidden { false };
1838
    bool m_areFullscreenControlsHidden { false };
1832
#endif
1839
#endif
1833
1840
1841
#if ENABLE(DEVICE_ORIENTATION)
1842
    Optional<bool> m_deviceOrientationAccessState;
1843
    Optional<bool> m_deviceMotionAccessState;
1844
#endif
1845
1834
    HashSet<HTMLPictureElement*> m_viewportDependentPictures;
1846
    HashSet<HTMLPictureElement*> m_viewportDependentPictures;
1835
    HashSet<HTMLPictureElement*> m_appearanceDependentPictures;
1847
    HashSet<HTMLPictureElement*> m_appearanceDependentPictures;
1836
1848
- a/Source/WebCore/page/ChromeClient.h +5 lines
Lines 482-487 public: a/Source/WebCore/page/ChromeClient.h_sec1
482
    virtual void hasStorageAccess(String&& /*subFrameHost*/, String&& /*topFrameHost*/, uint64_t /*frameID*/, uint64_t /*pageID*/, WTF::CompletionHandler<void (bool)>&& callback) { callback(false); }
482
    virtual void hasStorageAccess(String&& /*subFrameHost*/, String&& /*topFrameHost*/, uint64_t /*frameID*/, uint64_t /*pageID*/, WTF::CompletionHandler<void (bool)>&& callback) { callback(false); }
483
    virtual void requestStorageAccess(String&& /*subFrameHost*/, String&& /*topFrameHost*/, uint64_t /*frameID*/, uint64_t /*pageID*/, WTF::CompletionHandler<void (bool)>&& callback) { callback(false); }
483
    virtual void requestStorageAccess(String&& /*subFrameHost*/, String&& /*topFrameHost*/, uint64_t /*frameID*/, uint64_t /*pageID*/, WTF::CompletionHandler<void (bool)>&& callback) { callback(false); }
484
484
485
#if ENABLE(DEVICE_ORIENTATION)
486
    virtual void requestDeviceOrientationAccessPermission(const SecurityOrigin&, WTF::CompletionHandler<void(bool)>&& callback) { callback(true); }
487
    virtual void requestDeviceMotionAccessPermission(const SecurityOrigin&, WTF::CompletionHandler<void(bool)>&& callback) { callback(true); }
488
#endif
489
485
    virtual void didInsertMenuElement(HTMLMenuElement&) { }
490
    virtual void didInsertMenuElement(HTMLMenuElement&) { }
486
    virtual void didRemoveMenuElement(HTMLMenuElement&) { }
491
    virtual void didRemoveMenuElement(HTMLMenuElement&) { }
487
    virtual void didInsertMenuItemElement(HTMLMenuItemElement&) { }
492
    virtual void didInsertMenuItemElement(HTMLMenuItemElement&) { }
- a/Source/WebCore/page/DOMWindow.cpp -63 / +128 lines
Lines 1826-1875 bool DOMWindow::addEventListener(const AtomicString& eventType, Ref<EventListene a/Source/WebCore/page/DOMWindow.cpp_sec1
1826
    else if (eventNames().isGamepadEventType(eventType))
1826
    else if (eventNames().isGamepadEventType(eventType))
1827
        incrementGamepadEventListenerCount();
1827
        incrementGamepadEventListenerCount();
1828
#endif
1828
#endif
1829
#if ENABLE(DEVICE_ORIENTATION)
1830
    else if (eventType == eventNames().deviceorientationEvent)
1831
        startListeningForDeviceOrientationIfNecessary();
1832
    else if (eventType == eventNames().devicemotionEvent)
1833
        startListeningForDeviceMotionIfNecessary();
1834
#endif
1835
1836
    return true;
1837
}
1829
1838
1830
#if ENABLE(DEVICE_ORIENTATION)
1839
#if ENABLE(DEVICE_ORIENTATION)
1831
    if (frame() && frame()->settings().deviceOrientationEventEnabled() && document() && document()->loader() && document()->loader()->deviceOrientationEventEnabled()) {
1840
1841
DeviceOrientationController* DOMWindow::deviceOrientationController() const
1842
{
1832
#if PLATFORM(IOS_FAMILY)
1843
#if PLATFORM(IOS_FAMILY)
1833
        if ((eventType == eventNames().devicemotionEvent || eventType == eventNames().deviceorientationEvent)) {
1844
    return document() ? &document()->deviceOrientationController() : nullptr;
1834
            if (isSameSecurityOriginAsMainFrame() && isSecureContext()) {
1835
                if (eventType == eventNames().deviceorientationEvent)
1836
                    document()->deviceOrientationController().addDeviceEventListener(*this);
1837
                else
1838
                    document()->deviceMotionController().addDeviceEventListener(*this);
1839
            } else if (document()) {
1840
                if (isSecureContext())
1841
                    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);
1842
                else
1843
                    document()->addConsoleMessage(MessageSource::JS, MessageLevel::Warning, "Blocked attempt to add a device motion or orientation listener because the browsing context is not secure."_s);
1844
            }
1845
        }
1846
#else
1845
#else
1847
        if (eventType == eventNames().devicemotionEvent) {
1846
    return DeviceOrientationController::from(page());
1848
            if (isSameSecurityOriginAsMainFrame() && isSecureContext()) {
1847
#endif
1849
                if (DeviceMotionController* controller = DeviceMotionController::from(page()))
1848
}
1850
                    controller->addDeviceEventListener(*this);
1849
1851
            } else
1850
DeviceMotionController* DOMWindow::deviceMotionController() const
1852
                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);
1851
{
1853
        } else if (eventType == eventNames().deviceorientationEvent) {
1852
#if PLATFORM(IOS_FAMILY)
1854
            if (isSameSecurityOriginAsMainFrame() && isSecureContext()) {
1853
    return document() ? &document()->deviceMotionController() : nullptr;
1855
                if (DeviceOrientationController* controller = DeviceOrientationController::from(page()))
1854
#else
1856
                    controller->addDeviceEventListener(*this);
1855
    return DeviceMotionController::from(page());
1857
            } else {
1856
#endif
1858
                if (isSecureContext())
1857
}
1859
                    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);
1858
1860
                else
1859
bool DOMWindow::isAllowedToUseDeviceMotionOrientation(String& message) const
1861
                    document()->addConsoleMessage(MessageSource::JS, MessageLevel::Warning, "Blocked attempt to add a device motion or orientation listener because the browsing context is not secure."_s);
1860
{
1862
            }
1861
    if (!frame() || !frame()->settings().deviceOrientationEventEnabled() || !document() || !document()->loader() || !document()->loader()->deviceOrientationEventEnabled()) {
1862
        message = "API is disabled"_s;
1863
        return false;
1864
    }
1865
1866
    if (!isSecureContext()) {
1867
        message = "Browsing context is not secure"_s;
1868
        return false;
1869
    }
1870
1871
    if (!isSameSecurityOriginAsMainFrame()) {
1872
        message = "Source frame did not have the same security origin as the main page"_s;
1873
        return false;
1874
    }
1875
    return true;
1876
}
1877
1878
bool DOMWindow::isAllowedToAddDeviceMotionOrientationListener(const String& eventType, String& message) const
1879
{
1880
    String innerMessage;
1881
    if (!isAllowedToUseDeviceMotionOrientation(innerMessage)) {
1882
        message = makeString("Blocked attempt to add a ", eventType, " event listener, reason: ", innerMessage, ".");
1883
        return false;
1884
    }
1885
1886
    if (frame()->settings().deviceOrientationPermissionAPIEnabled()) {
1887
        auto permissionState = (eventType == eventNames().deviceorientationEvent) ? document()->deviceOrientationAccessState() : document()->deviceMotionAccessState();
1888
        if (permissionState && !*permissionState) {
1889
            message = makeString("No ", eventType, " events will be fired because permission to use the API was denied.");
1890
            return false;
1863
        }
1891
        }
1864
#endif // PLATFORM(IOS_FAMILY)
1892
        if (!permissionState) {
1865
    } else if (eventType == eventNames().devicemotionEvent)
1893
            message = makeString("No ", eventType, " events will be fired until permission has been requested and granted.");
1866
        failedToRegisterDeviceMotionEventListener();
1894
            return false;
1867
#endif // ENABLE(DEVICE_ORIENTATION)
1895
        }
1896
    }
1868
1897
1869
    return true;
1898
    return true;
1870
}
1899
}
1871
1900
1872
#if ENABLE(DEVICE_ORIENTATION)
1901
void DOMWindow::startListeningForDeviceOrientationIfNecessary()
1902
{
1903
    if (!hasEventListeners(eventNames().deviceorientationEvent))
1904
        return;
1905
1906
    auto* deviceController = deviceOrientationController();
1907
    if (!deviceController || deviceController->hasDeviceEventListener(*this))
1908
        return;
1909
1910
    String errorMessage;
1911
    if (!isAllowedToAddDeviceMotionOrientationListener(eventNames().deviceorientationEvent, errorMessage)) {
1912
        if (auto* document = this->document())
1913
            document->addConsoleMessage(MessageSource::JS, MessageLevel::Warning, errorMessage);
1914
        return;
1915
    }
1916
1917
    deviceController->addDeviceEventListener(*this);
1918
}
1919
1920
void DOMWindow::stopListeningForDeviceOrientationIfNecessary()
1921
{
1922
    if (hasEventListeners(eventNames().deviceorientationEvent))
1923
        return;
1924
1925
    if (auto* deviceController = deviceOrientationController())
1926
        deviceController->removeDeviceEventListener(*this);
1927
}
1928
1929
void DOMWindow::startListeningForDeviceMotionIfNecessary()
1930
{
1931
    if (!hasEventListeners(eventNames().devicemotionEvent))
1932
        return;
1933
1934
    auto* deviceController = deviceMotionController();
1935
    if (!deviceController || deviceController->hasDeviceEventListener(*this))
1936
        return;
1937
1938
    String errorMessage;
1939
    if (!isAllowedToAddDeviceMotionOrientationListener(eventNames().devicemotionEvent, errorMessage)) {
1940
        failedToRegisterDeviceMotionEventListener();
1941
        if (auto* document = this->document())
1942
            document->addConsoleMessage(MessageSource::JS, MessageLevel::Warning, errorMessage);
1943
        return;
1944
    }
1945
1946
    deviceController->addDeviceEventListener(*this);
1947
}
1948
1949
void DOMWindow::stopListeningForDeviceMotionIfNecessary()
1950
{
1951
    if (hasEventListeners(eventNames().devicemotionEvent))
1952
        return;
1953
1954
    if (auto* deviceController = deviceMotionController())
1955
        deviceController->removeDeviceEventListener(*this);
1956
}
1873
1957
1874
void DOMWindow::failedToRegisterDeviceMotionEventListener()
1958
void DOMWindow::failedToRegisterDeviceMotionEventListener()
1875
{
1959
{
Lines 1941-1962 bool DOMWindow::removeEventListener(const AtomicString& eventType, EventListener a/Source/WebCore/page/DOMWindow.cpp_sec2
1941
        removeUnloadEventListener(this);
2025
        removeUnloadEventListener(this);
1942
    else if (eventType == eventNames().beforeunloadEvent && allowsBeforeUnloadListeners(this))
2026
    else if (eventType == eventNames().beforeunloadEvent && allowsBeforeUnloadListeners(this))
1943
        removeBeforeUnloadEventListener(this);
2027
        removeBeforeUnloadEventListener(this);
1944
#if ENABLE(DEVICE_ORIENTATION)
1945
#if PLATFORM(IOS_FAMILY)
1946
    else if (eventType == eventNames().devicemotionEvent && document())
1947
        document()->deviceMotionController().removeDeviceEventListener(*this);
1948
    else if (eventType == eventNames().deviceorientationEvent && document())
1949
        document()->deviceOrientationController().removeDeviceEventListener(*this);
1950
#else
1951
    else if (eventType == eventNames().devicemotionEvent) {
1952
        if (DeviceMotionController* controller = DeviceMotionController::from(page()))
1953
            controller->removeDeviceEventListener(*this);
1954
    } else if (eventType == eventNames().deviceorientationEvent) {
1955
        if (DeviceOrientationController* controller = DeviceOrientationController::from(page()))
1956
            controller->removeDeviceEventListener(*this);
1957
    }
1958
#endif // PLATFORM(IOS_FAMILY)
1959
#endif // ENABLE(DEVICE_ORIENTATION)
1960
#if PLATFORM(IOS_FAMILY)
2028
#if PLATFORM(IOS_FAMILY)
1961
    else if (eventType == eventNames().scrollEvent)
2029
    else if (eventType == eventNames().scrollEvent)
1962
        decrementScrollEventListenersCount();
2030
        decrementScrollEventListenersCount();
Lines 1977-1982 bool DOMWindow::removeEventListener(const AtomicString& eventType, EventListener a/Source/WebCore/page/DOMWindow.cpp_sec3
1977
    else if (eventNames().isGamepadEventType(eventType))
2045
    else if (eventNames().isGamepadEventType(eventType))
1978
        decrementGamepadEventListenerCount();
2046
        decrementGamepadEventListenerCount();
1979
#endif
2047
#endif
2048
#if ENABLE(DEVICE_ORIENTATION)
2049
    else if (eventType == eventNames().deviceorientationEvent)
2050
        stopListeningForDeviceOrientationIfNecessary();
2051
    else if (eventType == eventNames().devicemotionEvent)
2052
        stopListeningForDeviceMotionIfNecessary();
2053
#endif
1980
2054
1981
    return true;
2055
    return true;
1982
}
2056
}
Lines 2059-2076 void DOMWindow::removeAllEventListeners() a/Source/WebCore/page/DOMWindow.cpp_sec4
2059
    EventTarget::removeAllEventListeners();
2133
    EventTarget::removeAllEventListeners();
2060
2134
2061
#if ENABLE(DEVICE_ORIENTATION)
2135
#if ENABLE(DEVICE_ORIENTATION)
2062
#if PLATFORM(IOS_FAMILY)
2136
        stopListeningForDeviceOrientationIfNecessary();
2063
    if (Document* document = this->document()) {
2137
        stopListeningForDeviceMotionIfNecessary();
2064
        document->deviceMotionController().removeAllDeviceEventListeners(*this);
2138
#endif
2065
        document->deviceOrientationController().removeAllDeviceEventListeners(*this);
2066
    }
2067
#else
2068
    if (DeviceMotionController* controller = DeviceMotionController::from(page()))
2069
        controller->removeAllDeviceEventListeners(*this);
2070
    if (DeviceOrientationController* controller = DeviceOrientationController::from(page()))
2071
        controller->removeAllDeviceEventListeners(*this);
2072
#endif // PLATFORM(IOS_FAMILY)
2073
#endif // ENABLE(DEVICE_ORIENTATION)
2074
2139
2075
#if PLATFORM(IOS_FAMILY)
2140
#if PLATFORM(IOS_FAMILY)
2076
    if (m_scrollEventListenerCount) {
2141
    if (m_scrollEventListenerCount) {
- a/Source/WebCore/page/DOMWindow.h +18 lines
Lines 82-87 class VisualViewport; a/Source/WebCore/page/DOMWindow.h_sec1
82
class WebKitNamespace;
82
class WebKitNamespace;
83
class WebKitPoint;
83
class WebKitPoint;
84
84
85
#if ENABLE(DEVICE_ORIENTATION)
86
class DeviceMotionController;
87
class DeviceOrientationController;
88
#endif
89
85
struct ImageBitmapOptions;
90
struct ImageBitmapOptions;
86
struct WindowFeatures;
91
struct WindowFeatures;
87
92
Lines 311-316 public: a/Source/WebCore/page/DOMWindow.h_sec2
311
    unsigned scrollEventListenerCount() const { return m_scrollEventListenerCount; }
316
    unsigned scrollEventListenerCount() const { return m_scrollEventListenerCount; }
312
#endif
317
#endif
313
318
319
#if ENABLE(DEVICE_ORIENTATION)
320
    void startListeningForDeviceOrientationIfNecessary();
321
    void stopListeningForDeviceOrientationIfNecessary();
322
    void startListeningForDeviceMotionIfNecessary();
323
    void stopListeningForDeviceMotionIfNecessary();
324
325
    bool isAllowedToUseDeviceMotionOrientation(String& message) const;
326
    bool isAllowedToAddDeviceMotionOrientationListener(const String& eventType, String& message) const;
327
328
    DeviceOrientationController* deviceOrientationController() const;
329
    DeviceMotionController* deviceMotionController() const;
330
#endif
331
314
    void resetAllGeolocationPermission();
332
    void resetAllGeolocationPermission();
315
333
316
#if ENABLE(IOS_TOUCH_EVENTS) || ENABLE(IOS_GESTURE_EVENTS)
334
#if ENABLE(IOS_TOUCH_EVENTS) || ENABLE(IOS_GESTURE_EVENTS)
- a/Source/WebCore/page/DeviceController.cpp +5 lines
Lines 69-74 void DeviceController::removeAllDeviceEventListeners(DOMWindow& window) a/Source/WebCore/page/DeviceController.cpp_sec1
69
        m_client.stopUpdating();
69
        m_client.stopUpdating();
70
}
70
}
71
71
72
bool DeviceController::hasDeviceEventListener(DOMWindow& window) const
73
{
74
    return m_listeners.contains(&window);
75
}
76
72
void DeviceController::dispatchDeviceEvent(Event& event)
77
void DeviceController::dispatchDeviceEvent(Event& event)
73
{
78
{
74
    for (auto& listener : copyToVector(m_listeners.values())) {
79
    for (auto& listener : copyToVector(m_listeners.values())) {
- a/Source/WebCore/page/DeviceController.h +1 lines
Lines 46-51 public: a/Source/WebCore/page/DeviceController.h_sec1
46
    void addDeviceEventListener(DOMWindow&);
46
    void addDeviceEventListener(DOMWindow&);
47
    void removeDeviceEventListener(DOMWindow&);
47
    void removeDeviceEventListener(DOMWindow&);
48
    void removeAllDeviceEventListeners(DOMWindow&);
48
    void removeAllDeviceEventListeners(DOMWindow&);
49
    bool hasDeviceEventListener(DOMWindow&) const;
49
50
50
    void dispatchDeviceEvent(Event&);
51
    void dispatchDeviceEvent(Event&);
51
    bool isActive() { return !m_listeners.isEmpty(); }
52
    bool isActive() { return !m_listeners.isEmpty(); }
- a/Source/WebCore/page/Settings.yaml +5 lines
Lines 764-769 deviceOrientationEventEnabled: a/Source/WebCore/page/Settings.yaml_sec1
764
  initial: true
764
  initial: true
765
  conditional: DEVICE_ORIENTATION
765
  conditional: DEVICE_ORIENTATION
766
766
767
deviceOrientationPermissionAPIEnabled:
768
  type: bool
769
  initial: false
770
  conditional: DEVICE_ORIENTATION
771
767
shouldEnableTextAutosizingBoost:
772
shouldEnableTextAutosizingBoost:
768
  type: bool
773
  type: bool
769
  initial: false
774
  initial: false
- a/Source/WebKit/Shared/WebPreferences.yaml +9 lines
Lines 12-17 DeviceOrientationEventEnabled: a/Source/WebKit/Shared/WebPreferences.yaml_sec1
12
  condition: ENABLE(DEVICE_ORIENTATION)
12
  condition: ENABLE(DEVICE_ORIENTATION)
13
  webcoreName: deviceOrientationEventEnabled
13
  webcoreName: deviceOrientationEventEnabled
14
14
15
DeviceOrientationPermissionAPIEnabled:
16
  type: bool
17
  defaultValue: false
18
  condition: ENABLE(DEVICE_ORIENTATION)
19
  webcoreName: deviceOrientationPermissionAPIEnabled
20
  humanReadableName: "Permission API for device orientation / motion access."
21
  humanReadableDescription: "DeviceOrientationEvent.requestPermission() / DeviceMotionEvent.requestPermission()"
22
  category: experimental
23
15
JavaScriptEnabled:
24
JavaScriptEnabled:
16
  type: bool
25
  type: bool
17
  defaultValue: true
26
  defaultValue: true
- a/Source/WebKit/UIProcess/API/APIUIClient.h +5 lines
Lines 173-178 public: a/Source/WebKit/UIProcess/API/APIUIClient.h_sec1
173
    virtual void didLosePointerLock(WebKit::WebPageProxy*) { }
173
    virtual void didLosePointerLock(WebKit::WebPageProxy*) { }
174
#endif
174
#endif
175
175
176
#if ENABLE(DEVICE_ORIENTATION)
177
    virtual void requestDeviceOrientationAccessPermission(WebKit::WebPageProxy&, SecurityOrigin&, CompletionHandler<void(bool)>&& completionHandler) { completionHandler(true); }
178
    virtual void requestDeviceMotionAccessPermission(WebKit::WebPageProxy&, SecurityOrigin&, CompletionHandler<void(bool)>&& completionHandler) { completionHandler(true); }
179
#endif
180
176
    virtual void didClickAutoFillButton(WebKit::WebPageProxy&, Object*) { }
181
    virtual void didClickAutoFillButton(WebKit::WebPageProxy&, Object*) { }
177
182
178
    virtual void didResignInputElementStrongPasswordAppearance(WebKit::WebPageProxy&, Object*) { }
183
    virtual void didResignInputElementStrongPasswordAppearance(WebKit::WebPageProxy&, Object*) { }
- a/Source/WebKit/UIProcess/API/C/WKPage.cpp -1 / +19 lines
Lines 115-121 template<> struct ClientTraits<WKPagePolicyClientBase> { a/Source/WebKit/UIProcess/API/C/WKPage.cpp_sec1
115
};
115
};
116
116
117
template<> struct ClientTraits<WKPageUIClientBase> {
117
template<> struct ClientTraits<WKPageUIClientBase> {
118
    typedef std::tuple<WKPageUIClientV0, WKPageUIClientV1, WKPageUIClientV2, WKPageUIClientV3, WKPageUIClientV4, WKPageUIClientV5, WKPageUIClientV6, WKPageUIClientV7, WKPageUIClientV8, WKPageUIClientV9, WKPageUIClientV10, WKPageUIClientV11, WKPageUIClientV12> Versions;
118
    typedef std::tuple<WKPageUIClientV0, WKPageUIClientV1, WKPageUIClientV2, WKPageUIClientV3, WKPageUIClientV4, WKPageUIClientV5, WKPageUIClientV6, WKPageUIClientV7, WKPageUIClientV8, WKPageUIClientV9, WKPageUIClientV10, WKPageUIClientV11, WKPageUIClientV12, WKPageUIClientV13> Versions;
119
};
119
};
120
120
121
#if ENABLE(CONTEXT_MENUS)
121
#if ENABLE(CONTEXT_MENUS)
Lines 1903-1908 void WKPageSetPageUIClient(WKPageRef pageRef, const WKPageUIClientBase* wkClient a/Source/WebKit/UIProcess/API/C/WKPage.cpp_sec2
1903
            m_client.requestStorageAccessConfirm(toAPI(&page), toAPI(frame), toAPI(requestingDomain.impl()), toAPI(currentDomain.impl()), toAPI(listener.ptr()), m_client.base.clientInfo);
1903
            m_client.requestStorageAccessConfirm(toAPI(&page), toAPI(frame), toAPI(requestingDomain.impl()), toAPI(currentDomain.impl()), toAPI(listener.ptr()), m_client.base.clientInfo);
1904
        }
1904
        }
1905
1905
1906
#if ENABLE(DEVICE_ORIENTATION)
1907
        void requestDeviceOrientationAccessPermission(WebPageProxy& page, API::SecurityOrigin& origin, CompletionHandler<void(bool)>&& completionHandler) final
1908
        {
1909
            if (!m_client.requestDeviceOrientationAccessPermission)
1910
                return completionHandler(true);
1911
1912
            completionHandler(m_client.requestDeviceOrientationAccessPermission(toAPI(&page), toAPI(&origin), m_client.base.clientInfo));
1913
        }
1914
1915
        void requestDeviceMotionAccessPermission(WebPageProxy& page, API::SecurityOrigin& origin, CompletionHandler<void(bool)>&& completionHandler) final
1916
        {
1917
            if (!m_client.requestDeviceMotionAccessPermission)
1918
                return completionHandler(true);
1919
1920
            completionHandler(m_client.requestDeviceMotionAccessPermission(toAPI(&page), toAPI(&origin), m_client.base.clientInfo));
1921
        }
1922
#endif
1923
1906
        // Printing.
1924
        // Printing.
1907
        float headerHeight(WebPageProxy& page, WebFrameProxy& frame) final
1925
        float headerHeight(WebPageProxy& page, WebFrameProxy& frame) final
1908
        {
1926
        {
- a/Source/WebKit/UIProcess/API/C/WKPageUIClient.h +107 lines
Lines 134-139 typedef void (*WKDidLosePointerLockCallback)(WKPageRef page, const void* clientI a/Source/WebKit/UIProcess/API/C/WKPageUIClient.h_sec1
134
typedef void (*WKHasVideoInPictureInPictureDidChangeCallback)(WKPageRef page, bool hasVideoInPictureInPicture, const void* clientInfo);
134
typedef void (*WKHasVideoInPictureInPictureDidChangeCallback)(WKPageRef page, bool hasVideoInPictureInPicture, const void* clientInfo);
135
typedef void (*WKDidExceedBackgroundResourceLimitWhileInForegroundCallback)(WKPageRef page, WKResourceLimit limit, const void* clientInfo);
135
typedef void (*WKDidExceedBackgroundResourceLimitWhileInForegroundCallback)(WKPageRef page, WKResourceLimit limit, const void* clientInfo);
136
typedef void (*WKPageDidResignInputElementStrongPasswordAppearanceCallback)(WKPageRef page, WKTypeRef userData, const void *clientInfo);
136
typedef void (*WKPageDidResignInputElementStrongPasswordAppearanceCallback)(WKPageRef page, WKTypeRef userData, const void *clientInfo);
137
typedef bool (*WKPageRequestDeviceOrientationAccessPermissionCallback)(WKPageRef page, WKSecurityOriginRef securityOrigin, const void *clientInfo);
138
typedef bool (*WKPageRequestDeviceMotionAccessPermissionCallback)(WKPageRef page, WKSecurityOriginRef securityOrigin, const void *clientInfo);
137
139
138
// Deprecated
140
// Deprecated
139
typedef WKPageRef (*WKPageCreateNewPageCallback_deprecatedForUseWithV0)(WKPageRef page, WKDictionaryRef features, WKEventModifiers modifiers, WKEventMouseButton mouseButton, const void *clientInfo);
141
typedef WKPageRef (*WKPageCreateNewPageCallback_deprecatedForUseWithV0)(WKPageRef page, WKDictionaryRef features, WKEventModifiers modifiers, WKEventMouseButton mouseButton, const void *clientInfo);
Lines 1140-1145 typedef struct WKPageUIClientV12 { a/Source/WebKit/UIProcess/API/C/WKPageUIClient.h_sec2
1140
    WKPageRequestStorageAccessConfirmCallback                           requestStorageAccessConfirm;
1142
    WKPageRequestStorageAccessConfirmCallback                           requestStorageAccessConfirm;
1141
} WKPageUIClientV12;
1143
} WKPageUIClientV12;
1142
1144
1145
typedef struct WKPageUIClientV13 {
1146
    WKPageUIClientBase                                                  base;
1147
1148
    // Version 0.
1149
    WKPageCreateNewPageCallback_deprecatedForUseWithV0                  createNewPage_deprecatedForUseWithV0;
1150
    WKPageUIClientCallback                                              showPage;
1151
    WKPageUIClientCallback                                              close;
1152
    WKPageTakeFocusCallback                                             takeFocus;
1153
    WKPageFocusCallback                                                 focus;
1154
    WKPageUnfocusCallback                                               unfocus;
1155
    WKPageRunJavaScriptAlertCallback_deprecatedForUseWithV0             runJavaScriptAlert_deprecatedForUseWithV0;
1156
    WKPageRunJavaScriptConfirmCallback_deprecatedForUseWithV0           runJavaScriptConfirm_deprecatedForUseWithV0;
1157
    WKPageRunJavaScriptPromptCallback_deprecatedForUseWithV0            runJavaScriptPrompt_deprecatedForUseWithV0;
1158
    WKPageSetStatusTextCallback                                         setStatusText;
1159
    WKPageMouseDidMoveOverElementCallback_deprecatedForUseWithV0        mouseDidMoveOverElement_deprecatedForUseWithV0;
1160
    WKPageMissingPluginButtonClickedCallback_deprecatedForUseWithV0     missingPluginButtonClicked_deprecatedForUseWithV0;
1161
    WKPageDidNotHandleKeyEventCallback                                  didNotHandleKeyEvent;
1162
    WKPageDidNotHandleWheelEventCallback                                didNotHandleWheelEvent;
1163
    WKPageGetToolbarsAreVisibleCallback                                 toolbarsAreVisible;
1164
    WKPageSetToolbarsAreVisibleCallback                                 setToolbarsAreVisible;
1165
    WKPageGetMenuBarIsVisibleCallback                                   menuBarIsVisible;
1166
    WKPageSetMenuBarIsVisibleCallback                                   setMenuBarIsVisible;
1167
    WKPageGetStatusBarIsVisibleCallback                                 statusBarIsVisible;
1168
    WKPageSetStatusBarIsVisibleCallback                                 setStatusBarIsVisible;
1169
    WKPageGetIsResizableCallback                                        isResizable;
1170
    WKPageSetIsResizableCallback                                        setIsResizable;
1171
    WKPageGetWindowFrameCallback                                        getWindowFrame;
1172
    WKPageSetWindowFrameCallback                                        setWindowFrame;
1173
    WKPageRunBeforeUnloadConfirmPanelCallback_deprecatedForUseWithV6    runBeforeUnloadConfirmPanel_deprecatedForUseWithV6;
1174
    WKPageUIClientCallback                                              didDraw;
1175
    WKPageUIClientCallback                                              pageDidScroll;
1176
    WKPageExceededDatabaseQuotaCallback                                 exceededDatabaseQuota;
1177
    WKPageRunOpenPanelCallback                                          runOpenPanel;
1178
    WKPageDecidePolicyForGeolocationPermissionRequestCallback           decidePolicyForGeolocationPermissionRequest;
1179
    WKPageHeaderHeightCallback                                          headerHeight;
1180
    WKPageFooterHeightCallback                                          footerHeight;
1181
    WKPageDrawHeaderCallback                                            drawHeader;
1182
    WKPageDrawFooterCallback                                            drawFooter;
1183
    WKPagePrintFrameCallback                                            printFrame;
1184
    WKPageUIClientCallback                                              runModal;
1185
    void*                                                               unused1; // Used to be didCompleteRubberBandForMainFrame
1186
    WKPageSaveDataToFileInDownloadsFolderCallback                       saveDataToFileInDownloadsFolder;
1187
    void*                                                               shouldInterruptJavaScript_unavailable;
1188
1189
    // Version 1.
1190
    WKPageCreateNewPageCallback_deprecatedForUseWithV1                  createNewPage_deprecatedForUseWithV1;
1191
    WKPageMouseDidMoveOverElementCallback                               mouseDidMoveOverElement;
1192
    WKPageDecidePolicyForNotificationPermissionRequestCallback          decidePolicyForNotificationPermissionRequest;
1193
    WKPageUnavailablePluginButtonClickedCallback_deprecatedForUseWithV1 unavailablePluginButtonClicked_deprecatedForUseWithV1;
1194
1195
    // Version 2.
1196
    WKPageShowColorPickerCallback                                       showColorPicker;
1197
    WKPageHideColorPickerCallback                                       hideColorPicker;
1198
    WKPageUnavailablePluginButtonClickedCallback                        unavailablePluginButtonClicked;
1199
1200
    // Version 3.
1201
    WKPagePinnedStateDidChangeCallback                                  pinnedStateDidChange;
1202
1203
    // Version 4.
1204
    void*                                                               unused2; // Used to be didBeginTrackingPotentialLongMousePress.
1205
    void*                                                               unused3; // Used to be didRecognizeLongMousePress.
1206
    void*                                                               unused4; // Used to be didCancelTrackingPotentialLongMousePress.
1207
    WKPageIsPlayingAudioDidChangeCallback                               isPlayingAudioDidChange;
1208
1209
    // Version 5.
1210
    WKPageDecidePolicyForUserMediaPermissionRequestCallback             decidePolicyForUserMediaPermissionRequest;
1211
    WKPageDidClickAutoFillButtonCallback                                didClickAutoFillButton;
1212
    WKPageRunJavaScriptAlertCallback_deprecatedForUseWithV5             runJavaScriptAlert_deprecatedForUseWithV5;
1213
    WKPageRunJavaScriptConfirmCallback_deprecatedForUseWithV5           runJavaScriptConfirm_deprecatedForUseWithV5;
1214
    WKPageRunJavaScriptPromptCallback_deprecatedForUseWithV5            runJavaScriptPrompt_deprecatedForUseWithV5;
1215
    WKPageMediaSessionMetadataDidChangeCallback                         mediaSessionMetadataDidChange;
1216
1217
    // Version 6.
1218
    WKPageCreateNewPageCallback                                         createNewPage;
1219
    WKPageRunJavaScriptAlertCallback                                    runJavaScriptAlert;
1220
    WKPageRunJavaScriptConfirmCallback                                  runJavaScriptConfirm;
1221
    WKPageRunJavaScriptPromptCallback                                   runJavaScriptPrompt;
1222
    WKCheckUserMediaPermissionCallback                                  checkUserMediaPermissionForOrigin;
1223
1224
    // Version 7.
1225
    WKPageRunBeforeUnloadConfirmPanelCallback                           runBeforeUnloadConfirmPanel;
1226
    WKFullscreenMayReturnToInlineCallback                               fullscreenMayReturnToInline;
1227
1228
    // Version 8.
1229
    WKRequestPointerLockCallback                                        requestPointerLock;
1230
    WKDidLosePointerLockCallback                                        didLosePointerLock;
1231
1232
    // Version 9.
1233
    WKHandleAutoplayEventCallback                                       handleAutoplayEvent;
1234
1235
    // Version 10.
1236
    WKHasVideoInPictureInPictureDidChangeCallback                       hasVideoInPictureInPictureDidChange;
1237
    WKDidExceedBackgroundResourceLimitWhileInForegroundCallback         didExceedBackgroundResourceLimitWhileInForeground;
1238
1239
    // Version 11.
1240
    WKPageDidResignInputElementStrongPasswordAppearanceCallback         didResignInputElementStrongPasswordAppearance;
1241
1242
    // Version 12.
1243
    WKPageRequestStorageAccessConfirmCallback                           requestStorageAccessConfirm;
1244
1245
    // Version 13.
1246
    WKPageRequestDeviceOrientationAccessPermissionCallback              requestDeviceOrientationAccessPermission;
1247
    WKPageRequestDeviceMotionAccessPermissionCallback                   requestDeviceMotionAccessPermission;
1248
} WKPageUIClientV13;
1249
1143
#ifdef __cplusplus
1250
#ifdef __cplusplus
1144
}
1251
}
1145
#endif
1252
#endif
- a/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegate.h +17 lines
Lines 34-39 NS_ASSUME_NONNULL_BEGIN a/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegate.h_sec1
34
@class WKNavigationAction;
34
@class WKNavigationAction;
35
@class WKOpenPanelParameters;
35
@class WKOpenPanelParameters;
36
@class WKPreviewElementInfo;
36
@class WKPreviewElementInfo;
37
@class WKSecurityOrigin;
37
@class WKWebView;
38
@class WKWebView;
38
@class WKWebViewConfiguration;
39
@class WKWebViewConfiguration;
39
@class WKWindowFeatures;
40
@class WKWindowFeatures;
Lines 151-156 NS_ASSUME_NONNULL_BEGIN a/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegate.h_sec2
151
 */
152
 */
152
- (void)webView:(WKWebView *)webView commitPreviewingViewController:(UIViewController *)previewingViewController WK_API_AVAILABLE(ios(10.0));
153
- (void)webView:(WKWebView *)webView commitPreviewingViewController:(UIViewController *)previewingViewController WK_API_AVAILABLE(ios(10.0));
153
154
155
/*! @abstract Allows you app to determine whether or not the given security origin should have access to the device's orientation.
156
 @param securityOrigin The security origin which requested access to the device's orientation.
157
 @param decisionHandler The decision handler to call once the app has made its decision. Pass YES to allow to origin access, NO otherwise.
158
159
 If you do not implement this method, access to the device's orientation will be granted.
160
 */
161
- (void)webView:(WKWebView *)webView shouldAllowDeviceOrientationAccessForSecurityOrigin:(WKSecurityOrigin *)securityOrigin decisionHandler:(void (^)(BOOL))decisionHandler WK_API_AVAILABLE(ios(WK_IOS_TBA));
162
163
/*! @abstract Allows you app to determine whether or not the given security origin should have access to the device's motion.
164
 @param securityOrigin The security origin which requested access to the device's motion.
165
 @param decisionHandler The decision handler to call once the app has made its decision. Pass YES to allow to origin access, NO otherwise.
166
167
 If you do not implement this method, access to the device's motion will be granted.
168
 */
169
- (void)webView:(WKWebView *)webView shouldAllowDeviceMotionAccessForSecurityOrigin:(WKSecurityOrigin *)securityOrigin decisionHandler:(void (^)(BOOL))decisionHandler WK_API_AVAILABLE(ios(WK_IOS_TBA));
170
154
#endif // TARGET_OS_IPHONE
171
#endif // TARGET_OS_IPHONE
155
172
156
#if !TARGET_OS_IPHONE
173
#if !TARGET_OS_IPHONE
- a/Source/WebKit/UIProcess/Cocoa/UIDelegate.h +8 lines
Lines 119-124 private: a/Source/WebKit/UIProcess/Cocoa/UIDelegate.h_sec1
119
        bool runOpenPanel(WebPageProxy*, WebFrameProxy*, const WebCore::SecurityOriginData&, API::OpenPanelParameters*, WebOpenPanelResultListenerProxy*) final;
119
        bool runOpenPanel(WebPageProxy*, WebFrameProxy*, const WebCore::SecurityOriginData&, API::OpenPanelParameters*, WebOpenPanelResultListenerProxy*) final;
120
        void didExceedBackgroundResourceLimitWhileInForeground(WebPageProxy&, WKResourceLimit) final;
120
        void didExceedBackgroundResourceLimitWhileInForeground(WebPageProxy&, WKResourceLimit) final;
121
        void saveDataToFileInDownloadsFolder(WebPageProxy*, const WTF::String&, const WTF::String&, const URL&, API::Data&) final;
121
        void saveDataToFileInDownloadsFolder(WebPageProxy*, const WTF::String&, const WTF::String&, const URL&, API::Data&) final;
122
#endif
123
#if ENABLE(DEVICE_ORIENTATION)
124
        void requestDeviceOrientationAccessPermission(WebKit::WebPageProxy&, API::SecurityOrigin&, CompletionHandler<void(bool)>&&) final;
125
        void requestDeviceMotionAccessPermission(WebKit::WebPageProxy&, API::SecurityOrigin&, CompletionHandler<void(bool)>&&) final;
122
#endif
126
#endif
123
        bool needsFontAttributes() const final { return m_uiDelegate.m_delegateMethods.webViewDidChangeFontAttributes; }
127
        bool needsFontAttributes() const final { return m_uiDelegate.m_delegateMethods.webViewDidChangeFontAttributes; }
124
        void didChangeFontAttributes(const WebCore::FontAttributes&) final;
128
        void didChangeFontAttributes(const WebCore::FontAttributes&) final;
Lines 187-192 private: a/Source/WebKit/UIProcess/Cocoa/UIDelegate.h_sec2
187
        bool webViewSaveDataToFileSuggestedFilenameMimeTypeOriginatingURL : 1;
191
        bool webViewSaveDataToFileSuggestedFilenameMimeTypeOriginatingURL : 1;
188
        bool webViewRunOpenPanelWithParametersInitiatedByFrameCompletionHandler : 1;
192
        bool webViewRunOpenPanelWithParametersInitiatedByFrameCompletionHandler : 1;
189
        bool webViewRequestNotificationPermissionForSecurityOriginDecisionHandler : 1;
193
        bool webViewRequestNotificationPermissionForSecurityOriginDecisionHandler : 1;
194
#endif
195
#if ENABLE(DEVICE_ORIENTATION)
196
        bool webViewShouldAllowDeviceOrientationAccessForSecurityOriginDecisionHandler : 1;
197
        bool webViewShouldAllowDeviceMotionAccessForSecurityOriginDecisionHandler : 1;
190
#endif
198
#endif
191
        bool webViewDecideDatabaseQuotaForSecurityOriginCurrentQuotaCurrentOriginUsageCurrentDatabaseUsageExpectedUsageDecisionHandler : 1;
199
        bool webViewDecideDatabaseQuotaForSecurityOriginCurrentQuotaCurrentOriginUsageCurrentDatabaseUsageExpectedUsageDecisionHandler : 1;
192
        bool webViewDecideDatabaseQuotaForSecurityOriginDatabaseNameDisplayNameCurrentQuotaCurrentOriginUsageCurrentDatabaseUsageExpectedUsageDecisionHandler : 1;
200
        bool webViewDecideDatabaseQuotaForSecurityOriginDatabaseNameDisplayNameCurrentQuotaCurrentOriginUsageCurrentDatabaseUsageExpectedUsageDecisionHandler : 1;
- a/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm +43 lines
Lines 132-137 void UIDelegate::setDelegate(id <WKUIDelegate> delegate) a/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm_sec1
132
    m_delegateMethods.webViewSaveDataToFileSuggestedFilenameMimeTypeOriginatingURL = [delegate respondsToSelector:@selector(_webView:saveDataToFile:suggestedFilename:mimeType:originatingURL:)];
132
    m_delegateMethods.webViewSaveDataToFileSuggestedFilenameMimeTypeOriginatingURL = [delegate respondsToSelector:@selector(_webView:saveDataToFile:suggestedFilename:mimeType:originatingURL:)];
133
    m_delegateMethods.webViewRunOpenPanelWithParametersInitiatedByFrameCompletionHandler = [delegate respondsToSelector:@selector(webView:runOpenPanelWithParameters:initiatedByFrame:completionHandler:)];
133
    m_delegateMethods.webViewRunOpenPanelWithParametersInitiatedByFrameCompletionHandler = [delegate respondsToSelector:@selector(webView:runOpenPanelWithParameters:initiatedByFrame:completionHandler:)];
134
    m_delegateMethods.webViewRequestNotificationPermissionForSecurityOriginDecisionHandler = [delegate respondsToSelector:@selector(_webView:requestNotificationPermissionForSecurityOrigin:decisionHandler:)];
134
    m_delegateMethods.webViewRequestNotificationPermissionForSecurityOriginDecisionHandler = [delegate respondsToSelector:@selector(_webView:requestNotificationPermissionForSecurityOrigin:decisionHandler:)];
135
#endif
136
#if ENABLE(DEVICE_ORIENTATION)
137
    m_delegateMethods.webViewShouldAllowDeviceOrientationAccessForSecurityOriginDecisionHandler = [delegate respondsToSelector:@selector(webView:shouldAllowDeviceOrientationAccessForSecurityOrigin:decisionHandler:)];
138
    m_delegateMethods.webViewShouldAllowDeviceMotionAccessForSecurityOriginDecisionHandler = [delegate respondsToSelector:@selector(webView:shouldAllowDeviceMotionAccessForSecurityOrigin:decisionHandler:)];
135
#endif
139
#endif
136
    m_delegateMethods.webViewDecideDatabaseQuotaForSecurityOriginCurrentQuotaCurrentOriginUsageCurrentDatabaseUsageExpectedUsageDecisionHandler = [delegate respondsToSelector:@selector(_webView:decideDatabaseQuotaForSecurityOrigin:currentQuota:currentOriginUsage:currentDatabaseUsage:expectedUsage:decisionHandler:)];
140
    m_delegateMethods.webViewDecideDatabaseQuotaForSecurityOriginCurrentQuotaCurrentOriginUsageCurrentDatabaseUsageExpectedUsageDecisionHandler = [delegate respondsToSelector:@selector(_webView:decideDatabaseQuotaForSecurityOrigin:currentQuota:currentOriginUsage:currentDatabaseUsage:expectedUsage:decisionHandler:)];
137
    m_delegateMethods.webViewDecideDatabaseQuotaForSecurityOriginDatabaseNameDisplayNameCurrentQuotaCurrentOriginUsageCurrentDatabaseUsageExpectedUsageDecisionHandler = [delegate respondsToSelector:@selector(_webView:decideDatabaseQuotaForSecurityOrigin:databaseName:displayName:currentQuota:currentOriginUsage:currentDatabaseUsage:expectedUsage:decisionHandler:)];
141
    m_delegateMethods.webViewDecideDatabaseQuotaForSecurityOriginDatabaseNameDisplayNameCurrentQuotaCurrentOriginUsageCurrentDatabaseUsageExpectedUsageDecisionHandler = [delegate respondsToSelector:@selector(_webView:decideDatabaseQuotaForSecurityOrigin:databaseName:displayName:currentQuota:currentOriginUsage:currentDatabaseUsage:expectedUsage:decisionHandler:)];
Lines 844-849 bool UIDelegate::UIClient::runOpenPanel(WebPageProxy*, WebFrameProxy* webFramePr a/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm_sec2
844
}
848
}
845
#endif
849
#endif
846
850
851
#if ENABLE(DEVICE_ORIENTATION)
852
853
void UIDelegate::UIClient::requestDeviceOrientationAccessPermission(WebKit::WebPageProxy&, API::SecurityOrigin& securityOrigin, CompletionHandler<void(bool)>&& completionHandler)
854
{
855
    if (!m_uiDelegate.m_delegateMethods.webViewShouldAllowDeviceOrientationAccessForSecurityOriginDecisionHandler)
856
        return completionHandler(true);
857
858
    auto delegate = m_uiDelegate.m_delegate.get();
859
    if (!delegate)
860
        return completionHandler(true);
861
862
    auto checker = CompletionHandlerCallChecker::create(delegate.get(), @selector(webView:shouldAllowDeviceOrientationAccessForSecurityOrigin:decisionHandler:));
863
    [(id <WKUIDelegatePrivate>)delegate webView:m_uiDelegate.m_webView shouldAllowDeviceOrientationAccessForSecurityOrigin:wrapper(securityOrigin) decisionHandler:makeBlockPtr([completionHandler = WTFMove(completionHandler), checker = WTFMove(checker)] (BOOL granted) mutable {
864
        if (checker->completionHandlerHasBeenCalled())
865
            return;
866
        checker->didCallCompletionHandler();
867
        completionHandler(granted);
868
    }).get()];
869
}
870
871
void UIDelegate::UIClient::requestDeviceMotionAccessPermission(WebKit::WebPageProxy&, API::SecurityOrigin& securityOrigin, CompletionHandler<void(bool)>&& completionHandler)
872
{
873
    if (!m_uiDelegate.m_delegateMethods.webViewShouldAllowDeviceMotionAccessForSecurityOriginDecisionHandler)
874
        return completionHandler(true);
875
876
    auto delegate = m_uiDelegate.m_delegate.get();
877
    if (!delegate)
878
        return completionHandler(true);
879
880
    auto checker = CompletionHandlerCallChecker::create(delegate.get(), @selector(webView:shouldAllowDeviceMotionAccessForSecurityOrigin:decisionHandler:));
881
    [(id <WKUIDelegatePrivate>)delegate webView:m_uiDelegate.m_webView shouldAllowDeviceMotionAccessForSecurityOrigin:wrapper(securityOrigin) decisionHandler:makeBlockPtr([completionHandler = WTFMove(completionHandler), checker = WTFMove(checker)] (BOOL granted) mutable {
882
        if (checker->completionHandlerHasBeenCalled())
883
            return;
884
        checker->didCallCompletionHandler();
885
        completionHandler(granted);
886
    }).get()];
887
}
888
#endif
889
847
void UIDelegate::UIClient::didChangeFontAttributes(const WebCore::FontAttributes& fontAttributes)
890
void UIDelegate::UIClient::didChangeFontAttributes(const WebCore::FontAttributes& fontAttributes)
848
{
891
{
849
    if (!needsFontAttributes())
892
    if (!needsFontAttributes())
- a/Source/WebKit/UIProcess/WebPageProxy.cpp +22 lines
Lines 7168-7173 void WebPageProxy::clearUserMediaState() a/Source/WebKit/UIProcess/WebPageProxy.cpp_sec1
7168
#endif
7168
#endif
7169
}
7169
}
7170
7170
7171
#if ENABLE(DEVICE_ORIENTATION)
7172
void WebPageProxy::requestDeviceOrientationAccessPermission(WebCore::SecurityOriginData&& originData, uint64_t callbackID)
7173
{
7174
    auto origin = API::SecurityOrigin::create(originData.securityOrigin());
7175
    m_uiClient->requestDeviceOrientationAccessPermission(*this, origin.get(), [this, weakThis = makeWeakPtr(*this), callbackID](bool granted) {
7176
        if (!weakThis || !isValid())
7177
            return;
7178
        m_process->send(Messages::WebPage::DidReceiveDeviceOrientationMotionAccessPermissionDecision(callbackID, granted), m_pageID);
7179
    });
7180
}
7181
7182
void WebPageProxy::requestDeviceMotionAccessPermission(WebCore::SecurityOriginData&& originData, uint64_t callbackID)
7183
{
7184
    auto origin = API::SecurityOrigin::create(originData.securityOrigin());
7185
    m_uiClient->requestDeviceMotionAccessPermission(*this, origin.get(), [this, weakThis = makeWeakPtr(*this), callbackID](bool granted) {
7186
        if (!weakThis || !isValid())
7187
            return;
7188
        m_process->send(Messages::WebPage::DidReceiveDeviceOrientationMotionAccessPermissionDecision(callbackID, granted), m_pageID);
7189
    });
7190
}
7191
#endif
7192
7171
void WebPageProxy::requestNotificationPermission(uint64_t requestID, const String& originString)
7193
void WebPageProxy::requestNotificationPermission(uint64_t requestID, const String& originString)
7172
{
7194
{
7173
    if (!isRequestIDValid(requestID))
7195
    if (!isRequestIDValid(requestID))
- a/Source/WebKit/UIProcess/WebPageProxy.h +5 lines
Lines 1401-1406 public: a/Source/WebKit/UIProcess/WebPageProxy.h_sec1
1401
    void requestStorageAccessConfirm(const WebCore::RegistrableDomain& subFrameDomain, const WebCore::RegistrableDomain& topFrameDomain, uint64_t frameID, CompletionHandler<void(bool)>&&);
1401
    void requestStorageAccessConfirm(const WebCore::RegistrableDomain& subFrameDomain, const WebCore::RegistrableDomain& topFrameDomain, uint64_t frameID, CompletionHandler<void(bool)>&&);
1402
#endif
1402
#endif
1403
1403
1404
#if ENABLE(DEVICE_ORIENTATION)
1405
    void requestDeviceOrientationAccessPermission(WebCore::SecurityOriginData&&, uint64_t callbackID);
1406
    void requestDeviceMotionAccessPermission(WebCore::SecurityOriginData&&, uint64_t callbackID);
1407
#endif
1408
1404
    static WebPageProxy* nonEphemeralWebPageProxy();
1409
    static WebPageProxy* nonEphemeralWebPageProxy();
1405
1410
1406
#if ENABLE(ATTACHMENT_ELEMENT)
1411
#if ENABLE(ATTACHMENT_ELEMENT)
- a/Source/WebKit/UIProcess/WebPageProxy.messages.in +5 lines
Lines 532-537 messages -> WebPageProxy { a/Source/WebKit/UIProcess/WebPageProxy.messages.in_sec1
532
    StopURLSchemeTask(uint64_t handlerIdentifier, uint64_t taskIdentifier)
532
    StopURLSchemeTask(uint64_t handlerIdentifier, uint64_t taskIdentifier)
533
    LoadSynchronousURLSchemeTask(struct WebKit::URLSchemeTaskParameters parameters) -> (WebCore::ResourceResponse response, WebCore::ResourceError error, IPC::DataReference data) Delayed
533
    LoadSynchronousURLSchemeTask(struct WebKit::URLSchemeTaskParameters parameters) -> (WebCore::ResourceResponse response, WebCore::ResourceError error, IPC::DataReference data) Delayed
534
534
535
#if ENABLE(DEVICE_ORIENTATION)
536
    RequestDeviceOrientationAccessPermission(struct WebCore::SecurityOriginData origin, uint64_t callbackID);
537
    RequestDeviceMotionAccessPermission(struct WebCore::SecurityOriginData origin, uint64_t callbackID);
538
#endif
539
535
#if ENABLE(ATTACHMENT_ELEMENT)
540
#if ENABLE(ATTACHMENT_ELEMENT)
536
    RegisterAttachmentIdentifierFromData(String identifier, String contentType, String preferredFileName, IPC::SharedBufferDataReference data)
541
    RegisterAttachmentIdentifierFromData(String identifier, String contentType, String preferredFileName, IPC::SharedBufferDataReference data)
537
    RegisterAttachmentIdentifierFromFilePath(String identifier, String contentType, String filePath)
542
    RegisterAttachmentIdentifierFromFilePath(String identifier, String contentType, String filePath)
- a/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp +12 lines
Lines 1320-1323 void WebChromeClient::requestStorageAccess(String&& subFrameHost, String&& topFr a/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp_sec1
1320
}
1320
}
1321
#endif
1321
#endif
1322
1322
1323
#if ENABLE(DEVICE_ORIENTATION)
1324
void WebChromeClient::requestDeviceOrientationAccessPermission(const SecurityOrigin& origin, CompletionHandler<void(bool)>&& callback)
1325
{
1326
    m_page.requestDeviceOrientationAccessPermission(origin, WTFMove(callback));
1327
}
1328
1329
void WebChromeClient::requestDeviceMotionAccessPermission(const SecurityOrigin& origin, CompletionHandler<void(bool)>&& callback)
1330
{
1331
    m_page.requestDeviceMotionAccessPermission(origin, WTFMove(callback));
1332
}
1333
#endif
1334
1323
} // namespace WebKit
1335
} // namespace WebKit
- a/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h +5 lines
Lines 366-371 private: a/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h_sec1
366
    void requestStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, WTF::CompletionHandler<void (bool)>&&) final;
366
    void requestStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, WTF::CompletionHandler<void (bool)>&&) final;
367
#endif
367
#endif
368
368
369
#if ENABLE(DEVICE_ORIENTATION)
370
    void requestDeviceOrientationAccessPermission(const WebCore::SecurityOrigin&, CompletionHandler<void(bool)>&&) final;
371
    void requestDeviceMotionAccessPermission(const WebCore::SecurityOrigin&, CompletionHandler<void(bool)>&&) final;
372
#endif
373
369
    String m_cachedToolTip;
374
    String m_cachedToolTip;
370
    mutable RefPtr<WebFrame> m_cachedFrameSetLargestFrame;
375
    mutable RefPtr<WebFrame> m_cachedFrameSetLargestFrame;
371
    mutable bool m_cachedMainFrameHasHorizontalScrollbar { false };
376
    mutable bool m_cachedMainFrameHasHorizontalScrollbar { false };
- a/Source/WebKit/WebProcess/WebPage/WebPage.cpp +33 lines
Lines 6354-6359 void WebPage::requestStorageAccess(String&& subFrameHost, String&& topFrameHost, a/Source/WebKit/WebProcess/WebPage/WebPage.cpp_sec1
6354
    WebProcess::singleton().ensureNetworkProcessConnection().connection().sendWithAsyncReply(Messages::NetworkConnectionToWebProcess::RequestStorageAccess(sessionID(), RegistrableDomain::uncheckedCreateFromHost(subFrameHost), RegistrableDomain::uncheckedCreateFromHost(topFrameHost), frameID, m_pageID, promptEnabled), WTFMove(completionHandler));
6354
    WebProcess::singleton().ensureNetworkProcessConnection().connection().sendWithAsyncReply(Messages::NetworkConnectionToWebProcess::RequestStorageAccess(sessionID(), RegistrableDomain::uncheckedCreateFromHost(subFrameHost), RegistrableDomain::uncheckedCreateFromHost(topFrameHost), frameID, m_pageID, promptEnabled), WTFMove(completionHandler));
6355
}
6355
}
6356
#endif
6356
#endif
6357
6358
#if ENABLE(DEVICE_ORIENTATION)
6359
static uint64_t nextDeviceOrientationMotionPermissionCallbackID()
6360
{
6361
    static uint64_t nextCallbackID = 0;
6362
    return ++nextCallbackID;
6363
}
6364
6365
void WebPage::requestDeviceOrientationAccessPermission(const WebCore::SecurityOrigin& origin, CompletionHandler<void(bool)>&& callback)
6366
{
6367
    auto callbackID = nextDeviceOrientationMotionPermissionCallbackID();
6368
    ASSERT(!m_deviceOrientationMotionPermissionCallbackMap.contains(callbackID));
6369
    m_deviceOrientationMotionPermissionCallbackMap.add(callbackID, WTFMove(callback));
6370
6371
    send(Messages::WebPageProxy::RequestDeviceOrientationAccessPermission(origin.data(), callbackID));
6372
}
6373
6374
void WebPage::requestDeviceMotionAccessPermission(const WebCore::SecurityOrigin& origin, CompletionHandler<void(bool)>&& callback)
6375
{
6376
    auto callbackID = nextDeviceOrientationMotionPermissionCallbackID();
6377
    ASSERT(!m_deviceOrientationMotionPermissionCallbackMap.contains(callbackID));
6378
    m_deviceOrientationMotionPermissionCallbackMap.add(callbackID, WTFMove(callback));
6379
6380
    send(Messages::WebPageProxy::RequestDeviceMotionAccessPermission(origin.data(), callbackID));
6381
}
6382
6383
void WebPage::didReceiveDeviceOrientationMotionAccessPermissionDecision(uint64_t callbackID, bool granted)
6384
{
6385
    auto callback = m_deviceOrientationMotionPermissionCallbackMap.take(callbackID);
6386
    ASSERT(callback);
6387
    callback(granted);
6388
}
6389
#endif
6357
    
6390
    
6358
static ShareSheetCallbackID nextShareSheetCallbackID()
6391
static ShareSheetCallbackID nextShareSheetCallbackID()
6359
{
6392
{
- a/Source/WebKit/WebProcess/WebPage/WebPage.h +13 lines
Lines 1111-1116 public: a/Source/WebKit/WebProcess/WebPage/WebPage.h_sec1
1111
    void requestStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, CompletionHandler<void(bool)>&& callback);
1111
    void requestStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, CompletionHandler<void(bool)>&& callback);
1112
#endif
1112
#endif
1113
1113
1114
#if ENABLE(DEVICE_ORIENTATION)
1115
    void requestDeviceOrientationAccessPermission(const WebCore::SecurityOrigin&, CompletionHandler<void(bool)>&&);
1116
    void requestDeviceMotionAccessPermission(const WebCore::SecurityOrigin&, CompletionHandler<void(bool)>&&);
1117
#endif
1118
1114
    void showShareSheet(WebCore::ShareDataWithParsedURL&, WTF::CompletionHandler<void(bool)>&& callback);
1119
    void showShareSheet(WebCore::ShareDataWithParsedURL&, WTF::CompletionHandler<void(bool)>&& callback);
1115
    void didCompleteShareSheet(bool wasCompleted, ShareSheetCallbackID contextId);
1120
    void didCompleteShareSheet(bool wasCompleted, ShareSheetCallbackID contextId);
1116
    
1121
    
Lines 1207-1212 private: a/Source/WebKit/WebProcess/WebPage/WebPage.h_sec2
1207
    void requestAdditionalItemsForDragSession(const WebCore::IntPoint& clientPosition, const WebCore::IntPoint& globalPosition);
1212
    void requestAdditionalItemsForDragSession(const WebCore::IntPoint& clientPosition, const WebCore::IntPoint& globalPosition);
1208
#endif
1213
#endif
1209
1214
1215
#if ENABLE(DEVICE_ORIENTATION)
1216
    void didReceiveDeviceOrientationMotionAccessPermissionDecision(uint64_t callbackID, bool granted);
1217
#endif
1218
1210
#if !PLATFORM(COCOA) && !PLATFORM(WPE)
1219
#if !PLATFORM(COCOA) && !PLATFORM(WPE)
1211
    static const char* interpretKeyEvent(const WebCore::KeyboardEvent*);
1220
    static const char* interpretKeyEvent(const WebCore::KeyboardEvent*);
1212
#endif
1221
#endif
Lines 1837-1842 private: a/Source/WebKit/WebProcess/WebPage/WebPage.h_sec3
1837
    HashMap<uint64_t, WTF::Function<void(bool granted)>> m_storageAccessResponseCallbackMap;
1846
    HashMap<uint64_t, WTF::Function<void(bool granted)>> m_storageAccessResponseCallbackMap;
1838
    HashMap<ShareSheetCallbackID, WTF::Function<void(bool completed)>> m_shareSheetResponseCallbackMap;
1847
    HashMap<ShareSheetCallbackID, WTF::Function<void(bool completed)>> m_shareSheetResponseCallbackMap;
1839
1848
1849
#if ENABLE(DEVICE_ORIENTATION)
1850
    HashMap<uint64_t, WTF::CompletionHandler<void(bool granted)>> m_deviceOrientationMotionPermissionCallbackMap;
1851
#endif
1852
1840
#if ENABLE(APPLICATION_MANIFEST)
1853
#if ENABLE(APPLICATION_MANIFEST)
1841
    HashMap<uint64_t, uint64_t> m_applicationManifestFetchCallbackMap;
1854
    HashMap<uint64_t, uint64_t> m_applicationManifestFetchCallbackMap;
1842
#endif
1855
#endif
- a/Source/WebKit/WebProcess/WebPage/WebPage.messages.in +4 lines
Lines 364-369 messages -> WebPage LegacyReceiver { a/Source/WebKit/WebProcess/WebPage/WebPage.messages.in_sec1
364
    # Notification
364
    # Notification
365
    DidReceiveNotificationPermissionDecision(uint64_t notificationID, bool allowed)
365
    DidReceiveNotificationPermissionDecision(uint64_t notificationID, bool allowed)
366
366
367
#if ENABLE(DEVICE_ORIENTATION)
368
    DidReceiveDeviceOrientationMotionAccessPermissionDecision(uint64_t callbackID, bool granted)
369
#endif
370
367
    # Printing.
371
    # Printing.
368
    BeginPrinting(uint64_t frameID, struct WebKit::PrintInfo printInfo)
372
    BeginPrinting(uint64_t frameID, struct WebKit::PrintInfo printInfo)
369
    EndPrinting()
373
    EndPrinting()
- a/Tools/ChangeLog +28 lines
Lines 1-3 a/Tools/ChangeLog_sec1
1
2019-03-05  Chris Dumez  <cdumez@apple.com>
2
3
        Add support for Device Orientation / Motion permission API
4
        https://bugs.webkit.org/show_bug.cgi?id=195329
5
        <rdar://problem/47645367>
6
7
        Reviewed by NOBODY (OOPS!).
8
9
        Add test infrastructure to help test the Device Orientation / Motion permission API.
10
11
        * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
12
        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
13
        (WTR::TestRunner::setShouldAllowDeviceOrientationAccess):
14
        (WTR::TestRunner::setShouldAllowDeviceMotionAccess):
15
        * WebKitTestRunner/InjectedBundle/TestRunner.h:
16
        * WebKitTestRunner/TestController.cpp:
17
        (WTR::requestDeviceOrientationAccessPermission):
18
        (WTR::requestDeviceMotionAccessPermission):
19
        (WTR::TestController::createWebViewWithOptions):
20
        (WTR::TestController::resetStateToConsistentValues):
21
        (WTR::TestController::handleDeviceOrientationAccessPermissionRequest):
22
        (WTR::TestController::handleDeviceMotionAccessPermissionRequest):
23
        * WebKitTestRunner/TestController.h:
24
        (WTR::TestController::setShouldAllowDeviceOrientationAccess):
25
        (WTR::TestController::setShouldAllowDeviceMotionAccess):
26
        * WebKitTestRunner/TestInvocation.cpp:
27
        (WTR::TestInvocation::didReceiveMessageFromInjectedBundle):
28
1
2019-03-04  Chris Dumez  <cdumez@apple.com>
29
2019-03-04  Chris Dumez  <cdumez@apple.com>
2
30
3
        Do not share WebProcesses between private and regular sessions
31
        Do not share WebProcesses between private and regular sessions
- a/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl +4 lines
Lines 104-109 interface TestRunner { a/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl_sec1
104
    boolean isCommandEnabled(DOMString name);
104
    boolean isCommandEnabled(DOMString name);
105
    unsigned long windowCount();
105
    unsigned long windowCount();
106
106
107
    // Device Orientation Motion.
108
    void setShouldAllowDeviceOrientationAccess(boolean value);
109
    void setShouldAllowDeviceMotionAccess(boolean value);
110
107
    // Special DOM variables.
111
    // Special DOM variables.
108
    attribute boolean globalFlag;
112
    attribute boolean globalFlag;
109
113
- a/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp +14 lines
Lines 1294-1299 void TestRunner::setShouldDownloadUndisplayableMIMETypes(bool value) a/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp_sec1
1294
    WKBundlePagePostMessage(InjectedBundle::singleton().page()->page(), messageName.get(), messageBody.get());
1294
    WKBundlePagePostMessage(InjectedBundle::singleton().page()->page(), messageName.get(), messageBody.get());
1295
}
1295
}
1296
1296
1297
void TestRunner::setShouldAllowDeviceOrientationAccess(bool value)
1298
{
1299
    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetShouldAllowDeviceOrientationAccess"));
1300
    WKRetainPtr<WKBooleanRef> messageBody(AdoptWK, WKBooleanCreate(value));
1301
    WKBundlePagePostMessage(InjectedBundle::singleton().page()->page(), messageName.get(), messageBody.get());
1302
}
1303
1304
void TestRunner::setShouldAllowDeviceMotionAccess(bool value)
1305
{
1306
    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetShouldAllowDeviceMotionAccess"));
1307
    WKRetainPtr<WKBooleanRef> messageBody(AdoptWK, WKBooleanCreate(value));
1308
    WKBundlePagePostMessage(InjectedBundle::singleton().page()->page(), messageName.get(), messageBody.get());
1309
}
1310
1297
void TestRunner::terminateNetworkProcess()
1311
void TestRunner::terminateNetworkProcess()
1298
{
1312
{
1299
    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("TerminateNetworkProcess"));
1313
    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("TerminateNetworkProcess"));
- a/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h +2 lines
Lines 348-353 public: a/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h_sec1
348
    void setNavigationGesturesEnabled(bool);
348
    void setNavigationGesturesEnabled(bool);
349
    void setIgnoresViewportScaleLimits(bool);
349
    void setIgnoresViewportScaleLimits(bool);
350
    void setShouldDownloadUndisplayableMIMETypes(bool);
350
    void setShouldDownloadUndisplayableMIMETypes(bool);
351
    void setShouldAllowDeviceOrientationAccess(bool);
352
    void setShouldAllowDeviceMotionAccess(bool);
351
353
352
    bool didCancelClientRedirect() const { return m_didCancelClientRedirect; }
354
    bool didCancelClientRedirect() const { return m_didCancelClientRedirect; }
353
    void setDidCancelClientRedirect(bool value) { m_didCancelClientRedirect = value; }
355
    void setDidCancelClientRedirect(bool value) { m_didCancelClientRedirect = value; }
- a/Tools/WebKitTestRunner/TestController.cpp -3 / +35 lines
Lines 261-266 static void requestPointerLock(WKPageRef page, const void*) a/Tools/WebKitTestRunner/TestController.cpp_sec1
261
    WKPageDidAllowPointerLock(page);
261
    WKPageDidAllowPointerLock(page);
262
}
262
}
263
263
264
static bool requestDeviceOrientationAccessPermission(WKPageRef, WKSecurityOriginRef origin, const void*)
265
{
266
    return TestController::singleton().handleDeviceOrientationAccessPermissionRequest(origin);
267
}
268
269
static bool requestDeviceMotionAccessPermission(WKPageRef, WKSecurityOriginRef origin, const void*)
270
{
271
    return TestController::singleton().handleDeviceMotionAccessPermissionRequest(origin);
272
}
273
264
WKPageRef TestController::createOtherPage(WKPageRef, WKPageConfigurationRef configuration, WKNavigationActionRef navigationAction, WKWindowFeaturesRef windowFeatures, const void *clientInfo)
274
WKPageRef TestController::createOtherPage(WKPageRef, WKPageConfigurationRef configuration, WKNavigationActionRef navigationAction, WKWindowFeaturesRef windowFeatures, const void *clientInfo)
265
{
275
{
266
    PlatformWebView* parentView = static_cast<PlatformWebView*>(const_cast<void*>(clientInfo));
276
    PlatformWebView* parentView = static_cast<PlatformWebView*>(const_cast<void*>(clientInfo));
Lines 569-576 void TestController::createWebViewWithOptions(const TestOptions& options) a/Tools/WebKitTestRunner/TestController.cpp_sec2
569
    resetPreferencesToConsistentValues(options);
579
    resetPreferencesToConsistentValues(options);
570
580
571
    platformCreateWebView(configuration.get(), options);
581
    platformCreateWebView(configuration.get(), options);
572
    WKPageUIClientV8 pageUIClient = {
582
    WKPageUIClientV13 pageUIClient = {
573
        { 8, m_mainWebView.get() },
583
        { 13, m_mainWebView.get() },
574
        0, // createNewPage_deprecatedForUseWithV0
584
        0, // createNewPage_deprecatedForUseWithV0
575
        0, // showPage
585
        0, // showPage
576
        0, // close
586
        0, // close
Lines 636-642 void TestController::createWebViewWithOptions(const TestOptions& options) a/Tools/WebKitTestRunner/TestController.cpp_sec3
636
        0, // runBeforeUnloadConfirmPanel
646
        0, // runBeforeUnloadConfirmPanel
637
        0, // fullscreenMayReturnToInline
647
        0, // fullscreenMayReturnToInline
638
        requestPointerLock,
648
        requestPointerLock,
639
        0,
649
        0, // didLosePointerLock
650
        0, // handleAutoplayEvent
651
        0, // hasVideoInPictureInPictureDidChange
652
        0, // didExceedBackgroundResourceLimitWhileInForeground
653
        0, // didResignInputElementStrongPasswordAppearance
654
        0, // requestStorageAccessConfirm
655
        requestDeviceOrientationAccessPermission,
656
        requestDeviceMotionAccessPermission
640
    };
657
    };
641
    WKPageSetPageUIClient(m_mainWebView->page(), &pageUIClient.base);
658
    WKPageSetPageUIClient(m_mainWebView->page(), &pageUIClient.base);
642
659
Lines 942-947 bool TestController::resetStateToConsistentValues(const TestOptions& options, Re a/Tools/WebKitTestRunner/TestController.cpp_sec4
942
959
943
    m_shouldDownloadUndisplayableMIMETypes = false;
960
    m_shouldDownloadUndisplayableMIMETypes = false;
944
961
962
    m_shouldAllowDeviceOrientationAccess = false;
963
    m_shouldAllowDeviceMotionAccess = false;
964
945
    m_workQueueManager.clearWorkQueue();
965
    m_workQueueManager.clearWorkQueue();
946
966
947
    m_rejectsProtectionSpaceAndContinueForAuthenticationChallenges = false;
967
    m_rejectsProtectionSpaceAndContinueForAuthenticationChallenges = false;
Lines 2547-2552 void TestController::handleCheckOfUserMediaPermissionForOrigin(WKFrameRef frame, a/Tools/WebKitTestRunner/TestController.cpp_sec5
2547
    WKUserMediaPermissionCheckSetUserMediaAccessInfo(checkRequest, saltString.get(), settingsForOrigin(originHash).persistentPermission());
2567
    WKUserMediaPermissionCheckSetUserMediaAccessInfo(checkRequest, saltString.get(), settingsForOrigin(originHash).persistentPermission());
2548
}
2568
}
2549
2569
2570
bool TestController::handleDeviceOrientationAccessPermissionRequest(WKSecurityOriginRef origin)
2571
{
2572
    m_currentInvocation->outputText(makeString("Received device orientation access permission request for security origin \"", originUserVisibleName(origin), "\".\n"));
2573
    return m_shouldAllowDeviceOrientationAccess;
2574
}
2575
2576
bool TestController::handleDeviceMotionAccessPermissionRequest(WKSecurityOriginRef origin)
2577
{
2578
    m_currentInvocation->outputText(makeString("Received device motion access permission request for security origin \"", originUserVisibleName(origin), "\".\n"));
2579
    return m_shouldAllowDeviceMotionAccess;
2580
}
2581
2550
void TestController::handleUserMediaPermissionRequest(WKFrameRef frame, WKSecurityOriginRef userMediaDocumentOrigin, WKSecurityOriginRef topLevelDocumentOrigin, WKUserMediaPermissionRequestRef request)
2582
void TestController::handleUserMediaPermissionRequest(WKFrameRef frame, WKSecurityOriginRef userMediaDocumentOrigin, WKSecurityOriginRef topLevelDocumentOrigin, WKUserMediaPermissionRequestRef request)
2551
{
2583
{
2552
    auto originHash = userMediaOriginHash(userMediaDocumentOrigin, topLevelDocumentOrigin);
2584
    auto originHash = userMediaOriginHash(userMediaDocumentOrigin, topLevelDocumentOrigin);
- a/Tools/WebKitTestRunner/TestController.h +8 lines
Lines 150-155 public: a/Tools/WebKitTestRunner/TestController.h_sec1
150
    unsigned userMediaPermissionRequestCountForOrigin(WKStringRef userMediaDocumentOriginString, WKStringRef topLevelDocumentOriginString);
150
    unsigned userMediaPermissionRequestCountForOrigin(WKStringRef userMediaDocumentOriginString, WKStringRef topLevelDocumentOriginString);
151
    void resetUserMediaPermissionRequestCountForOrigin(WKStringRef userMediaDocumentOriginString, WKStringRef topLevelDocumentOriginString);
151
    void resetUserMediaPermissionRequestCountForOrigin(WKStringRef userMediaDocumentOriginString, WKStringRef topLevelDocumentOriginString);
152
152
153
    // Device Orientation / Motion.
154
    bool handleDeviceOrientationAccessPermissionRequest(WKSecurityOriginRef);
155
    bool handleDeviceMotionAccessPermissionRequest(WKSecurityOriginRef);
156
153
    // Content Extensions.
157
    // Content Extensions.
154
    void configureContentExtensionForTest(const TestInvocation&);
158
    void configureContentExtensionForTest(const TestInvocation&);
155
    void resetContentExtensions();
159
    void resetContentExtensions();
Lines 199-204 public: a/Tools/WebKitTestRunner/TestController.h_sec2
199
    void setIgnoresViewportScaleLimits(bool);
203
    void setIgnoresViewportScaleLimits(bool);
200
204
201
    void setShouldDownloadUndisplayableMIMETypes(bool value) { m_shouldDownloadUndisplayableMIMETypes = value; }
205
    void setShouldDownloadUndisplayableMIMETypes(bool value) { m_shouldDownloadUndisplayableMIMETypes = value; }
206
    void setShouldAllowDeviceOrientationAccess(bool value) { m_shouldAllowDeviceOrientationAccess = value; }
207
    void setShouldAllowDeviceMotionAccess(bool value) { m_shouldAllowDeviceMotionAccess = value; }
202
208
203
    void setStatisticsDebugMode(bool value);
209
    void setStatisticsDebugMode(bool value);
204
    void setStatisticsPrevalentResourceForDebugMode(WKStringRef hostName);
210
    void setStatisticsPrevalentResourceForDebugMode(WKStringRef hostName);
Lines 508-513 private: a/Tools/WebKitTestRunner/TestController.h_sec3
508
    bool m_policyDelegateEnabled { false };
514
    bool m_policyDelegateEnabled { false };
509
    bool m_policyDelegatePermissive { false };
515
    bool m_policyDelegatePermissive { false };
510
    bool m_shouldDownloadUndisplayableMIMETypes { false };
516
    bool m_shouldDownloadUndisplayableMIMETypes { false };
517
    bool m_shouldAllowDeviceOrientationAccess { false };
518
    bool m_shouldAllowDeviceMotionAccess { false };
511
519
512
    bool m_rejectsProtectionSpaceAndContinueForAuthenticationChallenges { false };
520
    bool m_rejectsProtectionSpaceAndContinueForAuthenticationChallenges { false };
513
    bool m_handlesAuthenticationChallenges { false };
521
    bool m_handlesAuthenticationChallenges { false };
- a/Tools/WebKitTestRunner/TestInvocation.cpp +14 lines
Lines 747-752 void TestInvocation::didReceiveMessageFromInjectedBundle(WKStringRef messageName a/Tools/WebKitTestRunner/TestInvocation.cpp_sec1
747
        return;
747
        return;
748
    }
748
    }
749
749
750
    if (WKStringIsEqualToUTF8CString(messageName, "SetShouldAllowDeviceOrientationAccess")) {
751
        ASSERT(WKGetTypeID(messageBody) == WKBooleanGetTypeID());
752
        WKBooleanRef value = static_cast<WKBooleanRef>(messageBody);
753
        TestController::singleton().setShouldAllowDeviceOrientationAccess(WKBooleanGetValue(value));
754
        return;
755
    }
756
757
    if (WKStringIsEqualToUTF8CString(messageName, "SetShouldAllowDeviceMotionAccess")) {
758
        ASSERT(WKGetTypeID(messageBody) == WKBooleanGetTypeID());
759
        WKBooleanRef value = static_cast<WKBooleanRef>(messageBody);
760
        TestController::singleton().setShouldAllowDeviceMotionAccess(WKBooleanGetValue(value));
761
        return;
762
    }
763
750
    if (WKStringIsEqualToUTF8CString(messageName, "RunUIProcessScript")) {
764
    if (WKStringIsEqualToUTF8CString(messageName, "RunUIProcessScript")) {
751
        WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody);
765
        WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody);
752
        WKRetainPtr<WKStringRef> scriptKey(AdoptWK, WKStringCreateWithUTF8CString("Script"));
766
        WKRetainPtr<WKStringRef> scriptKey(AdoptWK, WKStringCreateWithUTF8CString("Script"));
- a/LayoutTests/ChangeLog +21 lines
Lines 1-3 a/LayoutTests/ChangeLog_sec1
1
2019-03-05  Chris Dumez  <cdumez@apple.com>
2
3
        Add support for Device Orientation / Motion permission API
4
        https://bugs.webkit.org/show_bug.cgi?id=195329
5
        <rdar://problem/47645367>
6
7
        Reviewed by NOBODY (OOPS!).
8
9
        Add layout test coverage.
10
11
        * TestExpectations:
12
        * fast/device-orientation/device-motion-request-permission-denied-expected.txt: Added.
13
        * fast/device-orientation/device-motion-request-permission-denied.html: Added.
14
        * fast/device-orientation/device-motion-request-permission-granted-expected.txt: Added.
15
        * fast/device-orientation/device-motion-request-permission-granted.html: Added.
16
        * fast/device-orientation/device-orientation-request-permission-denied-expected.txt: Added.
17
        * fast/device-orientation/device-orientation-request-permission-denied.html: Added.
18
        * fast/device-orientation/device-orientation-request-permission-granted-expected.txt: Added.
19
        * fast/device-orientation/device-orientation-request-permission-granted.html: Added.
20
        * platform/ios-wk2/TestExpectations:
21
1
2019-03-03  Darin Adler  <darin@apple.com>
22
2019-03-03  Darin Adler  <darin@apple.com>
2
23
3
        Prepare to improve handling of conversion of float to strings
24
        Prepare to improve handling of conversion of float to strings
- a/LayoutTests/TestExpectations +1 lines
Lines 32-37 fast/zooming/ios [ Skip ] a/LayoutTests/TestExpectations_sec1
32
fast/forms/ios [ Skip ]
32
fast/forms/ios [ Skip ]
33
fast/viewport/ios [ Skip ]
33
fast/viewport/ios [ Skip ]
34
fast/visual-viewport/ios/ [ Skip ]
34
fast/visual-viewport/ios/ [ Skip ]
35
fast/device-orientation [ Skip ]
35
fast/events/ios [ Skip ]
36
fast/events/ios [ Skip ]
36
fast/events/watchos [ Skip ]
37
fast/events/watchos [ Skip ]
37
fast/events/pointer/ios [ Skip ]
38
fast/events/pointer/ios [ Skip ]
- a/LayoutTests/fast/device-orientation/device-motion-request-permission-denied-expected.txt +14 lines
Line 0 a/LayoutTests/fast/device-orientation/device-motion-request-permission-denied-expected.txt_sec1
1
CONSOLE MESSAGE: line 12: No devicemotion events will be fired until permission has been requested and granted.
2
Received device motion access permission request for security origin "".
3
CONSOLE MESSAGE: line 18: No devicemotion events will be fired because permission to use the API was denied.
4
Basic testing for DeviceMotionEvent.requestPermission().
5
6
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
7
8
9
PASS result is "denied"
10
PASS result is "denied"
11
PASS successfullyParsed is true
12
13
TEST COMPLETE
14
- a/LayoutTests/fast/device-orientation/device-motion-request-permission-denied.html +28 lines
Line 0 a/LayoutTests/fast/device-orientation/device-motion-request-permission-denied.html_sec1
1
<!DOCTYPE html>
2
<html>
3
<body>
4
<script src="../../resources/js-test.js"></script>
5
<script>
6
description("Basic testing for DeviceMotionEvent.requestPermission().");
7
jsTestIsAsync = true;
8
9
if (window.testRunner)
10
    testRunner.setShouldAllowDeviceMotionAccess(false);
11
12
addEventListener("devicemotion", () => {});
13
14
DeviceMotionEvent.requestPermission().then((_result) => {
15
    result = _result;
16
    shouldBeEqualToString("result", "denied");
17
18
    addEventListener("devicemotion", () => {});
19
20
    DeviceMotionEvent.requestPermission().then((_result) => {
21
        result = _result;
22
        shouldBeEqualToString("result", "denied");
23
        finishJSTest();
24
    });
25
});
26
</script>
27
</body>
28
</html>
- a/LayoutTests/fast/device-orientation/device-motion-request-permission-granted-expected.txt +13 lines
Line 0 a/LayoutTests/fast/device-orientation/device-motion-request-permission-granted-expected.txt_sec1
1
CONSOLE MESSAGE: line 12: No devicemotion events will be fired until permission has been requested and granted.
2
Received device motion access permission request for security origin "".
3
Basic testing for DeviceMotionEvent.requestPermission().
4
5
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
6
7
8
PASS result is "granted"
9
PASS result is "granted"
10
PASS successfullyParsed is true
11
12
TEST COMPLETE
13
- a/LayoutTests/fast/device-orientation/device-motion-request-permission-granted.html +28 lines
Line 0 a/LayoutTests/fast/device-orientation/device-motion-request-permission-granted.html_sec1
1
<!DOCTYPE html>
2
<html>
3
<body>
4
<script src="../../resources/js-test.js"></script>
5
<script>
6
description("Basic testing for DeviceMotionEvent.requestPermission().");
7
jsTestIsAsync = true;
8
9
if (window.testRunner)
10
    testRunner.setShouldAllowDeviceMotionAccess(true);
11
12
addEventListener("devicemotion", () => {});
13
14
DeviceMotionEvent.requestPermission().then((_result) => {
15
    result = _result;
16
    shouldBeEqualToString("result", "granted");
17
18
    addEventListener("devicemotion", () => {});
19
20
    DeviceMotionEvent.requestPermission().then((_result) => {
21
        result = _result;
22
        shouldBeEqualToString("result", "granted");
23
        finishJSTest();
24
    });
25
});
26
</script>
27
</body>
28
</html>
- a/LayoutTests/fast/device-orientation/device-orientation-request-permission-denied-expected.txt +14 lines
Line 0 a/LayoutTests/fast/device-orientation/device-orientation-request-permission-denied-expected.txt_sec1
1
CONSOLE MESSAGE: line 12: No deviceorientation events will be fired until permission has been requested and granted.
2
Received device orientation access permission request for security origin "".
3
CONSOLE MESSAGE: line 18: No deviceorientation events will be fired because permission to use the API was denied.
4
Basic testing for DeviceOrientationEvent.requestPermission().
5
6
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
7
8
9
PASS result is "denied"
10
PASS result is "denied"
11
PASS successfullyParsed is true
12
13
TEST COMPLETE
14
- a/LayoutTests/fast/device-orientation/device-orientation-request-permission-denied.html +28 lines
Line 0 a/LayoutTests/fast/device-orientation/device-orientation-request-permission-denied.html_sec1
1
<!DOCTYPE html>
2
<html>
3
<body>
4
<script src="../../resources/js-test.js"></script>
5
<script>
6
description("Basic testing for DeviceOrientationEvent.requestPermission().");
7
jsTestIsAsync = true;
8
9
if (window.testRunner)
10
    testRunner.setShouldAllowDeviceOrientationAccess(false);
11
12
addEventListener("deviceorientation", () => {});
13
14
DeviceOrientationEvent.requestPermission().then((_result) => {
15
    result = _result;
16
    shouldBeEqualToString("result", "denied");
17
18
    addEventListener("deviceorientation", () => {});
19
20
    DeviceOrientationEvent.requestPermission().then((_result) => {
21
        result = _result;
22
        shouldBeEqualToString("result", "denied");
23
        finishJSTest();
24
    });
25
});
26
</script>
27
</body>
28
</html>
- a/LayoutTests/fast/device-orientation/device-orientation-request-permission-granted-expected.txt +13 lines
Line 0 a/LayoutTests/fast/device-orientation/device-orientation-request-permission-granted-expected.txt_sec1
1
CONSOLE MESSAGE: line 12: No deviceorientation events will be fired until permission has been requested and granted.
2
Received device orientation access permission request for security origin "".
3
Basic testing for DeviceOrientationEvent.requestPermission().
4
5
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
6
7
8
PASS result is "granted"
9
PASS result is "granted"
10
PASS successfullyParsed is true
11
12
TEST COMPLETE
13
- a/LayoutTests/fast/device-orientation/device-orientation-request-permission-granted.html +28 lines
Line 0 a/LayoutTests/fast/device-orientation/device-orientation-request-permission-granted.html_sec1
1
<!DOCTYPE html>
2
<html>
3
<body>
4
<script src="../../resources/js-test.js"></script>
5
<script>
6
description("Basic testing for DeviceOrientationEvent.requestPermission().");
7
jsTestIsAsync = true;
8
9
if (window.testRunner)
10
    testRunner.setShouldAllowDeviceOrientationAccess(true);
11
12
addEventListener("deviceorientation", () => {});
13
14
DeviceOrientationEvent.requestPermission().then((_result) => {
15
    result = _result;
16
    shouldBeEqualToString("result", "granted");
17
18
    addEventListener("deviceorientation", () => {});
19
20
    DeviceOrientationEvent.requestPermission().then((_result) => {
21
        result = _result;
22
        shouldBeEqualToString("result", "granted");
23
        finishJSTest();
24
    });
25
});
26
</script>
27
</body>
28
</html>
- a/LayoutTests/http/tests/events/device-orientation-motion-non-secure-context.html -2 / +2 lines
Lines 27-33 function runDeviceMotionTest() a/LayoutTests/http/tests/events/device-orientation-motion-non-secure-context.html_sec1
27
    debug("* Registering device motion listener");
27
    debug("* Registering device motion listener");
28
    addEventListener("devicemotion", function() { });
28
    addEventListener("devicemotion", function() { });
29
    internals.postTask(() => {
29
    internals.postTask(() => {
30
        shouldBeEqualToString("lastConsoleMessage", "Blocked attempt to add a device motion or orientation listener because the browsing context is not secure.");
30
        shouldBeEqualToString("lastConsoleMessage", "Blocked attempt to add a devicemotion event listener, reason: Browsing context is not secure.");
31
        finishJSTest();
31
        finishJSTest();
32
    });
32
    });
33
}
33
}
Lines 44-50 function runDeviceOrientationTest() a/LayoutTests/http/tests/events/device-orientation-motion-non-secure-context.html_sec2
44
    debug("* Registering device orientation listener");
44
    debug("* Registering device orientation listener");
45
    addEventListener("deviceorientation", function() { });
45
    addEventListener("deviceorientation", function() { });
46
    internals.postTask(() => {
46
    internals.postTask(() => {
47
        shouldBeEqualToString("lastConsoleMessage", "Blocked attempt to add a device motion or orientation listener because the browsing context is not secure.");
47
        shouldBeEqualToString("lastConsoleMessage", "Blocked attempt to add a deviceorientation event listener, reason: Browsing context is not secure.");
48
        runDeviceMotionTest();
48
        runDeviceMotionTest();
49
    });
49
    });
50
}
50
}
- a/LayoutTests/http/tests/events/device-orientation-motion-secure-context-expected.txt -2 / +3 lines
Lines 1-10 a/LayoutTests/http/tests/events/device-orientation-motion-secure-context-expected.txt_sec1
1
CONSOLE MESSAGE: line 37: Device Orientation API is not supported
1
CONSOLE MESSAGE: line 51: Device Orientation API is not supported
2
CONSOLE MESSAGE: line 19: Device Motion API is not supported
2
CONSOLE MESSAGE: line 28: Device Motion API is not supported
3
Tests that trying to set an event listener for deviceorientation and deviceorientation does not log an error in secure contexts.
3
Tests that trying to set an event listener for deviceorientation and deviceorientation does not log an error in secure contexts.
4
4
5
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
5
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
6
6
7
7
8
8
PASS successfullyParsed is true
9
PASS successfullyParsed is true
9
10
10
TEST COMPLETE
11
TEST COMPLETE
- a/LayoutTests/http/tests/events/device-orientation-motion-secure-context.html -13 / +34 lines
Lines 6-11 a/LayoutTests/http/tests/events/device-orientation-motion-secure-context.html_sec1
6
description("Tests that trying to set an event listener for deviceorientation and deviceorientation does not log an error in secure contexts.");
6
description("Tests that trying to set an event listener for deviceorientation and deviceorientation does not log an error in secure contexts.");
7
jsTestIsAsync = true;
7
jsTestIsAsync = true;
8
8
9
if (window.testRunner) {
10
    if (testRunner.setShouldAllowDeviceOrientationAccess)
11
        testRunner.setShouldAllowDeviceOrientationAccess(true);
12
13
    if (testRunner.setShouldAllowDeviceMotionAccess)
14
        testRunner.setShouldAllowDeviceMotionAccess(true);
15
}
16
9
// localhost is secure by default.
17
// localhost is secure by default.
10
18
11
let lastConsoleMessage = null;
19
let lastConsoleMessage = null;
Lines 15-33 internals.setConsoleMessageListener((message) => { a/LayoutTests/http/tests/events/device-orientation-motion-secure-context.html_sec2
15
23
16
function runDeviceMotionTest()
24
function runDeviceMotionTest()
17
{
25
{
26
    debug("");
18
    if (!window.DeviceMotionEvent) {
27
    if (!window.DeviceMotionEvent) {
19
        console.log("Device Motion API is not supported");
28
        console.log("Device Motion API is not supported");
20
        finishJSTest();
29
        finishJSTest();
21
        return;
30
        return;
22
    }
31
    }
23
32
24
    lastConsoleMessage = null;
33
    debug("* Requesting device motion access...");
25
    debug("");
34
    DeviceMotionEvent.requestPermission().then((_result) => {
26
    debug("* Registering device motion listener");
35
        result = _result;
27
    addEventListener("devicemotion", function() { });
36
        shouldBeEqualToString("result", "granted");
28
    internals.postTask(() => {
37
29
        shouldBeNull("lastConsoleMessage");
38
        lastConsoleMessage = null;
30
        finishJSTest();
39
        debug("* Registering device motion listener");
40
        addEventListener("devicemotion", function() { });
41
        internals.postTask(() => {
42
            shouldBeNull("lastConsoleMessage");
43
            finishJSTest();
44
        });
31
    });
45
    });
32
}
46
}
33
47
Lines 39-50 function runDeviceOrientationTest() a/LayoutTests/http/tests/events/device-orientation-motion-secure-context.html_sec3
39
        return;
53
        return;
40
    }
54
    }
41
55
42
    lastConsoleMessage = null;
56
    debug("* Requesting device orientation access...");
43
    debug("* Registering device orientation listener");
57
    DeviceOrientationEvent.requestPermission().then((_result) => {
44
    addEventListener("deviceorientation", function() { });
58
        result = _result;
45
    internals.postTask(() => {
59
        shouldBeEqualToString("result", "granted");
46
        shouldBeNull("lastConsoleMessage");
60
47
        runDeviceMotionTest();
61
        DeviceOrientationEvent.requestPermission
62
        lastConsoleMessage = null;
63
        debug("* Registering device orientation listener");
64
        addEventListener("deviceorientation", function() { });
65
        internals.postTask(() => {
66
            shouldBeNull("lastConsoleMessage");
67
            runDeviceMotionTest();
68
        });
48
    });
69
    });
49
}
70
}
50
71
- a/LayoutTests/platform/ios-wk2/TestExpectations +1 lines
Lines 7-12 a/LayoutTests/platform/ios-wk2/TestExpectations_sec1
7
#//////////////////////////////////////////////////////////////////////////////////////////
7
#//////////////////////////////////////////////////////////////////////////////////////////
8
8
9
compositing/ios [ Pass ]
9
compositing/ios [ Pass ]
10
fast/device-orientation [ Pass ]
10
fast/history/ios [ Pass ]
11
fast/history/ios [ Pass ]
11
fast/scrolling/ios [ Pass ]
12
fast/scrolling/ios [ Pass ]
12
fast/viewport/ios [ Pass ]
13
fast/viewport/ios [ Pass ]
- a/LayoutTests/platform/ios/http/tests/events/device-orientation-motion-non-secure-context-expected.txt -4 / +4 lines
Lines 1-15 a/LayoutTests/platform/ios/http/tests/events/device-orientation-motion-non-secure-context-expected.txt_sec1
1
CONSOLE MESSAGE: line 45: Blocked attempt to add a device motion or orientation listener because the browsing context is not secure.
1
CONSOLE MESSAGE: line 45: Blocked attempt to add a deviceorientation event listener, reason: Browsing context is not secure.
2
CONSOLE MESSAGE: line 28: Blocked attempt to add a device motion or orientation listener because the browsing context is not secure.
2
CONSOLE MESSAGE: line 28: Blocked attempt to add a devicemotion event listener, reason: Browsing context is not secure.
3
Tests that trying to set an event listener for deviceorientation and deviceorientation logs an error in non-secure contexts.
3
Tests that trying to set an event listener for deviceorientation and deviceorientation logs an error in non-secure contexts.
4
4
5
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
5
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
6
6
7
7
8
* Registering device orientation listener
8
* Registering device orientation listener
9
PASS lastConsoleMessage is "Blocked attempt to add a device motion or orientation listener because the browsing context is not secure."
9
PASS lastConsoleMessage is "Blocked attempt to add a deviceorientation event listener, reason: Browsing context is not secure."
10
10
11
* Registering device motion listener
11
* Registering device motion listener
12
PASS lastConsoleMessage is "Blocked attempt to add a device motion or orientation listener because the browsing context is not secure."
12
PASS lastConsoleMessage is "Blocked attempt to add a devicemotion event listener, reason: Browsing context is not secure."
13
PASS successfullyParsed is true
13
PASS successfullyParsed is true
14
14
15
TEST COMPLETE
15
TEST COMPLETE
- a/LayoutTests/platform/ios/http/tests/events/device-orientation-motion-secure-context-expected.txt +6 lines
Lines 1-11 a/LayoutTests/platform/ios/http/tests/events/device-orientation-motion-secure-context-expected.txt_sec1
1
Received device orientation access permission request for security origin "http://127.0.0.1:8000".
2
Received device motion access permission request for security origin "http://127.0.0.1:8000".
1
Tests that trying to set an event listener for deviceorientation and deviceorientation does not log an error in secure contexts.
3
Tests that trying to set an event listener for deviceorientation and deviceorientation does not log an error in secure contexts.
2
4
3
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
5
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
4
6
5
7
8
* Requesting device orientation access...
9
PASS result is "granted"
6
* Registering device orientation listener
10
* Registering device orientation listener
7
PASS lastConsoleMessage is null
11
PASS lastConsoleMessage is null
8
12
13
* Requesting device motion access...
14
PASS result is "granted"
9
* Registering device motion listener
15
* Registering device motion listener
10
PASS lastConsoleMessage is null
16
PASS lastConsoleMessage is null
11
PASS successfullyParsed is true
17
PASS successfullyParsed is true

Return to Bug 195329