// Store a property as an expando on the bound element. this._prop = "propVal"; // Wait for both constructors to fire. window.constructorCount = (window.constructorCount + 1) || 1; if (window.constructorCount != 2) return; // Grab some basic infrastructure off the content window. var win = XPCNativeWrapper.unwrap(window); SpecialPowers = win.SpecialPowers; Cu = SpecialPowers.Cu; is = win.is; ok = win.ok; SimpleTest = win.SimpleTest; // Stick some expandos on the content window. window.xrayExpando = 3; win.primitiveExpando = 11; win.stringExpando = "stringExpando"; win.objectExpando = { foo: 12 }; win.globalExpando = SpecialPowers.unwrap(Cu.getGlobalForObject({})); win.functionExpando = function() { return "called" }; win.functionExpando.prop = 2; // Make sure we're Xraying. ok(Cu.isXrayWrapper(window), "Window is Xrayed"); ok(Cu.isXrayWrapper(document), "Document is Xrayed"); var bound = document.getElementById('bound'); ok(bound, "bound is non-null"); is(bound.method('baz'), "method:baz", "Xray methods work"); is(bound.prop, "propVal", "Property Xrays work"); is(bound.primitiveField, undefined, "Xrays don't show fields"); is(bound.wrappedJSObject.primitiveField, 2, "Waiving Xrays show fields"); // Check that here document.QueryInterface works ok("QueryInterface" in document, "Should have a document.QueryInterface here"); is(document.QueryInterface(Components.interfaces.nsIDOMDocument), document, "Should be able to QI the document"); // This gets invoked by an event handler. window.finish = function() { // Content messed with stuff. Make sure we still see the right thing. is(bound.method('bay'), "method:bay", "Xray methods work"); is(bound.wrappedJSObject.method('bay'), "hah", "Xray waived methods work"); is(bound.prop, "set:someOtherVal", "Xray props work"); is(bound.wrappedJSObject.prop, "redefined", "Xray waived props work"); is(bound.wrappedJSObject.primitiveField, 321, "Can't do anything about redefined fields"); SimpleTest.finish(); } // Hand things off to content. Content will call us back. win.go(); 2 return "method:" + arg; is(typeof arg.prop, 'undefined', "No properties"); is(Object.getOwnPropertyNames(arg).length, 0, "Should have no own properties"); try { arg.foo = 2; ok(true, "Stuff fails silently"); } catch (e) { ok(false, "Stuff should fail silently"); } is(typeof arg.foo, 'undefined', "Shouldn't place props"); return this._prop; this._prop = "set:" + val; Mozilla Bug 821850

Bound element
Bound element