Bug 1435142 - Part 3: expose closeTabByDblclick to WebExtension. r=mixedpuppy

MozReview-Commit-ID: GVgDdNFP0qL

--HG--
extra : rebase_source : 79f2920ce087c3c6643e1ca42d3315aa12091205
This commit is contained in:
Hector Zhao 2018-03-06 17:11:49 +08:00
Родитель 1c68e4334c
Коммит 1d22807852
3 изменённых файлов: 65 добавлений и 0 удалений

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

@ -105,6 +105,16 @@ ExtensionPreferencesManager.addSetting("cacheEnabled", {
},
});
ExtensionPreferencesManager.addSetting("closeTabsByDoubleClick", {
prefNames: [
"browser.tabs.closeTabByDblclick",
],
setCallback(value) {
return {[this.prefNames[0]]: value};
},
});
ExtensionPreferencesManager.addSetting("contextMenuShowEvent", {
prefNames: [
"ui.context_menus.after_mouseup",
@ -221,6 +231,11 @@ this.browserSettings = class extends ExtensionAPI {
return Services.prefs.getBoolPref("browser.cache.disk.enable") &&
Services.prefs.getBoolPref("browser.cache.memory.enable");
}),
closeTabsByDoubleClick: getSettingsAPI(
extension, "closeTabsByDoubleClick",
() => {
return Services.prefs.getBoolPref("browser.tabs.closeTabByDblclick");
}, undefined, false, ["android"]),
contextMenuShowEvent: Object.assign(
getSettingsAPI(
extension, "contextMenuShowEvent",

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

@ -117,6 +117,10 @@
"$ref": "types.Setting",
"description": "Enables or disables the browser cache."
},
"closeTabsByDoubleClick": {
"$ref": "types.Setting",
"description": "This boolean setting controls whether the selected tab can be closed with a double click."
},
"contextMenuShowEvent": {
"$ref": "types.Setting",
"description": "Controls after which mouse event context menus popup. This setting's value is of type ContextMenuMouseEvent, which has possible values of <code>mouseup</code> and <code>mousedown</code>."

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

@ -30,6 +30,7 @@ add_task(async function test_browser_settings() {
"image.animation_mode": "none",
"permissions.default.desktop-notification": PERM_UNKNOWN_ACTION,
"ui.context_menus.after_mouseup": false,
"browser.tabs.closeTabByDblclick": false,
"browser.tabs.loadBookmarksInTabs": false,
"browser.search.openintab": false,
"network.proxy.type": proxySvc.PROXYCONFIG_SYSTEM,
@ -164,6 +165,15 @@ add_task(async function test_browser_settings() {
{"ui.context_menus.after_mouseup": false});
}
if (AppConstants.platform !== "android") {
await testSetting(
"closeTabsByDoubleClick", true,
{"browser.tabs.closeTabByDblclick": true});
await testSetting(
"closeTabsByDoubleClick", false,
{"browser.tabs.closeTabByDblclick": false});
}
await testSetting(
"openBookmarksInNewTabs", true,
{"browser.tabs.loadBookmarksInTabs": true});
@ -351,6 +361,42 @@ add_task(async function test_bad_value() {
await extension.unload();
});
add_task(async function test_bad_value_android() {
if (AppConstants.platform !== "android") {
return;
}
async function background() {
await browser.test.assertRejects(
browser.browserSettings.closeTabsByDoubleClick.set({value: true}),
/android is not a supported platform for the closeTabsByDoubleClick setting/,
"closeTabsByDoubleClick.set rejects on Android.");
await browser.test.assertRejects(
browser.browserSettings.closeTabsByDoubleClick.get({}),
/android is not a supported platform for the closeTabsByDoubleClick setting/,
"closeTabsByDoubleClick.get rejects on Android.");
await browser.test.assertRejects(
browser.browserSettings.closeTabsByDoubleClick.clear({}),
/android is not a supported platform for the closeTabsByDoubleClick setting/,
"closeTabsByDoubleClick.clear rejects on Android.");
browser.test.sendMessage("done");
}
let extension = ExtensionTestUtils.loadExtension({
background,
manifest: {
permissions: ["browserSettings"],
},
});
await extension.startup();
await extension.awaitMessage("done");
await extension.unload();
});
add_task(async function test_bad_value_proxy_config() {
let background = AppConstants.platform === "android" ?
async () => {