Bug 1445848 [wpt PR 10024] - Add sensor referenceFrame/frequency TypeError tests, a=testonly
authorkaixinjxq <xiuqix.jiang@intel.com>
Mon, 09 Apr 2018 17:00:47 +0000
changeset 467071 e69bf5bd4142d37c8bb500f3ab3f0c45c68075c8
parent 467070 98bbd3c05ff01b50f3048314c286020d4f2b8d8a
child 467072 9ddf4a86b3c16dda8388162d48da6c1cfd68a489
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1445848, 10024
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 1445848 [wpt PR 10024] - Add sensor referenceFrame/frequency TypeError tests, a=testonly Automatic update from web-platform-testsAdd sensor referenceFrame/frequency TypeError tests (#10024) * Add sensor referenceFrame/frequency TypeError tests wpt-commits: 7c4bc542cf4c8710661f6a4818480db8dece715e wpt-pr: 10024 wpt-commits: 7c4bc542cf4c8710661f6a4818480db8dece715e wpt-pr: 10024
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
@@ -591358,17 +591358,17 @@
    "99bcfb42c91e084a3b847ab4bab2bad80e548540",
    "testharness"
   ],
   "sensors/generic-sensor-feature-policy-test.sub.js": [
    "c7c9c4d1c578f267cbb4241d7ea7a981be6f49ee",
    "support"
   ],
   "sensors/generic-sensor-tests.js": [
-   "983fcde578270e32e6ba3ab4b6420b53ae3bbbc2",
+   "6364f1838215eaafd91b86690039da41d4c19cd1",
    "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
@@ -254,16 +254,32 @@ function runGenericSensorTests(sensorTyp
   test(() => {
      assert_throws("NotSupportedError", () => { new sensorType({invalid: 1}) });
      assert_throws("NotSupportedError", () => { new sensorType({frequency: 60, invalid: 1}) });
      if (spatialSensors.indexOf(sensorType.name) == -1) {
        assert_throws("NotSupportedError", () => { new sensorType({referenceFrame: "screen"}) });
      }
   }, `${sensorType.name}: throw 'NotSupportedError' for an unsupported sensor option`);
 
+  test(() => {
+    const invalidFreqs = [
+      "invalid",
+      NaN,
+      Infinity,
+      -Infinity,
+      {},
+      undefined
+    ];
+    invalidFreqs.map(freq => {
+      assert_throws(new TypeError(),
+                    () => { new sensorType({frequency: freq}) },
+                    `when freq is ${freq}`);
+    });
+  }, `${sensorType.name}: throw 'TypeError' if frequency is invalid`);
+
   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"]);
@@ -271,16 +287,33 @@ function runGenericSensorTests(sensorTyp
 
     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'`);
+
+  test(() => {
+    const invalidRefFrames = [
+      "invalid",
+      null,
+      123,
+      {},
+      "",
+      true,
+      undefined
+    ];
+    invalidRefFrames.map(refFrame => {
+      assert_throws(new TypeError(),
+                    () => { new sensorType({referenceFrame: refFrame}) },
+                    `when refFrame is ${refFrame}`);
+    });
+  }, `${sensorType.name}: throw 'TypeError' if referenceFrame is not one of enumeration values`);
 }
 
 function runGenericSensorInsecureContext(sensorType) {
   test(() => {
     assert_false(sensorType in window, `${sensorType} must not be exposed`);
   }, `${sensorType} is not exposed in an insecure context`);
 }