content/base/test/test_plugin_freezing.html

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:86dce12fdc0f
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 type="text/javascript" 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;
16
17 var testIndex = 0;
18 var tests;
19
20 window.addEventListener("unload", function() {
21 e1.stopWatchingInstanceCount();
22 }, false);
23
24 function nextTest() {
25 if (testIndex == tests.length) {
26 if (w) {
27 w.close();
28 }
29 SimpleTest.waitForFocus(function() {
30 SimpleTest.finish();
31 });
32 return;
33 }
34
35 var test = tests[testIndex];
36 ++testIndex;
37 test();
38 }
39
40 function waitForInstanceCount(n) {
41 if (e1.getInstanceCount() == n) {
42 ok(true, "reached instance count " + n);
43 nextTest();
44 return;
45 }
46 setTimeout(function() { waitForInstanceCount(n); }, 0);
47 }
48
49 tests = [
50 function() { waitForInstanceCount(1); },
51 function() { w.location.href = "about:blank";
52 waitForInstanceCount(0); },
53 ];
54
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?");
62 }
63
64 </script>
65 <pre id="test">
66 </pre>
67 </body>
68 </html>

mercurial