Backed out 5 changesets (bug 1328058) for timing out in browser_block_silentAudioTrack_media.js

CLOSED TREE

Backed out changeset 0c48cff3db5d (bug 1328058)
Backed out changeset 37d35ca95b1f (bug 1328058)
Backed out changeset 0c177bdf5ec3 (bug 1328058)
Backed out changeset b369d9999b8a (bug 1328058)
Backed out changeset 61dbcbe35565 (bug 1328058)
This commit is contained in:
Phil Ringnalda 2017-02-02 20:59:34 -08:00
Родитель 64ec99ecef
Коммит 3281b2aab2
11 изменённых файлов: 34 добавлений и 280 удалений

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

@ -7109,6 +7109,14 @@
this.removeAttribute("blocked");
modifiedAttrs.push("blocked");
// We don't want sound icon flickering between "blocked", "none" and
// "sound-playing", here adding the "soundplaying" is to keep the
// transition smoothly.
if (!this.hasAttribute("soundplaying")) {
this.setAttribute("soundplaying", true);
modifiedAttrs.push("soundplaying");
}
browser.resumeMedia();
hist.add(3 /* unblockByClickingIcon */);
this.finishMediaBlockTimer();

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

@ -1058,29 +1058,6 @@ AudioChannelService::RefreshAgentsAudioFocusChanged(AudioChannelAgent* aAgent,
}
}
void
AudioChannelService::NotifyMediaResumedFromBlock(nsPIDOMWindowOuter* aWindow)
{
MOZ_ASSERT(aWindow);
MOZ_ASSERT(aWindow->IsOuterWindow());
nsCOMPtr<nsPIDOMWindowOuter> topWindow = aWindow->GetScriptableTop();
if (!topWindow) {
return;
}
AudioChannelWindow* winData = GetWindowData(topWindow->WindowID());
if (!winData) {
return;
}
if (!winData->mShouldSendBlockStopEvent) {
return;
}
winData->NotifyMediaBlockStop(aWindow);
}
void
AudioChannelService::AudioChannelWindow::RequestAudioFocus(AudioChannelAgent* aAgent)
{
@ -1286,26 +1263,6 @@ AudioChannelService::AudioChannelWindow::RemoveAgent(AudioChannelAgent* aAgent)
AudibleChangedReasons::ePauseStateChanged);
}
void
AudioChannelService::AudioChannelWindow::NotifyMediaBlockStop(nsPIDOMWindowOuter* aWindow)
{
mShouldSendBlockStopEvent = false;
// Can't use raw pointer for lamba variable capturing, use smart ptr.
nsCOMPtr<nsPIDOMWindowOuter> window = aWindow;
NS_DispatchToCurrentThread(NS_NewRunnableFunction([window] () -> void {
nsCOMPtr<nsIObserverService> observerService =
services::GetObserverService();
if (NS_WARN_IF(!observerService)) {
return;
}
observerService->NotifyObservers(ToSupports(window),
"audio-playback",
u"blockStop");
})
);
}
void
AudioChannelService::AudioChannelWindow::AppendAgentAndIncreaseAgentsNum(AudioChannelAgent* aAgent)
{
@ -1370,7 +1327,7 @@ AudioChannelService::AudioChannelWindow::AudioAudibleChanged(AudioChannelAgent*
NotifyAudioCompetingChanged(aAgent, aAudible == AudibleState::eAudible);
if (aAudible != AudibleState::eNotAudible) {
MaybeNotifyMediaBlockStart(aAgent);
MaybeNotifyMediaBlocked(aAgent);
}
}
@ -1447,7 +1404,7 @@ AudioChannelService::AudioChannelWindow::NotifyChannelActive(uint64_t aWindowID,
}
void
AudioChannelService::AudioChannelWindow::MaybeNotifyMediaBlockStart(AudioChannelAgent* aAgent)
AudioChannelService::AudioChannelWindow::MaybeNotifyMediaBlocked(AudioChannelAgent* aAgent)
{
nsCOMPtr<nsPIDOMWindowOuter> window = aAgent->Window();
if (!window) {
@ -1470,19 +1427,16 @@ AudioChannelService::AudioChannelWindow::MaybeNotifyMediaBlockStart(AudioChannel
return;
}
if (!mShouldSendBlockStopEvent) {
mShouldSendBlockStopEvent = true;
NS_DispatchToCurrentThread(NS_NewRunnableFunction([window] () -> void {
nsCOMPtr<nsIObserverService> observerService =
services::GetObserverService();
if (NS_WARN_IF(!observerService)) {
return;
}
NS_DispatchToCurrentThread(NS_NewRunnableFunction([window] () -> void {
nsCOMPtr<nsIObserverService> observerService =
services::GetObserverService();
if (NS_WARN_IF(!observerService)) {
return;
}
observerService->NotifyObservers(ToSupports(window),
"audio-playback",
u"blockStart");
})
);
}
observerService->NotifyObservers(ToSupports(window),
"audio-playback",
u"block");
})
);
}

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

@ -201,8 +201,6 @@ public:
void NotifyCreatedNewAgent(AudioChannelAgent* aAgent);
void NotifyMediaResumedFromBlock(nsPIDOMWindowOuter* aWindow);
private:
AudioChannelService();
~AudioChannelService();
@ -247,7 +245,6 @@ private:
: mWindowID(aWindowID)
, mIsAudioCaptured(false)
, mOwningAudioFocus(!AudioChannelService::IsEnableAudioCompeting())
, mShouldSendBlockStopEvent(false)
{
// Workaround for bug1183033, system channel type can always playback.
mChannels[(int16_t)AudioChannel::System].mMuted = false;
@ -261,8 +258,6 @@ private:
void AppendAgent(AudioChannelAgent* aAgent, AudibleState aAudible);
void RemoveAgent(AudioChannelAgent* aAgent);
void NotifyMediaBlockStop(nsPIDOMWindowOuter* aWindow);
uint64_t mWindowID;
bool mIsAudioCaptured;
AudioChannelConfig mChannels[NUMBER_OF_AUDIO_CHANNELS];
@ -275,9 +270,6 @@ private:
// lose audio focus when other windows starts playing.
bool mOwningAudioFocus;
// If we've dispatched "blockStart" event, we must dispatch another event
// "blockStop" when the window is resumed from suspend-block.
bool mShouldSendBlockStopEvent;
private:
void AudioCapturedChanged(AudioChannelAgent* aAgent,
AudioCaptureState aCapture);
@ -299,7 +291,7 @@ private:
void NotifyChannelActive(uint64_t aWindowID, AudioChannel aChannel,
bool aActive);
void MaybeNotifyMediaBlockStart(AudioChannelAgent* aAgent);
void MaybeNotifyMediaBlocked(AudioChannelAgent* aAgent);
void RequestAudioFocus(AudioChannelAgent* aAgent);
void NotifyAudioCompetingChanged(AudioChannelAgent* aAgent, bool aActive);

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

@ -4230,25 +4230,12 @@ nsPIDOMWindowOuter::SetMediaSuspend(SuspendTypes aSuspend)
}
if (!IsDisposableSuspend(aSuspend)) {
MaybeNotifyMediaResumedFromBlock(aSuspend);
mMediaSuspend = aSuspend;
}
RefreshMediaElementsSuspend(aSuspend);
}
void
nsPIDOMWindowOuter::MaybeNotifyMediaResumedFromBlock(SuspendTypes aSuspend)
{
if (mMediaSuspend == nsISuspendedTypes::SUSPENDED_BLOCK &&
aSuspend == nsISuspendedTypes::NONE_SUSPENDED) {
RefPtr<AudioChannelService> service = AudioChannelService::GetOrCreate();
if (service) {
service->NotifyMediaResumedFromBlock(GetOuterWindow());
}
}
}
bool
nsPIDOMWindowOuter::GetAudioMuted() const
{

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

@ -898,7 +898,6 @@ protected:
void RefreshMediaElementsVolume();
void RefreshMediaElementsSuspend(SuspendTypes aSuspend);
bool IsDisposableSuspend(SuspendTypes aSuspend) const;
void MaybeNotifyMediaResumedFromBlock(SuspendTypes aSuspend);
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_PIDOMWINDOWOUTER_IID)

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

@ -1016,10 +1016,8 @@ var AudioPlaybackListener = {
if (topic === "audio-playback") {
if (subject && subject.top == global.content) {
let name = "AudioPlayback:";
if (data === "blockStart") {
name += "BlockStart";
} else if (data === "blockStop") {
name += "BlockStop";
if (data === "block") {
name += "Block";
} else {
name += (data === "active") ? "Start" : "Stop";
}

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

@ -13,11 +13,6 @@ support-files =
tags = audiochannel
support-files =
file_multipleAudio.html
[browser_block_silentAudioTrack_media.js]
tags = audiochannel
support-files =
file_silentAudioTrack.html
silentAudioTrack.mp4
[browser_block_autoplay_media_pausedAfterPlay.js]
tags = audiochannel
support-files =

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

@ -1,149 +0,0 @@
const PAGE = "https://example.com/browser/toolkit/content/tests/browser/file_silentAudioTrack.html";
var SuspendedType = {
NONE_SUSPENDED : 0,
SUSPENDED_PAUSE : 1,
SUSPENDED_BLOCK : 2,
SUSPENDED_PAUSE_DISPOSABLE : 3
};
function* wait_for_tab_playing_event(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;
});
}
}
function* wait_for_tab_block_event(tab, expectBlocked) {
if (tab.soundBlocked == expectBlocked) {
ok(true, "The tab should " + (expectBlocked ? "" : "not ") + "be blocked");
} else {
info("Block state doens't match, wait for attributes changes.");
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;
});
}
}
function disable_non_test_mouse(disable) {
let utils = window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils);
utils.disableNonTestMouseEvents(disable);
}
function* hover_icon(icon, tooltip) {
disable_non_test_mouse(true);
let popupShownPromise = BrowserTestUtils.waitForEvent(tooltip, "popupshown");
EventUtils.synthesizeMouse(icon, 1, 1, {type: "mouseover"});
EventUtils.synthesizeMouse(icon, 2, 2, {type: "mousemove"});
EventUtils.synthesizeMouse(icon, 3, 3, {type: "mousemove"});
EventUtils.synthesizeMouse(icon, 4, 4, {type: "mousemove"});
return popupShownPromise;
}
function leave_icon(icon) {
EventUtils.synthesizeMouse(icon, 0, 0, {type: "mouseout"});
EventUtils.synthesizeMouseAtCenter(document.documentElement, {type: "mousemove"});
EventUtils.synthesizeMouseAtCenter(document.documentElement, {type: "mousemove"});
EventUtils.synthesizeMouseAtCenter(document.documentElement, {type: "mousemove"});
disable_non_test_mouse(false);
}
function* click_unblock_icon(tab) {
let icon = document.getAnonymousElementByAttribute(tab, "anonid", "soundplaying-icon");
yield hover_icon(icon, document.getElementById("tabbrowser-tab-tooltip"));
EventUtils.synthesizeMouseAtCenter(icon, {button: 0});
leave_icon(icon);
}
function check_audio_suspended(suspendedType) {
var autoPlay = content.document.getElementById("autoplay");
if (!autoPlay) {
ok(false, "Can't get the audio element!");
}
is(autoPlay.computedSuspended, suspendedType,
"The suspeded state of autoplay audio is correct.");
}
add_task(function* setup_test_preference() {
yield SpecialPowers.pushPrefEnv({"set": [
["media.useAudioChannelService.testing", true],
["media.block-autoplay-until-in-foreground", true]
]});
});
add_task(function* unblock_icon_should_disapear_after_resume_tab() {
info("- open new background tab -");
let tab = window.gBrowser.addTab("about:blank");
tab.linkedBrowser.loadURI(PAGE);
yield BrowserTestUtils.browserLoaded(tab.linkedBrowser);
info("- the suspend state of tab should be suspend-block -");
yield ContentTask.spawn(tab.linkedBrowser, SuspendedType.SUSPENDED_BLOCK,
check_audio_suspended);
info("- tab should display unblocking icon -");
yield wait_for_tab_block_event(tab, true);
info("- select tab as foreground tab -");
yield BrowserTestUtils.switchTab(window.gBrowser, tab);
info("- the suspend state of tab should be none-suspend -");
yield ContentTask.spawn(tab.linkedBrowser, SuspendedType.NONE_SUSPENDED,
check_audio_suspended);
info("- should not display unblocking icon -");
yield wait_for_tab_block_event(tab, false);
info("- should not display sound indicator icon -");
yield wait_for_tab_playing_event(tab, false);
info("- remove tab -");
yield BrowserTestUtils.removeTab(tab);
});
add_task(function* should_not_show_sound_indicator_after_resume_tab() {
info("- open new background tab -");
let tab = window.gBrowser.addTab("about:blank");
tab.linkedBrowser.loadURI(PAGE);
yield BrowserTestUtils.browserLoaded(tab.linkedBrowser);
info("- the suspend state of tab should be suspend-block -");
yield ContentTask.spawn(tab.linkedBrowser, SuspendedType.SUSPENDED_BLOCK,
check_audio_suspended);
info("- tab should display unblocking icon -");
yield wait_for_tab_block_event(tab, true);
info("- click play tab icon -");
yield click_unblock_icon(tab);
info("- the suspend state of tab should be none-suspend -");
yield ContentTask.spawn(tab.linkedBrowser, SuspendedType.NONE_SUSPENDED,
check_audio_suspended);
info("- should not display unblocking icon -");
yield wait_for_tab_block_event(tab, false);
info("- should not display sound indicator icon -");
yield wait_for_tab_playing_event(tab, false);
info("- remove tab -");
yield BrowserTestUtils.removeTab(tab);
});

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

@ -1,18 +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="autoplay" src="silentAudioTrack.mp4"></audio>
<script type="text/javascript">
// In linux debug on try server, sometimes the download process would fail, so
// we can't activate the "auto-play" or playing after receving "oncanplay".
// Therefore, we just call play here.
var audio = document.getElementById("autoplay");
audio.loop = true;
audio.play();
</script>
</body>

Двоичный файл не отображается.

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

@ -700,6 +700,12 @@
let event = document.createEvent("Events");
event.initEvent("DOMAudioPlaybackStarted", true, false);
this.dispatchEvent(event);
if (this._audioBlocked) {
this._audioBlocked = false;
event = document.createEvent("Events");
event.initEvent("DOMAudioPlaybackBlockStopped", true, false);
this.dispatchEvent(event);
}
]]>
</body>
</method>
@ -714,7 +720,7 @@
</body>
</method>
<method name="audioPlaybackBlockStarted">
<method name="audioPlaybackBlocked">
<body>
<![CDATA[
this._audioBlocked = true;
@ -725,20 +731,6 @@
</body>
</method>
<method name="audioPlaybackBlockStopped">
<body>
<![CDATA[
if (!this._audioBlocked) {
return;
}
this._audioBlocked = false;
let event = document.createEvent("Events");
event.initEvent("DOMAudioPlaybackBlockStopped", true, false);
this.dispatchEvent(event);
]]>
</body>
</method>
<field name="_audioMuted">false</field>
<property name="audioMuted"
onget="return this._audioMuted;"
@ -967,8 +959,7 @@
this.messageManager.addMessageListener("Autoscroll:Cancel", this);
this.messageManager.addMessageListener("AudioPlayback:Start", this);
this.messageManager.addMessageListener("AudioPlayback:Stop", this);
this.messageManager.addMessageListener("AudioPlayback:BlockStart", this);
this.messageManager.addMessageListener("AudioPlayback:BlockStop", this);
this.messageManager.addMessageListener("AudioPlayback:Block", this);
if (this.hasAttribute("selectmenulist")) {
this.messageManager.addMessageListener("Forms:ShowDropDown", this);
@ -1066,11 +1057,8 @@
case "AudioPlayback:Stop":
this.audioPlaybackStopped();
break;
case "AudioPlayback:BlockStart":
this.audioPlaybackBlockStarted();
break;
case "AudioPlayback:BlockStop":
this.audioPlaybackBlockStopped();
case "AudioPlayback:Block":
this.audioPlaybackBlocked();
break;
case "Forms:ShowDropDown": {
if (!this._selectParentHelper) {