Results in:
Fired DOMContentLoaded!
Target!
Fired DOMContentLoaded!
Target!
Fired DOMContentLoaded!
Target!
Fired DOMContentLoaded!
Target!
Fired DOMContentLoaded!
Target!
Fired inline!
Fired DOMContentLoaded!
Target!
Fired onload!
The order seems to be:
1. inline
2. DOMContentLoaded
3. onload=""
So inline code should be in place... However line 14 in the JS code
results in
"Error: event.originalTarget.defaultView.whopzer is not a function"
If I try to do the same in JSShell with a globalevent (var globalevent
outside and globalevent = event inside) and do
globalevent.originalTarget.defaultView.whopzer("test\n") then it dumps
"Fired test\n"
So alright, I go ahead a put EventListeners on the doc at line 12
(#document) and 13 (<window>). These doesn't fire at all.
Any ideas to getting the inline function whopzer fired from the addon?
event.originalTarget.defaultView.whopzer("direct addon!\n");
Issue window.dump(event.originalTarget.defaultView);
I guess you'll see a wrapped window.
jjb
This is what I got. Text after # are my comments and not part of the
actual output
test loaded! # The test code is started
Fired inline # That is from previous
Fired DOMContentLoaded! # That is same from previous code
Found Target As [object XPCNativeWrapper [object Window]]! # This is
the previous dump("Target!") changed to: dump("Found Target As
"+event.originalTarget.defaultView+"!\n");
Fired onload # That is the same from previous code
# At this point the document is fully loaded and nothing else happens.
[object Window] # I open JavaScript Shell (from the developer
extension) and type in
window.dump(globalevent.originalTarget.defaultView)
What I see is that the event.originalTarget.defaultView from when the
code is running is changed from [object XPCNativeWrapper [object
Window]] to [object Window].
It seems the XPCNativeWrapper was the way to go looking. Found this:
http://developer.mozilla.org/en/Chrome_Registration#xpcnativewrappers
All the [object XPCNativeWrapper [object Window]] became [object
Window] :-)
I'm not following all of what you are saying, but when you get Window
objects in extensions they can be wrapped in two ways. XPCNativeWrapper
or XPCSafeJSObjectWrapper (or some such). Since I can't tell which I
will get, I've started to add tests like
if (obj.wrappedJSObject)
var unwrapped = obj.wrappedJSObject;
else
var unwrapped = obj;
I guess you got one of each.
jjb
hmm, I don't see the wrappedJSObject on the window. Could it be
because of the XPCNativeWrapper is changed quickly after the window is
done loading everything that its removed?