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