Calling a function from chrome addon code to none-addon code (butstill chrome location) - Mozilla
This is a discussion on Calling a function from chrome addon code to none-addon code (butstill chrome location) - Mozilla ; JS code in addon: http://pastebin.mozilla.org/551714
XUL code opened in window and processed by addon code above:
http://pastebin.mozilla.org/551717
Results in:
Fired DOMContentLoaded!
Target!
Fired DOMContentLoaded!
Target!
Fired DOMContentLoaded!
Target!
Fired DOMContentLoaded!
Target!
Fired DOMContentLoaded!
Target!
Fired inline!
Fired DOMContentLoaded!
Target!
Fired ...
-
Calling a function from chrome addon code to none-addon code (butstill chrome location)
JS code in addon: http://pastebin.mozilla.org/551714
XUL code opened in window and processed by addon code above:
http://pastebin.mozilla.org/551717
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 (). These doesn't fire at all.
Any ideas to getting the inline function whopzer fired from the addon?
-
Re: Calling a function from chrome addon code to none-addon code(but still chrome location)
fuzzyshoting@gmail.com wrote:
> JS code in addon: http://pastebin.mozilla.org/551714
....
>
> 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
-
Re: Calling a function from chrome addon code to none-addon code (butstill chrome location)
On Oct 10, 5:50*am, "John J. Barton"
wrote:
> fuzzyshot...@gmail.com wrote:
> > JS code in addon:http://pastebin.mozilla.org/551714
> ...
>
> > 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].
-
Re: Calling a function from chrome addon code to none-addon code (butstill chrome location)
On Oct 11, 3:33*am, fuzzyshot...@gmail.com wrote:
> On Oct 10, 5:50*am, "John J. Barton"
> wrote:
>
> > fuzzyshot...@gmail.com wrote:
> > > JS code in addon:http://pastebin.mozilla.org/551714
> > ...
>
> > > 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/Chro...nativewrappers
All the [object XPCNativeWrapper [object Window]] became [object
Window] :-)
-
Re: Calling a function from chrome addon code to none-addon code(but still chrome location)
fuzzyshoting@gmail.com wrote:
> On Oct 10, 5:50 am, "John J. Barton"
> wrote:
....
> 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].
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
-
Re: Calling a function from chrome addon code to none-addon code (butstill chrome location)
On Oct 11, 6:57*pm, "John J. Barton"
wrote:
> fuzzyshot...@gmail.com wrote:
> > On Oct 10, 5:50 am, "John J. Barton"
> > wrote:
> ...
> > 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].
>
> 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?