Bug 1525554 - Avoid testharness reporting unhandled promise rejections in pause-remove-from-document-networkState.html; r=annevk
authorEdgar Chen <echen@mozilla.com>
Wed, 29 May 2019 12:35:14 +0000
changeset 476052 617ee0765a326cbee2d60998512d90ea4a2986b5
parent 476051 2283a3e7f2de4a11bd7b589662dd860044faf590
child 476053 ac0ff2775804c4af2d20f48f88cf6ab5c9b27fb4
push id36083
push usernerli@mozilla.com
push dateWed, 29 May 2019 15:58:28 +0000
treeherdermozilla-central@2bb77ed1fcc5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersannevk
bugs1525554
milestone69.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 1525554 - Avoid testharness reporting unhandled promise rejections in pause-remove-from-document-networkState.html; r=annevk Differential Revision: https://phabricator.services.mozilla.com/D32305
testing/web-platform/tests/html/semantics/embedded-content/media-elements/playing-the-media-resource/pause-remove-from-document-networkState.html
--- a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/playing-the-media-resource/pause-remove-from-document-networkState.html
+++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/playing-the-media-resource/pause-remove-from-document-networkState.html
@@ -2,21 +2,26 @@
 <title>paused state when removing from a document when networkState is NETWORK_EMPTY</title>
 <meta name="timeout" content="long" />
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 <div id="log"></div>
 <video hidden></video>
 <script>
 // Negative test for the specified behavior prior to HTML r8447.
-async_test(function(t) {
+promise_test(async function(t) {
   var v = document.querySelector('video');
-  v.play();
-  t.step_timeout(function() {
-    assert_equals(v.networkState, v.NETWORK_EMPTY,
-                  'networkState after stable state');
-    assert_false(v.paused, 'paused after stable state');
-    v.parentNode.removeChild(v);
-    assert_false(v.paused, 'paused after removing');
-    v.onpause = t.step_func_done();
-  }, 0);
+  var watcher = new EventWatcher(t, v, [ 'pause' ]);
+  var p = v.play();
+
+  await new Promise(resolve => t.step_timeout(resolve, 0));
+  assert_equals(v.networkState, v.NETWORK_EMPTY,
+                'networkState after stable state');
+  assert_false(v.paused, 'paused after stable state');
+  v.parentNode.removeChild(v);
+  assert_false(v.paused, 'paused after removing');
+
+  await watcher.wait_for('pause');
+
+  await promise_rejects(t, 'AbortError', p, 'We expect promise being rejected');
+  assert_true(v.paused, 'paused after removing and stable state');
 });
 </script>