1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/components/migration/tests/unit/head_migration.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,64 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this file, 1.6 + * You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +const Cc = Components.classes; 1.9 +const Ci = Components.interfaces; 1.10 +const Cu = Components.utils; 1.11 +const Cr = Components.results; 1.12 + 1.13 +Cu.import("resource://gre/modules/XPCOMUtils.jsm"); 1.14 +Cu.import("resource://gre/modules/Services.jsm"); 1.15 + 1.16 +XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils", 1.17 + "resource://gre/modules/PlacesUtils.jsm"); 1.18 +XPCOMUtils.defineLazyModuleGetter(this, "FileUtils", 1.19 + "resource://gre/modules/FileUtils.jsm"); 1.20 +XPCOMUtils.defineLazyModuleGetter(this, "MigrationUtils", 1.21 + "resource:///modules/MigrationUtils.jsm"); 1.22 +// Initialize profile. 1.23 +let gProfD = do_get_profile(); 1.24 + 1.25 +// Create a fake XULAppInfo to satisfy the eventual needs of the migrators. 1.26 +let (XULAppInfo = { 1.27 + // nsIXUlAppInfo 1.28 + get vendor() "Mozilla", 1.29 + get name() "XPCShell", 1.30 + get ID() "xpcshell@tests.mozilla.org", 1.31 + get version() "1", 1.32 + get appBuildID() "2007010101", 1.33 + get platformVersion() "1.0", 1.34 + get platformBuildID() "2007010101", 1.35 + 1.36 + // nsIXUlRuntime (partial) 1.37 + get inSafeMode() false, 1.38 + logConsoleErrors: true, 1.39 + get OS() "XPCShell", 1.40 + get XPCOMABI() "noarch-spidermonkey", 1.41 + invalidateCachesOnRestart: function () {}, 1.42 + 1.43 + // nsIWinAppHelper 1.44 + get userCanElevate() false, 1.45 + 1.46 + QueryInterface: function (aIID) { 1.47 + let interfaces = [Ci.nsIXULAppInfo, Ci.nsIXULRuntime]; 1.48 + if ("nsIWinAppHelper" in Ci) 1.49 + interfaces.push(Ci.nsIWinAppHelper); 1.50 + if (!interfaces.some(function (v) aIID.equals(v))) 1.51 + throw Cr.NS_ERROR_NO_INTERFACE; 1.52 + return this; 1.53 + } 1.54 +}) { 1.55 + const CONTRACT_ID = "@mozilla.org/xre/app-info;1"; 1.56 + const CID = Components.ID("7685dac8-3637-4660-a544-928c5ec0e714}"); 1.57 + 1.58 + let registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar); 1.59 + registrar.registerFactory(CID, "XULAppInfo", CONTRACT_ID, { 1.60 + createInstance: function (aOuter, aIID) { 1.61 + if (aOuter != null) 1.62 + throw Cr.NS_ERROR_NO_AGGREGATION; 1.63 + return XULAppInfo.QueryInterface(aIID); 1.64 + }, 1.65 + QueryInterface: XPCOMUtils.generateQI(Ci.nsIFactory) 1.66 + }); 1.67 +}