diff --git a/src/experiment_apis/customizableUI/api.js b/src/experiment_apis/customizableUI/api.js index 50f6159..d95270d 100644 --- a/src/experiment_apis/customizableUI/api.js +++ b/src/experiment_apis/customizableUI/api.js @@ -1,14 +1,14 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -/* global ChromeUtils ExtensionAPI ExtensionCommon */ +/* global ChromeUtils ExtensionAPI */ this.customizableUI = class extends ExtensionAPI { getAPI(context) { - const {Services} = ChromeUtils.import('resource://gre/modules/Services.jsm'); - ChromeUtils.import('resource://gre/modules/ExtensionCommon.jsm'); + const {CustomizableUI} = ChromeUtils.import('resource:///modules/CustomizableUI.jsm'); + const {ExtensionCommon} = ChromeUtils.import('resource://gre/modules/ExtensionCommon.jsm'); const {EventManager} = ExtensionCommon; - const {CustomizableUI} = ChromeUtils.import('resource:///modules/CustomizableUI.jsm', {}); + const {Services} = ChromeUtils.import('resource://gre/modules/Services.jsm'); return { customizableUI: { onWidgetRemoved: new EventManager( @@ -27,8 +27,12 @@ this.customizableUI = class extends ExtensionAPI { }, ).api(), async isWidgetInOverflow(widgetId) { + const {area} = CustomizableUI.getPlacementOfWidget(widgetId); const browserWindow = Services.wm.getMostRecentWindow('navigator:browser'); - return CustomizableUI.getWidget(widgetId).forWindow(browserWindow).overflowed; + // First check is for the non-fixed overflow menu (e.g. widget moved by resizing window) + // Second is for fixed overflow menu (e.g. widget moved by (un)pinning button to overflow) + return (CustomizableUI.getWidget(widgetId).forWindow(browserWindow).overflowed + || area === 'widget-overflow-fixed-list'); }, }, }; diff --git a/src/experiment_apis/customizableUI/schema.json b/src/experiment_apis/customizableUI/schema.json index 6179b04..63a7c9f 100644 --- a/src/experiment_apis/customizableUI/schema.json +++ b/src/experiment_apis/customizableUI/schema.json @@ -5,7 +5,7 @@ { "name": "onWidgetRemoved", "type": "function", - "description": "Fired when a widget is removed from the browser chrome", + "description": "Fired when a widget is removed from the browser chrome.", "parameters": [ { "name": "widgetId", @@ -19,7 +19,7 @@ { "name": "isWidgetInOverflow", "type": "function", - "description": "Returns a boolean for whether or not the provided widget in the provided window is in the overflow menu or not.", + "description": "Determine whether or not a widget is in the overflow menu.", "async": true, "parameters": [ {