mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 961106 - Remove observers on frame script unload r=billm
From 173bf18bbcfc0e2a2f2637471b1e61d2115c7e67 Mon Sep 17 00:00:00 2001
This commit is contained in:
parent
c23918343f
commit
7b6be55d2d
@ -342,11 +342,16 @@ let FormDataListener = {
|
||||
*/
|
||||
let PageStyleListener = {
|
||||
init: function () {
|
||||
Services.obs.addObserver(this, "author-style-disabled-changed", true);
|
||||
Services.obs.addObserver(this, "style-sheet-applicable-state-changed", true);
|
||||
Services.obs.addObserver(this, "author-style-disabled-changed", false);
|
||||
Services.obs.addObserver(this, "style-sheet-applicable-state-changed", false);
|
||||
gFrameTree.addObserver(this);
|
||||
},
|
||||
|
||||
uninit: function () {
|
||||
Services.obs.removeObserver(this, "author-style-disabled-changed");
|
||||
Services.obs.removeObserver(this, "style-sheet-applicable-state-changed");
|
||||
},
|
||||
|
||||
observe: function (subject, topic) {
|
||||
let frame = subject.defaultView;
|
||||
|
||||
@ -367,8 +372,7 @@ let PageStyleListener = {
|
||||
MessageQueue.push("pageStyle", () => null);
|
||||
},
|
||||
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver,
|
||||
Ci.nsISupportsWeakReference])
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver])
|
||||
};
|
||||
|
||||
/**
|
||||
@ -419,10 +423,14 @@ let DocShellCapabilitiesListener = {
|
||||
let SessionStorageListener = {
|
||||
init: function () {
|
||||
addEventListener("MozStorageChanged", this);
|
||||
Services.obs.addObserver(this, "browser:purge-domain-data", true);
|
||||
Services.obs.addObserver(this, "browser:purge-domain-data", false);
|
||||
gFrameTree.addObserver(this);
|
||||
},
|
||||
|
||||
uninit: function () {
|
||||
Services.obs.removeObserver(this, "browser:purge-domain-data");
|
||||
},
|
||||
|
||||
handleEvent: function (event) {
|
||||
// Ignore events triggered by localStorage or globalStorage changes.
|
||||
if (gFrameTree.contains(event.target) && isSessionStorageEvent(event)) {
|
||||
@ -450,8 +458,7 @@ let SessionStorageListener = {
|
||||
this.collect();
|
||||
},
|
||||
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver,
|
||||
Ci.nsISupportsWeakReference])
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver])
|
||||
};
|
||||
|
||||
/**
|
||||
@ -656,3 +663,13 @@ SessionStorageListener.init();
|
||||
ScrollPositionListener.init();
|
||||
DocShellCapabilitiesListener.init();
|
||||
PrivacyListener.init();
|
||||
|
||||
addEventListener("unload", () => {
|
||||
// Remove all registered nsIObservers.
|
||||
PageStyleListener.uninit();
|
||||
SessionStorageListener.uninit();
|
||||
|
||||
// We don't need to take care of any gFrameTree observers as the gFrameTree
|
||||
// will die with the content script. The same goes for the privacy transition
|
||||
// observer that will die with the docShell when the tab is closed.
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user