content/base/test/test_plugin_freezing.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial