1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/base/test/test_plugin_freezing.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,68 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<head> 1.7 + <title>Test for plugin freezing and thawing</title> 1.8 + <script type="text/javascript" src="/MochiKit/MochiKit.js"></script> 1.9 + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.10 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 1.11 +</head> 1.12 +<body> 1.13 +<div id="content" style="display: none"> 1.14 +</div> 1.15 +<embed id='e1' type='application/x-test'></embed> 1.16 +<script> 1.17 +var e1 = document.getElementById('e1'); 1.18 +var w; 1.19 + 1.20 +var testIndex = 0; 1.21 +var tests; 1.22 + 1.23 +window.addEventListener("unload", function() { 1.24 + e1.stopWatchingInstanceCount(); 1.25 +}, false); 1.26 + 1.27 +function nextTest() { 1.28 + if (testIndex == tests.length) { 1.29 + if (w) { 1.30 + w.close(); 1.31 + } 1.32 + SimpleTest.waitForFocus(function() { 1.33 + SimpleTest.finish(); 1.34 + }); 1.35 + return; 1.36 + } 1.37 + 1.38 + var test = tests[testIndex]; 1.39 + ++testIndex; 1.40 + test(); 1.41 +} 1.42 + 1.43 +function waitForInstanceCount(n) { 1.44 + if (e1.getInstanceCount() == n) { 1.45 + ok(true, "reached instance count " + n); 1.46 + nextTest(); 1.47 + return; 1.48 + } 1.49 + setTimeout(function() { waitForInstanceCount(n); }, 0); 1.50 +} 1.51 + 1.52 +tests = [ 1.53 + function() { waitForInstanceCount(1); }, 1.54 + function() { w.location.href = "about:blank"; 1.55 + waitForInstanceCount(0); }, 1.56 +]; 1.57 + 1.58 +try { 1.59 + e1.startWatchingInstanceCount(); 1.60 + var w = window.open("data:text/html,<embed id='e2' type='application/x-test'></embed>"); 1.61 + SimpleTest.waitForFocus(nextTest, w); 1.62 + SimpleTest.waitForExplicitFinish(); 1.63 +} catch (err) { 1.64 + todo(false, "Instances already being watched?"); 1.65 +} 1.66 + 1.67 +</script> 1.68 +<pre id="test"> 1.69 +</pre> 1.70 +</body> 1.71 +</html>