зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1190586 - UITour should expose if default browser can be set w/o UI on Win8+. r=dolske
This commit is contained in:
Родитель
960774d138
Коммит
a5322fb222
|
@ -8,6 +8,7 @@ this.EXPORTED_SYMBOLS = ["UITour", "UITourMetricsProvider"];
|
|||
|
||||
const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
|
||||
|
||||
Cu.import("resource://gre/modules/AppConstants.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Promise.jsm");
|
||||
|
@ -1805,6 +1806,27 @@ this.UITour = {
|
|||
}
|
||||
} catch (e) {}
|
||||
appinfo["defaultBrowser"] = isDefaultBrowser;
|
||||
|
||||
let canSetDefaultBrowserInBackground = true;
|
||||
if (AppConstants.isPlatformAndVersionAtLeast("win", "6.2")) {
|
||||
let prefBranch =
|
||||
Services.prefs.getBranch("browser.shell.associationHash");
|
||||
let prefChildren = prefBranch.getChildList("");
|
||||
canSetDefaultBrowserInBackground = prefChildren.length > 0;
|
||||
} else if (AppConstants.isPlatformAndVersionAtLeast("macosx", "10.10")) {
|
||||
canSetDefaultBrowserInBackground = false;
|
||||
} else if (AppConstants.platform == "linux") {
|
||||
// The ShellService may not exist on some versions of Linux.
|
||||
try {
|
||||
let shell = aWindow.getShellService();
|
||||
} catch (e) {
|
||||
canSetDefaultBrowserInBackground = null;
|
||||
}
|
||||
}
|
||||
|
||||
appinfo["canSetDefaultBrowserInBackground"] =
|
||||
canSetDefaultBrowserInBackground;
|
||||
|
||||
this.sendPageCallback(aMessageManager, aCallbackID, appinfo);
|
||||
break;
|
||||
case "availableTargets":
|
||||
|
|
|
@ -61,7 +61,34 @@ let tests = [
|
|||
.getService(Components.interfaces.nsIShellService);
|
||||
let isDefault = shell.isDefaultBrowser(false);
|
||||
gContentAPI.getConfiguration("appinfo", (data) => {
|
||||
is(data.value, data.defaultBrowser, "gContentAPI result should match shellService.isDefaultBrowser");
|
||||
is(isDefault, data.defaultBrowser, "gContentAPI result should match shellService.isDefaultBrowser");
|
||||
done();
|
||||
});
|
||||
}),
|
||||
|
||||
taskify(function* test_setInBackgroundWhenPrefExists(done) {
|
||||
Services.prefs.setCharPref("browser.shell.associationHash.http", "ABCDEFG");
|
||||
gContentAPI.getConfiguration("appinfo", (data) => {
|
||||
let canSetInBackground = true;
|
||||
is(canSetInBackground, data.canSetDefaultBrowserInBackground,
|
||||
"canSetDefaultBrowserInBackground should be true when a hash is present");
|
||||
Services.prefs.clearUserPref("browser.shell.associationHash.http");
|
||||
done();
|
||||
});
|
||||
}),
|
||||
|
||||
taskify(function* test_setInBackgroundWhenPrefDoesntExist(done) {
|
||||
/* The association hashes are only supported on Windows. */
|
||||
Cu.import("resource://gre/modules/AppConstants.jsm");
|
||||
if (AppConstants.platform != "win") {
|
||||
info("Skipping test_setInBackgroundWhenPrefDoesntExist on non-Windows platform");
|
||||
return;
|
||||
}
|
||||
|
||||
gContentAPI.getConfiguration("appinfo", (data) => {
|
||||
let canSetInBackground = false;
|
||||
is(canSetInBackground, data.canSetDefaultBrowserInBackground,
|
||||
"canSetDefaultBrowserInBackground should be false when no hashes are present");
|
||||
done();
|
||||
});
|
||||
})
|
||||
|
|
Загрузка…
Ссылка в новой задаче