|
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); |
|
11 |
|
12 var p = null; |
|
13 |
|
14 var missingDoc = "not-found.html"; |
|
15 |
|
16 var expectedWriteURL = ""; |
|
17 var expectedNotifyStatus = -1; |
|
18 |
|
19 var writeHappened = false; |
|
20 var expectedWrite = false; |
|
21 |
|
22 function writeCallback(url) { |
|
23 writeHappened = true; |
|
24 } |
|
25 |
|
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 } |
|
31 |
|
32 function test1() { |
|
33 // In this test we do not expect a stream for the missing document. |
|
34 p.setPluginWantsAllStreams(false); |
|
35 |
|
36 expectedWriteURL = missingDoc; |
|
37 expectedNotifyStatus = 1; |
|
38 |
|
39 writeHappened = false; |
|
40 expectedWrite = false; |
|
41 |
|
42 p.streamTest(missingDoc, false, null, writeCallback, notifyCallback, null, false); |
|
43 } |
|
44 |
|
45 function test2() { |
|
46 // In this test we expect a stream for the missing document. |
|
47 p.setPluginWantsAllStreams(true); |
|
48 |
|
49 expectedWriteURL = missingDoc; |
|
50 expectedNotifyStatus = 0; |
|
51 |
|
52 writeHappened = false; |
|
53 expectedWrite = true; |
|
54 |
|
55 p.streamTest(missingDoc, false, null, writeCallback, notifyCallback, null, false); |
|
56 } |
|
57 |
|
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 } |
|
68 |
|
69 function runTests() { |
|
70 p = document.getElementById("plugin1"); |
|
71 runNextTest(); |
|
72 } |
|
73 </script> |
|
74 |
|
75 <embed id="plugin1" type="application/x-test" width="200" height="200"></embed> |
|
76 </body> |
|
77 </html> |