test_plugin_freezing.html (1438B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <title>Test for plugin freezing and thawing</title> 5 <script src="/tests/SimpleTest/SimpleTest.js"></script> 6 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 7 </head> 8 <body> 9 <div id="content" style="display: none"> 10 </div> 11 <embed id='e1' type='application/x-test'></embed> 12 <script> 13 var e1 = document.getElementById('e1'); 14 var w; 15 16 var testIndex = 0; 17 var tests; 18 19 window.addEventListener("unload", function() { 20 e1.stopWatchingInstanceCount(); 21 }); 22 23 function nextTest() { 24 if (testIndex == tests.length) { 25 if (w) { 26 w.close(); 27 } 28 SimpleTest.waitForFocus(function() { 29 SimpleTest.finish(); 30 }); 31 return; 32 } 33 34 var test = tests[testIndex]; 35 ++testIndex; 36 test(); 37 } 38 39 function waitForInstanceCount(n) { 40 if (e1.getInstanceCount() == n) { 41 ok(true, "reached instance count " + n); 42 nextTest(); 43 return; 44 } 45 setTimeout(function() { waitForInstanceCount(n); }, 0); 46 } 47 48 tests = [ 49 function() { waitForInstanceCount(1); }, 50 function() { w.location.href = "about:blank"; 51 waitForInstanceCount(0); }, 52 ]; 53 54 try { 55 e1.startWatchingInstanceCount(); 56 var w = window.open("data:text/html,<embed id='e2' type='application/x-test'></embed>"); 57 SimpleTest.waitForFocus(nextTest, w); 58 SimpleTest.waitForExplicitFinish(); 59 } catch (err) { 60 todo(false, "Instances already being watched?"); 61 } 62 63 </script> 64 <pre id="test"> 65 </pre> 66 </body> 67 </html>