Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | <html> |
michael@0 | 2 | <head> |
michael@0 | 3 | <title>Test NPPVpluginWantsAllNetworkStreams</title> |
michael@0 | 4 | <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 5 | <script type="application/javascript" src="utils.js"></script> |
michael@0 | 6 | </head> |
michael@0 | 7 | <body onload="runTests()"> |
michael@0 | 8 | <script class="testbody" type="application/javascript"> |
michael@0 | 9 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 10 | setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED); |
michael@0 | 11 | |
michael@0 | 12 | var p = null; |
michael@0 | 13 | |
michael@0 | 14 | var missingDoc = "not-found.html"; |
michael@0 | 15 | |
michael@0 | 16 | var expectedWriteURL = ""; |
michael@0 | 17 | var expectedNotifyStatus = -1; |
michael@0 | 18 | |
michael@0 | 19 | var writeHappened = false; |
michael@0 | 20 | var expectedWrite = false; |
michael@0 | 21 | |
michael@0 | 22 | function writeCallback(url) { |
michael@0 | 23 | writeHappened = true; |
michael@0 | 24 | } |
michael@0 | 25 | |
michael@0 | 26 | function notifyCallback(status, data) { |
michael@0 | 27 | is(writeHappened, expectedWrite, "Test for expected write."); |
michael@0 | 28 | is(status, expectedNotifyStatus, "Test for expected stream notification status."); |
michael@0 | 29 | runNextTest(); |
michael@0 | 30 | } |
michael@0 | 31 | |
michael@0 | 32 | function test1() { |
michael@0 | 33 | // In this test we do not expect a stream for the missing document. |
michael@0 | 34 | p.setPluginWantsAllStreams(false); |
michael@0 | 35 | |
michael@0 | 36 | expectedWriteURL = missingDoc; |
michael@0 | 37 | expectedNotifyStatus = 1; |
michael@0 | 38 | |
michael@0 | 39 | writeHappened = false; |
michael@0 | 40 | expectedWrite = false; |
michael@0 | 41 | |
michael@0 | 42 | p.streamTest(missingDoc, false, null, writeCallback, notifyCallback, null, false); |
michael@0 | 43 | } |
michael@0 | 44 | |
michael@0 | 45 | function test2() { |
michael@0 | 46 | // In this test we expect a stream for the missing document. |
michael@0 | 47 | p.setPluginWantsAllStreams(true); |
michael@0 | 48 | |
michael@0 | 49 | expectedWriteURL = missingDoc; |
michael@0 | 50 | expectedNotifyStatus = 0; |
michael@0 | 51 | |
michael@0 | 52 | writeHappened = false; |
michael@0 | 53 | expectedWrite = true; |
michael@0 | 54 | |
michael@0 | 55 | p.streamTest(missingDoc, false, null, writeCallback, notifyCallback, null, false); |
michael@0 | 56 | } |
michael@0 | 57 | |
michael@0 | 58 | var tests = [test1, test2]; |
michael@0 | 59 | var currentTest = -1; |
michael@0 | 60 | function runNextTest() { |
michael@0 | 61 | currentTest++; |
michael@0 | 62 | if (currentTest < tests.length) { |
michael@0 | 63 | tests[currentTest](); |
michael@0 | 64 | } else { |
michael@0 | 65 | SimpleTest.finish(); |
michael@0 | 66 | } |
michael@0 | 67 | } |
michael@0 | 68 | |
michael@0 | 69 | function runTests() { |
michael@0 | 70 | p = document.getElementById("plugin1"); |
michael@0 | 71 | runNextTest(); |
michael@0 | 72 | } |
michael@0 | 73 | </script> |
michael@0 | 74 | |
michael@0 | 75 | <embed id="plugin1" type="application/x-test" width="200" height="200"></embed> |
michael@0 | 76 | </body> |
michael@0 | 77 | </html> |