content/base/test/test_plugin_freezing.html

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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;
    17 var testIndex = 0;
    18 var tests;
    20 window.addEventListener("unload", function() {
    21   e1.stopWatchingInstanceCount();
    22 }, false);
    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   }
    35   var test = tests[testIndex];
    36   ++testIndex;
    37   test();
    38 }
    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 }
    49 tests = [
    50   function() { waitForInstanceCount(1); },
    51   function() { w.location.href = "about:blank";
    52                waitForInstanceCount(0); },
    53 ];
    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 }
    64 </script>
    65 <pre id="test">
    66 </pre>
    67 </body>
    68 </html>

mercurial