1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/plugins/test/mochitest/test_GCrace.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,72 @@ 1.4 +<head> 1.5 + <title>GC race with actors on the parent</title> 1.6 + 1.7 + <script type="text/javascript" 1.8 + src="/tests/SimpleTest/SimpleTest.js"></script> 1.9 + <script type="text/javascript" src="utils.js"></script> 1.10 + <link rel="stylesheet" type="text/css" 1.11 + href="/tests/SimpleTest/test.css" /> 1.12 +<body onload="start()"> 1.13 + <p id="display"></p> 1.14 + 1.15 + <script class="testbody" type="application/javascript"> 1.16 + SimpleTest.waitForExplicitFinish(); 1.17 + setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED); 1.18 + 1.19 + function start() { 1.20 + if (!SimpleTest.testPluginIsOOP()) { 1.21 + ok(true, "Skipping this test when test plugin is not OOP."); 1.22 + SimpleTest.finish(); 1.23 + return; 1.24 + } 1.25 + else { 1.26 + if (navigator.platform.startsWith("Win")) { 1.27 + SimpleTest.expectAssertions(0, 350); 1.28 + } 1.29 + 1.30 + setTimeout(checkGCRace, 1000); 1.31 + } 1.32 + } 1.33 + 1.34 + var nested = false; 1.35 + 1.36 + function cb(f) { 1.37 + ok(!nested, "Callback shouldn't occur in a nested stack frame"); 1.38 + try { 1.39 + f(35); 1.40 + ok(true, "Callback was called, no crash"); 1.41 + } 1.42 + catch (e) { 1.43 + ok(false, "Exception calling callback object: " + e); 1.44 + } 1.45 + SimpleTest.executeSoon(removePlugin); 1.46 + } 1.47 + 1.48 + function removePlugin() { 1.49 + var p = document.getElementById('p'); 1.50 + p.parentNode.removeChild(p); 1.51 + p = null; 1.52 + SpecialPowers.Cu.forceGC(); 1.53 + SimpleTest.finish(); 1.54 + } 1.55 + 1.56 + function checkGCRace() { 1.57 + nested = true; 1.58 + 1.59 + // The plugin will hand back a function and immediately sleep. 1.60 + // We will lose our only reference to the function and force GC, followed 1.61 + // by calling us with that function object again. We should be able to 1.62 + // call the function and not crash. 1.63 + var p = document.getElementById('p'); 1.64 + var f = p.checkGCRace(cb); 1.65 + f = null; // 'f' should be collected next GC 1.66 + 1.67 + nested = false; 1.68 + 1.69 + setTimeout(function() { 1.70 + SpecialPowers.Cu.forceGC(); 1.71 + }, 2000); 1.72 + } 1.73 + </script> 1.74 + 1.75 + <embed id="p" type="application/x-test" wmode="window"></embed>