зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1387976 - Persist tab-muted state across restarts of the browser. r=jaws
--HG-- extra : rebase_source : f64d173f28041bdc2271cd522c91d7b406f3977d
This commit is contained in:
Родитель
ec727b06ef
Коммит
401631cd0e
|
@ -116,7 +116,7 @@ class TabBrowser {
|
|||
"resumeMedia", "mute", "unmute", "blockedPopups", "lastURI",
|
||||
"purgeSessionHistory", "stopScroll", "startScroll",
|
||||
"userTypedValue", "userTypedClear", "mediaBlocked",
|
||||
"didStartLoadSinceLastUserTyping"
|
||||
"didStartLoadSinceLastUserTyping", "audioMuted"
|
||||
];
|
||||
|
||||
this._removingTabs = [];
|
||||
|
@ -1965,7 +1965,7 @@ class TabBrowser {
|
|||
let setter;
|
||||
switch (name) {
|
||||
case "audioMuted":
|
||||
getter = () => false;
|
||||
getter = () => aTab.hasAttribute("muted");
|
||||
break;
|
||||
case "contentTitle":
|
||||
getter = () => SessionStore.getLazyTabValue(aTab, "title");
|
||||
|
|
|
@ -1847,11 +1847,6 @@
|
|||
<parameter name="aMuteReason"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
// Do not attempt to toggle mute state if browser is lazy.
|
||||
if (!this.linkedPanel) {
|
||||
return;
|
||||
}
|
||||
|
||||
let tabContainer = this.parentNode;
|
||||
let browser = this.linkedBrowser;
|
||||
let modifiedAttrs = [];
|
||||
|
@ -1866,12 +1861,18 @@
|
|||
this.finishMediaBlockTimer();
|
||||
} else {
|
||||
if (browser.audioMuted) {
|
||||
if (this.linkedPanel) {
|
||||
+ //"Lazy Browser" should not invoke its unmute method
|
||||
browser.unmute();
|
||||
}
|
||||
this.removeAttribute("muted");
|
||||
BrowserUITelemetry.countTabMutingEvent("unmute", aMuteReason);
|
||||
hist.add(1 /* unmute */);
|
||||
} else {
|
||||
if (this.linkedPanel) {
|
||||
+ //"Lazy Browser" should not invoke its unmute method
|
||||
browser.mute();
|
||||
}
|
||||
this.setAttribute("muted", "true");
|
||||
BrowserUITelemetry.countTabMutingEvent("mute", aMuteReason);
|
||||
hist.add(0 /* mute */);
|
||||
|
|
|
@ -35,3 +35,4 @@ skip-if = (debug && os == 'mac') || (debug && os == 'linux' && bits == 64) #Bug
|
|||
[browser_visibleTabs_bookmarkAllTabs.js]
|
||||
[browser_visibleTabs_contextMenu.js]
|
||||
[browser_open_newtab_start_observer_notification.js]
|
||||
[browser_bug_1387976_restore_lazy_tab_browser_muted_state.js]
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
const { TabState } = ChromeUtils.import("resource:///modules/sessionstore/TabState.jsm", {});
|
||||
|
||||
/**
|
||||
* Simulate a restart of a tab by removing it, then add a lazy tab
|
||||
* which is restored with the tabData of the removed tab.
|
||||
*
|
||||
* @param tab
|
||||
* The tab to restart.
|
||||
* @return {Object} the restored lazy tab
|
||||
*/
|
||||
const restartTab = async function(tab) {
|
||||
let tabData = TabState.clone(tab);
|
||||
BrowserTestUtils.removeTab(tab);
|
||||
|
||||
let restoredLazyTab = BrowserTestUtils.addTab(gBrowser, "", {createLazyBrowser: true});
|
||||
SessionStore.setTabState(restoredLazyTab, JSON.stringify(tabData));
|
||||
return restoredLazyTab;
|
||||
};
|
||||
|
||||
function get_tab_state(tab) {
|
||||
const ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
|
||||
return JSON.parse(ss.getTabState(tab));
|
||||
}
|
||||
|
||||
add_task(async function() {
|
||||
const tab = BrowserTestUtils.addTab(gBrowser, "http://mochi.test:8888/");
|
||||
const browser = gBrowser.getBrowserForTab(tab);
|
||||
await BrowserTestUtils.browserLoaded(browser);
|
||||
|
||||
// Let's make sure the tab is not in a muted state at the beginning
|
||||
ok(!("muted" in get_tab_state(tab)), "Tab should not be in a muted state");
|
||||
|
||||
info("toggling Muted audio...");
|
||||
tab.toggleMuteAudio();
|
||||
|
||||
ok("muted" in get_tab_state(tab), "Tab should be in a muted state");
|
||||
|
||||
info("Restarting tab...");
|
||||
let restartedTab = await restartTab(tab);
|
||||
|
||||
ok("muted" in get_tab_state(restartedTab), "Restored tab should still be in a muted state after restart");
|
||||
|
||||
BrowserTestUtils.removeTab(restartedTab);
|
||||
});
|
Загрузка…
Ссылка в новой задаче