Skip to content
This repository has been archived by the owner on May 12, 2020. It is now read-only.

Incorrect document element #8

Closed
djl opened this issue Jul 14, 2011 · 16 comments
Closed

Incorrect document element #8

djl opened this issue Jul 14, 2011 · 16 comments

Comments

@djl
Copy link
Contributor

djl commented Jul 14, 2011

While jumping between Chrome and Firefox I noticed that some custom JS scripts I run were not working correctly in Firefox.

Turns out the document element isn't actually a real document object. Instead of returning the expected HTMLDocument object, it returns [object XrayWrapper [object HTMLDocument]].

Is there any way to have document refer to the real HTMLDocument object?

@rlr
Copy link
Owner

rlr commented Jul 14, 2011

I noticed this weirdness too but was hoping everything would just work... I guess not. Can you provide a minimal snippet of code that fails due to this so I can try a few things out? Thanks.

@djl
Copy link
Contributor Author

djl commented Jul 14, 2011

Sure. Here's the snippet that tipped me off:

document.onkeydown = null;

@rlr
Copy link
Owner

rlr commented Jul 14, 2011

Strange thing is if I just do alert(document); it shows [object HTMLDocument] :-/

@rlr
Copy link
Owner

rlr commented Jul 14, 2011

This also works:

document.onclick = function() {
    alert('click');
}

(I am on version 0.9 which just got approved yesterday)

@djl
Copy link
Contributor Author

djl commented Jul 14, 2011

Well I'm lost. I'm also on 0.9 and doing alert(document); shows this for every page:

broke

I'll keep looking into what's going on. It'll probably be a problem on my side.

@rlr
Copy link
Owner

rlr commented Jul 14, 2011

oh now that is really weird :(

oh wait, what version of Firefox are you on? Mac?

@rlr
Copy link
Owner

rlr commented Jul 14, 2011

Oooh, I do get that with Firefox 5... I was testing on Aurora... INTERESTING!

@djl
Copy link
Contributor Author

djl commented Jul 14, 2011

I'm on Firefox 5.0.1, OS X.

Aha! It doesn't happen on Aurora. Maybe it was an upstream problem?

Ninja edit: you're too quick for me!

@yvesvanbroekhoven
Copy link

Hi guys,

I have the same problem with FF 5 on Mac with the following snippet:

$("select").change(function(){
  window.location  = "http://google.com"
});

I also get the XrayWrapper object instead of the normal:

Alt text

Any ideas how to fix this?

@rlr
Copy link
Owner

rlr commented Jul 20, 2011

I experimented a little but wasn't able to get the object out of the wrapper. I'll try to find help.

@hablutzel1
Copy link

It unwraps and exposes the real object

var realObject= XPCNativeWrapper.unwrap(wrappedObject);

@rlr
Copy link
Owner

rlr commented Jul 21, 2011

Thanks @skarootz, I'll give that a try!

@rlr
Copy link
Owner

rlr commented Jul 22, 2011

@skarootz That doesn't seem to be working for me.

alert(document);
alert(XPCNativeWrapper.unwrap(document));

shows [object XrayWrapper [object HTMLDocument]] in both cases :(

@hablutzel1
Copy link

Not sure about the reason, I found that solution when I was trying to access
a DOM Object from a greasemonkey script (firefox 4).

On Fri, Jul 22, 2011 at 8:44 AM, rlr <
reply@reply.github.com>wrote:

@skarootz That doesn't seem to be working for me.

alert(document);
alert(XPCNativeWrapper.unwrap(document));

shows [object XrayWrapper [object HTMLDocument]] in both cases :(

Reply to this email directly or view it on GitHub:
#8 (comment)

Jaime Hablutzel - 9-9956-3299

(tildes omitidas intencionalmente)

@yvesvanbroekhoven
Copy link

Hi guys,

I have found documentation about this on https://developer.mozilla.org/en/XPCNativeWrapper.

Now, I got console.log working in a quick example, needs to be wrapped in a check of course

// Normally, you can access console.log just like this
window.console.log("this should not work");

// But now we need a work around
_window = new XPCNativeWrapper(content, "window");
_window = _window.wrappedJSObject
_window.console.log("this should work");
_window.console.log(_window.location.hostname);

Hope we can narrow this down to a fix :)

rlr added a commit that referenced this issue Jul 27, 2011
@rlr
Copy link
Owner

rlr commented Jul 27, 2011

Yay, thanks @yvesvanbroekhoven! I think that fixes it ^^

@rlr rlr closed this as completed Jul 27, 2011
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants