Bug 1576633 [wpt PR 18677] - Convert some tests to use `idl_test`, a=testonly
authorPhilip Jägenstedt <philip@foolip.org>
Wed, 28 Aug 2019 09:53:24 +0000
changeset 551254 08e4c310b6c3f7bb1d5c6832beb63bf43fe1a6f8
parent 551253 86386465c9b4a385a7501354b6bef263aa038589
child 551255 5d48cc514157cbde1615c6e641f8d1852e4e1845
push id11865
push userbtara@mozilla.com
push dateMon, 02 Sep 2019 08:54:37 +0000
treeherdermozilla-beta@37f59c4671b3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1576633, 18677
milestone70.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 1576633 [wpt PR 18677] - Convert some tests to use `idl_test`, a=testonly Automatic update from web-platform-tests Convert some tests to use `idl_test` (#18677) -- wpt-commits: a593c50f4371977e6df58ccbffedbdca8b3910f4 wpt-pr: 18677
testing/web-platform/tests/audio-output/idlharness.https.window.js
testing/web-platform/tests/beacon/idlharness.any.js
testing/web-platform/tests/encrypted-media/idlharness.https.html
testing/web-platform/tests/geolocation-API/idlharness.window.js
testing/web-platform/tests/mediacapture-depth/idlharness.html
testing/web-platform/tests/mediacapture-streams/idlharness.https.window.js
testing/web-platform/tests/orientation-event/idlharness.https.window.js
testing/web-platform/tests/permissions/interfaces.any.js
testing/web-platform/tests/requestidlecallback/idlharness.window.js
testing/web-platform/tests/server-timing/idlharness.https.any.js
--- a/testing/web-platform/tests/audio-output/idlharness.https.window.js
+++ b/testing/web-platform/tests/audio-output/idlharness.https.window.js
@@ -1,24 +1,19 @@
 // META: script=/resources/WebIDLParser.js
 // META: script=/resources/idlharness.js
 
 // https://w3c.github.io/mediacapture-output/
 
 'use strict';
 
-promise_test(async () => {
-  const srcs = ['audio-output', 'dom', 'html'];
-  const [idl, dom, html] = await Promise.all(
-    srcs.map(i => fetch(`/interfaces/${i}.idl`).then(r => r.text())));
-
-  const idl_array = new IdlArray();
-  idl_array.add_idls(idl);
-  idl_array.add_dependency_idls(html);
-  idl_array.add_dependency_idls(dom);
-  self.audio = document.createElement('audio');
-  self.video = document.createElement('video');
-  idl_array.add_objects({
-    HTMLAudioElement: ['audio'],
-    HTMLVideoElement: ['video']
-  });
-  idl_array.test();
-}, 'Test IDL implementation of audio-output API');
+idl_test(
+  ['audio-output'],
+  ['html', 'dom'],
+  idl_array => {
+    self.audio = document.createElement('audio');
+    self.video = document.createElement('video');
+    idl_array.add_objects({
+      HTMLAudioElement: ['audio'],
+      HTMLVideoElement: ['video']
+    });
+  }
+);
--- a/testing/web-platform/tests/beacon/idlharness.any.js
+++ b/testing/web-platform/tests/beacon/idlharness.any.js
@@ -1,17 +1,14 @@
 // META: script=/resources/WebIDLParser.js
 // META: script=/resources/idlharness.js
 
 // https://w3c.github.io/beacon/
 
-promise_test(async () => {
-  const idl = await fetch('/interfaces/beacon.idl').then(r => r.text());
-  const html = await fetch('/interfaces/html.idl').then(r => r.text());
-
-  const idl_array = new IdlArray();
-  idl_array.add_idls(idl);
-  idl_array.add_dependency_idls(html);
-  idl_array.add_objects({
-    Navigator: ['navigator'],
-  });
-  idl_array.test();
-}, 'beacon interfaces');
+idl_test(
+  ['beacon'],
+  ['html'],
+  idl_array => {
+    idl_array.add_objects({
+      Navigator: ['navigator'],
+    });
+  }
+);
--- a/testing/web-platform/tests/encrypted-media/idlharness.https.html
+++ b/testing/web-platform/tests/encrypted-media/idlharness.https.html
@@ -17,21 +17,24 @@
       This test verifies that implementations of the Encrypted Media Extensions API match its WebIDL definition.
     </p>
 
     <div id='log'></div>
 
     <script>
       'use strict';
 
-      promise_test(async () => {
-        const idls = await fetch('/interfaces/encrypted-media.idl').then(r => r.text());
-        const html = await fetch('/interfaces/html.idl').then(r => r.text());
-        const dom = await fetch('/interfaces/dom.idl').then(r => r.text());
-        var idl_array = new IdlArray();
-        idl_array.add_idls(idls);
-        idl_array.add_dependency_idls(html);
-        idl_array.add_dependency_idls(dom);
-        idl_array.test();
-      }, 'Test encrypted-media IDL');
+      idl_test(
+        ['encrypted-media'],
+        ['html', 'dom'],
+        idl_array => {
+          self.audio = document.createElement('audio');
+          self.video = document.createElement('video');
+          idl_array.add_objects({
+            HTMLAudioElement: ['audio'],
+            HTMLVideoElement: ['video'],
+            Navigator: ['navigator'],
+          });
+        }
+      );
     </script>
   </body>
 </html>
--- a/testing/web-platform/tests/geolocation-API/idlharness.window.js
+++ b/testing/web-platform/tests/geolocation-API/idlharness.window.js
@@ -1,18 +1,17 @@
 // META: script=/resources/WebIDLParser.js
 // META: script=/resources/idlharness.js
 
 // https://www.w3.org/TR/geolocation-API/
 
-promise_test(async () => {
-  const idl = await fetch('/interfaces/geolocation-API.idl').then(r => r.text());
-  const html = await fetch('/interfaces/html.idl').then(r => r.text());
-
-  const idl_array = new IdlArray();
-  idl_array.add_idls(idl);
-  idl_array.add_dependency_idls(html);
-  idl_array.add_objects({
-    Navigator: ["navigator"],
-    Geolocation: ["navigator.geolocation"]
-  });
-  idl_array.test();
-}, 'geolocation-API interfaces');
+idl_test(
+  ['geolocation-API'],
+  ['html'],
+  idl_array => {
+    self.audio = document.createElement('audio');
+    self.video = document.createElement('video');
+    idl_array.add_objects({
+      Navigator: ['navigator'],
+      Geolocation: ['navigator.geolocation'],
+    });
+  }
+);
--- a/testing/web-platform/tests/mediacapture-depth/idlharness.html
+++ b/testing/web-platform/tests/mediacapture-depth/idlharness.html
@@ -1,31 +1,29 @@
 <!DOCTYPE html>
 <html>
 
 <head>
   <meta charset=utf-8>
   <title>Media Capture Depth Stream Extensions IDL test</title>
-  <link rel="help" href="See https://w3c.github.io/mediacapture-depth/">
+  <link rel="help" href="https://w3c.github.io/mediacapture-depth/">
   <script src="/resources/testharness.js"></script>
   <script src="/resources/testharnessreport.js"></script>
   <script src="/resources/WebIDLParser.js"></script>
   <script src="/resources/idlharness.js"></script>
 </head>
 
 <body>
   <script>
     'use strict';
 
-    promise_test(async () => {
-      const idl = await fetch('/interfaces/mediacapture-depth.idl').then(r => r.text());
-      const main = await fetch('/interfaces/mediacapture-streams.idl').then(r => r.text());
-
-      var idl_array = new IdlArray();
-      idl_array.add_idls(idl);
-      idl_array.add_dependency_idls(main);
-      idl_array.test();
-    }, 'mediacapture-depth interfaces');
+    idl_test(
+      ['mediacapture-depth'],
+      ['mediacapture-streams'],
+      idl_array => {
+        // No objects, spec defines dictionaries only.
+      }
+    );
   </script>
   <div id="log"></div>
 </body>
 
 </html>
--- a/testing/web-platform/tests/mediacapture-streams/idlharness.https.window.js
+++ b/testing/web-platform/tests/mediacapture-streams/idlharness.https.window.js
@@ -1,54 +1,48 @@
 // META: script=/resources/WebIDLParser.js
 // META: script=/resources/idlharness.js
 
 'use strict';
 
 // https://w3c.github.io/mediacapture-main/
 
-
-promise_test(async () => {
-  const srcs = ['mediacapture-streams','dom','html'];
-  const [idl, dom, html] = await Promise.all(
-    srcs.map(i => fetch(`/interfaces/${i}.idl`).then(r => r.text())));
-
-  const idl_array = new IdlArray();
-  idl_array.add_idls(idl);
-  idl_array.add_dependency_idls(html);
-  idl_array.add_dependency_idls(dom);
+idl_test(
+  ['mediacapture-streams'],
+  ['dom', 'html'],
+  async idl_array => {
+    const inputDevices = [];
+    const outputDevices = [];
+    try {
+      const list = await navigator.mediaDevices.enumerateDevices();
+      for (const device of list) {
+        if (device.kind in self) {
+          continue;
+        }
+        assert_in_array(device.kind, ['audioinput', 'videoinput', 'audiooutput']);
+        self[device.kind] = device;
+        if (device.kind.endsWith('input')) {
+          inputDevices.push(device.kind);
+        } else {
+          outputDevices.push(device.kind);
+        }
+      }
+    } catch (e) {}
 
-  const devices = [];
-  // Errors will be surfaced in idlharness.js's test_object below.
-  try {
-    const list = await navigator.mediaDevices.enumerateDevices();
-    for (const item of list) {
-      switch (item.kind) {
-      case 'audioinput':
-      case 'videoinput':
-      case 'audiooutput':
-        self[item.kind] = item;
-        devices.push(item.kind);
-      default:
-        assert_unreached(
-          'media.kind should be one of "audioinput", "videoinput", or "audiooutput".');
-      }
-    }
-  } catch (e) {}
+    try {
+      self.stream = await navigator.mediaDevices.getUserMedia({audio: true});
+      self.track = stream.getTracks()[0];
+      self.trackEvent = new MediaStreamTrackEvent("type", {
+        track: track,
+      });
+    } catch (e) {}
 
-  try {
-    self.stream = await navigator.mediaDevices.getUserMedia({audio: true});
-    self.track = stream.getTracks()[0];
-    self.trackEvent = new MediaStreamTrackEvent("type", {
-      track: track,
+    idl_array.add_objects({
+      InputDeviceInfo: inputDevices,
+      MediaStream: ['stream', 'new MediaStream()'],
+      Navigator: ['navigator'],
+      MediaDevices: ['navigator.mediaDevices'],
+      MediaDeviceInfo: outputDevices,
+      MediaStreamTrack: ['track'],
+      MediaStreamTrackEvent: ['trackEvent'],
     });
-  } catch (e) { throw e}
-
-  idl_array.add_objects({
-    InputDeviceInfo: devices,
-    MediaStream: ['stream', 'new MediaStream()'],
-    Navigator: ['navigator'],
-    MediaDevices: ['navigator.mediaDevices'],
-    MediaStreamTrack: ['track'],
-    MediaStreamTrackEvent: ['trackEvent'],
-  });
-  idl_array.test();
-}, 'mediacapture-streams interfaces.');
+  }
+);
--- a/testing/web-platform/tests/orientation-event/idlharness.https.window.js
+++ b/testing/web-platform/tests/orientation-event/idlharness.https.window.js
@@ -1,23 +1,18 @@
 // META: script=/resources/WebIDLParser.js
 // META: script=/resources/idlharness.js
 
 // https://w3c.github.io/deviceorientation/spec-source-orientation.html
 
 'use strict';
 
-promise_test(async () => {
-  const idl = await fetch('/interfaces/orientation-event.idl').then(r => r.text());
-  const dom = await fetch('/interfaces/dom.idl').then(r => r.text());
-  const html = await fetch('/interfaces/html.idl').then(r => r.text());
-
-  var idl_array = new IdlArray();
-  idl_array.add_idls(idl);
-  idl_array.add_dependency_idls(html);
-  idl_array.add_dependency_idls(dom);
-  idl_array.add_objects({
-    Window: ['window'],
-    DeviceOrientationEvent: ['new DeviceOrientationEvent("foo")'],
-    DeviceMotionEvent: ['new DeviceMotionEvent("foo")'],
-  });
-  idl_array.test();
-}, 'orientation-event interfaces');
+idl_test(
+  ['orientation-event'],
+  ['html', 'dom'],
+  idl_array => {
+    idl_array.add_objects({
+      Window: ['window'],
+      DeviceOrientationEvent: ['new DeviceOrientationEvent("foo")'],
+      DeviceMotionEvent: ['new DeviceMotionEvent("foo")'],
+    });
+  }
+);
--- a/testing/web-platform/tests/permissions/interfaces.any.js
+++ b/testing/web-platform/tests/permissions/interfaces.any.js
@@ -1,41 +1,27 @@
 // META: script=/resources/WebIDLParser.js
 // META: script=/resources/idlharness.js
 
-"use strict";
-
-if (self.importScripts) {
-  importScripts("/resources/testharness.js");
-  importScripts("/resources/WebIDLParser.js", "/resources/idlharness.js");
-}
-
 // https://w3c.github.io/permissions/#idl-index
 
-promise_test(async () => {
-  const idl = await fetch("/interfaces/permissions.idl").then(r => r.text());
-  const dom = await fetch("/interfaces/dom.idl").then(r => r.text());
-  const html = await fetch("/interfaces/html.idl").then(r => r.text());
+"use strict";
 
-  const idl_array = new IdlArray();
-  idl_array.add_idls(idl);
-  idl_array.add_dependency_idls(dom);
-  idl_array.add_dependency_idls(html);
+idl_test(
+  ['permissions'],
+  ['html', 'dom'],
+  async idl_array => {
+    try {
+      self.permissionStatus = await navigator.permissions.query({ name: "geolocation" });
+    } catch (e) {}
 
-  try {
-    self.permissionStatus = await navigator.permissions.query({ name: "geolocation" });
-    self.permissionStatus = await navigator.permissions.query({ name: "background-fetch" });
-  } catch (e) {
-    // Will be surfaced in idlharness.js's test_object below.
-  }
+    if (self.GLOBAL.isWorker()) {
+      idl_array.add_objects({ WorkerNavigator: ['navigator'] });
+    } else {
+      idl_array.add_objects({ Navigator: ['navigator'] });
+    }
 
-  if (self.GLOBAL.isWorker()) {
-    idl_array.add_objects({ WorkerNavigator: ['navigator'] });
-  } else {
-    idl_array.add_objects({ Navigator: ['navigator'] });
+    idl_array.add_objects({
+      Permissions: ['navigator.permissions'],
+      PermissionStatus: ['permissionStatus']
+    });
   }
-
-  idl_array.add_objects({
-    Permissions: ['navigator.permissions'],
-    PermissionStatus: ['permissionStatus']
-  });
-  idl_array.test();
-}, "Test IDL implementation of Permissions API");
+);
--- a/testing/web-platform/tests/requestidlecallback/idlharness.window.js
+++ b/testing/web-platform/tests/requestidlecallback/idlharness.window.js
@@ -1,30 +1,24 @@
 // META: script=/resources/WebIDLParser.js
 // META: script=/resources/idlharness.js
 
-async_test(function() {
-  const srcs = ['requestidlecallback', 'html', 'dom'];
-  Promise.all(srcs.map(i => fetch(`/interfaces/${i}.idl`).then(r => r.text())))
-    .then(([idl, html, dom]) => {
-      var idl_array = new IdlArray();
-      idl_array.add_idls(idl);
-      idl_array.add_dependency_idls(html);
-      idl_array.add_dependency_idls(dom);
-      idl_array.add_objects({Window: ['window']});
+// https://w3c.github.io/requestidlecallback/
+
+'use strict';
 
-      let deadline;
-      const execIDLTest = this.step_func_done(function() {
-        idl_array.add_objects({IdleDeadline: [deadline]});
-        idl_array.test();
-      });
+idl_test(
+  ['requestidlecallback'],
+  ['html', 'dom'],
+  async idl_array => {
+    idl_array.add_objects({
+      IdleDeadline: ['deadline'],
+      Window: ['window'],
+    });
 
-      if (!window.requestIdleCallback) {
-        execIDLTest();
-      } else {
-        const callback = this.step_func(d => {
-          deadline = d;
-          execIDLTest();
-        });
-        requestIdleCallback(callback, { timeout: 100 });
-      }
+    await new Promise(resolve => {
+      requestIdleCallback(d => {
+        self.deadline = d;
+        resolve();
+      }, { timeout: 100 });
     });
-}, 'IdleDeadline object setup');
+  }
+);
--- a/testing/web-platform/tests/server-timing/idlharness.https.any.js
+++ b/testing/web-platform/tests/server-timing/idlharness.https.any.js
@@ -1,21 +1,16 @@
 // META: script=/resources/WebIDLParser.js
 // META: script=/resources/idlharness.js
 
 'use strict';
 
 // https://w3c.github.io/server-timing/
 
-promise_test(async () => {
-  const idl = await fetch('/interfaces/server-timing.idl').then(r => r.text());
-  const res = await fetch('/interfaces/resource-timing.idl').then(r => r.text());
-  const perf = await fetch('/interfaces/performance-timeline.idl').then(r => r.text());
-
-  const idl_array = new IdlArray();
-  idl_array.add_idls(idl);
-  idl_array.add_dependency_idls(res);
-  idl_array.add_dependency_idls(perf);
-  idl_array.add_objects({
-    Performance: ['performance'],
-  });
-  idl_array.test();
-}, 'Test server-timing IDL implementation');
+idl_test(
+  ['server-timing'],
+  ['resource-timing', 'performance-timeline'],
+  idl_array => {
+    idl_array.add_objects({
+      Performance: ['performance'],
+    });
+  }
+);