Bug 1404724 - remove browser_style warning, fix default values, r?aswan draft
authorShane Caraveo <scaraveo@mozilla.com>
Tue, 29 May 2018 16:55:43 -0400
changeset 801155 e0ab228d5be49dbe2e6c982f1b11114bb8378193
parent 800874 f01bb6245db1ea2a87e5360104a4110571265137
push id111596
push usermixedpuppy@gmail.com
push dateTue, 29 May 2018 20:58:49 +0000
reviewersaswan
bugs1404724
milestone62.0a1
Bug 1404724 - remove browser_style warning, fix default values, r?aswan MozReview-Commit-ID: Akdhrm4leIQ
browser/components/extensions/parent/ext-browserAction.js
browser/components/extensions/parent/ext-pageAction.js
browser/components/extensions/parent/ext-sidebarAction.js
browser/components/extensions/schemas/browser_action.json
browser/components/extensions/schemas/page_action.json
browser/components/extensions/schemas/sidebar_action.json
browser/components/extensions/test/browser/browser_ext_sidebarAction_browser_style.js
mobile/android/components/extensions/schemas/browser_action.json
mobile/android/components/extensions/schemas/page_action.json
toolkit/components/extensions/schemas/manifest.json
toolkit/mozapps/extensions/internal/XPIInstall.jsm
--- 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": true
               },
               "default_panel": {
                 "type": "string",
                 "format": "strictRelativeUrl",
                 "preprocess": "localize"
               },
               "open_at_install": {
                 "type": "boolean",
--- 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,17 +1,17 @@
 /* -*- 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) {
         browser.test.assertEq(browserStyleBackgroundColor, buttonBackgroundColor, assertMessage);
       } else {
--- a/mobile/android/components/extensions/schemas/browser_action.json
+++ b/mobile/android/components/extensions/schemas/browser_action.json
@@ -27,17 +27,18 @@
                 "type": "string",
                 "format": "relativeUrl",
                 "optional": true,
                 "preprocess": "localize"
               },
               "browser_style": {
                 "type": "boolean",
                 "deprecated": "Unsupported on Android.",
-                "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"],
                 "deprecated": "Unsupported on Android.",
                 "optional": true
               }
--- a/mobile/android/components/extensions/schemas/page_action.json
+++ b/mobile/android/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
               }
             },
             "optional": true
           }
         }
       }
     ]
   },
--- a/toolkit/components/extensions/schemas/manifest.json
+++ b/toolkit/components/extensions/schemas/manifest.json
@@ -141,17 +141,18 @@
             "type": "object",
 
             "optional": true,
 
             "properties": {
               "page": { "$ref": "ExtensionURL" },
               "browser_style": {
                 "type": "boolean",
-                "optional": true
+                "optional": true,
+                "default": true
               },
               "chrome_style": {
                 "type": "boolean",
                 "optional": true
               },
               "open_in_tab": {
                 "type": "boolean",
                 "optional": true
--- a/toolkit/mozapps/extensions/internal/XPIInstall.jsm
+++ b/toolkit/mozapps/extensions/internal/XPIInstall.jsm
@@ -476,21 +476,17 @@ async function loadManifestFromWebManife
     // 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;
+    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;