diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /testing/web-platform/tests/orientation-event/orientation | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/orientation-event/orientation')
17 files changed, 575 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..610b1b3c56 --- /dev/null +++ b/testing/web-platform/tests/orientation-event/orientation/absolute-fallback.https.html @@ -0,0 +1,19 @@ +<!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'; + +sensor_test(async (t, sensorProvider) => { + const orientationData = generateOrientationData(1.1, 2.2, 3.3, true); + + // Make the relative orientation sensor unavailable and set mock data for + // the absolute one. + sensorProvider.setGetSensorShouldFail('RelativeOrientationEulerAngles', true); + setMockOrientationData(sensorProvider, orientationData); + return waitForEvent(getExpectedAbsoluteOrientationEvent(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..8f8cfa29c4 --- /dev/null +++ b/testing/web-platform/tests/orientation-event/orientation/add-listener-from-callback.https.html @@ -0,0 +1,47 @@ +<!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'; + +sensor_test(async (t, sensorProvider) => { + const orientationData = generateOrientationData(1.1, 2.2, 3.3, false); + + let firstListener = null; + let secondListener = null; + let firstEventCount = 0; + let firstPromise = new Promise(resolve => { + firstListener = (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(orientationData)); + window.removeEventListener('deviceorientation', firstListener); + if (++firstEventCount == 1) { + window.addEventListener('deviceorientation', secondListener); + } + resolve(event); + }; + }); + + let secondEventCount = 0; + let secondPromise = new Promise(resolve => { + secondListener = (event) => { + assertEventEquals(event, getExpectedOrientationEvent(orientationData)); + window.removeEventListener('deviceorientation', secondListener); + ++secondEventCount; + resolve(event); + }; + }); + + setMockOrientationData(sensorProvider, orientationData); + 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..61fd218781 --- /dev/null +++ b/testing/web-platform/tests/orientation-event/orientation/basic-operation-absolute.https.html @@ -0,0 +1,28 @@ +<!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'; + +sensor_test(async (t, sensorProvider) => { + const orientationData = generateOrientationData(1.1, 2.2, 3.3, true); + setMockOrientationData(sensorProvider, orientationData); + return waitForEvent(getExpectedAbsoluteOrientationEvent(orientationData)); +}, 'Tests basic operation of deviceorientationabsolute event using mock data.'); + +sensor_test(async (t, sensorProvider) => { + const orientationData = generateOrientationData(null, null, null, true); + const watcher = new EventWatcher(t, window, ['deviceorientationabsolute']); + + // Make the absolute orientation sensor unavailable + sensorProvider.setGetSensorShouldFail('AbsoluteOrientationEulerAngles', true); + 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..45fe38006e --- /dev/null +++ b/testing/web-platform/tests/orientation-event/orientation/basic-operation.https.html @@ -0,0 +1,29 @@ +<!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'; + +sensor_test(async (t, sensorProvider) => { + const orientationData = generateOrientationData(1.1, 2.2, 3.3, false); + setMockOrientationData(sensorProvider, orientationData); + return waitForEvent(getExpectedOrientationEvent(orientationData)); +}, 'Tests basic operation of deviceorientation event using mock data.'); + +sensor_test(async (t, sensorProvider) => { + const orientationData = generateOrientationData(null, null, null, false); + const watcher = new EventWatcher(t, window, ['deviceorientation']); + + // Make the orientation sensor unavailable + sensorProvider.setGetSensorShouldFail('AbsoluteOrientationEulerAngles', true); + sensorProvider.setGetSensorShouldFail('RelativeOrientationEulerAngles', true); + 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..473b7f8828 --- /dev/null +++ b/testing/web-platform/tests/orientation-event/orientation/multiple-event-listeners.https.html @@ -0,0 +1,22 @@ +<!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'; + +sensor_test(async (t, sensorProvider) => { + const orientationData1 = generateOrientationData(1, 2, 3, false); + setMockOrientationData(sensorProvider, orientationData1); + await Promise.all([ + waitForEvent(getExpectedOrientationEvent(orientationData1)), + waitForEvent(getExpectedOrientationEvent(orientationData1)) + ]); + + const orientationData2 = generateOrientationData(11, 12, 13, false); + setMockOrientationData(sensorProvider, 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..e5d7621123 --- /dev/null +++ b/testing/web-platform/tests/orientation-event/orientation/no-synchronous-events.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'; + +sensor_test(async (t, sensorProvider) => { + const orientationData = generateOrientationData(1.1, 2.2, 3.3, false); + + let setMockDataPromise = setMockOrientationData(sensorProvider, orientationData); + // Add an empty listener to make sure the event pump is running and the mock + // sensor is created and configured. If the pump and fake sensor weren't set + // up ahead of time, then the fact that we get an asynchronous event could be + // due to the asynchronous set up process. + window.addEventListener('deviceorientation', event => {}); + await setMockDataPromise; + + 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..f9e4aa6420 --- /dev/null +++ b/testing/web-platform/tests/orientation-event/orientation/null-values.https.html @@ -0,0 +1,30 @@ +<!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'; + +sensor_test(async (t, sensorProvider) => { + const orientationData1 = generateOrientationData(1.1, null, null, false); + const orientationData2 = generateOrientationData(null, 2.2, null, false); + const orientationData3 = generateOrientationData(null, null, 3.3, false); + // The all null event is last because DeviceSingleWindowEventController + // will stop updating the sensor when it sees a null event. + const orientationData4 = generateOrientationData(null, null, null, false); + + setMockOrientationData(sensorProvider, orientationData1); + await waitForEvent(getExpectedOrientationEvent(orientationData1)); + + setMockOrientationData(sensorProvider, orientationData2); + await waitForEvent(getExpectedOrientationEvent(orientationData2)); + + setMockOrientationData(sensorProvider, orientationData3); + await waitForEvent(getExpectedOrientationEvent(orientationData3)); + + setMockOrientationData(sensorProvider, orientationData4); + await waitForEvent(getExpectedOrientationEvent(orientationData4)); +}, '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-manual.https.html b/testing/web-platform/tests/orientation-event/orientation/page-visibility-manual.https.html new file mode 100644 index 0000000000..033f17602b --- /dev/null +++ b/testing/web-platform/tests/orientation-event/orientation/page-visibility-manual.https.html @@ -0,0 +1,28 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<meta name="timeout" content="long"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> +'use strict'; + +promise_test(t => { + return new Promise((resolve, reject) => { + document.addEventListener("visibilitychange", () => { + assert_true(document.hidden, "document is hidden"); + window.addEventListener( + 'deviceorientation', + event => { + if (document.hidden) { + reject(); + } else { + resolve(); + } + }, + { once: true }); + }, { once: true }); + }); +}, 'Tests to check that deviceorientation events are not fired when the page is not visible.'); +</script> + +<p>Switch the page to the background, then switch back to it.</p> 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..c84588d598 --- /dev/null +++ b/testing/web-platform/tests/orientation-event/orientation/updates.https.html @@ -0,0 +1,19 @@ +<!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'; + +sensor_test(async (t, sensorProvider) => { + const orientationData1 = generateOrientationData(1.1, 2.2, 3.3, false); + setMockOrientationData(sensorProvider, orientationData1); + await waitForEvent(getExpectedOrientationEvent(orientationData1)); + + const orientationData2 = generateOrientationData(11.1, 22.2, 33.3, false); + setMockOrientationData(sensorProvider, orientationData2); + await waitForEvent(getExpectedOrientationEvent(orientationData2)); +}, 'Tests that updates to the orientation causes new events to fire.'); +</script> |