Bug 1262053 - part10 : modify tests. draft
authorAlastor Wu <alwu@mozilla.com>
Tue, 16 Aug 2016 14:57:12 +0800
changeset 401073 e5fcd05e5d821c15a1c83e233598c7326d20f742
parent 401072 82aae5d4ea69c7d649bd8555abc42de5ffc14249
child 528385 5cf03b05d6bd42e210b2462af6e8e7d281fa3659
push id26351
push useralwu@mozilla.com
push dateTue, 16 Aug 2016 06:57:30 +0000
bugs1262053
milestone51.0a1
Bug 1262053 - part10 : modify tests. MozReview-Commit-ID: 3zNltoFEgm0
dom/browser-element/mochitest/browserElement_NoAudioTrack.js
toolkit/content/tests/browser/browser_block_autoplay_media.js
toolkit/content/tests/browser/browser_mediaPlayback_suspended_multipleAudio.js
--- a/dom/browser-element/mochitest/browserElement_NoAudioTrack.js
+++ b/dom/browser-element/mochitest/browserElement_NoAudioTrack.js
@@ -69,17 +69,17 @@ function setupTestFrame() {
     is(channels.length, 9, "9 audio channel by default");
 
     var ac = channels[0];
     ok(ac instanceof BrowserElementAudioChannel, "Correct class");
     ok("onactivestatechanged" in ac, "onactivestatechanged exists");
 
     ac.onactivestatechanged = () => {
       ac.onactivestatechanged = null;
-      error("Should not receive onactivestatechanged!");
+      ok(true, "Should receive onactivestatechanged!");
     };
 
     continueTest();
   }
 
   testFrame.addEventListener('mozbrowserloadend', loadend);
   testFrame.addEventListener('mozbrowsershowmodalprompt', alertListener);
   ok(true, "Add event-listeners.");
--- a/toolkit/content/tests/browser/browser_block_autoplay_media.js
+++ b/toolkit/content/tests/browser/browser_block_autoplay_media.js
@@ -79,9 +79,9 @@ add_task(function* block_autoplay_media(
   yield wait_for_tab_playing_event(tab2, false);
   yield ContentTask.spawn(tab2.linkedBrowser, SuspendedType.SUSPENDED_BLOCK,
                           check_audio_suspended);
 
   info("- remove tabs -");
   yield BrowserTestUtils.removeTab(tab1);
   yield BrowserTestUtils.removeTab(tab2);
   yield BrowserTestUtils.removeTab(tab3);
-});
\ No newline at end of file
+});
--- a/toolkit/content/tests/browser/browser_mediaPlayback_suspended_multipleAudio.js
+++ b/toolkit/content/tests/browser/browser_mediaPlayback_suspended_multipleAudio.js
@@ -138,24 +138,17 @@ function no_audio_resumed() {
 
 function play_nonautoplay_audio_should_be_blocked(suspendedType) {
   var nonAutoPlay = content.document.getElementById('nonautoplay');
   if (!nonAutoPlay) {
     ok(false, "Can't get the audio element!");
   }
 
   nonAutoPlay.play();
-  return new Promise(resolve => {
-    nonAutoPlay.onplay = function () {
-      nonAutoPlay.onplay = null;
-      is(nonAutoPlay.computedSuspended, suspendedType,
-         "The suspeded state of non-autoplay audio is correct.");
-      resolve();
-    }
-  });
+  ok(nonAutoPlay.paused, "The blocked audio can't be playback.");
 }
 
 function* suspended_pause(url, browser) {
   info("### Start test for suspended-pause ###");
   browser.loadURI(url);
 
   info("- page should have playing audio -");
   yield wait_for_event(browser, "DOMAudioPlaybackStarted");