summaryrefslogtreecommitdiffstats
path: root/devtools/server/tests/chrome/test_Debugger.Script.prototype.global.html
blob: d403d6b4a3ba2679db5e8a1d9cd75d8a5a4138cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<!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 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";

const {addDebuggerToGlobal} = ChromeUtils.importESModule("resource://gre/modules/jsdebugger.sys.mjs");
addDebuggerToGlobal(globalThis);

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

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

  function firstOnLoadHandler() {
    const dbg = new Debugger();
    const 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.
    const 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>