Bug 1190082 - Rename media-playback and the related stuff to audio-playback; r=smaug

Given that we only dispatch this for audio, media-playback sounds
like a misnomer.
This commit is contained in:
Ehsan Akhgari 2015-08-01 11:32:12 -04:00
parent 9f9bae1800
commit fc6b13788a
16 changed files with 73 additions and 73 deletions

View File

@ -4256,7 +4256,7 @@
this.setIcon(tab, icon);
]]>
</handler>
<handler event="DOMMediaPlaybackStarted">
<handler event="DOMAudioPlaybackStarted">
<![CDATA[
if (!Services.prefs.getBoolPref("browser.tabs.showAudioPlayingIcon") ||
!event.isTrusted)
@ -4273,7 +4273,7 @@
}
]]>
</handler>
<handler event="DOMMediaPlaybackStopped">
<handler event="DOMAudioPlaybackStopped">
<![CDATA[
if (!Services.prefs.getBoolPref("browser.tabs.showAudioPlayingIcon") ||
!event.isTrusted)

View File

@ -132,7 +132,7 @@ public:
if (observerService) {
observerService->NotifyObservers(
ToSupports(mWindow),
"media-playback",
"audio-playback",
mActive ? NS_LITERAL_STRING("active").get()
: NS_LITERAL_STRING("inactive").get());
}

View File

@ -17,7 +17,7 @@ var expectedNotification = null;
var observer = {
observe: function(subject, topic, data) {
is(topic, "media-playback", "media-playback received");
is(topic, "audio-playback", "audio-playback received");
is(data, expectedNotification, "This is the right notification");
runTest();
}
@ -35,7 +35,7 @@ var tests = [
},
function() {
observerService.addObserver(observer, "media-playback", false);
observerService.addObserver(observer, "audio-playback", false);
ok(true, "Observer set");
runTest();
},
@ -51,7 +51,7 @@ var tests = [
},
function() {
observerService.removeObserver(observer, "media-playback");
observerService.removeObserver(observer, "audio-playback");
ok(true, "Observer removed");
runTest();
}

View File

@ -19,7 +19,7 @@ var iframe = null;
var observer = {
observe: function(subject, topic, data) {
is(topic, "media-playback", "media-playback received");
is(topic, "audio-playback", "audio-playback received");
is(data, expectedNotification, "This is the right notification");
runTest();
}
@ -35,7 +35,7 @@ var tests = [
},
function() {
observerService.addObserver(observer, "media-playback", false);
observerService.addObserver(observer, "audio-playback", false);
ok(true, "Observer set");
runTest();
},
@ -51,7 +51,7 @@ var tests = [
},
function() {
observerService.removeObserver(observer, "media-playback");
observerService.removeObserver(observer, "audio-playback");
ok(true, "Observer removed");
runTest();
}

View File

@ -15,7 +15,7 @@ SimpleTest.waitForExplicitFinish();
var observer = {
observe: function(subject, topic, data) {
ok(false, "should not receive media-playback notification!");
ok(false, "should not receive audio-playback notification!");
}
};
@ -27,7 +27,7 @@ video.loop = true;
video.src = "noaudio.webm";
video.onplay = video.onpause = function() {
// Yield to the event loop a few times to make sure that media-playback is not dispatched.
// Yield to the event loop a few times to make sure that audio-playback is not dispatched.
SimpleTest.executeSoon(function() {
SimpleTest.executeSoon(function() {
SimpleTest.executeSoon(function() {
@ -43,7 +43,7 @@ var tests = [
},
function() {
observerService.addObserver(observer, "media-playback", false);
observerService.addObserver(observer, "audio-playback", false);
ok(true, "Observer set");
runTest();
},
@ -57,7 +57,7 @@ var tests = [
},
function() {
observerService.removeObserver(observer, "media-playback");
observerService.removeObserver(observer, "audio-playback");
ok(true, "Observer removed");
runTest();
}

View File

@ -18,11 +18,11 @@ var expectedNotification = null;
var observer = {
observe: function(subject, topic, data) {
if (expectedNotification !== null) {
is(topic, "media-playback", "media-playback received");
is(topic, "audio-playback", "audio-playback received");
is(data, expectedNotification, "This is the right notification");
runTest();
} else {
ok(false, "should not receive media-playback notification!");
ok(false, "should not receive audio-playback notification!");
}
}
};
@ -39,7 +39,7 @@ var tests = [
},
function() {
observerService.addObserver(observer, "media-playback", false);
observerService.addObserver(observer, "audio-playback", false);
ok(true, "Observer set");
audio.src = "audio.ogg";
@ -82,7 +82,7 @@ var tests = [
function() {
expectedNotification = null;
audio.onpause = function() {
// Yield to the event loop a few times to make sure that media-playback is not dispatched.
// Yield to the event loop a few times to make sure that audio-playback is not dispatched.
SimpleTest.executeSoon(function() {
SimpleTest.executeSoon(function() {
SimpleTest.executeSoon(function() {
@ -98,7 +98,7 @@ var tests = [
function() {
expectedNotification = null;
audio.muted = false;
// Yield to the event loop a few times to make sure that media-playback is not dispatched.
// Yield to the event loop a few times to make sure that audio-playback is not dispatched.
SimpleTest.executeSoon(function() {
SimpleTest.executeSoon(function() {
SimpleTest.executeSoon(function() {
@ -109,7 +109,7 @@ var tests = [
},
function() {
observerService.removeObserver(observer, "media-playback");
observerService.removeObserver(observer, "audio-playback");
ok(true, "Observer removed");
runTest();
}

View File

@ -18,11 +18,11 @@ var expectedNotification = null;
var observer = {
observe: function(subject, topic, data) {
if (expectedNotification !== null) {
is(topic, "media-playback", "media-playback received");
is(topic, "audio-playback", "audio-playback received");
is(data, expectedNotification, "This is the right notification");
runTest();
} else {
ok(false, "should not receive media-playback notification!");
ok(false, "should not receive audio-playback notification!");
}
}
};
@ -39,7 +39,7 @@ var tests = [
},
function() {
observerService.addObserver(observer, "media-playback", false);
observerService.addObserver(observer, "audio-playback", false);
ok(true, "Observer set");
audio.src = "audio.ogg";
@ -61,7 +61,7 @@ var tests = [
function() {
expectedNotification = null;
audio.volume = 0;
// Yield to the event loop a few times to make sure that media-playback is not dispatched.
// Yield to the event loop a few times to make sure that audio-playback is not dispatched.
SimpleTest.executeSoon(function() {
SimpleTest.executeSoon(function() {
SimpleTest.executeSoon(function() {
@ -74,7 +74,7 @@ var tests = [
function() {
expectedNotification = null;
audio.muted = false;
// Yield to the event loop a few times to make sure that media-playback is not dispatched.
// Yield to the event loop a few times to make sure that audio-playback is not dispatched.
SimpleTest.executeSoon(function() {
SimpleTest.executeSoon(function() {
SimpleTest.executeSoon(function() {
@ -108,7 +108,7 @@ var tests = [
function() {
expectedNotification = null;
audio.volume = 0;
// Yield to the event loop a few times to make sure that media-playback is not dispatched.
// Yield to the event loop a few times to make sure that audio-playback is not dispatched.
SimpleTest.executeSoon(function() {
SimpleTest.executeSoon(function() {
SimpleTest.executeSoon(function() {
@ -121,7 +121,7 @@ var tests = [
function() {
expectedNotification = null;
audio.volume = 0.5;
// Yield to the event loop a few times to make sure that media-playback is not dispatched.
// Yield to the event loop a few times to make sure that audio-playback is not dispatched.
SimpleTest.executeSoon(function() {
SimpleTest.executeSoon(function() {
SimpleTest.executeSoon(function() {
@ -142,7 +142,7 @@ var tests = [
},
function() {
observerService.removeObserver(observer, "media-playback");
observerService.removeObserver(observer, "audio-playback");
ok(true, "Observer removed");
runTest();
}

View File

@ -18,11 +18,11 @@ var expectedNotification = null;
var observer = {
observe: function(subject, topic, data) {
if (expectedNotification !== null) {
is(topic, "media-playback", "media-playback received");
is(topic, "audio-playback", "audio-playback received");
is(data, expectedNotification, "This is the right notification");
runTest();
} else {
ok(false, "should not receive media-playback notification!");
ok(false, "should not receive audio-playback notification!");
}
}
};
@ -39,7 +39,7 @@ var tests = [
},
function() {
observerService.addObserver(observer, "media-playback", false);
observerService.addObserver(observer, "audio-playback", false);
ok(true, "Observer set");
audio.src = "audio.ogg";
@ -82,7 +82,7 @@ var tests = [
function() {
expectedNotification = null;
audio.onpause = function() {
// Yield to the event loop a few times to make sure that media-playback is not dispatched.
// Yield to the event loop a few times to make sure that audio-playback is not dispatched.
SimpleTest.executeSoon(function() {
SimpleTest.executeSoon(function() {
SimpleTest.executeSoon(function() {
@ -98,7 +98,7 @@ var tests = [
function() {
expectedNotification = null;
audio.volume = 1;
// Yield to the event loop a few times to make sure that media-playback is not dispatched.
// Yield to the event loop a few times to make sure that audio-playback is not dispatched.
SimpleTest.executeSoon(function() {
SimpleTest.executeSoon(function() {
SimpleTest.executeSoon(function() {
@ -109,7 +109,7 @@ var tests = [
},
function() {
observerService.removeObserver(observer, "media-playback");
observerService.removeObserver(observer, "audio-playback");
ok(true, "Observer removed");
runTest();
}

View File

@ -52,7 +52,7 @@ var iframe = null;
var observer = {
observe: function(subject, topic, data) {
is(topic, "media-playback", "media-playback received");
is(topic, "audio-playback", "audio-playback received");
is(data, expectedNotification, "This is the right notification");
SimpleTest.executeSoon(runTest);
}
@ -68,7 +68,7 @@ var tests = [
},
function() {
observerService.addObserver(observer, "media-playback", false);
observerService.addObserver(observer, "audio-playback", false);
ok(true, "Observer set");
runTest();
},
@ -93,7 +93,7 @@ var tests = [
},
function() {
observerService.removeObserver(observer, "media-playback");
observerService.removeObserver(observer, "audio-playback");
ok(true, "Observer removed");
runTest();
}

View File

@ -19,7 +19,7 @@ var iframe = null;
var observer = {
observe: function(subject, topic, data) {
is(topic, "media-playback", "media-playback received");
is(topic, "audio-playback", "audio-playback received");
is(data, expectedNotification, "This is the right notification");
SimpleTest.executeSoon(runTest);
}
@ -39,7 +39,7 @@ var tests = [
},
function() {
observerService.addObserver(observer, "media-playback", false);
observerService.addObserver(observer, "audio-playback", false);
ok(true, "Observer set");
runTest();
},
@ -60,7 +60,7 @@ var tests = [
},
function() {
observerService.removeObserver(observer, "media-playback");
observerService.removeObserver(observer, "audio-playback");
ok(true, "Observer removed");
runTest();
}

View File

@ -19,7 +19,7 @@ var iframe = null;
var observer = {
observe: function(subject, topic, data) {
is(topic, "media-playback", "media-playback received");
is(topic, "audio-playback", "audio-playback received");
is(data, expectedNotification, "This is the right notification");
runTest();
}
@ -35,7 +35,7 @@ var tests = [
},
function() {
observerService.addObserver(observer, "media-playback", false);
observerService.addObserver(observer, "audio-playback", false);
ok(true, "Observer set");
runTest();
},
@ -51,7 +51,7 @@ var tests = [
},
function() {
observerService.removeObserver(observer, "media-playback");
observerService.removeObserver(observer, "audio-playback");
ok(true, "Observer removed");
runTest();
}

View File

@ -55,7 +55,7 @@ let CERTIFICATE_ERROR_PAGE_PREF = 'security.alternate_certificate_error_page';
const OBSERVED_EVENTS = [
'xpcom-shutdown',
'media-playback',
'audio-playback',
'activity-done',
'invalid-widget'
];
@ -288,7 +288,7 @@ BrowserElementChild.prototype = {
// Ignore notifications not about our document. (Note that |content| /can/
// be null; see bug 874900.)
if (topic !== 'activity-done' && topic !== 'media-playback' &&
if (topic !== 'activity-done' && topic !== 'audio-playback' &&
(!content || subject !== content.document)) {
return;
}
@ -298,7 +298,7 @@ BrowserElementChild.prototype = {
case 'activity-done':
sendAsyncMsg('activitydone', { success: (data == 'activity-success') });
break;
case 'media-playback':
case 'audio-playback':
if (subject === content) {
sendAsyncMsg('audioplaybackchange', { _payload_: data });
}

View File

@ -689,26 +689,26 @@ addMessageListener("WebChannelMessageToContent", function (e) {
}
});
let MediaPlaybackListener = {
let AudioPlaybackListener = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]),
init() {
Services.obs.addObserver(this, "media-playback", false);
addMessageListener("MediaPlaybackMute", this);
Services.obs.addObserver(this, "audio-playback", false);
addMessageListener("AudioPlaybackMute", this);
addEventListener("unload", () => {
MediaPlaybackListener.uninit();
AudioPlaybackListener.uninit();
});
},
uninit() {
Services.obs.removeObserver(this, "media-playback");
removeMessageListener("MediaPlaybackMute", this);
Services.obs.removeObserver(this, "audio-playback");
removeMessageListener("AudioPlaybackMute", this);
},
observe(subject, topic, data) {
if (topic === "media-playback") {
if (topic === "audio-playback") {
if (subject && subject.top == global.content) {
let name = "MediaPlayback:";
let name = "AudioPlayback:";
name += (data === "active") ? "Start" : "Stop";
sendAsyncMessage(name);
}
@ -716,11 +716,11 @@ let MediaPlaybackListener = {
},
receiveMessage(msg) {
if (msg.name == "MediaPlaybackMute") {
if (msg.name == "AudioPlaybackMute") {
let utils = global.content.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils);
utils.audioMuted = msg.data.type === "mute";
}
},
};
MediaPlaybackListener.init();
AudioPlaybackListener.init();

View File

@ -10,8 +10,8 @@ function wait_for_event(browser, event) {
function* test_on_browser(url, browser) {
browser.loadURI(url);
yield wait_for_event(browser, "DOMMediaPlaybackStarted");
yield wait_for_event(browser, "DOMMediaPlaybackStopped");
yield wait_for_event(browser, "DOMAudioPlaybackStarted");
yield wait_for_event(browser, "DOMAudioPlaybackStopped");
}
add_task(function*() {

View File

@ -33,7 +33,7 @@ function* test_audio_in_browser() {
function* test_on_browser(url, browser) {
browser.loadURI(url);
yield wait_for_event(browser, "DOMMediaPlaybackStarted");
yield wait_for_event(browser, "DOMAudioPlaybackStarted");
var result = yield ContentTask.spawn(browser, null, test_audio_in_browser);
is(result.computedVolume, 1, "Audio volume is 1");
@ -43,7 +43,7 @@ function* test_on_browser(url, browser) {
browser.mute();
ok(browser.audioMuted, "Audio should be muted now");
yield wait_for_event(browser, "DOMMediaPlaybackStopped");
yield wait_for_event(browser, "DOMAudioPlaybackStopped");
result = yield ContentTask.spawn(browser, null, test_audio_in_browser);
is(result.computedVolume, 0, "Audio volume is 0 when muted");
@ -52,7 +52,7 @@ function* test_on_browser(url, browser) {
function* test_visibility(url, browser) {
browser.loadURI(url);
yield wait_for_event(browser, "DOMMediaPlaybackStarted");
yield wait_for_event(browser, "DOMAudioPlaybackStarted");
var result = yield ContentTask.spawn(browser, null, test_audio_in_browser);
is(result.computedVolume, 1, "Audio volume is 1");
@ -67,7 +67,7 @@ function* test_visibility(url, browser) {
url: "about:blank",
}, function() {});
yield wait_for_event(browser, "DOMMediaPlaybackStopped");
yield wait_for_event(browser, "DOMAudioPlaybackStopped");
result = yield ContentTask.spawn(browser, null, test_audio_in_browser);
is(result.computedVolume, 0, "Audio volume is 0 when muted");

View File

@ -663,21 +663,21 @@
onget="return this.blockedPopups;"
readonly="true"/>
<method name="mediaPlaybackStarted">
<method name="audioPlaybackStarted">
<body>
<![CDATA[
let event = document.createEvent("Events");
event.initEvent("DOMMediaPlaybackStarted", true, true);
event.initEvent("DOMAudioPlaybackStarted", true, true);
this.dispatchEvent(event);
]]>
</body>
</method>
<method name="mediaPlaybackStopped">
<method name="audioPlaybackStopped">
<body>
<![CDATA[
let event = document.createEvent("Events");
event.initEvent("DOMMediaPlaybackStopped", true, true);
event.initEvent("DOMAudioPlaybackStopped", true, true);
this.dispatchEvent(event);
]]>
</body>
@ -692,7 +692,7 @@
<body>
<![CDATA[
this._audioMuted = true;
this.messageManager.sendAsyncMessage("MediaPlaybackMute",
this.messageManager.sendAsyncMessage("AudioPlaybackMute",
{type: "mute"});
]]>
</body>
@ -702,7 +702,7 @@
<body>
<![CDATA[
this._audioMuted = false;
this.messageManager.sendAsyncMessage("MediaPlaybackMute",
this.messageManager.sendAsyncMessage("AudioPlaybackMute",
{type: "unmute"});
]]>
</body>
@ -858,8 +858,8 @@
this.messageManager.addMessageListener("PopupBlocking:UpdateBlockedPopups", this);
this.messageManager.addMessageListener("Autoscroll:Start", this);
this.messageManager.addMessageListener("Autoscroll:Cancel", this);
this.messageManager.addMessageListener("MediaPlayback:Start", this);
this.messageManager.addMessageListener("MediaPlayback:Stop", this);
this.messageManager.addMessageListener("AudioPlayback:Start", this);
this.messageManager.addMessageListener("AudioPlayback:Stop", this);
}
]]>
</constructor>
@ -946,11 +946,11 @@
case "Autoscroll:Cancel":
this._autoScrollPopup.hidePopup();
break;
case "MediaPlayback:Start":
this.mediaPlaybackStarted();
case "AudioPlayback:Start":
this.audioPlaybackStarted();
break;
case "MediaPlayback:Stop":
this.mediaPlaybackStopped();
case "AudioPlayback:Stop":
this.audioPlaybackStopped();
break;
}
]]></body>