[Pkg-mozext-commits] [greasemonkey] 08/43: [WIP] Fix listening for load events.
David Prévot
taffit at moszumanska.debian.org
Sun Feb 22 21:56:09 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository greasemonkey.
commit 74fc599fe02ebaec279a881496d8d95b6979623c
Author: Ventero <ventero at ventero.de>
Date: Tue Sep 30 18:31:07 2014 +0200
[WIP] Fix listening for load events.
---
content/framescript.js | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/content/framescript.js b/content/framescript.js
index 749657a..12e8b7f 100644
--- a/content/framescript.js
+++ b/content/framescript.js
@@ -66,6 +66,10 @@ var observer = {
if (!doc || !win) break;
+ // Listen for load event (which unlike DOMContentLoaded can't be done
+ // globally), as some documents (e.g. images) don't fire DCL.
+ win.addEventListener("load", contentLoad, true);
+
// TODO:
// Sometimes we get this notification twice with different windows but
// identical documentURI/location.href. In one of those cases, the call
@@ -85,9 +89,10 @@ var observer = {
},
contentLoad: function(aEvent) {
- if (!GM_util.getEnabled()) return;
-
var contentWin = aEvent.target.defaultView;
+ contentWin.removeEventListener("load", contentLoad, true);
+
+ if (!GM_util.getEnabled()) return;
this.runScripts('document-end', contentWin);
},
@@ -193,8 +198,10 @@ var observerService = Cc['@mozilla.org/observer-service;1']
observerService.addObserver(observer, 'document-element-inserted', false);
observerService.addObserver(observer, 'inner-window-destroyed', false);
-addEventListener("DOMContentLoaded", observer.contentLoad.bind(observer));
-addEventListener("load", observer.contentLoad.bind(observer));
+// Used for DOMContentLoaded here and load in observer.observe.
+var contentLoad = observer.contentLoad.bind(observer);
+addEventListener("DOMContentLoaded", contentLoad, true);
+
addEventListener("pagehide", observer.pagehide.bind(observer));
addEventListener("pageshow", observer.pageshow.bind(observer));
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/greasemonkey.git
More information about the Pkg-mozext-commits
mailing list