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 /dom/base/test/unit/test_bug553888.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 'dom/base/test/unit/test_bug553888.js')
-rw-r--r-- | dom/base/test/unit/test_bug553888.js | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/dom/base/test/unit/test_bug553888.js b/dom/base/test/unit/test_bug553888.js new file mode 100644 index 000000000..036d51211 --- /dev/null +++ b/dom/base/test/unit/test_bug553888.js @@ -0,0 +1,60 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +Components.utils.import("resource://testing-common/httpd.js"); + +var server = new HttpServer(); +server.start(-1); + +const SERVER_PORT = server.identity.primaryPort; +const HTTP_BASE = "http://localhost:" + SERVER_PORT; +const redirectPath = "/redirect"; +const headerCheckPath = "/headerCheck"; +const redirectURL = HTTP_BASE + redirectPath; +const headerCheckURL = HTTP_BASE + headerCheckPath; + +function redirectHandler(metadata, response) { + response.setStatusLine(metadata.httpVersion, 302, "Found"); + response.setHeader("Location", headerCheckURL, false); +} + +function headerCheckHandler(metadata, response) { + try { + let headerValue = metadata.getHeader("X-Custom-Header"); + do_check_eq(headerValue, "present"); + } catch(e) { + do_throw("No header present after redirect"); + } + try { + metadata.getHeader("X-Unwanted-Header"); + do_throw("Unwanted header present after redirect"); + } catch (x) { + } + response.setStatusLine(metadata.httpVersion, 200, "OK"); + response.setHeader("Content-Type", "text/plain"); + response.write(""); +} + +function run_test() { + server.registerPathHandler(redirectPath, redirectHandler); + server.registerPathHandler(headerCheckPath, headerCheckHandler); + + do_test_pending(); + var request = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"] + .createInstance(Components.interfaces.nsIXMLHttpRequest); + request.open("GET", redirectURL, true); + request.setRequestHeader("X-Custom-Header", "present"); + request.addEventListener("readystatechange", function() { + if (request.readyState == 4) { + do_check_eq(request.status, 200); + server.stop(do_test_finished); + } + }, false); + request.send(); + try { + request.setRequestHeader("X-Unwanted-Header", "present"); + do_throw("Shouldn't be able to set a header after send"); + } catch (x) { + } +} |