Bug 1404724 - remove browser_style warning, fix default values, r?aswan
MozReview-Commit-ID: Akdhrm4leIQ
--- a/browser/components/extensions/parent/ext-browserAction.js
+++ b/browser/components/extensions/parent/ext-browserAction.js
@@ -73,21 +73,17 @@ this.browserAction = class extends Exten
title: options.default_title || extension.name,
badgeText: "",
badgeBackgroundColor: null,
popup: options.default_popup || "",
area: browserAreas[options.default_area || "navbar"],
};
this.globals = Object.create(this.defaults);
- this.browserStyle = options.browser_style || false;
- if (options.browser_style === null) {
- this.extension.logger.warn("Please specify whether you want browser_style " +
- "or not in your browser_action options.");
- }
+ this.browserStyle = options.browser_style;
browserActionMap.set(extension, this);
this.defaults.icon = await StartupCache.get(
extension, ["browserAction", "default_icon"],
() => IconDetails.normalize({
path: options.default_icon,
iconType: "browserAction",
--- a/browser/components/extensions/parent/ext-pageAction.js
+++ b/browser/components/extensions/parent/ext-pageAction.js
@@ -65,21 +65,17 @@ this.pageAction = class extends Extensio
this.defaults = {
show,
showMatches,
hideMatches,
title: options.default_title || extension.name,
popup: options.default_popup || "",
};
- this.browserStyle = options.browser_style || false;
- if (options.browser_style === null) {
- this.extension.logger.warn("Please specify whether you want browser_style " +
- "or not in your page_action options.");
- }
+ this.browserStyle = options.browser_style;
this.tabContext = new TabContext(tab => this.defaults);
this.tabContext.on("location-change", this.handleLocationChange.bind(this)); // eslint-disable-line mozilla/balanced-listeners
pageActionMap.set(extension, this);
this.defaults.icon = await StartupCache.get(
--- a/browser/components/extensions/parent/ext-sidebarAction.js
+++ b/browser/components/extensions/parent/ext-sidebarAction.js
@@ -37,19 +37,17 @@ this.sidebarAction = class extends Exten
// Add the extension to the sidebar menu. The sidebar widget will copy
// from that when it is viewed, so we shouldn't need to update that.
let widgetId = makeWidgetId(extension.id);
this.id = `${widgetId}-sidebar-action`;
this.menuId = `menu_${this.id}`;
this.buttonId = `button_${this.id}`;
- // We default browser_style to true because this is a new API and
- // we therefore don't need to worry about breaking existing add-ons.
- this.browserStyle = options.browser_style || options.browser_style === null;
+ this.browserStyle = options.browser_style;
this.defaults = {
enabled: true,
title: options.default_title || extension.name,
icon: IconDetails.normalize({path: options.default_icon}, extension),
panel: options.default_panel || "",
};
this.globals = Object.create(this.defaults);
--- a/browser/components/extensions/schemas/browser_action.json
+++ b/browser/components/extensions/schemas/browser_action.json
@@ -32,17 +32,18 @@
"default_popup": {
"type": "string",
"format": "relativeUrl",
"optional": true,
"preprocess": "localize"
},
"browser_style": {
"type": "boolean",
- "optional": true
+ "optional": true,
+ "default": false
},
"default_area": {
"description": "Defines the location the browserAction will appear by default. The default location is navbar.",
"type": "string",
"enum": ["navbar", "menupanel", "tabstrip", "personaltoolbar"],
"optional": true
}
},
--- a/browser/components/extensions/schemas/page_action.json
+++ b/browser/components/extensions/schemas/page_action.json
@@ -25,17 +25,18 @@
"default_popup": {
"type": "string",
"format": "relativeUrl",
"optional": true,
"preprocess": "localize"
},
"browser_style": {
"type": "boolean",
- "optional": true
+ "optional": true,
+ "default": false
},
"show_matches": {
"type": "array",
"optional": true,
"minItems": 1,
"items": { "$ref": "MatchPattern" }
},
"hide_matches": {
--- a/browser/components/extensions/schemas/sidebar_action.json
+++ b/browser/components/extensions/schemas/sidebar_action.json
@@ -19,17 +19,18 @@
"preprocess": "localize"
},
"default_icon": {
"$ref": "IconPath",
"optional": true
},
"browser_style": {
"type": "boolean",
- "optional": true
+ "optional": true,
+ "default": false
},
"default_panel": {
"type": "string",
"format": "strictRelativeUrl",
"preprocess": "localize"
},
"open_at_install": {
"type": "boolean",
--- a/browser/components/extensions/test/browser/browser_ext_optionsPage_browser_style.js
+++ b/browser/components/extensions/test/browser/browser_ext_optionsPage_browser_style.js
@@ -6,17 +6,17 @@ requestLongerTimeout(2);
async function testOptionsBrowserStyle(optionsUI, assertMessage) {
function optionsScript() {
browser.test.onMessage.addListener((msgName, optionsUI, assertMessage) => {
if (msgName !== "check-style") {
browser.test.notifyFail("options-ui-browser_style");
}
- let browserStyle = !("browser_style" in optionsUI) || optionsUI.browser_style;
+ let browserStyle = optionsUI.browser_style;
function verifyButton(buttonElement, expected) {
let buttonStyle = window.getComputedStyle(buttonElement);
let buttonBackgroundColor = buttonStyle.backgroundColor;
if (browserStyle && expected.hasBrowserStyleClass) {
browser.test.assertEq("rgb(9, 150, 248)", buttonBackgroundColor, assertMessage);
} else {
browser.test.assertTrue(buttonBackgroundColor !== "rgb(9, 150, 248)", assertMessage);
--- a/browser/components/extensions/test/browser/browser_ext_sidebarAction_browser_style.js
+++ b/browser/components/extensions/test/browser/browser_ext_sidebarAction_browser_style.js
@@ -1,23 +1,23 @@
/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim: set sts=2 sw=2 et tw=80: */
"use strict";
async function testSidebarBrowserStyle(sidebarAction, assertMessage) {
function sidebarScript() {
browser.test.onMessage.addListener((msgName, info, assertMessage) => {
if (msgName !== "check-style") {
- browser.test.notifyFail("options-ui-browser_style");
+ browser.test.notifyFail("sidebar-browser-style");
}
let style = window.getComputedStyle(document.getElementById("button"));
let buttonBackgroundColor = style.backgroundColor;
let browserStyleBackgroundColor = "rgb(9, 150, 248)";
- if (!("browser_style" in info) || info.browser_style) {
+ if (info.browser_style) {
browser.test.assertEq(browserStyleBackgroundColor, buttonBackgroundColor, assertMessage);
} else {
browser.test.assertTrue(browserStyleBackgroundColor !== buttonBackgroundColor, assertMessage);
}
browser.test.notifyPass("sidebar-browser-style");
});
browser.test.sendMessage("sidebar-ready");
--- a/toolkit/mozapps/extensions/internal/XPIInstall.jsm
+++ b/toolkit/mozapps/extensions/internal/XPIInstall.jsm
@@ -455,37 +455,31 @@ async function loadManifestFromWebManife
let addon = new AddonInternal();
addon.id = bss.id;
addon.version = manifest.version;
addon.type = extension.type === "extension" ?
"webextension" : `webextension-${extension.type}`;
addon.strictCompatibility = true;
addon.internalName = null;
addon.updateURL = bss.update_url;
- addon.optionsBrowserStyle = true;
+ addon.optionsBrowserStyle = !!manifest.options_ui.browser_style;
addon.optionsURL = null;
addon.optionsType = null;
addon.aboutURL = null;
addon.dependencies = Object.freeze(Array.from(extension.dependencies));
addon.startupData = extension.startupData;
if (manifest.options_ui) {
// Store just the relative path here, the AddonWrapper getURL
// wrapper maps this to a full URL.
addon.optionsURL = manifest.options_ui.page;
if (manifest.options_ui.open_in_tab)
addon.optionsType = AddonManager.OPTIONS_TYPE_TAB;
else
addon.optionsType = AddonManager.OPTIONS_TYPE_INLINE_BROWSER;
-
- if (manifest.options_ui.browser_style === null)
- logger.warn("Please specify whether you want browser_style " +
- "or not in your options_ui options.");
- else
- addon.optionsBrowserStyle = manifest.options_ui.browser_style;
}
// WebExtensions don't use iconURLs
addon.iconURL = null;
addon.icon64URL = null;
addon.icons = manifest.icons || {};
addon.userPermissions = extension.manifestPermissions;