[Pkg-mozext-commits] [adblock-plus] 27/98: Issue 4253 - Implement a less fragile way to detect documents that element hiding needs to apply to
David Prévot
taffit at moszumanska.debian.org
Tue Oct 24 01:30:15 UTC 2017
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository adblock-plus.
commit ceeac8c37d1301b60af12fec520774662c83d4a6
Author: Wladimir Palant <trev at adblockplus.org>
Date: Tue Jul 19 19:35:47 2016 +0200
Issue 4253 - Implement a less fragile way to detect documents that element hiding needs to apply to
---
lib/child/elemHide.js | 37 +++++++++++++++++--------------------
1 file changed, 17 insertions(+), 20 deletions(-)
diff --git a/lib/child/elemHide.js b/lib/child/elemHide.js
index 24269c8..bc55810 100644
--- a/lib/child/elemHide.js
+++ b/lib/child/elemHide.js
@@ -302,7 +302,7 @@ let observer = {
Ci.nsIObserver, Ci.nsISupportsWeakReference
]),
- topic: "content-document-global-created",
+ topic: "document-element-inserted",
styleURL: Utils.makeURI("about:abp-elemhide?css"),
sheet: null,
@@ -325,32 +325,29 @@ let observer = {
if (topic != this.topic)
return;
- if (subject.document.readyState == "uninitialized")
+ let window = subject.defaultView;
+ if (!window)
{
- // It would be nice to listen to the readystatechange event here. However,
- // adding event listeners on uninitialized documents isn't possible. So
- // we listen for DOMContentLoaded and beforescriptexecute - whichever
- // fires first.
- let listener = () =>
- {
- subject.removeEventListener("DOMContentLoaded", listener);
- subject.removeEventListener("beforescriptexecute", listener);
- this.observe(subject, topic, data);
- };
- subject.addEventListener("DOMContentLoaded", listener);
- subject.addEventListener("beforescriptexecute", listener);
+ // This is typically XBL bindings and SVG images, but also real
+ // documents occasionally - probably due to speculative loading?
return;
}
+ let type = window.QueryInterface(Ci.nsIInterfaceRequestor)
+ .getInterface(Ci.nsIWebNavigation)
+ .QueryInterface(Ci.nsIDocShellTreeItem)
+ .itemType;
+ if (type != Ci.nsIDocShellTreeItem.typeContent)
+ return;
port.emitWithResponse("elemhideEnabled", {
- frames: getFrames(subject),
- isPrivate: isPrivate(subject)
+ frames: getFrames(window),
+ isPrivate: isPrivate(window)
}).then(({
enabled, contentType, docDomain, thirdParty, location, filter,
filterType
}) =>
{
- if (Cu.isDeadWrapper(subject))
+ if (Cu.isDeadWrapper(window))
{
// We are too late, the window is gone already.
return;
@@ -364,8 +361,8 @@ let observer = {
Ci.nsIStyleSheetService.USER_SHEET);
}
- let utils = subject.QueryInterface(Ci.nsIInterfaceRequestor)
- .getInterface(Ci.nsIDOMWindowUtils);
+ let utils = window.QueryInterface(Ci.nsIInterfaceRequestor)
+ .getInterface(Ci.nsIDOMWindowUtils);
try
{
utils.addSheet(this.sheet, Ci.nsIStyleSheetService.USER_SHEET);
@@ -381,7 +378,7 @@ let observer = {
}
else if (filter)
{
- RequestNotifier.addNodeData(subject.document, subject.top, {
+ RequestNotifier.addNodeData(window.document, window.top, {
contentType, docDomain, thirdParty, location, filter, filterType
});
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/adblock-plus.git
More information about the Pkg-mozext-commits
mailing list