Index: lib/child/elemHide.js |
=================================================================== |
--- a/lib/child/elemHide.js |
+++ b/lib/child/elemHide.js |
@@ -323,22 +323,27 @@ let observer = { |
observe: function(subject, topic, data) |
{ |
if (topic != this.topic) |
return; |
if (subject.document.readyState == "uninitialized") |
{ |
// It would be nice to listen to the readystatechange event here. However, |
- // it doesn't fire when changing from "uninitialized" state. |
- Utils.runAsync(() => |
+ // adding event listeners on uninitialized documents isn't possible. So |
+ // we listen for DOMContentLoaded and beforescriptexecute - whichever |
+ // fires first. |
+ let listener = () => |
{ |
- if (!Cu.isDeadWrapper(subject)) |
- this.observe(subject, topic, data); |
- }); |
+ subject.removeEventListener("DOMContentLoaded", listener); |
+ subject.removeEventListener("beforescriptexecute", listener); |
+ this.observe(subject, topic, data); |
+ }; |
+ subject.addEventListener("DOMContentLoaded", listener); |
+ subject.addEventListener("beforescriptexecute", listener); |
Wladimir Palant
2016/07/19 16:23:25
For reference, DOMContentLoaded fires too late - w
|
return; |
} |
port.emitWithResponse("elemhideEnabled", { |
frames: getFrames(subject), |
isPrivate: isPrivate(subject) |
}).then(({ |
enabled, contentType, docDomain, thirdParty, location, filter, |