Bug 960903 - Listen for subframe loads and clear observers r=yoric

This commit is contained in:
Tim Taubert 2014-01-22 13:10:58 +01:00
Родитель a5afd2d4bf
Коммит eb267d030f
1 изменённых файлов: 13 добавлений и 7 удалений

Просмотреть файл

@ -217,8 +217,13 @@ let SyncHandler = {
let SessionHistoryListener = {
init: function () {
gFrameTree.addObserver(this);
addEventListener("load", this, true);
addEventListener("hashchange", this, true);
Services.obs.addObserver(this, "browser:purge-session-history", true);
Services.obs.addObserver(this, "browser:purge-session-history", false);
},
uninit: function () {
Services.obs.removeObserver(this, "browser:purge-session-history");
},
observe: function () {
@ -230,8 +235,11 @@ let SessionHistoryListener = {
setTimeout(() => this.collect(), 0);
},
handleEvent: function () {
this.collect();
handleEvent: function (event) {
// We are only interested in "load" events from subframes.
if (event.type == "hashchange" || event.target != content.document) {
this.collect();
}
},
collect: function () {
@ -246,10 +254,7 @@ let SessionHistoryListener = {
onFrameTreeReset: function () {
this.collect();
},
QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver,
Ci.nsISupportsWeakReference])
}
};
/**
@ -673,6 +678,7 @@ addEventListener("unload", () => {
// Remove all registered nsIObservers.
PageStyleListener.uninit();
SessionStorageListener.uninit();
SessionHistoryListener.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