From 08c515de22d5fb8e7af8a27f7a215ebab8a66285 Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Sun, 16 Aug 2015 19:34:39 -0400 Subject: [PATCH] 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. --- .../content/test/general/browser_audioTabIcon.js | 12 ++++++++++++ browser/components/sessionstore/TabAttributes.jsm | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/browser/base/content/test/general/browser_audioTabIcon.js b/browser/base/content/test/general/browser_audioTabIcon.js index 637af85cb64..6f180ffa3fe 100644 --- a/browser/base/content/test/general/browser_audioTabIcon.js +++ b/browser/base/content/test/general/browser_audioTabIcon.js @@ -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); diff --git a/browser/components/sessionstore/TabAttributes.jsm b/browser/components/sessionstore/TabAttributes.jsm index f4ff6b0959c..6c515342430 100644 --- a/browser/components/sessionstore/TabAttributes.jsm +++ b/browser/components/sessionstore/TabAttributes.jsm @@ -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