Bug 944375 - Add a new const array named TAB_OBSERVING to SessionStore.jsm and modify onTabAdd and onTabRemove to subscribe to events by iterating through this array. r=ttaubert

This commit is contained in:
John Hood 2013-12-09 12:19:15 -08:00
parent fd3ad68c10
commit 8d07c04e4b

View File

@ -78,6 +78,11 @@ const TAB_EVENTS = [
"TabUnpinned"
];
// Browser events observed.
const BROWSER_EVENTS = [
"load", "SwapDocShells", "UserTypedValueChanged"
];
// The number of milliseconds in a day
const MS_PER_DAY = 1000.0 * 60.0 * 60.0 * 24.0;
@ -1243,9 +1248,7 @@ let SessionStoreInternal = {
*/
onTabAdd: function ssi_onTabAdd(aWindow, aTab, aNoNotification) {
let browser = aTab.linkedBrowser;
browser.addEventListener("load", this, true);
browser.addEventListener("SwapDocShells", this, true);
browser.addEventListener("UserTypedValueChanged", this, true);
BROWSER_EVENTS.forEach(msg => browser.addEventListener(msg, this, true));
let mm = browser.messageManager;
MESSAGES.forEach(msg => mm.addMessageListener(msg, this));
@ -1271,9 +1274,7 @@ let SessionStoreInternal = {
*/
onTabRemove: function ssi_onTabRemove(aWindow, aTab, aNoNotification) {
let browser = aTab.linkedBrowser;
browser.removeEventListener("load", this, true);
browser.removeEventListener("SwapDocShells", this, true);
browser.removeEventListener("UserTypedValueChanged", this, true);
BROWSER_EVENTS.forEach(msg => browser.removeEventListener(msg, this, true));
let mm = browser.messageManager;
MESSAGES.forEach(msg => mm.removeMessageListener(msg, this));