Bug 1458383 - Don't session restore browser.mediaBlocked. r=mikedeboer
This is a backout of
Bug 1347791 part 4; 49b533231388.
49b533231388 took the mediaBlocked attribute and stored it in session store,
and caused us to call browser.resumeMedia() or blockMedia() as appropriate
upon restore. We don't want to session restore whether tabs have had delay
playback start unblocked anymore, so remove the code that session stores
that attribute.
MozReview-Commit-ID: AkRVlufrUAK
--- a/browser/base/content/tabbrowser.js
+++ b/browser/base/content/tabbrowser.js
@@ -123,17 +123,17 @@ window._gBrowser = {
"gotoIndex", "currentURI", "documentURI",
"preferences", "imageDocument", "isRemoteBrowser", "messageManager",
"getTabBrowser", "finder", "fastFind", "sessionHistory", "contentTitle",
"characterSet", "fullZoom", "textZoom", "webProgress",
"addProgressListener", "removeProgressListener", "audioPlaybackStarted",
"audioPlaybackStopped", "pauseMedia", "stopMedia",
"resumeMedia", "mute", "unmute", "blockedPopups", "lastURI",
"purgeSessionHistory", "stopScroll", "startScroll",
- "userTypedValue", "userTypedClear", "mediaBlocked",
+ "userTypedValue", "userTypedClear",
"didStartLoadSinceLastUserTyping", "audioMuted"
],
_removingTabs: [],
_multiSelectedTabsMap: new WeakMap(),
/**
@@ -1964,29 +1964,18 @@ window._gBrowser = {
// Wait for load handler to be instantiated before
// initializing the reload.
aTab.addEventListener("SSTabRestoring", () => {
browser[name](params);
}, { once: true });
gBrowser._insertBrowser(aTab);
};
break;
- case "resumeMedia":
- getter = () =>
- () => {
- // No need to insert a browser, so we just call the browser's
- // method.
- aTab.addEventListener("SSTabRestoring", () => {
- browser[name]();
- }, { once: true });
- };
- break;
case "userTypedValue":
case "userTypedClear":
- case "mediaBlocked":
getter = () => SessionStore.getLazyTabValue(aTab, name);
break;
default:
getter = () => {
if (AppConstants.NIGHTLY_BUILD) {
let message =
`[bug 1345098] Lazy browser prematurely inserted via '${name}' property access:\n`;
console.log(message + new Error().stack);
--- a/browser/components/sessionstore/SessionStore.jsm
+++ b/browser/components/sessionstore/SessionStore.jsm
@@ -3808,20 +3808,16 @@ var SessionStoreInternal = {
} else {
tabbrowser.showTab(tab);
}
if (!!tabData.muted != browser.audioMuted) {
tab.toggleMuteAudio(tabData.muteReason);
}
- if (!tabData.mediaBlocked) {
- browser.resumeMedia();
- }
-
if (tabData.lastAccessed) {
tab.updateLastAccessed(tabData.lastAccessed);
}
if ("attributes" in tabData) {
// Ensure that we persist tab attributes restored from previous sessions.
Object.keys(tabData.attributes).forEach(a => TabAttributes.persist(a));
}
--- a/browser/components/sessionstore/TabAttributes.jsm
+++ b/browser/components/sessionstore/TabAttributes.jsm
@@ -9,21 +9,18 @@ var EXPORTED_SYMBOLS = ["TabAttributes"]
// We never want to directly read or write these 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.
// 'iconloadingprincipal' is same as 'image' that it should be handled by
// using the gBrowser.getIcon()/setIcon() methods.
-// 'activemedia-blocked' should not be accessed directly but handled by using
-// tab's toggleMuteAudio() or linkedBrowser's methods
-// activeMediaBlockStarted()/activeMediaBlockBlockStopped().
const ATTRIBUTES_TO_SKIP = new Set(["image", "muted", "pending", "iconloadingprincipal",
- "skipbackgroundnotify", "activemedia-blocked"]);
+ "skipbackgroundnotify"]);
// A set of tab attributes to persist. We will read a given list of tab
// attributes when collecting tab data and will re-set those attributes when
// the given tab data is restored to a new tab.
var TabAttributes = Object.freeze({
persist(name) {
return TabAttributesInternal.persist(name);
},
--- a/browser/components/sessionstore/TabState.jsm
+++ b/browser/components/sessionstore/TabState.jsm
@@ -100,18 +100,16 @@ var TabStateInternal = {
tabData.hidden = tab.hidden;
if (browser.audioMuted) {
tabData.muted = true;
tabData.muteReason = tab.muteReason;
}
- tabData.mediaBlocked = browser.mediaBlocked;
-
// Save tab attributes.
tabData.attributes = TabAttributes.get(tab);
if (options.extData) {
tabData.extData = options.extData;
}
// Copy data from the tab state cache only if the tab has fully finished
--- a/browser/components/sessionstore/test/browser_attributes.js
+++ b/browser/components/sessionstore/test/browser_attributes.js
@@ -1,29 +1,24 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
/**
* 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', 'muted', 'activemedia-blocked' and 'pending' that need to be
+ * 'image', 'muted', and 'pending' that need to be
* handled differently or internally.
*/
const PREF = "browser.sessionstore.restore_on_demand";
-const PREF2 = "media.block-autoplay-until-in-foreground";
add_task(async function test() {
Services.prefs.setBoolPref(PREF, true);
registerCleanupFunction(() => Services.prefs.clearUserPref(PREF));
- // Since we need to test 'activemedia-blocked' attribute.
- Services.prefs.setBoolPref(PREF2, true);
- registerCleanupFunction(() => Services.prefs.clearUserPref(PREF2));
-
// Add a new tab with a nice icon.
let tab = BrowserTestUtils.addTab(gBrowser, "about:robots");
await promiseBrowserLoaded(tab.linkedBrowser);
// Because there is debounce logic in ContentLinkHandler.jsm to reduce the
// favicon loads, we have to wait some time before checking that icon was
// stored properly.
await BrowserTestUtils.waitForCondition(() => {
@@ -33,31 +28,25 @@ add_task(async function test() {
// Check that the tab has 'image' and 'iconloadingprincipal' attributes.
ok(tab.hasAttribute("image"), "tab.image exists");
ok(tab.hasAttribute("iconloadingprincipal"), "tab.iconloadingprincipal exists");
tab.toggleMuteAudio();
// Check that the tab has a 'muted' attribute.
ok(tab.hasAttribute("muted"), "tab.muted exists");
- // Pretend to start autoplay media in tab, tab should get the notification.
- tab.linkedBrowser.activeMediaBlockStarted();
- ok(tab.hasAttribute("activemedia-blocked"), "tab.activemedia-blocked exists");
-
- // Make sure we do not persist 'image','muted' and 'activemedia-blocked' attributes.
+ // Make sure we do not persist 'image' and 'muted' attributes.
ss.persistTabAttribute("image");
ss.persistTabAttribute("muted");
ss.persistTabAttribute("iconloadingprincipal");
- ss.persistTabAttribute("activemedia-blocked");
let {attributes} = JSON.parse(ss.getTabState(tab));
ok(!("image" in attributes), "'image' attribute not saved");
ok(!("iconloadingprincipal" in attributes), "'iconloadingprincipal' attribute not saved");
ok(!("muted" in attributes), "'muted' attribute not saved");
ok(!("custom" in attributes), "'custom' attribute not saved");
- ok(!("activemedia-blocked" in attributes), "'activemedia-blocked' attribute not saved");
// Test persisting a custom attribute.
tab.setAttribute("custom", "foobar");
ss.persistTabAttribute("custom");
({attributes} = JSON.parse(ss.getTabState(tab)));
is(attributes.custom, "foobar", "'custom' attribute is correct");