Calling a function from chrome addon code to none-addon code (butstill chrome location)
JS code in addon: [url]http://pastebin.mozilla.org/551714[/url]
XUL code opened in window and processed by addon code above:
[url]http://pastebin.mozilla.org/551717[/url]
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?
Re: Calling a function from chrome addon code to none-addon code(but still chrome location)
[email]fuzzyshoting@gmail.com[/email] wrote:[color=blue]
> JS code in addon: [url]http://pastebin.mozilla.org/551714[/url][/color]
....[color=blue]
>
> Any ideas to getting the inline function whopzer fired from the addon?[/color]
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" <johnjbar...@johnjbarton.com>
wrote:[color=blue]
> fuzzyshot...@gmail.com wrote:[color=green]
> > JS code in addon:[url]http://pastebin.mozilla.org/551714[/url][/color]
> ...
>[color=green]
> > Any ideas to getting the inline function whopzer fired from the addon?[/color]
>
> event.originalTarget.defaultView.whopzer("direct addon!\n");
>
> Issue window.dump(event.originalTarget.defaultView);
> I guess you'll see a wrapped window.
>
> jjb[/color]
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:[color=blue]
> On Oct 10, 5:50*am, "John J. Barton" <johnjbar...@johnjbarton.com>
> wrote:
>[color=green]
> > fuzzyshot...@gmail.com wrote:[color=darkred]
> > > JS code in addon:[url]http://pastebin.mozilla.org/551714[/url][/color]
> > ...[/color]
>[color=green][color=darkred]
> > > Any ideas to getting the inline function whopzer fired from the addon?[/color][/color]
>[color=green]
> > event.originalTarget.defaultView.whopzer("direct addon!\n");[/color]
>[color=green]
> > Issue window.dump(event.originalTarget.defaultView);
> > I guess you'll see a wrapped window.[/color]
>[color=green]
> > jjb[/color]
>
> 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].[/color]
It seems the XPCNativeWrapper was the way to go looking. Found this:
[url]http://developer.mozilla.org/en/Chrome_Registration#xpcnativewrappers[/url]
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)
[email]fuzzyshoting@gmail.com[/email] wrote:[color=blue]
> On Oct 10, 5:50 am, "John J. Barton" <johnjbar...@johnjbarton.com>
> wrote:[/color]
....[color=blue]
> 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].[/color]
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" <johnjbar...@johnjbarton.com>
wrote:[color=blue]
> fuzzyshot...@gmail.com wrote:[color=green]
> > On Oct 10, 5:50 am, "John J. Barton" <johnjbar...@johnjbarton.com>
> > wrote:[/color]
> ...[color=green]
> > 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)[/color]
>[color=green]
> > 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].[/color]
>
> 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[/color]
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?