Jens Ansorg | 2 Oct 2007 14:19
Picon
Favicon

Node cannot be used in a document other than the one in which it was created?

hi,

I hope this is the appropriate group otherwise please set a fitting 
follow-up.

Firefox3 has tightened security when dealing with different DOMs in the 
browser as I just figured out.

I have a page (A) that loads another XHTML document (B) via 
XMLHTTPRequest. After load the request.responseXML holds my xhtml 
document (B). I pick a certain node out of this document (newData) and 
insert it into the page (placeholder), like
   "placeholder.parentNode.replaceChild(newData, placeholder);"

This does work in Firefox 2 but throws the error in the subject in 
Firefox 3 nightly. Now, I do understand that there is tightened security 
and the behavior is probably right.

My Question is now: is there another way to achieve what I'm currently 
doing? How can I get parts of (B) into (A)?

thanks
Jens
Martijn | 2 Oct 2007 14:41
Picon

Re: Node cannot be used in a document other than the one in which it was created?

Hi Jens,

This was a change being made in
https://bugzilla.mozilla.org/show_bug.cgi?id=47903

See:
http://developer.mozilla.org/en/docs/DOM:document.importNode
http://developer.mozilla.org/en/docs/DOM:document.adoptNode
http://developer.mozilla.org/en/docs/Gecko_1.9_Changes_affecting_websites

for information how to solve your problem.
I hope this helps you.

Regards,
Martijn

2007/10/2, Jens Ansorg <jens <at> ja-web.de>:
> hi,
>
> I hope this is the appropriate group otherwise please set a fitting
> follow-up.
>
> Firefox3 has tightened security when dealing with different DOMs in the
> browser as I just figured out.
>
>
> I have a page (A) that loads another XHTML document (B) via
> XMLHTTPRequest. After load the request.responseXML holds my xhtml
> document (B). I pick a certain node out of this document (newData) and
> insert it into the page (placeholder), like
(Continue reading)

anand.nalya | 3 Oct 2007 14:14
Picon
Gravatar

Emulating Ctrl+Tab in Firefox

Hi,
I wanted to emulate Ctrl+Tab in javascript. I've written the following
function, but it doesn't work.

function fireCtrlTab(){
      if( window.KeyEvent ) {
          var evObj = document.createEvent('KeyEvents');
          evObj.initKeyEvent( 'keyup', true, true, window, true,
false, false, false, 9, 0 );
          window.dispatchEvent(evObj);
     }
}

Does someone have any idea??

Thanks,
Anand
Boris Zbarsky | 3 Oct 2007 16:49
Picon
Favicon

Re: Emulating Ctrl+Tab in Firefox

anand.nalya <at> gmail.com wrote:
> I wanted to emulate Ctrl+Tab in javascript. I've written the following
> function, but it doesn't work.

Are you in trusted script?

And in any case, is there a reason you're only firing keyup, and not keydown and 
keypress?

-Boris
anand.nalya | 4 Oct 2007 07:38
Picon
Gravatar

Re: Emulating Ctrl+Tab in Firefox

Hi Boris,

I'm not in a trusted script.
I need to emulate Ctrl + Tab as the javascript framework I'm using
captures all the keyevents, so Ctrl+Tab does not pass on to the
browser to switch tabs.
There is no specific reason for using keyup event, all I want is to
switch tabs when Ctrl+Tab is pressed.
Also is there some other API that I can directly use to do this
instead of manually creating this keyevent.

-Anand Nalya
Boris Zbarsky | 4 Oct 2007 07:54
Picon
Favicon

Re: Emulating Ctrl+Tab in Firefox

anand.nalya <at> gmail.com wrote:
> I'm not in a trusted script.

Then you won't be able to affect the browser UI behavior.  Events generated by 
untrusted script are ignored by the UI; otherwise you could use them to, for 
example, trigger arbitrary menu items.

> I need to emulate Ctrl + Tab as the javascript framework I'm using
> captures all the keyevents, so Ctrl+Tab does not pass on to the
> browser to switch tabs.

Yeah, that's the sort of thing that I don't think you can make work.

> Also is there some other API that I can directly use to do this
> instead of manually creating this keyevent.

A way for untrusted script to switch tabs would generally be considered a 
security hole...

-Boris
anand.nalya | 4 Oct 2007 08:23
Picon
Gravatar

Re: Emulating Ctrl+Tab in Firefox

On Oct 4, 10:54 am, Boris Zbarsky <bzbar... <at> mit.edu> wrote:
> anand.na... <at> gmail.com wrote:
> > I'm not in a trusted script.
>
> Then you won't be able to affect the browser UI behavior.  Events generated by
> untrusted script are ignored by the UI; otherwise you could use them to, for
> example, trigger arbitrary menu items.
>
> > I need to emulate Ctrl + Tab as the javascript framework I'm using
> > captures all the keyevents, so Ctrl+Tab does not pass on to the
> > browser to switch tabs.
>
> Yeah, that's the sort of thing that I don't think you can make work.
>
> > Also is there some other API that I can directly use to do this
> > instead of manually creating this keyevent.
>
> A way for untrusted script to switch tabs would generally be considered a
> security hole...
>
> -Boris

Thanks for the quick reply. Can you give me some pointers on how to do
this with trusted scripts

-Anand
Boris Zbarsky | 4 Oct 2007 08:32
Picon
Favicon

Re: Emulating Ctrl+Tab in Firefox

anand.nalya <at> gmail.com wrote:
> Thanks for the quick reply. Can you give me some pointers on how to do
> this with trusted scripts

If you're in a web page, the answer is basically "with great pain and only if 
the user trusts you to have full control over their computer".  See 
<http://www.mozilla.org/projects/security/components/signed-scripts.html>.  I 
believe you'd need the UniversalXPConnect privilege to make your events trusted.

-Boris
Jens Ansorg | 4 Oct 2007 09:51
Picon
Favicon

Re: Node cannot be used in a document other than the one in which it was created?

Martijn wrote:
> Hi Jens,
> 
> This was a change being made in
> https://bugzilla.mozilla.org/show_bug.cgi?id=47903
> 
> See:
> http://developer.mozilla.org/en/docs/DOM:document.importNode
> http://developer.mozilla.org/en/docs/DOM:document.adoptNode
> http://developer.mozilla.org/en/docs/Gecko_1.9_Changes_affecting_websites
> 
> for information how to solve your problem.
> I hope this helps you.
> 
> Regards,

yes, great.

thanks for the pointers1

Jens
anand.nalya | 5 Oct 2007 10:11
Picon
Gravatar

Re: Emulating Ctrl+Tab in Firefox

On Oct 4, 11:32 am, Boris Zbarsky <bzbar... <at> mit.edu> wrote:
>
> If you're in a web page, the answer is basically "with great pain and only if
> the user trusts you to have full control over their computer".  See
> <http://www.mozilla.org/projects/security/components/signed-scripts.html>.  I
> believe you'd need the UniversalXPConnect privilege to make your events trusted.
>
> -Boris

Hi Boris,

I'm trying a different approach to solve this problem.

Instead of creating a new event manually, can't we capture the key
event in the browser before it gets passed on to the actual
application and then send that event to the browser.

I'm able to capture the Ctrl+Tab before its passed on the application
( using a keyup event handler ).
Can u suggest how can I proceed further?

thanks
-Anand Nalya

Gmane