Bug 1195150 - Persist the tab muted state in the session store; r=billm

The muted state is state that belong to the whole tab, and it would be
nice if it was integrated with undo close tab and session restore.
This commit is contained in:
Ehsan Akhgari 2015-08-16 19:34:39 -04:00
parent 86c13c8ffb
commit 08c515de22
2 changed files with 13 additions and 1 deletions

View File

@ -70,6 +70,12 @@ function* test_mute_tab(tab, icon, expectMuted) {
return mutedPromise;
}
function get_tab_attributes(tab) {
const ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
let {attributes} = JSON.parse(ss.getTabState(tab));
return attributes;
}
function* test_playing_icon_on_tab(tab, browser, isPinned) {
let icon = document.getAnonymousElementByAttribute(tab, "anonid",
isPinned ? "overlay-icon" : "soundplaying-icon");
@ -83,12 +89,18 @@ function* test_playing_icon_on_tab(tab, browser, isPinned) {
yield test_tooltip(icon, "Mute tab");
ok(!("muted" in get_tab_attributes(tab)), "No muted attribute should be persisted");
yield test_mute_tab(tab, icon, true);
ok("muted" in get_tab_attributes(tab), "Muted attribute should be persisted");
yield test_tooltip(icon, "Unmute tab");
yield test_mute_tab(tab, icon, false);
ok(!("muted" in get_tab_attributes(tab)), "No muted attribute should be persisted");
yield test_tooltip(icon, "Mute tab");
yield test_mute_tab(tab, icon, true);

View File

@ -24,7 +24,7 @@ this.TabAttributes = Object.freeze({
});
let TabAttributesInternal = {
_attrs: new Set(),
_attrs: new Set(["muted"]),
// We never want to directly read or write those attributes.
// 'image' should not be accessed directly but handled by using the