mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1211314 - Use tab.toggleMuteAudio() from sessionstore instead of setting the muted attribute manually on the tab; r=jaws
This commit is contained in:
parent
92cc948abc
commit
cdc218794c
@ -98,10 +98,9 @@ function* test_mute_tab(tab, icon, expectMuted) {
|
||||
return mutedPromise;
|
||||
}
|
||||
|
||||
function get_tab_attributes(tab) {
|
||||
function get_tab_state(tab) {
|
||||
const ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
|
||||
let {attributes} = JSON.parse(ss.getTabState(tab));
|
||||
return attributes;
|
||||
return JSON.parse(ss.getTabState(tab));
|
||||
}
|
||||
|
||||
function* test_muting_using_menu(tab, expectMuted) {
|
||||
@ -147,17 +146,17 @@ function* test_playing_icon_on_tab(tab, browser, isPinned) {
|
||||
|
||||
yield test_tooltip(icon, "Mute tab", isActiveTab);
|
||||
|
||||
ok(!("muted" in get_tab_attributes(tab)), "No muted attribute should be persisted");
|
||||
ok(!("muted" in get_tab_state(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");
|
||||
ok("muted" in get_tab_state(tab), "Muted attribute should be persisted");
|
||||
|
||||
yield test_tooltip(icon, "Unmute tab", isActiveTab);
|
||||
|
||||
yield test_mute_tab(tab, icon, false);
|
||||
|
||||
ok(!("muted" in get_tab_attributes(tab)), "No muted attribute should be persisted");
|
||||
ok(!("muted" in get_tab_state(tab)), "No muted attribute should be persisted");
|
||||
|
||||
yield test_tooltip(icon, "Mute tab", isActiveTab);
|
||||
|
||||
|
@ -2679,6 +2679,10 @@ var SessionStoreInternal = {
|
||||
tabbrowser.showTab(tabs[t]);
|
||||
numVisibleTabs++;
|
||||
}
|
||||
|
||||
if (!!winData.tabs[t].muted != tabs[t].linkedBrowser.audioMuted) {
|
||||
tabs[t].toggleMuteAudio();
|
||||
}
|
||||
}
|
||||
|
||||
if (!overwriteTabs && firstWindow) {
|
||||
@ -2938,6 +2942,10 @@ var SessionStoreInternal = {
|
||||
tabbrowser.showTab(tab);
|
||||
}
|
||||
|
||||
if (!!tabData.muted != browser.audioMuted) {
|
||||
tab.toggleMuteAudio();
|
||||
}
|
||||
|
||||
if (tabData.lastAccessed) {
|
||||
tab.lastAccessed = tabData.lastAccessed;
|
||||
}
|
||||
|
@ -24,13 +24,15 @@ this.TabAttributes = Object.freeze({
|
||||
});
|
||||
|
||||
var TabAttributesInternal = {
|
||||
_attrs: new Set(["muted"]),
|
||||
_attrs: new Set(),
|
||||
|
||||
// We never want to directly read or write those attributes.
|
||||
// 'image' should not be accessed directly but handled by using the
|
||||
// gBrowser.getIcon()/setIcon() methods.
|
||||
// 'muted' should not be accessed directly but handled by using the
|
||||
// tab.linkedBrowser.audioMuted/toggleMuteAudio methods.
|
||||
// 'pending' is used internal by sessionstore and managed accordingly.
|
||||
_skipAttrs: new Set(["image", "pending"]),
|
||||
_skipAttrs: new Set(["image", "muted", "pending"]),
|
||||
|
||||
persist: function (name) {
|
||||
if (this._attrs.has(name) || this._skipAttrs.has(name)) {
|
||||
|
@ -159,6 +159,10 @@ var TabStateInternal = {
|
||||
else
|
||||
delete tabData.pinned;
|
||||
tabData.hidden = tab.hidden;
|
||||
if (browser.audioMuted)
|
||||
tabData.muted = true;
|
||||
else
|
||||
delete tabData.muted;
|
||||
|
||||
// Save tab attributes.
|
||||
tabData.attributes = TabAttributes.get(tab);
|
||||
|
@ -4,7 +4,7 @@
|
||||
/**
|
||||
* This test makes sure that we correctly preserve tab attributes when storing
|
||||
* and restoring tabs. It also ensures that we skip special attributes like
|
||||
* 'image' and 'pending' that need to be handled differently or internally.
|
||||
* 'image', 'muted' and 'pending' that need to be handled differently or internally.
|
||||
*/
|
||||
|
||||
const PREF = "browser.sessionstore.restore_on_demand";
|
||||
@ -20,10 +20,16 @@ add_task(function* test() {
|
||||
// Check that the tab has an 'image' attribute.
|
||||
ok(tab.hasAttribute("image"), "tab.image exists");
|
||||
|
||||
// Make sure we do not persist 'image' attributes.
|
||||
tab.toggleMuteAudio();
|
||||
// Check that the tab has a 'muted' attribute.
|
||||
ok(tab.hasAttribute("muted"), "tab.muted exists");
|
||||
|
||||
// Make sure we do not persist 'image' or 'muted' attributes.
|
||||
ss.persistTabAttribute("image");
|
||||
ss.persistTabAttribute("muted");
|
||||
let {attributes} = JSON.parse(ss.getTabState(tab));
|
||||
ok(!("image" in attributes), "'image' attribute not saved");
|
||||
ok(!("muted" in attributes), "'muted' attribute not saved");
|
||||
ok(!("custom" in attributes), "'custom' attribute not saved");
|
||||
|
||||
// Test persisting a custom attribute.
|
||||
|
Loading…
Reference in New Issue
Block a user