Bug 474043 - Part 4 - Cleanup some JSON suffixes. r=Paolo

MozReview-Commit-ID: cja118sBOO

--HG--
extra : rebase_source : ab54cb7f9ec3a82add1c08f3a35513b43ec4beee
This commit is contained in:
Marco Bonardo 2018-03-13 17:50:17 +01:00
Родитель acd043c0a2
Коммит 42c4dcae3e
3 изменённых файлов: 19 добавлений и 31 удалений

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

@ -22,16 +22,11 @@ XPCOMUtils.defineLazyServiceGetter(this, "gExternalProtocolService",
XPCOMUtils.defineLazyServiceGetter(this, "gMIMEService",
"@mozilla.org/mime;1",
"nsIMIMEService");
XPCOMUtils.defineLazyServiceGetter(this, "gHandlerService",
"@mozilla.org/uriloader/handler-service;1",
"nsIHandlerService");
var HandlerServiceTestUtils = {
/**
* This has to be initialized to the nsIHandlerService instance under testing.
*
* When support for migration from the RDF to the JSON back-end is removed,
* this can be replaced by a lazy getter for the default implementation.
*/
handlerService: null,
/**
* Retrieves the names of all the MIME types and protocols configured in the
* handler service instance currently under testing.
@ -41,7 +36,7 @@ var HandlerServiceTestUtils = {
*/
getAllHandlerInfoTypes() {
let handlerInfoTypes = [];
let handlerInfoEnumerator = this.handlerService.enumerate();
let handlerInfoEnumerator = gHandlerService.enumerate();
while (handlerInfoEnumerator.hasMoreElements()) {
let handlerInfo = handlerInfoEnumerator.getNext()
.QueryInterface(Ci.nsIHandlerInfo);
@ -97,8 +92,8 @@ var HandlerServiceTestUtils = {
}
handlerInfo.setFileExtensions("");
// Populate the object from the handler service instance under testing.
if (this.handlerService.exists(handlerInfo)) {
this.handlerService.fillHandlerInfo(handlerInfo, "");
if (gHandlerService.exists(handlerInfo)) {
gHandlerService.fillHandlerInfo(handlerInfo, "");
}
return handlerInfo;
}
@ -109,8 +104,8 @@ var HandlerServiceTestUtils = {
let osDefaultHandlerFound = {};
let handlerInfo = gExternalProtocolService.getProtocolHandlerInfoFromOS(
type, osDefaultHandlerFound);
if (this.handlerService.exists(handlerInfo)) {
this.handlerService.fillHandlerInfo(handlerInfo, "");
if (gHandlerService.exists(handlerInfo)) {
gHandlerService.fillHandlerInfo(handlerInfo, "");
} else {
gExternalProtocolService.setProtocolHandlerDefaults(
handlerInfo, osDefaultHandlerFound.value);

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

@ -18,7 +18,7 @@ ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
ChromeUtils.import("resource://testing-common/HandlerServiceTestUtils.jsm", this);
ChromeUtils.import("resource://testing-common/TestUtils.jsm");
XPCOMUtils.defineLazyServiceGetter(this, "gHandlerServiceJSON",
XPCOMUtils.defineLazyServiceGetter(this, "gHandlerService",
"@mozilla.org/uriloader/handler-service;1",
"nsIHandlerService");
@ -30,11 +30,11 @@ let jsonPath = OS.Path.join(OS.Constants.Path.profileDir, "handlers.json");
* Unloads the nsIHandlerService data store, so the back-end file can be
* accessed or modified, and the new data will be loaded at the next access.
*/
let unloadHandlerStoreJSON = async function() {
let unloadHandlerStore = async function() {
// If this function is called before the nsIHandlerService instance has been
// initialized for the first time, the observer below will not be registered.
// We have to force initialization to prevent the function from stalling.
gHandlerServiceJSON;
gHandlerService;
let promise = TestUtils.topicObserved("handlersvc-json-replace-complete");
Services.obs.notifyObservers(null, "handlersvc-json-replace", null);
@ -44,8 +44,8 @@ let unloadHandlerStoreJSON = async function() {
/**
* Unloads the data store and deletes it.
*/
let deleteHandlerStoreJSON = async function() {
await unloadHandlerStoreJSON();
let deleteHandlerStore = async function() {
await unloadHandlerStore();
await OS.File.remove(jsonPath, { ignoreAbsent: true });
};
@ -53,8 +53,8 @@ let deleteHandlerStoreJSON = async function() {
/**
* Unloads the data store and replaces it with the test data file.
*/
let copyTestDataToHandlerStoreJSON = async function() {
await unloadHandlerStoreJSON();
let copyTestDataToHandlerStore = async function() {
await unloadHandlerStore();
await OS.File.copy(do_get_file("handlers.json").path, jsonPath);
};
@ -63,5 +63,5 @@ let copyTestDataToHandlerStoreJSON = async function() {
* Ensures the files are removed and the services unloaded when the tests end.
*/
registerCleanupFunction(async function test_terminate() {
await deleteHandlerStoreJSON();
await deleteHandlerStore();
});

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

@ -2,16 +2,9 @@
* http://creativecommons.org/publicdomain/zero/1.0/ */
/*
* Tests the nsIHandlerService interface using the JSON backend.
* Tests the nsIHandlerService interface.
*/
let gHandlerService = gHandlerServiceJSON;
let unloadHandlerStore = unloadHandlerStoreJSON;
let deleteHandlerStore = deleteHandlerStoreJSON;
let copyTestDataToHandlerStore = copyTestDataToHandlerStoreJSON;
HandlerServiceTestUtils.handlerService = gHandlerService;
// Set up an nsIWebHandlerApp instance that can be used in multiple tests.
let webHandlerApp = Cc["@mozilla.org/uriloader/web-handler-app;1"]
.createInstance(Ci.nsIWebHandlerApp);
@ -443,7 +436,7 @@ add_task(async function test_store_no_duplicates() {
/**
* Tests that "store" deletes properties that have their default values from
* the data store. This is mainly relevant for the JSON back-end.
* the data store.
*
* File extensions are never deleted once they have been associated.
*/
@ -615,7 +608,7 @@ add_task(async function test_default_protocol_handlers_no_duplicates() {
/**
* Ensures forward compatibility by checking that the "store" method preserves
* unknown properties in the test data. This is specific to the JSON back-end.
* unknown properties in the test data.
*/
add_task(async function test_store_keeps_unknown_properties() {
// Create a new nsIHandlerInfo instance before loading the test data.