зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 1 changesets (bug 1417940) for failing browser-chrome browser/components/contextualidentity/test/browser/browser_aboutURLs.js r=backout on a CLOSED TREE
Backed out changeset 2c2f807e23b5 (bug 1417940)
This commit is contained in:
Родитель
83c3d396d1
Коммит
d377351feb
|
@ -2,25 +2,26 @@
|
|||
* 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/. */
|
||||
|
||||
var Cu = Components.utils;
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
// get release notes and vendor URL from prefs
|
||||
var releaseNotesURL = Services.urlFormatter.formatURLPref("app.releaseNotesURL");
|
||||
var formatter = Components.classes["@mozilla.org/toolkit/URLFormatterService;1"]
|
||||
.getService(Components.interfaces.nsIURLFormatter);
|
||||
var releaseNotesURL = formatter.formatURLPref("app.releaseNotesURL");
|
||||
if (releaseNotesURL != "about:blank") {
|
||||
var relnotes = document.getElementById("releaseNotesURL");
|
||||
relnotes.setAttribute("href", releaseNotesURL);
|
||||
relnotes.parentNode.removeAttribute("hidden");
|
||||
}
|
||||
|
||||
var vendorURL = Services.urlFormatter.formatURLPref("app.vendorURL");
|
||||
var vendorURL = formatter.formatURLPref("app.vendorURL");
|
||||
if (vendorURL != "about:blank") {
|
||||
var vendor = document.getElementById("vendorURL");
|
||||
vendor.setAttribute("href", vendorURL);
|
||||
}
|
||||
|
||||
// insert the version of the XUL application (!= XULRunner platform version)
|
||||
var versionNum = Services.appinfo.version;
|
||||
var versionNum = Components.classes["@mozilla.org/xre/app-info;1"]
|
||||
.getService(Components.interfaces.nsIXULAppInfo)
|
||||
.version;
|
||||
var version = document.getElementById("version");
|
||||
version.textContent += " " + versionNum;
|
||||
|
||||
|
|
|
@ -4,9 +4,6 @@
|
|||
|
||||
var Cc = Components.classes;
|
||||
var Ci = Components.interfaces;
|
||||
var Cu = Components.utils;
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
var gProtocols = [];
|
||||
var gContainer;
|
||||
window.onload = function() {
|
||||
|
@ -15,6 +12,7 @@ window.onload = function() {
|
|||
};
|
||||
|
||||
function findAbouts() {
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
|
||||
for (var cid in Cc) {
|
||||
var result = cid.match(/@mozilla.org\/network\/protocol\/about;1\?what\=(.*)$/);
|
||||
if (result) {
|
||||
|
@ -22,7 +20,7 @@ function findAbouts() {
|
|||
var contract = "@mozilla.org/network/protocol/about;1?what=" + aboutType;
|
||||
try {
|
||||
var am = Cc[contract].getService(Ci.nsIAboutModule);
|
||||
var uri = Services.io.newURI("about:" + aboutType);
|
||||
var uri = ios.newURI("about:" + aboutType);
|
||||
var flags = am.getURIFlags(uri);
|
||||
if (!(flags & Ci.nsIAboutModule.HIDE_FROM_ABOUTABOUT)) {
|
||||
gProtocols.push(aboutType);
|
||||
|
|
|
@ -27,7 +27,9 @@ const bundle = Services.strings.createBundle(
|
|||
function findCurrentProfile() {
|
||||
let cpd;
|
||||
try {
|
||||
cpd = Services.dirsvc.get("ProfD", Ci.nsIFile);
|
||||
cpd = Cc["@mozilla.org/file/directory_service;1"]
|
||||
.getService(Ci.nsIProperties)
|
||||
.get("ProfD", Ci.nsIFile);
|
||||
} catch (e) {}
|
||||
|
||||
if (cpd) {
|
||||
|
|
|
@ -901,7 +901,9 @@ function copyRawDataToClipboard(button) {
|
|||
transferable.init(getLoadContext());
|
||||
transferable.addDataFlavor("text/unicode");
|
||||
transferable.setTransferData("text/unicode", str, str.data.length * 2);
|
||||
Services.clipboard.setData(transferable, null, Ci.nsIClipboard.kGlobalClipboard);
|
||||
Cc["@mozilla.org/widget/clipboard;1"].
|
||||
getService(Ci.nsIClipboard).
|
||||
setData(transferable, null, Ci.nsIClipboard.kGlobalClipboard);
|
||||
if (AppConstants.platform == "android") {
|
||||
// Present a toast notification.
|
||||
let message = {
|
||||
|
@ -951,7 +953,9 @@ function copyContentsToClipboard() {
|
|||
transferable.setTransferData("text/unicode", ssText, dataText.length * 2);
|
||||
|
||||
// Store the data into the clipboard.
|
||||
Services.clipboard.setData(transferable, null, Services.clipboard.kGlobalClipboard);
|
||||
let clipboard = Cc["@mozilla.org/widget/clipboard;1"]
|
||||
.getService(Ci.nsIClipboard);
|
||||
clipboard.setData(transferable, null, clipboard.kGlobalClipboard);
|
||||
|
||||
if (AppConstants.platform == "android") {
|
||||
// Present a toast notification.
|
||||
|
|
|
@ -8,7 +8,9 @@ function closeWindow(aClose, aPromptFunction) {
|
|||
// Closing the last window doesn't quit the application on OS X.
|
||||
if (AppConstants.platform != "macosx") {
|
||||
var windowCount = 0;
|
||||
var e = Services.wm.getEnumerator(null);
|
||||
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
|
||||
.getService(Components.interfaces.nsIWindowMediator);
|
||||
var e = wm.getEnumerator(null);
|
||||
|
||||
while (e.hasMoreElements()) {
|
||||
var w = e.getNext();
|
||||
|
@ -37,10 +39,14 @@ function closeWindow(aClose, aPromptFunction) {
|
|||
}
|
||||
|
||||
function canQuitApplication(aData) {
|
||||
var os = Components.classes["@mozilla.org/observer-service;1"]
|
||||
.getService(Components.interfaces.nsIObserverService);
|
||||
if (!os) return true;
|
||||
|
||||
try {
|
||||
var cancelQuit = Components.classes["@mozilla.org/supports-PRBool;1"]
|
||||
.createInstance(Components.interfaces.nsISupportsPRBool);
|
||||
Services.obs.notifyObservers(cancelQuit, "quit-application-requested", aData || null);
|
||||
os.notifyObservers(cancelQuit, "quit-application-requested", aData || null);
|
||||
|
||||
// Something aborted the quit process.
|
||||
if (cancelQuit.data)
|
||||
|
@ -53,7 +59,10 @@ function goQuitApplication() {
|
|||
if (!canQuitApplication())
|
||||
return false;
|
||||
|
||||
Services.startup.quit(Components.interfaces.nsIAppStartup.eAttemptQuit);
|
||||
var appStartup = Components.classes["@mozilla.org/toolkit/app-startup;1"].
|
||||
getService(Components.interfaces.nsIAppStartup);
|
||||
|
||||
appStartup.quit(Components.interfaces.nsIAppStartup.eAttemptQuit);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,9 @@
|
|||
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
var pluginsbundle = Services.strings.createBundle("chrome://global/locale/plugins.properties");
|
||||
var Ci = Components.interfaces;
|
||||
var strBundleService = Components.classes["@mozilla.org/intl/stringbundle;1"].getService(Ci.nsIStringBundleService);
|
||||
var pluginsbundle = strBundleService.createBundle("chrome://global/locale/plugins.properties");
|
||||
|
||||
// eslint-disable-next-line no-unsanitized/method
|
||||
document.writeln("<title>" + pluginsbundle.GetStringFromName("title_label") + "<\/title>");
|
||||
|
|
|
@ -98,11 +98,15 @@ function test() {
|
|||
}
|
||||
|
||||
/* import-globals-from common/mockTransfer.js */
|
||||
Services.scriptloader.loadSubScript("chrome://mochitests/content/browser/toolkit/content/tests/browser/common/mockTransfer.js",
|
||||
Cc["@mozilla.org/moz/jssubscript-loader;1"]
|
||||
.getService(Ci.mozIJSSubScriptLoader)
|
||||
.loadSubScript("chrome://mochitests/content/browser/toolkit/content/tests/browser/common/mockTransfer.js",
|
||||
this);
|
||||
|
||||
function createTemporarySaveDirectory() {
|
||||
var saveDir = Services.dirsvc.get("TmpD", Ci.nsIFile);
|
||||
var saveDir = Cc["@mozilla.org/file/directory_service;1"]
|
||||
.getService(Ci.nsIProperties)
|
||||
.get("TmpD", Ci.nsIFile);
|
||||
saveDir.append("testsavedir");
|
||||
if (!saveDir.exists())
|
||||
saveDir.create(Ci.nsIFile.DIRECTORY_TYPE, 0o755);
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
* 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/. */
|
||||
|
||||
Services.scriptloader.loadSubScript("chrome://mochikit/content/tests/SimpleTest/MockObjects.js", this);
|
||||
Cc["@mozilla.org/moz/jssubscript-loader;1"]
|
||||
.getService(Ci.mozIJSSubScriptLoader)
|
||||
.loadSubScript("chrome://mochikit/content/tests/SimpleTest/MockObjects.js", this);
|
||||
|
||||
var mockTransferCallback;
|
||||
|
||||
|
|
|
@ -6,17 +6,18 @@ const XUL_CACHE_PREF = "nglayout.debug.disable_xul_cache";
|
|||
var Cc = Components.classes;
|
||||
var Ci = Components.interfaces;
|
||||
var Cr = Components.results;
|
||||
var Cu = Components.utils;
|
||||
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
var gDirSvc = Cc["@mozilla.org/file/directory_service;1"].
|
||||
getService(Ci.nsIDirectoryService).QueryInterface(Ci.nsIProperties);
|
||||
var gChromeReg = Cc["@mozilla.org/chrome/chrome-registry;1"].
|
||||
getService(Ci.nsIXULChromeRegistry);
|
||||
var gPrefs = Cc["@mozilla.org/preferences-service;1"].
|
||||
getService(Ci.nsIPrefBranch);
|
||||
|
||||
// Create the temporary file in the profile, instead of in TmpD, because
|
||||
// we know the mochitest harness kills off the profile when it's done.
|
||||
function copyToTemporaryFile(f) {
|
||||
let tmpd = Services.dirsvc.get("ProfD", Ci.nsIFile);
|
||||
let tmpd = gDirSvc.get("ProfD", Ci.nsIFile);
|
||||
let tmpf = tmpd.clone();
|
||||
tmpf.append("temp.manifest");
|
||||
tmpf.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o600);
|
||||
|
@ -26,7 +27,9 @@ function copyToTemporaryFile(f) {
|
|||
}
|
||||
|
||||
function* dirIter(directory) {
|
||||
var testsDir = Services.io.newURI(directory)
|
||||
var ioSvc = Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService);
|
||||
var testsDir = ioSvc.newURI(directory)
|
||||
.QueryInterface(Ci.nsIFileURL).file;
|
||||
|
||||
let en = testsDir.directoryEntries;
|
||||
|
@ -54,7 +57,7 @@ function copyDirToTempProfile(path, subdirname) {
|
|||
subdirname = "mochikit-tmp";
|
||||
}
|
||||
|
||||
let tmpdir = Services.dirsvc.get("ProfD", Ci.nsIFile);
|
||||
let tmpdir = gDirSvc.get("ProfD", Ci.nsIFile);
|
||||
tmpdir.append(subdirname);
|
||||
tmpdir.createUnique(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0o777);
|
||||
|
||||
|
@ -73,7 +76,8 @@ function copyDirToTempProfile(path, subdirname) {
|
|||
}
|
||||
|
||||
function convertChromeURI(chromeURI) {
|
||||
let uri = Services.io.newURI(chromeURI);
|
||||
let uri = Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService).newURI(chromeURI);
|
||||
return gChromeReg.convertChromeURL(uri);
|
||||
}
|
||||
|
||||
|
@ -95,7 +99,7 @@ function chromeURIToFile(chromeURI) {
|
|||
// Register a chrome manifest temporarily and return a function which un-does
|
||||
// the registrarion when no longer needed.
|
||||
function createManifestTemporarily(tempDir, manifestText) {
|
||||
Services.prefs.setBoolPref(XUL_CACHE_PREF, true);
|
||||
gPrefs.setBoolPref(XUL_CACHE_PREF, true);
|
||||
|
||||
tempDir.append("temp.manifest");
|
||||
|
||||
|
@ -116,14 +120,14 @@ function createManifestTemporarily(tempDir, manifestText) {
|
|||
tempfile.fileSize = 0; // truncate the manifest
|
||||
gChromeReg.checkForNewChrome();
|
||||
gChromeReg.refreshSkins();
|
||||
Services.prefs.clearUserPref(XUL_CACHE_PREF);
|
||||
gPrefs.clearUserPref(XUL_CACHE_PREF);
|
||||
};
|
||||
}
|
||||
|
||||
// Register a chrome manifest temporarily and return a function which un-does
|
||||
// the registrarion when no longer needed.
|
||||
function registerManifestTemporarily(manifestURI) {
|
||||
Services.prefs.setBoolPref(XUL_CACHE_PREF, true);
|
||||
gPrefs.setBoolPref(XUL_CACHE_PREF, true);
|
||||
|
||||
let file = chromeURIToFile(manifestURI);
|
||||
|
||||
|
@ -137,7 +141,7 @@ function registerManifestTemporarily(manifestURI) {
|
|||
tempfile.fileSize = 0; // truncate the manifest
|
||||
gChromeReg.checkForNewChrome();
|
||||
gChromeReg.refreshSkins();
|
||||
Services.prefs.clearUserPref(XUL_CACHE_PREF);
|
||||
gPrefs.clearUserPref(XUL_CACHE_PREF);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -6,13 +6,12 @@
|
|||
var Ci = Components.interfaces;
|
||||
var Cc = Components.classes;
|
||||
var Cr = Components.results;
|
||||
var Cu = Components.utils;
|
||||
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
function loadUtilsScript() {
|
||||
var loader = Cc["@mozilla.org/moz/jssubscript-loader;1"].
|
||||
getService(Ci.mozIJSSubScriptLoader);
|
||||
/* import-globals-from ../../contentAreaUtils.js */
|
||||
Services.scriptloader.loadSubScript("chrome://global/content/contentAreaUtils.js");
|
||||
loader.loadSubScript("chrome://global/content/contentAreaUtils.js");
|
||||
}
|
||||
|
||||
function test_urlSecurityCheck() {
|
||||
|
|
|
@ -10,27 +10,29 @@
|
|||
* that accept a browser to be modified.
|
||||
**/
|
||||
|
||||
var Cu = Components.utils;
|
||||
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
var ZoomManager = {
|
||||
get _prefBranch() {
|
||||
delete this._prefBranch;
|
||||
return this._prefBranch = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefBranch);
|
||||
},
|
||||
|
||||
get MIN() {
|
||||
delete this.MIN;
|
||||
return this.MIN = Services.prefs.getIntPref("zoom.minPercent") / 100;
|
||||
return this.MIN = this._prefBranch.getIntPref("zoom.minPercent") / 100;
|
||||
},
|
||||
|
||||
get MAX() {
|
||||
delete this.MAX;
|
||||
return this.MAX = Services.prefs.getIntPref("zoom.maxPercent") / 100;
|
||||
return this.MAX = this._prefBranch.getIntPref("zoom.maxPercent") / 100;
|
||||
},
|
||||
|
||||
get useFullZoom() {
|
||||
return Services.prefs.getBoolPref("browser.zoom.full");
|
||||
return this._prefBranch.getBoolPref("browser.zoom.full");
|
||||
},
|
||||
|
||||
set useFullZoom(aVal) {
|
||||
Services.prefs.setBoolPref("browser.zoom.full", aVal);
|
||||
this._prefBranch.setBoolPref("browser.zoom.full", aVal);
|
||||
return aVal;
|
||||
},
|
||||
|
||||
|
@ -64,8 +66,8 @@ var ZoomManager = {
|
|||
},
|
||||
|
||||
get zoomValues() {
|
||||
var zoomValues = Services.prefs.getCharPref("toolkit.zoomManager.zoomValues")
|
||||
.split(",").map(parseFloat);
|
||||
var zoomValues = this._prefBranch.getCharPref("toolkit.zoomManager.zoomValues")
|
||||
.split(",").map(parseFloat);
|
||||
zoomValues.sort((a, b) => a - b);
|
||||
|
||||
while (zoomValues[0] < this.MIN)
|
||||
|
|
|
@ -44,7 +44,9 @@ function parseINIStrings(path) {
|
|||
// Since we're basically re-implementing (with async) part of the crashreporter
|
||||
// client here, we'll just steal the strings we need from crashreporter.ini
|
||||
async function getL10nStrings() {
|
||||
let path = OS.Path.join(Services.dirsvc.get("GreD", Ci.nsIFile).path,
|
||||
let dirSvc = Cc["@mozilla.org/file/directory_service;1"].
|
||||
getService(Ci.nsIProperties);
|
||||
let path = OS.Path.join(dirSvc.get("GreD", Ci.nsIFile).path,
|
||||
"crashreporter.ini");
|
||||
let pathExists = await OS.File.exists(path);
|
||||
|
||||
|
@ -73,7 +75,7 @@ async function getL10nStrings() {
|
|||
"reporturl": crstrings.CrashDetailsURL
|
||||
};
|
||||
|
||||
path = OS.Path.join(Services.dirsvc.get("XCurProcD", Ci.nsIFile).path,
|
||||
path = OS.Path.join(dirSvc.get("XCurProcD", Ci.nsIFile).path,
|
||||
"crashreporter-override.ini");
|
||||
pathExists = await OS.File.exists(path);
|
||||
|
||||
|
@ -93,7 +95,9 @@ async function getL10nStrings() {
|
|||
}
|
||||
|
||||
function getDir(name) {
|
||||
let uAppDataPath = Services.dirsvc.get("UAppData", Ci.nsIFile).path;
|
||||
let dirSvc = Cc["@mozilla.org/file/directory_service;1"].
|
||||
getService(Ci.nsIProperties);
|
||||
let uAppDataPath = dirSvc.get("UAppData", Ci.nsIFile).path;
|
||||
return OS.Path.join(uAppDataPath, "Crash Reports", name);
|
||||
}
|
||||
|
||||
|
|
|
@ -49,8 +49,12 @@ function submitPendingReport(event) {
|
|||
}
|
||||
|
||||
function populateReportList() {
|
||||
|
||||
var prefService = Cc["@mozilla.org/preferences-service;1"].
|
||||
getService(Ci.nsIPrefBranch);
|
||||
|
||||
try {
|
||||
reportURL = Services.prefs.getCharPref("breakpad.reportURL");
|
||||
reportURL = prefService.getCharPref("breakpad.reportURL");
|
||||
// Ignore any non http/https urls
|
||||
if (!/^https?:/i.test(reportURL))
|
||||
reportURL = null;
|
||||
|
@ -89,9 +93,11 @@ function populateReportList() {
|
|||
}
|
||||
};
|
||||
}
|
||||
var reportURI = Services.io.newURI(reportURL);
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService);
|
||||
var reportURI = ios.newURI(reportURL);
|
||||
// resolving this URI relative to /report/index
|
||||
var aboutThrottling = Services.io.newURI("../../about/throttling", null, reportURI);
|
||||
var aboutThrottling = ios.newURI("../../about/throttling", null, reportURI);
|
||||
|
||||
for (var i = 0; i < reports.length; i++) {
|
||||
var row = document.createElement("tr");
|
||||
|
|
|
@ -4,7 +4,9 @@ add_task(async function test() {
|
|||
crD.append("Crash Reports");
|
||||
let crashes = add_fake_crashes(crD, 5);
|
||||
// sanity check
|
||||
let appDtest = Services.dirsvc.get("UAppData", Components.interfaces.nsIFile);
|
||||
let dirSvc = Components.classes["@mozilla.org/file/directory_service;1"]
|
||||
.getService(Components.interfaces.nsIProperties);
|
||||
let appDtest = dirSvc.get("UAppData", Components.interfaces.nsIFile);
|
||||
ok(appD.equals(appDtest), "directory service provider registered ok");
|
||||
|
||||
await BrowserTestUtils.withNewTab({ gBrowser, url: "about:crashes" }, function(browser) {
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
function create_subdir(dir, subdirname) {
|
||||
let subdir = dir.clone();
|
||||
subdir.append(subdirname);
|
||||
|
@ -17,7 +15,9 @@ function make_fake_appdir() {
|
|||
// Create a directory inside the profile and register it as UAppData, so
|
||||
// we can stick fake crash reports inside there. We put it inside the profile
|
||||
// just because we know that will get cleaned up after the mochitest run.
|
||||
let profD = Services.dirsvc.get("ProfD", Ci.nsIFile);
|
||||
let dirSvc = Cc["@mozilla.org/file/directory_service;1"]
|
||||
.getService(Ci.nsIProperties);
|
||||
let profD = dirSvc.get("ProfD", Ci.nsIFile);
|
||||
// create a subdir just to keep our files out of the way
|
||||
let appD = create_subdir(profD, "UAppData");
|
||||
|
||||
|
@ -48,21 +48,23 @@ function make_fake_appdir() {
|
|||
}
|
||||
};
|
||||
// register our new provider
|
||||
Services.dirsvc.QueryInterface(Ci.nsIDirectoryService)
|
||||
.registerProvider(_provider);
|
||||
dirSvc.QueryInterface(Ci.nsIDirectoryService)
|
||||
.registerProvider(_provider);
|
||||
// and undefine the old value
|
||||
try {
|
||||
Services.dirsvc.undefine("UAppData");
|
||||
dirSvc.undefine("UAppData");
|
||||
} catch (ex) {} // it's ok if this fails, the value might not be cached yet
|
||||
return appD.clone();
|
||||
}
|
||||
|
||||
function cleanup_fake_appdir() {
|
||||
Services.dirsvc.QueryInterface(Ci.nsIDirectoryService)
|
||||
.unregisterProvider(_provider);
|
||||
let dirSvc = Cc["@mozilla.org/file/directory_service;1"]
|
||||
.getService(Ci.nsIProperties);
|
||||
dirSvc.QueryInterface(Ci.nsIDirectoryService)
|
||||
.unregisterProvider(_provider);
|
||||
// undefine our value so future calls get the real value
|
||||
try {
|
||||
Services.dirsvc.undefine("UAppData");
|
||||
dirSvc.undefine("UAppData");
|
||||
} catch (ex) {
|
||||
dump("cleanup_fake_appdir: dirSvc.undefine failed: " + ex.message + "\n");
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
// enable crash reporting first
|
||||
var cwd = Services.dirsvc.get("CurWorkD", Components.interfaces.nsIFile);
|
||||
var cwd = Components.classes["@mozilla.org/file/directory_service;1"]
|
||||
.getService(Components.interfaces.nsIProperties)
|
||||
.get("CurWorkD", Components.interfaces.nsIFile);
|
||||
|
||||
// get the temp dir
|
||||
var env = Components.classes["@mozilla.org/process/environment;1"].getService(Components.interfaces.nsIEnvironment);
|
||||
|
@ -16,14 +16,17 @@ var crashReporter =
|
|||
crashReporter.UpdateCrashEventsDir();
|
||||
|
||||
// Setting the minidump path is not allowed in content processes
|
||||
var processType = Services.appinfo.processType;
|
||||
var processType = Components.classes["@mozilla.org/xre/runtime;1"].
|
||||
getService(Components.interfaces.nsIXULRuntime).processType;
|
||||
if (processType == Components.interfaces.nsIXULRuntime.PROCESS_TYPE_DEFAULT) {
|
||||
crashReporter.minidumpPath = _tmpd;
|
||||
}
|
||||
|
||||
var protocolHandler = Services.io.getProtocolHandler("resource")
|
||||
.QueryInterface(Components.interfaces.nsIResProtocolHandler);
|
||||
var curDirURI = Services.io.newFileURI(cwd);
|
||||
var ios = Components.classes["@mozilla.org/network/io-service;1"]
|
||||
.getService(Components.interfaces.nsIIOService);
|
||||
var protocolHandler = ios.getProtocolHandler("resource")
|
||||
.QueryInterface(Components.interfaces.nsIResProtocolHandler);
|
||||
var curDirURI = ios.newFileURI(cwd);
|
||||
protocolHandler.setSubstitution("test", curDirURI);
|
||||
Components.utils.import("resource://test/CrashTestUtils.jsm");
|
||||
var crashType = CrashTestUtils.CRASH_INVALID_POINTER_DEREF;
|
||||
|
|
|
@ -3,10 +3,12 @@
|
|||
// Let the event loop process a bit before crashing.
|
||||
if (shouldDelay) {
|
||||
let shouldCrashNow = false;
|
||||
let tm = Components.classes["@mozilla.org/thread-manager;1"]
|
||||
.getService(Components.interfaces.nsIThreadManager);
|
||||
|
||||
Services.tm.dispatchToMainThread({ run: () => { shouldCrashNow = true; } });
|
||||
tm.dispatchToMainThread({ run: () => { shouldCrashNow = true; } });
|
||||
|
||||
Services.tm.spinEventLoopUntil(() => shouldCrashNow);
|
||||
tm.spinEventLoopUntil(() => shouldCrashNow);
|
||||
}
|
||||
|
||||
// now actually crash
|
||||
|
|
|
@ -39,13 +39,15 @@ function getEventDir() {
|
|||
*/
|
||||
function do_crash(setup, callback, canReturnZero) {
|
||||
// get current process filename (xpcshell)
|
||||
let bin = Services.dirsvc.get("XREExeF", Components.interfaces.nsIFile);
|
||||
let ds = Components.classes["@mozilla.org/file/directory_service;1"]
|
||||
.getService(Components.interfaces.nsIProperties);
|
||||
let bin = ds.get("XREExeF", Components.interfaces.nsIFile);
|
||||
if (!bin.exists()) {
|
||||
// weird, can't find xpcshell binary?
|
||||
do_throw("Can't find xpcshell binary!");
|
||||
}
|
||||
// get Gre dir (GreD)
|
||||
let greD = Services.dirsvc.get("GreD", Components.interfaces.nsIFile);
|
||||
let greD = ds.get("GreD", Components.interfaces.nsIFile);
|
||||
let headfile = do_get_file("crasher_subprocess_head.js");
|
||||
let tailfile = do_get_file("crasher_subprocess_tail.js");
|
||||
// run xpcshell -g GreD -f head -e "some setup code" -f tail
|
||||
|
@ -107,7 +109,9 @@ function runMinidumpAnalyzer(dumpFile, additionalArgs) {
|
|||
}
|
||||
|
||||
// find minidump-analyzer executable.
|
||||
let bin = Services.dirsvc.get("XREExeF", Ci.nsIFile);
|
||||
let ds = Cc["@mozilla.org/file/directory_service;1"]
|
||||
.getService(Ci.nsIProperties);
|
||||
let bin = ds.get("XREExeF", Ci.nsIFile);
|
||||
ok(bin && bin.exists());
|
||||
bin = bin.parent;
|
||||
ok(bin && bin.exists());
|
||||
|
|
|
@ -13,7 +13,9 @@ function run_test() {
|
|||
CrashTestUtils.crash(crashType);
|
||||
}
|
||||
|
||||
Services.obs.addObserver(crashWhileReporting, "memory-pressure");
|
||||
var observerService = Components.classes["@mozilla.org/observer-service;1"]
|
||||
.getService(Components.interfaces.nsIObserverService);
|
||||
observerService.addObserver(crashWhileReporting, "memory-pressure");
|
||||
Components.utils.getJSTestingFunctions().reportLargeAllocationFailure();
|
||||
},
|
||||
function(mdump, extra) {
|
||||
|
|
|
@ -23,6 +23,8 @@ function run_test() {
|
|||
.createInstance(Ci.nsIFile);
|
||||
file.initWithPath(profd);
|
||||
|
||||
let dirSvc = Cc["@mozilla.org/file/directory_service;1"]
|
||||
.getService(Ci.nsIProperties);
|
||||
let provider = {
|
||||
getFile(prop, persistent) {
|
||||
persistent.value = true;
|
||||
|
@ -40,8 +42,8 @@ function run_test() {
|
|||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
};
|
||||
Services.dirsvc.QueryInterface(Ci.nsIDirectoryService)
|
||||
.registerProvider(provider);
|
||||
dirSvc.QueryInterface(Ci.nsIDirectoryService)
|
||||
.registerProvider(provider);
|
||||
|
||||
crashReporter.saveMemoryReport();
|
||||
},
|
||||
|
|
|
@ -14,18 +14,20 @@ function run_test() {
|
|||
}
|
||||
|
||||
// check setting/getting serverURL
|
||||
var ios = Components.classes["@mozilla.org/network/io-service;1"]
|
||||
.getService(Components.interfaces.nsIIOService);
|
||||
|
||||
// try it with two different URLs, just for kicks
|
||||
var testspecs = ["http://example.com/submit",
|
||||
"https://example.org/anothersubmit"];
|
||||
for (var i = 0; i < testspecs.length; ++i) {
|
||||
cr.serverURL = Services.io.newURI(testspecs[i]);
|
||||
cr.serverURL = ios.newURI(testspecs[i]);
|
||||
do_check_eq(cr.serverURL.spec, testspecs[i]);
|
||||
}
|
||||
|
||||
// should not allow setting non-http/https URLs
|
||||
try {
|
||||
cr.serverURL = Services.io.newURI("ftp://example.com/submit");
|
||||
cr.serverURL = ios.newURI("ftp://example.com/submit");
|
||||
do_throw("Setting serverURL to a non-http(s) URL should have thrown!");
|
||||
} catch (ex) {
|
||||
do_check_eq(ex.result, Components.results.NS_ERROR_INVALID_ARG);
|
||||
|
|
|
@ -61,10 +61,12 @@ function run_test() {
|
|||
do_crash(function() {
|
||||
// Enable the FHR, official policy bypass (since we're in a test) and
|
||||
// specify a telemetry server & client ID.
|
||||
Services.prefs.setBoolPref("datareporting.policy.dataSubmissionPolicyBypassNotification", true);
|
||||
Services.prefs.setBoolPref("datareporting.healthreport.uploadEnabled", true);
|
||||
Services.prefs.setCharPref("toolkit.telemetry.server", "http://a.telemetry.server");
|
||||
Services.prefs.setCharPref("toolkit.telemetry.cachedClientID",
|
||||
let prefs = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefBranch);
|
||||
prefs.setBoolPref("datareporting.policy.dataSubmissionPolicyBypassNotification", true);
|
||||
prefs.setBoolPref("datareporting.healthreport.uploadEnabled", true);
|
||||
prefs.setCharPref("toolkit.telemetry.server", "http://a.telemetry.server");
|
||||
prefs.setCharPref("toolkit.telemetry.cachedClientID",
|
||||
"f3582dee-22b9-4d73-96d1-79ef5bf2fc24");
|
||||
|
||||
// TelemetrySession setup will trigger the session annotation
|
||||
|
@ -87,8 +89,10 @@ function run_test() {
|
|||
|
||||
do_crash(function() {
|
||||
// Disable the FHR upload, no telemetry annotations should be present.
|
||||
Services.prefs.setBoolPref("datareporting.policy.dataSubmissionPolicyBypassNotification", true);
|
||||
Services.prefs.setBoolPref("datareporting.healthreport.uploadEnabled", false);
|
||||
let prefs = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefBranch);
|
||||
prefs.setBoolPref("datareporting.policy.dataSubmissionPolicyBypassNotification", true);
|
||||
prefs.setBoolPref("datareporting.healthreport.uploadEnabled", false);
|
||||
|
||||
// TelemetrySession setup will trigger the session annotation
|
||||
let scope = {};
|
||||
|
@ -106,8 +110,10 @@ function run_test() {
|
|||
do_crash(function() {
|
||||
// No telemetry annotations should be present if the user has not been
|
||||
// notified yet
|
||||
Services.prefs.setBoolPref("datareporting.policy.dataSubmissionPolicyBypassNotification", false);
|
||||
Services.prefs.setBoolPref("datareporting.healthreport.uploadEnabled", true);
|
||||
let prefs = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefBranch);
|
||||
prefs.setBoolPref("datareporting.policy.dataSubmissionPolicyBypassNotification", false);
|
||||
prefs.setBoolPref("datareporting.healthreport.uploadEnabled", true);
|
||||
|
||||
// TelemetrySession setup will trigger the session annotation
|
||||
let scope = {};
|
||||
|
|
|
@ -49,9 +49,11 @@ this.ForgetAboutSite = {
|
|||
let promises = [];
|
||||
// Cache
|
||||
promises.push((async function() {
|
||||
let cs = Cc["@mozilla.org/netwerk/cache-storage-service;1"].
|
||||
getService(Ci.nsICacheStorageService);
|
||||
// NOTE: there is no way to clear just that domain, so we clear out
|
||||
// everything)
|
||||
Services.cache2.clear();
|
||||
cs.clear();
|
||||
})().catch(ex => {
|
||||
throw new Error("Exception thrown while clearing the cache: " + ex);
|
||||
}));
|
||||
|
@ -68,10 +70,12 @@ this.ForgetAboutSite = {
|
|||
// Cookies
|
||||
// Need to maximize the number of cookies cleaned here
|
||||
promises.push((async function() {
|
||||
let enumerator = Services.cookies.getCookiesWithOriginAttributes(JSON.stringify({}), aDomain);
|
||||
let cm = Cc["@mozilla.org/cookiemanager;1"].
|
||||
getService(Ci.nsICookieManager);
|
||||
let enumerator = cm.getCookiesWithOriginAttributes(JSON.stringify({}), aDomain);
|
||||
while (enumerator.hasMoreElements()) {
|
||||
let cookie = enumerator.getNext().QueryInterface(Ci.nsICookie);
|
||||
Services.cookies.remove(cookie.host, cookie.name, cookie.path, false, cookie.originAttributes);
|
||||
cm.remove(cookie.host, cookie.name, cookie.path, false, cookie.originAttributes);
|
||||
}
|
||||
})().catch(ex => {
|
||||
throw new Error("Exception thrown while clearning cookies: " + ex);
|
||||
|
@ -115,11 +119,13 @@ this.ForgetAboutSite = {
|
|||
|
||||
// Passwords
|
||||
promises.push((async function() {
|
||||
let lm = Cc["@mozilla.org/login-manager;1"].
|
||||
getService(Ci.nsILoginManager);
|
||||
// Clear all passwords for domain
|
||||
let logins = Services.logins.getAllLogins();
|
||||
let logins = lm.getAllLogins();
|
||||
for (let i = 0; i < logins.length; i++)
|
||||
if (hasRootDomain(logins[i].hostname, aDomain))
|
||||
Services.logins.removeLogin(logins[i]);
|
||||
lm.removeLogin(logins[i]);
|
||||
})().catch(ex => {
|
||||
// XXXehsan: is there a better way to do this rather than this
|
||||
// hacky comparison?
|
||||
|
@ -129,14 +135,16 @@ this.ForgetAboutSite = {
|
|||
}));
|
||||
|
||||
// Permissions
|
||||
let pm = Cc["@mozilla.org/permissionmanager;1"].
|
||||
getService(Ci.nsIPermissionManager);
|
||||
// Enumerate all of the permissions, and if one matches, remove it
|
||||
let enumerator = Services.perms.enumerator;
|
||||
let enumerator = pm.enumerator;
|
||||
while (enumerator.hasMoreElements()) {
|
||||
let perm = enumerator.getNext().QueryInterface(Ci.nsIPermission);
|
||||
promises.push(new Promise((resolve, reject) => {
|
||||
try {
|
||||
if (hasRootDomain(perm.principal.URI.host, aDomain)) {
|
||||
Services.perms.removePermission(perm);
|
||||
pm.removePermission(perm);
|
||||
}
|
||||
} catch (ex) {
|
||||
// Ignore entry
|
||||
|
@ -148,6 +156,8 @@ this.ForgetAboutSite = {
|
|||
|
||||
// Offline Storages
|
||||
promises.push((async function() {
|
||||
let qms = Cc["@mozilla.org/dom/quota-manager-service;1"].
|
||||
getService(Ci.nsIQuotaManagerService);
|
||||
// delete data from both HTTP and HTTPS sites
|
||||
let httpURI = NetUtil.newURI("http://" + aDomain);
|
||||
let httpsURI = NetUtil.newURI("https://" + aDomain);
|
||||
|
@ -158,8 +168,8 @@ this.ForgetAboutSite = {
|
|||
.createCodebasePrincipal(httpURI, {});
|
||||
let httpsPrincipal = Services.scriptSecurityManager
|
||||
.createCodebasePrincipal(httpsURI, {});
|
||||
Services.qms.clearStoragesForPrincipal(httpPrincipal, null, true);
|
||||
Services.qms.clearStoragesForPrincipal(httpsPrincipal, null, true);
|
||||
qms.clearStoragesForPrincipal(httpPrincipal, null, true);
|
||||
qms.clearStoragesForPrincipal(httpsPrincipal, null, true);
|
||||
})().catch(ex => {
|
||||
throw new Error("Exception occured while clearing offline storages: " + ex);
|
||||
}));
|
||||
|
|
|
@ -8,8 +8,7 @@ var Cc = Components.classes;
|
|||
var Ci = Components.interfaces;
|
||||
var Cu = Components.utils;
|
||||
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
var dirSvc = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties);
|
||||
var profileDir = do_get_profile();
|
||||
|
||||
/**
|
||||
|
@ -24,7 +23,7 @@ function cleanUp() {
|
|||
];
|
||||
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
let file = Services.dirsvc.get("ProfD", Ci.nsIFile);
|
||||
let file = dirSvc.get("ProfD", Ci.nsIFile);
|
||||
file.append(files[i]);
|
||||
if (file.exists())
|
||||
file.remove(false);
|
||||
|
|
|
@ -35,6 +35,19 @@ const PREFERENCE_NAME = "test-pref";
|
|||
|
||||
// Utility Functions
|
||||
|
||||
/**
|
||||
* Creates an nsIURI object for the given string representation of a URI.
|
||||
*
|
||||
* @param aURIString
|
||||
* The spec of the URI to create.
|
||||
* @returns an nsIURI representing aURIString.
|
||||
*/
|
||||
function uri(aURIString) {
|
||||
return Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService).
|
||||
newURI(aURIString);
|
||||
}
|
||||
|
||||
/**
|
||||
* Asynchronously check a url is visited.
|
||||
*
|
||||
|
@ -61,8 +74,9 @@ function promiseIsURIVisited(aURI) {
|
|||
*/
|
||||
function add_cookie(aDomain) {
|
||||
check_cookie_exists(aDomain, false);
|
||||
Services.cookies.add(aDomain, COOKIE_PATH, COOKIE_NAME, "", false, false, false,
|
||||
COOKIE_EXPIRY, {});
|
||||
let cm = Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager);
|
||||
cm.add(aDomain, COOKIE_PATH, COOKIE_NAME, "", false, false, false,
|
||||
COOKIE_EXPIRY, {});
|
||||
check_cookie_exists(aDomain, true);
|
||||
}
|
||||
|
||||
|
@ -75,13 +89,14 @@ function add_cookie(aDomain) {
|
|||
* True if the cookie should exist, false otherwise.
|
||||
*/
|
||||
function check_cookie_exists(aDomain, aExists) {
|
||||
let cm = Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager);
|
||||
let cookie = {
|
||||
host: aDomain,
|
||||
name: COOKIE_NAME,
|
||||
path: COOKIE_PATH
|
||||
};
|
||||
let checker = aExists ? do_check_true : do_check_false;
|
||||
checker(Services.cookies.cookieExists(cookie));
|
||||
checker(cm.cookieExists(cookie));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -92,7 +107,9 @@ function check_cookie_exists(aDomain, aExists) {
|
|||
*/
|
||||
function add_disabled_host(aHost) {
|
||||
check_disabled_host(aHost, false);
|
||||
Services.logins.setLoginSavingEnabled(aHost, false);
|
||||
let lm = Cc["@mozilla.org/login-manager;1"].
|
||||
getService(Ci.nsILoginManager);
|
||||
lm.setLoginSavingEnabled(aHost, false);
|
||||
check_disabled_host(aHost, true);
|
||||
}
|
||||
|
||||
|
@ -105,8 +122,10 @@ function add_disabled_host(aHost) {
|
|||
* True if the host should be disabled, false otherwise.
|
||||
*/
|
||||
function check_disabled_host(aHost, aIsDisabled) {
|
||||
let lm = Cc["@mozilla.org/login-manager;1"].
|
||||
getService(Ci.nsILoginManager);
|
||||
let checker = aIsDisabled ? do_check_false : do_check_true;
|
||||
checker(Services.logins.getLoginSavingEnabled(aHost));
|
||||
checker(lm.getLoginSavingEnabled(aHost));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -121,7 +140,9 @@ function add_login(aHost) {
|
|||
createInstance(Ci.nsILoginInfo);
|
||||
login.init(aHost, "", null, LOGIN_USERNAME, LOGIN_PASSWORD,
|
||||
LOGIN_USERNAME_FIELD, LOGIN_PASSWORD_FIELD);
|
||||
Services.logins.addLogin(login);
|
||||
let lm = Cc["@mozilla.org/login-manager;1"].
|
||||
getService(Ci.nsILoginManager);
|
||||
lm.addLogin(login);
|
||||
check_login_exists(aHost, true);
|
||||
}
|
||||
|
||||
|
@ -134,8 +155,10 @@ function add_login(aHost) {
|
|||
* True if the login should exist, false otherwise.
|
||||
*/
|
||||
function check_login_exists(aHost, aExists) {
|
||||
let lm = Cc["@mozilla.org/login-manager;1"].
|
||||
getService(Ci.nsILoginManager);
|
||||
let count = { value: 0 };
|
||||
Services.logins.findLogins(count, aHost, "", null);
|
||||
lm.findLogins(count, aHost, "", null);
|
||||
do_check_eq(count.value, aExists ? 1 : 0);
|
||||
}
|
||||
|
||||
|
@ -147,9 +170,13 @@ function check_login_exists(aHost, aExists) {
|
|||
*/
|
||||
function add_permission(aURI) {
|
||||
check_permission_exists(aURI, false);
|
||||
let principal = Services.scriptSecurityManager.createCodebasePrincipal(aURI, {});
|
||||
let pm = Cc["@mozilla.org/permissionmanager;1"].
|
||||
getService(Ci.nsIPermissionManager);
|
||||
let ssm = Cc["@mozilla.org/scriptsecuritymanager;1"]
|
||||
.getService(Ci.nsIScriptSecurityManager);
|
||||
let principal = ssm.createCodebasePrincipal(aURI, {});
|
||||
|
||||
Services.perms.addFromPrincipal(principal, PERMISSION_TYPE, PERMISSION_VALUE);
|
||||
pm.addFromPrincipal(principal, PERMISSION_TYPE, PERMISSION_VALUE);
|
||||
check_permission_exists(aURI, true);
|
||||
}
|
||||
|
||||
|
@ -162,9 +189,13 @@ function add_permission(aURI) {
|
|||
* True if the permission should exist, false otherwise.
|
||||
*/
|
||||
function check_permission_exists(aURI, aExists) {
|
||||
let principal = Services.scriptSecurityManager.createCodebasePrincipal(aURI, {});
|
||||
let pm = Cc["@mozilla.org/permissionmanager;1"].
|
||||
getService(Ci.nsIPermissionManager);
|
||||
let ssm = Cc["@mozilla.org/scriptsecuritymanager;1"]
|
||||
.getService(Ci.nsIScriptSecurityManager);
|
||||
let principal = ssm.createCodebasePrincipal(aURI, {});
|
||||
|
||||
let perm = Services.perms.testExactPermissionFromPrincipal(principal, PERMISSION_TYPE);
|
||||
let perm = pm.testExactPermissionFromPrincipal(principal, PERMISSION_TYPE);
|
||||
let checker = aExists ? do_check_eq : do_check_neq;
|
||||
checker(perm, PERMISSION_VALUE);
|
||||
}
|
||||
|
@ -207,7 +238,7 @@ function preference_exists(aURI) {
|
|||
|
||||
// History
|
||||
async function test_history_cleared_with_direct_match() {
|
||||
const TEST_URI = Services.io.newURI("http://mozilla.org/foo");
|
||||
const TEST_URI = uri("http://mozilla.org/foo");
|
||||
do_check_false(await promiseIsURIVisited(TEST_URI));
|
||||
await PlacesTestUtils.addVisits(TEST_URI);
|
||||
do_check_true(await promiseIsURIVisited(TEST_URI));
|
||||
|
@ -216,7 +247,7 @@ async function test_history_cleared_with_direct_match() {
|
|||
}
|
||||
|
||||
async function test_history_cleared_with_subdomain() {
|
||||
const TEST_URI = Services.io.newURI("http://www.mozilla.org/foo");
|
||||
const TEST_URI = uri("http://www.mozilla.org/foo");
|
||||
do_check_false(await promiseIsURIVisited(TEST_URI));
|
||||
await PlacesTestUtils.addVisits(TEST_URI);
|
||||
do_check_true(await promiseIsURIVisited(TEST_URI));
|
||||
|
@ -225,7 +256,7 @@ async function test_history_cleared_with_subdomain() {
|
|||
}
|
||||
|
||||
async function test_history_not_cleared_with_uri_contains_domain() {
|
||||
const TEST_URI = Services.io.newURI("http://ilovemozilla.org/foo");
|
||||
const TEST_URI = uri("http://ilovemozilla.org/foo");
|
||||
do_check_false(await promiseIsURIVisited(TEST_URI));
|
||||
await PlacesTestUtils.addVisits(TEST_URI);
|
||||
do_check_true(await promiseIsURIVisited(TEST_URI));
|
||||
|
@ -280,7 +311,9 @@ async function test_login_manager_disabled_hosts_not_cleared_with_uri_contains_d
|
|||
check_disabled_host(TEST_HOST, true);
|
||||
|
||||
// Reset state
|
||||
Services.logins.setLoginSavingEnabled(TEST_HOST, true);
|
||||
let lm = Cc["@mozilla.org/login-manager;1"].
|
||||
getService(Ci.nsILoginManager);
|
||||
lm.setLoginSavingEnabled(TEST_HOST, true);
|
||||
check_disabled_host(TEST_HOST, false);
|
||||
}
|
||||
|
||||
|
@ -304,33 +337,37 @@ async function test_login_manager_logins_not_cleared_with_uri_contains_domain()
|
|||
await ForgetAboutSite.removeDataFromDomain("mozilla.org");
|
||||
check_login_exists(TEST_HOST, true);
|
||||
|
||||
Services.logins.removeAllLogins();
|
||||
let lm = Cc["@mozilla.org/login-manager;1"].
|
||||
getService(Ci.nsILoginManager);
|
||||
lm.removeAllLogins();
|
||||
check_login_exists(TEST_HOST, false);
|
||||
}
|
||||
|
||||
// Permission Manager
|
||||
async function test_permission_manager_cleared_with_direct_match() {
|
||||
const TEST_URI = Services.io.newURI("http://mozilla.org");
|
||||
const TEST_URI = uri("http://mozilla.org");
|
||||
add_permission(TEST_URI);
|
||||
await ForgetAboutSite.removeDataFromDomain("mozilla.org");
|
||||
check_permission_exists(TEST_URI, false);
|
||||
}
|
||||
|
||||
async function test_permission_manager_cleared_with_subdomain() {
|
||||
const TEST_URI = Services.io.newURI("http://www.mozilla.org");
|
||||
const TEST_URI = uri("http://www.mozilla.org");
|
||||
add_permission(TEST_URI);
|
||||
await ForgetAboutSite.removeDataFromDomain("mozilla.org");
|
||||
check_permission_exists(TEST_URI, false);
|
||||
}
|
||||
|
||||
async function test_permission_manager_not_cleared_with_uri_contains_domain() {
|
||||
const TEST_URI = Services.io.newURI("http://ilovemozilla.org");
|
||||
const TEST_URI = uri("http://ilovemozilla.org");
|
||||
add_permission(TEST_URI);
|
||||
await ForgetAboutSite.removeDataFromDomain("mozilla.org");
|
||||
check_permission_exists(TEST_URI, true);
|
||||
|
||||
// Reset state
|
||||
Services.perms.removeAll();
|
||||
let pm = Cc["@mozilla.org/permissionmanager;1"].
|
||||
getService(Ci.nsIPermissionManager);
|
||||
pm.removeAll();
|
||||
check_permission_exists(TEST_URI, false);
|
||||
}
|
||||
|
||||
|
@ -355,7 +392,7 @@ function waitForPurgeNotification() {
|
|||
|
||||
// Content Preferences
|
||||
async function test_content_preferences_cleared_with_direct_match() {
|
||||
const TEST_URI = Services.io.newURI("http://mozilla.org");
|
||||
const TEST_URI = uri("http://mozilla.org");
|
||||
do_check_false(await preference_exists(TEST_URI));
|
||||
await add_preference(TEST_URI);
|
||||
do_check_true(await preference_exists(TEST_URI));
|
||||
|
@ -365,7 +402,7 @@ async function test_content_preferences_cleared_with_direct_match() {
|
|||
}
|
||||
|
||||
async function test_content_preferences_cleared_with_subdomain() {
|
||||
const TEST_URI = Services.io.newURI("http://www.mozilla.org");
|
||||
const TEST_URI = uri("http://www.mozilla.org");
|
||||
do_check_false(await preference_exists(TEST_URI));
|
||||
await add_preference(TEST_URI);
|
||||
do_check_true(await preference_exists(TEST_URI));
|
||||
|
@ -375,7 +412,7 @@ async function test_content_preferences_cleared_with_subdomain() {
|
|||
}
|
||||
|
||||
async function test_content_preferences_not_cleared_with_uri_contains_domain() {
|
||||
const TEST_URI = Services.io.newURI("http://ilovemozilla.org");
|
||||
const TEST_URI = uri("http://ilovemozilla.org");
|
||||
do_check_false(await preference_exists(TEST_URI));
|
||||
await add_preference(TEST_URI);
|
||||
do_check_true(await preference_exists(TEST_URI));
|
||||
|
@ -391,7 +428,9 @@ async function test_content_preferences_not_cleared_with_uri_contains_domain() {
|
|||
|
||||
function push_registration_exists(aURL, ps) {
|
||||
return new Promise(resolve => {
|
||||
let principal = Services.scriptSecurityManager.createCodebasePrincipalFromOrigin(aURL);
|
||||
let ssm = Cc["@mozilla.org/scriptsecuritymanager;1"]
|
||||
.getService(Ci.nsIScriptSecurityManager);
|
||||
let principal = ssm.createCodebasePrincipalFromOrigin(aURL);
|
||||
return ps.getSubscription(aURL, principal, (status, record) => {
|
||||
if (!Components.isSuccessCode(status)) {
|
||||
resolve(false);
|
||||
|
@ -470,30 +509,36 @@ async function test_cache_cleared() {
|
|||
// the API is well tested, and that when we get the observer
|
||||
// notification, we have actually cleared the cache.
|
||||
// This seems to happen asynchronously...
|
||||
let os = Cc["@mozilla.org/observer-service;1"].
|
||||
getService(Ci.nsIObserverService);
|
||||
let observer = {
|
||||
observe(aSubject, aTopic, aData) {
|
||||
Services.obs.removeObserver(observer, "cacheservice:empty-cache");
|
||||
os.removeObserver(observer, "cacheservice:empty-cache");
|
||||
// Shutdown the download manager.
|
||||
Services.obs.notifyObservers(null, "quit-application");
|
||||
do_test_finished();
|
||||
}
|
||||
};
|
||||
Services.obs.addObserver(observer, "cacheservice:empty-cache");
|
||||
os.addObserver(observer, "cacheservice:empty-cache");
|
||||
await ForgetAboutSite.removeDataFromDomain("mozilla.org");
|
||||
do_test_pending();
|
||||
}
|
||||
|
||||
async function test_storage_cleared() {
|
||||
function getStorageForURI(aURI) {
|
||||
let principal = Services.scriptSecurityManager.createCodebasePrincipal(aURI, {});
|
||||
let ssm = Cc["@mozilla.org/scriptsecuritymanager;1"]
|
||||
.getService(Ci.nsIScriptSecurityManager);
|
||||
let principal = ssm.createCodebasePrincipal(aURI, {});
|
||||
|
||||
return Services.domStorageManager.createStorage(null, principal, "");
|
||||
let dsm = Cc["@mozilla.org/dom/localStorage-manager;1"].
|
||||
getService(Ci.nsIDOMStorageManager);
|
||||
return dsm.createStorage(null, principal, "");
|
||||
}
|
||||
|
||||
let s = [
|
||||
getStorageForURI(Services.io.newURI("http://mozilla.org")),
|
||||
getStorageForURI(Services.io.newURI("http://my.mozilla.org")),
|
||||
getStorageForURI(Services.io.newURI("http://ilovemozilla.org")),
|
||||
getStorageForURI(uri("http://mozilla.org")),
|
||||
getStorageForURI(uri("http://my.mozilla.org")),
|
||||
getStorageForURI(uri("http://ilovemozilla.org")),
|
||||
];
|
||||
|
||||
for (let i = 0; i < s.length; ++i) {
|
||||
|
|
|
@ -74,6 +74,8 @@ this.BrowserUtils = {
|
|||
* safe mode if it is already in safe mode.
|
||||
*/
|
||||
restartApplication() {
|
||||
let appStartup = Cc["@mozilla.org/toolkit/app-startup;1"]
|
||||
.getService(Ci.nsIAppStartup);
|
||||
let cancelQuit = Cc["@mozilla.org/supports-PRBool;1"]
|
||||
.createInstance(Ci.nsISupportsPRBool);
|
||||
Services.obs.notifyObservers(cancelQuit, "quit-application-requested", "restart");
|
||||
|
@ -82,10 +84,10 @@ this.BrowserUtils = {
|
|||
}
|
||||
// if already in safe mode restart in safe mode
|
||||
if (Services.appinfo.inSafeMode) {
|
||||
Services.startup.restartInSafeMode(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart);
|
||||
appStartup.restartInSafeMode(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart);
|
||||
return undefined;
|
||||
}
|
||||
Services.startup.quit(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart);
|
||||
appStartup.quit(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart);
|
||||
return undefined;
|
||||
},
|
||||
|
||||
|
@ -548,8 +550,10 @@ this.BrowserUtils = {
|
|||
}
|
||||
|
||||
if (delimitedAtStart && delimitedAtEnd) {
|
||||
let uriFixup = Cc["@mozilla.org/docshell/urifixup;1"]
|
||||
.getService(Ci.nsIURIFixup);
|
||||
try {
|
||||
url = Services.uriFixup.createFixupURI(linkText, Services.uriFixup.FIXUP_FLAG_NONE);
|
||||
url = uriFixup.createFixupURI(linkText, uriFixup.FIXUP_FLAG_NONE);
|
||||
} catch (ex) {}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -312,14 +312,15 @@ Finder.prototype = {
|
|||
}
|
||||
|
||||
let fastFind = this._fastFind;
|
||||
const fm = Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager);
|
||||
try {
|
||||
// Try to find the best possible match that should receive focus and
|
||||
// block scrolling on focus since find already scrolls. Further
|
||||
// scrolling is due to user action, so don't override this.
|
||||
if (fastFind.foundLink) {
|
||||
Services.focus.setFocus(fastFind.foundLink, Services.focus.FLAG_NOSCROLL);
|
||||
fm.setFocus(fastFind.foundLink, fm.FLAG_NOSCROLL);
|
||||
} else if (fastFind.foundEditable) {
|
||||
Services.focus.setFocus(fastFind.foundEditable, Services.focus.FLAG_NOSCROLL);
|
||||
fm.setFocus(fastFind.foundEditable, fm.FLAG_NOSCROLL);
|
||||
fastFind.collapseSelection();
|
||||
} else {
|
||||
this._getWindow().focus();
|
||||
|
|
|
@ -12,8 +12,6 @@ const Cc = Components.classes;
|
|||
const Ci = Components.interfaces;
|
||||
const Cu = Components.utils;
|
||||
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
this.InlineSpellChecker = function InlineSpellChecker(aEditor) {
|
||||
this.init(aEditor);
|
||||
this.mAddedWordStack = []; // We init this here to preserve it between init/uninit calls
|
||||
|
@ -260,9 +258,11 @@ InlineSpellChecker.prototype = {
|
|||
|
||||
if (!gLanguageBundle) {
|
||||
// Create the bundles for language and region names.
|
||||
gLanguageBundle = Services.strings.createBundle(
|
||||
var bundleService = Components.classes["@mozilla.org/intl/stringbundle;1"]
|
||||
.getService(Components.interfaces.nsIStringBundleService);
|
||||
gLanguageBundle = bundleService.createBundle(
|
||||
"chrome://global/locale/languageNames.properties");
|
||||
gRegionBundle = Services.strings.createBundle(
|
||||
gRegionBundle = bundleService.createBundle(
|
||||
"chrome://global/locale/regionNames.properties");
|
||||
}
|
||||
|
||||
|
|
|
@ -20,8 +20,6 @@ XPCOMUtils.defineLazyModuleGetter(this, "OS",
|
|||
"resource://gre/modules/osfile.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "Task",
|
||||
"resource://gre/modules/Task.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "Services",
|
||||
"resource://gre/modules/Services.jsm");
|
||||
const INTERNAL_FIELDS = new Set(["_level", "_message", "_time", "_namespace"]);
|
||||
|
||||
|
||||
|
@ -759,7 +757,8 @@ ConsoleAppender.prototype = {
|
|||
},
|
||||
|
||||
doAppend: function CApp_doAppend(formatted) {
|
||||
Services.console.logStringMessage(formatted);
|
||||
Cc["@mozilla.org/consoleservice;1"].
|
||||
getService(Ci.nsIConsoleService).logStringMessage(formatted);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -481,7 +481,8 @@ PopupNotifications.prototype = {
|
|||
notifications.push(notification);
|
||||
|
||||
let isActiveBrowser = this._isActiveBrowser(browser);
|
||||
let isActiveWindow = Services.focus.activeWindow == this.window;
|
||||
let fm = Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager);
|
||||
let isActiveWindow = fm.activeWindow == this.window;
|
||||
|
||||
if (isActiveBrowser) {
|
||||
if (isActiveWindow) {
|
||||
|
|
|
@ -10,13 +10,17 @@ const Cc = Components.classes;
|
|||
const Cu = Components.utils;
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
function newURI(spec) {
|
||||
return Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService)
|
||||
.newURI(spec);
|
||||
}
|
||||
|
||||
function RemoteWebProgressRequest(spec, originalSpec, requestCPOW) {
|
||||
this.wrappedJSObject = this;
|
||||
|
||||
this._uri = Services.io.newURI(spec);
|
||||
this._originalURI = Services.io.newURI(originalSpec);
|
||||
this._uri = newURI(spec);
|
||||
this._originalURI = newURI(originalSpec);
|
||||
this._requestCPOW = requestCPOW;
|
||||
}
|
||||
|
||||
|
@ -235,7 +239,7 @@ RemoteWebProgressManager.prototype = {
|
|||
switch (aMessage.name) {
|
||||
case "Content:StateChange":
|
||||
if (isTopLevel) {
|
||||
this._browser._documentURI = Services.io.newURI(json.documentURI);
|
||||
this._browser._documentURI = newURI(json.documentURI);
|
||||
}
|
||||
this._callProgressListeners(
|
||||
Ci.nsIWebProgress.NOTIFY_STATE_ALL, "onStateChange", webProgress,
|
||||
|
@ -244,7 +248,7 @@ RemoteWebProgressManager.prototype = {
|
|||
break;
|
||||
|
||||
case "Content:LocationChange":
|
||||
let location = Services.io.newURI(json.location);
|
||||
let location = newURI(json.location);
|
||||
let flags = json.flags;
|
||||
let remoteWebNav = this._browser._remoteWebNavigationImpl;
|
||||
|
||||
|
@ -254,7 +258,7 @@ RemoteWebProgressManager.prototype = {
|
|||
|
||||
if (isTopLevel) {
|
||||
remoteWebNav._currentURI = location;
|
||||
this._browser._documentURI = Services.io.newURI(json.documentURI);
|
||||
this._browser._documentURI = newURI(json.documentURI);
|
||||
this._browser._contentTitle = json.title;
|
||||
this._browser._imageDocument = null;
|
||||
this._browser._contentPrincipal = json.principal;
|
||||
|
|
|
@ -59,6 +59,7 @@ this.ResetProfile = {
|
|||
.getService(Ci.nsIEnvironment);
|
||||
env.set("MOZ_RESET_PROFILE_RESTART", "1");
|
||||
|
||||
Services.startup.quit(Ci.nsIAppStartup.eForceQuit | Ci.nsIAppStartup.eRestart);
|
||||
let appStartup = Cc["@mozilla.org/toolkit/app-startup;1"].getService(Ci.nsIAppStartup);
|
||||
appStartup.quit(Ci.nsIAppStartup.eForceQuit | Ci.nsIAppStartup.eRestart);
|
||||
},
|
||||
};
|
||||
|
|
|
@ -170,9 +170,13 @@ this.Troubleshoot = {
|
|||
var dataProviders = {
|
||||
|
||||
application: function application(done) {
|
||||
|
||||
let sysInfo = Cc["@mozilla.org/system-info;1"].
|
||||
getService(Ci.nsIPropertyBag2);
|
||||
|
||||
let data = {
|
||||
name: Services.appinfo.name,
|
||||
osVersion: Services.sysinfo.getProperty("name") + " " + Services.sysinfo.getProperty("version"),
|
||||
osVersion: sysInfo.getProperty("name") + " " + sysInfo.getProperty("version"),
|
||||
version: AppConstants.MOZ_APP_VERSION_DISPLAY,
|
||||
buildID: Services.appinfo.appBuildID,
|
||||
userAgent: Cc["@mozilla.org/network/protocol;1?name=http"].
|
||||
|
@ -188,8 +192,10 @@ var dataProviders = {
|
|||
try {
|
||||
data.vendor = Services.prefs.getCharPref("app.support.vendor");
|
||||
} catch (e) {}
|
||||
let urlFormatter = Cc["@mozilla.org/toolkit/URLFormatterService;1"].
|
||||
getService(Ci.nsIURLFormatter);
|
||||
try {
|
||||
data.supportURL = Services.urlFormatter.formatURLPref("app.support.baseURL");
|
||||
data.supportURL = urlFormatter.formatURLPref("app.support.baseURL");
|
||||
} catch (e) {}
|
||||
|
||||
data.numTotalWindows = 0;
|
||||
|
@ -686,9 +692,11 @@ if (AppConstants.MOZ_SANDBOX) {
|
|||
"hasPrivilegedUserNamespaces", "hasUserNamespaces",
|
||||
"canSandboxContent", "canSandboxMedia"];
|
||||
|
||||
let sysInfo = Cc["@mozilla.org/system-info;1"].
|
||||
getService(Ci.nsIPropertyBag2);
|
||||
for (let key of keys) {
|
||||
if (Services.sysinfo.hasKey(key)) {
|
||||
data[key] = Services.sysinfo.getPropertyAsBool(key);
|
||||
if (sysInfo.hasKey(key)) {
|
||||
data[key] = sysInfo.getPropertyAsBool(key);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,12 +10,6 @@
|
|||
|
||||
this.EXPORTED_SYMBOLS = ["NS_ASSERT"];
|
||||
|
||||
var Cu = Components.utils;
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "Services",
|
||||
"resource://gre/modules/Services.jsm");
|
||||
|
||||
var gTraceOnAssert = false;
|
||||
|
||||
/**
|
||||
|
@ -40,7 +34,9 @@ this.NS_ASSERT = function NS_ASSERT(condition, message) {
|
|||
return;
|
||||
|
||||
var releaseBuild = true;
|
||||
var defB = Services.prefs.getDefaultBranch(null);
|
||||
var defB = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefService)
|
||||
.getDefaultBranch(null);
|
||||
try {
|
||||
switch (defB.getCharPref("app.update.channel")) {
|
||||
case "nightly":
|
||||
|
|
|
@ -114,7 +114,10 @@ add_test(function test_set_unsupported_pref() {
|
|||
|
||||
// Make sure that we can get a string pref that we didn't set ourselves.
|
||||
add_test(function test_get_string_pref() {
|
||||
Services.prefs.setCharPref("test_get_string_pref", "a normal string");
|
||||
let svc = Cc["@mozilla.org/preferences-service;1"].
|
||||
getService(Ci.nsIPrefService).
|
||||
getBranch("");
|
||||
svc.setCharPref("test_get_string_pref", "a normal string");
|
||||
do_check_eq(Preferences.get("test_get_string_pref"), "a normal string");
|
||||
|
||||
// Clean up.
|
||||
|
@ -124,11 +127,14 @@ add_test(function test_get_string_pref() {
|
|||
});
|
||||
|
||||
add_test(function test_get_localized_string_pref() {
|
||||
let svc = Cc["@mozilla.org/preferences-service;1"].
|
||||
getService(Ci.nsIPrefService).
|
||||
getBranch("");
|
||||
let prefName = "test_get_localized_string_pref";
|
||||
let localizedString = Cc["@mozilla.org/pref-localizedstring;1"]
|
||||
.createInstance(Ci.nsIPrefLocalizedString);
|
||||
localizedString.data = "a localized string";
|
||||
Services.prefs.setComplexValue(prefName, Ci.nsIPrefLocalizedString, localizedString);
|
||||
svc.setComplexValue(prefName, Ci.nsIPrefLocalizedString, localizedString);
|
||||
do_check_eq(Preferences.get(prefName, null, Ci.nsIPrefLocalizedString),
|
||||
"a localized string");
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@ const C = Components.classes;
|
|||
const I = Components.interfaces;
|
||||
|
||||
Components.utils.import("resource://gre/modules/AppConstants.jsm");
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
const ToolkitProfileService = "@mozilla.org/toolkit/profile-service;1";
|
||||
|
||||
|
@ -27,7 +26,8 @@ function initWizard() {
|
|||
gProfileService = C[ToolkitProfileService].getService(I.nsIToolkitProfileService);
|
||||
gProfileManagerBundle = document.getElementById("bundle_profileManager");
|
||||
|
||||
gDefaultProfileParent = Services.dirsvc.get("DefProfRt", I.nsIFile);
|
||||
var dirService = C["@mozilla.org/file/directory_service;1"].getService(I.nsIProperties);
|
||||
gDefaultProfileParent = dirService.get("DefProfRt", I.nsIFile);
|
||||
|
||||
// Initialize the profile location display.
|
||||
gProfileDisplay = document.getElementById("profileDisplay").firstChild;
|
||||
|
@ -183,8 +183,10 @@ function onFinish() {
|
|||
gProfileManagerBundle.getString("profileCreationFailed");
|
||||
var profileCreationFailedTitle =
|
||||
gProfileManagerBundle.getString("profileCreationFailedTitle");
|
||||
Services.prompt.alert(window, profileCreationFailedTitle,
|
||||
profileCreationFailed + "\n" + e);
|
||||
var promptService = C["@mozilla.org/embedcomp/prompt-service;1"].
|
||||
getService(I.nsIPromptService);
|
||||
promptService.alert(window, profileCreationFailedTitle,
|
||||
profileCreationFailed + "\n" + e);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -4,9 +4,13 @@
|
|||
// Tests that the dll blocklist initializes correctly during test runs.
|
||||
add_task(async function test() {
|
||||
await BrowserTestUtils.withNewTab({gBrowser, url: "about:blank" }, function(browser) {
|
||||
ok(Services.appinfo.windowsDLLBlocklistStatus,
|
||||
ok(Components.classes["@mozilla.org/xre/app-info;1"]
|
||||
.getService(Ci.nsIXULRuntime)
|
||||
.windowsDLLBlocklistStatus,
|
||||
"Windows dll blocklist status should be true, indicating it is " +
|
||||
"running properly. A failure in this test is considered a " +
|
||||
"release blocker.");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче