mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-22 09:45:41 +00:00
Bug 1454627 - Run "onclick" event of menu with user input r=mixedpuppy
MozReview-Commit-ID: r1URJfOKUB --HG-- extra : rebase_source : 1f5c5bb7b6dbd9709a26bf10abddcda919eff70f
This commit is contained in:
parent
47a802bd4e
commit
38f52336fc
@ -32,7 +32,7 @@ class ContextMenusClickPropHandler {
|
||||
// No need for runSafe or anything because we are already being run inside
|
||||
// an event handler -- the event is just being forwarded to the actual
|
||||
// handler.
|
||||
onclick(info, tab);
|
||||
withHandlingUserInput(this.context.contentWindow, () => onclick(info, tab));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,9 +47,15 @@ add_task(async function testSources() {
|
||||
|
||||
browser.pageAction.onClicked.addListener(() => request("bookmarks"));
|
||||
browser.browserAction.onClicked.addListener(() => request("tabs"));
|
||||
browser.contextMenus.onClicked.addListener(() => request("webNavigation"));
|
||||
|
||||
browser.test.onMessage.addListener(msg => {
|
||||
if (msg === "contextMenus.update") {
|
||||
browser.contextMenus.onClicked.addListener(() => request("webNavigation"));
|
||||
browser.contextMenus.update("menu", {
|
||||
title: "test user events in onClicked",
|
||||
onclick: null,
|
||||
}, () => browser.test.sendMessage("contextMenus.update-done"));
|
||||
}
|
||||
if (msg === "openOptionsPage") {
|
||||
browser.runtime.openOptionsPage();
|
||||
}
|
||||
@ -57,8 +63,11 @@ add_task(async function testSources() {
|
||||
|
||||
browser.contextMenus.create({
|
||||
id: "menu",
|
||||
title: "test user events",
|
||||
title: "test user events in onclick",
|
||||
contexts: ["page"],
|
||||
onclick() {
|
||||
request("cookies");
|
||||
},
|
||||
}, () => {
|
||||
browser.test.sendMessage("actions-ready");
|
||||
});
|
||||
@ -111,7 +120,7 @@ add_task(async function testSources() {
|
||||
browser_action: {default_title: "test"},
|
||||
page_action: {default_title: "test"},
|
||||
permissions: ["contextMenus"],
|
||||
optional_permissions: ["bookmarks", "tabs", "webNavigation", "webRequest"],
|
||||
optional_permissions: ["bookmarks", "tabs", "webNavigation", "webRequest", "cookies"],
|
||||
options_ui: {page: "options.html"},
|
||||
content_security_policy: "script-src 'self' https://example.com; object-src 'none';",
|
||||
},
|
||||
@ -153,10 +162,18 @@ add_task(async function testSources() {
|
||||
gBrowser.selectedTab = tab;
|
||||
|
||||
let menu = await openContextMenu("body");
|
||||
let items = menu.getElementsByAttribute("label", "test user events");
|
||||
let items = menu.getElementsByAttribute("label", "test user events in onclick");
|
||||
is(items.length, 1, "Found context menu item");
|
||||
EventUtils.synthesizeMouseAtCenter(items[0], {});
|
||||
await check("context menu click");
|
||||
await check("context menu in onclick");
|
||||
|
||||
extension.sendMessage("contextMenus.update");
|
||||
await extension.awaitMessage("contextMenus.update-done");
|
||||
menu = await openContextMenu("body");
|
||||
items = menu.getElementsByAttribute("label", "test user events in onClicked");
|
||||
is(items.length, 1, "Found context menu item again");
|
||||
EventUtils.synthesizeMouseAtCenter(items[0], {});
|
||||
await check("context menu in onClicked");
|
||||
|
||||
extension.sendMessage("openOptionsPage");
|
||||
promisePopupNotificationShown("addon-webext-permissions").then(panel => {
|
||||
|
Loading…
Reference in New Issue
Block a user