Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test gets skipped with pattern: os == 'android'
- Manifest: devtools/server/tests/chrome/chrome.toml
<!DOCTYPE HTML>
<html>
<!--
When we use Debugger.Object.prototype.unsafeDereference to get a non-D.O
reference to a content object in chrome, that reference should be via an
xray wrapper.
-->
<head>
<meta charset="utf-8">
</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 = "http://mochi.test:8888/chrome/devtools/server/tests/chrome/nonchrome_unsafeDereference.html";
iframe.onload = function() {
const dbg = new Debugger();
const contentDO = dbg.addDebuggee(iframe.contentWindow);
const xhrDesc = contentDO.getOwnPropertyDescriptor("xhr");
isnot(xhrDesc, undefined, "xhr should be visible as property of content global");
isnot(xhrDesc.value, undefined, "xhr should have a value");
const xhr = xhrDesc.value.unsafeDereference();
is(typeof xhr, "object", "we should be able to deference xhr's value's D.O");
is(xhr.timeout, 1742, "chrome should see the xhr's 'timeout' property");
is(xhr.expando, undefined, "chrome should not see the xhr's 'expando' property");
SimpleTest.finish();
};
document.body.appendChild(iframe);
};
</script>
</pre>
</body>
</html>