Diff
Modified: trunk/LayoutTests/ChangeLog (242950 => 242951)
--- trunk/LayoutTests/ChangeLog 2019-03-14 18:40:50 UTC (rev 242950)
+++ trunk/LayoutTests/ChangeLog 2019-03-14 18:57:58 UTC (rev 242951)
@@ -1,3 +1,19 @@
+2019-03-14 Chris Dumez <[email protected]>
+
+ Device orientation's permission should only require a user gesture to prompt the user
+ https://bugs.webkit.org/show_bug.cgi?id=195731
+
+ Reviewed by Geoffrey Garen.
+
+ Update layout tests accordingly.
+
+ * fast/device-orientation/device-motion-request-permission-denied.html:
+ * fast/device-orientation/device-motion-request-permission-granted.html:
+ * fast/device-orientation/device-motion-request-permission-user-gesture-expected.txt:
+ * fast/device-orientation/device-orientation-request-permission-denied.html:
+ * fast/device-orientation/device-orientation-request-permission-granted.html:
+ * fast/device-orientation/device-orientation-request-permission-user-gesture-expected.txt:
+
2019-03-14 Dean Jackson <[email protected]>
Block all plugins smaller than 5x5px
Modified: trunk/LayoutTests/fast/device-orientation/device-motion-request-permission-denied.html (242950 => 242951)
--- trunk/LayoutTests/fast/device-orientation/device-motion-request-permission-denied.html 2019-03-14 18:40:50 UTC (rev 242950)
+++ trunk/LayoutTests/fast/device-orientation/device-motion-request-permission-denied.html 2019-03-14 18:57:58 UTC (rev 242951)
@@ -18,12 +18,10 @@
addEventListener("devicemotion", () => {});
- internals.withUserGesture(() => {
- DeviceMotionEvent.requestPermission().then((_result) => {
- result = _result;
- shouldBeEqualToString("result", "denied");
- finishJSTest();
- });
+ DeviceMotionEvent.requestPermission().then((_result) => {
+ result = _result;
+ shouldBeEqualToString("result", "denied");
+ finishJSTest();
});
});
});
Modified: trunk/LayoutTests/fast/device-orientation/device-motion-request-permission-granted.html (242950 => 242951)
--- trunk/LayoutTests/fast/device-orientation/device-motion-request-permission-granted.html 2019-03-14 18:40:50 UTC (rev 242950)
+++ trunk/LayoutTests/fast/device-orientation/device-motion-request-permission-granted.html 2019-03-14 18:57:58 UTC (rev 242951)
@@ -18,12 +18,10 @@
addEventListener("devicemotion", () => {});
- internals.withUserGesture(() => {
- DeviceMotionEvent.requestPermission().then((_result) => {
- result = _result;
- shouldBeEqualToString("result", "granted");
- finishJSTest();
- });
+ DeviceMotionEvent.requestPermission().then((_result) => {
+ result = _result;
+ shouldBeEqualToString("result", "granted");
+ finishJSTest();
});
});
});
Modified: trunk/LayoutTests/fast/device-orientation/device-motion-request-permission-user-gesture-expected.txt (242950 => 242951)
--- trunk/LayoutTests/fast/device-orientation/device-motion-request-permission-user-gesture-expected.txt 2019-03-14 18:40:50 UTC (rev 242950)
+++ trunk/LayoutTests/fast/device-orientation/device-motion-request-permission-user-gesture-expected.txt 2019-03-14 18:57:58 UTC (rev 242951)
@@ -1,4 +1,4 @@
-CONSOLE MESSAGE: line 14: NotAllowedError: Calling requestPermission() requires a user gesture
+CONSOLE MESSAGE: line 14: NotAllowedError: Requesting device orientation or motion access requires a user gesture
Tests that DeviceMotionEvent.requestPermission() requires a user gesture.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
Modified: trunk/LayoutTests/fast/device-orientation/device-orientation-request-permission-denied.html (242950 => 242951)
--- trunk/LayoutTests/fast/device-orientation/device-orientation-request-permission-denied.html 2019-03-14 18:40:50 UTC (rev 242950)
+++ trunk/LayoutTests/fast/device-orientation/device-orientation-request-permission-denied.html 2019-03-14 18:57:58 UTC (rev 242951)
@@ -18,12 +18,10 @@
addEventListener("deviceorientation", () => {});
- internals.withUserGesture(() => {
- DeviceOrientationEvent.requestPermission().then((_result) => {
- result = _result;
- shouldBeEqualToString("result", "denied");
- finishJSTest();
- });
+ DeviceOrientationEvent.requestPermission().then((_result) => {
+ result = _result;
+ shouldBeEqualToString("result", "denied");
+ finishJSTest();
});
});
});
Modified: trunk/LayoutTests/fast/device-orientation/device-orientation-request-permission-granted.html (242950 => 242951)
--- trunk/LayoutTests/fast/device-orientation/device-orientation-request-permission-granted.html 2019-03-14 18:40:50 UTC (rev 242950)
+++ trunk/LayoutTests/fast/device-orientation/device-orientation-request-permission-granted.html 2019-03-14 18:57:58 UTC (rev 242951)
@@ -18,12 +18,10 @@
addEventListener("deviceorientation", () => {});
- internals.withUserGesture(() => {
- DeviceOrientationEvent.requestPermission().then((_result) => {
- result = _result;
- shouldBeEqualToString("result", "granted");
- finishJSTest();
- });
+ DeviceOrientationEvent.requestPermission().then((_result) => {
+ result = _result;
+ shouldBeEqualToString("result", "granted");
+ finishJSTest();
});
});
});
Modified: trunk/LayoutTests/fast/device-orientation/device-orientation-request-permission-user-gesture-expected.txt (242950 => 242951)
--- trunk/LayoutTests/fast/device-orientation/device-orientation-request-permission-user-gesture-expected.txt 2019-03-14 18:40:50 UTC (rev 242950)
+++ trunk/LayoutTests/fast/device-orientation/device-orientation-request-permission-user-gesture-expected.txt 2019-03-14 18:57:58 UTC (rev 242951)
@@ -1,4 +1,4 @@
-CONSOLE MESSAGE: line 14: NotAllowedError: Calling requestPermission() requires a user gesture
+CONSOLE MESSAGE: line 14: NotAllowedError: Requesting device orientation or motion access requires a user gesture
Tests that DeviceOrientationEvent.requestPermission() requires a user gesture.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
Modified: trunk/Source/WebCore/ChangeLog (242950 => 242951)
--- trunk/Source/WebCore/ChangeLog 2019-03-14 18:40:50 UTC (rev 242950)
+++ trunk/Source/WebCore/ChangeLog 2019-03-14 18:57:58 UTC (rev 242951)
@@ -1,3 +1,25 @@
+2019-03-14 Chris Dumez <[email protected]>
+
+ Device orientation's permission should only require a user gesture to prompt the user
+ https://bugs.webkit.org/show_bug.cgi?id=195731
+
+ Reviewed by Geoffrey Garen.
+
+ Device orientation's permission should only require a user gesture to prompt the user. If the
+ user already made a decision, we should resolve the promise with this decision, even without
+ user gesture.
+
+ This is useful for JS to figure out if they are access to device orientation or not because
+ showing UI for the user to give permission.
+
+ No new tests, updated existing tests.
+
+ * dom/DeviceOrientationAndMotionAccessController.cpp:
+ (WebCore::DeviceOrientationAndMotionAccessController::shouldAllowAccess):
+ * dom/DeviceOrientationAndMotionAccessController.h:
+ * dom/DeviceOrientationOrMotionEvent.cpp:
+ (WebCore::DeviceOrientationOrMotionEvent::requestPermission):
+
2019-03-14 Youenn Fablet <[email protected]>
Reset storage quota when clearing IDB/Cache API entries
Modified: trunk/Source/WebCore/dom/DeviceOrientationAndMotionAccessController.cpp (242950 => 242951)
--- trunk/Source/WebCore/dom/DeviceOrientationAndMotionAccessController.cpp 2019-03-14 18:40:50 UTC (rev 242950)
+++ trunk/Source/WebCore/dom/DeviceOrientationAndMotionAccessController.cpp 2019-03-14 18:57:58 UTC (rev 242951)
@@ -34,6 +34,7 @@
#include "Document.h"
#include "Frame.h"
#include "Page.h"
+#include "UserGestureIndicator.h"
namespace WebCore {
@@ -43,11 +44,14 @@
ASSERT(&m_document.topDocument() == &m_document);
}
-void DeviceOrientationAndMotionAccessController::shouldAllowAccess(Function<void(bool granted)>&& callback)
+void DeviceOrientationAndMotionAccessController::shouldAllowAccess(Function<void(ExceptionOr<bool> granted)>&& callback)
{
if (m_accessState)
return callback(*m_accessState);
+ if (!UserGestureIndicator::processingUserGesture())
+ return callback(Exception { NotAllowedError, "Requesting device orientation or motion access requires a user gesture"_s });
+
auto* page = m_document.page();
if (!page)
return callback(false);
Modified: trunk/Source/WebCore/dom/DeviceOrientationAndMotionAccessController.h (242950 => 242951)
--- trunk/Source/WebCore/dom/DeviceOrientationAndMotionAccessController.h 2019-03-14 18:40:50 UTC (rev 242950)
+++ trunk/Source/WebCore/dom/DeviceOrientationAndMotionAccessController.h 2019-03-14 18:57:58 UTC (rev 242951)
@@ -27,6 +27,7 @@
#if ENABLE(DEVICE_ORIENTATION)
+#include "ExceptionOr.h"
#include <wtf/Function.h>
#include <wtf/Vector.h>
#include <wtf/WeakPtr.h>
@@ -41,7 +42,7 @@
explicit DeviceOrientationAndMotionAccessController(Document&);
const Optional<bool>& accessState() const { return m_accessState; }
- void shouldAllowAccess(Function<void(bool granted)>&&);
+ void shouldAllowAccess(Function<void(ExceptionOr<bool> granted)>&&);
private:
void setAccessState(bool);
Modified: trunk/Source/WebCore/dom/DeviceOrientationOrMotionEvent.cpp (242950 => 242951)
--- trunk/Source/WebCore/dom/DeviceOrientationOrMotionEvent.cpp 2019-03-14 18:40:50 UTC (rev 242950)
+++ trunk/Source/WebCore/dom/DeviceOrientationOrMotionEvent.cpp 2019-03-14 18:57:58 UTC (rev 242951)
@@ -27,7 +27,6 @@
#include "DeviceOrientationOrMotionEvent.h"
#include "Document.h"
-#include "UserGestureIndicator.h"
namespace WebCore {
@@ -38,9 +37,6 @@
if (!window)
return promise.reject(Exception { InvalidStateError, "No browsing context"_s });
- if (!UserGestureIndicator::processingUserGesture())
- return promise.reject(Exception { NotAllowedError, "Calling requestPermission() requires a user gesture"_s });
-
String errorMessage;
if (!window->isAllowedToUseDeviceMotionOrientation(errorMessage)) {
document.addConsoleMessage(MessageSource::JS, MessageLevel::Warning, makeString("Call to requestPermission() failed, reason: ", errorMessage, "."));
@@ -47,8 +43,10 @@
return promise.resolve(PermissionState::Denied);
}
- document.deviceOrientationAndMotionAccessController().shouldAllowAccess([promise = WTFMove(promise)](bool granted) mutable {
- promise.resolve(granted ? PermissionState::Granted : PermissionState::Denied);
+ document.deviceOrientationAndMotionAccessController().shouldAllowAccess([promise = WTFMove(promise)](ExceptionOr<bool> granted) mutable {
+ if (granted.hasException())
+ return promise.reject(granted.releaseException());
+ promise.resolve(granted.returnValue() ? PermissionState::Granted : PermissionState::Denied);
});
}
#endif