Backed out 4 changesets (bug 1322505) for frequent timeouts in browser_block_autoplay_media_pausedAfterPlay.js

Backed out changeset dad8acbe41e9 (bug 1322505)
Backed out changeset 861f01ee0e6e (bug 1322505)
Backed out changeset ddf90342d71d (bug 1322505)
Backed out changeset 049ab1a92da6 (bug 1322505)
This commit is contained in:
Phil Ringnalda 2017-01-19 21:57:46 -08:00
Родитель 3227a842d7
Коммит f10b4dc62e
7 изменённых файлов: 8 добавлений и 169 удалений

Просмотреть файл

@ -6992,12 +6992,6 @@
</getter>
</property>
<property name="soundBlocked" readonly="true">
<getter>
return this.getAttribute("blocked") == "true";
</getter>
</property>
<property name="lastAccessed">
<getter>
return this._lastAccessed == Infinity ? Date.now() : this._lastAccessed;

Просмотреть файл

@ -654,32 +654,14 @@ public:
}
}
bool
ShouldResetSuspend() const
{
// The disposable-pause should be clear after media starts playing.
if (!mOwner->Paused() &&
mSuspended == nsISuspendedTypes::SUSPENDED_PAUSE_DISPOSABLE) {
return true;
}
// If the blocked media is paused, we don't need to resume it. We reset the
// mSuspended in order to unregister the agent.
if (mOwner->Paused() &&
mSuspended == nsISuspendedTypes::SUSPENDED_BLOCK) {
return true;
}
return false;
}
void
NotifyPlayStateChanged()
NotifyPlayStarted()
{
MOZ_ASSERT(!mIsShutDown);
if (ShouldResetSuspend()) {
SetSuspended(nsISuspendedTypes::NONE_SUSPENDED);
}
// Reset the suspend type because the media element might be paused by
// audio channel before calling play(). eg. paused by Fennec media control,
// but resumed it from page.
SetSuspended(nsISuspendedTypes::NONE_SUSPENDED);
UpdateAudioChannelPlayingState();
}
@ -898,7 +880,7 @@ private:
if (!IsSuspended()) {
MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
("HTMLMediaElement::AudioChannelAgentCallback, ResumeFromAudioChannel, "
"this = %p, don't need to be resumed!\n", this));
"this = %p, Error : resume without suspended!\n", this));
return;
}
@ -2775,9 +2757,7 @@ HTMLMediaElement::Pause(ErrorResult& aRv)
// We changed mPaused and mAutoplaying which can affect AddRemoveSelfReference
AddRemoveSelfReference();
UpdateSrcMediaStreamPlaying();
if (mAudioChannelWrapper) {
mAudioChannelWrapper->NotifyPlayStateChanged();
}
UpdateAudioChannelPlayingState();
if (!oldPaused) {
FireTimeUpdate(false);
@ -7152,7 +7132,7 @@ HTMLMediaElement::UpdateCustomPolicyAfterPlayed()
{
OpenUnsupportedMediaWithExternalAppIfNeeded();
if (mAudioChannelWrapper) {
mAudioChannelWrapper->NotifyPlayStateChanged();
mAudioChannelWrapper->NotifyPlayStarted();
}
}

Просмотреть файл

@ -13,11 +13,6 @@ support-files =
tags = audiochannel
support-files =
file_multipleAudio.html
[browser_block_autoplay_media_pausedAfterPlay.js]
tags = audiochannel
support-files =
file_blockMedia_shouldPlay.html
file_blockMedia_shouldNotPlay.html
[browser_bug295977_autoscroll_overflow.js]
[browser_bug451286.js]
skip-if = !e10s

Просмотреть файл

@ -1,82 +0,0 @@
const PAGE_SHOULD_PLAY = "https://example.com/browser/toolkit/content/tests/browser/file_blockMedia_shouldPlay.html";
const PAGE_SHOULD_NOT_PLAY = "https://example.com/browser/toolkit/content/tests/browser/file_blockMedia_shouldNotPlay.html";
var SuspendedType = {
NONE_SUSPENDED : 0,
SUSPENDED_PAUSE : 1,
SUSPENDED_BLOCK : 2,
SUSPENDED_PAUSE_DISPOSABLE : 3
};
function check_audio_suspended(suspendedType) {
var audio = content.document.getElementById("testAudio");
if (!audio) {
ok(false, "Can't get the audio element!");
}
is(audio.computedSuspended, suspendedType,
"The suspeded state of audio is correct.");
}
function check_audio_pause_state(expectPause) {
var audio = content.document.getElementById("testAudio");
if (!audio) {
ok(false, "Can't get the audio element!");
}
is(audio.paused, expectPause,
"The pause state of audio is corret.")
}
add_task(function* setup_test_preference() {
yield SpecialPowers.pushPrefEnv({"set": [
["media.useAudioChannelService.testing", true],
["media.block-autoplay-until-in-foreground", true]
]});
});
add_task(function* block_autoplay_media() {
info("- open new background tab1, and check tab1's media suspend type -");
let tab1 = window.gBrowser.addTab("about:blank");
tab1.linkedBrowser.loadURI(PAGE_SHOULD_NOT_PLAY);
yield BrowserTestUtils.browserLoaded(tab1.linkedBrowser);
yield ContentTask.spawn(tab1.linkedBrowser, SuspendedType.NONE_SUSPENDED,
check_audio_suspended);
info("- the tab1 should not be blocked -");
yield waitForTabBlockEvent(tab1, false);
info("- open new background tab2, and check tab2's media suspend type -");
let tab2 = window.gBrowser.addTab("about:blank");
tab2.linkedBrowser.loadURI(PAGE_SHOULD_PLAY);
yield BrowserTestUtils.browserLoaded(tab2.linkedBrowser);
yield ContentTask.spawn(tab2.linkedBrowser, SuspendedType.SUSPENDED_BLOCK,
check_audio_suspended);
info("- the tab2 should be blocked -");
yield waitForTabBlockEvent(tab2, true);
info("- select tab1 as foreground tab, and tab1's media should be paused -");
yield BrowserTestUtils.switchTab(window.gBrowser, tab1);
yield ContentTask.spawn(tab1.linkedBrowser, true,
check_audio_pause_state);
info("- the tab1 should not be blocked -");
yield waitForTabBlockEvent(tab1, false);
info("- select tab2 as foreground tab, and tab2's media should be playing -");
yield BrowserTestUtils.switchTab(window.gBrowser, tab2);
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);
info("- remove tabs -");
yield BrowserTestUtils.removeTab(tab1);
yield BrowserTestUtils.removeTab(tab2);
});

Просмотреть файл

@ -1,15 +0,0 @@
<!DOCTYPE html>
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
</head>
<body>
<audio id="testAudio" src="audio.ogg"></audio>
<script type="text/javascript">
var audio = document.getElementById("testAudio");
audio.play();
audio.pause();
</script>
</body>

Просмотреть файл

@ -1,16 +0,0 @@
<!DOCTYPE html>
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
</head>
<body>
<audio id="testAudio" src="audio.ogg"></audio>
<script type="text/javascript">
var audio = document.getElementById("testAudio");
audio.play();
audio.pause();
audio.play();
</script>
</body>

Просмотреть файл

@ -31,20 +31,3 @@ function pushPrefs(...aPrefs) {
SpecialPowers.pushPrefEnv({"set": aPrefs}, deferred.resolve);
return deferred.promise;
}
/**
* Used to check whether the audio unblocking icon is in the tab.
*/
function* waitForTabBlockEvent(tab, expectBlocked) {
if (tab.soundBlocked == expectBlocked) {
ok(true, "The tab should " + (expectBlocked ? "" : "not ") + "be blocked");
} else {
yield BrowserTestUtils.waitForEvent(tab, "TabAttrModified", false, (event) => {
if (event.detail.changed.indexOf("blocked") >= 0) {
is(tab.soundBlocked, expectBlocked, "The tab should " + (expectBlocked ? "" : "not ") + "be blocked");
return true;
}
return false;
});
}
}