Commit 20133397 authored by Wanming Lin's avatar Wanming Lin Committed by Commit Bot

[sensor] Upstream sensor layout tests to wpt

Rewrote /external/wpt/resources/chromium/generic_sensor_mocks.js to align with
/http/tests/resources/sensor-helpers.js, but excluded those functions specific
for device orientation.

Merged tests from /sensor/resources/generic-sensor-tests.js to
/external/wpt/generic-sensor/generic-sensor-tests.js

Moved common utils into /external/wpt/generic-sensor/resources/generic-sensor-helpers.js

Merged tests from /sensor/*.html to corresponding test folders under /external/wpt/,
e.g. sensor/orientation-sensor.html  -> external/wpt/orientation-sensor/OrientationSensor.https.html

Updated all sensor tests under external/wpt/ to adapt to sensor mojom mocks

Deleted folder web_tests/sensor/

Bug: 816462
Change-Id: I614ce82b7c90530b7a268d8f6a0f72cc96ea3d6f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1770158
Commit-Queue: Wanming Lin <wanming.lin@intel.com>
Reviewed-by: default avatarReilly Grant <reillyg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#695905}
parent 2ba13f1a
...@@ -1666,7 +1666,6 @@ external/wpt/2dcontext/drawing-paths-to-the-canvas/canvas_focus_drawFocusIfNeede ...@@ -1666,7 +1666,6 @@ external/wpt/2dcontext/drawing-paths-to-the-canvas/canvas_focus_drawFocusIfNeede
external/wpt/FileAPI/FileReader/test_notreadableerrors-manual.html [ WontFix ] external/wpt/FileAPI/FileReader/test_notreadableerrors-manual.html [ WontFix ]
external/wpt/FileAPI/FileReader/test_securityerrors-manual.html [ WontFix ] external/wpt/FileAPI/FileReader/test_securityerrors-manual.html [ WontFix ]
external/wpt/FileAPI/url/url_createobjecturl_file_img-manual.html [ WontFix ] external/wpt/FileAPI/url/url_createobjecturl_file_img-manual.html [ WontFix ]
external/wpt/accelerometer/Accelerometer_onerror-manual.https.html [ WontFix ]
external/wpt/accelerometer/LinearAccelerationSensor-shake-threshold-manual.https.html [ WontFix ] external/wpt/accelerometer/LinearAccelerationSensor-shake-threshold-manual.https.html [ WontFix ]
external/wpt/audio-output/setSinkId-manual.https.html [ WontFix ] external/wpt/audio-output/setSinkId-manual.https.html [ WontFix ]
external/wpt/battery-status/battery-charging-manual.https.html [ WontFix ] external/wpt/battery-status/battery-charging-manual.https.html [ WontFix ]
...@@ -1849,8 +1848,6 @@ external/wpt/geolocation-API/getCurrentPosition_permission-manual.html [ WontFix ...@@ -1849,8 +1848,6 @@ external/wpt/geolocation-API/getCurrentPosition_permission-manual.html [ WontFix
external/wpt/geolocation-API/getCurrentPosition_permission_allow-manual.html [ WontFix ] external/wpt/geolocation-API/getCurrentPosition_permission_allow-manual.html [ WontFix ]
external/wpt/geolocation-API/getCurrentPosition_permission_deny-manual.html [ WontFix ] external/wpt/geolocation-API/getCurrentPosition_permission_deny-manual.html [ WontFix ]
external/wpt/geolocation-API/watchPosition_permission-manual.html [ WontFix ] external/wpt/geolocation-API/watchPosition_permission-manual.html [ WontFix ]
external/wpt/geolocation-sensor/GeolocationSensor_onerror-manual.https.html [ WontFix ]
external/wpt/gyroscope/Gyroscope_onerror-manual.https.html [ WontFix ]
external/wpt/hr-time/unload-manual.html [ WontFix ] external/wpt/hr-time/unload-manual.html [ WontFix ]
external/wpt/html-media-capture/capture_audio-manual.html [ WontFix ] external/wpt/html-media-capture/capture_audio-manual.html [ WontFix ]
external/wpt/html-media-capture/capture_audio_cancel-manual.html [ WontFix ] external/wpt/html-media-capture/capture_audio_cancel-manual.html [ WontFix ]
...@@ -1977,7 +1974,6 @@ external/wpt/html/semantics/interactive-elements/commands/legend/no-fieldset-par ...@@ -1977,7 +1974,6 @@ external/wpt/html/semantics/interactive-elements/commands/legend/no-fieldset-par
external/wpt/html/semantics/selectors/pseudo-classes/checked-001-manual.html [ WontFix ] external/wpt/html/semantics/selectors/pseudo-classes/checked-001-manual.html [ WontFix ]
external/wpt/html/webappapis/scripting/events/contextmenu-event-manual.htm [ WontFix ] external/wpt/html/webappapis/scripting/events/contextmenu-event-manual.htm [ WontFix ]
external/wpt/html/webappapis/scripting/events/event-handler-processing-algorithm-manual.html [ WontFix ] external/wpt/html/webappapis/scripting/events/event-handler-processing-algorithm-manual.html [ WontFix ]
external/wpt/magnetometer/Magnetometer_onerror-manual.https.html [ WontFix ]
external/wpt/mediacapture-streams/MediaStream-MediaElement-preload-none-manual.https.html [ WontFix ] external/wpt/mediacapture-streams/MediaStream-MediaElement-preload-none-manual.https.html [ WontFix ]
external/wpt/mediacapture-streams/MediaStreamTrack-end-manual.https.html [ WontFix ] external/wpt/mediacapture-streams/MediaStreamTrack-end-manual.https.html [ WontFix ]
external/wpt/notifications/body-basic-manual.html [ WontFix ] external/wpt/notifications/body-basic-manual.html [ WontFix ]
...@@ -2009,7 +2005,6 @@ external/wpt/orientation-event/t022-manual.https.html [ WontFix ] ...@@ -2009,7 +2005,6 @@ external/wpt/orientation-event/t022-manual.https.html [ WontFix ]
external/wpt/orientation-event/t023-manual.https.html [ WontFix ] external/wpt/orientation-event/t023-manual.https.html [ WontFix ]
external/wpt/orientation-event/t025-manual.https.html [ WontFix ] external/wpt/orientation-event/t025-manual.https.html [ WontFix ]
external/wpt/orientation-event/t028-manual.https.html [ WontFix ] external/wpt/orientation-event/t028-manual.https.html [ WontFix ]
external/wpt/orientation-sensor/OrientationSensor_onerror-manual.https.html [ WontFix ]
external/wpt/page-visibility/test_minimize-manual.html [ WontFix ] external/wpt/page-visibility/test_minimize-manual.html [ WontFix ]
external/wpt/page-visibility/test_tab_state_change-manual.html [ WontFix ] external/wpt/page-visibility/test_tab_state_change-manual.html [ WontFix ]
external/wpt/payment-method-basic-card/empty-data-manual.https.html [ WontFix ] external/wpt/payment-method-basic-card/empty-data-manual.https.html [ WontFix ]
......
...@@ -525,7 +525,6 @@ crbug.com/874695 paint/invalidation/filters/filter-repaint-on-accelerated-layer. ...@@ -525,7 +525,6 @@ crbug.com/874695 paint/invalidation/filters/filter-repaint-on-accelerated-layer.
crbug.com/874695 plugins/plugin-document-back-forward.html [ Slow ] crbug.com/874695 plugins/plugin-document-back-forward.html [ Slow ]
crbug.com/874695 pointer-lock/locked-element-iframe-removed-from-dom.html [ Slow ] crbug.com/874695 pointer-lock/locked-element-iframe-removed-from-dom.html [ Slow ]
crbug.com/874695 printing/webgl-oversized-printing.html [ Slow ] crbug.com/874695 printing/webgl-oversized-printing.html [ Slow ]
crbug.com/874695 sensor/magnetometer.html [ Slow ]
crbug.com/874695 storage/websql/change-version.html [ Slow ] crbug.com/874695 storage/websql/change-version.html [ Slow ]
crbug.com/874695 storage/websql/executesql-accepts-only-one-statement.html [ Slow ] crbug.com/874695 storage/websql/executesql-accepts-only-one-statement.html [ Slow ]
crbug.com/874695 storage/websql/open-database-creation-callback.html [ Slow ] crbug.com/874695 storage/websql/open-database-creation-callback.html [ Slow ]
......
...@@ -4790,12 +4790,6 @@ crbug.com/746128 [ Win7 Debug ] virtual/audio-service/media/controls/video-enter ...@@ -4790,12 +4790,6 @@ crbug.com/746128 [ Win7 Debug ] virtual/audio-service/media/controls/video-enter
crbug.com/746128 [ Mac ] media/controls/video-enter-exit-fullscreen-without-hovering-doesnt-show-controls.html [ Failure Pass ] crbug.com/746128 [ Mac ] media/controls/video-enter-exit-fullscreen-without-hovering-doesnt-show-controls.html [ Failure Pass ]
crbug.com/746128 [ Mac ] virtual/audio-service/media/controls/video-enter-exit-fullscreen-without-hovering-doesnt-show-controls.html [ Failure Pass ] crbug.com/746128 [ Mac ] virtual/audio-service/media/controls/video-enter-exit-fullscreen-without-hovering-doesnt-show-controls.html [ Failure Pass ]
crbug.com/731018 [ Mac ] sensor/accelerometer.html [ Failure Pass Crash ]
crbug.com/731018 [ Mac ] sensor/ambient-light-sensor.html [ Failure Pass Crash ]
crbug.com/731018 [ Mac ] sensor/gyroscope.html [ Failure Pass Crash ]
crbug.com/731018 [ Mac ] sensor/magnetometer.html [ Failure Pass Crash ]
crbug.com/731018 [ Mac ] sensor/orientation-sensor.html [ Failure Pass Crash ]
# Tests failing when enabling new modern media controls # Tests failing when enabling new modern media controls
crbug.com/831942 media/webkit-media-controls-webkit-appearance.html [ Failure Pass ] crbug.com/831942 media/webkit-media-controls-webkit-appearance.html [ Failure Pass ]
crbug.com/831942 virtual/audio-service/media/webkit-media-controls-webkit-appearance.html [ Failure Pass ] crbug.com/831942 virtual/audio-service/media/webkit-media-controls-webkit-appearance.html [ Failure Pass ]
...@@ -5666,9 +5660,6 @@ crbug.com/931349 [ Mac ] virtual/audio-service/media/video-played-ranges-1.html ...@@ -5666,9 +5660,6 @@ crbug.com/931349 [ Mac ] virtual/audio-service/media/video-played-ranges-1.html
# Sheriff 2019-02-13 # Sheriff 2019-02-13
crbug.com/931646 [ Win7 ] http/tests/preload/meta-viewport-link-headers-imagesrcset.html [ Failure Pass ] crbug.com/931646 [ Win7 ] http/tests/preload/meta-viewport-link-headers-imagesrcset.html [ Failure Pass ]
# Sheriff 2019-02-19
crbug.com/933346 [ Debug ] external/wpt/orientation-sensor/RelativeOrientationSensor.https.html [ Failure Timeout Pass ]
# These started failing when network service was enabled by default. # These started failing when network service was enabled by default.
crbug.com/933880 external/wpt/service-workers/service-worker/request-end-to-end.https.html [ Failure ] crbug.com/933880 external/wpt/service-workers/service-worker/request-end-to-end.https.html [ Failure ]
crbug.com/933880 virtual/omt-service-worker-startup/external/wpt/service-workers/service-worker/request-end-to-end.https.html [ Failure ] crbug.com/933880 virtual/omt-service-worker-startup/external/wpt/service-workers/service-worker/request-end-to-end.https.html [ Failure ]
...@@ -5719,7 +5710,6 @@ crbug.com/937811 [ Linux Release ] http/tests/devtools/elements/shadow/elements- ...@@ -5719,7 +5710,6 @@ crbug.com/937811 [ Linux Release ] http/tests/devtools/elements/shadow/elements-
crbug.com/937811 [ Linux Release ] http/tests/devtools/elements/shadow/elements-panel-shadow-selection-on-refresh-3.js [ Pass Failure ] crbug.com/937811 [ Linux Release ] http/tests/devtools/elements/shadow/elements-panel-shadow-selection-on-refresh-3.js [ Pass Failure ]
crbug.com/937811 [ Win Release ] http/tests/devtools/elements/shadow/elements-panel-shadow-selection-on-refresh-2.js [ Pass Failure ] crbug.com/937811 [ Win Release ] http/tests/devtools/elements/shadow/elements-panel-shadow-selection-on-refresh-2.js [ Pass Failure ]
crbug.com/935689 external/wpt/css/vendor-imports/mozilla/mozilla-central-reftests/counter-styles-3/symbols-function.html [ Failure Pass ] crbug.com/935689 external/wpt/css/vendor-imports/mozilla/mozilla-central-reftests/counter-styles-3/symbols-function.html [ Failure Pass ]
crbug.com/937858 [ Debug ] external/wpt/ambient-light/AmbientLightSensor.https.html [ Pass Failure ]
# Sheriff 2019-03-05 # Sheriff 2019-03-05
crbug.com/938200 http/tests/devtools/network/network-blocked-reason.js [ Timeout Pass ] crbug.com/938200 http/tests/devtools/network/network-blocked-reason.js [ Timeout Pass ]
...@@ -5814,8 +5804,6 @@ crbug.com/947690 [ Debug ] http/tests/history/back-during-beforeunload.html [ Pa ...@@ -5814,8 +5804,6 @@ crbug.com/947690 [ Debug ] http/tests/history/back-during-beforeunload.html [ Pa
# Sheriff 2019-04-03 # Sheriff 2019-04-03
crbug.com/949167 external/wpt/html/semantics/links/links-created-by-a-and-area-elements/target_blank_implicit_noopener.html [ Pass Timeout ] crbug.com/949167 external/wpt/html/semantics/links/links-created-by-a-and-area-elements/target_blank_implicit_noopener.html [ Pass Timeout ]
crbug.com/949207 external/wpt/html/semantics/links/links-created-by-a-and-area-elements/target_blank_implicit_noopener_base.html [ Pass Timeout ] crbug.com/949207 external/wpt/html/semantics/links/links-created-by-a-and-area-elements/target_blank_implicit_noopener_base.html [ Pass Timeout ]
crbug.com/949442 [ Mac10.13 Debug ] external/wpt/accelerometer/Accelerometer.https.html [ Pass Failure ]
crbug.com/949442 [ Mac10.13 Debug ] external/wpt/orientation-sensor/AbsoluteOrientationSensor.https.html [ Pass Failure ]
crbug.com/949445 [ Mac ] fast/forms/text/input-text-scroll-left-on-blur.html [ Failure ] crbug.com/949445 [ Mac ] fast/forms/text/input-text-scroll-left-on-blur.html [ Failure ]
# Sheriff 2019-04-09 # Sheriff 2019-04-09
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<link rel="help" href="https://www.w3.org/TR/accelerometer/"> <link rel="help" href="https://www.w3.org/TR/accelerometer/">
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<script src="/generic-sensor/generic-sensor-tests.js"></script> <script src="/generic-sensor/resources/generic-sensor-helpers.js"></script>
<script src="/generic-sensor/generic-sensor-iframe-tests.sub.js"></script> <script src="/generic-sensor/generic-sensor-iframe-tests.sub.js"></script>
<script src="/generic-sensor/generic-sensor-feature-policy-test.sub.js"></script> <script src="/generic-sensor/generic-sensor-feature-policy-test.sub.js"></script>
<div id="log"></div> <div id="log"></div>
......
This is a testharness.js-based test. This is a testharness.js-based test.
PASS Accelerometer: Test that 'onreading' is called and sensor reading is valid Found 66 tests; 44 PASS, 22 FAIL, 0 TIMEOUT, 0 NOTRUN.
PASS Accelerometer: sensor reading is correct PASS Accelerometer: Test that onerror is sent when sensor is not supported.
PASS Accelerometer: sensor timestamp is updated when time passes PASS Accelerometer: Test that onerror is sent when permissions are not granted.
PASS Accelerometer: Test that onerror is send when start() call has failed.
PASS Accelerometer: Test that frequency is capped to allowed maximum.
PASS Accelerometer: Test that frequency is capped to the maximum supported frequency.
PASS Accelerometer: Test that frequency is limited to the minimum supported frequency.
PASS Accelerometer: Test that sensor cannot be constructed within iframe disallowed to use feature policy.
PASS Accelerometer: Test that sensor can be constructed within an iframe allowed to use feature policy.
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: Test that sensor can be successfully created and its states are correct.
PASS Accelerometer: sensor.start() returns undefined PASS Accelerometer: sensor.start() returns undefined.
PASS Accelerometer: no exception is thrown when calling start() on already started sensor PASS Accelerometer: no exception is thrown when calling start() on already started sensor.
PASS Accelerometer: sensor.stop() returns undefined PASS Accelerometer: sensor.stop() returns undefined.
PASS Accelerometer: no exception is thrown when calling stop() on already stopped sensor 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: Test that fresh reading is fetched on start().
PASS Accelerometer: frequency hint works PASS Accelerometer: frequency hint works.
PASS Accelerometer: sensor receives suspend / resume notifications when cross-origin subframe is focused PASS Accelerometer: sensor receives suspend / resume notifications when cross-origin subframe is focused.
PASS Accelerometer: throw 'TypeError' if frequency is invalid PASS Accelerometer: throw 'TypeError' if frequency is invalid.
PASS Accelerometer: sensor reading is correct when options.referenceFrame is 'screen' PASS Accelerometer: sensor reading is correct when options.referenceFrame is 'screen'.
PASS Accelerometer: throw 'TypeError' if referenceFrame is not one of enumeration values 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: Test that onerror is sent when sensor is not supported. assert_true: expected true got false
FAIL GravitySensor: sensor reading is correct assert_true: expected true got false FAIL GravitySensor: Test that onerror is sent when permissions are not granted. 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 onerror is send when start() call has failed. assert_true: expected true got false
FAIL GravitySensor: Test that frequency is capped to allowed maximum. assert_true: expected true got false
FAIL GravitySensor: Test that frequency is capped to the maximum supported frequency. assert_true: expected true got false
FAIL GravitySensor: Test that frequency is limited to the minimum supported frequency. assert_true: expected true got false
FAIL GravitySensor: Test that sensor cannot be constructed within iframe disallowed to use feature policy. assert_true: expected true got false
FAIL GravitySensor: Test that sensor can be constructed within an iframe allowed to use feature policy. assert_true: expected true got false
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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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 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: Test that onerror is sent when sensor is not supported.
PASS LinearAccelerationSensor: sensor reading is correct PASS LinearAccelerationSensor: Test that onerror is sent when permissions are not granted.
PASS LinearAccelerationSensor: sensor timestamp is updated when time passes PASS LinearAccelerationSensor: Test that onerror is send when start() call has failed.
PASS LinearAccelerationSensor: Test that frequency is capped to allowed maximum.
PASS LinearAccelerationSensor: Test that frequency is capped to the maximum supported frequency.
PASS LinearAccelerationSensor: Test that frequency is limited to the minimum supported frequency.
PASS LinearAccelerationSensor: Test that sensor cannot be constructed within iframe disallowed to use feature policy.
PASS LinearAccelerationSensor: Test that sensor can be constructed within an iframe allowed to use feature policy.
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: Test that sensor can be successfully created and its states are correct.
PASS LinearAccelerationSensor: sensor.start() returns undefined PASS LinearAccelerationSensor: sensor.start() returns undefined.
PASS LinearAccelerationSensor: no exception is thrown when calling start() on already started sensor PASS LinearAccelerationSensor: no exception is thrown when calling start() on already started sensor.
PASS LinearAccelerationSensor: sensor.stop() returns undefined PASS LinearAccelerationSensor: sensor.stop() returns undefined.
PASS LinearAccelerationSensor: no exception is thrown when calling stop() on already stopped sensor 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: Test that fresh reading is fetched on start().
PASS LinearAccelerationSensor: frequency hint works PASS LinearAccelerationSensor: frequency hint works.
PASS LinearAccelerationSensor: sensor receives suspend / resume notifications when cross-origin subframe is focused PASS LinearAccelerationSensor: sensor receives suspend / resume notifications when cross-origin subframe is focused.
PASS LinearAccelerationSensor: throw 'TypeError' if frequency is invalid PASS LinearAccelerationSensor: throw 'TypeError' if frequency is invalid.
PASS LinearAccelerationSensor: sensor reading is correct when options.referenceFrame is 'screen' PASS LinearAccelerationSensor: sensor reading is correct when options.referenceFrame is 'screen'.
PASS LinearAccelerationSensor: throw 'TypeError' if referenceFrame is not one of enumeration values PASS LinearAccelerationSensor: throw 'TypeError' if referenceFrame is not one of enumeration values.
Harness: the test ran to completion. Harness: the test ran to completion.
...@@ -6,12 +6,40 @@ ...@@ -6,12 +6,40 @@
<link rel="help" href="https://www.w3.org/TR/accelerometer/"> <link rel="help" href="https://www.w3.org/TR/accelerometer/">
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<script src="/generic-sensor/resources/generic-sensor-helpers.js"></script>
<script src="/generic-sensor/generic-sensor-tests.js"></script> <script src="/generic-sensor/generic-sensor-tests.js"></script>
<div id="log"></div>
<script> <script>
runGenericSensorTests('Accelerometer'); 'use strict';
runGenericSensorTests('GravitySensor');
runGenericSensorTests('LinearAccelerationSensor'); const kReadings = {
readings: [
[1.12345, 2.12345, 3.12345]
],
expectedReadings: [
[1.12345, 2.12345, 3.12345]
],
expectedRemappedReadings: [
[-2.12345, 1.12345, 3.12345]
]
};
runGenericSensorTests(
'Accelerometer',
kReadings,
verifyXyzSensorReading,
['accelerometer']);
runGenericSensorTests(
'GravitySensor',
kReadings,
verifyXyzSensorReading,
['accelerometer']);
runGenericSensorTests(
'LinearAccelerationSensor',
kReadings,
verifyXyzSensorReading,
['accelerometer']);
</script> </script>
<!DOCTYPE html>
<meta charset="utf-8">
<title>Accelerometer Test: onerror</title>
<link rel="author" title="Intel" href="http://www.intel.com">
<link rel="help" href="https://www.w3.org/TR/accelerometer/">
<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>
<h2>Precondition</h2>
<ol>
<li>
Disable the Accelerometer Sensor or run test on a device without Accelerometer Sensor.
</li>
</ol>
<script>
runGenericSensorOnerror('Accelerometer');
runGenericSensorOnerror('GravitySensor');
runGenericSensorOnerror('LinearAccelerationSensor');
</script>
This is a testharness.js-based test.
FAIL Test that when shaking gesture along x axis of the device, the shake threshold can be greater than 25 assert_unreached: NotAllowedError:Permissions to access sensor are not granted Reached unreachable code
Harness: the test ran to completion.
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<link rel="help" href="https://w3c.github.io/ambient-light/"> <link rel="help" href="https://w3c.github.io/ambient-light/">
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<script src="/generic-sensor/generic-sensor-tests.js"></script> <script src="/generic-sensor/resources/generic-sensor-helpers.js"></script>
<script src="/generic-sensor/generic-sensor-iframe-tests.sub.js"></script> <script src="/generic-sensor/generic-sensor-iframe-tests.sub.js"></script>
<script src="/generic-sensor/generic-sensor-feature-policy-test.sub.js"></script> <script src="/generic-sensor/generic-sensor-feature-policy-test.sub.js"></script>
<div id="log"></div> <div id="log"></div>
......
...@@ -5,10 +5,25 @@ ...@@ -5,10 +5,25 @@
<link rel="help" href="https://www.w3.org/TR/ambient-light/"> <link rel="help" href="https://www.w3.org/TR/ambient-light/">
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<script src="/generic-sensor/resources/generic-sensor-helpers.js"></script>
<script src="/generic-sensor/generic-sensor-tests.js"></script> <script src="/generic-sensor/generic-sensor-tests.js"></script>
<div id="log"></div>
<script> <script>
runGenericSensorTests('AmbientLightSensor'); 'use strict';
const kReadings = {
readings: [
[3.1415]
],
expectedReadings: [
[3.1415]
]
};
runGenericSensorTests(
'AmbientLightSensor',
kReadings,
verifyAlsSensorReading,
['ambient-light-sensor']);
</script> </script>
<!DOCTYPE html>
<meta charset="utf-8">
<title>AmbientLightSensor Test: onerror</title>
<link rel="author" title="Intel" href="http://www.intel.com">
<link rel="help" href="https://www.w3.org/TR/ambient-light/">
<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>
<h2>Precondition</h2>
<ol>
<li>
Disable the Ambient Light Sensor or run test on a device without Amibent Light Sensor.
</li>
</ol>
<script>
runGenericSensorOnerror('AmbientLightSensor');
</script>
The `generic-sensor-tests.js` tests require an implementation of The `resources/generic-sensor-helpers.js` tests require an implementation of
the `GenericSensorTest` interface, which should emulate platform the `GenericSensorTest` interface, which should emulate platform
sensor backends. The `GenericSensorTest` interface is defined as: sensor backends. The `GenericSensorTest` interface is defined as:
``` ```
class MockSensor {
// Sets fake data that is used to deliver sensor reading updates.
async setSensorReading(FrozenArray<double> readingData);
setStartShouldFail(boolean shouldFail); // Sets flag that forces sensor to fail.
getSamplingFrequency(); // Return the sampling frequency.
};
class MockSensorProvider {
// Sets flag that forces mock SensorProvider to fail when getSensor() is
// invoked.
setGetSensorShouldFail(DOMString sensorType, boolean shouldFail);
// Sets flag that forces mock SensorProvider to permissions denied when
// getSensor() is invoked.
setPermissionsDenied(DOMString sensorType, boolean permissionsDenied);
getCreatedSensor(DOMString sensorType); // Return `MockSensor` interface.
setMaximumSupportedFrequency(double frequency); // Sets the maximum frequency.
setMinimumSupportedFrequency(double frequency); // Sets the minimum frequency.
}
class GenericSensorTest { class GenericSensorTest {
async initialize(); // Sets up the testing enviroment. initialize(); // Sets up the testing environment.
async reset(); // Frees the resources. async reset(); // Frees the resources.
getSensorProvider(); // Returns `MockSensorProvider` interface.
}; };
``` ```
......
'use strict';
// These tests rely on the User Agent providing an implementation of
// platform sensor backends.
//
// In Chromium-based browsers this implementation is provided by a polyfill
// in order to reduce the amount of test-only code shipped to users. To enable
// these tests the browser must be run with these options:
//
// --enable-blink-features=MojoJS,MojoJSTest
const loadChromiumResources = async () => {
if (!('MojoInterfaceInterceptor' in self)) {
// Do nothing on non-Chromium-based browsers or when the Mojo bindings are
// not present in the global namespace.
return;
}
const resources = [
'/gen/layout_test_data/mojo/public/js/mojo_bindings.js',
'/gen/mojo/public/mojom/base/string16.mojom.js',
'/gen/services/device/public/mojom/sensor.mojom.js',
'/gen/services/device/public/mojom/sensor_provider.mojom.js',
'/resources/chromium/generic_sensor_mocks.js',
];
await Promise.all(resources.map(path => {
const script = document.createElement('script');
script.src = path;
script.async = false;
const promise = new Promise((resolve, reject) => {
script.onload = resolve;
script.onerror = reject;
});
document.head.appendChild(script);
return promise;
}));
};
async function initialize_generic_sensor_tests() {
if (typeof GenericSensorTest === 'undefined') {
await loadChromiumResources();
}
assert_true(
typeof GenericSensorTest !== 'undefined',
'Mojo testing interface is not available.'
);
let sensorTest = new GenericSensorTest();
await sensorTest.initialize();
return sensorTest;
}
function sensor_test(func, name, properties) {
promise_test(async (t) => {
let sensorTest = await initialize_generic_sensor_tests();
try {
await func(t, sensorTest.getSensorProvider());
} finally {
await sensorTest.reset();
};
}, name, properties);
}
function verifySensorReading(pattern, values, timestamp, isNull) {
function round(val) {
return Number.parseFloat(val).toPrecision(6);
}
if (isNull) {
return (values === null || values.every(r => r === null)) &&
timestamp === null;
}
return values.every((r, i) => round(r) === round(pattern[i])) &&
timestamp !== null;
}
function verifyXyzSensorReading(pattern, {x, y, z, timestamp}, isNull) {
return verifySensorReading(pattern, [x, y, z], timestamp, isNull);
}
function verifyQuatSensorReading(pattern, {quaternion, timestamp}, isNull) {
return verifySensorReading(pattern, quaternion, timestamp, isNull);
}
function verifyAlsSensorReading(pattern, {illuminance, timestamp}, isNull) {
return verifySensorReading(pattern, [illuminance], timestamp, isNull);
}
function verifyGeoSensorReading(pattern, {latitude, longitude, altitude,
accuracy, altitudeAccuracy, heading, speed, timestamp}, isNull) {
return verifySensorReading(pattern, [latitude, longitude, altitude,
accuracy, altitudeAccuracy, heading, speed], timestamp, isNull);
}
// A "sliding window" that iterates over |data| and returns one item at a
// time, advancing and wrapping around as needed. |data| must be an array of
// arrays.
class RingBuffer {
constructor(data) {
this.bufferPosition_ = 0;
// Validate |data|'s format and deep-copy every element.
this.data_ = Array.from(data, element => {
if (!Array.isArray(element)) {
throw new TypeError('Every |data| element must be an array.');
}
return Array.from(element);
})
}
next() {
const value = this.data_[this.bufferPosition_];
this.bufferPosition_ = (this.bufferPosition_ + 1) % this.data_.length;
return { done: false, value: value };
}
[Symbol.iterator]() {
return this;
}
}
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<meta charset="utf-8"> <meta charset="utf-8">
<title>iframe sensor tester</title> <title>iframe sensor tester</title>
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/generic-sensor/generic-sensor-tests.js"></script> <script src="/generic-sensor/resources/generic-sensor-helpers.js"></script>
<script> <script>
let mockBackend = null; let mockBackend = null;
// Minimum frequency supported by the mock backend is 5Hz. Using 200ms // Minimum frequency supported by the mock backend is 5Hz. Using 200ms
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<link rel="help" href="https://wicg.github.io/geolocation-sensor/"> <link rel="help" href="https://wicg.github.io/geolocation-sensor/">
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<script src="/generic-sensor/generic-sensor-tests.js"></script> <script src="/generic-sensor/resources/generic-sensor-helpers.js"></script>
<script src="/generic-sensor/generic-sensor-iframe-tests.sub.js"></script> <script src="/generic-sensor/generic-sensor-iframe-tests.sub.js"></script>
<script src="/generic-sensor/generic-sensor-feature-policy-test.sub.js"></script> <script src="/generic-sensor/generic-sensor-feature-policy-test.sub.js"></script>
<div id="log"></div> <div id="log"></div>
......
This is a testharness.js-based test. This is a testharness.js-based test.
FAIL GeolocationSensor: Test that 'onreading' is called and sensor reading is valid assert_true: expected true got false FAIL GeolocationSensor: Test that onerror is sent when sensor is not supported. assert_true: expected true got false
FAIL GeolocationSensor: sensor reading is correct assert_true: expected true got false FAIL GeolocationSensor: Test that onerror is sent when permissions are not granted. assert_true: expected true got false
FAIL GeolocationSensor: sensor timestamp is updated when time passes assert_true: expected true got false FAIL GeolocationSensor: Test that onerror is send when start() call has failed. assert_true: expected true got false
FAIL GeolocationSensor: Test that frequency is capped to allowed maximum. assert_true: expected true got false
FAIL GeolocationSensor: Test that frequency is capped to the maximum supported frequency. assert_true: expected true got false
FAIL GeolocationSensor: Test that frequency is limited to the minimum supported frequency. assert_true: expected true got false
FAIL GeolocationSensor: Test that sensor cannot be constructed within iframe disallowed to use feature policy. assert_true: expected true got false
FAIL GeolocationSensor: Test that sensor can be constructed within an iframe allowed to use feature policy. assert_true: expected true got false
FAIL GeolocationSensor: Test that 'onreading' is called and sensor reading is valid. assert_true: expected true got false
FAIL GeolocationSensor: sensor reading is correct. assert_true: expected true got false
FAIL GeolocationSensor: sensor timestamp is updated when time passes. assert_true: expected true got false
FAIL GeolocationSensor: Test that sensor can be successfully created and its states are correct. assert_true: expected true got false FAIL GeolocationSensor: Test that sensor can be successfully created and its states are correct. assert_true: expected true got false
FAIL GeolocationSensor: sensor.start() returns undefined assert_true: expected true got false FAIL GeolocationSensor: sensor.start() returns undefined. assert_true: expected true got false
FAIL GeolocationSensor: no exception is thrown when calling start() on already started sensor assert_true: expected true got false FAIL GeolocationSensor: no exception is thrown when calling start() on already started sensor. assert_true: expected true got false
FAIL GeolocationSensor: sensor.stop() returns undefined assert_true: expected true got false FAIL GeolocationSensor: sensor.stop() returns undefined. assert_true: expected true got false
FAIL GeolocationSensor: no exception is thrown when calling stop() on already stopped sensor assert_true: expected true got false FAIL GeolocationSensor: no exception is thrown when calling stop() on already stopped sensor. assert_true: expected true got false
FAIL GeolocationSensor: Test that fresh reading is fetched on start() assert_true: expected true got false FAIL GeolocationSensor: Test that fresh reading is fetched on start(). assert_true: expected true got false
FAIL GeolocationSensor: frequency hint works assert_true: expected true got false FAIL GeolocationSensor: frequency hint works. assert_true: expected true got false
FAIL GeolocationSensor: sensor receives suspend / resume notifications when cross-origin subframe is focused assert_true: expected true got false FAIL GeolocationSensor: sensor receives suspend / resume notifications when cross-origin subframe is focused. assert_true: expected true got false
FAIL GeolocationSensor: throw 'TypeError' if frequency is invalid assert_true: expected true got false FAIL GeolocationSensor: throw 'TypeError' if frequency is invalid. assert_true: expected true got false
Harness: the test ran to completion. Harness: the test ran to completion.
...@@ -5,9 +5,25 @@ ...@@ -5,9 +5,25 @@
<link rel="help" href="https://wicg.github.io/geolocation-sensor/"> <link rel="help" href="https://wicg.github.io/geolocation-sensor/">
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<script src="/generic-sensor/resources/generic-sensor-helpers.js"></script>
<script src="/generic-sensor/generic-sensor-tests.js"></script> <script src="/generic-sensor/generic-sensor-tests.js"></script>
<script> <script>
runGenericSensorTests('GeolocationSensor'); 'use strict';
const kReadings = {
readings: [
[1.12345, 2.12345, 3.12345, 0.95, 0.96, 4.12345, 5.123]
],
expectedReadings: [
[1.12345, 2.12345, 3.12345, 0.95, 0.96, 4.12345, 5.123]
]
};
runGenericSensorTests(
'GeolocationSensor',
kReadings,
verifyXyzSensorReading,
['geolocation']);
</script> </script>
<!DOCTYPE html>
<meta charset="utf-8">
<title>GeolocationSensor Test: onerror</title>
<link rel="author" title="Intel" href="http://www.intel.com">
<link rel="help" href="https://wicg.github.io/geolocation-sensor/">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/generic-sensor/generic-sensor-tests.js"></script>
<h2>Precondition</h2>
<ol>
<li>
Disable the Geolocation sensor or run test on a device without Geolocation sensor.
</li>
</ol>
<script>
runGenericSensorOnerror('GeolocationSensor');
</script>
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<link rel="help" href="https://www.w3.org/TR/gyroscope/"> <link rel="help" href="https://www.w3.org/TR/gyroscope/">
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<script src="/generic-sensor/generic-sensor-tests.js"></script> <script src="/generic-sensor/resources/generic-sensor-helpers.js"></script>
<script src="/generic-sensor/generic-sensor-iframe-tests.sub.js"></script> <script src="/generic-sensor/generic-sensor-iframe-tests.sub.js"></script>
<script src="/generic-sensor/generic-sensor-feature-policy-test.sub.js"></script> <script src="/generic-sensor/generic-sensor-feature-policy-test.sub.js"></script>
<div id="log"></div> <div id="log"></div>
......
...@@ -6,10 +6,28 @@ ...@@ -6,10 +6,28 @@
<link rel="help" href="https://www.w3.org/TR/gyroscope/"> <link rel="help" href="https://www.w3.org/TR/gyroscope/">
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<script src="/generic-sensor/resources/generic-sensor-helpers.js"></script>
<script src="/generic-sensor/generic-sensor-tests.js"></script> <script src="/generic-sensor/generic-sensor-tests.js"></script>
<div id="log"></div>
<script> <script>
runGenericSensorTests('Gyroscope'); 'use strict';
const kReadings = {
readings: [
[1.12345, 2.12345, 3.12345]
],
expectedReadings: [
[1.12345, 2.12345, 3.12345]
],
expectedRemappedReadings: [
[-2.12345, 1.12345, 3.12345]
]
};
runGenericSensorTests(
'Gyroscope',
kReadings,
verifyXyzSensorReading,
['gyroscope']);
</script> </script>
<!DOCTYPE html>
<meta charset="utf-8">
<title>Gyroscope Test: onerror</title>
<link rel="author" title="Intel" href="http://www.intel.com">
<link rel="help" href="https://www.w3.org/TR/gyroscope/">
<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>
<h2>Precondition</h2>
<ol>
<li>
Disable the Gyroscope Sensor or run test on a device without Gyroscope Sensor.
</li>
</ol>
<script>
runGenericSensorOnerror('Gyroscope');
</script>
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<link rel="help" href="https://www.w3.org/TR/magnetometer/"> <link rel="help" href="https://www.w3.org/TR/magnetometer/">
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<script src="/generic-sensor/generic-sensor-tests.js"></script> <script src="/generic-sensor/resources/generic-sensor-helpers.js"></script>
<script src="/generic-sensor/generic-sensor-iframe-tests.sub.js"></script> <script src="/generic-sensor/generic-sensor-iframe-tests.sub.js"></script>
<script src="/generic-sensor/generic-sensor-feature-policy-test.sub.js"></script> <script src="/generic-sensor/generic-sensor-feature-policy-test.sub.js"></script>
<div id="log"></div> <div id="log"></div>
......
This is a testharness.js-based test. This is a testharness.js-based test.
PASS Magnetometer: Test that 'onreading' is called and sensor reading is valid PASS Magnetometer: Test that onerror is sent when sensor is not supported.
PASS Magnetometer: sensor reading is correct PASS Magnetometer: Test that onerror is sent when permissions are not granted.
PASS Magnetometer: sensor timestamp is updated when time passes PASS Magnetometer: Test that onerror is send when start() call has failed.
PASS Magnetometer: Test that frequency is capped to allowed maximum.
PASS Magnetometer: Test that frequency is capped to the maximum supported frequency.
PASS Magnetometer: Test that frequency is limited to the minimum supported frequency.
PASS Magnetometer: Test that sensor cannot be constructed within iframe disallowed to use feature policy.
PASS Magnetometer: Test that sensor can be constructed within an iframe allowed to use feature policy.
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: Test that sensor can be successfully created and its states are correct.
PASS Magnetometer: sensor.start() returns undefined PASS Magnetometer: sensor.start() returns undefined.
PASS Magnetometer: no exception is thrown when calling start() on already started sensor PASS Magnetometer: no exception is thrown when calling start() on already started sensor.
PASS Magnetometer: sensor.stop() returns undefined PASS Magnetometer: sensor.stop() returns undefined.
PASS Magnetometer: no exception is thrown when calling stop() on already stopped sensor 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: Test that fresh reading is fetched on start().
PASS Magnetometer: frequency hint works PASS Magnetometer: frequency hint works.
PASS Magnetometer: sensor receives suspend / resume notifications when cross-origin subframe is focused PASS Magnetometer: sensor receives suspend / resume notifications when cross-origin subframe is focused.
PASS Magnetometer: throw 'TypeError' if frequency is invalid PASS Magnetometer: throw 'TypeError' if frequency is invalid.
PASS Magnetometer: sensor reading is correct when options.referenceFrame is 'screen' PASS Magnetometer: sensor reading is correct when options.referenceFrame is 'screen'.
PASS Magnetometer: throw 'TypeError' if referenceFrame is not one of enumeration values 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: Test that onerror is sent when sensor is not supported. assert_true: expected true got false
FAIL UncalibratedMagnetometer: sensor reading is correct assert_true: expected true got false FAIL UncalibratedMagnetometer: Test that onerror is sent when permissions are not granted. 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 onerror is send when start() call has failed. assert_true: expected true got false
FAIL UncalibratedMagnetometer: Test that frequency is capped to allowed maximum. assert_true: expected true got false
FAIL UncalibratedMagnetometer: Test that frequency is capped to the maximum supported frequency. assert_true: expected true got false
FAIL UncalibratedMagnetometer: Test that frequency is limited to the minimum supported frequency. assert_true: expected true got false
FAIL UncalibratedMagnetometer: Test that sensor cannot be constructed within iframe disallowed to use feature policy. assert_true: expected true got false
FAIL UncalibratedMagnetometer: Test that sensor can be constructed within an iframe allowed to use feature policy. assert_true: expected true got false
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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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 FAIL UncalibratedMagnetometer: throw 'TypeError' if referenceFrame is not one of enumeration values. assert_true: expected true got false
Harness: the test ran to completion. Harness: the test ran to completion.
...@@ -6,11 +6,34 @@ ...@@ -6,11 +6,34 @@
<link rel="help" href="https://www.w3.org/TR/magnetometer/"> <link rel="help" href="https://www.w3.org/TR/magnetometer/">
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<script src="/generic-sensor/resources/generic-sensor-helpers.js"></script>
<script src="/generic-sensor/generic-sensor-tests.js"></script> <script src="/generic-sensor/generic-sensor-tests.js"></script>
<div id="log"></div>
<script> <script>
runGenericSensorTests('Magnetometer'); 'use strict';
runGenericSensorTests('UncalibratedMagnetometer');
const kReadings = {
readings: [
[-19.2, 12.1, -44.3]
],
expectedReadings: [
[-19.2, 12.1, -44.3]
],
expectedRemappedReadings: [
[-12.1, -19.2, -44.3]
]
};
runGenericSensorTests(
'Magnetometer',
kReadings,
verifyXyzSensorReading,
['magnetometer']);
runGenericSensorTests(
'UncalibratedMagnetometer',
kReadings,
verifyXyzSensorReading,
['magnetometer']);
</script> </script>
<!DOCTYPE html>
<meta charset="utf-8">
<title>Magnetometer Test: onerror</title>
<link rel="author" title="Intel" href="http://www.intel.com">
<link rel="help" href="https://www.w3.org/TR/magnetometer/">
<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>
<h2>Precondition</h2>
<ol>
<li>
Disable the Magnetometer Sensor or run test on a device without Magnetometer Sensor.
</li>
</ol>
<script>
runGenericSensorOnerror('Magnetometer');
runGenericSensorOnerror('UncalibratedMagnetometer');
</script>
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<link rel="help" href="https://www.w3.org/TR/orientation-sensor/"> <link rel="help" href="https://www.w3.org/TR/orientation-sensor/">
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<script src="/generic-sensor/generic-sensor-tests.js"></script> <script src="/generic-sensor/resources/generic-sensor-helpers.js"></script>
<script src="/generic-sensor/generic-sensor-iframe-tests.sub.js"></script> <script src="/generic-sensor/generic-sensor-iframe-tests.sub.js"></script>
<script src="/generic-sensor/generic-sensor-feature-policy-test.sub.js"></script> <script src="/generic-sensor/generic-sensor-feature-policy-test.sub.js"></script>
<div id="log"></div> <div id="log"></div>
......
...@@ -7,11 +7,17 @@ ...@@ -7,11 +7,17 @@
<link rel="help" href="https://w3c.github.io/sensors/"> <link rel="help" href="https://w3c.github.io/sensors/">
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<script src="/generic-sensor/resources/generic-sensor-helpers.js"></script>
<script src="/generic-sensor/generic-sensor-tests.js"></script> <script src="/generic-sensor/generic-sensor-tests.js"></script>
<script src="/orientation-sensor/orientation-sensor-tests.js"></script> <script src="/orientation-sensor/orientation-sensor-tests.js"></script>
<div id="log"></div>
<script> <script>
runGenericSensorTests(
'AbsoluteOrientationSensor',
kReadings,
verifyQuatSensorReading,
['accelerometer', 'gyroscope', 'magnetometer']);
runOrienationSensorTests('AbsoluteOrientationSensor'); runOrienationSensorTests('AbsoluteOrientationSensor');
runGenericSensorTests('AbsoluteOrientationSensor');
</script> </script>
<!DOCTYPE html>
<meta charset="utf-8">
<title>AbsoluteOrientationSensor Test: onerror</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>
<h2>Precondition</h2>
<ol>
<li>
Disable the motion sensors which the underlying physical sensors include Accelerometer, Magnetometer, and (when present) Gyroscope or run test on a device without the motion sensors.
</li>
</ol>
<script>
runGenericSensorOnerror('AbsoluteOrientationSensor');
runGenericSensorOnerror('RelativeOrientationSensor');
</script>
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<link rel="help" href="https://www.w3.org/TR/orientation-sensor/"> <link rel="help" href="https://www.w3.org/TR/orientation-sensor/">
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<script src="/generic-sensor/generic-sensor-tests.js"></script> <script src="/generic-sensor/resources/generic-sensor-helpers.js"></script>
<script src="/generic-sensor/generic-sensor-iframe-tests.sub.js"></script> <script src="/generic-sensor/generic-sensor-iframe-tests.sub.js"></script>
<script src="/generic-sensor/generic-sensor-feature-policy-test.sub.js"></script> <script src="/generic-sensor/generic-sensor-feature-policy-test.sub.js"></script>
<div id="log"></div> <div id="log"></div>
......
...@@ -7,11 +7,17 @@ ...@@ -7,11 +7,17 @@
<link rel="help" href="https://w3c.github.io/sensors/"> <link rel="help" href="https://w3c.github.io/sensors/">
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<script src="/generic-sensor/resources/generic-sensor-helpers.js"></script>
<script src="/generic-sensor/generic-sensor-tests.js"></script> <script src="/generic-sensor/generic-sensor-tests.js"></script>
<script src="/orientation-sensor/orientation-sensor-tests.js"></script> <script src="/orientation-sensor/orientation-sensor-tests.js"></script>
<div id="log"></div>
<script> <script>
runGenericSensorTests(
'RelativeOrientationSensor',
kReadings,
verifyQuatSensorReading,
['accelerometer', 'gyroscope']);
runOrienationSensorTests('RelativeOrientationSensor'); runOrienationSensorTests('RelativeOrientationSensor');
runGenericSensorTests('RelativeOrientationSensor');
</script> </script>
//IEEE 754: single precision retricts to 7 decimal digits 'use strict';
const float_precision = 1e-7;
const kDefaultReading = [
function create_matrix(quat) { [ 1, 0, 0, 0 ] // 180 degrees around X axis.
const X = quat[0]; ];
const Y = quat[1]; const kRotationMatrix = [1, 0, 0, 0,
const Z = quat[2]; 0, -1, 0, 0,
const W = quat[3]; 0, 0, -1, 0,
const mat = new Array( 0, 0, 0, 1];
1-2*Y*Y-2*Z*Z, 2*X*Y-2*Z*W, 2*X*Z+2*Y*W, 0, const kReadings = {
2*X*Y+2*Z*W, 1-2*X*X-2*Z*Z, 2*Y*Z-2*X*W, 0, readings: kDefaultReading,
2*X*Z-2*Y*W, 2*Y*Z+2*W*X, 1-2*X*X-2*Y*Y, 0, expectedReadings: kDefaultReading,
0, 0, 0, 1 expectedRemappedReadings: [
); // For 'orientation.angle == 270', which is set for tests at
return mat; // at SensorProxy::GetScreenOrientationAngle().
} [-0.707107, 0.707107, 0, 0]
]
};
async function checkQuaternion(t, sensorType) { async function checkQuaternion(t, sensorType) {
const sensor = new sensorType(); const sensor = new sensorType();
...@@ -26,41 +28,46 @@ async function checkQuaternion(t, sensorType) { ...@@ -26,41 +28,46 @@ async function checkQuaternion(t, sensorType) {
sensor.stop(); sensor.stop();
}; };
async function checkPopulateMatrix(t, sensorType) { async function checkPopulateMatrix(t, sensorProvider, sensorType) {
const sensor = new sensorType(); const sensor = new sensorType();
const eventWatcher = new EventWatcher(t, sensor, ["reading", "error"]); const eventWatcher = new EventWatcher(t, sensor, ["reading", "error"]);
//Throws with insufficient buffer space. // Throws with insufficient buffer space.
assert_throws({ name: 'TypeError' }, () => sensor.populateMatrix(new Float32Array(15))); assert_throws({ name: 'TypeError' },
() => sensor.populateMatrix(new Float32Array(15)));
//Throws if no orientation data available. // Throws if no orientation data available.
assert_throws({ name: 'NotReadableError' }, () => sensor.populateMatrix(new Float32Array(16))); assert_throws({ name: 'NotReadableError' },
() => sensor.populateMatrix(new Float32Array(16)));
// Throws if passed SharedArrayBuffer view. // Throws if passed SharedArrayBuffer view.
assert_throws({ name: 'TypeError' }, () => sensor.populateMatrix(new Float32Array(new SharedArrayBuffer(16)))); assert_throws({ name: 'TypeError' },
() => sensor.populateMatrix(new Float32Array(new SharedArrayBuffer(16))));
sensor.start(); sensor.start();
const mockSensor = await sensorProvider.getCreatedSensor(sensorType.name);
await mockSensor.setSensorReading(kDefaultReading);
await eventWatcher.wait_for("reading"); await eventWatcher.wait_for("reading");
const quat = sensor.quaternion;
const mat_expect = create_matrix(quat);
// Works for all supported types. // Works for all supported types.
const mat_32 = new Float32Array(16); const rotationMatrix32 = new Float32Array(16);
sensor.populateMatrix(mat_32); sensor.populateMatrix(rotationMatrix32);
assert_array_approx_equals(mat_32, mat_expect, float_precision); assert_array_equals(rotationMatrix32, kRotationMatrix);
const mat_64 = new Float64Array(16); let rotationMatrix64 = new Float64Array(16);
sensor.populateMatrix(mat_64); sensor.populateMatrix(rotationMatrix64);
assert_array_equals(mat_64, mat_expect); assert_array_equals(rotationMatrix64, kRotationMatrix);
const mat_dom = new DOMMatrix(); let rotationDOMMatrix = new DOMMatrix();
sensor.populateMatrix(mat_dom); sensor.populateMatrix(rotationDOMMatrix);
assert_array_equals(mat_dom.toFloat64Array(), mat_expect); assert_array_equals(rotationDOMMatrix.toFloat64Array(), kRotationMatrix);
// Sets every matrix element. // Sets every matrix element.
mat_64.fill(123); rotationMatrix64.fill(123);
sensor.populateMatrix(mat_64); sensor.populateMatrix(rotationMatrix64);
assert_array_equals(mat_64, mat_expect); assert_array_equals(rotationMatrix64, kRotationMatrix);
sensor.stop(); sensor.stop();
} }
...@@ -73,9 +80,8 @@ function runOrienationSensorTests(sensorName) { ...@@ -73,9 +80,8 @@ function runOrienationSensorTests(sensorName) {
return checkQuaternion(t, sensorType); return checkQuaternion(t, sensorType);
}, `${sensorName}.quaternion return a four-element FrozenArray.`); }, `${sensorName}.quaternion return a four-element FrozenArray.`);
sensor_test(async t => { sensor_test(async (t, sensorProvider) => {
assert_true(sensorName in self); assert_true(sensorName in self);
return checkPopulateMatrix(t, sensorType); return checkPopulateMatrix(t, sensorProvider, sensorType);
}, `${sensorName}.populateMatrix() method works correctly.`); }, `${sensorName}.populateMatrix() method works correctly.`);
} }
# TEAM: device-dev@chromium.org
# COMPONENT: Blink>Sensor
<!DOCTYPE html>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script src="../http/tests/resources/sensor-helpers.js"></script>
<script src="file:///gen/layout_test_data/mojo/public/js/mojo_bindings.js"></script>
<script src="file:///gen/services/device/public/mojom/sensor_provider.mojom.js"></script>
<script src="resources/generic-sensor-utils.js"></script>
<script src="resources/generic-sensor-tests.js"></script>
<script>
'use strict';
if (!window.testRunner)
debug('This test cannot be run without the TestRunner');
const kReadings = {
readings: [
[1.12345, 2.12345, 3.12345]
],
expectedReadings: [
[1.12345, 2.12345, 3.12345]
],
expectedRemappedReadings: [
[-2.12345, 1.12345, 3.12345]
]
}
runGenericSensorTests(
Accelerometer,
kReadings,
verifyXyzSensorReading,
['accelerometer']);
runGenericSensorTests(
LinearAccelerationSensor,
kReadings,
verifyXyzSensorReading,
['accelerometer']);
</script>
<!DOCTYPE html>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script src="../http/tests/resources/sensor-helpers.js"></script>
<script src="file:///gen/layout_test_data/mojo/public/js/mojo_bindings.js"></script>
<script src="file:///gen/services/device/public/mojom/sensor_provider.mojom.js"></script>
<script src="resources/generic-sensor-utils.js"></script>
<script src="resources/generic-sensor-tests.js"></script>
<script>
'use strict';
if (!window.testRunner)
debug('This test cannot be run without the TestRunner');
const kReadings = {
readings: [
[3.1415]
],
expectedReadings: [
[3.1415]
]
};
runGenericSensorTests(
AmbientLightSensor,
kReadings,
verifyAlsSensorReading,
['ambient-light-sensor']);
</script>
<!DOCTYPE html>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script src="../http/tests/resources/sensor-helpers.js"></script>
<script src="file:///gen/layout_test_data/mojo/public/js/mojo_bindings.js"></script>
<script src="file:///gen/services/device/public/mojom/sensor_provider.mojom.js"></script>
<script src="resources/generic-sensor-utils.js"></script>
<script src="resources/generic-sensor-tests.js"></script>
<script>
'use strict';
if (!window.testRunner)
debug('This test cannot be run without the TestRunner');
const kReadings = {
readings: [
[1.12345, 2.12345, 3.12345]
],
expectedReadings: [
[1.12345, 2.12345, 3.12345]
],
expectedRemappedReadings: [
[-2.12345, 1.12345, 3.12345]
]
}
runGenericSensorTests(
Gyroscope,
kReadings,
verifyXyzSensorReading,
['gyroscope']);
</script>
<!DOCTYPE html>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script src="../http/tests/resources/sensor-helpers.js"></script>
<script src="file:///gen/layout_test_data/mojo/public/js/mojo_bindings.js"></script>
<script src="file:///gen/services/device/public/mojom/sensor_provider.mojom.js"></script>
<script src="resources/generic-sensor-utils.js"></script>
<script src="resources/generic-sensor-tests.js"></script>
<script>
'use strict';
if (!window.testRunner)
debug('This test cannot be run without the TestRunner');
const kReadings = {
readings: [
[-19.2, 12.1, -44.3]
],
expectedReadings: [
[-19.2, 12.1, -44.3]
],
expectedRemappedReadings: [
[-12.1, -19.2, -44.3]
]
}
runGenericSensorTests(
Magnetometer,
kReadings,
verifyXyzSensorReading,
['magnetometer']);
</script>
<!DOCTYPE html>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script src="../http/tests/resources/sensor-helpers.js"></script>
<script src="file:///gen/layout_test_data/mojo/public/js/mojo_bindings.js"></script>
<script src="file:///gen/services/device/public/mojom/sensor_provider.mojom.js"></script>
<script>
'use strict';
sensor_test(sensorProvider => {
assert_true(sensorProvider instanceof Object);
}, 'Sensor Mojo bindings and mock interfaces are available to tests.')
</script>
<!DOCTYPE html>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script src="../http/tests/resources/sensor-helpers.js"></script>
<script src="file:///gen/layout_test_data/mojo/public/js/mojo_bindings.js"></script>
<script src="file:///gen/services/device/public/mojom/sensor_provider.mojom.js"></script>
<script src="resources/generic-sensor-utils.js"></script>
<script src="resources/generic-sensor-tests.js"></script>
<script>
'use strict';
if (!window.testRunner)
debug('This test cannot be run without the TestRunner');
const kDefaultReading = [
[ 1, 0, 0, 0 ] // 180 degrees around X axis.
];
const kRotationMatrix = [1, 0, 0, 0,
0, -1, 0, 0,
0, 0, -1, 0,
0, 0, 0, 1];
async function checkPopulateMatrix(sensorProvider, sensorType) {
let sensorObject = new sensorType();
// Throws with insufficient buffer space.
assert_throws({ name: 'TypeError' }, () => sensorObject.populateMatrix(new Float32Array(15)));
// Throws if no orientation data available.
assert_throws({ name: 'NotReadableError' }, () => sensorObject.populateMatrix(new Float32Array(16)));
if (window.SharedArrayBuffer) {
// Throws if passed SharedArrayBuffer view.
assert_throws({ name: 'TypeError' }, () => sensorObject.populateMatrix(new Float32Array(new SharedArrayBuffer(16))));
}
sensorObject.start();
let mockSensor = await sensorProvider.getCreatedSensor(sensorType.name);
await mockSensor.setSensorReading(kDefaultReading);
await new Promise((resolve, reject) => {
sensorObject.onreading = () => {
try {
// Works for all supported types.
let rotationMatrix32 = new Float32Array(16);
sensorObject.populateMatrix(rotationMatrix32);
assert_array_equals(rotationMatrix32, kRotationMatrix);
let rotationMatrix64 = new Float64Array(16);
sensorObject.populateMatrix(rotationMatrix64);
assert_array_equals(rotationMatrix64, kRotationMatrix);
let rotationDOMMatrix = new DOMMatrix();
sensorObject.populateMatrix(rotationDOMMatrix);
assert_array_equals(rotationDOMMatrix.toFloat64Array(),
kRotationMatrix);
// Sets every matrix element.
rotationMatrix64.fill(123);
sensorObject.populateMatrix(rotationMatrix64);
assert_array_equals(rotationMatrix64, kRotationMatrix);
sensorObject.stop();
resolve(mockSensor);
} catch (e) {
reject(e);
};
}
sensorObject.onerror = reject;
});
return mockSensor.removeConfigurationCalled();
}
const kReadings = {
readings: kDefaultReading,
expectedReadings: kDefaultReading,
expectedRemappedReadings: [
// For 'orientation.angle == 270', which is set for tests at
// at SensorProxy::GetScreenOrientationAngle().
[-0.707107, 0.707107, 0, 0]
]
}
runGenericSensorTests(
AbsoluteOrientationSensor,
kReadings,
verifyQuatSensorReading,
['accelerometer', 'gyroscope', 'magnetometer']);
sensor_test((t, sensorProvider) => {
return checkPopulateMatrix(
sensorProvider,
AbsoluteOrientationSensor);
}, 'Test AbsoluteOrientationSensor.populateMatrix() method works correctly.');
runGenericSensorTests(
RelativeOrientationSensor,
kReadings,
verifyQuatSensorReading,
['accelerometer', 'gyroscope']);
sensor_test((t, sensorProvider) => {
return checkPopulateMatrix(
sensorProvider,
RelativeOrientationSensor);
}, 'Test RelativeOrientationSensor.populateMatrix() method works correctly.');
</script>
'use strict';
function verifySensorReading(pattern, values, timestamp, isNull) {
function round(val) {
return Number.parseFloat(val).toPrecision(6);
}
if (isNull) {
return (values === null || values.every(r => r === null)) &&
timestamp === null;
}
return values.every((r, i) => round(r) === round(pattern[i])) &&
timestamp !== null;
}
function verifyXyzSensorReading(pattern, {x, y, z, timestamp}, isNull) {
return verifySensorReading(pattern, [x, y, z], timestamp, isNull);
}
function verifyQuatSensorReading(pattern, {quaternion, timestamp}, isNull) {
return verifySensorReading(pattern, quaternion, timestamp, isNull);
}
function verifyAlsSensorReading(pattern, {illuminance, timestamp}, isNull) {
return verifySensorReading(pattern, [illuminance], timestamp, isNull);
}
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