Bug 1915045 Ensure decode tasks are scheduled on BufferingState::Enter() r=media...
[gecko.git] / js / xpconnect / tests / chrome / test_windowProxyDeadWrapper.html
blob234a38ebeb535d373f94f21ac84cbf22cb58f897
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=1223372
5 -->
6 <head>
7 <meta charset="utf-8">
8 <title>Test for Bug 1223372</title>
9 <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
10 <link rel="stylesheet" type="text/css" href="chrome://global/skin"/>
11 <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
12 <script type="application/javascript">
14 /** Test for Bug 1223372 **/
15 const {TestUtils} = ChromeUtils.importESModule(
16 "resource://testing-common/TestUtils.sys.mjs"
19 async function go() {
20 SimpleTest.waitForExplicitFinish();
21 await SpecialPowers.pushPrefEnv({"set": [["security.allow_eval_with_system_principal",
22 true]]});
24 var frame = $('subframe');
25 frame.onload = null;
27 var w = frame.contentWindow;
29 w.eval("checkDead = function() { return Components.utils.isDeadWrapper(this); };");
30 var checkDead = w.checkDead;
32 w.eval("getObject = function() { return {}; }");
33 var getObject = w.getObject;
35 ok(!checkDead(), "WindowProxy shouldn't be dead yet");
37 // Load a content page in the chrome frame.
38 w.location = "https://example.org/tests/js/xpconnect/tests/mochitest/file_empty.html";
39 tryWindow();
41 function tryWindow() {
42 if (w.document.title != 'empty test page') {
43 info("Document not loaded yet - retrying");
44 SimpleTest.executeSoon(tryWindow);
45 return;
48 let winID = w.docShell.outerWindowID;
49 // Remove the frame. This will nuke the WindowProxy wrapper from our chrome
50 // document's global, so evaluating 'this' in it will return a dead wrapper
51 // once the window is destroyed.
52 frame.remove();
54 TestUtils.topicObserved("outer-window-nuked", (subject) => {
55 let id = subject.QueryInterface(Ci.nsISupportsPRUint64).data;
56 return id == winID;
57 }).then(() => {
58 ok(checkDead(), "Expected a dead object wrapper");
60 // Wrapping the Window should return a dead wrapper now.
61 var global = Cu.getGlobalForObject(getObject());
62 ok(Cu.isDeadWrapper(global),
63 "Expected a dead wrapper when requesting the window's global");
65 SimpleTest.finish();
66 });
70 </script>
71 </head>
72 <body>
73 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1223372">Mozilla Bug 1223372</a>
75 <iframe id="subframe" src="./file_empty.html" onload="go()"></iframe>
77 </body>
78 </html>