blob: c82c47954dff516be3a9963b2eefcb3327596bdf [file] [log] [blame]
<!DOCTYPE html>
<html>
<body>
<script src="/js-test-resources/js-test.js"></script>
<script>
description("Tests that trying to set an event listener for deviceorientation and deviceorientation does not log an error in secure contexts.");
jsTestIsAsync = true;
if (window.testRunner) {
if (testRunner.setShouldAllowDeviceOrientationAndMotionAccess)
testRunner.setShouldAllowDeviceOrientationAndMotionAccess(true);
}
// localhost is secure by default.
if (window.internals)
internals.markContextAsInsecure();
let lastConsoleMessage = null;
internals.setConsoleMessageListener((message) => {
lastConsoleMessage = message;
});
function runDeviceMotionTest()
{
debug("");
if (!window.DeviceMotionEvent) {
console.log("Device Motion API is not supported");
finishJSTest();
return;
}
debug("* Requesting device motion access...");
internals.withUserGesture(() => {
DeviceMotionEvent.requestPermission().then((_result) => {
result = _result;
shouldBeEqualToString("result", "denied");
finishJSTest();
});
});
}
function runDeviceOrientationTest()
{
if (!window.DeviceOrientationEvent) {
console.log("Device Orientation API is not supported");
runDeviceMotionTest();
return;
}
debug("* Requesting device orientation access...");
internals.withUserGesture(() => {
DeviceOrientationEvent.requestPermission().then((_result) => {
result = _result;
shouldBeEqualToString("result", "denied");
runDeviceMotionTest();
});
});
}
onload = runDeviceOrientationTest;
</script>
</body>
</html>