Bug 1404568 - Improve webext browser_action icon fallbacks. r=mixedpuppy

Currently if there is no default icon at the specified size, the default icon
falls back to the light text icon at that size. This is wrong in two ways:
First, the default theme uses dark text, so it should fallback to the dark icon
Secondly, authors expect the unsized default_icon to be used if specified

This patch fixes both of these issues, so that the default icon first falls back
to the unsized default_icon, and then only if that is not specified falls back
to the dark icon

MozReview-Commit-ID: C3RRTKhYq6r

--HG--
extra : rebase_source : dc10f5c65c763412edbe467bb75aeb4fbcd32ffc
This commit is contained in:
Ian Moody 2017-10-08 13:23:33 +01:00
Родитель 781ed3870b
Коммит 53b9116eab
2 изменённых файлов: 4 добавлений и 4 удалений

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

@ -46,7 +46,7 @@ async function testStaticTheme(options) {
await extension.startup();
// Confirm that the browser action has the correct default icon before a theme is loaded.
let expectedDefaultIcon = withDefaultIcon ? "default.png" : "light.png";
let expectedDefaultIcon = withDefaultIcon ? "default.png" : "dark.png";
await testBrowserAction(extension, expectedDefaultIcon);
let theme = ExtensionTestUtils.loadExtension({
@ -164,7 +164,7 @@ add_task(async function browseraction_theme_icons_dynamic_theme() {
"theme_icons": [{
"light": "light.png",
"dark": "dark.png",
"size": 19,
"size": 16,
}],
},
},

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

@ -1310,9 +1310,9 @@ let IconDetails = {
this._checkURL(lightURL, extension);
this._checkURL(darkURL, extension);
let defaultURL = result[size];
let defaultURL = result[size] || result[19]; // always fallback to default first
result[size] = {
"default": defaultURL || lightURL, // Fallback to the light url if no default is specified.
"default": defaultURL || darkURL, // Fallback to the dark url if no default is specified.
"light": lightURL,
"dark": darkURL,
};