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