Closed Bug 604430 Opened 11 years ago Closed 11 years ago

wantsXrays argument in Constructor doesn't work as expected

Categories

(DevTools :: General, defect)

defect
Not set
normal

Tracking

(blocking2.0 beta7+)

VERIFIED FIXED
Tracking Status
blocking2.0 --- beta7+

People

(Reporter: rcampbell, Assigned: mrbkap)

References

Details

Attachments

(2 files, 1 obsolete file)

Evaluating an object in the JSTerm now returns objects in the format:

[Object XrayWrapper [[Object someobject]]

Should be:

[Object someobject]
today's build: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0b8pre) Gecko/20101014 Firefox/4.0b8pre
built from:
http://hg.mozilla.org/mozilla-central/rev/ad0a0be8be74
Blocks: devtools4b8
you also get: Error: uncaught exception: [Exception... "Component is not available"  nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)"  location: "JS frame :: resource://gre/modules/PropertyPanel.jsm :: namesAndValuesOf :: line 130"  data: no]

when trying to inspect these objects:(
Just talked to mrbkap about this. he says we can ditch the __proto__ trick and add another window as an argument to evalInSandbox as well as another argument of false (or true, he is not sure which)
blocking2.0: --- → ?
Assignee: nobody → rcampbell
I'm not sure those comments apply here or in bug 599940, David. In any case, I'd already started experimenting with elimination of __proto__ and adding the helper methods directly to the sandbox.

I think this is just going to be a straight string replacement.
ok, disregard that last comment. I thought we were detecting and removing occurrences of [Object XPCWrappedJSObject [blah]] and replacing them. That appears to not be the case.

I expect fixing this and removing the withs as I'd started in bug 59940 will fix both bugs.
I've tried both true and false as arguments to the "wantXrays" parameter and neither works.

    // create a JS Sandbox out of this.context
    this.sandbox = new Cu.Sandbox(this._window,
      { sandboxPrototype: this._window, wantXrays: false });

Either I'm calling this incorrectly or it's broken.

CCing mrbkap for some consultation.
pinging mrbkap!

Does the above code snippet make sense to you?
Attached file xray-test.js
Dear mrbkap,

minimal wrapper test.

Instructions:
1. Open the Error Console on this page.
2. Copy and paste the contents of this file (appended below for easy copy'n'paste) into the Code: line in the Error Console.
3. Evaluate.

Check the value of the output for an "[object XrayWrapper" prefix. Changing the value of wantXrays to true or false makes no difference.

code:

var Cu = Components.utils;
var jsm = { };
Cu.import("resource://gre/modules/Services.jsm", jsm);
var Svcs = jsm.Services;
var gBrowser = Svcs.wm.getMostRecentWindow("navigator:browser").gBrowser;
var w = gBrowser.selectedBrowser.contentWindow;
var sb = Components.utils.Sandbox(w, { sandboxPrototype: w, wantXrays: false });
sb.$ = w.document.getElementById;
Cu.evalInSandbox("$('header');", sb, "1.8", "TEST", 1)

sincerely,
Rob M. Campbell, esq.

PS, beer me.
Attached patch Fix (obsolete) — Splinter Review
So this should fix it. It makes the sandbox object itself respect the wantXrays flag.
Assignee: rcampbell → mrbkap
Status: NEW → ASSIGNED
Attachment #485898 - Flags: review?(peterv)
Attached patch FixSplinter Review
This does s/preferXrays/wantXrays/g and also fixes a couple of strings in the mochitest.
Attachment #485898 - Attachment is obsolete: true
Attachment #485901 - Flags: review?(peterv)
Attachment #485898 - Flags: review?(peterv)
Attachment #485901 - Flags: review?(peterv) → review+
You people kill me
blocking2.0: ? → beta7+
http://hg.mozilla.org/mozilla-central/rev/1b0dcd032479
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
that fix is all the beer I require. Yummy!
for the record, this fix doesn't fix the bug of the XrayWrapper prefix in the Web Console, just going to morph the title so we don't lose it.
Summary: Object XrayWrapper prefix on returned objects in Web Console → wantsXrays argument in Constructor doesn't work as expected
verified fixed in today's nightly build using the above test case in the error console.

Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0b8pre) Gecko/20101026 Firefox/4.0b8pre
Status: RESOLVED → VERIFIED
Blocks: 599940
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.