зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1400805 - added WebExtension API to get/set browser.display.use_document_fonts r=ntim,zombie
MozReview-Commit-ID: 9JaJN1yTxMy --HG-- extra : rebase_source : 097cbef283a62ab3fc69bdb62a06c0f1feae5dbc
This commit is contained in:
Родитель
30281ed197
Коммит
007caf3a34
|
@ -239,6 +239,16 @@ ExtensionPreferencesManager.addSetting("overrideDocumentColors", {
|
|||
},
|
||||
});
|
||||
|
||||
ExtensionPreferencesManager.addSetting("useDocumentFonts", {
|
||||
prefNames: [
|
||||
"browser.display.use_document_fonts",
|
||||
],
|
||||
|
||||
setCallback(value) {
|
||||
return {[this.prefNames[0]]: value};
|
||||
},
|
||||
});
|
||||
|
||||
this.browserSettings = class extends ExtensionAPI {
|
||||
getAPI(context) {
|
||||
let {extension} = context;
|
||||
|
@ -448,6 +458,24 @@ this.browserSettings = class extends ExtensionAPI {
|
|||
},
|
||||
}
|
||||
),
|
||||
useDocumentFonts: Object.assign(
|
||||
getSettingsAPI(
|
||||
extension, "useDocumentFonts",
|
||||
() => {
|
||||
return Services.prefs.getIntPref("browser.display.use_document_fonts") !== 0;
|
||||
}
|
||||
),
|
||||
{
|
||||
set: details => {
|
||||
if (typeof details.value !== "boolean") {
|
||||
throw new ExtensionError(
|
||||
`${details.value} is not a valid value for useDocumentFonts.`);
|
||||
}
|
||||
return ExtensionPreferencesManager.setSetting(
|
||||
extension.id, "useDocumentFonts", Number(details.value));
|
||||
},
|
||||
}
|
||||
),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
|
|
@ -160,6 +160,10 @@
|
|||
"overrideDocumentColors": {
|
||||
"$ref": "types.Setting",
|
||||
"description": "This setting controls whether the user-chosen colors override the page's colors."
|
||||
},
|
||||
"useDocumentFonts": {
|
||||
"$ref": "types.Setting",
|
||||
"description": "This setting controls whether the document's fonts are used."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,6 +51,7 @@ add_task(async function test_browser_settings() {
|
|||
"browser.tabs.insertRelatedAfterCurrent": true,
|
||||
"browser.tabs.insertAfterCurrent": false,
|
||||
"browser.display.document_color_use": 1,
|
||||
"browser.display.use_document_fonts": 1,
|
||||
};
|
||||
|
||||
async function background() {
|
||||
|
@ -220,6 +221,13 @@ add_task(async function test_browser_settings() {
|
|||
"overrideDocumentColors", "always",
|
||||
{"browser.display.document_color_use": 2});
|
||||
|
||||
await testSetting(
|
||||
"useDocumentFonts", false,
|
||||
{"browser.display.use_document_fonts": 0});
|
||||
await testSetting(
|
||||
"useDocumentFonts", true,
|
||||
{"browser.display.use_document_fonts": 1});
|
||||
|
||||
async function testProxy(config, expectedPrefs) {
|
||||
// proxyConfig is not supported on Android.
|
||||
if (AppConstants.platform === "android") {
|
||||
|
|
Загрузка…
Ссылка в новой задаче