Bug 757860 - Load JS HTTP server as a module; r=rnewman

--HG--
rename : services/common/tests/unit/aitcserver.js => services/common/aitcserver.js
rename : services/common/tests/unit/storageserver.js => services/common/storageserver.js
This commit is contained in:
Gregory Szorc 2012-06-29 13:28:17 -07:00
Родитель e921c68d8f
Коммит e26986f8c8
13 изменённых файлов: 21 добавлений и 33 удалений

Просмотреть файл

@ -31,9 +31,8 @@ libs::
TEST_DIRS += tests
# TODO enable once build infra supports testing modules.
#TESTING_JS_MODULES := aitcserver.js storageserver.js
#TESTING_JS_MODULE_DIR := services-common
TESTING_JS_MODULES := aitcserver.js storageserver.js
TESTING_JS_MODULE_DIR := services-common
# What follows is a helper to launch a standalone storage server instance.
# Most of the code lives in a Python script in the tests directory. If we

Просмотреть файл

@ -4,8 +4,6 @@
"use strict";
// TODO enable once build infra supports test modules.
/*
const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
const EXPORTED_SYMBOLS = [
@ -14,7 +12,6 @@ const EXPORTED_SYMBOLS = [
];
Cu.import("resource://testing-common/httpd.js");
*/
Cu.import("resource://services-crypto/utils.js");
Cu.import("resource://services-common/log4moz.js");
Cu.import("resource://services-common/utils.js");
@ -133,7 +130,7 @@ AITCServer10User.prototype = {
function AITCServer10Server() {
this._log = Log4Moz.repository.getLogger("Services.Common.AITCServer");
this.server = new nsHttpServer();
this.server = new HttpServer();
this.port = null;
this.users = {};
this.autoCreateUsers = false;

Просмотреть файл

@ -8,8 +8,6 @@
* The server should not be used for any production purposes.
*/
// TODO enable once build infra supports testing modules.
/*
const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
const EXPORTED_SYMBOLS = [
@ -21,7 +19,6 @@ const EXPORTED_SYMBOLS = [
];
Cu.import("resource://testing-common/httpd.js");
*/
Cu.import("resource://services-common/async.js");
Cu.import("resource://services-common/log4moz.js");
Cu.import("resource://services-common/utils.js");
@ -853,7 +850,7 @@ let StorageServerCallback = {
*/
function StorageServer(callback) {
this.callback = callback || {__proto__: StorageServerCallback};
this.server = new nsHttpServer();
this.server = new HttpServer();
this.started = false;
this.users = {};
this._log = Log4Moz.repository.getLogger(STORAGE_HTTP_LOGGER);

Просмотреть файл

@ -1,14 +1,11 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
const {classes: Cc, interfaces: Ci, results: Cr, utils: Cu, manager: Cm} = Components;
// Where to bind test HTTP servers to.
const TEST_SERVER_URL = "http://localhost:8080/";
// This has the side-effect of populating Cc, Ci, Cu, Cr. It's best not to
// ask questions and just accept it.
do_load_httpd_js();
const Cm = Components.manager;
let gSyncProfile = do_get_profile();
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
@ -54,4 +51,4 @@ function addResourceAlias() {
handler.setSubstitution("services-" + module, uri);
}
}
addResourceAlias();
addResourceAlias();

Просмотреть файл

@ -2,6 +2,7 @@
* 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/. */
Cu.import("resource://testing-common/httpd.js");
Cu.import("resource://services-common/log4moz.js");
Cu.import("resource://services-common/utils.js");
@ -93,7 +94,7 @@ function get_server_port() {
function httpd_setup (handlers, port) {
let port = port || 8080;
let server = new nsHttpServer();
let server = new HttpServer();
for (let path in handlers) {
server.registerPathHandler(path, handlers[path]);
}

Просмотреть файл

@ -6,8 +6,7 @@
Cu.import("resource://services-common/rest.js");
Cu.import("resource://services-common/utils.js");
// TODO enable once build infra supports testing modules.
//Cu.import("resource://testing-common/services-common/aitcserver.js");
Cu.import("resource://testing-common/services-common/aitcserver.js");
function run_test() {
initTestLogging("Trace");

Просмотреть файл

@ -22,11 +22,8 @@ function run_test() {
Components.utils.import(resource, {});
}
// TODO enable once build infra supports testing modules.
/*
for each (let m in test_modules) {
let resource = "resource://testing-common/services-common/" + m;
Components.utils.import(resource, {});
}
*/
}

Просмотреть файл

@ -616,7 +616,7 @@ add_test(function test_abort() {
* channel activity until the request is automatically canceled.
*/
add_test(function test_timeout() {
let server = new nsHttpServer();
let server = new HttpServer();
let server_connection;
server._handler.handleResponse = function(connection) {
// This is a handler that doesn't do anything, just keeps the connection
@ -633,7 +633,9 @@ add_test(function test_timeout() {
do_check_eq(error.result, Cr.NS_ERROR_NET_TIMEOUT);
do_check_eq(this.status, this.ABORTED);
_("Closing connection.");
server_connection.close();
_("Shutting down server.");
server.stop(run_next_test);
});
});

Просмотреть файл

@ -4,8 +4,7 @@
Cu.import("resource://services-common/async.js");
Cu.import("resource://services-common/rest.js");
Cu.import("resource://services-common/utils.js");
// TODO enable once build infra supports testing modules.
//Cu.import("resource://testing-common/services-common/storageserver.js");
Cu.import("resource://testing-common/services-common/storageserver.js");
const PORT = 8080;
const DEFAULT_USER = "123";

Просмотреть файл

@ -1,5 +1,5 @@
[DEFAULT]
head = head_global.js head_helpers.js head_http.js aitcserver.js storageserver.js
head = head_global.js head_helpers.js head_http.js
tail =
# Test load modules first so syntax failures are caught early.

Просмотреть файл

@ -527,7 +527,7 @@ let SyncServerCallback = {
*/
function SyncServer(callback) {
this.callback = callback || {__proto__: SyncServerCallback};
this.server = new nsHttpServer();
this.server = new HttpServer();
this.started = false;
this.users = {};
this._log = Log4Moz.repository.getLogger(SYNC_HTTP_LOGGER);
@ -539,7 +539,7 @@ function SyncServer(callback) {
}
SyncServer.prototype = {
port: 8080,
server: null, // nsHttpServer.
server: null, // HttpServer.
users: null, // Map of username => {collections, password}.
/**
@ -775,8 +775,8 @@ SyncServer.prototype = {
},
/**
* This is invoked by the nsHttpServer. `this` is bound to the SyncServer;
* `handler` is the nsHttpServer's handler.
* This is invoked by the HttpServer. `this` is bound to the SyncServer;
* `handler` is the HttpServer's handler.
*
* TODO: need to use the correct Sync API response codes and errors here.
* TODO: Basic Auth.

Просмотреть файл

@ -170,7 +170,7 @@ add_test(function test_disabled_install_semantics() {
server.createContents(USER, contents);
server.start();
let amoServer = new nsHttpServer();
let amoServer = new HttpServer();
amoServer.registerFile("/search/guid:addon1%40tests.mozilla.org",
do_get_file("addon1-search.xml"));

Просмотреть файл

@ -42,7 +42,7 @@ function createRecordForThisApp(id, addonId, enabled, deleted) {
function createAndStartHTTPServer(port) {
try {
let server = new nsHttpServer();
let server = new HttpServer();
let bootstrap1XPI = ExtensionsTestPath("/addons/test_bootstrap1_1.xpi");