devtools/server/tests/mochitest/test_Debugger.Script.prototype.global.html
author Kris Maglione <maglione.k@gmail.com>
Wed, 24 Jan 2018 15:48:47 -0800
changeset 453235 d4a7c018420e408fbe0a13ffddd2861623fda5a7
parent 396499 1f17eeabf363349bd01b0c6c4edfaf58ade60c6e
child 453238 cc87ad81ff86109c7ea0187424fa9a8ed3b4af6c
permissions -rw-r--r--
Bug 1431533: Part 5a - Auto-rewrite code to use ChromeUtils import methods. r=florian MozReview-Commit-ID: 8V1ZT53ReiP

<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=958646

Debugger.Script.prototype.global should return innerize globals, not WindowProxies.
-->
<head>
  <meta charset="utf-8">
  <title>Debugger.Script.prototype.global should return inner windows</title>
  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
</head>
<body>
<pre id="test">
<script>
"use strict";

ChromeUtils.import("resource://gre/modules/jsdebugger.jsm");
addDebuggerToGlobal(this);

window.onload = function () {
  SimpleTest.waitForExplicitFinish();

  let iframe = document.createElement("iframe");
  iframe.src = "data:text/html,<script>function glorp() { }<\/script>";
  iframe.onload = firstOnLoadHandler;
  document.body.appendChild(iframe);

  function firstOnLoadHandler() {
    let dbg = new Debugger();
    let iframeDO = dbg.addDebuggee(iframe.contentWindow);

    // For sanity: check that the debuggee global is the inner window,
    // and that the outer window gets a distinct D.O.
    let iframeWindowProxyDO = iframeDO.makeDebuggeeValue(iframe.contentWindow);
    ok(iframeDO !== iframeWindowProxyDO);

    // The real test: Debugger.Script.prototype.global returns inner windows.
    ok(iframeDO.getOwnPropertyDescriptor("glorp").value.script.global === iframeDO);

    SimpleTest.finish();
  }
};
</script>
</pre>
</body>
</html>