mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-17 07:15:46 +00:00
Bug 1250685 - Fix extension context menu for images. r=kmag
This commit is contained in:
parent
a72cf7f810
commit
d7b2387a81
@ -40,7 +40,7 @@ var gMenuBuilder = {
|
||||
this.xulMenu = xulMenu;
|
||||
for (let [, root] of gRootItems) {
|
||||
let rootElement = this.buildElementWithChildren(root, contextData);
|
||||
if (!rootElement.childNodes.length) {
|
||||
if (!rootElement.firstChild.childNodes.length) {
|
||||
// If the root has no visible children, there is no reason to show
|
||||
// the root menu item itself either.
|
||||
continue;
|
||||
|
@ -2,6 +2,67 @@
|
||||
/* vim: set sts=2 sw=2 et tw=80: */
|
||||
"use strict";
|
||||
|
||||
|
||||
add_task(function* () {
|
||||
let tab1 = yield BrowserTestUtils.openNewForegroundTab(gBrowser,
|
||||
"http://mochi.test:8888/browser/browser/components/extensions/test/browser/context.html");
|
||||
|
||||
gBrowser.selectedTab = tab1;
|
||||
|
||||
let extension = ExtensionTestUtils.loadExtension({
|
||||
manifest: {
|
||||
"permissions": ["contextMenus"],
|
||||
},
|
||||
|
||||
background: function() {
|
||||
browser.contextMenus.create({
|
||||
id: "clickme",
|
||||
title: "Click me!",
|
||||
contexts: ["image"],
|
||||
});
|
||||
browser.test.notifyPass();
|
||||
},
|
||||
});
|
||||
|
||||
yield extension.startup();
|
||||
yield extension.awaitFinish();
|
||||
|
||||
let contentAreaContextMenu = document.getElementById("contentAreaContextMenu");
|
||||
let popupShownPromise = BrowserTestUtils.waitForEvent(contentAreaContextMenu, "popupshown");
|
||||
yield BrowserTestUtils.synthesizeMouseAtCenter("#img1", {
|
||||
type: "contextmenu",
|
||||
button: 2,
|
||||
}, gBrowser.selectedBrowser);
|
||||
yield popupShownPromise;
|
||||
|
||||
let item = contentAreaContextMenu.getElementsByAttribute("label", "Click me!");
|
||||
is(item.length, 1, "contextMenu item for image was found");
|
||||
|
||||
let popupHiddenPromise = BrowserTestUtils.waitForEvent(contentAreaContextMenu, "popuphidden");
|
||||
EventUtils.synthesizeMouseAtCenter(item[0], {});
|
||||
yield popupHiddenPromise;
|
||||
|
||||
contentAreaContextMenu = document.getElementById("contentAreaContextMenu");
|
||||
popupShownPromise = BrowserTestUtils.waitForEvent(contentAreaContextMenu, "popupshown");
|
||||
yield BrowserTestUtils.synthesizeMouseAtCenter("body", {
|
||||
type: "contextmenu",
|
||||
button: 2,
|
||||
}, gBrowser.selectedBrowser);
|
||||
yield popupShownPromise;
|
||||
|
||||
item = contentAreaContextMenu.getElementsByAttribute("label", "Click me!");
|
||||
is(item.length, 0, "no contextMenu item for image was found");
|
||||
|
||||
// click something to close the context menu
|
||||
popupHiddenPromise = BrowserTestUtils.waitForEvent(contentAreaContextMenu, "popuphidden");
|
||||
EventUtils.synthesizeMouseAtCenter(document.getElementById("context-selectall"), {});
|
||||
yield popupHiddenPromise;
|
||||
|
||||
yield extension.unload();
|
||||
|
||||
yield BrowserTestUtils.removeTab(tab1);
|
||||
});
|
||||
|
||||
/* globals content */
|
||||
/* eslint-disable mozilla/no-cpows-in-tests */
|
||||
add_task(function* () {
|
||||
|
Loading…
Reference in New Issue
Block a user