Bug 1444324 [wpt PR 9942] - Add sensor screen tests, a=testonly
authorkaixinjxq <xiuqix.jiang@intel.com>
Mon, 09 Apr 2018 14:37:25 +0000
changeset 413406 8a5e9750add01f7b256203c59b398004ee59fb6f
parent 413405 4c7588bbe70bd29f11b0ce8f78a9c89b1709df4b
child 413407 69d95f3b3edbfe347b1c3a55bc7ff12931c6cef7
push id102161
push userjames@hoppipolla.co.uk
push dateSun, 15 Apr 2018 09:10:16 +0000
treeherdermozilla-inbound@ebfad4be630d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1444324
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1444324 [wpt PR 9942] - Add sensor screen tests, a=testonly Automatic update from web-platform-testsAdd sensor screen tests (#9942) * Add sensor screen tests * Add the detailed TODO thing in the annotation wpt-commits: 6e88051b24154ae47b5074ce3a195d5560463d4c wpt-pr: 9942 wpt-commits: 6e88051b24154ae47b5074ce3a195d5560463d4c wpt-pr: 9942
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/sensors/generic-sensor-tests.js
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -590635,17 +590635,17 @@
    "99bcfb42c91e084a3b847ab4bab2bad80e548540",
    "testharness"
   ],
   "sensors/generic-sensor-feature-policy-test.sub.js": [
    "c7c9c4d1c578f267cbb4241d7ea7a981be6f49ee",
    "support"
   ],
   "sensors/generic-sensor-tests.js": [
-   "0f1cea2c0d3f38220cbfdbe4f47d713214987cbd",
+   "383a4f839c4a74b5b4d2a6cff9c83a61bc5aee04",
    "support"
   ],
   "sensors/idlharness.https.html": [
    "02c734b907075c8abb7504fc7e2b93730ac80a0c",
    "testharness"
   ],
   "server-timing/cross_origin.html": [
    "74333db517babacbb84bb20c91ccfc8b2627b934",
--- a/testing/web-platform/tests/sensors/generic-sensor-tests.js
+++ b/testing/web-platform/tests/sensors/generic-sensor-tests.js
@@ -8,16 +8,24 @@ const properties = {
   "UncalibratedMagnetometer" : ['timestamp', 'x', 'y', 'z',
                                 'xBias', 'yBias', 'zBias'],
   'AbsoluteOrientationSensor' : ['timestamp', 'quaternion'],
   'RelativeOrientationSensor' : ['timestamp', 'quaternion'],
   'GeolocationSensor' : ['timestamp', 'latitude', 'longitude', 'altitude',
                          'accuracy', 'altitudeAccuracy', 'heading', 'speed'],
   'ProximitySensor' : ['timestamp', 'max']
 };
+const spatialSensors = ['Accelerometer',
+                       'LinearAccelerationSensor',
+                       'GravitySensor',
+                       'Gyroscope',
+                       'Magnetometer',
+                       'UncalibratedMagnetometer',
+                       'AbsoluteOrientationSensor',
+                       'RelativeOrientationSensor'];
 
 function assert_reading_not_null(sensor) {
   for (let property in properties[sensor.constructor.name]) {
     let propertyName = properties[sensor.constructor.name][property];
     assert_not_equals(sensor[propertyName], null);
   }
 }
 
@@ -237,16 +245,34 @@ function runGenericSensorTests(sensorTyp
     iframe.remove();
     await sensorWatcher.wait_for("reading");
     const cachedSensor3 = reading_to_array(sensor);
     assert_greater_than(sensor.timestamp, cachedTimestamp);
 
     sensor.stop();
   }, `${sensorType.name}: sensor receives suspend / resume notifications when\
   cross-origin subframe is focused`);
+
+  if (spatialSensors.indexOf(sensorType.name) == -1) {
+    // The sensorType does not represent a spatial sensor.
+    return;
+  }
+
+  promise_test(async t => {
+    const sensor = new sensorType({referenceFrame: "screen"});
+    const sensorWatcher = new EventWatcher(t, sensor, ["reading", "error"]);
+    sensor.start();
+
+    await sensorWatcher.wait_for("reading");
+    //TODO use mock data to verify sensor readings, blocked by issue:
+    // https://github.com/w3c/web-platform-tests/issues/9686
+    assert_reading_not_null(sensor);
+
+    sensor.stop();
+  }, `${sensorType.name}: sensor reading is correct when options.referenceFrame is 'screen'`);
 }
 
 function runGenericSensorInsecureContext(sensorType) {
   test(() => {
     assert_false(sensorType in window, `${sensorType} must not be exposed`);
   }, `${sensorType} is not exposed in an insecure context`);
 }