mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Test only - Bug 489230 - Use mock XHR for test_0050_general.js and additional cleanup. r=me
--HG-- rename : toolkit/mozapps/update/test/unit/data/aus-0110_general-1.mar => toolkit/mozapps/update/test/unit/data/aus-0110_general.mar rename : toolkit/mozapps/update/test/unit/data/aus-0110_general_ref_image1.png => toolkit/mozapps/update/test/unit/data/aus-0110_general_ref_image.png rename : toolkit/mozapps/update/test/unit/data/aus-0110_general-2.mar => toolkit/mozapps/update/test/unit/data/aus-0111_general.mar rename : toolkit/mozapps/update/test/unit/data/aus-0110_general_ref_image2.png => toolkit/mozapps/update/test/unit/data/aus-0111_general_ref_image.png
This commit is contained in:
parent
21cc8c0b17
commit
13a719963f
Before Width: | Height: | Size: 854 B After Width: | Height: | Size: 854 B |
Before Width: | Height: | Size: 759 B After Width: | Height: | Size: 759 B |
@ -107,11 +107,13 @@ function getPrefBranch() {
|
||||
|
||||
/**
|
||||
* Nulls out the most commonly used global vars used by tests as appropriate.
|
||||
* This is not in the tail file due to check-interactive executing the tail file
|
||||
* prior to _execute_test();.
|
||||
* This was moved here from the tail file due to check-interactive executing
|
||||
* the tail file prior to _execute_test(); (bug 384339). It hasn't been moved
|
||||
* back since it is easier to comment out the call to cleanUp when needed.
|
||||
*/
|
||||
function cleanUp() {
|
||||
gDirSvc.unregisterProvider(dirProvider);
|
||||
removeUpdateDirsAndFiles();
|
||||
gDirSvc.unregisterProvider(gDirProvider);
|
||||
|
||||
if (gXHR) {
|
||||
gXHRCallback = null;
|
||||
@ -132,12 +134,9 @@ function cleanUp() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the most commonly used global vars used by tests and
|
||||
* nsIApplicationUpdateService
|
||||
* Sets the most commonly used preferences used by tests
|
||||
*/
|
||||
function startAUS() {
|
||||
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1.0", "2.0");
|
||||
|
||||
function setDefaultPrefs() {
|
||||
var pb = getPrefBranch();
|
||||
// Don't display UI for a successful installation. Some apps may not set this
|
||||
// pref to false like Firefox does.
|
||||
@ -150,7 +149,15 @@ function startAUS() {
|
||||
pb.setBoolPref("extensions.update.enabled", false);
|
||||
pb.setBoolPref("browser.search.update", false);
|
||||
pb.setBoolPref("browser.microsummary.updateGenerators", false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes nsIApplicationUpdateService and the most commonly used global
|
||||
* vars used by tests.
|
||||
*/
|
||||
function startAUS() {
|
||||
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1.0", "2.0");
|
||||
setDefaultPrefs();
|
||||
gAUS = AUS_Cc["@mozilla.org/updates/update-service;1"].
|
||||
getService(AUS_Ci.nsIApplicationUpdateService);
|
||||
var os = AUS_Cc["@mozilla.org/observer-service;1"].
|
||||
@ -418,23 +425,13 @@ function writeStatusFile(aStatus) {
|
||||
* replaced.
|
||||
*/
|
||||
function writeFile(aFile, aText) {
|
||||
var fos = AUS_Cc["@mozilla.org/network/safe-file-output-stream;1"].
|
||||
var fos = AUS_Cc["@mozilla.org/network/file-output-stream;1"].
|
||||
createInstance(AUS_Ci.nsIFileOutputStream);
|
||||
if (!aFile.exists())
|
||||
aFile.create(AUS_Ci.nsILocalFile.NORMAL_FILE_TYPE, PERMS_FILE);
|
||||
fos.init(aFile, MODE_WRONLY | MODE_CREATE | MODE_TRUNCATE, PERMS_FILE, 0);
|
||||
fos.write(aText, aText.length);
|
||||
|
||||
if (fos instanceof AUS_Ci.nsISafeOutputStream) {
|
||||
try {
|
||||
fos.finish();
|
||||
}
|
||||
catch (e) {
|
||||
fos.close();
|
||||
}
|
||||
}
|
||||
else
|
||||
fos.close();
|
||||
fos.close();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -479,27 +476,6 @@ function getString(aName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggles network offline.
|
||||
*
|
||||
* Be sure to toggle back to online before the test finishes to prevent the
|
||||
* following from being printed to the test's log file.
|
||||
* WARNING: NS_ENSURE_TRUE(thread) failed: file c:/moz/mozilla-central/mozilla/netwerk/base/src/nsSocketTransportService2.cpp, line 115
|
||||
* WARNING: unable to post SHUTDOWN message
|
||||
*/
|
||||
function toggleOffline(aOffline) {
|
||||
const ioService = AUS_Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(AUS_Ci.nsIIOService);
|
||||
|
||||
try {
|
||||
ioService.manageOfflineStatus = !aOffline;
|
||||
}
|
||||
catch (e) {
|
||||
}
|
||||
if (ioService.offline != aOffline)
|
||||
ioService.offline = aOffline;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the bare bones XMLHttpRequest implementation below.
|
||||
*
|
||||
@ -627,7 +603,7 @@ const updateCheckListener = {
|
||||
*/
|
||||
function removeUpdateDirsAndFiles() {
|
||||
var appDir = getCurrentProcessDir();
|
||||
file = appDir.clone();
|
||||
var file = appDir.clone();
|
||||
file.append("active-update.xml");
|
||||
try {
|
||||
if (file.exists())
|
||||
@ -681,6 +657,8 @@ function removeUpdateDirsAndFiles() {
|
||||
* A nsIFile for the directory to be deleted
|
||||
*/
|
||||
function removeDirRecursive(aDir) {
|
||||
if (!aDir.exists())
|
||||
return;
|
||||
try {
|
||||
aDir.remove(true);
|
||||
return;
|
||||
@ -798,7 +776,7 @@ if (gProfD.exists())
|
||||
gProfD.remove(true);
|
||||
gProfD.create(AUS_Ci.nsIFile.DIRECTORY_TYPE, PERMS_DIRECTORY);
|
||||
|
||||
var dirProvider = {
|
||||
var gDirProvider = {
|
||||
getFile: function(prop, persistent) {
|
||||
switch (prop) {
|
||||
case NS_APP_USER_PROFILE_50_DIR:
|
||||
@ -818,4 +796,4 @@ var dirProvider = {
|
||||
throw AUS_Cr.NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
};
|
||||
gDirSvc.QueryInterface(AUS_Ci.nsIDirectoryService).registerProvider(dirProvider);
|
||||
gDirSvc.QueryInterface(AUS_Ci.nsIDirectoryService).registerProvider(gDirProvider);
|
||||
|
@ -36,10 +36,13 @@
|
||||
* ***** END LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
/* General nsIUpdateCheckListener onerror error code and statusText Tests */
|
||||
/* General nsIUpdateCheckListener onload and onerror error code and statusText
|
||||
Tests */
|
||||
|
||||
// Errors tested:
|
||||
// 200, 403, 404, 500, 2152398861, 2152398918, default (200)
|
||||
// 200, 403, 404, 500, 2152398849, 2152398862, 2152398864, 2152398867,
|
||||
// 2152398868, 2152398878, 2152398890, 2152398919, 2152398920, 2153390069,
|
||||
// 2152398918, 2152398861
|
||||
|
||||
var gNextRunFunc;
|
||||
var gExpectedStatusCode;
|
||||
@ -52,96 +55,154 @@ function run_test() {
|
||||
startUpdateChecker();
|
||||
getPrefBranch().setCharPref(PREF_APP_UPDATE_URL_OVERRIDE,
|
||||
URL_HOST + "update.xml");
|
||||
overrideXHR(callHandleEvent);
|
||||
do_timeout(0, "run_test_pt1()");
|
||||
}
|
||||
|
||||
function end_test() {
|
||||
stop_httpserver(do_test_finished);
|
||||
do_test_finished();
|
||||
cleanUp();
|
||||
}
|
||||
|
||||
// Custom error httpd handler used to return error codes we can't simulate
|
||||
function httpdErrorHandler(metadata, response) {
|
||||
response.setStatusLine(metadata.httpVersion, gExpectedStatusCode, "Error");
|
||||
// Callback function used by the custom XMLHttpRequest implementation to
|
||||
// call the nsIDOMEventListener's handleEvent method for onload.
|
||||
function callHandleEvent() {
|
||||
gXHR.status = gExpectedStatusCode;
|
||||
var e = { target: gXHR };
|
||||
gXHR.onload.handleEvent(e);
|
||||
}
|
||||
|
||||
// Helper functions for testing nsIUpdateCheckListener onerror error statusText
|
||||
function run_test_helper(aMsg, aExpectedStatusCode, aExpectedStatusTextCode,
|
||||
aNextRunFunc) {
|
||||
// Helper functions for testing nsIUpdateCheckListener statusText
|
||||
function run_test_helper(aNextRunFunc, aExpectedStatusCode, aMsg) {
|
||||
gStatusCode = null;
|
||||
gStatusText = null;
|
||||
gCheckFunc = check_test_helper;
|
||||
gNextRunFunc = aNextRunFunc;
|
||||
gExpectedStatusCode = gResponseStatusCode = aExpectedStatusCode;
|
||||
gExpectedStatusText = getStatusText(aExpectedStatusTextCode);
|
||||
gExpectedStatusCode = aExpectedStatusCode;
|
||||
dump("Testing: " + aMsg + "\n");
|
||||
gUpdateChecker.checkForUpdates(updateCheckListener, true);
|
||||
}
|
||||
|
||||
function check_test_helper() {
|
||||
do_check_eq(gStatusCode, gExpectedStatusCode);
|
||||
do_check_eq(gStatusText, gExpectedStatusText);
|
||||
var expectedStatusText = getStatusText(gExpectedStatusCode);
|
||||
do_check_eq(gStatusText, expectedStatusText);
|
||||
gNextRunFunc();
|
||||
}
|
||||
|
||||
/**
|
||||
* The following tests do not use the http server
|
||||
* The following tests use a custom XMLHttpRequest to return the status codes
|
||||
*/
|
||||
|
||||
// network is offline
|
||||
function run_test_pt1() {
|
||||
toggleOffline(true);
|
||||
run_test_helper("run_test_pt1 - network is offline",
|
||||
0, 2152398918, run_test_pt2);
|
||||
}
|
||||
|
||||
// connection refused
|
||||
function run_test_pt2() {
|
||||
toggleOffline(false);
|
||||
run_test_helper("run_test_pt2 - connection refused",
|
||||
0, 2152398861, run_test_pt3);
|
||||
}
|
||||
|
||||
/**
|
||||
* The following tests use the codes returned by the http server
|
||||
*/
|
||||
|
||||
// file not found
|
||||
function run_test_pt3() {
|
||||
start_httpserver(DIR_DATA);
|
||||
run_test_helper("run_test_pt3 - file not found",
|
||||
404, 404, run_test_pt4);
|
||||
}
|
||||
|
||||
// file malformed
|
||||
function run_test_pt4() {
|
||||
gTestserver.registerPathHandler("/update.xml", pathHandler);
|
||||
gResponseBody = "<html><head></head><body></body></html>\n";
|
||||
run_test_helper("run_test_pt4 - file malformed",
|
||||
200, 200, run_test_pt5);
|
||||
}
|
||||
|
||||
// internal server error
|
||||
function run_test_pt5() {
|
||||
gResponseBody = "\n";
|
||||
run_test_helper("run_test_pt5 - internal server error",
|
||||
500, 500, run_test_pt6);
|
||||
}
|
||||
|
||||
/**
|
||||
* The following tests use a custom error handler to return codes from the http
|
||||
* server
|
||||
*/
|
||||
|
||||
// access denied
|
||||
function run_test_pt6() {
|
||||
gTestserver.registerErrorHandler(404, httpdErrorHandler);
|
||||
run_test_helper("run_test_pt6 - access denied",
|
||||
403, 403, run_test_pt7);
|
||||
}
|
||||
|
||||
// default onerror error message (error code 399 is not defined)
|
||||
function run_test_pt7() {
|
||||
run_test_helper("run_test_pt7 - default onerror error message",
|
||||
399, 404, end_test);
|
||||
function run_test_pt1() {
|
||||
gStatusCode = null;
|
||||
gStatusText = null;
|
||||
gCheckFunc = check_test_pt1;
|
||||
gExpectedStatusCode = 399;
|
||||
dump("Testing: run_test_pt1 - default onerror error message\n");
|
||||
gUpdateChecker.checkForUpdates(updateCheckListener, true);
|
||||
}
|
||||
|
||||
function check_test_pt1() {
|
||||
do_check_eq(gStatusCode, gExpectedStatusCode);
|
||||
var expectedStatusText = getStatusText(404);
|
||||
do_check_eq(gStatusText, expectedStatusText);
|
||||
run_test_pt2();
|
||||
}
|
||||
|
||||
// file malformed - 200
|
||||
function run_test_pt2() {
|
||||
run_test_helper(run_test_pt3, 200,
|
||||
"run_test_pt2 - file malformed");
|
||||
}
|
||||
|
||||
// access denied - 403
|
||||
function run_test_pt3() {
|
||||
run_test_helper(run_test_pt4, 403,
|
||||
"run_test_pt3 - access denied");
|
||||
}
|
||||
|
||||
// file not found - 404
|
||||
function run_test_pt4() {
|
||||
run_test_helper(run_test_pt5, 404,
|
||||
"run_test_pt4 - file not found");
|
||||
}
|
||||
|
||||
// internal server error - 500
|
||||
function run_test_pt5() {
|
||||
run_test_helper(run_test_pt6, 500,
|
||||
"run_test_pt5 - internal server error");
|
||||
}
|
||||
|
||||
// failed (unknown reason) - NS_BINDING_FAILED (2152398849)
|
||||
function run_test_pt6() {
|
||||
run_test_helper(run_test_pt7, AUS_Cr.NS_BINDING_FAILED,
|
||||
"run_test_pt6 - failed (unknown reason)");
|
||||
}
|
||||
|
||||
// connection timed out - NS_ERROR_NET_TIMEOUT (2152398862)
|
||||
function run_test_pt7() {
|
||||
run_test_helper(run_test_pt8, AUS_Cr.NS_ERROR_NET_TIMEOUT,
|
||||
"run_test_pt7 - connection timed out");
|
||||
}
|
||||
|
||||
// network offline - NS_ERROR_OFFLINE (2152398864)
|
||||
function run_test_pt8() {
|
||||
run_test_helper(run_test_pt9, AUS_Cr.NS_ERROR_OFFLINE,
|
||||
"run_test_pt8 - network offline");
|
||||
}
|
||||
|
||||
// port not allowed - NS_ERROR_PORT_ACCESS_NOT_ALLOWED (2152398867)
|
||||
function run_test_pt9() {
|
||||
run_test_helper(run_test_pt10, AUS_Cr.NS_ERROR_PORT_ACCESS_NOT_ALLOWED,
|
||||
"run_test_pt9 - port not allowed");
|
||||
}
|
||||
|
||||
// no data was received - NS_ERROR_NET_RESET (2152398868)
|
||||
function run_test_pt10() {
|
||||
run_test_helper(run_test_pt11, AUS_Cr.NS_ERROR_NET_RESET,
|
||||
"run_test_pt10 - no data was received");
|
||||
}
|
||||
|
||||
// update server not found - NS_ERROR_UNKNOWN_HOST (2152398878)
|
||||
function run_test_pt11() {
|
||||
run_test_helper(run_test_pt12, AUS_Cr.NS_ERROR_UNKNOWN_HOST,
|
||||
"run_test_pt11 - update server not found");
|
||||
}
|
||||
|
||||
// proxy server not found - NS_ERROR_UNKNOWN_PROXY_HOST (2152398890)
|
||||
function run_test_pt12() {
|
||||
run_test_helper(run_test_pt13, AUS_Cr.NS_ERROR_UNKNOWN_PROXY_HOST,
|
||||
"run_test_pt12 - proxy server not found");
|
||||
}
|
||||
|
||||
// data transfer interrupted - NS_ERROR_NET_INTERRUPT (2152398919)
|
||||
function run_test_pt13() {
|
||||
run_test_helper(run_test_pt14, AUS_Cr.NS_ERROR_NET_INTERRUPT,
|
||||
"run_test_pt13 - data transfer interrupted");
|
||||
}
|
||||
|
||||
// proxy server connection refused - NS_ERROR_PROXY_CONNECTION_REFUSED (2152398920)
|
||||
function run_test_pt14() {
|
||||
run_test_helper(run_test_pt15, AUS_Cr.NS_ERROR_PROXY_CONNECTION_REFUSED,
|
||||
"run_test_pt14 - proxy server connection refused");
|
||||
}
|
||||
|
||||
// server certificate expired - 2153390069
|
||||
function run_test_pt15() {
|
||||
run_test_helper(run_test_pt16, 2153390069,
|
||||
"run_test_pt15 - server certificate expired");
|
||||
}
|
||||
|
||||
// network is offline - NS_ERROR_DOCUMENT_NOT_CACHED (2152398918)
|
||||
function run_test_pt16() {
|
||||
run_test_helper(run_test_pt17, AUS_Cr.NS_ERROR_DOCUMENT_NOT_CACHED,
|
||||
"run_test_pt16 - network is offline");
|
||||
}
|
||||
|
||||
// connection refused - NS_ERROR_CONNECTION_REFUSED (2152398861)
|
||||
function run_test_pt17() {
|
||||
run_test_helper(end_test, AUS_Cr.NS_ERROR_CONNECTION_REFUSED,
|
||||
"run_test_pt17 - connection refused");
|
||||
}
|
||||
|
@ -1,160 +0,0 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Application Update Service.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Robert Strong <robert.bugzilla@gmail.com>.
|
||||
*
|
||||
* Portions created by the Initial Developer are Copyright (C) 2008
|
||||
* the Mozilla Foundation <http://www.mozilla.org/>. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
/* General nsIUpdateCheckListener onload error code and statusText Tests */
|
||||
|
||||
// Errors tested:
|
||||
// 2152398849, 2152398862, 2152398864, 2152398867, 2152398868, 2152398878,
|
||||
// 2152398890, 2152398919, 2152398920, default (404)
|
||||
|
||||
var gNextRunFunc;
|
||||
var gExpectedStatusCode;
|
||||
var gExpectedStatusText;
|
||||
|
||||
function run_test() {
|
||||
do_test_pending();
|
||||
removeUpdateDirsAndFiles();
|
||||
startAUS();
|
||||
startUpdateChecker();
|
||||
getPrefBranch().setCharPref(PREF_APP_UPDATE_URL_OVERRIDE,
|
||||
URL_HOST + "update.xml");
|
||||
overrideXHR(callHandleEvent);
|
||||
do_timeout(0, "run_test_pt1()");
|
||||
}
|
||||
|
||||
function end_test() {
|
||||
do_test_finished();
|
||||
cleanUp();
|
||||
}
|
||||
|
||||
// Callback function used by the custom XMLHttpRequest implemetation to
|
||||
// call the nsIDOMEventListener's handleEvent method for onload.
|
||||
function callHandleEvent() {
|
||||
gXHR.status = gExpectedStatusCode;
|
||||
var e = { target: gXHR };
|
||||
gXHR.onload.handleEvent(e);
|
||||
}
|
||||
|
||||
// Helper functions for testing nsIUpdateCheckListener onload error statusTexts
|
||||
function run_test_helper(aMsg, aExpectedStatusCode, aExpectedStatusTextCode,
|
||||
aNextRunFunc) {
|
||||
gStatusCode = null;
|
||||
gStatusText = null;
|
||||
gCheckFunc = check_test_helper;
|
||||
gNextRunFunc = aNextRunFunc;
|
||||
gExpectedStatusCode = aExpectedStatusCode;
|
||||
gExpectedStatusText = getStatusText(aExpectedStatusTextCode);
|
||||
dump("Testing: " + aMsg + "\n");
|
||||
gUpdateChecker.checkForUpdates(updateCheckListener, true);
|
||||
}
|
||||
|
||||
function check_test_helper() {
|
||||
do_check_eq(gStatusCode, gExpectedStatusCode);
|
||||
do_check_eq(gStatusText, gExpectedStatusText);
|
||||
gNextRunFunc();
|
||||
}
|
||||
|
||||
/**
|
||||
* The following tests use a custom XMLHttpRequest to return the status codes
|
||||
*/
|
||||
|
||||
// failed (unknown reason)
|
||||
function run_test_pt1() {
|
||||
run_test_helper("run_test_pt1 - failed (unknown reason)",
|
||||
2152398849, 2152398849, run_test_pt2);
|
||||
}
|
||||
|
||||
// connection timed out
|
||||
function run_test_pt2() {
|
||||
run_test_helper("run_test_pt2 - connection timed out",
|
||||
2152398862, 2152398862, run_test_pt3);
|
||||
}
|
||||
|
||||
// network offline
|
||||
function run_test_pt3() {
|
||||
run_test_helper("run_test_pt3 - network offline",
|
||||
2152398864, 2152398864, run_test_pt4);
|
||||
}
|
||||
|
||||
// port not allowed
|
||||
function run_test_pt4() {
|
||||
run_test_helper("run_test_pt4 - port not allowed",
|
||||
2152398867, 2152398867, run_test_pt5);
|
||||
}
|
||||
|
||||
// no data was received
|
||||
function run_test_pt5() {
|
||||
run_test_helper("run_test_pt5 - no data was received",
|
||||
2152398868, 2152398868, run_test_pt6);
|
||||
}
|
||||
|
||||
// update server not found
|
||||
function run_test_pt6() {
|
||||
run_test_helper("run_test_pt6 - update server not found",
|
||||
2152398878, 2152398878, run_test_pt7);
|
||||
}
|
||||
|
||||
// proxy server not found
|
||||
function run_test_pt7() {
|
||||
run_test_helper("run_test_pt7 - proxy server not found",
|
||||
2152398890, 2152398890, run_test_pt8);
|
||||
}
|
||||
|
||||
// data transfer interrupted
|
||||
function run_test_pt8() {
|
||||
run_test_helper("run_test_pt8 - data transfer interrupted",
|
||||
2152398919, 2152398919, run_test_pt9);
|
||||
}
|
||||
|
||||
// proxy server connection refused
|
||||
function run_test_pt9() {
|
||||
run_test_helper("run_test_pt9 - proxy server connection refused",
|
||||
2152398920, 2152398920, run_test_pt10);
|
||||
}
|
||||
|
||||
// server certificate expired
|
||||
function run_test_pt10() {
|
||||
run_test_helper("run_test_pt10 - server certificate expired",
|
||||
2153390069, 2153390069, run_test_pt11);
|
||||
}
|
||||
|
||||
// default onload error message (error code 1152398920 is not defined)
|
||||
function run_test_pt11() {
|
||||
run_test_helper("run_test_pt11 - default onload error message",
|
||||
1152398920, 404, end_test);
|
||||
}
|
@ -48,9 +48,9 @@ function run_test() {
|
||||
|
||||
writeUpdatesToXMLFile(getLocalUpdatesXMLString(""), false);
|
||||
|
||||
patches = getLocalPatchString(null, null, null, null, null, null,
|
||||
STATE_DOWNLOADING);
|
||||
updates = getLocalUpdateString(patches, null, null, "0.9", null, "0.9");
|
||||
var patches = getLocalPatchString(null, null, null, null, null, null,
|
||||
STATE_DOWNLOADING);
|
||||
var updates = getLocalUpdateString(patches, null, null, "0.9", null, "0.9");
|
||||
writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true);
|
||||
writeStatusFile(STATE_DOWNLOADING);
|
||||
|
||||
|
@ -48,10 +48,11 @@ function run_test() {
|
||||
|
||||
writeUpdatesToXMLFile(getLocalUpdatesXMLString(""), false);
|
||||
|
||||
patches = getLocalPatchString(null, null, null, null, null, null,
|
||||
STATE_DOWNLOADING);
|
||||
updates = getLocalUpdateString(patches, null, null, "1.0", null, "1.0", null,
|
||||
null, null, URL_HOST + DIR_DATA + "/empty.mar");
|
||||
var patches = getLocalPatchString(null, null, null, null, null, null,
|
||||
STATE_DOWNLOADING);
|
||||
var updates = getLocalUpdateString(patches, null, null, "1.0", null, "1.0",
|
||||
null, null, null,
|
||||
URL_HOST + DIR_DATA + "/empty.mar");
|
||||
writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true);
|
||||
writeStatusFile(STATE_DOWNLOADING);
|
||||
|
||||
|
@ -55,13 +55,13 @@ function run_test() {
|
||||
}
|
||||
dump("Testing: successful removal of the directory used to apply the mar file\n");
|
||||
do_check_false(testDir.exists());
|
||||
testDir.create(AUS_Ci.nsIFile.DIRECTORY_TYPE, 0755);
|
||||
testDir.create(AUS_Ci.nsIFile.DIRECTORY_TYPE, PERMS_DIRECTORY);
|
||||
|
||||
// Create an empty test file to test the complete mar's ability to replace an
|
||||
// existing file.
|
||||
var testFile = testDir.clone();
|
||||
testFile.append("text1");
|
||||
testFile.create(AUS_Ci.nsIFile.NORMAL_FILE_TYPE, 0644);
|
||||
testFile.create(AUS_Ci.nsIFile.NORMAL_FILE_TYPE, PERMS_FILE);
|
||||
|
||||
var binDir = getGREDir();
|
||||
|
||||
@ -95,7 +95,7 @@ function run_test() {
|
||||
"\nException: " + e + "\n");
|
||||
}
|
||||
|
||||
var mar = do_get_file("data/aus-0110_general-1.mar");
|
||||
var mar = do_get_file("data/aus-0110_general.mar");
|
||||
mar.copyTo(updatesSubDir, "update.mar");
|
||||
|
||||
// apply the complete mar and check the innards of the files
|
||||
@ -108,7 +108,7 @@ function run_test() {
|
||||
do_check_eq(getFileBytes(getTestFile(testDir, "text1")), "ToBeModified\n");
|
||||
do_check_eq(getFileBytes(getTestFile(testDir, "text2")), "ToBeDeleted\n");
|
||||
|
||||
var refImage = do_get_file("data/aus-0110_general_ref_image1.png");
|
||||
var refImage = do_get_file("data/aus-0110_general_ref_image.png");
|
||||
var srcImage = getTestFile(testDir, "image1.png");
|
||||
do_check_eq(getFileBytes(srcImage), getFileBytes(refImage));
|
||||
|
||||
|
@ -55,7 +55,7 @@ function run_test() {
|
||||
}
|
||||
dump("Testing: successful removal of the directory used to apply the mar file\n");
|
||||
do_check_false(testDir.exists());
|
||||
testDir.create(AUS_Ci.nsIFile.DIRECTORY_TYPE, 0755);
|
||||
testDir.create(AUS_Ci.nsIFile.DIRECTORY_TYPE, PERMS_DIRECTORY);
|
||||
|
||||
// Create the files to test the partial mar's ability to modify and delete
|
||||
// files.
|
||||
@ -67,7 +67,7 @@ function run_test() {
|
||||
testFile.append("text2");
|
||||
writeFile(testFile, "ToBeDeleted\n");
|
||||
|
||||
testFile = do_get_file("data/aus-0110_general_ref_image1.png");
|
||||
testFile = do_get_file("data/aus-0110_general_ref_image.png");
|
||||
testFile.copyTo(testDir, "image1.png");
|
||||
|
||||
var binDir = getGREDir();
|
||||
@ -102,11 +102,11 @@ function run_test() {
|
||||
"\nException: " + e + "\n");
|
||||
}
|
||||
|
||||
var mar = do_get_file("data/aus-0110_general-2.mar");
|
||||
var mar = do_get_file("data/aus-0111_general.mar");
|
||||
mar.copyTo(updatesSubDir, "update.mar");
|
||||
|
||||
// apply the partial mar and check the innards of the files
|
||||
exitValue = runUpdate(updatesSubDir, updater);
|
||||
var exitValue = runUpdate(updatesSubDir, updater);
|
||||
dump("Testing: updater binary process exitValue for success when applying " +
|
||||
"a partial mar\n");
|
||||
do_check_eq(exitValue, 0);
|
||||
@ -117,8 +117,8 @@ function run_test() {
|
||||
do_check_false(getTestFile(testDir, "text2").exists()); // file removed
|
||||
do_check_eq(getFileBytes(getTestFile(testDir, "text3")), "Added\n");
|
||||
|
||||
refImage = do_get_file("data/aus-0110_general_ref_image2.png");
|
||||
srcImage = getTestFile(testDir, "image1.png");
|
||||
var refImage = do_get_file("data/aus-0111_general_ref_image.png");
|
||||
var srcImage = getTestFile(testDir, "image1.png");
|
||||
do_check_eq(getFileBytes(srcImage), getFileBytes(refImage));
|
||||
|
||||
try {
|
||||
@ -132,7 +132,6 @@ function run_test() {
|
||||
"\nException: " + e + "\n");
|
||||
}
|
||||
|
||||
removeUpdateDirsAndFiles();
|
||||
cleanUp();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user