Bug 527444 - use do_register_cleanup calls instead of tail_*.js files in xpcshell, in Core and Toolkit. r?paolo.
Patch originally by Rahid Hasan. Updated by Akshendra Pratap Singh, jdm and Standard8.
MozReview-Commit-ID: F0edTCSsXzy
--- a/modules/libjar/zipwriter/test/unit/head_zipwriter.js
+++ b/modules/libjar/zipwriter/test/unit/head_zipwriter.js
@@ -39,8 +39,18 @@ var ZipReader = Components.Constructor("
var tmpDir = do_get_profile();
var tmpFile = tmpDir.clone();
tmpFile.append("zipwriter-test.zip");
if (tmpFile.exists())
tmpFile.remove(true);
var zipW = new ZipWriter();
+
+do_register_cleanup(function() {
+ try {
+ zipW.close();
+ } catch (e) {
+ // Just ignore a failure here and attempt to delete the file anyway.
+ }
+ if (tmpFile.exists())
+ tmpFile.remove(true);
+});
deleted file mode 100644
--- a/modules/libjar/zipwriter/test/unit/tail_zipwriter.js
+++ /dev/null
@@ -1,14 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * 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/.
- */
-
-try {
- zipW.close();
-}
-catch (e) {
- // Just ignore a failure here and attempt to delete the file anyway.
-}
-
-if (tmpFile.exists())
- tmpFile.remove(true);
--- a/modules/libjar/zipwriter/test/unit/xpcshell.ini
+++ b/modules/libjar/zipwriter/test/unit/xpcshell.ini
@@ -1,11 +1,11 @@
[DEFAULT]
head = head_zipwriter.js
-tail = tail_zipwriter.js
+tail =
support-files =
data/test_bug446708/thumbs/st14-1.tiff
data/emptyfile.txt
data/smallfile.txt
data/test.png
data/test.txt
data/test.zip
data/test_bug399727.html
--- a/toolkit/components/url-classifier/tests/unit/head_urlclassifier.js
+++ b/toolkit/components/url-classifier/tests/unit/head_urlclassifier.js
@@ -472,8 +472,12 @@ function waitUntilMetaDataSaved(expected
do_timeout(1000, waitUntilMetaDataSaved.bind(null, expectedState,
expectedChecksum,
callback));
}
});
}
cleanUp();
+
+do_register_cleanup(function() {
+ cleanUp();
+});
deleted file mode 100644
--- a/toolkit/components/url-classifier/tests/unit/tail_urlclassifier.js
+++ /dev/null
@@ -1,1 +0,0 @@
-cleanUp();
--- a/toolkit/components/url-classifier/tests/unit/xpcshell.ini
+++ b/toolkit/components/url-classifier/tests/unit/xpcshell.ini
@@ -1,11 +1,11 @@
[DEFAULT]
head = head_urlclassifier.js
-tail = tail_urlclassifier.js
+tail =
skip-if = toolkit == 'android'
support-files =
data/digest1.chunk
data/digest2.chunk
[test_addsub.js]
[test_bug1274685_unowned_list.js]
[test_backoff.js]
--- a/toolkit/identity/tests/unit/head_identity.js
+++ b/toolkit/identity/tests/unit/head_identity.js
@@ -241,16 +241,20 @@ Services.prefs.setBoolPref("toolkit.iden
// Switch on firefox accounts
var initialPrefFXAValue = false;
try {
initialPrefFXAValue = Services.prefs.getBoolPref("identity.fxaccounts.enabled");
} catch (noPref) {}
Services.prefs.setBoolPref("identity.fxaccounts.enabled", true);
-// after execution, restore prefs
do_register_cleanup(function() {
log("restoring prefs to their initial values");
Services.prefs.setBoolPref("toolkit.identity.debug", initialPrefDebugValue);
Services.prefs.setBoolPref("identity.fxaccounts.enabled", initialPrefFXAValue);
+
+ // Pre-emptively shut down to clear resources.
+ if (typeof IdentityService !== "undefined") {
+ IdentityService.shutdown();
+ } else if (typeof IDService !== "undefined") {
+ IDService.shutdown();
+ }
});
-
-
deleted file mode 100644
--- a/toolkit/identity/tests/unit/tail_identity.js
+++ /dev/null
@@ -1,8 +0,0 @@
-
-// pre-emptively shut down to clear resources
-if (typeof IdentityService !== "undefined") {
- IdentityService.shutdown();
-} else if (typeof IDService !== "undefined") {
- IDService.shutdown();
-}
-
--- a/toolkit/identity/tests/unit/xpcshell.ini
+++ b/toolkit/identity/tests/unit/xpcshell.ini
@@ -1,11 +1,11 @@
[DEFAULT]
head = head_identity.js
-tail = tail_identity.js
+tail =
skip-if = (appname != "b2g" || toolkit == 'gonk')
support-files =
data/idp_1/.well-known/browserid
data/idp_invalid_1/.well-known/browserid
# Test load modules first so syntax failures are caught early.
[test_load_modules.js]
[test_minimalidentity.js]
--- a/uriloader/exthandler/tests/unit/head_handlerService.js
+++ b/uriloader/exthandler/tests/unit/head_handlerService.js
@@ -28,29 +28,29 @@ var HandlerServiceTest = {
this.__consoleSvc = Cc["@mozilla.org/consoleservice;1"].
getService(Ci.nsIConsoleService);
return this.__consoleSvc;
},
//**************************************************************************//
// nsISupports
-
+
interfaces: [Ci.nsIDirectoryServiceProvider, Ci.nsISupports],
QueryInterface: function HandlerServiceTest_QueryInterface(iid) {
if (!this.interfaces.some( function(v) { return iid.equals(v) } ))
throw Cr.NS_ERROR_NO_INTERFACE;
return this;
},
//**************************************************************************//
// Initialization & Destruction
-
+
init: function HandlerServiceTest_init() {
// Register ourselves as a directory provider for the datasource file
// if there isn't one registered already.
try {
this._dirSvc.get("UMimTyp", Ci.nsIFile);
} catch (ex) {
this._dirSvc.registerProvider(this);
this._providerRegistered = true;
@@ -156,8 +156,12 @@ var HandlerServiceTest = {
message = "*** HandlerServiceTest: " + message;
this._consoleSvc.logStringMessage(message);
print(message);
}
};
HandlerServiceTest.init();
+
+do_register_cleanup(function() {
+ HandlerServiceTest.destroy();
+});
deleted file mode 100644
--- a/uriloader/exthandler/tests/unit/tail_handlerService.js
+++ /dev/null
@@ -1,5 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * 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/. */
-
-HandlerServiceTest.destroy();
--- a/uriloader/exthandler/tests/unit/xpcshell.ini
+++ b/uriloader/exthandler/tests/unit/xpcshell.ini
@@ -1,11 +1,11 @@
[DEFAULT]
head = head_handlerService.js
-tail = tail_handlerService.js
+tail =
run-sequentially = Bug 912235 - Intermittent failures
[test_getTypeFromExtension_ext_to_type_mapping.js]
[test_getTypeFromExtension_with_empty_Content_Type.js]
[test_badMIMEType.js]
[test_handlerService.js]
support-files = mailcap
# Bug 676997: test consistently fails on Android