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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial