dom/plugins/test/mochitest/test_NPPVpluginWantsAllNetworkStreams.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 <html>
     2 <head>
     3   <title>Test NPPVpluginWantsAllNetworkStreams</title>
     4   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     5   <script type="application/javascript" src="utils.js"></script>
     6 </head>
     7 <body onload="runTests()">
     8   <script class="testbody" type="application/javascript">
     9     SimpleTest.waitForExplicitFinish();
    10     setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
    12     var p = null;
    14     var missingDoc = "not-found.html";
    16     var expectedWriteURL = "";
    17     var expectedNotifyStatus = -1;
    19     var writeHappened = false;
    20     var expectedWrite = false;
    22     function writeCallback(url) {
    23       writeHappened = true;
    24     }
    26     function notifyCallback(status, data) {
    27       is(writeHappened, expectedWrite, "Test for expected write.");
    28       is(status, expectedNotifyStatus, "Test for expected stream notification status.");
    29       runNextTest();
    30     }
    32     function test1() {
    33       // In this test we do not expect a stream for the missing document.
    34       p.setPluginWantsAllStreams(false);
    36       expectedWriteURL = missingDoc;
    37       expectedNotifyStatus = 1;
    39       writeHappened = false;
    40       expectedWrite = false;
    42       p.streamTest(missingDoc, false, null, writeCallback, notifyCallback, null, false);
    43     }
    45     function test2() {
    46       // In this test we expect a stream for the missing document.
    47       p.setPluginWantsAllStreams(true);
    49       expectedWriteURL = missingDoc;
    50       expectedNotifyStatus = 0;
    52       writeHappened = false;
    53       expectedWrite = true;
    55       p.streamTest(missingDoc, false, null, writeCallback, notifyCallback, null, false);
    56     }
    58     var tests = [test1, test2];
    59     var currentTest = -1;
    60     function runNextTest() {
    61       currentTest++;
    62       if (currentTest < tests.length) {
    63         tests[currentTest]();
    64       } else {
    65         SimpleTest.finish();
    66       }
    67     }
    69     function runTests() {
    70       p = document.getElementById("plugin1");
    71       runNextTest();
    72     }
    73   </script>
    75   <embed id="plugin1" type="application/x-test" width="200" height="200"></embed>
    76 </body>
    77 </html>

mercurial