// 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, 2, "Field Xrays work"); is(bound.objectField.bar.a, 1, "Field Xrays work on objects"); is(bound.contentField.foo, 10, "Field Xrays work on content objects"); var hole = bound.contentField.rabbit.hole; is(hole.win, window, "We gain back Xray vision when hitting a native object"); ok(Cu.isXrayWrapper(hole.win), "Really is Xray"); // 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.primitiveField, 321, "Can't do anything about redefined fields"); SimpleTest.finish(); } // Hand things off to content. Content will call us back. win.go(); 2 ({ foo: 2, bar: {a: 1} }) XPCNativeWrapper.unwrap(window).contentVal
return "method:" + arg;
return this._prop; this._prop = "set:" + val;
Mozilla Bug 821850

Bound element
Bound element