diff --git a/toolkit/mozapps/update/tests/chrome/update.sjs b/toolkit/mozapps/update/tests/chrome/update.sjs index 8c0be8f36bc3..78bb1b93f8bb 100644 --- a/toolkit/mozapps/update/tests/chrome/update.sjs +++ b/toolkit/mozapps/update/tests/chrome/update.sjs @@ -51,7 +51,7 @@ function handleRequest(aRequest, aResponse) { let statusReason = params.statusReason ? params.statusReason : "OK"; aResponse.setStatusLine(aRequest.httpVersion, statusCode, statusReason); aResponse.setHeader("Cache-Control", "no-cache", false); - + // When a mar download is started by the update service it can finish // downloading before the ui has loaded. By specifying a serviceURL for the // update patch that points to this file and has a slowDownloadMar param the diff --git a/toolkit/mozapps/update/tests/chrome/utils.js b/toolkit/mozapps/update/tests/chrome/utils.js index ab62d97b1c2a..68a27cbd0b26 100644 --- a/toolkit/mozapps/update/tests/chrome/utils.js +++ b/toolkit/mozapps/update/tests/chrome/utils.js @@ -165,6 +165,56 @@ this.__defineGetter__("gCallback", function() { : defaultCallback; }); +/** + * nsIObserver for receiving window open and close notifications. + */ +const gWindowObserver = { + observe: function WO_observe(aSubject, aTopic, aData) { + let win = aSubject.QueryInterface(Ci.nsIDOMEventTarget); + + if (aTopic == "domwindowclosed") { + if (win.location != URI_UPDATE_PROMPT_DIALOG) { + debugDump("domwindowclosed event for window not being tested - " + + "location: " + win.location + "... returning early"); + return; + } + // Allow tests the ability to provide their own function (it must be + // named finishTest) for finishing the test. + try { + finishTest(); + } + catch (e) { + finishTestDefault(); + } + return; + } + + win.addEventListener("load", function WO_observe_onLoad() { + win.removeEventListener("load", WO_observe_onLoad, false); + // Ignore windows other than the update UI window. + if (win.location != URI_UPDATE_PROMPT_DIALOG) { + debugDump("load event for window not being tested - location: " + + win.location + "... returning early"); + return; + } + + // The first wizard page should always be the dummy page. + let pageid = win.document.documentElement.currentPage.pageid; + if (pageid != PAGEID_DUMMY) { + // This should never happen but if it does this will provide a clue + // for diagnosing the cause. + ok(false, "Unexpected load event - pageid got: " + pageid + + ", expected: " + PAGEID_DUMMY + "... returning early"); + return; + } + + gWin = win; + gDocElem = gWin.document.documentElement; + gDocElem.addEventListener("pageshow", onPageShowDefault, false); + }, false); + } +}; + /** * Default test run function that can be used by most tests. This function uses * protective measures to prevent the test from failing provided by @@ -507,29 +557,29 @@ function getExpectedButtonStates() { switch (gTest.pageid) { case PAGEID_CHECKING: - return { cancel: { disabled: false, hidden: false } }; + return {cancel: {disabled: false, hidden: false}}; case PAGEID_FOUND_BASIC: if (gTest.neverButton) { - return { extra1: { disabled: false, hidden: false }, - extra2: { disabled: false, hidden: false }, - next : { disabled: false, hidden: false } } + return {extra1: {disabled: false, hidden: false}, + extra2: {disabled: false, hidden: false}, + next: {disabled: false, hidden: false}} } - return { extra1: { disabled: false, hidden: false }, - next : { disabled: false, hidden: false } }; + return {extra1: {disabled: false, hidden: false}, + next: {disabled: false, hidden: false}}; case PAGEID_DOWNLOADING: - return { extra1: { disabled: false, hidden: false } }; + return {extra1: {disabled: false, hidden: false}}; case PAGEID_NO_UPDATES_FOUND: case PAGEID_MANUAL_UPDATE: case PAGEID_UNSUPPORTED: case PAGEID_ERRORS: case PAGEID_ERROR_EXTRA: - return { finish: { disabled: false, hidden: false } }; + return {finish: {disabled: false, hidden: false}}; case PAGEID_ERROR_PATCHING: - return { next : { disabled: false, hidden: false } }; + return {next: { disabled: false, hidden: false}}; case PAGEID_FINISHED: case PAGEID_FINISHED_BKGRD: - return { extra1: { disabled: false, hidden: false }, - finish: { disabled: false, hidden: false } }; + return {extra1: { disabled: false, hidden: false}, + finish: { disabled: false, hidden: false}}; } return null; } @@ -966,53 +1016,3 @@ const errorsPrefObserver = { } } }; - -/** - * nsIObserver for receiving window open and close notifications. - */ -const gWindowObserver = { - observe: function WO_observe(aSubject, aTopic, aData) { - let win = aSubject.QueryInterface(Ci.nsIDOMEventTarget); - - if (aTopic == "domwindowclosed") { - if (win.location != URI_UPDATE_PROMPT_DIALOG) { - debugDump("domwindowclosed event for window not being tested - " + - "location: " + win.location + "... returning early"); - return; - } - // Allow tests the ability to provide their own function (it must be - // named finishTest) for finishing the test. - try { - finishTest(); - } - catch (e) { - finishTestDefault(); - } - return; - } - - win.addEventListener("load", function WO_observe_onLoad() { - win.removeEventListener("load", WO_observe_onLoad, false); - // Ignore windows other than the update UI window. - if (win.location != URI_UPDATE_PROMPT_DIALOG) { - debugDump("load event for window not being tested - location: " + - win.location + "... returning early"); - return; - } - - // The first wizard page should always be the dummy page. - let pageid = win.document.documentElement.currentPage.pageid; - if (pageid != PAGEID_DUMMY) { - // This should never happen but if it does this will provide a clue - // for diagnosing the cause. - ok(false, "Unexpected load event - pageid got: " + pageid + - ", expected: " + PAGEID_DUMMY + "... returning early"); - return; - } - - gWin = win; - gDocElem = gWin.document.documentElement; - gDocElem.addEventListener("pageshow", onPageShowDefault, false); - }, false); - } -}; diff --git a/toolkit/mozapps/update/tests/data/shared.js b/toolkit/mozapps/update/tests/data/shared.js index fcf9f8fb298e..3403eec6221c 100644 --- a/toolkit/mozapps/update/tests/data/shared.js +++ b/toolkit/mozapps/update/tests/data/shared.js @@ -140,19 +140,6 @@ function reloadUpdateManagerData() { observe(null, "um-reload-update-data", ""); } -/** - * Sets the app.update.channel preference. - * - * @param aChannel - * The update channel. - */ -function setUpdateChannel(aChannel) { - gChannel = aChannel; - debugDump("setting default pref " + PREF_APP_UPDATE_CHANNEL + " to " + gChannel); - gDefaultPrefBranch.setCharPref(PREF_APP_UPDATE_CHANNEL, gChannel); - gPrefRoot.addObserver(PREF_APP_UPDATE_CHANNEL, observer, false); -} - const observer = { observe: function(aSubject, aTopic, aData) { if (aTopic == "nsPref:changed" && aData == PREF_APP_UPDATE_CHANNEL) { @@ -166,6 +153,19 @@ const observer = { QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]) }; +/** + * Sets the app.update.channel preference. + * + * @param aChannel + * The update channel. + */ +function setUpdateChannel(aChannel) { + gChannel = aChannel; + debugDump("setting default pref " + PREF_APP_UPDATE_CHANNEL + " to " + gChannel); + gDefaultPrefBranch.setCharPref(PREF_APP_UPDATE_CHANNEL, gChannel); + gPrefRoot.addObserver(PREF_APP_UPDATE_CHANNEL, observer, false); +} + /** * Sets the app.update.url.override preference. * @@ -483,8 +483,8 @@ function cleanUpdatesDir(aDir) { try { entry.remove(false); } catch (e) { - logTestInfo("cleanUpdatesDir: unable to remove file. Path: " + - entry.path + ", Exception: " + e); + logTestInfo("cleanUpdatesDir: unable to remove file. Path: " + + entry.path + ", Exception: " + e); throw (e); } } @@ -595,7 +595,7 @@ function getGREBinDir() { */ function logTestInfo(aText, aCaller) { let caller = aCaller ? aCaller : Components.stack.caller; - let now = new Date; + let now = new Date(); let hh = now.getHours(); let mm = now.getMinutes(); let ss = now.getSeconds(); diff --git a/toolkit/mozapps/update/tests/data/xpcshellUtilsAUS.js b/toolkit/mozapps/update/tests/data/xpcshellUtilsAUS.js index 74e36ce79d6a..5604b09a521f 100644 --- a/toolkit/mozapps/update/tests/data/xpcshellUtilsAUS.js +++ b/toolkit/mozapps/update/tests/data/xpcshellUtilsAUS.js @@ -200,228 +200,222 @@ var gTestDirs = []; // Common files for both successful and failed updates. var gTestFilesCommon = [ -{ - description : "Should never change", - fileName : FILE_UPDATE_SETTINGS_INI, - relPathDir : DIR_RESOURCES, - originalContents : UPDATE_SETTINGS_CONTENTS, - compareContents : UPDATE_SETTINGS_CONTENTS, - originalFile : null, - compareFile : null, - originalPerms : 0o767, - comparePerms : 0o767 -}, { - description : "Should never change", - fileName : "channel-prefs.js", - relPathDir : DIR_RESOURCES + "defaults/pref/", - originalContents : "ShouldNotBeReplaced\n", - compareContents : "ShouldNotBeReplaced\n", - originalFile : null, - compareFile : null, - originalPerms : 0o767, - comparePerms : 0o767 -}]; + { + description: "Should never change", + fileName: FILE_UPDATE_SETTINGS_INI, + relPathDir: DIR_RESOURCES, + originalContents: UPDATE_SETTINGS_CONTENTS, + compareContents: UPDATE_SETTINGS_CONTENTS, + originalFile: null, + compareFile: null, + originalPerms: 0o767, + comparePerms: 0o767 + }, { + description: "Should never change", + fileName: "channel-prefs.js", + relPathDir: DIR_RESOURCES + "defaults/pref/", + originalContents: "ShouldNotBeReplaced\n", + compareContents: "ShouldNotBeReplaced\n", + originalFile: null, + compareFile: null, + originalPerms: 0o767, + comparePerms: 0o767 + }]; -// Files for a complete successful update. This can be used for a complete -// failed update by calling setTestFilesAndDirsForFailure. + // Files for a complete successful update. This can be used for a complete + // failed update by calling setTestFilesAndDirsForFailure. var gTestFilesCompleteSuccess = [ -{ - description : "Added by update.manifest (add)", - fileName : "precomplete", - relPathDir : DIR_RESOURCES, - originalContents : null, - compareContents : null, - originalFile : FILE_PARTIAL_PRECOMPLETE, - compareFile : FILE_COMPLETE_PRECOMPLETE, - originalPerms : 0o666, - comparePerms : 0o644 -}, { - description : "Added by update.manifest (add)", - fileName : "searchpluginstext0", - relPathDir : DIR_RESOURCES + "searchplugins/", - originalContents : "ToBeReplacedWithFromComplete\n", - compareContents : "FromComplete\n", - originalFile : null, - compareFile : null, - originalPerms : 0o775, - comparePerms : 0o644 -}, { - description : "Added by update.manifest (add)", - fileName : "searchpluginspng1.png", - relPathDir : DIR_RESOURCES + "searchplugins/", - originalContents : null, - compareContents : null, - originalFile : null, - compareFile : "complete.png", - originalPerms : null, - comparePerms : 0o644 -}, { - description : "Added by update.manifest (add)", - fileName : "searchpluginspng0.png", - relPathDir : DIR_RESOURCES + "searchplugins/", - originalContents : null, - compareContents : null, - originalFile : "partial.png", - compareFile : "complete.png", - originalPerms : 0o666, - comparePerms : 0o644 -}, { - description : "Added by update.manifest (add)", - fileName : "removed-files", - relPathDir : DIR_RESOURCES, - originalContents : null, - compareContents : null, - originalFile : FILE_PARTIAL_REMOVEDFILES, - compareFile : FILE_COMPLETE_REMOVEDFILES, - originalPerms : 0o666, - comparePerms : 0o644 -}, { - description : "Added by update.manifest if the parent directory " + - "exists (add-if)", - fileName : "extensions1text0", - relPathDir : DIR_RESOURCES + "distribution/extensions/extensions1/", - originalContents : null, - compareContents : "FromComplete\n", - originalFile : null, - compareFile : null, - originalPerms : null, - comparePerms : 0o644 -}, { - description : "Added by update.manifest if the parent directory " + - "exists (add-if)", - fileName : "extensions1png1.png", - relPathDir : DIR_RESOURCES + "distribution/extensions/extensions1/", - originalContents : null, - compareContents : null, - originalFile : "partial.png", - compareFile : "complete.png", - originalPerms : 0o666, - comparePerms : 0o644 -}, { - description : "Added by update.manifest if the parent directory " + - "exists (add-if)", - fileName : "extensions1png0.png", - relPathDir : DIR_RESOURCES + "distribution/extensions/extensions1/", - originalContents : null, - compareContents : null, - originalFile : null, - compareFile : "complete.png", - originalPerms : null, - comparePerms : 0o644 -}, { - description : "Added by update.manifest if the parent directory " + - "exists (add-if)", - fileName : "extensions0text0", - relPathDir : DIR_RESOURCES + "distribution/extensions/extensions0/", - originalContents : "ToBeReplacedWithFromComplete\n", - compareContents : "FromComplete\n", - originalFile : null, - compareFile : null, - originalPerms : null, - comparePerms : 0o644 -}, { - description : "Added by update.manifest if the parent directory " + - "exists (add-if)", - fileName : "extensions0png1.png", - relPathDir : DIR_RESOURCES + "distribution/extensions/extensions0/", - originalContents : null, - compareContents : null, - originalFile : null, - compareFile : "complete.png", - originalPerms : null, - comparePerms : 0o644 -}, { - description : "Added by update.manifest if the parent directory " + - "exists (add-if)", - fileName : "extensions0png0.png", - relPathDir : DIR_RESOURCES + "distribution/extensions/extensions0/", - originalContents : null, - compareContents : null, - originalFile : null, - compareFile : "complete.png", - originalPerms : null, - comparePerms : 0o644 -}, { - description : "Added by update.manifest (add)", - fileName : "exe0.exe", - relPathDir : DIR_MACOS, - originalContents : null, - compareContents : null, - originalFile : FILE_HELPER_BIN, - compareFile : FILE_COMPLETE_EXE, - originalPerms : 0o777, - comparePerms : 0o755 -}, { - description : "Added by update.manifest (add)", - fileName : "10text0", - relPathDir : DIR_RESOURCES + "1/10/", - originalContents : "ToBeReplacedWithFromComplete\n", - compareContents : "FromComplete\n", - originalFile : null, - compareFile : null, - originalPerms : 0o767, - comparePerms : 0o644 -}, { - description : "Added by update.manifest (add)", - fileName : "0exe0.exe", - relPathDir : DIR_RESOURCES + "0/", - originalContents : null, - compareContents : null, - originalFile : FILE_HELPER_BIN, - compareFile : FILE_COMPLETE_EXE, - originalPerms : 0o777, - comparePerms : 0o755 -}, { - description : "Added by update.manifest (add)", - fileName : "00text1", - relPathDir : DIR_RESOURCES + "0/00/", - originalContents : "ToBeReplacedWithFromComplete\n", - compareContents : "FromComplete\n", - originalFile : null, - compareFile : null, - originalPerms : 0o677, - comparePerms : 0o644 -}, { - description : "Added by update.manifest (add)", - fileName : "00text0", - relPathDir : DIR_RESOURCES + "0/00/", - originalContents : "ToBeReplacedWithFromComplete\n", - compareContents : "FromComplete\n", - originalFile : null, - compareFile : null, - originalPerms : 0o775, - comparePerms : 0o644 -}, { - description : "Added by update.manifest (add)", - fileName : "00png0.png", - relPathDir : DIR_RESOURCES + "0/00/", - originalContents : null, - compareContents : null, - originalFile : null, - compareFile : "complete.png", - originalPerms : 0o776, - comparePerms : 0o644 -}, { - description : "Removed by precomplete (remove)", - fileName : "20text0", - relPathDir : DIR_RESOURCES + "2/20/", - originalContents : "ToBeDeleted\n", - compareContents : null, - originalFile : null, - compareFile : null, - originalPerms : null, - comparePerms : null -}, { - description : "Removed by precomplete (remove)", - fileName : "20png0.png", - relPathDir : DIR_RESOURCES + "2/20/", - originalContents : "ToBeDeleted\n", - compareContents : null, - originalFile : null, - compareFile : null, - originalPerms : null, - comparePerms : null -}]; + { + description: "Added by update.manifest (add)", + fileName: "precomplete", + relPathDir: DIR_RESOURCES, + originalContents: null, + compareContents: null, + originalFile: FILE_PARTIAL_PRECOMPLETE, + compareFile: FILE_COMPLETE_PRECOMPLETE, + originalPerms: 0o666, + comparePerms: 0o644 + }, { + description: "Added by update.manifest (add)", + fileName: "searchpluginstext0", + relPathDir: DIR_RESOURCES + "searchplugins/", + originalContents: "ToBeReplacedWithFromComplete\n", + compareContents: "FromComplete\n", + originalFile: null, + compareFile: null, + originalPerms: 0o775, + comparePerms: 0o644 + }, { + description: "Added by update.manifest (add)", + fileName: "searchpluginspng1.png", + relPathDir: DIR_RESOURCES + "searchplugins/", + originalContents: null, + compareContents: null, + originalFile: null, + compareFile: "complete.png", + originalPerms: null, + comparePerms: 0o644 + }, { + description: "Added by update.manifest (add)", + fileName: "searchpluginspng0.png", + relPathDir: DIR_RESOURCES + "searchplugins/", + originalContents: null, + compareContents: null, + originalFile: "partial.png", + compareFile: "complete.png", + originalPerms: 0o666, + comparePerms: 0o644 + }, { + description: "Added by update.manifest (add)", + fileName: "removed-files", + relPathDir: DIR_RESOURCES, + originalContents: null, + compareContents: null, + originalFile: FILE_PARTIAL_REMOVEDFILES, + compareFile: FILE_COMPLETE_REMOVEDFILES, + originalPerms: 0o666, + comparePerms: 0o644 + }, { + description: "Added by update.manifest if the parent directory exists (add-if)", + fileName: "extensions1text0", + relPathDir: DIR_RESOURCES + "distribution/extensions/extensions1/", + originalContents: null, + compareContents: "FromComplete\n", + originalFile: null, + compareFile: null, + originalPerms: null, + comparePerms: 0o644 + }, { + description: "Added by update.manifest if the parent directory exists (add-if)", + fileName: "extensions1png1.png", + relPathDir: DIR_RESOURCES + "distribution/extensions/extensions1/", + originalContents: null, + compareContents: null, + originalFile: "partial.png", + compareFile: "complete.png", + originalPerms: 0o666, + comparePerms: 0o644 + }, { + description: "Added by update.manifest if the parent directory exists (add-if)", + fileName: "extensions1png0.png", + relPathDir: DIR_RESOURCES + "distribution/extensions/extensions1/", + originalContents: null, + compareContents: null, + originalFile: null, + compareFile: "complete.png", + originalPerms: null, + comparePerms: 0o644 + }, { + description: "Added by update.manifest if the parent directory exists (add-if)", + fileName: "extensions0text0", + relPathDir: DIR_RESOURCES + "distribution/extensions/extensions0/", + originalContents: "ToBeReplacedWithFromComplete\n", + compareContents: "FromComplete\n", + originalFile: null, + compareFile: null, + originalPerms: null, + comparePerms: 0o644 + }, { + description: "Added by update.manifest if the parent directory exists (add-if)", + fileName: "extensions0png1.png", + relPathDir: DIR_RESOURCES + "distribution/extensions/extensions0/", + originalContents: null, + compareContents: null, + originalFile: null, + compareFile: "complete.png", + originalPerms: null, + comparePerms: 0o644 + }, { + description: "Added by update.manifest if the parent directory exists (add-if)", + fileName: "extensions0png0.png", + relPathDir: DIR_RESOURCES + "distribution/extensions/extensions0/", + originalContents: null, + compareContents: null, + originalFile: null, + compareFile: "complete.png", + originalPerms: null, + comparePerms: 0o644 + }, { + description: "Added by update.manifest (add)", + fileName: "exe0.exe", + relPathDir: DIR_MACOS, + originalContents: null, + compareContents: null, + originalFile: FILE_HELPER_BIN, + compareFile: FILE_COMPLETE_EXE, + originalPerms: 0o777, + comparePerms: 0o755 + }, { + description: "Added by update.manifest (add)", + fileName: "10text0", + relPathDir: DIR_RESOURCES + "1/10/", + originalContents: "ToBeReplacedWithFromComplete\n", + compareContents: "FromComplete\n", + originalFile: null, + compareFile: null, + originalPerms: 0o767, + comparePerms: 0o644 + }, { + description: "Added by update.manifest (add)", + fileName: "0exe0.exe", + relPathDir: DIR_RESOURCES + "0/", + originalContents: null, + compareContents: null, + originalFile: FILE_HELPER_BIN, + compareFile: FILE_COMPLETE_EXE, + originalPerms: 0o777, + comparePerms: 0o755 + }, { + description: "Added by update.manifest (add)", + fileName: "00text1", + relPathDir: DIR_RESOURCES + "0/00/", + originalContents: "ToBeReplacedWithFromComplete\n", + compareContents: "FromComplete\n", + originalFile: null, + compareFile: null, + originalPerms: 0o677, + comparePerms: 0o644 + }, { + description: "Added by update.manifest (add)", + fileName: "00text0", + relPathDir: DIR_RESOURCES + "0/00/", + originalContents: "ToBeReplacedWithFromComplete\n", + compareContents: "FromComplete\n", + originalFile: null, + compareFile: null, + originalPerms: 0o775, + comparePerms: 0o644 + }, { + description: "Added by update.manifest (add)", + fileName: "00png0.png", + relPathDir: DIR_RESOURCES + "0/00/", + originalContents: null, + compareContents: null, + originalFile: null, + compareFile: "complete.png", + originalPerms: 0o776, + comparePerms: 0o644 + }, { + description: "Removed by precomplete (remove)", + fileName: "20text0", + relPathDir: DIR_RESOURCES + "2/20/", + originalContents: "ToBeDeleted\n", + compareContents: null, + originalFile: null, + compareFile: null, + originalPerms: null, + comparePerms: null + }, { + description: "Removed by precomplete (remove)", + fileName: "20png0.png", + relPathDir: DIR_RESOURCES + "2/20/", + originalContents: "ToBeDeleted\n", + compareContents: null, + originalFile: null, + compareFile: null, + originalPerms: null, + comparePerms: null + }]; // Concatenate the common files to the end of the array. gTestFilesCompleteSuccess = gTestFilesCompleteSuccess.concat(gTestFilesCommon); @@ -429,321 +423,313 @@ gTestFilesCompleteSuccess = gTestFilesCompleteSuccess.concat(gTestFilesCommon); // Files for a partial successful update. This can be used for a partial failed // update by calling setTestFilesAndDirsForFailure. var gTestFilesPartialSuccess = [ -{ - description : "Added by update.manifest (add)", - fileName : "precomplete", - relPathDir : DIR_RESOURCES, - originalContents : null, - compareContents : null, - originalFile : FILE_COMPLETE_PRECOMPLETE, - compareFile : FILE_PARTIAL_PRECOMPLETE, - originalPerms : 0o666, - comparePerms : 0o644 -}, { - description : "Added by update.manifest (add)", - fileName : "searchpluginstext0", - relPathDir : DIR_RESOURCES + "searchplugins/", - originalContents : "ToBeReplacedWithFromPartial\n", - compareContents : "FromPartial\n", - originalFile : null, - compareFile : null, - originalPerms : 0o775, - comparePerms : 0o644 -}, { - description : "Patched by update.manifest if the file exists " + - "(patch-if)", - fileName : "searchpluginspng1.png", - relPathDir : DIR_RESOURCES + "searchplugins/", - originalContents : null, - compareContents : null, - originalFile : "complete.png", - compareFile : "partial.png", - originalPerms : 0o666, - comparePerms : 0o666 -}, { - description : "Patched by update.manifest if the file exists " + - "(patch-if)", - fileName : "searchpluginspng0.png", - relPathDir : DIR_RESOURCES + "searchplugins/", - originalContents : null, - compareContents : null, - originalFile : "complete.png", - compareFile : "partial.png", - originalPerms : 0o666, - comparePerms : 0o666 -}, { - description : "Added by update.manifest if the parent directory " + - "exists (add-if)", - fileName : "extensions1text0", - relPathDir : DIR_RESOURCES + "distribution/extensions/extensions1/", - originalContents : null, - compareContents : "FromPartial\n", - originalFile : null, - compareFile : null, - originalPerms : null, - comparePerms : 0o644 -}, { - description : "Patched by update.manifest if the parent directory " + - "exists (patch-if)", - fileName : "extensions1png1.png", - relPathDir : DIR_RESOURCES + "distribution/extensions/extensions1/", - originalContents : null, - compareContents : null, - originalFile : "complete.png", - compareFile : "partial.png", - originalPerms : 0o666, - comparePerms : 0o666 -}, { - description : "Patched by update.manifest if the parent directory " + - "exists (patch-if)", - fileName : "extensions1png0.png", - relPathDir : DIR_RESOURCES + "distribution/extensions/extensions1/", - originalContents : null, - compareContents : null, - originalFile : "complete.png", - compareFile : "partial.png", - originalPerms : 0o666, - comparePerms : 0o666 -}, { - description : "Added by update.manifest if the parent directory " + - "exists (add-if)", - fileName : "extensions0text0", - relPathDir : DIR_RESOURCES + "distribution/extensions/extensions0/", - originalContents : "ToBeReplacedWithFromPartial\n", - compareContents : "FromPartial\n", - originalFile : null, - compareFile : null, - originalPerms : 0o644, - comparePerms : 0o644 -}, { - description : "Patched by update.manifest if the parent directory " + - "exists (patch-if)", - fileName : "extensions0png1.png", - relPathDir : DIR_RESOURCES + "distribution/extensions/extensions0/", - originalContents : null, - compareContents : null, - originalFile : "complete.png", - compareFile : "partial.png", - originalPerms : 0o644, - comparePerms : 0o644 -}, { - description : "Patched by update.manifest if the parent directory " + - "exists (patch-if)", - fileName : "extensions0png0.png", - relPathDir : DIR_RESOURCES + "distribution/extensions/extensions0/", - originalContents : null, - compareContents : null, - originalFile : "complete.png", - compareFile : "partial.png", - originalPerms : 0o644, - comparePerms : 0o644 -}, { - description : "Patched by update.manifest (patch)", - fileName : "exe0.exe", - relPathDir : DIR_MACOS, - originalContents : null, - compareContents : null, - originalFile : FILE_COMPLETE_EXE, - compareFile : FILE_PARTIAL_EXE, - originalPerms : 0o755, - comparePerms : 0o755 -}, { - description : "Patched by update.manifest (patch)", - fileName : "0exe0.exe", - relPathDir : DIR_RESOURCES + "0/", - originalContents : null, - compareContents : null, - originalFile : FILE_COMPLETE_EXE, - compareFile : FILE_PARTIAL_EXE, - originalPerms : 0o755, - comparePerms : 0o755 -}, { - description : "Added by update.manifest (add)", - fileName : "00text0", - relPathDir : DIR_RESOURCES + "0/00/", - originalContents : "ToBeReplacedWithFromPartial\n", - compareContents : "FromPartial\n", - originalFile : null, - compareFile : null, - originalPerms : 0o644, - comparePerms : 0o644 -}, { - description : "Patched by update.manifest (patch)", - fileName : "00png0.png", - relPathDir : DIR_RESOURCES + "0/00/", - originalContents : null, - compareContents : null, - originalFile : "complete.png", - compareFile : "partial.png", - originalPerms : 0o666, - comparePerms : 0o666 -}, { - description : "Added by update.manifest (add)", - fileName : "20text0", - relPathDir : DIR_RESOURCES + "2/20/", - originalContents : null, - compareContents : "FromPartial\n", - originalFile : null, - compareFile : null, - originalPerms : null, - comparePerms : 0o644 -}, { - description : "Added by update.manifest (add)", - fileName : "20png0.png", - relPathDir : DIR_RESOURCES + "2/20/", - originalContents : null, - compareContents : null, - originalFile : null, - compareFile : "partial.png", - originalPerms : null, - comparePerms : 0o644 -}, { - description : "Added by update.manifest (add)", - fileName : "00text2", - relPathDir : DIR_RESOURCES + "0/00/", - originalContents : null, - compareContents : "FromPartial\n", - originalFile : null, - compareFile : null, - originalPerms : null, - comparePerms : 0o644 -}, { - description : "Removed by update.manifest (remove)", - fileName : "10text0", - relPathDir : DIR_RESOURCES + "1/10/", - originalContents : "ToBeDeleted\n", - compareContents : null, - originalFile : null, - compareFile : null, - originalPerms : null, - comparePerms : null -}, { - description : "Removed by update.manifest (remove)", - fileName : "00text1", - relPathDir : DIR_RESOURCES + "0/00/", - originalContents : "ToBeDeleted\n", - compareContents : null, - originalFile : null, - compareFile : null, - originalPerms : null, - comparePerms : null -}]; + { + description: "Added by update.manifest (add)", + fileName: "precomplete", + relPathDir: DIR_RESOURCES, + originalContents: null, + compareContents: null, + originalFile: FILE_COMPLETE_PRECOMPLETE, + compareFile: FILE_PARTIAL_PRECOMPLETE, + originalPerms: 0o666, + comparePerms: 0o644 + }, { + description: "Added by update.manifest (add)", + fileName: "searchpluginstext0", + relPathDir: DIR_RESOURCES + "searchplugins/", + originalContents: "ToBeReplacedWithFromPartial\n", + compareContents: "FromPartial\n", + originalFile: null, + compareFile: null, + originalPerms: 0o775, + comparePerms: 0o644 + }, { + description: "Patched by update.manifest if the file exists (patch-if)", + fileName: "searchpluginspng1.png", + relPathDir: DIR_RESOURCES + "searchplugins/", + originalContents: null, + compareContents: null, + originalFile: "complete.png", + compareFile: "partial.png", + originalPerms: 0o666, + comparePerms: 0o666 + }, { + description: "Patched by update.manifest if the file exists (patch-if)", + fileName: "searchpluginspng0.png", + relPathDir: DIR_RESOURCES + "searchplugins/", + originalContents: null, + compareContents: null, + originalFile: "complete.png", + compareFile: "partial.png", + originalPerms: 0o666, + comparePerms: 0o666 + }, { + description: "Added by update.manifest if the parent directory exists (add-if)", + fileName: "extensions1text0", + relPathDir: DIR_RESOURCES + "distribution/extensions/extensions1/", + originalContents: null, + compareContents: "FromPartial\n", + originalFile: null, + compareFile: null, + originalPerms: null, + comparePerms: 0o644 + }, { + description: "Patched by update.manifest if the parent directory exists (patch-if)", + fileName: "extensions1png1.png", + relPathDir: DIR_RESOURCES + "distribution/extensions/extensions1/", + originalContents: null, + compareContents: null, + originalFile: "complete.png", + compareFile: "partial.png", + originalPerms: 0o666, + comparePerms: 0o666 + }, { + description: "Patched by update.manifest if the parent directory exists (patch-if)", + fileName: "extensions1png0.png", + relPathDir: DIR_RESOURCES + "distribution/extensions/extensions1/", + originalContents: null, + compareContents: null, + originalFile: "complete.png", + compareFile: "partial.png", + originalPerms: 0o666, + comparePerms: 0o666 + }, { + description: "Added by update.manifest if the parent directory exists (add-if)", + fileName: "extensions0text0", + relPathDir: DIR_RESOURCES + "distribution/extensions/extensions0/", + originalContents: "ToBeReplacedWithFromPartial\n", + compareContents: "FromPartial\n", + originalFile: null, + compareFile: null, + originalPerms: 0o644, + comparePerms: 0o644 + }, { + description: "Patched by update.manifest if the parent directory exists (patch-if)", + fileName: "extensions0png1.png", + relPathDir: DIR_RESOURCES + "distribution/extensions/extensions0/", + originalContents: null, + compareContents: null, + originalFile: "complete.png", + compareFile: "partial.png", + originalPerms: 0o644, + comparePerms: 0o644 + }, { + description: "Patched by update.manifest if the parent directory exists (patch-if)", + fileName: "extensions0png0.png", + relPathDir: DIR_RESOURCES + "distribution/extensions/extensions0/", + originalContents: null, + compareContents: null, + originalFile: "complete.png", + compareFile: "partial.png", + originalPerms: 0o644, + comparePerms: 0o644 + }, { + description: "Patched by update.manifest (patch)", + fileName: "exe0.exe", + relPathDir: DIR_MACOS, + originalContents: null, + compareContents: null, + originalFile: FILE_COMPLETE_EXE, + compareFile: FILE_PARTIAL_EXE, + originalPerms: 0o755, + comparePerms: 0o755 + }, { + description: "Patched by update.manifest (patch)", + fileName: "0exe0.exe", + relPathDir: DIR_RESOURCES + "0/", + originalContents: null, + compareContents: null, + originalFile: FILE_COMPLETE_EXE, + compareFile: FILE_PARTIAL_EXE, + originalPerms: 0o755, + comparePerms: 0o755 + }, { + description: "Added by update.manifest (add)", + fileName: "00text0", + relPathDir: DIR_RESOURCES + "0/00/", + originalContents: "ToBeReplacedWithFromPartial\n", + compareContents: "FromPartial\n", + originalFile: null, + compareFile: null, + originalPerms: 0o644, + comparePerms: 0o644 + }, { + description: "Patched by update.manifest (patch)", + fileName: "00png0.png", + relPathDir: DIR_RESOURCES + "0/00/", + originalContents: null, + compareContents: null, + originalFile: "complete.png", + compareFile: "partial.png", + originalPerms: 0o666, + comparePerms: 0o666 + }, { + description: "Added by update.manifest (add)", + fileName: "20text0", + relPathDir: DIR_RESOURCES + "2/20/", + originalContents: null, + compareContents: "FromPartial\n", + originalFile: null, + compareFile: null, + originalPerms: null, + comparePerms: 0o644 + }, { + description: "Added by update.manifest (add)", + fileName: "20png0.png", + relPathDir: DIR_RESOURCES + "2/20/", + originalContents: null, + compareContents: null, + originalFile: null, + compareFile: "partial.png", + originalPerms: null, + comparePerms: 0o644 + }, { + description: "Added by update.manifest (add)", + fileName: "00text2", + relPathDir: DIR_RESOURCES + "0/00/", + originalContents: null, + compareContents: "FromPartial\n", + originalFile: null, + compareFile: null, + originalPerms: null, + comparePerms: 0o644 + }, { + description: "Removed by update.manifest (remove)", + fileName: "10text0", + relPathDir: DIR_RESOURCES + "1/10/", + originalContents: "ToBeDeleted\n", + compareContents: null, + originalFile: null, + compareFile: null, + originalPerms: null, + comparePerms: null + }, { + description: "Removed by update.manifest (remove)", + fileName: "00text1", + relPathDir: DIR_RESOURCES + "0/00/", + originalContents: "ToBeDeleted\n", + compareContents: null, + originalFile: null, + compareFile: null, + originalPerms: null, + comparePerms: null + }]; // Concatenate the common files to the end of the array. gTestFilesPartialSuccess = gTestFilesPartialSuccess.concat(gTestFilesCommon); var gTestDirsCommon = [ -{ - relPathDir : DIR_RESOURCES + "3/", - dirRemoved : false, - files : ["3text0", "3text1"], - filesRemoved : true -}, { - relPathDir : DIR_RESOURCES + "4/", - dirRemoved : true, - files : ["4text0", "4text1"], - filesRemoved : true -}, { - relPathDir : DIR_RESOURCES + "5/", - dirRemoved : true, - files : ["5test.exe", "5text0", "5text1"], - filesRemoved : true -}, { - relPathDir : DIR_RESOURCES + "6/", - dirRemoved : true -}, { - relPathDir : DIR_RESOURCES + "7/", - dirRemoved : true, - files : ["7text0", "7text1"], - subDirs : ["70/", "71/"], - subDirFiles : ["7xtest.exe", "7xtext0", "7xtext1"] -}, { - relPathDir : DIR_RESOURCES + "8/", - dirRemoved : false -}, { - relPathDir : DIR_RESOURCES + "8/80/", - dirRemoved : true -}, { - relPathDir : DIR_RESOURCES + "8/81/", - dirRemoved : false, - files : ["81text0", "81text1"] -}, { - relPathDir : DIR_RESOURCES + "8/82/", - dirRemoved : false, - subDirs : ["820/", "821/"] -}, { - relPathDir : DIR_RESOURCES + "8/83/", - dirRemoved : true -}, { - relPathDir : DIR_RESOURCES + "8/84/", - dirRemoved : true -}, { - relPathDir : DIR_RESOURCES + "8/85/", - dirRemoved : true -}, { - relPathDir : DIR_RESOURCES + "8/86/", - dirRemoved : true, - files : ["86text0", "86text1"] -}, { - relPathDir : DIR_RESOURCES + "8/87/", - dirRemoved : true, - subDirs : ["870/", "871/"], - subDirFiles : ["87xtext0", "87xtext1"] -}, { - relPathDir : DIR_RESOURCES + "8/88/", - dirRemoved : true -}, { - relPathDir : DIR_RESOURCES + "8/89/", - dirRemoved : true -}, { - relPathDir : DIR_RESOURCES + "9/90/", - dirRemoved : true -}, { - relPathDir : DIR_RESOURCES + "9/91/", - dirRemoved : false, - files : ["91text0", "91text1"] -}, { - relPathDir : DIR_RESOURCES + "9/92/", - dirRemoved : false, - subDirs : ["920/", "921/"] -}, { - relPathDir : DIR_RESOURCES + "9/93/", - dirRemoved : true -}, { - relPathDir : DIR_RESOURCES + "9/94/", - dirRemoved : true -}, { - relPathDir : DIR_RESOURCES + "9/95/", - dirRemoved : true -}, { - relPathDir : DIR_RESOURCES + "9/96/", - dirRemoved : true, - files : ["96text0", "96text1"] -}, { - relPathDir : DIR_RESOURCES + "9/97/", - dirRemoved : true, - subDirs : ["970/", "971/"], - subDirFiles : ["97xtext0", "97xtext1"] -}, { - relPathDir : DIR_RESOURCES + "9/98/", - dirRemoved : true -}, { - relPathDir : DIR_RESOURCES + "9/99/", - dirRemoved : true -}]; + { + relPathDir: DIR_RESOURCES + "3/", + dirRemoved: false, + files: ["3text0", "3text1"], + filesRemoved: true + }, { + relPathDir: DIR_RESOURCES + "4/", + dirRemoved: true, + files: ["4text0", "4text1"], + filesRemoved: true + }, { + relPathDir: DIR_RESOURCES + "5/", + dirRemoved: true, + files: ["5test.exe", "5text0", "5text1"], + filesRemoved: true + }, { + relPathDir: DIR_RESOURCES + "6/", + dirRemoved: true + }, { + relPathDir: DIR_RESOURCES + "7/", + dirRemoved: true, + files: ["7text0", "7text1"], + subDirs: ["70/", "71/"], + subDirFiles: ["7xtest.exe", "7xtext0", "7xtext1"] + }, { + relPathDir: DIR_RESOURCES + "8/", + dirRemoved: false + }, { + relPathDir: DIR_RESOURCES + "8/80/", + dirRemoved: true + }, { + relPathDir: DIR_RESOURCES + "8/81/", + dirRemoved: false, + files: ["81text0", "81text1"] + }, { + relPathDir: DIR_RESOURCES + "8/82/", + dirRemoved: false, + subDirs: ["820/", "821/"] + }, { + relPathDir: DIR_RESOURCES + "8/83/", + dirRemoved: true + }, { + relPathDir: DIR_RESOURCES + "8/84/", + dirRemoved: true + }, { + relPathDir: DIR_RESOURCES + "8/85/", + dirRemoved: true + }, { + relPathDir: DIR_RESOURCES + "8/86/", + dirRemoved: true, + files: ["86text0", "86text1"] + }, { + relPathDir: DIR_RESOURCES + "8/87/", + dirRemoved: true, + subDirs: ["870/", "871/"], + subDirFiles: ["87xtext0", "87xtext1"] + }, { + relPathDir: DIR_RESOURCES + "8/88/", + dirRemoved: true + }, { + relPathDir: DIR_RESOURCES + "8/89/", + dirRemoved: true + }, { + relPathDir: DIR_RESOURCES + "9/90/", + dirRemoved: true + }, { + relPathDir: DIR_RESOURCES + "9/91/", + dirRemoved: false, + files: ["91text0", "91text1"] + }, { + relPathDir: DIR_RESOURCES + "9/92/", + dirRemoved: false, + subDirs: ["920/", "921/"] + }, { + relPathDir: DIR_RESOURCES + "9/93/", + dirRemoved: true + }, { + relPathDir: DIR_RESOURCES + "9/94/", + dirRemoved: true + }, { + relPathDir: DIR_RESOURCES + "9/95/", + dirRemoved: true + }, { + relPathDir: DIR_RESOURCES + "9/96/", + dirRemoved: true, + files: ["96text0", "96text1"] + }, { + relPathDir: DIR_RESOURCES + "9/97/", + dirRemoved: true, + subDirs: ["970/", "971/"], + subDirFiles: ["97xtext0", "97xtext1"] + }, { + relPathDir: DIR_RESOURCES + "9/98/", + dirRemoved: true + }, { + relPathDir: DIR_RESOURCES + "9/99/", + dirRemoved: true + }]; // Directories for a complete successful update. This array can be used for a // complete failed update by calling setTestFilesAndDirsForFailure. var gTestDirsCompleteSuccess = [ -{ - description : "Removed by precomplete (rmdir)", - relPathDir : DIR_RESOURCES + "2/20/", - dirRemoved : true -}, { - description : "Removed by precomplete (rmdir)", - relPathDir : DIR_RESOURCES + "2/", - dirRemoved : true -}]; + { + description: "Removed by precomplete (rmdir)", + relPathDir: DIR_RESOURCES + "2/20/", + dirRemoved: true + }, { + description: "Removed by precomplete (rmdir)", + relPathDir: DIR_RESOURCES + "2/", + dirRemoved: true + }]; // Concatenate the common files to the beginning of the array. gTestDirsCompleteSuccess = gTestDirsCommon.concat(gTestDirsCompleteSuccess); @@ -751,15 +737,15 @@ gTestDirsCompleteSuccess = gTestDirsCommon.concat(gTestDirsCompleteSuccess); // Directories for a partial successful update. This array can be used for a // partial failed update by calling setTestFilesAndDirsForFailure. var gTestDirsPartialSuccess = [ -{ - description : "Removed by update.manifest (rmdir)", - relPathDir : DIR_RESOURCES + "1/10/", - dirRemoved : true -}, { - description : "Removed by update.manifest (rmdir)", - relPathDir : DIR_RESOURCES + "1/", - dirRemoved : true -}]; + { + description: "Removed by update.manifest (rmdir)", + relPathDir: DIR_RESOURCES + "1/10/", + dirRemoved: true + }, { + description: "Removed by update.manifest (rmdir)", + relPathDir: DIR_RESOURCES + "1/", + dirRemoved: true + }]; // Concatenate the common files to the beginning of the array. gTestDirsPartialSuccess = gTestDirsCommon.concat(gTestDirsPartialSuccess); @@ -1347,8 +1333,7 @@ function getSpecialFolderDir(aCSIDL) { return dir; } -XPCOMUtils.defineLazyGetter(this, "gInstallDirPathHash", - function test_gInstallDirPathHash() { +XPCOMUtils.defineLazyGetter(this, "gInstallDirPathHash", function test_gIDPH() { if (!IS_WIN) { do_throw("Windows only function called by a different platform!"); } @@ -1386,8 +1371,7 @@ XPCOMUtils.defineLazyGetter(this, "gInstallDirPathHash", return null; }); -XPCOMUtils.defineLazyGetter(this, "gLocalAppDataDir", - function test_gLocalAppDataDir() { +XPCOMUtils.defineLazyGetter(this, "gLocalAppDataDir", function test_gLADD() { if (!IS_WIN) { do_throw("Windows only function called by a different platform!"); } @@ -1396,8 +1380,7 @@ XPCOMUtils.defineLazyGetter(this, "gLocalAppDataDir", return getSpecialFolderDir(CSIDL_LOCAL_APPDATA); }); -XPCOMUtils.defineLazyGetter(this, "gProgFilesDir", - function test_gProgFilesDir() { +XPCOMUtils.defineLazyGetter(this, "gProgFilesDir", function test_gPFD() { if (!IS_WIN) { do_throw("Windows only function called by a different platform!"); } @@ -1481,8 +1464,7 @@ function getMockUpdRootDWin() { return updatesDir; } -XPCOMUtils.defineLazyGetter(this, "gUpdatesRootDir", - function test_gUpdatesRootDir() { +XPCOMUtils.defineLazyGetter(this, "gUpdatesRootDir", function test_gURD() { if (!IS_MACOSX) { do_throw("Mac OS X only function called by a different platform!"); } @@ -1892,6 +1874,27 @@ function getUpdateLog(aLogLeafName) { return updateLog; } +/** + * The update-staged observer for the call to nsIUpdateProcessor:processUpdate. + */ +const gUpdateStagedObserver = { + observe: function(aSubject, aTopic, aData) { + debugDump("observe called with topic: " + aTopic + ", data: " + aData); + if (aTopic == "update-staged") { + Services.obs.removeObserver(gUpdateStagedObserver, "update-staged"); + // The environment is reset after the update-staged observer topic because + // processUpdate in nsIUpdateProcessor uses a new thread and clearing the + // environment immediately after calling processUpdate can clear the + // environment before the updater is launched. + resetEnvironment(); + // Use do_execute_soon to prevent any failures from propagating to the + // update service. + do_execute_soon(checkUpdateStagedState.bind(null, aData)); + } + }, + QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]) +}; + /** * Stages an update using nsIUpdateProcessor:processUpdate for updater tests. */ @@ -2115,17 +2118,17 @@ function setupAppFiles() { // Required files for the application or the test that aren't listed in the // dependentlibs.list file. - let appFiles = [ { relPath : FILE_APP_BIN, - inGreDir : false }, - { relPath : FILE_APPLICATION_INI, - inGreDir : true }, - { relPath : "dependentlibs.list", - inGreDir : true } ]; + let appFiles = [{relPath: FILE_APP_BIN, + inGreDir: false}, + {relPath: FILE_APPLICATION_INI, + inGreDir: true}, + {relPath: "dependentlibs.list", + inGreDir: true}]; // On Linux the updater.png must also be copied if (IS_UNIX && !IS_MACOSX && !IS_TOOLKIT_GONK) { - appFiles.push( { relPath : "icons/updater.png", - inGreDir : true } ); + appFiles.push({relPath: "icons/updater.png", + inGreDir: true}); } // Read the dependent libs file leafnames from the dependentlibs.list file @@ -2141,8 +2144,8 @@ function setupAppFiles() { let line = {}; do { hasMore = fis.readLine(line); - appFiles.push( { relPath : line.value, - inGreDir : false } ); + appFiles.push({relPath: line.value, + inGreDir: false}); } while (hasMore); fis.close(); @@ -2218,13 +2221,13 @@ function copyFileToTestAppDir(aFileRelPath, aInGreDir) { if (destFile.exists()) { try { destFile.remove(true); - } catch (e) { + } catch (ex) { logTestInfo("unable to remove file that failed to copy! Path: " + destFile.path); } } do_throw("Unable to copy file! Path: " + srcFile.path + - ", Exception: " + e); + ", Exception: " + ex); } } } else { @@ -2388,6 +2391,8 @@ function runUpdateUsingService(aExpectedStatus, aSwitchApp, aCheckSvcLog) { do_throw("Windows only function called by a different platform!"); } + let svcOriginalLog; + // Check the service logs for a successful update function checkServiceLogs(aOriginalContents) { let contents = readServiceLogFile(); @@ -2467,7 +2472,6 @@ function runUpdateUsingService(aExpectedStatus, aSwitchApp, aCheckSvcLog) { }); } - let svcOriginalLog; if (aCheckSvcLog) { svcOriginalLog = readServiceLogFile(); } @@ -3319,7 +3323,7 @@ function checkFilesAfterUpdateCommon(aGetFileFunc, aStageDirExists, if (stageDir.exists()) { debugDump("testing backup files should not be left behind in the " + "staging directory"); - let applyToDir = getApplyDirFile(null, true); + applyToDir = getApplyDirFile(null, true); checkFilesInDirRecursive(stageDir, checkForBackupFiles); } @@ -3536,9 +3540,9 @@ function isFileInUse(aFile) { if (fileBak.exists()) { fileBak.remove(false); } - } catch (e) { + } catch (ex) { logTestInfo("unable to remove backup file, path: " + - fileBak.path + ", exception: " + e); + fileBak.path + ", exception: " + ex); } } return true; @@ -3975,6 +3979,20 @@ function adjustGeneralPaths() { }); } +/** + * The timer callback to kill the process if it takes too long. + */ +const gAppTimerCallback = { + notify: function TC_notify(aTimer) { + gAppTimer = null; + if (gProcess.isRunning) { + logTestInfo("attempting to kill process"); + gProcess.kill(); + } + Assert.ok(false, "launch application timer expired"); + }, + QueryInterface: XPCOMUtils.generateQI([Ci.nsITimerCallback]) +}; /** * Launches an application to apply an update. @@ -4072,42 +4090,6 @@ function runUpdateUsingApp(aExpectedStatus) { debugDump("finish - launching application to apply update"); } -/** - * The timer callback to kill the process if it takes too long. - */ -const gAppTimerCallback = { - notify: function TC_notify(aTimer) { - gAppTimer = null; - if (gProcess.isRunning) { - logTestInfo("attempting to kill process"); - gProcess.kill(); - } - Assert.ok(false, "launch application timer expired"); - }, - QueryInterface: XPCOMUtils.generateQI([Ci.nsITimerCallback]) -}; - -/** - * The update-staged observer for the call to nsIUpdateProcessor:processUpdate. - */ -const gUpdateStagedObserver = { - observe: function(aSubject, aTopic, aData) { - debugDump("observe called with topic: " + aTopic + ", data: " + aData); - if (aTopic == "update-staged") { - Services.obs.removeObserver(gUpdateStagedObserver, "update-staged"); - // The environment is reset after the update-staged observer topic because - // processUpdate in nsIUpdateProcessor uses a new thread and clearing the - // environment immediately after calling processUpdate can clear the - // environment before the updater is launched. - resetEnvironment(); - // Use do_execute_soon to prevent any failures from propagating to the - // update service. - do_execute_soon(checkUpdateStagedState.bind(null, aData)); - } - }, - QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]) -}; - /** * Sets the environment that will be used by the application process when it is * launched. diff --git a/toolkit/mozapps/update/tests/unit_aus_update/downloadCompleteAfterPartialFailure.js b/toolkit/mozapps/update/tests/unit_aus_update/downloadCompleteAfterPartialFailure.js index a5b04a454f3a..15903379230b 100644 --- a/toolkit/mozapps/update/tests/unit_aus_update/downloadCompleteAfterPartialFailure.js +++ b/toolkit/mozapps/update/tests/unit_aus_update/downloadCompleteAfterPartialFailure.js @@ -4,6 +4,29 @@ Components.utils.import("resource://testing-common/MockRegistrar.jsm"); +const WindowWatcher = { + getNewPrompter: function WW_getNewPrompter(aParent) { + Assert.ok(!aParent, + "the aParent parameter should not be defined"); + return { + alert: function WW_GNP_alert(aTitle, aText) { + let title = getString("updaterIOErrorTitle"); + Assert.equal(aTitle, title, + "the ui string for title" + MSG_SHOULD_EQUAL); + let text = gUpdateBundle.formatStringFromName("updaterIOErrorMsg", + [Services.appinfo.name, + Services.appinfo.name], 2); + Assert.equal(aText, text, + "the ui string for message" + MSG_SHOULD_EQUAL); + + doTestFinish(); + } + }; + }, + + QueryInterface: XPCOMUtils.generateQI([Ci.nsIWindowWatcher]) +}; + function run_test() { setupTestCommon(); @@ -41,26 +64,3 @@ function run_test() { createInstance(Ci.nsIUpdatePrompt); prompter.showUpdateError(update); } - -const WindowWatcher = { - getNewPrompter: function WW_getNewPrompter(aParent) { - Assert.ok(!aParent, - "the aParent parameter should not be defined"); - return { - alert: function WW_GNP_alert(aTitle, aText) { - let title = getString("updaterIOErrorTitle"); - Assert.equal(aTitle, title, - "the ui string for title" + MSG_SHOULD_EQUAL); - let text = gUpdateBundle.formatStringFromName("updaterIOErrorMsg", - [Services.appinfo.name, - Services.appinfo.name], 2); - Assert.equal(aText, text, - "the ui string for message" + MSG_SHOULD_EQUAL); - - doTestFinish(); - } - }; - }, - - QueryInterface: XPCOMUtils.generateQI([Ci.nsIWindowWatcher]) -}; diff --git a/toolkit/mozapps/update/tests/unit_aus_update/downloadInterruptedRecovery.js b/toolkit/mozapps/update/tests/unit_aus_update/downloadInterruptedRecovery.js index 57fc16b389e9..36d608b7a382 100644 --- a/toolkit/mozapps/update/tests/unit_aus_update/downloadInterruptedRecovery.js +++ b/toolkit/mozapps/update/tests/unit_aus_update/downloadInterruptedRecovery.js @@ -104,40 +104,40 @@ IncrementalDownload.prototype = { // Do the actual operation async to give a chance for observers // to add themselves. tm.mainThread.dispatch(function() { - this._observer = observer.QueryInterface(Ci.nsIRequestObserver); - this._ctxt = ctxt; - this._observer.onStartRequest(this, this._ctxt); - let mar = getTestDirFile(FILE_SIMPLE_MAR); - mar.copyTo(this._destination.parent, this._destination.leafName); - let status = Cr.NS_OK - switch (gIncrementalDownloadErrorType++) { - case 0: - status = Cr.NS_ERROR_NET_RESET; - break; - case 1: - status = Cr.NS_ERROR_CONNECTION_REFUSED; - break; - case 2: - status = Cr.NS_ERROR_NET_RESET; - break; - case 3: - status = Cr.NS_OK; - break; - case 4: - status = Cr.NS_ERROR_OFFLINE; - // After we report offline, we want to eventually show offline - // status being changed to online. - let tm = Cc["@mozilla.org/thread-manager;1"]. - getService(Ci.nsIThreadManager); - tm.mainThread.dispatch(function() { - Services.obs.notifyObservers(gAUS, - "network:offline-status-changed", - "online"); - }, Ci.nsIThread.DISPATCH_NORMAL); - break; - } - this._observer.onStopRequest(this, this._ctxt, status); - }.bind(this), Ci.nsIThread.DISPATCH_NORMAL); + this._observer = observer.QueryInterface(Ci.nsIRequestObserver); + this._ctxt = ctxt; + this._observer.onStartRequest(this, this._ctxt); + let mar = getTestDirFile(FILE_SIMPLE_MAR); + mar.copyTo(this._destination.parent, this._destination.leafName); + let status = Cr.NS_OK + switch (gIncrementalDownloadErrorType++) { + case 0: + status = Cr.NS_ERROR_NET_RESET; + break; + case 1: + status = Cr.NS_ERROR_CONNECTION_REFUSED; + break; + case 2: + status = Cr.NS_ERROR_NET_RESET; + break; + case 3: + status = Cr.NS_OK; + break; + case 4: + status = Cr.NS_ERROR_OFFLINE; + // After we report offline, we want to eventually show offline + // status being changed to online. + let tm2 = Cc["@mozilla.org/thread-manager;1"]. + getService(Ci.nsIThreadManager); + tm2.mainThread.dispatch(function() { + Services.obs.notifyObservers(gAUS, + "network:offline-status-changed", + "online"); + }, Ci.nsIThread.DISPATCH_NORMAL); + break; + } + this._observer.onStopRequest(this, this._ctxt, status); + }.bind(this), Ci.nsIThread.DISPATCH_NORMAL); }, get URI() { diff --git a/toolkit/mozapps/update/tests/unit_aus_update/uiAutoPref.js b/toolkit/mozapps/update/tests/unit_aus_update/uiAutoPref.js index bb291b389fd1..9a5aaf2ea665 100644 --- a/toolkit/mozapps/update/tests/unit_aus_update/uiAutoPref.js +++ b/toolkit/mozapps/update/tests/unit_aus_update/uiAutoPref.js @@ -4,6 +4,23 @@ Components.utils.import("resource://testing-common/MockRegistrar.jsm"); +const WindowWatcher = { + openWindow: function(aParent, aUrl, aName, aFeatures, aArgs) { + gCheckFunc(); + }, + + QueryInterface: XPCOMUtils.generateQI([Ci.nsIWindowWatcher]) +}; + +const WindowMediator = { + getMostRecentWindow: function(aWindowType) { + do_execute_soon(check_status); + return { getInterface: XPCOMUtils.generateQI([Ci.nsIDOMWindow]) }; + }, + + QueryInterface: XPCOMUtils.generateQI([Ci.nsIWindowMediator]) +}; + function run_test() { setupTestCommon(); // Calling do_get_profile prevents an error from being logged @@ -56,20 +73,3 @@ function check_status() { function check_showUpdateAvailable() { do_throw("showUpdateAvailable should not have called openWindow!"); } - -const WindowWatcher = { - openWindow: function(aParent, aUrl, aName, aFeatures, aArgs) { - gCheckFunc(); - }, - - QueryInterface: XPCOMUtils.generateQI([Ci.nsIWindowWatcher]) -}; - -const WindowMediator = { - getMostRecentWindow: function(aWindowType) { - do_execute_soon(check_status); - return { getInterface: XPCOMUtils.generateQI([Ci.nsIDOMWindow]) }; - }, - - QueryInterface: XPCOMUtils.generateQI([Ci.nsIWindowMediator]) -}; diff --git a/toolkit/mozapps/update/tests/unit_aus_update/uiSilentPref.js b/toolkit/mozapps/update/tests/unit_aus_update/uiSilentPref.js index eb25e30ddd32..25110be8cb4a 100644 --- a/toolkit/mozapps/update/tests/unit_aus_update/uiSilentPref.js +++ b/toolkit/mozapps/update/tests/unit_aus_update/uiSilentPref.js @@ -9,6 +9,18 @@ Components.utils.import("resource://testing-common/MockRegistrar.jsm"); * showUpdateError when the app.update.silent preference is true. */ +const WindowWatcher = { + openWindow: function(aParent, aUrl, aName, aFeatures, aArgs) { + gCheckFunc(); + }, + + getNewPrompter: function(aParent) { + gCheckFunc(); + }, + + QueryInterface: XPCOMUtils.generateQI([Ci.nsIWindowWatcher]) +}; + function run_test() { setupTestCommon(); @@ -62,15 +74,3 @@ function check_showUpdateAvailable() { function check_showUpdateError() { do_throw("showUpdateError should not have seen getNewPrompter!"); } - -const WindowWatcher = { - openWindow: function(aParent, aUrl, aName, aFeatures, aArgs) { - gCheckFunc(); - }, - - getNewPrompter: function(aParent) { - gCheckFunc(); - }, - - QueryInterface: XPCOMUtils.generateQI([Ci.nsIWindowWatcher]) -}; diff --git a/toolkit/mozapps/update/tests/unit_aus_update/uiUnsupportedAlreadyNotified.js b/toolkit/mozapps/update/tests/unit_aus_update/uiUnsupportedAlreadyNotified.js index 4504b521dac2..15dfc7240854 100644 --- a/toolkit/mozapps/update/tests/unit_aus_update/uiUnsupportedAlreadyNotified.js +++ b/toolkit/mozapps/update/tests/unit_aus_update/uiUnsupportedAlreadyNotified.js @@ -4,6 +4,22 @@ Cu.import("resource://testing-common/MockRegistrar.jsm"); +const WindowWatcher = { + openWindow: function(aParent, aUrl, aName, aFeatures, aArgs) { + check_showUpdateAvailable(); + }, + + QueryInterface: XPCOMUtils.generateQI([Ci.nsIWindowWatcher]) +}; + +const WindowMediator = { + getMostRecentWindow: function(aWindowType) { + return null; + }, + + QueryInterface: XPCOMUtils.generateQI([Ci.nsIWindowMediator]) +}; + function run_test() { setupTestCommon(); @@ -56,19 +72,3 @@ function check_test() { function check_showUpdateAvailable() { do_throw("showUpdateAvailable should not have called openWindow!"); } - -const WindowWatcher = { - openWindow: function(aParent, aUrl, aName, aFeatures, aArgs) { - check_showUpdateAvailable(); - }, - - QueryInterface: XPCOMUtils.generateQI([Ci.nsIWindowWatcher]) -}; - -const WindowMediator = { - getMostRecentWindow: function(aWindowType) { - return null; - }, - - QueryInterface: XPCOMUtils.generateQI([Ci.nsIWindowMediator]) -}; diff --git a/toolkit/mozapps/update/tests/unit_aus_update/urlConstruction.js b/toolkit/mozapps/update/tests/unit_aus_update/urlConstruction.js index f22fa4e43e74..1f58c8108c20 100644 --- a/toolkit/mozapps/update/tests/unit_aus_update/urlConstruction.js +++ b/toolkit/mozapps/update/tests/unit_aus_update/urlConstruction.js @@ -179,7 +179,7 @@ function getServicePack() { // http://msdn.microsoft.com/en-us/library/ms724833%28v=vs.85%29.aspx const SZCSDVERSIONLENGTH = 128; const OSVERSIONINFOEXW = new ctypes.StructType('OSVERSIONINFOEXW', - [ + [ {dwOSVersionInfoSize: DWORD}, {dwMajorVersion: DWORD}, {dwMinorVersion: DWORD}, @@ -191,7 +191,7 @@ function getServicePack() { {wSuiteMask: WORD}, {wProductType: BYTE}, {wReserved: BYTE} - ]); + ]); let kernel32 = ctypes.open("kernel32"); try { @@ -224,7 +224,7 @@ function getProcArchitecture() { // This structure is described at: // http://msdn.microsoft.com/en-us/library/ms724958%28v=vs.85%29.aspx const SYSTEM_INFO = new ctypes.StructType('SYSTEM_INFO', - [ + [ {wProcessorArchitecture: WORD}, {wReserved: WORD}, {dwPageSize: DWORD}, @@ -236,7 +236,7 @@ function getProcArchitecture() { {dwAllocationGranularity: DWORD}, {wProcessorLevel: WORD}, {wProcessorRevision: WORD} - ]); + ]); let kernel32 = ctypes.open("kernel32"); try { @@ -293,8 +293,8 @@ function getSystemCapabilities() { instructionSet = "MMX"; } } catch (e) { - Cu.reportError("Error getting processor instruction set. " + - "Exception: " + e); + Cu.reportError("Error getting processor instruction set. " + + "Exception: " + e); } lib.close(); diff --git a/toolkit/mozapps/update/tests/unit_base_updater/marAppInUseStageSuccessComplete_unix.js b/toolkit/mozapps/update/tests/unit_base_updater/marAppInUseStageSuccessComplete_unix.js index cc1dc2630fd5..e77e59141c84 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marAppInUseStageSuccessComplete_unix.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marAppInUseStageSuccessComplete_unix.js @@ -90,17 +90,17 @@ function setupSymLinks() { createSymlink(); do_register_cleanup(removeSymlink); gTestFiles.splice(gTestFiles.length - 3, 0, - { - description : "Readable symlink", - fileName : "link", - relPathDir : DIR_RESOURCES, - originalContents : "test", - compareContents : "test", - originalFile : null, - compareFile : null, - originalPerms : 0o666, - comparePerms : 0o666 - }); + { + description: "Readable symlink", + fileName: "link", + relPathDir: DIR_RESOURCES, + originalContents: "test", + compareContents: "test", + originalFile: null, + compareFile: null, + originalPerms: 0o666, + comparePerms: 0o666 + }); } } diff --git a/toolkit/mozapps/update/tests/unit_base_updater/marStageSuccessComplete.js b/toolkit/mozapps/update/tests/unit_base_updater/marStageSuccessComplete.js index a983f4d0b2ee..9173eee6ce1a 100644 --- a/toolkit/mozapps/update/tests/unit_base_updater/marStageSuccessComplete.js +++ b/toolkit/mozapps/update/tests/unit_base_updater/marStageSuccessComplete.js @@ -107,17 +107,17 @@ function setupSymLinks() { createSymlink(); do_register_cleanup(removeSymlink); gTestFiles.splice(gTestFiles.length - 3, 0, - { - description : "Readable symlink", - fileName : "link", - relPathDir : DIR_RESOURCES, - originalContents : "test", - compareContents : "test", - originalFile : null, - compareFile : null, - originalPerms : 0o666, - comparePerms : 0o666 - }); + { + description: "Readable symlink", + fileName: "link", + relPathDir: DIR_RESOURCES, + originalContents: "test", + compareContents: "test", + originalFile: null, + compareFile: null, + originalPerms: 0o666, + comparePerms: 0o666 + }); } } diff --git a/toolkit/mozapps/update/tests/unit_service_updater/marStageSuccessCompleteSvc.js b/toolkit/mozapps/update/tests/unit_service_updater/marStageSuccessCompleteSvc.js index a983f4d0b2ee..9173eee6ce1a 100644 --- a/toolkit/mozapps/update/tests/unit_service_updater/marStageSuccessCompleteSvc.js +++ b/toolkit/mozapps/update/tests/unit_service_updater/marStageSuccessCompleteSvc.js @@ -107,17 +107,17 @@ function setupSymLinks() { createSymlink(); do_register_cleanup(removeSymlink); gTestFiles.splice(gTestFiles.length - 3, 0, - { - description : "Readable symlink", - fileName : "link", - relPathDir : DIR_RESOURCES, - originalContents : "test", - compareContents : "test", - originalFile : null, - compareFile : null, - originalPerms : 0o666, - comparePerms : 0o666 - }); + { + description: "Readable symlink", + fileName: "link", + relPathDir: DIR_RESOURCES, + originalContents: "test", + compareContents: "test", + originalFile: null, + compareFile: null, + originalPerms: 0o666, + comparePerms: 0o666 + }); } }