Bug 1576594 [wpt PR 18674] - Convert the Media Source idlharness.js test to use idl_test, a=testonly
authorPhilip Jägenstedt <philip@foolip.org>
Wed, 28 Aug 2019 09:51:17 +0000
changeset 551228 d979bcd30c36f66ff6e59b5a3e52f52801660adb
parent 551227 f1052bf49e9af0ec5a3c94707bc58cd7396eceea
child 551229 28bcf3624fbb29e2c541db78ad21bf3880eccc41
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
bugs1576594, 18674
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 1576594 [wpt PR 18674] - Convert the Media Source idlharness.js test to use idl_test, a=testonly Automatic update from web-platform-tests Convert the Media Source idlharness.js test to use idl_test (#18674) Also rename it to .window.js since nothing is worker-exposed. -- wpt-commits: bbaa31bd1cb350f8fab6da80c8159182e37e1b62 wpt-pr: 18674
testing/web-platform/tests/media-source/idlharness.any.js
testing/web-platform/tests/media-source/idlharness.window.js
deleted file mode 100644
--- a/testing/web-platform/tests/media-source/idlharness.any.js
+++ /dev/null
@@ -1,59 +0,0 @@
-// META: script=/resources/WebIDLParser.js
-// META: script=/resources/idlharness.js
-
-// https://w3c.github.io/media-source/
-
-'use strict';
-
-var mediaSource;
-var sourceBuffer;
-var video = document.createElement("video");
-
-promise_test(async t => {
-  const srcs = ['media-source', 'dom', 'html', 'url'];
-  const [idl, dom, html, url] = await Promise.all(
-      srcs.map(i => fetch(`/interfaces/${i}.idl`).then(r => r.text())));
-
-  var idlArray = new IdlArray();
-  idlArray.add_idls(idl);
-  idlArray.add_dependency_idls(dom);
-  idlArray.add_dependency_idls(html);
-  idlArray.add_dependency_idls(url);
-
-  const testIdls = new Promise(resolve => {
-    try {
-      mediaSource = new MediaSource();
-      video.src = URL.createObjectURL(mediaSource);
-      mediaSource.addEventListener("sourceopen", function () {
-        var defaultType ='video/webm;codecs="vp8,vorbis"';
-        if (MediaSource.isTypeSupported(defaultType)) {
-          sourceBuffer = mediaSource.addSourceBuffer(defaultType);
-        } else {
-          sourceBuffer = mediaSource.addSourceBuffer('video/mp4');
-        }
-        sourceBuffer.addEventListener("updateend", function (e) {
-          mediaSource.endOfStream();
-          resolve();
-        });
-        sourceBuffer.appendBuffer(new ArrayBuffer());
-      });
-    } catch (e) {
-      // Will be surfaced in idlharness.js's test_object below.
-    }
-  })
-
-  idlArray.add_objects({
-    MediaSource: ['mediaSource'],
-    SourceBuffer: ['sourceBuffer'],
-    SourceBufferList: ['mediaSource.sourceBuffers']
-  });
-
-  const timeout = new Promise((_, reject) => t.step_timeout(reject, 3000));
-  return Promise
-      .race([testIdls, timeout])
-      .then(() => { idlArray.test(); })
-      .catch(() => {
-        idlArray.test();
-        return Promise.reject('Failed to create media-source objects')
-      });
-}, 'media-source interfaces');
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/media-source/idlharness.window.js
@@ -0,0 +1,36 @@
+// META: script=/resources/WebIDLParser.js
+// META: script=/resources/idlharness.js
+
+// https://w3c.github.io/media-source/
+
+'use strict';
+
+idl_test(
+  ['media-source'],
+  ['dom', 'html', 'url'],
+  async idl_array => {
+    self.audio = document.createElement('audio');
+    self.video = document.createElement('video');
+    idl_array.add_objects({
+      MediaSource: ['mediaSource'],
+      SourceBuffer: ['sourceBuffer'],
+      SourceBufferList: ['mediaSource.sourceBuffers'],
+    });
+
+    const video = document.createElement('video');
+    self.mediaSource = new MediaSource();
+    video.src = URL.createObjectURL(mediaSource);
+
+    self.sourceBuffer = await new Promise((resolve, reject) => {
+      mediaSource.addEventListener('sourceopen', () => {
+        var defaultType = 'video/webm;codecs="vp8,vorbis"';
+        if (MediaSource.isTypeSupported(defaultType)) {
+          resolve(mediaSource.addSourceBuffer(defaultType));
+        } else {
+          resolve(mediaSource.addSourceBuffer('video/mp4'));
+        }
+      });
+      step_timeout(() => reject(new Error('sourceopen event not fired')), 3000);
+    });
+  }
+);