Thu, 15 Jan 2015 21:03:48 +0100
Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)
michael@0 | 1 | /* -*- Mode: JavaScript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | "use strict"; |
michael@0 | 3 | Cu.import("resource://testing-common/httpd.js"); |
michael@0 | 4 | |
michael@0 | 5 | var httpserver = null; |
michael@0 | 6 | const noRedirectURI = "/content"; |
michael@0 | 7 | const pageValue = "Final page"; |
michael@0 | 8 | const acceptType = "application/json"; |
michael@0 | 9 | |
michael@0 | 10 | function redirectHandler(metadata, response) |
michael@0 | 11 | { |
michael@0 | 12 | response.setStatusLine(metadata.httpVersion, 302, "Moved Temporarily"); |
michael@0 | 13 | response.setHeader("Location", noRedirectURI, false); |
michael@0 | 14 | } |
michael@0 | 15 | |
michael@0 | 16 | function contentHandler(metadata, response) |
michael@0 | 17 | { |
michael@0 | 18 | do_check_eq(metadata.getHeader("Accept"), acceptType); |
michael@0 | 19 | httpserver.stop(do_test_finished); |
michael@0 | 20 | } |
michael@0 | 21 | |
michael@0 | 22 | function dummyHandler(request, buffer) |
michael@0 | 23 | { |
michael@0 | 24 | } |
michael@0 | 25 | |
michael@0 | 26 | function run_test() |
michael@0 | 27 | { |
michael@0 | 28 | httpserver = new HttpServer(); |
michael@0 | 29 | httpserver.registerPathHandler("/redirect", redirectHandler); |
michael@0 | 30 | httpserver.registerPathHandler("/content", contentHandler); |
michael@0 | 31 | httpserver.start(-1); |
michael@0 | 32 | |
michael@0 | 33 | var prefs = Cc["@mozilla.org/preferences-service;1"] |
michael@0 | 34 | .getService(Components.interfaces.nsIPrefBranch); |
michael@0 | 35 | prefs.setBoolPref("network.http.prompt-temp-redirect", false); |
michael@0 | 36 | |
michael@0 | 37 | var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService); |
michael@0 | 38 | var chan = ios.newChannel("http://localhost:" + |
michael@0 | 39 | httpserver.identity.primaryPort + "/redirect", |
michael@0 | 40 | "", |
michael@0 | 41 | null); |
michael@0 | 42 | |
michael@0 | 43 | chan.QueryInterface(Ci.nsIHttpChannel); |
michael@0 | 44 | chan.setRequestHeader("Accept", acceptType, false); |
michael@0 | 45 | |
michael@0 | 46 | chan.asyncOpen(new ChannelListener(dummyHandler, null), null); |
michael@0 | 47 | |
michael@0 | 48 | do_test_pending(); |
michael@0 | 49 | } |