Commit 303956b6 authored by Mikhail Pozdnyakov's avatar Mikhail Pozdnyakov Committed by Commit Bot

Enable WPT tests for the Generic Sensor classes

This patch introduces mock implementations of the Sensor
and SensorProvider mojo interfaces to the WPT tests
for Chromium.

The ongoing WPT issue for the Generic Sensor tests automation:
https://github.com/w3c/web-platform-tests/issues/9686

Bug: 816462
Change-Id: I8e4880ee5269b07f0bf68a2752038e128d166c55
Reviewed-on: https://chromium-review.googlesource.com/980886Reviewed-by: default avatarMike West <mkwst@chromium.org>
Reviewed-by: default avatarPhilip Jägenstedt <foolip@chromium.org>
Reviewed-by: default avatarReilly Grant <reillyg@chromium.org>
Reviewed-by: default avatarAlexander Shalamov <alexander.shalamov@intel.com>
Commit-Queue: Mikhail Pozdnyakov <mikhail.pozdnyakov@intel.com>
Cr-Commit-Position: refs/heads/master@{#550586}
parent f8fb043b
......@@ -216,6 +216,9 @@ void LayoutTestMessageFilter::OnSetPermission(
type = PermissionType::CLIPBOARD_WRITE;
} else if (name == "payment-handler") {
type = PermissionType::PAYMENT_HANDLER;
} else if (name == "accelerometer" || name == "gyroscope" ||
name == "magnetometer" || name == "ambient-light-sensor") {
type = PermissionType::SENSORS;
} else {
NOTREACHED();
type = PermissionType::NOTIFICATIONS;
......
......@@ -68,6 +68,11 @@ mojom("generic_sensor") {
visibility_blink =
[ "//third_party/blink/renderer/platform:blink_platform_public_deps" ]
# Generic Sensor Mojom interfaces are exposed publicly to layout tests which
# use prepackaged redistributable JS bindings. It is therefore not desirable
# to scramble these messages.
scramble_message_ids = false
}
mojom("constants") {
......
This is a testharness.js-based test.
Harness Error. harness_status.status = 1 , harness_status.message = Uncaught ReferenceError: GravitySensor is not defined
PASS Accelerometer: Feature-Policy header accelerometer 'none' disallows the top-level document.
PASS Accelerometer: Feature-Policy header accelerometer 'none' disallows same-origin iframes.
PASS Accelerometer: Feature-Policy header accelerometer 'none' disallows cross-origin iframes.
PASS LinearAccelerationSensor: Feature-Policy header accelerometer 'none' disallows the top-level document.
PASS LinearAccelerationSensor: Feature-Policy header accelerometer 'none' disallows same-origin iframes.
PASS LinearAccelerationSensor: Feature-Policy header accelerometer 'none' disallows cross-origin iframes.
FAIL GravitySensor: Feature-Policy header accelerometer 'none' disallows the top-level document. assert_true: expected true got false
FAIL GravitySensor: Feature-Policy header accelerometer 'none' disallows same-origin iframes. assert_true: expected true got false
FAIL GravitySensor: Feature-Policy header accelerometer 'none' disallows cross-origin iframes. assert_true: expected true got false
Harness: the test ran to completion.
......@@ -8,8 +8,8 @@
<script>
"use strict";
run_fp_tests_disabled(Accelerometer);
run_fp_tests_disabled(LinearAccelerationSensor);
run_fp_tests_disabled(GravitySensor);
run_fp_tests_disabled('Accelerometer');
run_fp_tests_disabled('LinearAccelerationSensor');
run_fp_tests_disabled('GravitySensor');
</script>
</body>
This is a testharness.js-based test.
Harness Error. harness_status.status = 1 , harness_status.message = Uncaught ReferenceError: GravitySensor is not defined
PASS Accelerometer: Feature-Policy allow='accelerometer' attribute allows same-origin relocation
PASS Accelerometer: Feature-Policy allow='accelerometer' attribute disallows cross-origin relocation
PASS LinearAccelerationSensor: Feature-Policy allow='accelerometer' attribute allows same-origin relocation
PASS LinearAccelerationSensor: Feature-Policy allow='accelerometer' attribute disallows cross-origin relocation
FAIL GravitySensor: Feature-Policy allow='accelerometer' attribute allows same-origin relocation assert_true: expected true got false
FAIL GravitySensor: Feature-Policy allow='accelerometer' attribute disallows cross-origin relocation assert_true: expected true got false
Harness: the test ran to completion.
......@@ -8,8 +8,8 @@
<script>
"use strict";
run_fp_tests_enabled_by_attribute_redirect_on_load(Accelerometer);
run_fp_tests_enabled_by_attribute_redirect_on_load(LinearAccelerationSensor);
run_fp_tests_enabled_by_attribute_redirect_on_load(GravitySensor);
run_fp_tests_enabled_by_attribute_redirect_on_load('Accelerometer');
run_fp_tests_enabled_by_attribute_redirect_on_load('LinearAccelerationSensor');
run_fp_tests_enabled_by_attribute_redirect_on_load('GravitySensor');
</script>
</body>
This is a testharness.js-based test.
Harness Error. harness_status.status = 1 , harness_status.message = Uncaught ReferenceError: GravitySensor is not defined
PASS Accelerometer: Feature-Policy allow='accelerometer' attribute allows same-origin iframe
PASS Accelerometer: Feature-Policy allow='accelerometer' attribute allows cross-origin iframe
PASS LinearAccelerationSensor: Feature-Policy allow='accelerometer' attribute allows same-origin iframe
PASS LinearAccelerationSensor: Feature-Policy allow='accelerometer' attribute allows cross-origin iframe
FAIL GravitySensor: Feature-Policy allow='accelerometer' attribute allows same-origin iframe assert_true: expected true got false
FAIL GravitySensor: Feature-Policy allow='accelerometer' attribute allows cross-origin iframe assert_true: expected true got false
Harness: the test ran to completion.
......@@ -8,8 +8,8 @@
<script>
"use strict";
run_fp_tests_enabled_by_attribute(Accelerometer);
run_fp_tests_enabled_by_attribute(LinearAccelerationSensor);
run_fp_tests_enabled_by_attribute(GravitySensor);
run_fp_tests_enabled_by_attribute('Accelerometer');
run_fp_tests_enabled_by_attribute('LinearAccelerationSensor');
run_fp_tests_enabled_by_attribute('GravitySensor');
</script>
</body>
This is a testharness.js-based test.
Harness Error. harness_status.status = 1 , harness_status.message = Uncaught ReferenceError: GravitySensor is not defined
PASS Accelerometer: Feature-Policy header accelerometer * allows the top-level document.
PASS Accelerometer: Feature-Policy header accelerometer * allows same-origin iframes.
PASS Accelerometer: Feature-Policy header accelerometer * allows cross-origin iframes.
PASS LinearAccelerationSensor: Feature-Policy header accelerometer * allows the top-level document.
PASS LinearAccelerationSensor: Feature-Policy header accelerometer * allows same-origin iframes.
PASS LinearAccelerationSensor: Feature-Policy header accelerometer * allows cross-origin iframes.
FAIL GravitySensor: Feature-Policy header accelerometer * allows the top-level document. assert_true: expected true got false
FAIL GravitySensor: Feature-Policy header accelerometer * allows same-origin iframes. assert_true: expected true got false
FAIL GravitySensor: Feature-Policy header accelerometer * allows cross-origin iframes. assert_true: expected true got false
Harness: the test ran to completion.
......@@ -8,8 +8,8 @@
<script>
"use strict";
run_fp_tests_enabled(Accelerometer);
run_fp_tests_enabled(LinearAccelerationSensor);
run_fp_tests_enabled(GravitySensor);
run_fp_tests_enabled('Accelerometer');
run_fp_tests_enabled('LinearAccelerationSensor');
run_fp_tests_enabled('GravitySensor');
</script>
</body>
This is a testharness.js-based test.
Harness Error. harness_status.status = 1 , harness_status.message = Uncaught ReferenceError: GravitySensor is not defined
PASS Accelerometer: Feature-Policy header accelerometer 'self' allows the top-level document.
PASS Accelerometer: Feature-Policy header accelerometer 'self' allows same-origin iframes.
PASS Accelerometer: Feature-Policy header accelerometer 'self' disallows cross-origin iframes.
PASS LinearAccelerationSensor: Feature-Policy header accelerometer 'self' allows the top-level document.
PASS LinearAccelerationSensor: Feature-Policy header accelerometer 'self' allows same-origin iframes.
PASS LinearAccelerationSensor: Feature-Policy header accelerometer 'self' disallows cross-origin iframes.
FAIL GravitySensor: Feature-Policy header accelerometer 'self' allows the top-level document. assert_true: expected true got false
FAIL GravitySensor: Feature-Policy header accelerometer 'self' allows same-origin iframes. assert_true: expected true got false
FAIL GravitySensor: Feature-Policy header accelerometer 'self' disallows cross-origin iframes. assert_true: expected true got false
Harness: the test ran to completion.
......@@ -8,8 +8,8 @@
<script>
"use strict";
run_fp_tests_enabled_on_self_origin(Accelerometer);
run_fp_tests_enabled_on_self_origin(LinearAccelerationSensor);
run_fp_tests_enabled_on_self_origin(GravitySensor);
run_fp_tests_enabled_on_self_origin('Accelerometer');
run_fp_tests_enabled_on_self_origin('LinearAccelerationSensor');
run_fp_tests_enabled_on_self_origin('GravitySensor');
</script>
</body>
This is a testharness.js-based test.
Harness Error. harness_status.status = 1 , harness_status.message = Uncaught ReferenceError: GravitySensor is not defined
FAIL Accelerometer: Test that 'onreading' is called and sensor reading is valid assert_equals: Expected reading event, but got error event instead expected "reading" but got "error"
FAIL Accelerometer: sensor reading is correct assert_equals: Expected reading event, but got error event instead expected "reading" but got "error"
FAIL Accelerometer: sensor timestamp is updated when time passes assert_equals: Expected reading event, but got error event instead expected "reading" but got "error"
FAIL Accelerometer: Test that sensor can be successfully created and its states are correct. assert_equals: Expected activate event, but got error event instead expected "activate" but got "error"
FAIL Accelerometer: sensor.start() returns undefined assert_equals: Expected activate event, but got error event instead expected "activate" but got "error"
FAIL Accelerometer: no exception is thrown when calling start() on already started sensor assert_equals: Expected activate event, but got error event instead expected "activate" but got "error"
FAIL Accelerometer: sensor.stop() returns undefined assert_equals: Expected activate event, but got error event instead expected "activate" but got "error"
FAIL Accelerometer: no exception is thrown when calling stop() on already stopped sensor assert_equals: Expected activate event, but got error event instead expected "activate" but got "error"
FAIL Accelerometer: Test that fresh reading is fetched on start() assert_equals: Expected reading event, but got error event instead expected "reading" but got "error"
FAIL Accelerometer: sensor readings can not be fired on the background tab assert_equals: Expected reading event, but got error event instead expected "reading" but got "error"
FAIL Accelerometer: frequency hint works promise_test: Unhandled rejection with value: object "[object SensorErrorEvent]"
FAIL Accelerometer: sensor receives suspend / resume notifications when cross-origin subframe is focused assert_equals: Expected reading event, but got error event instead expected "reading" but got "error"
FAIL Accelerometer: throw 'NotSupportedError' for an unsupported sensor option assert_throws: function "() => { new sensorType({invalid: 1}) }" did not throw
PASS Accelerometer: Test that 'onreading' is called and sensor reading is valid
PASS Accelerometer: sensor reading is correct
PASS Accelerometer: sensor timestamp is updated when time passes
PASS Accelerometer: Test that sensor can be successfully created and its states are correct.
PASS Accelerometer: sensor.start() returns undefined
PASS Accelerometer: no exception is thrown when calling start() on already started sensor
PASS Accelerometer: sensor.stop() returns undefined
PASS Accelerometer: no exception is thrown when calling stop() on already stopped sensor
PASS Accelerometer: Test that fresh reading is fetched on start()
PASS Accelerometer: frequency hint works
PASS Accelerometer: sensor receives suspend / resume notifications when cross-origin subframe is focused
FAIL Accelerometer: throw 'TypeError' if frequency is invalid assert_throws: when freq is undefined function "() => { new sensorType({frequency: freq}) }" did not throw
FAIL Accelerometer: sensor reading is correct when options.referenceFrame is 'screen' assert_equals: Expected reading event, but got error event instead expected "reading" but got "error"
FAIL Accelerometer: throw 'TypeError' if referenceFrame is not one of enumeration values assert_throws: when refFrame is undefined function "() => { new sensorType({referenceFrame: refFrame}) }" did not throw
PASS Accelerometer: sensor reading is correct when options.referenceFrame is 'screen'
PASS Accelerometer: throw 'TypeError' if referenceFrame is not one of enumeration values
FAIL GravitySensor: Test that 'onreading' is called and sensor reading is valid assert_true: expected true got false
FAIL GravitySensor: sensor reading is correct assert_true: expected true got false
FAIL GravitySensor: sensor timestamp is updated when time passes assert_true: expected true got false
FAIL GravitySensor: Test that sensor can be successfully created and its states are correct. assert_true: expected true got false
FAIL GravitySensor: sensor.start() returns undefined assert_true: expected true got false
FAIL GravitySensor: no exception is thrown when calling start() on already started sensor assert_true: expected true got false
FAIL GravitySensor: sensor.stop() returns undefined assert_true: expected true got false
FAIL GravitySensor: no exception is thrown when calling stop() on already stopped sensor assert_true: expected true got false
FAIL GravitySensor: Test that fresh reading is fetched on start() assert_true: expected true got false
FAIL GravitySensor: frequency hint works assert_true: expected true got false
FAIL GravitySensor: sensor receives suspend / resume notifications when cross-origin subframe is focused assert_true: expected true got false
FAIL GravitySensor: throw 'TypeError' if frequency is invalid assert_true: expected true got false
FAIL GravitySensor: sensor reading is correct when options.referenceFrame is 'screen' assert_true: expected true got false
FAIL GravitySensor: throw 'TypeError' if referenceFrame is not one of enumeration values assert_true: expected true got false
PASS LinearAccelerationSensor: Test that 'onreading' is called and sensor reading is valid
PASS LinearAccelerationSensor: sensor reading is correct
PASS LinearAccelerationSensor: sensor timestamp is updated when time passes
PASS LinearAccelerationSensor: Test that sensor can be successfully created and its states are correct.
PASS LinearAccelerationSensor: sensor.start() returns undefined
PASS LinearAccelerationSensor: no exception is thrown when calling start() on already started sensor
PASS LinearAccelerationSensor: sensor.stop() returns undefined
PASS LinearAccelerationSensor: no exception is thrown when calling stop() on already stopped sensor
PASS LinearAccelerationSensor: Test that fresh reading is fetched on start()
PASS LinearAccelerationSensor: frequency hint works
PASS LinearAccelerationSensor: sensor receives suspend / resume notifications when cross-origin subframe is focused
FAIL LinearAccelerationSensor: throw 'TypeError' if frequency is invalid assert_throws: when freq is undefined function "() => { new sensorType({frequency: freq}) }" did not throw
PASS LinearAccelerationSensor: sensor reading is correct when options.referenceFrame is 'screen'
PASS LinearAccelerationSensor: throw 'TypeError' if referenceFrame is not one of enumeration values
Harness: the test ran to completion.
......@@ -9,8 +9,8 @@
<div id="log"></div>
<script>
runGenericSensorTests(Accelerometer);
runGenericSensorTests(GravitySensor);
runGenericSensorTests(LinearAccelerationSensor);
runGenericSensorTests('Accelerometer');
runGenericSensorTests('GravitySensor');
runGenericSensorTests('LinearAccelerationSensor');
</script>
This is a testharness.js-based test.
Harness Error. harness_status.status = 1 , harness_status.message = Uncaught ReferenceError: GravitySensor is not defined
PASS Accelerometer: 'onerror' event is fired when sensor is not supported
FAIL GravitySensor: 'onerror' event is fired when sensor is not supported assert_true: expected true got false
PASS LinearAccelerationSensor: 'onerror' event is fired when sensor is not supported
Harness: the test ran to completion.
......@@ -15,8 +15,8 @@
</ol>
<script>
runGenericSensorOnerror(Accelerometer);
runGenericSensorOnerror(GravitySensor);
runGenericSensorOnerror(LinearAccelerationSensor);
runGenericSensorOnerror('Accelerometer');
runGenericSensorOnerror('GravitySensor');
runGenericSensorOnerror('LinearAccelerationSensor');
</script>
The `generic-sensor-tests.js` tests require an implementation of
the `GenericSensorTest` interface, which should emulate platform
sensor backends. The `GenericSensorTest` interface is defined as:
```
class GenericSensorTest {
async initialize(); // Sets up the testing enviroment.
async reset(); // Frees the resources.
};
```
The Chromium implementation of the `GenericSensorTest` interface is located in
[generic_sensor_mocks.js](../resources/chromium/generic_sensor_mocks.js).
Other browser vendors should provide their own implementations of
the `GenericSensorTest` interface.
[Known issue](https://github.com/w3c/web-platform-tests/issues/9686): a
WebDriver extension is a better approach for the Generic Sensor tests
automation.
......@@ -17,17 +17,19 @@ const cross_origin_src =
"https://{{domains[www]}}:{{ports[https][0]}}" + same_origin_src;
const base_src = "/feature-policy/resources/redirect-on-load.html#";
function run_fp_tests_disabled(sensorType) {
const sensorName = sensorType.name;
function run_fp_tests_disabled(sensorName) {
const sensorType = self[sensorName];
const featureNameList = feature_policies[sensorName];
const header = "Feature-Policy header " + featureNameList.join(" 'none';") + " 'none'";
const desc = "'new " + sensorName + "()'";
test(() => {
assert_true(sensorName in self);
assert_throws("SecurityError", () => {new sensorType()});
}, `${sensorName}: ${header} disallows the top-level document.`);
async_test(t => {
assert_true(sensorName in self);
test_feature_availability(
desc,
t,
......@@ -37,6 +39,7 @@ function run_fp_tests_disabled(sensorType) {
}, `${sensorName}: ${header} disallows same-origin iframes.`);
async_test(t => {
assert_true(sensorName in self);
test_feature_availability(
desc,
t,
......@@ -46,17 +49,18 @@ function run_fp_tests_disabled(sensorType) {
}, `${sensorName}: ${header} disallows cross-origin iframes.`);
}
function run_fp_tests_enabled(sensorType) {
const sensorName = sensorType.name;
function run_fp_tests_enabled(sensorName) {
const sensorType = self[sensorName];
const featureNameList = feature_policies[sensorName];
const header = "Feature-Policy header " + featureNameList.join(" *;") + " *";
const desc = "'new " + sensorName + "()'";
test(() => {
assert_true(sensorName in window);
assert_true(sensorName in self);
}, `${sensorName}: ${header} allows the top-level document.`);
async_test(t => {
assert_true(sensorName in self);
test_feature_availability(
desc,
t,
......@@ -66,6 +70,7 @@ function run_fp_tests_enabled(sensorType) {
}, `${sensorName}: ${header} allows same-origin iframes.`);
async_test(t => {
assert_true(sensorName in self);
test_feature_availability(
desc,
t,
......@@ -75,13 +80,14 @@ function run_fp_tests_enabled(sensorType) {
}, `${sensorName}: ${header} allows cross-origin iframes.`);
}
function run_fp_tests_enabled_by_attribute(sensorType) {
const sensorName = sensorType.name;
function run_fp_tests_enabled_by_attribute(sensorName) {
const sensorType = self[sensorName];
const featureNameList = feature_policies[sensorName];
const header = "Feature-Policy allow='" + featureNameList.join(" ") + "' attribute";
const desc = "'new " + sensorName + "()'";
async_test(t => {
assert_true(sensorName in self);
test_feature_availability(
desc,
t,
......@@ -92,6 +98,7 @@ function run_fp_tests_enabled_by_attribute(sensorType) {
}, `${sensorName}: ${header} allows same-origin iframe`);
async_test(t => {
assert_true(sensorName in self);
test_feature_availability(
desc,
t,
......@@ -102,13 +109,14 @@ function run_fp_tests_enabled_by_attribute(sensorType) {
}, `${sensorName}: ${header} allows cross-origin iframe`);
}
function run_fp_tests_enabled_by_attribute_redirect_on_load(sensorType) {
const sensorName = sensorType.name;
function run_fp_tests_enabled_by_attribute_redirect_on_load(sensorName) {
const sensorType = self[sensorName];
const featureNameList = feature_policies[sensorName];
const header = "Feature-Policy allow='" + featureNameList.join(" ") + "' attribute";
const desc = "'new " + sensorName + "()'";
async_test(t => {
assert_true(sensorName in self);
test_feature_availability(
desc,
t,
......@@ -119,6 +127,7 @@ function run_fp_tests_enabled_by_attribute_redirect_on_load(sensorType) {
}, `${sensorName}: ${header} allows same-origin relocation`);
async_test(t => {
assert_true(sensorName in self);
test_feature_availability(
desc,
t,
......@@ -129,17 +138,18 @@ function run_fp_tests_enabled_by_attribute_redirect_on_load(sensorType) {
}, `${sensorName}: ${header} disallows cross-origin relocation`);
}
function run_fp_tests_enabled_on_self_origin(sensorType) {
const sensorName = sensorType.name;
function run_fp_tests_enabled_on_self_origin(sensorName) {
const sensorType = self[sensorName];
const featureNameList = feature_policies[sensorName];
const header = "Feature-Policy header " + featureNameList.join(" 'self';") + " 'self'";
const desc = "'new " + sensorName + "()'";
test(() => {
assert_true(sensorName in window);
assert_true(sensorName in self);
}, `${sensorName}: ${header} allows the top-level document.`);
async_test(t => {
assert_true(sensorName in self);
test_feature_availability(
desc,
t,
......@@ -149,6 +159,7 @@ function run_fp_tests_enabled_on_self_origin(sensorType) {
}, `${sensorName}: ${header} allows same-origin iframes.`);
async_test(t => {
assert_true(sensorName in self);
test_feature_availability(
desc,
t,
......
......@@ -8,6 +8,6 @@
<script>
"use strict";
run_fp_tests_disabled(Gyroscope);
run_fp_tests_disabled('Gyroscope');
</script>
</body>
......@@ -8,6 +8,6 @@
<script>
"use strict";
run_fp_tests_enabled_by_attribute_redirect_on_load(Gyroscope);
run_fp_tests_enabled_by_attribute_redirect_on_load('Gyroscope');
</script>
</body>
......@@ -8,6 +8,6 @@
<script>
"use strict";
run_fp_tests_enabled_by_attribute(Gyroscope);
run_fp_tests_enabled_by_attribute('Gyroscope');
</script>
</body>
......@@ -8,6 +8,6 @@
<script>
"use strict";
run_fp_tests_enabled(Gyroscope);
run_fp_tests_enabled('Gyroscope');
</script>
</body>
......@@ -8,6 +8,6 @@
<script>
"use strict";
run_fp_tests_enabled_on_self_origin(Gyroscope);
run_fp_tests_enabled_on_self_origin('Gyroscope');
</script>
</body>
This is a testharness.js-based test.
FAIL Gyroscope: Test that 'onreading' is called and sensor reading is valid assert_equals: Expected reading event, but got error event instead expected "reading" but got "error"
FAIL Gyroscope: sensor reading is correct assert_equals: Expected reading event, but got error event instead expected "reading" but got "error"
FAIL Gyroscope: sensor timestamp is updated when time passes assert_equals: Expected reading event, but got error event instead expected "reading" but got "error"
FAIL Gyroscope: Test that sensor can be successfully created and its states are correct. assert_equals: Expected activate event, but got error event instead expected "activate" but got "error"
FAIL Gyroscope: sensor.start() returns undefined assert_equals: Expected activate event, but got error event instead expected "activate" but got "error"
FAIL Gyroscope: no exception is thrown when calling start() on already started sensor assert_equals: Expected activate event, but got error event instead expected "activate" but got "error"
FAIL Gyroscope: sensor.stop() returns undefined assert_equals: Expected activate event, but got error event instead expected "activate" but got "error"
FAIL Gyroscope: no exception is thrown when calling stop() on already stopped sensor assert_equals: Expected activate event, but got error event instead expected "activate" but got "error"
FAIL Gyroscope: Test that fresh reading is fetched on start() assert_equals: Expected reading event, but got error event instead expected "reading" but got "error"
FAIL Gyroscope: sensor readings can not be fired on the background tab assert_equals: Expected reading event, but got error event instead expected "reading" but got "error"
FAIL Gyroscope: frequency hint works promise_test: Unhandled rejection with value: object "[object SensorErrorEvent]"
FAIL Gyroscope: sensor receives suspend / resume notifications when cross-origin subframe is focused assert_equals: Expected reading event, but got error event instead expected "reading" but got "error"
FAIL Gyroscope: throw 'NotSupportedError' for an unsupported sensor option assert_throws: function "() => { new sensorType({invalid: 1}) }" did not throw
PASS Gyroscope: Test that 'onreading' is called and sensor reading is valid
PASS Gyroscope: sensor reading is correct
PASS Gyroscope: sensor timestamp is updated when time passes
PASS Gyroscope: Test that sensor can be successfully created and its states are correct.
PASS Gyroscope: sensor.start() returns undefined
PASS Gyroscope: no exception is thrown when calling start() on already started sensor
PASS Gyroscope: sensor.stop() returns undefined
PASS Gyroscope: no exception is thrown when calling stop() on already stopped sensor
PASS Gyroscope: Test that fresh reading is fetched on start()
PASS Gyroscope: frequency hint works
PASS Gyroscope: sensor receives suspend / resume notifications when cross-origin subframe is focused
FAIL Gyroscope: throw 'TypeError' if frequency is invalid assert_throws: when freq is undefined function "() => { new sensorType({frequency: freq}) }" did not throw
FAIL Gyroscope: sensor reading is correct when options.referenceFrame is 'screen' assert_equals: Expected reading event, but got error event instead expected "reading" but got "error"
FAIL Gyroscope: throw 'TypeError' if referenceFrame is not one of enumeration values assert_throws: when refFrame is undefined function "() => { new sensorType({referenceFrame: refFrame}) }" did not throw
PASS Gyroscope: sensor reading is correct when options.referenceFrame is 'screen'
PASS Gyroscope: throw 'TypeError' if referenceFrame is not one of enumeration values
Harness: the test ran to completion.
......@@ -9,6 +9,6 @@
<div id="log"></div>
<script>
runGenericSensorTests(Gyroscope);
runGenericSensorTests('Gyroscope');
</script>
......@@ -15,6 +15,6 @@
</ol>
<script>
runGenericSensorOnerror(Gyroscope);
runGenericSensorOnerror('Gyroscope');
</script>
......@@ -925,6 +925,7 @@ CONSOLE: payment-request/payment-request-response-id.html
# Tests that use WebKit/Blink testing APIs
LAYOUTTESTS APIS: css/css-regions/interactivity/*
LAYOUTTESTS APIS: resources/chromium/generic_sensor_mocks.js
# Existing use of WEB-PLATFORM.TEST
WEB-PLATFORM.TEST: clear-site-data/support/test_utils.sub.js
......
This is a testharness.js-based test.
Harness Error. harness_status.status = 1 , harness_status.message = Uncaught ReferenceError: UncalibratedMagnetometer is not defined
PASS Magnetometer: Feature-Policy header magnetometer 'none' disallows the top-level document.
PASS Magnetometer: Feature-Policy header magnetometer 'none' disallows same-origin iframes.
PASS Magnetometer: Feature-Policy header magnetometer 'none' disallows cross-origin iframes.
FAIL UncalibratedMagnetometer: Feature-Policy header magnetometer 'none' disallows the top-level document. assert_true: expected true got false
FAIL UncalibratedMagnetometer: Feature-Policy header magnetometer 'none' disallows same-origin iframes. assert_true: expected true got false
FAIL UncalibratedMagnetometer: Feature-Policy header magnetometer 'none' disallows cross-origin iframes. assert_true: expected true got false
Harness: the test ran to completion.
......@@ -8,7 +8,7 @@
<script>
"use strict";
run_fp_tests_disabled(Magnetometer);
run_fp_tests_disabled(UncalibratedMagnetometer);
run_fp_tests_disabled('Magnetometer');
run_fp_tests_disabled('UncalibratedMagnetometer');
</script>
</body>
This is a testharness.js-based test.
Harness Error. harness_status.status = 1 , harness_status.message = Uncaught ReferenceError: UncalibratedMagnetometer is not defined
PASS Magnetometer: Feature-Policy allow='magnetometer' attribute allows same-origin relocation
PASS Magnetometer: Feature-Policy allow='magnetometer' attribute disallows cross-origin relocation
FAIL UncalibratedMagnetometer: Feature-Policy allow='magnetometer' attribute allows same-origin relocation assert_true: expected true got false
FAIL UncalibratedMagnetometer: Feature-Policy allow='magnetometer' attribute disallows cross-origin relocation assert_true: expected true got false
Harness: the test ran to completion.
......@@ -8,7 +8,7 @@
<script>
"use strict";
run_fp_tests_enabled_by_attribute_redirect_on_load(Magnetometer);
run_fp_tests_enabled_by_attribute_redirect_on_load(UncalibratedMagnetometer);
run_fp_tests_enabled_by_attribute_redirect_on_load('Magnetometer');
run_fp_tests_enabled_by_attribute_redirect_on_load('UncalibratedMagnetometer');
</script>
</body>
This is a testharness.js-based test.
Harness Error. harness_status.status = 1 , harness_status.message = Uncaught ReferenceError: UncalibratedMagnetometer is not defined
PASS Magnetometer: Feature-Policy allow='magnetometer' attribute allows same-origin iframe
PASS Magnetometer: Feature-Policy allow='magnetometer' attribute allows cross-origin iframe
FAIL UncalibratedMagnetometer: Feature-Policy allow='magnetometer' attribute allows same-origin iframe assert_true: expected true got false
FAIL UncalibratedMagnetometer: Feature-Policy allow='magnetometer' attribute allows cross-origin iframe assert_true: expected true got false
Harness: the test ran to completion.
......@@ -8,7 +8,7 @@
<script>
"use strict";
run_fp_tests_enabled_by_attribute(Magnetometer);
run_fp_tests_enabled_by_attribute(UncalibratedMagnetometer);
run_fp_tests_enabled_by_attribute('Magnetometer');
run_fp_tests_enabled_by_attribute('UncalibratedMagnetometer');
</script>
</body>
This is a testharness.js-based test.
Harness Error. harness_status.status = 1 , harness_status.message = Uncaught ReferenceError: UncalibratedMagnetometer is not defined
PASS Magnetometer: Feature-Policy header magnetometer * allows the top-level document.
PASS Magnetometer: Feature-Policy header magnetometer * allows same-origin iframes.
PASS Magnetometer: Feature-Policy header magnetometer * allows cross-origin iframes.
FAIL UncalibratedMagnetometer: Feature-Policy header magnetometer * allows the top-level document. assert_true: expected true got false
FAIL UncalibratedMagnetometer: Feature-Policy header magnetometer * allows same-origin iframes. assert_true: expected true got false
FAIL UncalibratedMagnetometer: Feature-Policy header magnetometer * allows cross-origin iframes. assert_true: expected true got false
Harness: the test ran to completion.
......@@ -8,7 +8,7 @@
<script>
"use strict";
run_fp_tests_enabled(Magnetometer);
run_fp_tests_enabled(UncalibratedMagnetometer);
run_fp_tests_enabled('Magnetometer');
run_fp_tests_enabled('UncalibratedMagnetometer');
</script>
</body>
This is a testharness.js-based test.
Harness Error. harness_status.status = 1 , harness_status.message = Uncaught ReferenceError: UncalibratedMagnetometer is not defined
PASS Magnetometer: Feature-Policy header magnetometer 'self' allows the top-level document.
PASS Magnetometer: Feature-Policy header magnetometer 'self' allows same-origin iframes.
PASS Magnetometer: Feature-Policy header magnetometer 'self' disallows cross-origin iframes.
FAIL UncalibratedMagnetometer: Feature-Policy header magnetometer 'self' allows the top-level document. assert_true: expected true got false
FAIL UncalibratedMagnetometer: Feature-Policy header magnetometer 'self' allows same-origin iframes. assert_true: expected true got false
FAIL UncalibratedMagnetometer: Feature-Policy header magnetometer 'self' disallows cross-origin iframes. assert_true: expected true got false
Harness: the test ran to completion.
......@@ -8,7 +8,7 @@
<script>
"use strict";
run_fp_tests_enabled_on_self_origin(Magnetometer);
run_fp_tests_enabled_on_self_origin(UncalibratedMagnetometer);
run_fp_tests_enabled_on_self_origin('Magnetometer');
run_fp_tests_enabled_on_self_origin('UncalibratedMagnetometer');
</script>
</body>
This is a testharness.js-based test.
Harness Error. harness_status.status = 1 , harness_status.message = Uncaught ReferenceError: UncalibratedMagnetometer is not defined
FAIL Magnetometer: Test that 'onreading' is called and sensor reading is valid assert_equals: Expected reading event, but got error event instead expected "reading" but got "error"
FAIL Magnetometer: sensor reading is correct assert_equals: Expected reading event, but got error event instead expected "reading" but got "error"
FAIL Magnetometer: sensor timestamp is updated when time passes assert_equals: Expected reading event, but got error event instead expected "reading" but got "error"
FAIL Magnetometer: Test that sensor can be successfully created and its states are correct. assert_equals: Expected activate event, but got error event instead expected "activate" but got "error"
FAIL Magnetometer: sensor.start() returns undefined assert_equals: Expected activate event, but got error event instead expected "activate" but got "error"
FAIL Magnetometer: no exception is thrown when calling start() on already started sensor assert_equals: Expected activate event, but got error event instead expected "activate" but got "error"
FAIL Magnetometer: sensor.stop() returns undefined assert_equals: Expected activate event, but got error event instead expected "activate" but got "error"
FAIL Magnetometer: no exception is thrown when calling stop() on already stopped sensor assert_equals: Expected activate event, but got error event instead expected "activate" but got "error"
FAIL Magnetometer: Test that fresh reading is fetched on start() assert_equals: Expected reading event, but got error event instead expected "reading" but got "error"
FAIL Magnetometer: sensor readings can not be fired on the background tab assert_equals: Expected reading event, but got error event instead expected "reading" but got "error"
FAIL Magnetometer: frequency hint works promise_test: Unhandled rejection with value: object "[object SensorErrorEvent]"
FAIL Magnetometer: sensor receives suspend / resume notifications when cross-origin subframe is focused assert_equals: Expected reading event, but got error event instead expected "reading" but got "error"
FAIL Magnetometer: throw 'NotSupportedError' for an unsupported sensor option assert_throws: function "() => { new sensorType({invalid: 1}) }" did not throw
PASS Magnetometer: Test that 'onreading' is called and sensor reading is valid
PASS Magnetometer: sensor reading is correct
PASS Magnetometer: sensor timestamp is updated when time passes
PASS Magnetometer: Test that sensor can be successfully created and its states are correct.
PASS Magnetometer: sensor.start() returns undefined
PASS Magnetometer: no exception is thrown when calling start() on already started sensor
PASS Magnetometer: sensor.stop() returns undefined
PASS Magnetometer: no exception is thrown when calling stop() on already stopped sensor
PASS Magnetometer: Test that fresh reading is fetched on start()
PASS Magnetometer: frequency hint works
PASS Magnetometer: sensor receives suspend / resume notifications when cross-origin subframe is focused
FAIL Magnetometer: throw 'TypeError' if frequency is invalid assert_throws: when freq is undefined function "() => { new sensorType({frequency: freq}) }" did not throw
FAIL Magnetometer: sensor reading is correct when options.referenceFrame is 'screen' assert_equals: Expected reading event, but got error event instead expected "reading" but got "error"
FAIL Magnetometer: throw 'TypeError' if referenceFrame is not one of enumeration values assert_throws: when refFrame is undefined function "() => { new sensorType({referenceFrame: refFrame}) }" did not throw
PASS Magnetometer: sensor reading is correct when options.referenceFrame is 'screen'
PASS Magnetometer: throw 'TypeError' if referenceFrame is not one of enumeration values
FAIL UncalibratedMagnetometer: Test that 'onreading' is called and sensor reading is valid assert_true: expected true got false
FAIL UncalibratedMagnetometer: sensor reading is correct assert_true: expected true got false
FAIL UncalibratedMagnetometer: sensor timestamp is updated when time passes assert_true: expected true got false
FAIL UncalibratedMagnetometer: Test that sensor can be successfully created and its states are correct. assert_true: expected true got false
FAIL UncalibratedMagnetometer: sensor.start() returns undefined assert_true: expected true got false
FAIL UncalibratedMagnetometer: no exception is thrown when calling start() on already started sensor assert_true: expected true got false
FAIL UncalibratedMagnetometer: sensor.stop() returns undefined assert_true: expected true got false
FAIL UncalibratedMagnetometer: no exception is thrown when calling stop() on already stopped sensor assert_true: expected true got false
FAIL UncalibratedMagnetometer: Test that fresh reading is fetched on start() assert_true: expected true got false
FAIL UncalibratedMagnetometer: frequency hint works assert_true: expected true got false
FAIL UncalibratedMagnetometer: sensor receives suspend / resume notifications when cross-origin subframe is focused assert_true: expected true got false
FAIL UncalibratedMagnetometer: throw 'TypeError' if frequency is invalid assert_true: expected true got false
FAIL UncalibratedMagnetometer: sensor reading is correct when options.referenceFrame is 'screen' assert_true: expected true got false
FAIL UncalibratedMagnetometer: throw 'TypeError' if referenceFrame is not one of enumeration values assert_true: expected true got false
Harness: the test ran to completion.
......@@ -9,7 +9,7 @@
<div id="log"></div>
<script>
runGenericSensorTests(Magnetometer);
runGenericSensorTests(UncalibratedMagnetometer);
runGenericSensorTests('Magnetometer');
runGenericSensorTests('UncalibratedMagnetometer');
</script>
This is a testharness.js-based test.
Harness Error. harness_status.status = 1 , harness_status.message = Uncaught ReferenceError: UncalibratedMagnetometer is not defined
PASS Magnetometer: 'onerror' event is fired when sensor is not supported
FAIL UncalibratedMagnetometer: 'onerror' event is fired when sensor is not supported assert_true: expected true got false
Harness: the test ran to completion.
......@@ -15,7 +15,7 @@
</ol>
<script>
runGenericSensorOnerror(Magnetometer);
runGenericSensorOnerror(UncalibratedMagnetometer);
runGenericSensorOnerror('Magnetometer');
runGenericSensorOnerror('UncalibratedMagnetometer');
</script>
......@@ -8,6 +8,6 @@
<script>
"use strict";
run_fp_tests_disabled(AbsoluteOrientationSensor);
run_fp_tests_disabled('AbsoluteOrientationSensor');
</script>
</body>
......@@ -8,6 +8,6 @@
<script>
"use strict";
run_fp_tests_enabled_by_attribute_redirect_on_load(AbsoluteOrientationSensor);
run_fp_tests_enabled_by_attribute_redirect_on_load('AbsoluteOrientationSensor');
</script>
</body>
......@@ -8,6 +8,6 @@
<script>
"use strict";
run_fp_tests_enabled_by_attribute(AbsoluteOrientationSensor);
run_fp_tests_enabled_by_attribute('AbsoluteOrientationSensor');
</script>
</body>
......@@ -8,6 +8,6 @@
<script>
"use strict";
run_fp_tests_enabled(AbsoluteOrientationSensor);
run_fp_tests_enabled('AbsoluteOrientationSensor');
</script>
</body>
......@@ -8,6 +8,6 @@
<script>
"use strict";
run_fp_tests_enabled_on_self_origin(AbsoluteOrientationSensor);
run_fp_tests_enabled_on_self_origin('AbsoluteOrientationSensor');
</script>
</body>
This is a testharness.js-based test.
PASS AbsoluteOrientationSensor.quaternion return a four-element FrozenArray.
PASS AbsoluteOrientationSensor.populateMatrix() method works correctly.
PASS AbsoluteOrientationSensor: Test that 'onreading' is called and sensor reading is valid
PASS AbsoluteOrientationSensor: sensor reading is correct
PASS AbsoluteOrientationSensor: sensor timestamp is updated when time passes
PASS AbsoluteOrientationSensor: Test that sensor can be successfully created and its states are correct.
PASS AbsoluteOrientationSensor: sensor.start() returns undefined
PASS AbsoluteOrientationSensor: no exception is thrown when calling start() on already started sensor
PASS AbsoluteOrientationSensor: sensor.stop() returns undefined
PASS AbsoluteOrientationSensor: no exception is thrown when calling stop() on already stopped sensor
PASS AbsoluteOrientationSensor: Test that fresh reading is fetched on start()
PASS AbsoluteOrientationSensor: frequency hint works
PASS AbsoluteOrientationSensor: sensor receives suspend / resume notifications when cross-origin subframe is focused
FAIL AbsoluteOrientationSensor: throw 'TypeError' if frequency is invalid assert_throws: when freq is undefined function "() => { new sensorType({frequency: freq}) }" did not throw
PASS AbsoluteOrientationSensor: sensor reading is correct when options.referenceFrame is 'screen'
PASS AbsoluteOrientationSensor: throw 'TypeError' if referenceFrame is not one of enumeration values
Harness: the test ran to completion.
<!DOCTYPE html>
<meta charset="utf-8">
<title>OrientationSensor Test</title>
<link rel="author" title="Intel" href="http://www.intel.com">
<link rel="help" href="https://w3c.github.io/orientation-sensor/">
<link rel="help" href="https://w3c.github.io/sensors/">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/generic-sensor/generic-sensor-tests.js"></script>
<script src="/orientation-sensor/orientation-sensor-tests.js"></script>
<div id="log"></div>
<script>
runOrienationSensorTests('AbsoluteOrientationSensor');
runGenericSensorTests('AbsoluteOrientationSensor');
</script>
This is a testharness.js-based test.
FAIL Test AbsoluteOrientationSensor.quaternion return a four-element FrozenArray. assert_equals: Expected reading event, but got error event instead expected "reading" but got "error"
FAIL Test RelativeOrientationSensor.quaternion return a four-element FrozenArray. assert_equals: Expected reading event, but got error event instead expected "reading" but got "error"
FAIL Test AbsoluteOrientationSensor.populateMatrix() method works correctly. assert_equals: Expected reading event, but got error event instead expected "reading" but got "error"
FAIL Test RelativeOrientationSensor.populateMatrix() method works correctly. assert_equals: Expected reading event, but got error event instead expected "reading" but got "error"
FAIL AbsoluteOrientationSensor: Test that 'onreading' is called and sensor reading is valid assert_equals: Expected reading event, but got error event instead expected "reading" but got "error"
FAIL AbsoluteOrientationSensor: sensor reading is correct assert_equals: Expected reading event, but got error event instead expected "reading" but got "error"
FAIL AbsoluteOrientationSensor: sensor timestamp is updated when time passes assert_equals: Expected reading event, but got error event instead expected "reading" but got "error"
FAIL AbsoluteOrientationSensor: Test that sensor can be successfully created and its states are correct. assert_equals: Expected activate event, but got error event instead expected "activate" but got "error"
FAIL AbsoluteOrientationSensor: sensor.start() returns undefined assert_equals: Expected activate event, but got error event instead expected "activate" but got "error"
FAIL AbsoluteOrientationSensor: no exception is thrown when calling start() on already started sensor assert_equals: Expected activate event, but got error event instead expected "activate" but got "error"
FAIL AbsoluteOrientationSensor: sensor.stop() returns undefined assert_equals: Expected activate event, but got error event instead expected "activate" but got "error"
FAIL AbsoluteOrientationSensor: no exception is thrown when calling stop() on already stopped sensor assert_equals: Expected activate event, but got error event instead expected "activate" but got "error"
FAIL AbsoluteOrientationSensor: Test that fresh reading is fetched on start() assert_equals: Expected reading event, but got error event instead expected "reading" but got "error"
FAIL AbsoluteOrientationSensor: sensor readings can not be fired on the background tab assert_equals: Expected reading event, but got error event instead expected "reading" but got "error"
FAIL AbsoluteOrientationSensor: frequency hint works promise_test: Unhandled rejection with value: object "[object SensorErrorEvent]"
FAIL AbsoluteOrientationSensor: sensor receives suspend / resume notifications when cross-origin subframe is focused assert_equals: Expected reading event, but got error event instead expected "reading" but got "error"
FAIL AbsoluteOrientationSensor: throw 'NotSupportedError' for an unsupported sensor option assert_throws: function "() => { new sensorType({invalid: 1}) }" did not throw
FAIL AbsoluteOrientationSensor: throw 'TypeError' if frequency is invalid assert_throws: when freq is undefined function "() => { new sensorType({frequency: freq}) }" did not throw
FAIL AbsoluteOrientationSensor: sensor reading is correct when options.referenceFrame is 'screen' assert_equals: Expected reading event, but got error event instead expected "reading" but got "error"
FAIL AbsoluteOrientationSensor: throw 'TypeError' if referenceFrame is not one of enumeration values assert_throws: when refFrame is undefined function "() => { new sensorType({referenceFrame: refFrame}) }" did not throw
FAIL RelativeOrientationSensor: Test that 'onreading' is called and sensor reading is valid assert_equals: Expected reading event, but got error event instead expected "reading" but got "error"
FAIL RelativeOrientationSensor: sensor reading is correct assert_equals: Expected reading event, but got error event instead expected "reading" but got "error"
FAIL RelativeOrientationSensor: sensor timestamp is updated when time passes assert_equals: Expected reading event, but got error event instead expected "reading" but got "error"
FAIL RelativeOrientationSensor: Test that sensor can be successfully created and its states are correct. assert_equals: Expected activate event, but got error event instead expected "activate" but got "error"
FAIL RelativeOrientationSensor: sensor.start() returns undefined assert_equals: Expected activate event, but got error event instead expected "activate" but got "error"
FAIL RelativeOrientationSensor: no exception is thrown when calling start() on already started sensor assert_equals: Expected activate event, but got error event instead expected "activate" but got "error"
FAIL RelativeOrientationSensor: sensor.stop() returns undefined assert_equals: Expected activate event, but got error event instead expected "activate" but got "error"
FAIL RelativeOrientationSensor: no exception is thrown when calling stop() on already stopped sensor assert_equals: Expected activate event, but got error event instead expected "activate" but got "error"
FAIL RelativeOrientationSensor: Test that fresh reading is fetched on start() assert_equals: Expected reading event, but got error event instead expected "reading" but got "error"
FAIL RelativeOrientationSensor: sensor readings can not be fired on the background tab assert_equals: Expected reading event, but got error event instead expected "reading" but got "error"
FAIL RelativeOrientationSensor: frequency hint works promise_test: Unhandled rejection with value: object "[object SensorErrorEvent]"
FAIL RelativeOrientationSensor: sensor receives suspend / resume notifications when cross-origin subframe is focused assert_equals: Expected reading event, but got error event instead expected "reading" but got "error"
FAIL RelativeOrientationSensor: throw 'NotSupportedError' for an unsupported sensor option assert_throws: function "() => { new sensorType({invalid: 1}) }" did not throw
FAIL RelativeOrientationSensor: throw 'TypeError' if frequency is invalid assert_throws: when freq is undefined function "() => { new sensorType({frequency: freq}) }" did not throw
FAIL RelativeOrientationSensor: sensor reading is correct when options.referenceFrame is 'screen' assert_equals: Expected reading event, but got error event instead expected "reading" but got "error"
FAIL RelativeOrientationSensor: throw 'TypeError' if referenceFrame is not one of enumeration values assert_throws: when refFrame is undefined function "() => { new sensorType({referenceFrame: refFrame}) }" did not throw
Harness: the test ran to completion.
......@@ -16,7 +16,7 @@
</ol>
<script>
runGenericSensorOnerror(AbsoluteOrientationSensor);
runGenericSensorOnerror(RelativeOrientationSensor);
runGenericSensorOnerror('AbsoluteOrientationSensor');
runGenericSensorOnerror('RelativeOrientationSensor');
</script>
......@@ -8,6 +8,6 @@
<script>
"use strict";
run_fp_tests_disabled(RelativeOrientationSensor);
run_fp_tests_disabled('RelativeOrientationSensor');
</script>
</body>
......@@ -8,6 +8,6 @@
<script>
"use strict";
run_fp_tests_enabled_by_attribute_redirect_on_load(RelativeOrientationSensor);
run_fp_tests_enabled_by_attribute_redirect_on_load('RelativeOrientationSensor');
</script>
</body>
......@@ -8,6 +8,6 @@
<script>
"use strict";
run_fp_tests_enabled_by_attribute(RelativeOrientationSensor);
run_fp_tests_enabled_by_attribute('RelativeOrientationSensor');
</script>
</body>
......@@ -8,6 +8,6 @@
<script>
"use strict";
run_fp_tests_enabled(RelativeOrientationSensor);
run_fp_tests_enabled('RelativeOrientationSensor');
</script>
</body>
......@@ -8,6 +8,6 @@
<script>
"use strict";
run_fp_tests_enabled_on_self_origin(RelativeOrientationSensor);
run_fp_tests_enabled_on_self_origin('RelativeOrientationSensor');
</script>
</body>
This is a testharness.js-based test.
PASS RelativeOrientationSensor.quaternion return a four-element FrozenArray.
PASS RelativeOrientationSensor.populateMatrix() method works correctly.
PASS RelativeOrientationSensor: Test that 'onreading' is called and sensor reading is valid
PASS RelativeOrientationSensor: sensor reading is correct
PASS RelativeOrientationSensor: sensor timestamp is updated when time passes
PASS RelativeOrientationSensor: Test that sensor can be successfully created and its states are correct.
PASS RelativeOrientationSensor: sensor.start() returns undefined
PASS RelativeOrientationSensor: no exception is thrown when calling start() on already started sensor
PASS RelativeOrientationSensor: sensor.stop() returns undefined
PASS RelativeOrientationSensor: no exception is thrown when calling stop() on already stopped sensor
PASS RelativeOrientationSensor: Test that fresh reading is fetched on start()
PASS RelativeOrientationSensor: frequency hint works
PASS RelativeOrientationSensor: sensor receives suspend / resume notifications when cross-origin subframe is focused
FAIL RelativeOrientationSensor: throw 'TypeError' if frequency is invalid assert_throws: when freq is undefined function "() => { new sensorType({frequency: freq}) }" did not throw
PASS RelativeOrientationSensor: sensor reading is correct when options.referenceFrame is 'screen'
PASS RelativeOrientationSensor: throw 'TypeError' if referenceFrame is not one of enumeration values
Harness: the test ran to completion.
<!DOCTYPE html>
<meta charset="utf-8">
<title>OrientationSensor Test</title>
<link rel="author" title="Intel" href="http://www.intel.com">
<link rel="help" href="https://w3c.github.io/orientation-sensor/">
<link rel="help" href="https://w3c.github.io/sensors/">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/generic-sensor/generic-sensor-tests.js"></script>
<script src="/orientation-sensor/orientation-sensor-tests.js"></script>
<div id="log"></div>
<script>
runOrienationSensorTests('RelativeOrientationSensor');
runGenericSensorTests('RelativeOrientationSensor');
</script>
<!DOCTYPE html>
<meta charset="utf-8">
<title>OrientationSensor Test</title>
<link rel="author" title="Intel" href="http://www.intel.com">
<link rel="help" href="https://w3c.github.io/orientation-sensor/">
<link rel="help" href="https://w3c.github.io/sensors/">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/generic-sensor/generic-sensor-tests.js"></script>
<div id="log"></div>
<script>
//IEEE 754: single precision retricts to 7 decimal digits
const float_precision = 1e-7;
......@@ -80,23 +67,17 @@ async function checkPopulateMatrix(t, sensorType) {
sensor.stop();
}
promise_test(t => {
return checkQuaternion(t, AbsoluteOrientationSensor);
}, "Test AbsoluteOrientationSensor.quaternion return a four-element FrozenArray.");
promise_test(t => {
return checkQuaternion(t, RelativeOrientationSensor);
}, "Test RelativeOrientationSensor.quaternion return a four-element FrozenArray.");
function runOrienationSensorTests(sensorName) {
const sensorType = self[sensorName];
promise_test(t => {
return checkPopulateMatrix(t, AbsoluteOrientationSensor);
}, "Test AbsoluteOrientationSensor.populateMatrix() method works correctly.");
sensor_test(async t => {
assert_true(sensorName in self);
return checkQuaternion(t, sensorType);
}, `${sensorName}.quaternion return a four-element FrozenArray.`);
promise_test(t => {
return checkPopulateMatrix(t, RelativeOrientationSensor);
}, "Test RelativeOrientationSensor.populateMatrix() method works correctly.");
runGenericSensorTests(AbsoluteOrientationSensor);
runGenericSensorTests(RelativeOrientationSensor);
sensor_test(async t => {
assert_true(sensorName in self);
return checkPopulateMatrix(t, sensorType);
}, `${sensorName}.populateMatrix() method works correctly.`);
}
</script>
'use strict';
var GenericSensorTest = (() => {
// Class that mocks Sensor interface defined in
// https://cs.chromium.org/chromium/src/services/device/public/mojom/sensor.mojom
class MockSensor {
constructor(sensorRequest, handle, offset, size, reportingMode) {
this.client_ = null;
this.reportingMode_ = reportingMode;
this.sensorReadingTimerId_ = null;
this.requestedFrequencies_ = [];
let rv = handle.mapBuffer(offset, size);
assert_equals(rv.result, Mojo.RESULT_OK, "Failed to map shared buffer");
this.buffer_ = new Float64Array(rv.buffer);
this.buffer_.fill(0);
this.binding_ = new mojo.Binding(device.mojom.Sensor, this,
sensorRequest);
this.binding_.setConnectionErrorHandler(() => {
this.reset();
});
}
getDefaultConfiguration() {
return Promise.resolve({frequency: 5});
}
addConfiguration(configuration) {
assert_not_equals(configuration, null, "Invalid sensor configuration.");
this.requestedFrequencies_.push(configuration.frequency);
// Sort using descending order.
this.requestedFrequencies_.sort(
(first, second) => { return second - first });
this.startReading();
return Promise.resolve({success: true});
}
removeConfiguration(configuration) {
let index = this.requestedFrequencies_.indexOf(configuration.frequency);
if (index == -1)
return;
this.requestedFrequencies_.splice(index, 1);
if (this.isReading) {
this.stopReading();
if (this.requestedFrequencies_.length !== 0)
this.startReading();
}
}
suspend() {
this.stopReading();
}
resume() {
this.startReading();
}
reset() {
this.stopReading();
this.requestedFrequencies_ = [];
this.buffer_.fill(0);
this.binding_.close();
}
startReading() {
if (this.isReading) {
console.warn("Sensor reading is already started.");
return;
}
if (this.requestedFrequencies_.length == 0) {
console.warn("Sensor reading cannot be started as" +
"there are no configurations added.");
return;
}
const maxFrequencyHz = this.requestedFrequencies_[0];
const timeoutMs = (1 / maxFrequencyHz) * 1000;
this.sensorReadingTimerId_ = window.setInterval(() => {
// For all tests sensor reading should have monotonically
// increasing timestamp in seconds.
this.buffer_[1] = window.performance.now() * 0.001;
if (this.reportingMode_ === device.mojom.ReportingMode.ON_CHANGE) {
this.client_.sensorReadingChanged();
}
}, timeoutMs);
}
stopReading() {
if (this.isReading) {
window.clearInterval(this.sensorReadingTimerId_);
this.sensorReadingTimerId_ = null;
}
}
get isReading() {
this.sensorReadingTimerId_ !== null;
}
}
// Class that mocks SensorProvider interface defined in
// https://cs.chromium.org/chromium/src/services/device/public/mojom/sensor_provider.mojom
class MockSensorProvider {
constructor() {
this.readingSizeInBytes_ =
device.mojom.SensorInitParams.kReadBufferSizeForTests;
this.sharedBufferSizeInBytes_ = this.readingSizeInBytes_ *
device.mojom.SensorType.LAST;
let rv = Mojo.createSharedBuffer(this.sharedBufferSizeInBytes_);
assert_equals(rv.result, Mojo.RESULT_OK, "Failed to create buffer");
this.sharedBufferHandle_ = rv.handle;
this.activeSensor_ = null;
this.isContinuous_ = false;
this.binding_ = new mojo.Binding(device.mojom.SensorProvider, this);
this.interceptor_ = new MojoInterfaceInterceptor(
device.mojom.SensorProvider.name);
this.interceptor_.oninterfacerequest = e => {
this.binding_.bind(e.handle);
this.binding_.setConnectionErrorHandler(() => {
console.error("Mojo connection error");
this.reset();
});
};
this.interceptor_.start();
}
async getSensor(type) {
const offset = (device.mojom.SensorType.LAST - type) *
this.readingSizeInBytes_;
const reportingMode = device.mojom.ReportingMode.ON_CHANGE;
let sensorPtr = new device.mojom.SensorPtr();
if (this.activeSensor_ == null) {
let mockSensor = new MockSensor(
mojo.makeRequest(sensorPtr), this.sharedBufferHandle_, offset,
this.readingSizeInBytes_, reportingMode);
this.activeSensor_ = mockSensor;
this.activeSensor_.client_ = new device.mojom.SensorClientPtr();
}
let rv = this.sharedBufferHandle_.duplicateBufferHandle();
assert_equals(rv.result, Mojo.RESULT_OK);
let maxAllowedFrequencyHz = 60;
if (type == device.mojom.SensorType.AMBIENT_LIGHT ||
type == device.mojom.SensorType.MAGNETOMETER) {
maxAllowedFrequencyHz = 10;
}
let initParams = new device.mojom.SensorInitParams({
sensor: sensorPtr,
clientRequest: mojo.makeRequest(this.activeSensor_.client_),
memory: rv.handle,
bufferOffset: offset,
mode: reportingMode,
defaultConfiguration: {frequency: 5},
minimumFrequency: 1,
maximumFrequency: maxAllowedFrequencyHz
});
return {result: device.mojom.SensorCreationResult.SUCCESS,
initParams: initParams};
}
async reset() {
if (this.activeSensor_ !== null) {
this.activeSensor_.reset();
this.activeSensor_ = null;
}
// Wait for an event loop iteration to let
// the pending mojo commands pass.
function schedule(func) {
return new Promise(resolve => {
setTimeout(() => {
func();
resolve();
}, 0);
});
}
await schedule(this.binding_.close.bind(this.binding_));
await schedule(this.interceptor_.stop.bind(this.interceptor_));
}
}
let testInternal = {
initialized: false,
sensorProvider: null
}
class GenericSensorTestChromium {
constructor() {
Object.freeze(this); // Make it immutable.
}
initialize() {
if (testInternal.initialized)
throw new Error('Call reset() before initialize().');
if (testRunner) { // Grant sensor permissions for Chromium testrunner.
['accelerometer', 'gyroscope',
'magnetometer', 'ambient-light-sensor'].forEach((entry) => {
testRunner.setPermission(entry, 'granted',
location.origin, location.origin);
});
}
testInternal.sensorProvider = new MockSensorProvider;
testInternal.initialized = true;
}
// Resets state of sensor mocks between test runs.
async reset() {
if (!testInternal.initialized)
throw new Error('Call initialize() before reset().');
await testInternal.sensorProvider.reset();
testInternal.sensorProvider = null;
testInternal.initialized = false;
}
}
return GenericSensorTestChromium;
})();
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment