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:
Rob Wu 2018-07-27 19:06:00 +02:00
Родитель 62d7399a68
Коммит 98a7b1a964
2 изменённых файлов: 23 добавлений и 6 удалений

Просмотреть файл

@ -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 => {