зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1341062 - part1 : wait for audioplayback event to ensure the media element has been resumed. r=baku
Block-stop should be dispatched before audio-playback, so we can check block event first. Also add "loop" attribute for video to avoid getting the wrong pause state. MozReview-Commit-ID: 3WHuJGsZCPn --HG-- extra : rebase_source : 75147657a727bf34aacf9feb1674ccf29142a0eb
This commit is contained in:
Родитель
2d8a4d4653
Коммит
22ff369556
|
@ -64,14 +64,15 @@ add_task(function* block_autoplay_media() {
|
|||
info("- the tab1 should not be blocked -");
|
||||
yield waitForTabBlockEvent(tab1, false);
|
||||
|
||||
info("- select tab2 as foreground tab, and tab2's media should be playing -");
|
||||
info("- select tab2 as foreground tab, and the tab2 should not be blocked -");
|
||||
yield BrowserTestUtils.switchTab(window.gBrowser, tab2);
|
||||
yield waitForTabBlockEvent(tab2, false);
|
||||
|
||||
info("- tab2's media should be playing -");
|
||||
yield waitForTabPlayingEvent(tab2, true);
|
||||
yield ContentTask.spawn(tab2.linkedBrowser, false,
|
||||
check_audio_pause_state);
|
||||
|
||||
info("- the tab2 should not be blocked -");
|
||||
yield waitForTabBlockEvent(tab2, false);
|
||||
|
||||
info("- check tab2's media suspend type -");
|
||||
yield ContentTask.spawn(tab2.linkedBrowser, SuspendedType.NONE_SUSPENDED,
|
||||
check_audio_suspended);
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<meta content="utf-8" http-equiv="encoding">
|
||||
</head>
|
||||
<body>
|
||||
<audio id="testAudio" src="audio.ogg"></audio>
|
||||
<audio id="testAudio" src="audio.ogg" loop></audio>
|
||||
<script type="text/javascript">
|
||||
|
||||
var audio = document.getElementById("testAudio");
|
||||
|
|
|
@ -49,3 +49,21 @@ function* waitForTabBlockEvent(tab, expectBlocked) {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to check whether the tab has soundplaying attribute.
|
||||
*/
|
||||
function* waitForTabPlayingEvent(tab, expectPlaying) {
|
||||
if (tab.soundPlaying == expectPlaying) {
|
||||
ok(true, "The tab should " + (expectPlaying ? "" : "not ") + "be playing");
|
||||
} else {
|
||||
info("Playing state doens't match, wait for attributes changes.");
|
||||
yield BrowserTestUtils.waitForEvent(tab, "TabAttrModified", false, (event) => {
|
||||
if (event.detail.changed.indexOf("soundplaying") >= 0) {
|
||||
is(tab.soundPlaying, expectPlaying, "The tab should " + (expectPlaying ? "" : "not ") + "be playing");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче