summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/orientation-event/device-orientation-events-unavailable-on-insecure-origins.html
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/orientation-event/device-orientation-events-unavailable-on-insecure-origins.html')
-rw-r--r--testing/web-platform/tests/orientation-event/device-orientation-events-unavailable-on-insecure-origins.html61
1 files changed, 61 insertions, 0 deletions
diff --git a/testing/web-platform/tests/orientation-event/device-orientation-events-unavailable-on-insecure-origins.html b/testing/web-platform/tests/orientation-event/device-orientation-events-unavailable-on-insecure-origins.html
new file mode 100644
index 0000000000..6d2eee402f
--- /dev/null
+++ b/testing/web-platform/tests/orientation-event/device-orientation-events-unavailable-on-insecure-origins.html
@@ -0,0 +1,61 @@
+<!DOCTYPE html>
+<title>Device Sensor Events not exposed to insecure origins</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/common/get-host-info.sub.js"></script>
+<script src="/resources/testdriver.js"></script>
+<script src="/resources/testdriver-vendor.js"></script>
+<script src="resources/orientation-event-helpers.js"></script>
+<script>
+
+if (window.location.origin != get_host_info().HTTP_ORIGIN) {
+ window.location = get_host_info().HTTP_ORIGIN + window.location.pathname;
+ promise_test(_ => new Promise(_ => {}), "Stall tests on the wrong host.");
+} else {
+ test(() => {
+ assert_false('DeviceMotionEvent' in window);
+ assert_false('DeviceOrientationEvent' in window);
+ assert_false('DeviceOrientationAbsoluteEvent' in window);
+ assert_false('DeviceMotionEventAcceleration' in window);
+ assert_false('DeviceMotionEventRotationRate' in window);
+ assert_false('ondevicemotion' in window);
+ assert_false('ondeviceorientation' in window);
+ assert_false('ondeviceorientationabsolute' in window);
+ }, 'Event interfaces and event handlers are not exposed on `window`.');
+
+ promise_test(async (t) => {
+ const helper = new SensorTestHelper(t, 'devicemotion');
+ await helper.initializeSensors();
+ const motionData = generateMotionData(1, 2, 3,
+ 4, 5, 6,
+ 7, 8, 9);
+ await helper.setData(motionData);
+
+ window.ondevicemotion = t.unreached_func("devicemotion event should not be fired.");
+
+ await new Promise(r => t.step_timeout(r, 1000));
+ }, 'addEventListener() for `devicemotion` does not crash but the handler never fires.');
+
+ promise_test(async (t) => {
+ const helper = new SensorTestHelper(t, 'deviceorientation');
+ await helper.initializeSensors();
+ const orientationData = generateOrientationData(1.1, 2.2, 3.3, false);
+ await helper.setData(orientationData);
+
+ window.ondeviceorientation = t.unreached_func("deviceorientation event should not be fired.");
+
+ await new Promise(r => t.step_timeout(r, 1000));
+ }, 'addEventListener() for `deviceorientation` does not crash but the handler never fires.');
+
+ promise_test(async (t) => {
+ const helper = new SensorTestHelper(t, 'deviceorientationabsolute');
+ await helper.initializeSensors();
+ const orientationData = generateOrientationData(1.1, 2.2, 3.3, true);
+ await helper.setData(orientationData);
+
+ window.ondeviceorientationabsolute = t.unreached_func("deviceorientationabsolute event should not be fired.");
+
+ await new Promise(r => t.step_timeout(r, 1000));
+ }, 'addEventListener() for `deviceorientationabsolute` does not crash but the handler never fires.');
+}
+</script>