mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-27 21:00:50 +00:00
Bug 1313459 support CUI areas for browserAction, r=aswan
MozReview-Commit-ID: IoPOCv6M0qy --HG-- extra : rebase_source : b032c4e8d1f9fe3cdc79ea9216540b7de51a572a
This commit is contained in:
parent
e4420d1268
commit
a4ed9eb735
@ -38,7 +38,14 @@ function isAncestorOrSelf(target, node) {
|
||||
}
|
||||
|
||||
// WeakMap[Extension -> BrowserAction]
|
||||
var browserActionMap = new WeakMap();
|
||||
const browserActionMap = new WeakMap();
|
||||
|
||||
const browserAreas = {
|
||||
"navbar": CustomizableUI.AREA_NAVBAR,
|
||||
"menupanel": CustomizableUI.AREA_PANEL,
|
||||
"tabstrip": CustomizableUI.AREA_TABSTRIP,
|
||||
"personaltoolbar": CustomizableUI.AREA_BOOKMARKS,
|
||||
};
|
||||
|
||||
// Responsible for the browser_action section of the manifest as well
|
||||
// as the associated popup.
|
||||
@ -62,6 +69,7 @@ function BrowserAction(options, extension) {
|
||||
badgeBackgroundColor: null,
|
||||
icon: IconDetails.normalize({path: options.default_icon}, extension),
|
||||
popup: options.default_popup || "",
|
||||
area: browserAreas[options.default_area || "navbar"],
|
||||
};
|
||||
|
||||
this.browserStyle = options.browser_style || false;
|
||||
@ -85,7 +93,7 @@ BrowserAction.prototype = {
|
||||
removable: true,
|
||||
label: this.defaults.title || this.extension.name,
|
||||
tooltiptext: this.defaults.title || "",
|
||||
defaultArea: CustomizableUI.AREA_NAVBAR,
|
||||
defaultArea: this.defaults.area,
|
||||
|
||||
onBeforeCreated: document => {
|
||||
let view = document.createElementNS(XUL_NS, "panelview");
|
||||
|
@ -31,6 +31,12 @@
|
||||
"browser_style": {
|
||||
"type": "boolean",
|
||||
"optional": true
|
||||
},
|
||||
"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
|
||||
}
|
||||
},
|
||||
"optional": true
|
||||
|
@ -24,6 +24,7 @@ support-files =
|
||||
searchSuggestionEngine.sjs
|
||||
../../../../../toolkit/components/extensions/test/mochitest/head_webrequest.js
|
||||
|
||||
[browser_ext_browserAction_area.js]
|
||||
[browser_ext_browserAction_context.js]
|
||||
[browser_ext_browserAction_disabled.js]
|
||||
[browser_ext_browserAction_pageAction_icon.js]
|
||||
|
@ -0,0 +1,49 @@
|
||||
/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
||||
/* vim: set sts=2 sw=2 et tw=80: */
|
||||
"use strict";
|
||||
|
||||
var browserAreas = {
|
||||
"navbar": CustomizableUI.AREA_NAVBAR,
|
||||
"menupanel": CustomizableUI.AREA_PANEL,
|
||||
"tabstrip": CustomizableUI.AREA_TABSTRIP,
|
||||
"personaltoolbar": CustomizableUI.AREA_BOOKMARKS,
|
||||
};
|
||||
|
||||
function* testInArea(area) {
|
||||
let manifest = {
|
||||
"browser_action": {
|
||||
"browser_style": true,
|
||||
},
|
||||
};
|
||||
if (area) {
|
||||
manifest.browser_action.default_area = area;
|
||||
}
|
||||
let extension = ExtensionTestUtils.loadExtension({
|
||||
manifest,
|
||||
});
|
||||
yield extension.startup();
|
||||
let widget = getBrowserActionWidget(extension);
|
||||
let placement = CustomizableUI.getPlacementOfWidget(widget.id);
|
||||
is(placement && placement.area, browserAreas[area || "navbar"], `widget located in correct area`);
|
||||
yield extension.unload();
|
||||
}
|
||||
|
||||
add_task(function* testBrowserActionDefaultArea() {
|
||||
yield testInArea();
|
||||
});
|
||||
|
||||
add_task(function* testBrowserActionInToolbar() {
|
||||
yield testInArea("navbar");
|
||||
});
|
||||
|
||||
add_task(function* testBrowserActionInMenuPanel() {
|
||||
yield testInArea("menupanel");
|
||||
});
|
||||
|
||||
add_task(function* testBrowserActionInTabStrip() {
|
||||
yield testInArea("tabstrip");
|
||||
});
|
||||
|
||||
add_task(function* testBrowserActionInPersonalToolbar() {
|
||||
yield testInArea("personaltoolbar");
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user