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