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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/devtools/server/tests/mochitest/test_unsafeDereference.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,52 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=837723
     1.8 +
     1.9 +When we use Debugger.Object.prototype.unsafeDereference to get a non-D.O
    1.10 +reference to a content object in chrome, that reference should be via an
    1.11 +xray wrapper.
    1.12 +-->
    1.13 +<head>
    1.14 +  <meta charset="utf-8">
    1.15 +  <title>Mozilla Bug 837723</title>
    1.16 +  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
    1.17 +  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
    1.18 +</head>
    1.19 +<body>
    1.20 +<pre id="test">
    1.21 +<script>
    1.22 +
    1.23 +Components.utils.import("resource://gre/modules/jsdebugger.jsm");
    1.24 +addDebuggerToGlobal(this);
    1.25 +
    1.26 +window.onload = function () {
    1.27 +  SimpleTest.waitForExplicitFinish();
    1.28 +
    1.29 +  var iframe = document.createElement("iframe");
    1.30 +  iframe.src = "http://mochi.test:8888/chrome/toolkit/devtools/server/tests/mochitest/nonchrome_unsafeDereference.html";
    1.31 +
    1.32 +  iframe.onload = function () {
    1.33 +    var dbg = new Debugger;
    1.34 +    var contentDO = dbg.addDebuggee(iframe.contentWindow);
    1.35 +    var xhrDesc = contentDO.getOwnPropertyDescriptor('xhr');
    1.36 +
    1.37 +    isnot(xhrDesc, undefined, "xhr should be visible as property of content global");
    1.38 +    isnot(xhrDesc.value, undefined, "xhr should have a value");
    1.39 +
    1.40 +    var xhr = xhrDesc.value.unsafeDereference();
    1.41 +
    1.42 +    is(typeof xhr, "object", "we should be able to deference xhr's value's D.O");
    1.43 +    is(xhr.timeout, 1742, "chrome should see the xhr's 'timeout' property");
    1.44 +    is(xhr.expando, undefined, "chrome should not see the xhr's 'expando' property");
    1.45 +
    1.46 +    SimpleTest.finish();
    1.47 +  }
    1.48 +
    1.49 +  document.body.appendChild(iframe);
    1.50 +}
    1.51 +
    1.52 +</script>
    1.53 +</pre>
    1.54 +</body>
    1.55 +</html>

mercurial