|
1 <head> |
|
2 <title>GC race with actors on the parent</title> |
|
3 |
|
4 <script type="text/javascript" |
|
5 src="/tests/SimpleTest/SimpleTest.js"></script> |
|
6 <script type="text/javascript" src="utils.js"></script> |
|
7 <link rel="stylesheet" type="text/css" |
|
8 href="/tests/SimpleTest/test.css" /> |
|
9 <body onload="start()"> |
|
10 <p id="display"></p> |
|
11 |
|
12 <script class="testbody" type="application/javascript"> |
|
13 SimpleTest.waitForExplicitFinish(); |
|
14 setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED); |
|
15 |
|
16 function start() { |
|
17 if (!SimpleTest.testPluginIsOOP()) { |
|
18 ok(true, "Skipping this test when test plugin is not OOP."); |
|
19 SimpleTest.finish(); |
|
20 return; |
|
21 } |
|
22 else { |
|
23 if (navigator.platform.startsWith("Win")) { |
|
24 SimpleTest.expectAssertions(0, 350); |
|
25 } |
|
26 |
|
27 setTimeout(checkGCRace, 1000); |
|
28 } |
|
29 } |
|
30 |
|
31 var nested = false; |
|
32 |
|
33 function cb(f) { |
|
34 ok(!nested, "Callback shouldn't occur in a nested stack frame"); |
|
35 try { |
|
36 f(35); |
|
37 ok(true, "Callback was called, no crash"); |
|
38 } |
|
39 catch (e) { |
|
40 ok(false, "Exception calling callback object: " + e); |
|
41 } |
|
42 SimpleTest.executeSoon(removePlugin); |
|
43 } |
|
44 |
|
45 function removePlugin() { |
|
46 var p = document.getElementById('p'); |
|
47 p.parentNode.removeChild(p); |
|
48 p = null; |
|
49 SpecialPowers.Cu.forceGC(); |
|
50 SimpleTest.finish(); |
|
51 } |
|
52 |
|
53 function checkGCRace() { |
|
54 nested = true; |
|
55 |
|
56 // The plugin will hand back a function and immediately sleep. |
|
57 // We will lose our only reference to the function and force GC, followed |
|
58 // by calling us with that function object again. We should be able to |
|
59 // call the function and not crash. |
|
60 var p = document.getElementById('p'); |
|
61 var f = p.checkGCRace(cb); |
|
62 f = null; // 'f' should be collected next GC |
|
63 |
|
64 nested = false; |
|
65 |
|
66 setTimeout(function() { |
|
67 SpecialPowers.Cu.forceGC(); |
|
68 }, 2000); |
|
69 } |
|
70 </script> |
|
71 |
|
72 <embed id="p" type="application/x-test" wmode="window"></embed> |