Bug 1234596 - Convert 20 tests within netwerk/test to use AsyncOpen2 (r=mcmanus)

This commit is contained in:
Christoph Kerschbaumer 2015-12-22 13:09:31 -08:00
parent c2658436b2
commit 8adf739828
19 changed files with 200 additions and 432 deletions

View File

@ -11,7 +11,7 @@ load(_HTTPD_JS_PATH.path);
// if these tests fail, we'll want the debug output
DEBUG = true;
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/NetUtil.jsm");
/**
* Constructs a new nsHttpServer instance. This function is intended to
@ -32,19 +32,8 @@ function createServer()
*/
function makeChannel(url)
{
var ios = Cc["@mozilla.org/network/io-service;1"]
.getService(Ci.nsIIOService);
var chan = ios.newChannel2(url,
null,
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER)
return NetUtil.newChannel({uri: url, loadUsingSystemPrincipal: true})
.QueryInterface(Ci.nsIHttpChannel);
return chan;
}
/**
@ -297,7 +286,7 @@ function runHttpTests(testArray, done)
}
listener._channel = ch;
ch.asyncOpen(listener, null);
ch.asyncOpen2(listener);
}
/** Index of the test being run. */

View File

@ -233,7 +233,7 @@ function HTTPTestLoader(path, start, stop)
this._stop = stop;
var channel = makeChannel(path);
channel.asyncOpen(this, null);
channel.asyncOpen2(this);
}
HTTPTestLoader.prototype =
{

View File

@ -1,5 +1,4 @@
Cu.import("resource://testing-common/httpd.js");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/NetUtil.jsm");
var h2Port;
@ -123,17 +122,10 @@ function addCertFromFile(certdb, filename, trustString) {
}
function makeChan(origin) {
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
var chan = ios.newChannel2(origin + "altsvc-test",
null,
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER).QueryInterface(Ci.nsIHttpChannel);
return chan;
return NetUtil.newChannel({
uri: origin + "altsvc-test",
loadUsingSystemPrincipal: true
}).QueryInterface(Ci.nsIHttpChannel);
}
var origin;
@ -212,7 +204,7 @@ function doTest()
}
chan.loadFlags = Ci.nsIRequest.LOAD_FRESH_CONNECTION |
Ci.nsIChannel.LOAD_INITIAL_DOCUMENT_URI;
chan.asyncOpen(listener, null);
chan.asyncOpen2(listener);
}
// xaltsvc is overloaded to do two things..

View File

@ -1,5 +1,5 @@
Cu.import("resource://testing-common/httpd.js");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/NetUtil.jsm");
var httpserver = new HttpServer();
var currentTestIndex = 0;
@ -45,24 +45,17 @@ var domBranch;
function setupChannel(url)
{
var ios = Components.classes["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
var chan = ios.newChannel2("http://localhost:" + port + url,
"",
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
return chan;
return NetUtil.newChannel({
uri: "http://localhost:" + port + url,
loadUsingSystemPrincipal: true
});
}
function startIter()
{
var channel = setupChannel(tests[currentTestIndex].url);
channel.asyncOpen(new ChannelListener(completeIter,
channel, tests[currentTestIndex].flags), null);
channel.asyncOpen2(new ChannelListener(completeIter,
channel, tests[currentTestIndex].flags));
}
function completeIter(request, data, ctx)

View File

@ -1,7 +1,7 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
"use strict";
Cu.import("resource://testing-common/httpd.js");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/NetUtil.jsm");
var httpserver = null;
const noRedirectURI = "/content";
@ -35,21 +35,14 @@ function run_test()
.getService(Components.interfaces.nsIPrefBranch);
prefs.setBoolPref("network.http.prompt-temp-redirect", false);
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
var chan = ios.newChannel2("http://localhost:" +
httpserver.identity.primaryPort + "/redirect",
"",
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
var chan = NetUtil.newChannel({
uri: "http://localhost:" + httpserver.identity.primaryPort + "/redirect",
loadUsingSystemPrincipal: true
});
chan.QueryInterface(Ci.nsIHttpChannel);
chan.setRequestHeader("Accept", acceptType, false);
chan.asyncOpen(new ChannelListener(dummyHandler, null), null);
chan.asyncOpen2(new ChannelListener(dummyHandler, null));
do_test_pending();
}

View File

@ -1,4 +1,4 @@
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/NetUtil.jsm");
function getLinkFile()
{
@ -94,15 +94,13 @@ RequestObserver.prototype = {
function test_cancel()
{
var chan = ios.newChannelFromURI2(linkURI,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
var chan = NetUtil.newChannel({
uri: linkURI,
loadUsingSystemPrincipal: true
});
do_check_eq(chan.URI, linkURI);
do_check_eq(chan.originalURI, linkURI);
chan.asyncOpen(new RequestObserver(linkURI, newURI, do_test_finished), null);
chan.asyncOpen2(new RequestObserver(linkURI, newURI, do_test_finished));
do_check_true(chan.isPending());
chan.cancel(Cr.NS_ERROR_ABORT);
do_check_true(chan.isPending());
@ -118,16 +116,13 @@ function run_test()
linkURI = ios.newFileURI(link);
do_test_pending();
var chan = ios.newChannelFromURI2(linkURI,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
var chan = NetUtil.newChannel({
uri: linkURI,
loadUsingSystemPrincipal: true
});
do_check_eq(chan.URI, linkURI);
do_check_eq(chan.originalURI, linkURI);
chan.notificationCallbacks = new NotificationCallbacks(linkURI, newURI);
chan.asyncOpen(new RequestObserver(linkURI, newURI, test_cancel), null);
chan.asyncOpen2(new RequestObserver(linkURI, newURI, test_cancel));
do_check_true(chan.isPending());
}

View File

@ -1,5 +1,5 @@
Cu.import("resource://testing-common/httpd.js");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/NetUtil.jsm");
const sentCookieVal = "foo=bar";
const responseBody = "response body";
@ -64,16 +64,11 @@ function run_test()
// the channel both to set a cookie (since nsICookieService::setCookieString
// requires such a channel in order to successfully set a cookie) and then
// to load the pre-redirect URI.
var chan = ioService.newChannel2(preRedirectURL,
"",
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER).
QueryInterface(Ci.nsIHttpChannel).
QueryInterface(Ci.nsIHttpChannelInternal);
var chan = NetUtil.newChannel({
uri: preRedirectURL,
loadUsingSystemPrincipal: true
}).QueryInterface(Ci.nsIHttpChannel)
.QueryInterface(Ci.nsIHttpChannelInternal);
chan.forceAllowThirdPartyCookie = true;
// Set a cookie on one of the URIs. It doesn't matter which one, since
@ -84,7 +79,7 @@ function run_test()
setCookieString(postRedirectURI, null, sentCookieVal, chan);
// Load the pre-redirect URI.
chan.asyncOpen(new ChannelListener(finish_test, null), null);
chan.asyncOpen2(new ChannelListener(finish_test, null));
do_test_pending();
}

View File

@ -1,5 +1,5 @@
Cu.import("resource://testing-common/httpd.js");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/NetUtil.jsm");
const VALUE_HDR_NAME = "X-HTTP-VALUE-HEADER";
const VARY_HDR_NAME = "X-HTTP-VARY-HEADER";
@ -8,19 +8,10 @@ const CACHECTRL_HDR_NAME = "X-CACHE-CONTROL-HEADER";
var httpserver = null;
function make_channel(flags, vary, value) {
var ios = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
var chan = ios.newChannel2("http://localhost:" +
httpserver.identity.primaryPort +
"/bug633743",
null,
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER)
.QueryInterface(Components.interfaces.nsIHttpChannel);
var chan = NetUtil.newChannel({
uri: "http://localhost:" + httpserver.identity.primaryPort + "/bug633743",
loadUsingSystemPrincipal: true
}).QueryInterface(Components.interfaces.nsIHttpChannel);
return chan.QueryInterface(Ci.nsIHttpChannel);
}
@ -67,7 +58,7 @@ Test.prototype = {
if (this._cacheHdr)
channel.setRequestHeader(CACHECTRL_HDR_NAME, this._cacheHdr, false);
channel.asyncOpen(this, null);
channel.asyncOpen2(this);
}
};

View File

@ -4,7 +4,7 @@
//
Cu.import("resource://testing-common/httpd.js");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/NetUtil.jsm");
do_get_profile();
@ -21,18 +21,10 @@ function repeatToLargerThan1K(data) {
}
function setupChannel(suffix, value) {
var ios = Components.classes["@mozilla.org/network/io-service;1"]
.getService(Ci.nsIIOService);
var chan = ios.newChannel2("http://localhost:" +
httpserver.identity.primaryPort +
suffix,
"",
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
var chan = NetUtil.newChannel({
uri: "http://localhost:" + httpserver.identity.primaryPort + suffix,
loadUsingSystemPrincipal: true
});
var httpChan = chan.QueryInterface(Components.interfaces.nsIHttpChannel);
httpChan.setRequestHeader("x-request", value, false);
@ -109,9 +101,7 @@ function InitializeCacheDevices(memDevice, diskDevice) {
}
}
var channel = setupChannel("/bug650995", "Initial value");
channel.asyncOpen(new ChannelListener(
nextTest, null),
null);
channel.asyncOpen2(new ChannelListener(nextTest, null));
}
}
@ -128,14 +118,14 @@ function TestCacheEntrySize(setSizeFunc, firstRequest, secondRequest, secondExpe
this.start = function() {
setSizeFunc();
var channel = setupChannel("/bug650995", firstRequest);
channel.asyncOpen(new ChannelListener(this.initialLoad, this), null);
channel.asyncOpen2(new ChannelListener(this.initialLoad, this));
},
this.initialLoad = function(request, data, ctx) {
do_check_eq(firstRequest, data);
var channel = setupChannel("/bug650995", secondRequest);
do_execute_soon(function() {
channel.asyncOpen(new ChannelListener(ctx.testAndTriggerNext, ctx), null);
channel.asyncOpen2(new ChannelListener(ctx.testAndTriggerNext, ctx));
});
},

View File

@ -1,5 +1,6 @@
Cu.import("resource://testing-common/httpd.js");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/NetUtil.jsm");
var httpServer = null;
// Need to randomize, because apparently no one clears our cache
@ -13,16 +14,7 @@ var cacheUpdateObserver = null;
var systemPrincipal = Services.scriptSecurityManager.getSystemPrincipal();
function make_channel(url, callback, ctx) {
var ios = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
return ios.newChannel2(url,
"",
null,
null, // aLoadingNode
systemPrincipal,
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
return NetUtil.newChannel({uri: url, loadUsingSystemPrincipal: true});
}
function make_uri(url) {
@ -105,7 +97,7 @@ function run_test()
var chan = make_channel(randomURI);
var chanac = chan.QueryInterface(Ci.nsIApplicationCacheChannel);
chanac.chooseApplicationCache = true;
chan.asyncOpen(new ChannelListener(finish_test), null);
chan.asyncOpen2(new ChannelListener(finish_test));
});
}}

View File

@ -1,7 +1,7 @@
// Test getLocalHost/getLocalPort and getRemoteHost/getRemotePort.
Cu.import("resource://testing-common/httpd.js");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/NetUtil.jsm");
var httpserver = new HttpServer();
httpserver.start(-1);
@ -46,17 +46,10 @@ CheckGetHostListener.prototype = {
}
function make_channel(url) {
var ios = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
return ios.newChannel2(url,
null,
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER)
.QueryInterface(Components.interfaces.nsIHttpChannel);
return NetUtil.newChannel({
uri: url,
loadUsingSystemPrincipal: true
}).QueryInterface(Components.interfaces.nsIHttpChannel);
}
function test_handler(metadata, response) {
@ -70,6 +63,6 @@ function run_test() {
httpserver.registerPathHandler("/testdir", test_handler);
var channel = make_channel("http://localhost:" + PORT + "/testdir");
channel.asyncOpen(new CheckGetHostListener(), null);
channel.asyncOpen2(new CheckGetHostListener());
do_test_pending();
}

View File

@ -5,7 +5,7 @@
// Note: sets Cc and Ci variables
Cu.import("resource://testing-common/httpd.js");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/NetUtil.jsm");
XPCOMUtils.defineLazyGetter(this, "URL", function() {
return "http://localhost:" + httpserver.identity.primaryPort;
@ -64,33 +64,28 @@ function setup_test() {
setOK = channel.getRequestHeader("MergeWithEmpty");
do_check_eq(setOK, "foo");
var uri = ios.newURI("http://foo1.invalid:80", null, null);
var uri = NetUtil.newURI("http://foo1.invalid:80");
channel.referrer = uri;
do_check_true(channel.referrer.equals(uri));
setOK = channel.getRequestHeader("Referer");
do_check_eq(setOK, "http://foo1.invalid/");
uri = ios.newURI("http://foo2.invalid:90/bar", null, null);
uri = NetUtil.newURI("http://foo2.invalid:90/bar");
channel.referrer = uri;
setOK = channel.getRequestHeader("Referer");
do_check_eq(setOK, "http://foo2.invalid:90/bar");
// ChannelListener defined in head_channels.js
channel.asyncOpen(new ChannelListener(checkRequestResponse, channel), null);
channel.asyncOpen2(new ChannelListener(checkRequestResponse, channel));
if (dbg) { print("============== setup_test: out"); }
}
function setupChannel(path) {
ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
var chan = ios.newChannel2(URL + path,
"",
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
var chan = NetUtil.newChannel({
uri: URL + path,
loadUsingSystemPrincipal: true
});
chan.QueryInterface(Ci.nsIHttpChannel);
chan.requestMethod = "GET";
return chan;

View File

@ -22,7 +22,7 @@ var lastTest = 4; // set to test of interest when debugging
// Note: sets Cc and Ci variables
Cu.import("resource://testing-common/httpd.js");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/NetUtil.jsm");
XPCOMUtils.defineLazyGetter(this, "URL", function() {
return "http://localhost:" + httpserver.identity.primaryPort;
@ -65,22 +65,16 @@ function run_test_number(num)
var channel = setupChannel(testPath);
flags = test_flags[num]; // OK if flags undefined for test
channel.asyncOpen(new ChannelListener(eval("completeTest" + num),
channel, flags), null);
channel.asyncOpen2(new ChannelListener(eval("completeTest" + num),
channel, flags));
}
function setupChannel(url)
{
var ios = Components.classes["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
var chan = ios.newChannel2(URL + url,
"",
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
var chan = NetUtil.newChannel({
uri: URL + url,
loadUsingSystemPrincipal: true
});
var httpChan = chan.QueryInterface(Components.interfaces.nsIHttpChannel);
return httpChan;
}

View File

@ -2,7 +2,7 @@
// suspends future notifications correctly.
Cu.import("resource://testing-common/httpd.js");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/NetUtil.jsm");
XPCOMUtils.defineLazyGetter(this, "URL", function() {
return "http://localhost:" + httpserv.identity.primaryPort;
@ -55,16 +55,8 @@ var listener = {
};
function makeChan(url) {
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
var chan = ios.newChannel2(url,
null,
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER).QueryInterface(Ci.nsIHttpChannel);
return chan;
return NetUtil.newChannel({uri: url, loadUsingSystemPrincipal: true})
.QueryInterface(Ci.nsIHttpChannel);
}
var httpserv = null;
@ -76,7 +68,7 @@ function run_test() {
var chan = makeChan(URL + "/woo");
chan.QueryInterface(Ci.nsIRequest);
chan.asyncOpen(listener, null);
chan.asyncOpen2(listener);
do_test_pending();
}

View File

@ -17,7 +17,7 @@
// run_myipaddress_test();
// run_failed_script_test();
// run_isresolvable_test();
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/NetUtil.jsm");
var ios = Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
@ -172,14 +172,10 @@ resolveCallback.prototype = {
};
function run_filter_test() {
var channel = ios.newChannel2("http://www.mozilla.org/",
null,
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
var channel = NetUtil.newChannel({
uri: "http://www.mozilla.org/",
loadUsingSystemPrincipal: true
});
// Verify initial state
var cb = new resolveCallback();
@ -202,14 +198,10 @@ function filter_test0_1(pi) {
var cb = new resolveCallback();
cb.nextFunction = filter_test0_2;
var channel = ios.newChannel2("http://www.mozilla.org/",
null,
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
var channel = NetUtil.newChannel({
uri: "http://www.mozilla.org/",
loadUsingSystemPrincipal: true
});
var req = pps.asyncResolve(channel, 0, cb);
}
@ -222,14 +214,10 @@ function filter_test0_2(pi)
var cb = new resolveCallback();
cb.nextFunction = filter_test0_3;
var channel = ios.newChannel2("http://www.mozilla.org/",
null,
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
var channel = NetUtil.newChannel({
uri: "http://www.mozilla.org/",
loadUsingSystemPrincipal: true
});
var req = pps.asyncResolve(channel, 0, cb);
}
@ -244,14 +232,10 @@ function filter_test0_3(pi)
var cb = new resolveCallback();
cb.nextFunction = filter_test0_4;
var channel = ios.newChannel2("http://www.mozilla.org/",
null,
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
var channel = NetUtil.newChannel({
uri: "http://www.mozilla.org/",
loadUsingSystemPrincipal: true
});
var req = pps.asyncResolve(channel, 0, cb);
}
@ -264,14 +248,10 @@ function filter_test0_4(pi)
pps.registerChannelFilter(filter03, 10);
var cb = new resolveCallback();
cb.nextFunction = filter_test0_5;
var channel = ios.newChannel2("http://www.mozilla.org/",
null,
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
var channel = NetUtil.newChannel({
uri: "http://www.mozilla.org/",
loadUsingSystemPrincipal: true
});
var req = pps.asyncResolve(channel, 0, cb);
}
@ -353,14 +333,10 @@ function run_filter_test2() {
var cb = new resolveCallback();
cb.nextFunction = filter_test1_1;
var channel = ios.newChannel2("http://www.mozilla.org/",
null,
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
var channel = NetUtil.newChannel({
uri: "http://www.mozilla.org/",
loadUsingSystemPrincipal: true
});
var req = pps.asyncResolve(channel, 0, cb);
}
@ -372,14 +348,10 @@ function filter_test1_1(pi) {
var cb = new resolveCallback();
cb.nextFunction = filter_test1_2;
var channel = ios.newChannel2("http://www.mozilla.org/",
null,
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
var channel = NetUtil.newChannel({
uri: "http://www.mozilla.org/",
loadUsingSystemPrincipal: true
});
var req = pps.asyncResolve(channel, 0, cb);
}
@ -392,14 +364,10 @@ function filter_test1_2(pi) {
var cb = new resolveCallback();
cb.nextFunction = filter_test1_3;
var channel = ios.newChannel2("http://www.mozilla.org/",
null,
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
var channel = NetUtil.newChannel({
uri: "http://www.mozilla.org/",
loadUsingSystemPrincipal: true
});
var req = pps.asyncResolve(channel, 0, cb);
}
@ -411,15 +379,10 @@ function filter_test1_3(pi) {
var filter_3_1;
function run_filter_test3() {
var channel = ios.newChannel2("http://www.mozilla.org/",
null,
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
var channel = NetUtil.newChannel({
uri: "http://www.mozilla.org/",
loadUsingSystemPrincipal: true
});
// Push a filter and verify the results asynchronously
filter_3_1 = new TestFilter("http", "foo", 8080, 0, 10);
@ -437,15 +400,10 @@ function filter_test3_1(pi) {
}
function run_pref_test() {
var channel = ios.newChannel2("http://www.mozilla.org/",
null,
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
var channel = NetUtil.newChannel({
uri: "http://www.mozilla.org/",
loadUsingSystemPrincipal: true
});
// Verify 'direct' setting
prefs.setIntPref("network.proxy.type", 0);
@ -464,14 +422,10 @@ function pref_test1_1(pi)
var cb = new resolveCallback();
cb.nextFunction = pref_test1_2;
var channel = ios.newChannel2("http://www.mozilla.org/",
null,
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
var channel = NetUtil.newChannel({
uri: "http://www.mozilla.org/",
loadUsingSystemPrincipal: true
});
var req = pps.asyncResolve(channel, 0, cb);
}
@ -486,14 +440,10 @@ function pref_test1_2(pi)
var cb = new resolveCallback();
cb.nextFunction = pref_test1_3;
var channel = ios.newChannel2("http://www.mozilla.org/",
null,
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
var channel = NetUtil.newChannel({
uri: "http://www.mozilla.org/",
loadUsingSystemPrincipal: true
});
var req = pps.asyncResolve(channel, 0, cb);
}
@ -510,14 +460,10 @@ function pref_test1_3(pi)
var cb = new resolveCallback();
cb.nextFunction = pref_test1_4;
var channel = ios.newChannel2("http://www.mozilla.org/",
null,
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
var channel = NetUtil.newChannel({
uri: "http://www.mozilla.org/",
loadUsingSystemPrincipal: true
});
var req = pps.asyncResolve(channel, 0, cb);
}
@ -575,15 +521,10 @@ function run_pac_test() {
'function FindProxyForURL(url, host) {' +
' return "PROXY foopy:8080; DIRECT";' +
'}';
var channel = ios.newChannel2("http://www.mozilla.org/",
null,
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
var channel = NetUtil.newChannel({
uri: "http://www.mozilla.org/",
loadUsingSystemPrincipal: true
});
// Configure PAC
prefs.setIntPref("network.proxy.type", 2);
@ -596,15 +537,10 @@ function run_pac2_test() {
'function FindProxyForURL(url, host) {' +
' return "HTTPS foopy:8080; DIRECT";' +
'}';
var channel = ios.newChannel2("http://www.mozilla.org/",
null,
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
var channel = NetUtil.newChannel({
uri: "http://www.mozilla.org/",
loadUsingSystemPrincipal: true
});
// Configure PAC
originalTLSProxy = prefs.getBoolPref("network.proxy.proxy_over_tls");
@ -619,15 +555,10 @@ function run_pac3_test() {
'function FindProxyForURL(url, host) {' +
' return "HTTPS foopy:8080; DIRECT";' +
'}';
var channel = ios.newChannel2("http://www.mozilla.org/",
null,
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
var channel = NetUtil.newChannel({
uri: "http://www.mozilla.org/",
loadUsingSystemPrincipal: true
});
// Configure PAC
prefs.setCharPref("network.proxy.autoconfig_url", pac);
prefs.setBoolPref("network.proxy.proxy_over_tls", false);
@ -662,14 +593,10 @@ function run_pac4_test() {
' && myAppOrigin() == "' + appOrigin + '")' +
' return "PROXY foopy:8080; DIRECT";' +
'}';
var channel = ios.newChannel2("http://www.mozilla.org/",
null,
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
var channel = NetUtil.newChannel({
uri: "http://www.mozilla.org/",
loadUsingSystemPrincipal: true
});
channel.notificationCallbacks =
AppsUtils.createLoadContext(appId, isInBrowser);
@ -713,15 +640,10 @@ TestResolveCancelationCallback.prototype = {
};
function run_pac_cancel_test() {
var channel = ios.newChannel2("http://www.mozilla.org/",
null,
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
var channel = NetUtil.newChannel({
uri: "http://www.mozilla.org/",
loadUsingSystemPrincipal: true
});
// Configure PAC
var pac = 'data:text/plain,' +
'function FindProxyForURL(url, host) {' +
@ -761,15 +683,10 @@ function check_host_filters_cb()
function check_host_filter(i) {
var uri;
dump("*** uri=" + hostList[i] + " bShouldBeFiltered=" + bShouldBeFiltered + "\n");
var channel = ios.newChannel2(hostList[i],
null,
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
var channel = NetUtil.newChannel({
uri: hostList[i],
loadUsingSystemPrincipal: true
});
var cb = new resolveCallback();
cb.nextFunction = host_filter_cb;
var req = pps.asyncResolve(channel, 0, cb);
@ -872,15 +789,10 @@ function run_myipaddress_test()
// no traffic to this IP is ever sent, it is just a public IP that
// does not require DNS to determine a route.
var channel = ios.newChannel2("http://192.0.43.10/",
null,
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
var channel = NetUtil.newChannel({
uri: "http://192.0.43.10/",
loadUsingSystemPrincipal: true
});
prefs.setIntPref("network.proxy.type", 2);
prefs.setCharPref("network.proxy.autoconfig_url", pac);
@ -915,14 +827,10 @@ function run_myipaddress_test_2()
' return "PROXY " + myaddr + ":5678";' +
'}';
var channel = ios.newChannel2("http://www.mozilla.org/",
null,
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
var channel = NetUtil.newChannel({
uri: "http://www.mozilla.org/",
loadUsingSystemPrincipal: true
});
prefs.setIntPref("network.proxy.type", 2);
prefs.setCharPref("network.proxy.autoconfig_url", pac);
@ -951,15 +859,10 @@ function run_failed_script_test()
var pac = 'data:text/plain,' +
'\nfor(;\n';
var channel = ios.newChannel2("http://www.mozilla.org/",
null,
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
var channel = NetUtil.newChannel({
uri: "http://www.mozilla.org/",
loadUsingSystemPrincipal: true
});
prefs.setIntPref("network.proxy.type", 2);
prefs.setCharPref("network.proxy.autoconfig_url", pac);
@ -985,15 +888,11 @@ function failed_script_callback(pi)
obs = obs.QueryInterface(Components.interfaces.nsIObserverService);
obs.addObserver(directFilterListener, "http-on-modify-request", false);
var chan = ios.newChannel2("http://127.0.0.1:7247",
"",
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
chan.asyncOpen(directFilterListener, chan);
var chan = NetUtil.newChannel({
uri: "http://127.0.0.1:7247",
loadUsingSystemPrincipal: true
});
chan.asyncOpen2(directFilterListener);
}
var directFilterListener = {
@ -1038,15 +937,10 @@ function run_isresolvable_test()
' return "PROXY 127.0.0.1:1234";' +
'}';
var channel = ios.newChannel2("http://www.mozilla.org/",
null,
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
var channel = NetUtil.newChannel({
uri: "http://www.mozilla.org/",
loadUsingSystemPrincipal: true
});
prefs.setIntPref("network.proxy.type", 2);
prefs.setCharPref("network.proxy.autoconfig_url", pac);

View File

@ -1,19 +1,13 @@
Cu.import("resource://testing-common/httpd.js");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/NetUtil.jsm");
var httpServer = null;
function make_channel(url, callback, ctx) {
var ios = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
return ios.newChannel2(url,
"",
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
return NetUtil.newChannel({
uri: url,
loadUsingSystemPrincipal: true
});
}
const responseBody = "response body";
@ -54,6 +48,6 @@ function run_test()
var chan = make_channel("http://localhost:" +
httpServer.identity.primaryPort + "/content");
chan.notificationCallbacks = nc;
chan.asyncOpen(new ChannelListener(finish_test, null, CL_EXPECT_FAILURE), null);
chan.asyncOpen2(new ChannelListener(finish_test, null, CL_EXPECT_FAILURE));
do_test_pending();
}

View File

@ -1,19 +1,13 @@
Cu.import("resource://testing-common/httpd.js");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/NetUtil.jsm");
var httpServer = null;
function make_channel(url, callback, ctx) {
var ios = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
return ios.newChannel2(url,
"",
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
return NetUtil.newChannel({
uri: url,
loadUsingSystemPrincipal: true
});
}
const responseBody = "response body";
@ -55,7 +49,7 @@ function run_test()
var chan = make_channel("http://localhost:" +
httpServer.identity.primaryPort + "/content");
chan.asyncOpen(new ChannelListener(finish_test, null, CL_EXPECT_FAILURE), null);
chan.asyncOpen2(new ChannelListener(finish_test, null, CL_EXPECT_FAILURE));
chan.cancel(Cr.NS_BINDING_ABORTED);
do_test_pending();
}

View File

@ -1,19 +1,10 @@
Cu.import("resource://testing-common/httpd.js");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/NetUtil.jsm");
var httpServer = null;
function make_channel(url, callback, ctx) {
var ios = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
return ios.newChannel2(url,
"",
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
return NetUtil.newChannel({uri: url, loadUsingSystemPrincipal: true});
}
const responseBody = "response body";
@ -47,6 +38,6 @@ function run_test()
var chan = make_channel("http://localhost:" +
httpServer.identity.primaryPort + "/content");
chan.asyncOpen(new ChannelListener(finish_test, null), null);
chan.asyncOpen2(new ChannelListener(finish_test, null));
do_test_pending();
}

View File

@ -1,19 +1,10 @@
Cu.import("resource://testing-common/httpd.js");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/NetUtil.jsm");
var httpserver = null;
function make_channel(url, callback, ctx) {
var ios = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
return ios.newChannel2(url,
"",
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
return NetUtil.newChannel({uri: url, loadUsingSystemPrincipal: true});
}
const responseBody = "response body";
@ -76,13 +67,13 @@ function finish_test() {
function start_cache_read() {
var chan = make_channel("http://localhost:" +
httpserver.identity.primaryPort + "/cached/test.gz");
chan.asyncOpen(new ChannelListener(finish_test, null), null);
chan.asyncOpen2(new ChannelListener(finish_test, null));
}
function start_canceler() {
var chan = make_channel("http://localhost:" +
httpserver.identity.primaryPort + "/cached/test.gz");
chan.asyncOpen(new Canceler(start_cache_read), null);
chan.asyncOpen2(new Canceler(start_cache_read));
}
function run_test() {
@ -92,6 +83,6 @@ function run_test() {
var chan = make_channel("http://localhost:" +
httpserver.identity.primaryPort + "/cached/test.gz");
chan.asyncOpen(new ChannelListener(start_canceler, null), null);
chan.asyncOpen2(new ChannelListener(start_canceler, null));
do_test_pending();
}