blob: 2f6e73dba1ef73c0ef91561029540b649ab337ef [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 logs an error in non-secure contexts.");
jsTestIsAsync = true;
// localhost is secure by default.
internals.markContextAsInsecure();
let lastConsoleMessage = null;
internals.setConsoleMessageListener((message) => {
lastConsoleMessage = message;
});
function runDeviceMotionTest()
{
if (!window.DeviceMotionEvent) {
console.log("Device Motion API is not supported");
finishJSTest();
return;
}
lastConsoleMessage = null;
debug("");
debug("* Registering device motion listener");
addEventListener("devicemotion", function() { });
internals.postTask(() => {
shouldBeEqualToString("lastConsoleMessage", "No device motion events will be fired, reason: Browsing context is not secure.");
finishJSTest();
});
}
function runDeviceOrientationTest()
{
if (!window.DeviceOrientationEvent) {
console.log("Device Orientation API is not supported");
runDeviceMotionTest();
return;
}
lastConsoleMessage = null;
debug("* Registering device orientation listener");
addEventListener("deviceorientation", function() { });
internals.postTask(() => {
shouldBeEqualToString("lastConsoleMessage", "No device orientation events will be fired, reason: Browsing context is not secure.");
runDeviceMotionTest();
});
}
onload = runDeviceOrientationTest;
</script>
</body>
</html>