Bug 1615934 - Send tab ID with composeAction.onClicked event. r=mkmelin
--HG-- extra : rebase_source : 170857d731223fe76b3e9c4de12e6e9593cc8c71 extra : histedit_source : c7b3309953db3904b2e7e47d73cf64e17db5a353
This commit is contained in:
Родитель
5a49fc3f9c
Коммит
aeb17b92ec
|
@ -67,4 +67,28 @@ this.composeAction = class extends ToolbarButtonAPI {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
getAPI(context) {
|
||||
let { extension } = context;
|
||||
let { windowManager } = extension;
|
||||
|
||||
let action = this;
|
||||
let api = super.getAPI(context);
|
||||
api.composeAction.onClicked = new EventManager({
|
||||
context,
|
||||
name: "composeAction.onClicked",
|
||||
inputHandling: true,
|
||||
register: fire => {
|
||||
let listener = (event, window) => {
|
||||
let win = windowManager.wrapWindow(window);
|
||||
fire.sync(win.activeTab.id);
|
||||
};
|
||||
action.on("click", listener);
|
||||
return () => {
|
||||
action.off("click", listener);
|
||||
};
|
||||
},
|
||||
}).api();
|
||||
return api;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -411,6 +411,11 @@
|
|||
"type": "function",
|
||||
"description": "Fired when a toolbar action icon is clicked. This event will not fire if the toolbar action has a popup.",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "tabId",
|
||||
"type": "integer",
|
||||
"minimum": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
|
|
@ -128,7 +128,8 @@ add_task(async function setup() {
|
|||
add_task(async function the_test() {
|
||||
async function background_nopopup() {
|
||||
browser.test.log("nopopup background script ran");
|
||||
browser.composeAction.onClicked.addListener(async () => {
|
||||
browser.composeAction.onClicked.addListener(async tabId => {
|
||||
browser.test.log(`tabId is ${tabId}`);
|
||||
await browser.composeAction.setTitle({ title: "New title" });
|
||||
await new Promise(setTimeout);
|
||||
browser.test.sendMessage("composeAction");
|
||||
|
|
Загрузка…
Ссылка в новой задаче