2014-06-25 09:12:07 +04:00
|
|
|
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
2014-02-26 18:03:14 +04:00
|
|
|
"use strict";
|
2018-01-30 02:20:18 +03:00
|
|
|
ChromeUtils.import("resource://testing-common/httpd.js");
|
|
|
|
ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
|
2014-02-26 18:03:14 +04:00
|
|
|
|
|
|
|
var httpserver = null;
|
|
|
|
const noRedirectURI = "/content";
|
|
|
|
const pageValue = "Final page";
|
|
|
|
const acceptType = "application/json";
|
|
|
|
|
|
|
|
function redirectHandler(metadata, response)
|
|
|
|
{
|
|
|
|
response.setStatusLine(metadata.httpVersion, 302, "Moved Temporarily");
|
|
|
|
response.setHeader("Location", noRedirectURI, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
function contentHandler(metadata, response)
|
|
|
|
{
|
2017-12-21 13:08:17 +03:00
|
|
|
Assert.equal(metadata.getHeader("Accept"), acceptType);
|
2014-02-26 18:03:14 +04:00
|
|
|
httpserver.stop(do_test_finished);
|
|
|
|
}
|
|
|
|
|
|
|
|
function dummyHandler(request, buffer)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
function run_test()
|
|
|
|
{
|
|
|
|
httpserver = new HttpServer();
|
|
|
|
httpserver.registerPathHandler("/redirect", redirectHandler);
|
|
|
|
httpserver.registerPathHandler("/content", contentHandler);
|
|
|
|
httpserver.start(-1);
|
|
|
|
|
|
|
|
var prefs = Cc["@mozilla.org/preferences-service;1"]
|
2018-02-28 20:51:33 +03:00
|
|
|
.getService(Ci.nsIPrefBranch);
|
2014-02-26 18:03:14 +04:00
|
|
|
prefs.setBoolPref("network.http.prompt-temp-redirect", false);
|
|
|
|
|
2015-12-23 07:57:57 +03:00
|
|
|
var chan = NetUtil.newChannel({
|
|
|
|
uri: "http://localhost:" + httpserver.identity.primaryPort + "/redirect",
|
|
|
|
loadUsingSystemPrincipal: true
|
|
|
|
});
|
2014-02-26 18:03:14 +04:00
|
|
|
chan.QueryInterface(Ci.nsIHttpChannel);
|
|
|
|
chan.setRequestHeader("Accept", acceptType, false);
|
|
|
|
|
2015-12-23 07:57:57 +03:00
|
|
|
chan.asyncOpen2(new ChannelListener(dummyHandler, null));
|
2014-02-26 18:03:14 +04:00
|
|
|
|
|
|
|
do_test_pending();
|
|
|
|
}
|