diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /netwerk/test/unit/test_nojsredir.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'netwerk/test/unit/test_nojsredir.js')
-rw-r--r-- | netwerk/test/unit/test_nojsredir.js | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/netwerk/test/unit/test_nojsredir.js b/netwerk/test/unit/test_nojsredir.js new file mode 100644 index 000000000..d61c41a18 --- /dev/null +++ b/netwerk/test/unit/test_nojsredir.js @@ -0,0 +1,62 @@ +Cu.import("resource://testing-common/httpd.js"); +Cu.import("resource://gre/modules/NetUtil.jsm"); + +var httpserver = new HttpServer(); +var index = 0; +var tests = [ + {url : "/test/test", + datalen : 16}, + + // Test that the http channel fails and the response body is suppressed + // bug 255119 + {url: "/test/test", + responseheader: [ "Location: javascript:alert()"], + flags : CL_EXPECT_FAILURE, + datalen : 0}, +]; + +function setupChannel(url) { + return NetUtil.newChannel({ + uri: "http://localhost:" + httpserver.identity.primaryPort + url, + loadUsingSystemPrincipal: true + }); +} + +function startIter() { + var channel = setupChannel(tests[index].url); + channel.asyncOpen2(new ChannelListener(completeIter, channel, tests[index].flags)); +} + +function completeIter(request, data, ctx) { + do_check_true(data.length == tests[index].datalen); + if (++index < tests.length) { + startIter(); + } else { + httpserver.stop(do_test_finished); + } +} + +function run_test() { + httpserver.registerPathHandler("/test/test", handler); + httpserver.start(-1); + + startIter(); + do_test_pending(); +} + +function handler(metadata, response) { + var body = "thequickbrownfox"; + response.setHeader("Content-Type", "text/plain", false); + + var header = tests[index].responseheader; + if (header != undefined) { + for (var i = 0; i < header.length; i++) { + var splitHdr = header[i].split(": "); + response.setHeader(splitHdr[0], splitHdr[1], false); + } + } + + response.setStatusLine(metadata.httpVersion, 302, "Redirected"); + response.bodyOutputStream.write(body, body.length); +} + |