summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/orientation-event/orientation
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/orientation-event/orientation')
-rw-r--r--testing/web-platform/tests/orientation-event/orientation/absolute-fallback.https.html23
-rw-r--r--testing/web-platform/tests/orientation-event/orientation/add-listener-from-callback.https.html59
-rw-r--r--testing/web-platform/tests/orientation-event/orientation/basic-operation-absolute.https.html34
-rw-r--r--testing/web-platform/tests/orientation-event/orientation/basic-operation.https.html34
-rw-r--r--testing/web-platform/tests/orientation-event/orientation/create-event.https.html40
-rw-r--r--testing/web-platform/tests/orientation-event/orientation/horizontal-surface-manual.https.html34
-rw-r--r--testing/web-platform/tests/orientation-event/orientation/multiple-event-listeners.https.html27
-rw-r--r--testing/web-platform/tests/orientation-event/orientation/no-synchronous-events.https.html24
-rw-r--r--testing/web-platform/tests/orientation-event/orientation/null-values.https.html27
-rw-r--r--testing/web-platform/tests/orientation-event/orientation/optional-event-properties.https.html73
-rw-r--r--testing/web-platform/tests/orientation-event/orientation/page-visibility.https.html50
-rw-r--r--testing/web-platform/tests/orientation-event/orientation/requestPermission.https.window.js48
-rw-r--r--testing/web-platform/tests/orientation-event/orientation/t006-manual.https.html30
-rw-r--r--testing/web-platform/tests/orientation-event/orientation/t009-manual.https.html30
-rw-r--r--testing/web-platform/tests/orientation-event/orientation/t010-manual.https.html30
-rw-r--r--testing/web-platform/tests/orientation-event/orientation/t012-manual.https.html41
-rw-r--r--testing/web-platform/tests/orientation-event/orientation/updates.https.html37
17 files changed, 641 insertions, 0 deletions
diff --git a/testing/web-platform/tests/orientation-event/orientation/absolute-fallback.https.html b/testing/web-platform/tests/orientation-event/orientation/absolute-fallback.https.html
new file mode 100644
index 0000000000..27a430728e
--- /dev/null
+++ b/testing/web-platform/tests/orientation-event/orientation/absolute-fallback.https.html
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/testdriver.js"></script>
+<script src="/resources/testdriver-vendor.js"></script>
+<script src="../resources/orientation-event-helpers.js"></script>
+<script>
+'use strict';
+
+promise_test(async (t) => {
+ const helper = new SensorTestHelper(t, 'deviceorientation');
+ await helper.grantSensorsPermissions();
+
+ // Make the relative orientation sensor unavailable and set mock data for
+ // the absolute one.
+ await helper.initializeSensors({enabledSensors: ['absolute-orientation'], disabledSensors: ['relative-orientation']});
+ const orientationData = generateOrientationData(1.1, 2.2, 3.3, true);
+
+ // Check sensor values when fallback is activated.
+ await helper.setData(orientationData);
+ await waitForEvent(getExpectedOrientationEvent(orientationData));
+}, 'Tests that deviceorientation falls back to using absolute orientation data if relative is unavailable.');
+</script>
diff --git a/testing/web-platform/tests/orientation-event/orientation/add-listener-from-callback.https.html b/testing/web-platform/tests/orientation-event/orientation/add-listener-from-callback.https.html
new file mode 100644
index 0000000000..7f664ab400
--- /dev/null
+++ b/testing/web-platform/tests/orientation-event/orientation/add-listener-from-callback.https.html
@@ -0,0 +1,59 @@
+<!DOCTYPE html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/testdriver.js"></script>
+<script src="/resources/testdriver-vendor.js"></script>
+<script src="../resources/orientation-event-helpers.js"></script>
+<script>
+'use strict';
+
+promise_test(async (t) => {
+ const helper = new SensorTestHelper(t, 'deviceorientation');
+ await helper.grantSensorsPermissions();
+ await helper.initializeSensors();
+
+ const orientationData1 = generateOrientationData(1.1, 2.2, 3.3, false);
+ const orientationData2 = generateOrientationData(11.1, 22.2, 33.3, false);
+
+ let firstListener = null;
+ let secondListener = null;
+ let firstEventCount = 0;
+ let firstPromise = new Promise(resolve => {
+ firstListener = async (event) => {
+ assert_true(event instanceof DeviceOrientationEvent, 'event is DeviceOrientationEvent');
+ assert_equals(event.type, 'deviceorientation', 'event.type is devicemotion');
+ assert_true(event.target instanceof Window, 'event is fired on the window object');
+ assertEventEquals(event, getExpectedOrientationEvent(orientationData1));
+ window.removeEventListener('deviceorientation', firstListener);
+ // Some implementations (e.g. Chromium) work without the call below
+ // because they disconnect from the virtual sensor in the
+ // removeEventListener() call above before connecting again, and in this
+ // case the same orientation data is still considered a significant
+ // change. This is an implementation detail though, so we explicitly pass
+ // different data here.
+ await helper.setData(orientationData2);
+ if (++firstEventCount == 1) {
+ window.addEventListener('deviceorientation', secondListener);
+ }
+ resolve(event);
+ };
+ });
+
+ let secondEventCount = 0;
+ let secondPromise = new Promise(resolve => {
+ secondListener = (event) => {
+ assertEventEquals(event, getExpectedOrientationEvent(orientationData2));
+ window.removeEventListener('deviceorientation', secondListener);
+ ++secondEventCount;
+ resolve(event);
+ };
+ });
+
+ await helper.setData(orientationData1);
+ window.addEventListener('deviceorientation', firstListener);
+ await firstPromise;
+ await secondPromise;
+ assert_equals(firstEventCount, 1, "Too many events fired for the first listener");
+ assert_equals(secondEventCount, 1, "Too many events fired for the second listener");
+}, 'Tests that adding a new deviceorientation event listener from a callback works as expected.');
+</script>
diff --git a/testing/web-platform/tests/orientation-event/orientation/basic-operation-absolute.https.html b/testing/web-platform/tests/orientation-event/orientation/basic-operation-absolute.https.html
new file mode 100644
index 0000000000..bebd69b952
--- /dev/null
+++ b/testing/web-platform/tests/orientation-event/orientation/basic-operation-absolute.https.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/testdriver.js"></script>
+<script src="/resources/testdriver-vendor.js"></script>
+<script src="../resources/orientation-event-helpers.js"></script>
+<script>
+'use strict';
+
+promise_test(async (t) => {
+ const helper = new SensorTestHelper(t, 'deviceorientationabsolute');
+ await helper.grantSensorsPermissions();
+ await helper.initializeSensors();
+
+ const orientationData = generateOrientationData(1.1, 2.2, 3.3, true);
+ await helper.setData(orientationData);
+ await waitForEvent(getExpectedAbsoluteOrientationEvent(orientationData));
+}, 'Tests basic operation of deviceorientationabsolute event using mock data.');
+
+promise_test(async (t) => {
+ const helper = new SensorTestHelper(t, 'deviceorientationabsolute');
+ await helper.grantSensorsPermissions();
+ await helper.initializeSensors({disabledSensors: ['absolute-orientation']});
+
+ const orientationData = generateOrientationData(null, null, null, true);
+ const watcher = new EventWatcher(t, window, ['deviceorientationabsolute']);
+
+ const event = await watcher.wait_for('deviceorientationabsolute');
+ assert_equals(event.type, 'deviceorientationabsolute', 'type is set to \"deviceorientationabsolute\"');
+ assert_true(event instanceof DeviceOrientationEvent, 'event is DeviceOrientationEvent');
+
+ assertEventEquals(event, getExpectedAbsoluteOrientationEvent(orientationData));
+}, 'If UA can never provide absolute information, the event should be fired as a null event.');
+</script>
diff --git a/testing/web-platform/tests/orientation-event/orientation/basic-operation.https.html b/testing/web-platform/tests/orientation-event/orientation/basic-operation.https.html
new file mode 100644
index 0000000000..c4d26e3744
--- /dev/null
+++ b/testing/web-platform/tests/orientation-event/orientation/basic-operation.https.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/testdriver.js"></script>
+<script src="/resources/testdriver-vendor.js"></script>
+<script src="../resources/orientation-event-helpers.js"></script>
+<script>
+'use strict';
+
+promise_test(async (t) => {
+ const helper = new SensorTestHelper(t, 'deviceorientation');
+ await helper.grantSensorsPermissions();
+ await helper.initializeSensors();
+
+ const orientationData = generateOrientationData(1.1, 2.2, 3.3, false);
+ await helper.setData(orientationData);
+ await waitForEvent(getExpectedOrientationEvent(orientationData));
+}, 'Tests basic operation of deviceorientation event using mock data.');
+
+promise_test(async (t) => {
+ const helper = new SensorTestHelper(t, 'deviceorientation');
+ await helper.grantSensorsPermissions();
+ await helper.initializeSensors({disabledSensors: ['relative-orientation']});
+
+ const orientationData = generateOrientationData(null, null, null, false);
+ const watcher = new EventWatcher(t, window, ['deviceorientation']);
+
+ const event = await watcher.wait_for('deviceorientation');
+ assert_equals(event.type, 'deviceorientation', 'type is set to \"deviceorientation\"');
+ assert_true(event instanceof DeviceOrientationEvent, 'event is DeviceOrientationEvent');
+
+ assertEventEquals(event, getExpectedOrientationEvent(orientationData));
+}, 'If UA can never provide orientation information, the event should be fired as a null event.');
+</script>
diff --git a/testing/web-platform/tests/orientation-event/orientation/create-event.https.html b/testing/web-platform/tests/orientation-event/orientation/create-event.https.html
new file mode 100644
index 0000000000..a21f95655e
--- /dev/null
+++ b/testing/web-platform/tests/orientation-event/orientation/create-event.https.html
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+'use strict';
+
+test(test => {
+ const event = document.createEvent('DeviceOrientationEvent');
+ const newEvent = new CustomEvent("deviceorientation", {
+ bubbles: false, cancelable: false,
+ alpha: 1.0,
+ beta: 2.0,
+ gama: 3.0,
+ absolute: false
+ });
+
+ assert_equals(typeof event, 'object');
+ assert_equals(Object.getPrototypeOf(event), DeviceOrientationEvent.prototype);
+
+ assert_true('type' in event);
+ assert_true('bubbles' in event);
+ assert_true('cancelable' in event);
+ assert_true('alpha' in event);
+ assert_true('beta' in event);
+ assert_true('gamma' in event);
+ assert_true('absolute' in event);
+
+ assert_equals(typeof event.type, 'string');
+ assert_equals(typeof event.bubbles, 'boolean');
+ assert_equals(typeof event.cancelable, 'boolean');
+ assert_equals(typeof event.alpha, 'object');
+ assert_equals(typeof event.beta, 'object');
+ assert_equals(typeof event.gamma, 'object');
+ assert_equals(typeof event.absolute, 'boolean');
+
+ assert_equals(newEvent.type, "deviceorientation");
+ assert_false(newEvent.bubbles);
+ assert_false(newEvent.cancelable);
+}, 'Tests that document.createEvent() works with DeviceOrientationEvent.');
+</script>
diff --git a/testing/web-platform/tests/orientation-event/orientation/horizontal-surface-manual.https.html b/testing/web-platform/tests/orientation-event/orientation/horizontal-surface-manual.https.html
new file mode 100644
index 0000000000..0b7302e704
--- /dev/null
+++ b/testing/web-platform/tests/orientation-event/orientation/horizontal-surface-manual.https.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>DeviceOrientationEvent: A device lying flat on a horizontal surface</title>
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ <link rel="author' title='Mosquito FP7">
+ <link rel="reviewer author" title="Zhiqiang Zhang" href="mailto:zhiqiang.zhang@intel.com"> <!-- 2013-10-12 -->
+ </head>
+ <body>
+ <p>Put the device on a horizontal surface to run the test.</p>
+ <div id="log"></div>
+ <script>
+ var gamma, beta;
+ var run = false;
+ window.addEventListener("deviceorientation", function(e) {
+ if (!run) {
+ run = true;
+ gamma = e.gamma; // Gamma : angle par rapport a x
+ beta = e.beta; // Beta : angle par rapport a y
+ }
+ }, false);
+
+ test(function() {
+ assert_approx_equals(gamma, 0, 2);
+ }, "X angle");
+
+ test(function() {
+ assert_approx_equals(beta, 0, 2);
+ }, "Y angle");
+ </script>
+ </body>
+</html>
+
diff --git a/testing/web-platform/tests/orientation-event/orientation/multiple-event-listeners.https.html b/testing/web-platform/tests/orientation-event/orientation/multiple-event-listeners.https.html
new file mode 100644
index 0000000000..a32f9f3a1f
--- /dev/null
+++ b/testing/web-platform/tests/orientation-event/orientation/multiple-event-listeners.https.html
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/testdriver.js"></script>
+<script src="/resources/testdriver-vendor.js"></script>
+<script src="../resources/orientation-event-helpers.js"></script>
+<script>
+'use strict';
+
+promise_test(async (t) => {
+ const helper = new SensorTestHelper(t, 'deviceorientation');
+ await helper.grantSensorsPermissions();
+ await helper.initializeSensors();
+
+ const orientationData1 = generateOrientationData(1, 2, 3, false);
+ await helper.setData(orientationData1);
+
+ await Promise.all([
+ waitForEvent(getExpectedOrientationEvent(orientationData1)),
+ waitForEvent(getExpectedOrientationEvent(orientationData1))
+ ]);
+
+ const orientationData2 = generateOrientationData(11, 12, 13, false);
+ await helper.setData(orientationData2);
+ await waitForEvent(getExpectedOrientationEvent(orientationData2));
+}, 'Tests using multiple event handlers for the Device Orientation API.');
+</script>
diff --git a/testing/web-platform/tests/orientation-event/orientation/no-synchronous-events.https.html b/testing/web-platform/tests/orientation-event/orientation/no-synchronous-events.https.html
new file mode 100644
index 0000000000..97dccfbc31
--- /dev/null
+++ b/testing/web-platform/tests/orientation-event/orientation/no-synchronous-events.https.html
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/testdriver.js"></script>
+<script src="/resources/testdriver-vendor.js"></script>
+<script src="../resources/orientation-event-helpers.js"></script>
+<script>
+'use strict';
+
+promise_test(async (t) => {
+ const helper = new SensorTestHelper(t, 'deviceorientation');
+ await helper.grantSensorsPermissions();
+ await helper.initializeSensors();
+
+ const orientationData = generateOrientationData(1.1, 2.2, 3.3, false);
+ await helper.setData(orientationData);
+
+ return new Promise((resolve, reject) => {
+ let result = reject;
+ window.addEventListener('deviceorientation', event => result());
+ result = resolve;
+ });
+}, 'Tests that events are never fired synchronously from a call to window.addEventListener().');
+</script>
diff --git a/testing/web-platform/tests/orientation-event/orientation/null-values.https.html b/testing/web-platform/tests/orientation-event/orientation/null-values.https.html
new file mode 100644
index 0000000000..c54d73da50
--- /dev/null
+++ b/testing/web-platform/tests/orientation-event/orientation/null-values.https.html
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/testdriver.js"></script>
+<script src="/resources/testdriver-vendor.js"></script>
+<script src="../resources/orientation-event-helpers.js"></script>
+<script>
+'use strict';
+
+promise_test(async (t) => {
+ const helper = new SensorTestHelper(t, 'deviceorientation');
+ await helper.grantSensorsPermissions();
+ await helper.initializeSensors({disabledSensors: ['absolute-orientation', 'relative-orientation']});
+
+ const orientationData1 = generateOrientationData(1.1, 2.2, 3.3, false);
+ // Currently it is not possible to set individual values to null because the
+ // parsing algorithms used by
+ // https://w3c.github.io/sensors/#update-virtual-sensor-reading-command
+ // always expect numbers.
+ const orientationData2 = generateOrientationData(null, null, null, false);
+
+ // An example how setting relative-orientation sensor as disabled will output
+ // null values. Even if we try to set non null values to sensor.
+ await helper.setData(orientationData1);
+ await waitForEvent(getExpectedOrientationEvent(orientationData2));
+}, 'Tests using null values for some of the event properties.');
+</script>
diff --git a/testing/web-platform/tests/orientation-event/orientation/optional-event-properties.https.html b/testing/web-platform/tests/orientation-event/orientation/optional-event-properties.https.html
new file mode 100644
index 0000000000..150ce5ca1d
--- /dev/null
+++ b/testing/web-platform/tests/orientation-event/orientation/optional-event-properties.https.html
@@ -0,0 +1,73 @@
+<!DOCTYPE html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+'use strict';
+
+test(test => {
+ event = document.createEvent('DeviceOrientationEvent');
+ assert_equals(event.type, "");
+ assert_equals(event.alpha, null);
+ assert_equals(event.beta, null);
+ assert_equals(event.gamma, null);
+ assert_false(event.absolute);
+}, 'Tests creating a DeviceOrientationEvent.');
+
+test(test => {
+ event = new DeviceOrientationEvent('foo', {alpha: 0, beta: 1, gamma: 2, absolute: false});
+ assert_equals(event.type, "foo");
+ assert_equals(event.alpha, 0);
+ assert_equals(event.beta, 1);
+ assert_equals(event.gamma, 2);
+ assert_false(event.absolute);
+}, 'Tests no missing value (absolute field is false).');
+
+test(test => {
+ event = new DeviceOrientationEvent('', {alpha: 0, beta: 1, gamma: 2, absolute: true});
+ assert_equals(event.alpha, 0);
+ assert_equals(event.beta, 1);
+ assert_equals(event.gamma, 2);
+ assert_true(event.absolute);
+}, 'Tests no missing value (absolute field is true).');
+
+test(test => {
+ event = new DeviceOrientationEvent('');
+ assert_equals(event.alpha, null);
+ assert_equals(event.beta, null);
+ assert_equals(event.gamma, null);
+ assert_false(event.absolute);
+}, 'Tests DeviceOrientationEvent default constructor.');
+
+test(test => {
+ event = new DeviceOrientationEvent('', {alpha: [], beta: [], gamma: [], absolute: []});
+ assert_equals(event.alpha, 0);
+ assert_equals(event.beta, 0);
+ assert_equals(event.gamma, 0);
+ assert_true(event.absolute);
+}, 'Tests all values are empty array.');
+
+test(test => {
+ event = new DeviceOrientationEvent('', {alpha: undefined, beta: undefined, gamma: undefined, absolute: undefined});
+ assert_equals(event.alpha, null);
+ assert_equals(event.beta, null);
+ assert_equals(event.gamma, null);
+ assert_false(event.absolute);
+}, 'Tests all values are undefined.');
+
+test(test => {
+ event = new DeviceOrientationEvent('', {alpha: '', beta: '', gamma: '', absolute: ''});
+ assert_equals(event.alpha, 0);
+ assert_equals(event.beta, 0);
+ assert_equals(event.gamma, 0);
+ assert_false(event.absolute);
+}, 'Tests all values are empty string.');
+
+
+test(test => {
+ event = new DeviceOrientationEvent('', {alpha: null, beta: null, gamma: null, absolute: null});
+ assert_equals(event.alpha, null);
+ assert_equals(event.beta, null);
+ assert_equals(event.gamma, null);
+ assert_false(event.absolute);
+}, 'Tests all values are null.');
+</script>
diff --git a/testing/web-platform/tests/orientation-event/orientation/page-visibility.https.html b/testing/web-platform/tests/orientation-event/orientation/page-visibility.https.html
new file mode 100644
index 0000000000..bcb4beeb8e
--- /dev/null
+++ b/testing/web-platform/tests/orientation-event/orientation/page-visibility.https.html
@@ -0,0 +1,50 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/testdriver.js"></script>
+<script src="/resources/testdriver-vendor.js"></script>
+<script src="/page-visibility/resources/window_state_context.js"></script>
+<script src="../resources/orientation-event-helpers.js"></script>
+<script>
+'use strict';
+
+promise_test(async (t) => {
+ const helper = new SensorTestHelper(t, 'deviceorientation');
+ await helper.grantSensorsPermissions();
+ await helper.initializeSensors();
+
+ const orientationData = generateOrientationData(1, 2, 3, false);
+
+ await helper.setData(orientationData);
+ const event = getExpectedOrientationEvent(orientationData);
+ await waitForEvent(event);
+
+ const {minimize, restore} = window_state_context(t);
+ await minimize();
+ assert_true(document.hidden);
+
+ let hiddenEventPromise = new Promise((resolve, reject) => {
+ window.addEventListener(
+ 'deviceorientation',
+ event => {
+ if (document.hidden) {
+ reject();
+ } else {
+ resolve();
+ }
+ },
+ { once: true });
+ });
+
+ // Sleep for a while to make sure no deviceorientation events are fired
+ // while the page is hidden.
+ await new Promise(resolve => { t.step_timeout(resolve, 100); });
+ await restore();
+ assert_false(document.hidden);
+ return Promise.all([hiddenEventPromise, waitForEvent(event)]);
+}, 'Tests to check that deviceorientation events are not fired when the page is not visible.');
+</script>
+</body>
+</html>
diff --git a/testing/web-platform/tests/orientation-event/orientation/requestPermission.https.window.js b/testing/web-platform/tests/orientation-event/orientation/requestPermission.https.window.js
new file mode 100644
index 0000000000..4a39a238d0
--- /dev/null
+++ b/testing/web-platform/tests/orientation-event/orientation/requestPermission.https.window.js
@@ -0,0 +1,48 @@
+// META: script=/resources/testdriver.js
+// META: script=/resources/testdriver-vendor.js
+
+'use strict';
+
+// The Device Orientation spec does not fully integrate with the Permissions
+// spec and does not list the permissions that are expected for
+// requestPermission() to work. The list below was based on the permissions
+// listed in https://w3c.github.io/orientation-sensor/#model for the low-level
+// sensors that power absolute and relative orientation sensors.
+const permissionDescriptorNames =
+ ['accelerometer', 'gyroscope', 'magnetometer'];
+
+promise_test(async (t) => {
+ await Promise.all(permissionDescriptorNames.map(
+ name => test_driver.set_permission({name}, 'granted')));
+
+ const permission = await DeviceOrientationEvent.requestPermission();
+ assert_equals(permission, 'granted');
+}, 'requestPermission() returns "granted" for granted permissions without user activation');
+
+promise_test(async (t) => {
+ await Promise.all(permissionDescriptorNames.map(
+ name => test_driver.set_permission({name}, 'granted')));
+
+ return test_driver.bless('enable user activation', async () => {
+ const permission = await DeviceOrientationEvent.requestPermission();
+ assert_equals(permission, 'granted');
+ });
+}, 'requestPermission() returns "granted" for granted permissions with user activation');
+
+promise_test(async (t) => {
+ await Promise.all(permissionDescriptorNames.map(
+ name => test_driver.set_permission({name}, 'denied')));
+
+ const permission = await DeviceOrientationEvent.requestPermission();
+ assert_equals(permission, 'denied');
+}, 'requestPermission() returns "denied" for denied permissions without user activation');
+
+promise_test(async (t) => {
+ await Promise.all(permissionDescriptorNames.map(
+ name => test_driver.set_permission({name}, 'denied')));
+
+ return test_driver.bless('enable user activation', async () => {
+ const permission = await DeviceOrientationEvent.requestPermission();
+ assert_equals(permission, 'denied');
+ });
+}, 'requestPermission() returns "denied" for denied permissions with user activation');
diff --git a/testing/web-platform/tests/orientation-event/orientation/t006-manual.https.html b/testing/web-platform/tests/orientation-event/orientation/t006-manual.https.html
new file mode 100644
index 0000000000..e41f4634e8
--- /dev/null
+++ b/testing/web-platform/tests/orientation-event/orientation/t006-manual.https.html
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Rotate the device frame around its z axis</title>
+ <meta name=viewport content="width=device-width, maximum-scale=1.0">
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ <link rel="author" title="Mosquito FP7">
+ <link rel="reviewer author" title="Zhiqiang Zhang" href="mailto:zhiqiang.zhang@intel.com"> <!-- 2013-10-12 -->
+ </head>
+ <body>
+ <p>Rotate the device frame around its z axis to run the test.</p>
+ <div id="log"></div>
+ <script>
+ var t1 = async_test("Alpha is in [0, 360)");
+ var run = false;
+ window.addEventListener("deviceorientation", function(e) {
+ if (!run && e.alpha !== null) {
+ run = true;
+ t1.step(function() {
+ assert_greater_than_equal(e.alpha, 0);
+ assert_less_than(e.alpha, 360);
+ });
+ t1.done();
+ }
+ }, false);
+ </script>
+ </body>
+</html>
+
diff --git a/testing/web-platform/tests/orientation-event/orientation/t009-manual.https.html b/testing/web-platform/tests/orientation-event/orientation/t009-manual.https.html
new file mode 100644
index 0000000000..d00f7e71b0
--- /dev/null
+++ b/testing/web-platform/tests/orientation-event/orientation/t009-manual.https.html
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Rotate the device frame around its x axis</title>
+ <meta name=viewport content="width=device-width, maximum-scale=1.0">
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ <link rel="author" title="Mosquito FP7">
+ <link rel="reviewer author" title="Zhiqiang Zhang" href="mailto:zhiqiang.zhang@intel.com"> <!-- 2013-10-12 -->
+ </head>
+ <body>
+ <p>Rotate the device frame around its x axis to run the test.</p>
+ <div id="log"></div>
+ <script>
+ var t1 = async_test("Beta is in [-180, 180)");
+ var run = false;
+ window.addEventListener("deviceorientation", function(e) {
+ if (!run && e.beta !== null) {
+ run = true;
+ t1.step(function() {
+ assert_greater_than_equal(e.beta, -180);
+ assert_less_than(e.beta, 180);
+ });
+ t1.done();
+ }
+ }, false);
+ </script>
+ </body>
+</html>
+
diff --git a/testing/web-platform/tests/orientation-event/orientation/t010-manual.https.html b/testing/web-platform/tests/orientation-event/orientation/t010-manual.https.html
new file mode 100644
index 0000000000..9a6e00e1f7
--- /dev/null
+++ b/testing/web-platform/tests/orientation-event/orientation/t010-manual.https.html
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Rotate the device frame around its y axis</title>
+ <meta name=viewport content="width=device-width, maximum-scale=1.0">
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ <link rel="author" title="Mosquito FP7">
+ <link rel="reviewer author" title="Zhiqiang Zhang" href="mailto:zhiqiang.zhang@intel.com"> <!-- 2013-10-12 -->
+ </head>
+ <body>
+ <p>Rotate the device frame around its y axis to run the test.</p>
+ <div id="log"></div>
+ <script>
+ var t1 = async_test("Gamma is in [-90, 90)");
+ var run = false;
+ window.addEventListener("deviceorientation", function(e) {
+ if (!run && e.gamma !== null) {
+ run = true;
+ t1.step(function() {
+ assert_greater_than_equal(e.gamma, -90);
+ assert_less_than(e.gamma, 90);
+ });
+ t1.done();
+ }
+ }, false);
+ </script>
+ </body>
+</html>
+
diff --git a/testing/web-platform/tests/orientation-event/orientation/t012-manual.https.html b/testing/web-platform/tests/orientation-event/orientation/t012-manual.https.html
new file mode 100644
index 0000000000..e5ac1c98b4
--- /dev/null
+++ b/testing/web-platform/tests/orientation-event/orientation/t012-manual.https.html
@@ -0,0 +1,41 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Implementations that are unable to provide all three angles must set the values of the unknown angles to null</title>
+ <meta name=viewport content="width=device-width, maximum-scale=1.0">
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ <link rel="author" title="Mosquito FP7">
+ <link rel="reviewer author" title="Zhiqiang Zhang" href="mailto:zhiqiang.zhang@intel.com"> <!-- 2013-10-12 -->
+ </head>
+ <body>
+ <p>Precondition: implementation is unable to provide all three angles</p>
+ <p>Rotate the device to run the test.</p>
+ <div id="log"></div>
+ <script>
+ var t1 = async_test("Alpha, Beta and Gamma are null. absolute is false.");
+ var run = false;
+ window.addEventListener("deviceorientation", function(e) {
+ if (!run) {
+ run = true;
+ t1.step(function() {
+ assert_equals(e.alpha, null, "alpha is set to null");
+ assert_equals(e.beta, null, "beta is set to null");
+ assert_equals(e.gamma, null, "gamma is set to null");
+ assert_false(e.absolute, "absolute is set to false");
+ });
+ t1.done();
+ }
+ }, false);
+
+ test(function() {
+ var evt = new DeviceOrientationEvent("foo");
+ assert_equals(evt.alpha, null, "alpha is set to null");
+ assert_equals(evt.beta, null, "beta is set to null");
+ assert_equals(evt.gamma, null, "gamma is set to null");
+ assert_false(evt.absolute, "absolute is set to false");
+ }, "User created event is initialized properly");
+ </script>
+ </body>
+</html>
+
diff --git a/testing/web-platform/tests/orientation-event/orientation/updates.https.html b/testing/web-platform/tests/orientation-event/orientation/updates.https.html
new file mode 100644
index 0000000000..fe1811535b
--- /dev/null
+++ b/testing/web-platform/tests/orientation-event/orientation/updates.https.html
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/testdriver.js"></script>
+<script src="/resources/testdriver-vendor.js"></script>
+<script src="../resources/orientation-event-helpers.js"></script>
+<script>
+'use strict';
+
+promise_test(async (t) => {
+ const helper = new SensorTestHelper(t, 'deviceorientation');
+ await helper.grantSensorsPermissions();
+ await helper.initializeSensors();
+
+ const orientationData1 = generateOrientationData(1.1, 2.2, 3.3, false);
+ await helper.setData(orientationData1);
+ await waitForEvent(getExpectedOrientationEvent(orientationData1));
+
+ const orientationData2 = generateOrientationData(11.1, 22.2, 33.3, false);
+ await helper.setData(orientationData2);
+ await waitForEvent(getExpectedOrientationEvent(orientationData2));
+}, 'Tests that updates to the relative orientation causes new events to fire.');
+
+promise_test(async (t) => {
+ const helper = new SensorTestHelper(t, 'deviceorientationabsolute');
+ await helper.grantSensorsPermissions();
+ await helper.initializeSensors();
+
+ const orientationData1 = generateOrientationData(1.1, 2.2, 3.3, true);
+ await helper.setData(orientationData1);
+ await waitForEvent(getExpectedAbsoluteOrientationEvent(orientationData1));
+
+ const orientationData2 = generateOrientationData(11.1, 22.2, 33.3, true);
+ await helper.setData(orientationData2);
+ await waitForEvent(getExpectedAbsoluteOrientationEvent(orientationData2));
+}, 'Tests that updates to the absolute orientation causes new events to fire.');
+</script>