import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo

This commit is contained in:
Roy Tam 2018-01-19 03:59:58 +08:00
commit dcd9973243
150858 changed files with 23884658 additions and 0 deletions

View file

@ -0,0 +1,43 @@
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
function is_app_offline(appId) {
let ioservice = Cc['@mozilla.org/network/io-service;1'].
getService(Ci.nsIIOService);
return ioservice.isAppOffline(appId);
}
var events_observed_no = 0;
// Holds the last observed app-offline event
var info = null;
function observer(aSubject, aTopic, aData) {
events_observed_no++;
info = aSubject.QueryInterface(Ci.nsIAppOfflineInfo);
dump("ChildObserver - subject: {" + aSubject.appId + ", " + aSubject.mode + "} ");
}
// Add observer for the app-offline notification
function run_test() {
Services.obs.addObserver(observer, "network:app-offline-status-changed", false);
}
// Chech that the app has the proper offline status
function check_status(appId, status)
{
do_check_eq(is_app_offline(appId), status == Ci.nsIAppOfflineInfo.OFFLINE);
}
// Check that the app has the proper offline status
// and that the correct notification has been received
function check_notification_and_status(appId, status) {
do_check_eq(info.appId, appId);
do_check_eq(info.mode, status);
do_check_eq(is_app_offline(appId), status == Ci.nsIAppOfflineInfo.OFFLINE);
}
// Remove the observer from the child process
function finished() {
Services.obs.removeObserver(observer, "network:app-offline-status-changed");
do_check_eq(events_observed_no, 2);
}

View file

@ -0,0 +1,45 @@
/**
* Send HTTP requests and notify the parent about their channelId
*/
Cu.import("resource://gre/modules/NetUtil.jsm");
let shouldQuit = false;
function run_test() {
// keep the event loop busy and the test alive until a "finish" command
// is issued by parent
do_timeout(100, function keepAlive() {
if (!shouldQuit) {
do_timeout(100, keepAlive);
}
});
}
function makeRequest(uri) {
let requestChannel = NetUtil.newChannel({uri, loadUsingSystemPrincipal: true});
requestChannel.asyncOpen2(new ChannelListener(checkResponse, requestChannel));
requestChannel.QueryInterface(Ci.nsIHttpChannel);
dump(`Child opened request: ${uri}, channelId=${requestChannel.channelId}\n`);
}
function checkResponse(request, buffer, requestChannel) {
// notify the parent process about the original request channel
requestChannel.QueryInterface(Ci.nsIHttpChannel);
do_send_remote_message(`request:${requestChannel.channelId}`);
// the response channel can be different (if it was redirected)
let responseChannel = request.QueryInterface(Ci.nsIHttpChannel);
let uri = responseChannel.URI.spec;
let origUri = responseChannel.originalURI.spec;
let id = responseChannel.channelId;
dump(`Child got response to: ${uri} (orig=${origUri}), channelId=${id}\n`);
// notify the parent process about this channel's ID
do_send_remote_message(`response:${id}`);
}
function finish() {
shouldQuit = true;
}

View file

@ -0,0 +1,4 @@
var Cc = Components.classes;
var Ci = Components.interfaces;
var Cu = Components.utils;
var Cr = Components.results;

View file

@ -0,0 +1,8 @@
//
// Load standard base class for network tests into child process
//
Components.utils.import('resource://gre/modules/XPCOMUtils.jsm');
load("../unit/head_channels.js");

View file

@ -0,0 +1,3 @@
function run_test() {
run_test_in_child("../unit/test_XHR_redirects.js");
}

View file

@ -0,0 +1,3 @@
function run_test() {
run_test_in_child("../unit/test_alt-data_simple.js");
}

View file

@ -0,0 +1,3 @@
function run_test() {
run_test_in_child("../unit/test_alt-data_stream.js");
}

View file

@ -0,0 +1,7 @@
Cu.import("resource://gre/modules/Services.jsm");
function run_test() {
// Allow all cookies.
Services.prefs.setIntPref("network.cookie.cookieBehavior", 0);
run_test_in_child("../unit/test_bug248970_cookie.js");
}

View file

@ -0,0 +1,6 @@
Cu.import("resource://gre/modules/Services.jsm");
function run_test() {
Services.prefs.setIntPref("network.cookie.cookieBehavior", 1);
run_test_in_child("../unit/test_bug528292.js");
}

View file

@ -0,0 +1,4 @@
function run_test() {
run_test_in_child("../unit/head_cache2.js");
run_test_in_child("../unit/test_cache_jar.js");
}

View file

@ -0,0 +1,7 @@
//
// Run test script in content process instead of chrome (xpcshell's default)
//
function run_test() {
run_test_in_child("../unit/test_cacheflags.js");
}

View file

@ -0,0 +1,3 @@
function run_test() {
run_test_in_child("../unit/test_channel_close.js");
}

View file

@ -0,0 +1,109 @@
Cu.import("resource://testing-common/httpd.js");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/Promise.jsm");
/*
* Test that when doing HTTP requests, the nsIHttpChannel is detected in
* both parent and child and shares the same channelId across processes.
*/
let httpserver;
let port;
function startHttpServer() {
httpserver = new HttpServer();
httpserver.registerPathHandler("/resource", (metadata, response) => {
response.setStatusLine(metadata.httpVersion, 200, "OK");
response.setHeader("Content-Type", "text/plain", false);
response.setHeader("Cache-Control", "no-cache", false);
response.bodyOutputStream.write("data", 4);
});
httpserver.registerPathHandler("/redirect", (metadata, response) => {
response.setStatusLine(metadata.httpVersion, 302, "Redirect");
response.setHeader("Location", "/resource", false);
response.setHeader("Cache-Control", "no-cache", false);
});
httpserver.start(-1);
port = httpserver.identity.primaryPort;
}
function stopHttpServer(next) {
httpserver.stop(next);
}
let expectedParentChannels = [];
let expectedChildMessages = [];
let maybeFinishWaitForParentChannels;
let parentChannelsDone = new Promise(resolve => {
maybeFinishWaitForParentChannels = () => {
if (expectedParentChannels.length == 0) {
dump("All expected parent channels were detected\n");
resolve();
}
};
});
function observer(subject, topic, data) {
let channel = subject.QueryInterface(Ci.nsIHttpChannel);
let uri = channel.URI.spec;
let origUri = channel.originalURI.spec;
let id = channel.channelId;
dump(`Parent detected channel: ${uri} (orig=${origUri}): channelId=${id}\n`);
// did we expect a new channel?
let expected = expectedParentChannels.shift();
do_check_true(!!expected);
// Start waiting for the messages about request/response from child
for (let event of expected) {
let message = `${event}:${id}`;
dump(`Expecting message from child: ${message}\n`);
let messagePromise = do_await_remote_message(message).then(() => {
dump(`Expected message from child arrived: ${message}\n`);
});
expectedChildMessages.push(messagePromise);
}
// If we don't expect any further parent channels, finish the parent wait
maybeFinishWaitForParentChannels();
}
function run_test() {
startHttpServer();
Services.obs.addObserver(observer, "http-on-modify-request", false);
run_test_in_child("child_channel_id.js", makeRequests);
}
function makeRequests() {
// First, a normal request without any redirect. Expect one channel detected
// in parent, used by both request and response.
expectedParentChannels.push(["request", "response"]);
sendCommand(`makeRequest("http://localhost:${port}/resource");`);
// Second request will be redirected. Expect two channels, one with the
// original request, then the redirected one which gets the final response.
expectedParentChannels.push(["request"], ["response"]);
sendCommand(`makeRequest("http://localhost:${port}/redirect");`);
waitForParentChannels();
}
function waitForParentChannels() {
parentChannelsDone.then(waitForChildMessages);
}
function waitForChildMessages() {
dump(`Waiting for ${expectedChildMessages.length} child messages\n`);
Promise.all(expectedChildMessages).then(finish);
}
function finish() {
Services.obs.removeObserver(observer, "http-on-modify-request");
sendCommand("finish();", () => stopHttpServer(do_test_finished));
}

View file

@ -0,0 +1,7 @@
//
// Run test script in content process instead of chrome (xpcshell's default)
//
function run_test() {
run_test_in_child("../unit/test_chunked_responses.js");
}

View file

@ -0,0 +1,11 @@
//
// Run test script in content process instead of chrome (xpcshell's default)
//
Cu.import("resource://gre/modules/Services.jsm");
function run_test() {
// Allow all cookies.
Services.prefs.setIntPref("network.cookie.cookieBehavior", 0);
run_test_in_child("../unit/test_cookie_header.js");
}

View file

@ -0,0 +1,7 @@
Cu.import("resource://gre/modules/Services.jsm");
function run_test() {
// Allow all cookies.
Services.prefs.setIntPref("network.cookie.cookieBehavior", 0);
run_test_in_child("../unit/test_cookiejars.js");
}

View file

@ -0,0 +1,7 @@
//
// Run test script in content process instead of chrome (xpcshell's default)
//
function run_test() {
run_test_in_child("../unit/test_dns_cancel.js");
}

View file

@ -0,0 +1,7 @@
//
// Run test script in content process instead of chrome (xpcshell's default)
//
function run_test() {
run_test_in_child("../unit/test_dns_per_interface.js");
}

View file

@ -0,0 +1,7 @@
//
// Run test script in content process instead of chrome (xpcshell's default)
//
function run_test() {
run_test_in_child("../unit/test_dns_service.js");
}

View file

@ -0,0 +1,7 @@
//
// Run test script in content process instead of chrome (xpcshell's default)
//
function run_test() {
run_test_in_child("../unit/test_duplicate_headers.js");
}

View file

@ -0,0 +1,7 @@
//
// Run test script in content process instead of chrome (xpcshell's default)
//
function run_test() {
run_test_in_child("../unit/test_event_sink.js");
}

View file

@ -0,0 +1,3 @@
function run_test() {
run_test_in_child("../unit/test_getHost.js");
}

View file

@ -0,0 +1,7 @@
//
// Run test script in content process instead of chrome (xpcshell's default)
//
function run_test() {
run_test_in_child("../unit/test_head.js");
}

View file

@ -0,0 +1,7 @@
//
// Run test script in content process instead of chrome (xpcshell's default)
//
function run_test() {
run_test_in_child("../unit/test_headers.js");
}

View file

@ -0,0 +1,3 @@
function run_test() {
run_test_in_child("../unit/test_httpsuspend.js");
}

View file

@ -0,0 +1,7 @@
//
// Run test script in content process instead of chrome (xpcshell's default)
//
function run_test() {
run_test_in_child("../unit/test_original_sent_received_head.js");
}

View file

@ -0,0 +1,3 @@
function run_test() {
run_test_in_child("../unit/test_post.js");
}

View file

@ -0,0 +1,36 @@
// This is the bit that runs in the parent process when the test begins. Here's
// what happens:
//
// - Load the entire single-process test in the parent
// - Setup the test harness within the child process
// - Send a command to the child to have the single-process test loaded there, as well
// - Send a command to the child to make the predictor available
// - run_test_real in the parent
// - run_test_real does a bunch of pref-setting and other fun things on the parent
// - once all that's done, it calls run_next_test IN THE PARENT
// - every time run_next_test is called, it is called IN THE PARENT
// - the test that gets started then does any parent-side setup that's necessary
// - once the parent-side setup is done, it calls continue_<testname> IN THE CHILD
// - when the test is done running on the child, the child calls predictor.reset
// this causes some code to be run on the parent which, when complete, sends an
// obserer service notification IN THE PARENT, which causes run_next_test to be
// called again, bumping us up to the top of the loop outlined here
// - when the final test is done, cleanup happens IN THE PARENT and we're done
//
// This is a little confusing, but it's what we have to do in order to have some
// things that must run on the parent (the setup - opening cache entries, etc)
// but with most of the test running on the child (calls to the predictor api,
// verification, etc).
//
function run_test() {
var test_path = do_get_file("../unit/test_predictor.js").path.replace(/\\/g, "/");
load(test_path);
do_load_child_test_harness();
do_test_pending();
sendCommand("load(\"" + test_path + "\");", function () {
sendCommand("predictor = Cc[\"@mozilla.org/network/predictor;1\"].getService(Ci.nsINetworkPredictor);", function() {
run_test_real();
do_test_finished();
});
});
}

View file

@ -0,0 +1,3 @@
function run_test() {
run_test_in_child("../unit/test_progress.js");
}

View file

@ -0,0 +1,7 @@
//
// Run test script in content process instead of chrome (xpcshell's default)
//
//
function run_test() {
run_test_in_child("../unit/test_redirect-caching_canceled.js");
}

View file

@ -0,0 +1,7 @@
//
// Run test script in content process instead of chrome (xpcshell's default)
//
//
function run_test() {
run_test_in_child("../unit/test_redirect-caching_failure.js");
}

View file

@ -0,0 +1,7 @@
//
// Run test script in content process instead of chrome (xpcshell's default)
//
//
function run_test() {
run_test_in_child("../unit/test_redirect-caching_passing.js");
}

View file

@ -0,0 +1,7 @@
//
// Run test script in content process instead of chrome (xpcshell's default)
//
//
function run_test() {
run_test_in_child("../unit/test_redirect_canceled.js");
}

View file

@ -0,0 +1,7 @@
//
// Run test script in content process instead of chrome (xpcshell's default)
//
function run_test() {
run_test_in_child("../unit/test_redirect_different-protocol.js");
}

View file

@ -0,0 +1,7 @@
//
// Run test script in content process instead of chrome (xpcshell's default)
//
function run_test() {
run_test_in_child("../unit/test_redirect_failure.js");
}

View file

@ -0,0 +1,3 @@
function run_test() {
run_test_in_child("../unit/test_redirect_from_script.js");
}

View file

@ -0,0 +1,7 @@
//
// Run test script in content process instead of chrome (xpcshell's default)
//
function run_test() {
run_test_in_child("../unit/test_redirect_history.js");
}

View file

@ -0,0 +1,7 @@
//
// Run test script in content process instead of chrome (xpcshell's default)
//
function run_test() {
run_test_in_child("../unit/test_redirect_passing.js");
}

View file

@ -0,0 +1,3 @@
function run_test() {
run_test_in_child("../unit/test_reentrancy.js");
}

View file

@ -0,0 +1,7 @@
//
// Run test script in content process instead of chrome (xpcshell's default)
//
function run_test() {
run_test_in_child("../unit/test_reply_without_content_type.js");
}

View file

@ -0,0 +1,3 @@
function run_test() {
run_test_in_child("../unit/test_resumable_channel.js");
}

View file

@ -0,0 +1,7 @@
//
// Run test script in content process instead of chrome (xpcshell's default)
//
function run_test() {
run_test_in_child("../unit/test_simple.js");
}

View file

@ -0,0 +1,3 @@
function run_test() {
run_test_in_child("../unit/test_synthesized_response.js");
}

View file

@ -0,0 +1,3 @@
function run_test() {
run_test_in_child("../unit/test_xmlhttprequest.js");
}

View file

@ -0,0 +1,99 @@
[DEFAULT]
head = head_channels_clone.js head_cc.js
tail =
skip-if = toolkit == 'android'
support-files =
child_channel_id.js
!/netwerk/test/unit/test_XHR_redirects.js
!/netwerk/test/unit/test_bug248970_cookie.js
!/netwerk/test/unit/test_bug528292.js
!/netwerk/test/unit/test_cache_jar.js
!/netwerk/test/unit/test_cacheflags.js
!/netwerk/test/unit/test_channel_close.js
!/netwerk/test/unit/test_cookie_header.js
!/netwerk/test/unit/test_cookiejars.js
!/netwerk/test/unit/test_dns_cancel.js
!/netwerk/test/unit/test_dns_per_interface.js
!/netwerk/test/unit/test_dns_service.js
!/netwerk/test/unit/test_duplicate_headers.js
!/netwerk/test/unit/test_event_sink.js
!/netwerk/test/unit/test_getHost.js
!/netwerk/test/unit/test_head.js
!/netwerk/test/unit/test_headers.js
!/netwerk/test/unit/test_httpsuspend.js
!/netwerk/test/unit/test_post.js
!/netwerk/test/unit/test_predictor.js
!/netwerk/test/unit/test_progress.js
!/netwerk/test/unit/test_redirect-caching_canceled.js
!/netwerk/test/unit/test_redirect-caching_failure.js
!/netwerk/test/unit/test_redirect-caching_passing.js
!/netwerk/test/unit/test_redirect_canceled.js
!/netwerk/test/unit/test_redirect_different-protocol.js
!/netwerk/test/unit/test_redirect_failure.js
!/netwerk/test/unit/test_redirect_from_script.js
!/netwerk/test/unit/test_redirect_history.js
!/netwerk/test/unit/test_redirect_passing.js
!/netwerk/test/unit/test_reentrancy.js
!/netwerk/test/unit/test_reply_without_content_type.js
!/netwerk/test/unit/test_resumable_channel.js
!/netwerk/test/unit/test_simple.js
!/netwerk/test/unit/test_synthesized_response.js
!/netwerk/test/unit/test_xmlhttprequest.js
!/netwerk/test/unit/head_channels.js
!/netwerk/test/unit/head_cache2.js
!/netwerk/test/unit/data/image.png
!/netwerk/test/unit/data/system_root.lnk
!/netwerk/test/unit/data/test_psl.txt
!/netwerk/test/unit/data/test_readline1.txt
!/netwerk/test/unit/data/test_readline2.txt
!/netwerk/test/unit/data/test_readline3.txt
!/netwerk/test/unit/data/test_readline4.txt
!/netwerk/test/unit/data/test_readline5.txt
!/netwerk/test/unit/data/test_readline6.txt
!/netwerk/test/unit/data/test_readline7.txt
!/netwerk/test/unit/data/test_readline8.txt
!/netwerk/test/unit/data/signed_win.exe
!/netwerk/test/unit/test_alt-data_simple.js
!/netwerk/test/unit/test_alt-data_stream.js
[test_bug528292_wrap.js]
[test_bug248970_cookie_wrap.js]
[test_cacheflags_wrap.js]
[test_cache_jar_wrap.js]
[test_channel_close_wrap.js]
[test_cookie_header_wrap.js]
[test_cookiejars_wrap.js]
[test_dns_cancel_wrap.js]
[test_dns_per_interface_wrap.js]
[test_dns_service_wrap.js]
[test_duplicate_headers_wrap.js]
[test_event_sink_wrap.js]
[test_head_wrap.js]
[test_headers_wrap.js]
[test_httpsuspend_wrap.js]
[test_post_wrap.js]
[test_predictor_wrap.js]
[test_progress_wrap.js]
[test_redirect-caching_canceled_wrap.js]
[test_redirect-caching_failure_wrap.js]
[test_redirect-caching_passing_wrap.js]
[test_redirect_canceled_wrap.js]
[test_redirect_failure_wrap.js]
# Do not test the channel.redirectTo() API under e10s until 827269 is resolved
[test_redirect_from_script_wrap.js]
skip-if = true
[test_redirect_passing_wrap.js]
[test_redirect_different-protocol_wrap.js]
[test_reentrancy_wrap.js]
[test_resumable_channel_wrap.js]
[test_simple_wrap.js]
[test_synthesized_response_wrap.js]
[test_xmlhttprequest_wrap.js]
[test_XHR_redirects.js]
[test_redirect_history_wrap.js]
[test_reply_without_content_type_wrap.js]
[test_getHost_wrap.js]
[test_alt-data_simple_wrap.js]
[test_alt-data_stream_wrap.js]
[test_original_sent_received_head_wrap.js]
[test_channel_id.js]