toolkit/devtools/server/tests/mochitest/test_unsafeDereference.html

branch
TOR_BUG_3246
changeset 7
129ffea94266
equal deleted inserted replaced
-1:000000000000 0:1e616a12a975
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=837723
5
6 When we use Debugger.Object.prototype.unsafeDereference to get a non-D.O
7 reference to a content object in chrome, that reference should be via an
8 xray wrapper.
9 -->
10 <head>
11 <meta charset="utf-8">
12 <title>Mozilla Bug 837723</title>
13 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
14 <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
15 </head>
16 <body>
17 <pre id="test">
18 <script>
19
20 Components.utils.import("resource://gre/modules/jsdebugger.jsm");
21 addDebuggerToGlobal(this);
22
23 window.onload = function () {
24 SimpleTest.waitForExplicitFinish();
25
26 var iframe = document.createElement("iframe");
27 iframe.src = "http://mochi.test:8888/chrome/toolkit/devtools/server/tests/mochitest/nonchrome_unsafeDereference.html";
28
29 iframe.onload = function () {
30 var dbg = new Debugger;
31 var contentDO = dbg.addDebuggee(iframe.contentWindow);
32 var xhrDesc = contentDO.getOwnPropertyDescriptor('xhr');
33
34 isnot(xhrDesc, undefined, "xhr should be visible as property of content global");
35 isnot(xhrDesc.value, undefined, "xhr should have a value");
36
37 var xhr = xhrDesc.value.unsafeDereference();
38
39 is(typeof xhr, "object", "we should be able to deference xhr's value's D.O");
40 is(xhr.timeout, 1742, "chrome should see the xhr's 'timeout' property");
41 is(xhr.expando, undefined, "chrome should not see the xhr's 'expando' property");
42
43 SimpleTest.finish();
44 }
45
46 document.body.appendChild(iframe);
47 }
48
49 </script>
50 </pre>
51 </body>
52 </html>

mercurial