dom/plugins/test/mochitest/test_NPPVpluginWantsAllNetworkStreams.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/plugins/test/mochitest/test_NPPVpluginWantsAllNetworkStreams.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,77 @@
     1.4 +<html>
     1.5 +<head>
     1.6 +  <title>Test NPPVpluginWantsAllNetworkStreams</title>
     1.7 +  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     1.8 +  <script type="application/javascript" src="utils.js"></script>
     1.9 +</head>
    1.10 +<body onload="runTests()">
    1.11 +  <script class="testbody" type="application/javascript">
    1.12 +    SimpleTest.waitForExplicitFinish();
    1.13 +    setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
    1.14 +
    1.15 +    var p = null;
    1.16 +
    1.17 +    var missingDoc = "not-found.html";
    1.18 +
    1.19 +    var expectedWriteURL = "";
    1.20 +    var expectedNotifyStatus = -1;
    1.21 +
    1.22 +    var writeHappened = false;
    1.23 +    var expectedWrite = false;
    1.24 +
    1.25 +    function writeCallback(url) {
    1.26 +      writeHappened = true;
    1.27 +    }
    1.28 +
    1.29 +    function notifyCallback(status, data) {
    1.30 +      is(writeHappened, expectedWrite, "Test for expected write.");
    1.31 +      is(status, expectedNotifyStatus, "Test for expected stream notification status.");
    1.32 +      runNextTest();
    1.33 +    }
    1.34 +
    1.35 +    function test1() {
    1.36 +      // In this test we do not expect a stream for the missing document.
    1.37 +      p.setPluginWantsAllStreams(false);
    1.38 +
    1.39 +      expectedWriteURL = missingDoc;
    1.40 +      expectedNotifyStatus = 1;
    1.41 +
    1.42 +      writeHappened = false;
    1.43 +      expectedWrite = false;
    1.44 +
    1.45 +      p.streamTest(missingDoc, false, null, writeCallback, notifyCallback, null, false);
    1.46 +    }
    1.47 +
    1.48 +    function test2() {
    1.49 +      // In this test we expect a stream for the missing document.
    1.50 +      p.setPluginWantsAllStreams(true);
    1.51 +
    1.52 +      expectedWriteURL = missingDoc;
    1.53 +      expectedNotifyStatus = 0;
    1.54 +
    1.55 +      writeHappened = false;
    1.56 +      expectedWrite = true;
    1.57 +
    1.58 +      p.streamTest(missingDoc, false, null, writeCallback, notifyCallback, null, false);
    1.59 +    }
    1.60 +
    1.61 +    var tests = [test1, test2];
    1.62 +    var currentTest = -1;
    1.63 +    function runNextTest() {
    1.64 +      currentTest++;
    1.65 +      if (currentTest < tests.length) {
    1.66 +        tests[currentTest]();
    1.67 +      } else {
    1.68 +        SimpleTest.finish();
    1.69 +      }
    1.70 +    }
    1.71 +
    1.72 +    function runTests() {
    1.73 +      p = document.getElementById("plugin1");
    1.74 +      runNextTest();
    1.75 +    }
    1.76 +  </script>
    1.77 +
    1.78 +  <embed id="plugin1" type="application/x-test" width="200" height="200"></embed>
    1.79 +</body>
    1.80 +</html>

mercurial