2 <?xml-stylesheet href=
"chrome://global/skin" type=
"text/css"?>
3 <?xml-stylesheet href=
"chrome://mochikit/content/tests/SimpleTest/test.css"
6 https://bugzilla.mozilla.org/show_bug.cgi?id=634156
8 <window title=
"Testing API exposing capabilities"
9 xmlns=
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
10 <script src=
"chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
12 <!-- test results are displayed in the html:body -->
13 <body xmlns=
"http://www.w3.org/1999/xhtml">
14 <a href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=634156"
15 target=
"_blank">Mozilla Bug
634156</a>
18 <!-- test code goes here -->
19 <script type=
"application/javascript"><![CDATA[
20 var sandbox = new Cu.Sandbox(
"about:blank");
23 Cu.evalInSandbox(
"Object.defineProperty(Object.prototype, 'getProp', { get: function() { throw 'FAIL: called getter' }, set: function() { throw 'FAIL: called setter'; } })", sandbox);
25 var obj = Cu.createObjectIn(sandbox);
26 is(obj, Cu.waiveXrays(obj),
"createObjectIn waives");
27 is(Object.getPrototypeOf(obj), Cu.waiveXrays(Cu.evalInSandbox(
"Object.prototype", sandbox)),
28 "Object is a sandbox object");
30 function genPropDesc(value) {
31 return { enumerable: true, configurable: true, writable: true,
35 'getProp': genPropDesc(function() { ok(true,
"called prop that shadowed a getter"); }),
36 'argument': genPropDesc(function(arg) { is(arg,
42,
"can pass arguments through"); }),
37 'returnval': genPropDesc(function() { return
42; })
39 Object.defineProperties(obj, props);
40 Cu.makeObjectPropsNormal(obj);
43 Cu.evalInSandbox(
"ok(Object.getPrototypeOf(api) === Object.prototype, 'we have the object we expected'); \
44 api.getProp(); api.argument(42); is(api.returnval(), 42, 'return value was correct');\
45 ok(typeof api.getProp === 'function', 'functions are functions');\
46 ok(Object.getPrototypeOf(api.getProp) === Function.prototype, 'functions come from our scope');", sandbox);