mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 07:42:04 +00:00
Backed out changeset 796f3bfbaa2d (bug 1476097) for perma dt failures in devtools/client/debugger/new/test/mochitest/browser_dbg-breakpoints-actions.js CLOSED TREE
This commit is contained in:
parent
ae8ecdb28d
commit
0fd9c747eb
@ -27,7 +27,6 @@ DevToolsModules(
|
||||
'source-map-url-service.js',
|
||||
'target-from-url.js',
|
||||
'target.js',
|
||||
'toolbox-context-menu.js',
|
||||
'toolbox-highlighter-utils.js',
|
||||
'toolbox-host-manager.js',
|
||||
'toolbox-hosts.js',
|
||||
|
@ -66,7 +66,7 @@ async function testMenuPopup(toolbox) {
|
||||
disabled: true,
|
||||
}),
|
||||
new MenuItem({
|
||||
l10nID: "editmenu-undo",
|
||||
l10nID: "foo",
|
||||
}),
|
||||
];
|
||||
|
||||
@ -132,7 +132,7 @@ async function testSubmenu(toolbox) {
|
||||
},
|
||||
}));
|
||||
menu.append(new MenuItem({
|
||||
l10nID: "editmenu-copy",
|
||||
l10nID: "submenu-parent",
|
||||
submenu: submenu,
|
||||
}));
|
||||
menu.append(new MenuItem({
|
||||
@ -152,7 +152,7 @@ async function testSubmenu(toolbox) {
|
||||
is(menus.length, 2, "Correct number of menus");
|
||||
ok(!menus[0].hasAttribute("label"), "No label: should be set by localization");
|
||||
ok(!menus[0].hasAttribute("disabled"), "Correct disabled state");
|
||||
is(menus[0].getAttribute("data-l10n-id"), "editmenu-copy", "Correct localization attribute");
|
||||
is(menus[0].getAttribute("data-l10n-id"), "submenu-parent", "Correct localization attribute");
|
||||
|
||||
is(menus[1].getAttribute("accesskey"), "A", "Correct accesskey");
|
||||
ok(menus[1].hasAttribute("disabled"), "Correct disabled state");
|
||||
|
@ -19,6 +19,7 @@ registerCleanupFunction(() => {
|
||||
add_task(async function checkMenuEntryStates() {
|
||||
info("Checking the state of edit menuitems with an empty clipboard");
|
||||
const toolbox = await openNewTabAndToolbox(URL, "inspector");
|
||||
const textboxContextMenu = toolbox.textBoxContextMenuPopup;
|
||||
|
||||
emptyClipboard();
|
||||
|
||||
@ -28,20 +29,20 @@ add_task(async function checkMenuEntryStates() {
|
||||
inspector.searchBox.focus();
|
||||
await onFocus;
|
||||
|
||||
info("Opening context menu");
|
||||
const onContextMenuPopup = toolbox.once("menu-open");
|
||||
synthesizeContextMenuEvent(inspector.searchBox);
|
||||
await onContextMenuPopup;
|
||||
|
||||
const textboxContextMenu = toolbox.doc.getElementById("toolbox-menu");
|
||||
ok(textboxContextMenu, "The textbox context menu is loaded in the toolbox");
|
||||
|
||||
const cmdUndo = textboxContextMenu.querySelector("#editmenu-undo");
|
||||
const cmdDelete = textboxContextMenu.querySelector("#editmenu-delete");
|
||||
const cmdSelectAll = textboxContextMenu.querySelector("#editmenu-selectAll");
|
||||
const cmdCut = textboxContextMenu.querySelector("#editmenu-cut");
|
||||
const cmdCopy = textboxContextMenu.querySelector("#editmenu-copy");
|
||||
const cmdPaste = textboxContextMenu.querySelector("#editmenu-paste");
|
||||
const cmdUndo = textboxContextMenu.querySelector("[command=cmd_undo]");
|
||||
const cmdDelete = textboxContextMenu.querySelector("[command=cmd_delete]");
|
||||
const cmdSelectAll = textboxContextMenu.querySelector("[command=cmd_selectAll]");
|
||||
const cmdCut = textboxContextMenu.querySelector("[command=cmd_cut]");
|
||||
const cmdCopy = textboxContextMenu.querySelector("[command=cmd_copy]");
|
||||
const cmdPaste = textboxContextMenu.querySelector("[command=cmd_paste]");
|
||||
|
||||
info("Opening context menu");
|
||||
|
||||
const onContextMenuPopup = once(textboxContextMenu, "popupshowing");
|
||||
textboxContextMenu.openPopupAtScreen(0, 0, true);
|
||||
await onContextMenuPopup;
|
||||
|
||||
is(cmdUndo.getAttribute("disabled"), "true", "cmdUndo is disabled");
|
||||
is(cmdDelete.getAttribute("disabled"), "true", "cmdDelete is disabled");
|
||||
@ -52,10 +53,6 @@ add_task(async function checkMenuEntryStates() {
|
||||
is(cmdCut.getAttribute("disabled"), "", "cmdCut is enabled");
|
||||
is(cmdCopy.getAttribute("disabled"), "", "cmdCopy is enabled");
|
||||
is(cmdPaste.getAttribute("disabled"), "", "cmdPaste is enabled");
|
||||
|
||||
const onContextMenuHidden = toolbox.once("menu-close");
|
||||
EventUtils.sendKey("ESCAPE", toolbox.win);
|
||||
await onContextMenuHidden;
|
||||
});
|
||||
|
||||
add_task(async function automaticallyBindTexbox() {
|
||||
@ -83,39 +80,35 @@ add_task(async function automaticallyBindTexbox() {
|
||||
await checkNonTextInput(doc.querySelector("input[type=radio]"), toolbox);
|
||||
});
|
||||
|
||||
async function checkNonTextInput(input, toolbox) {
|
||||
let textboxContextMenu = toolbox.doc.getElementById("toolbox-menu");
|
||||
ok(!textboxContextMenu, "The menu is closed");
|
||||
async function checkNonTextInput(input, {textBoxContextMenuPopup}) {
|
||||
is(textBoxContextMenuPopup.state, "closed", "The menu is closed");
|
||||
|
||||
info("Simulating context click on the non text input and expecting no menu to open");
|
||||
const eventBubbledUp = new Promise(resolve => {
|
||||
input.ownerDocument.addEventListener("contextmenu", resolve, { once: true });
|
||||
});
|
||||
synthesizeContextMenuEvent(input);
|
||||
EventUtils.synthesizeMouse(input, 2, 2, {type: "contextmenu", button: 2},
|
||||
input.ownerDocument.defaultView);
|
||||
info("Waiting for event");
|
||||
await eventBubbledUp;
|
||||
|
||||
textboxContextMenu = toolbox.doc.getElementById("toolbox-menu");
|
||||
ok(!textboxContextMenu, "The menu is still closed");
|
||||
is(textBoxContextMenuPopup.state, "closed", "The menu is still closed");
|
||||
}
|
||||
|
||||
async function checkTextBox(textBox, toolbox) {
|
||||
let textboxContextMenu = toolbox.doc.getElementById("toolbox-menu");
|
||||
ok(!textboxContextMenu, "The menu is closed");
|
||||
async function checkTextBox(textBox, {textBoxContextMenuPopup}) {
|
||||
is(textBoxContextMenuPopup.state, "closed", "The menu is closed");
|
||||
|
||||
info("Simulating context click on the textbox and expecting the menu to open");
|
||||
const onContextMenu = toolbox.once("menu-open");
|
||||
synthesizeContextMenuEvent(textBox);
|
||||
const onContextMenu = once(textBoxContextMenuPopup, "popupshown");
|
||||
EventUtils.synthesizeMouse(textBox, 2, 2, {type: "contextmenu", button: 2},
|
||||
textBox.ownerDocument.defaultView);
|
||||
await onContextMenu;
|
||||
|
||||
textboxContextMenu = toolbox.doc.getElementById("toolbox-menu");
|
||||
ok(textboxContextMenu, "The menu is now visible");
|
||||
is(textBoxContextMenuPopup.state, "open", "The menu is now visible");
|
||||
|
||||
info("Closing the menu");
|
||||
const onContextMenuHidden = toolbox.once("menu-close");
|
||||
EventUtils.sendKey("ESCAPE", toolbox.win);
|
||||
const onContextMenuHidden = once(textBoxContextMenuPopup, "popuphidden");
|
||||
textBoxContextMenuPopup.hidePopup();
|
||||
await onContextMenuHidden;
|
||||
|
||||
textboxContextMenu = toolbox.doc.getElementById("toolbox-menu");
|
||||
ok(!textboxContextMenu, "The menu is closed again");
|
||||
is(textBoxContextMenuPopup.state, "closed", "The menu is closed again");
|
||||
}
|
||||
|
@ -1,103 +0,0 @@
|
||||
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
||||
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
|
||||
/* 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/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
const Menu = require("devtools/client/framework/menu");
|
||||
const MenuItem = require("devtools/client/framework/menu-item");
|
||||
|
||||
var stringsLoaded = false;
|
||||
|
||||
/**
|
||||
* Lazily load strings for the edit menu.
|
||||
*/
|
||||
function loadEditMenuStrings(win) {
|
||||
if (stringsLoaded) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof win.MozXULElement !== "undefined") {
|
||||
stringsLoaded = true;
|
||||
win.MozXULElement.insertFTLIfNeeded("toolkit/main-window/editmenu.ftl");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an 'edit' menu for a input field. This integrates directly
|
||||
* with docshell commands to provide the right enabled state and editor
|
||||
* functionality.
|
||||
*
|
||||
* You'll need to call menu.popup() yourself, this just returns the Menu instance.
|
||||
*
|
||||
* @param {Window} win parent window reference
|
||||
* @param {String} id menu ID
|
||||
*
|
||||
* @returns {Menu}
|
||||
*/
|
||||
function createEditContextMenu(win, id) {
|
||||
// Localized strings for the menu are loaded lazily.
|
||||
loadEditMenuStrings(win);
|
||||
|
||||
const docshell = win.docShell;
|
||||
const menu = new Menu({id});
|
||||
menu.append(new MenuItem({
|
||||
id: "editmenu-undo",
|
||||
l10nID: "editmenu-undo",
|
||||
disabled: !docshell.isCommandEnabled("cmd_undo"),
|
||||
click: () => {
|
||||
docshell.doCommand("cmd_undo");
|
||||
},
|
||||
}));
|
||||
menu.append(new MenuItem({
|
||||
type: "separator",
|
||||
}));
|
||||
menu.append(new MenuItem({
|
||||
id: "editmenu-cut",
|
||||
l10nID: "editmenu-cut",
|
||||
disabled: !docshell.isCommandEnabled("cmd_cut"),
|
||||
click: () => {
|
||||
docshell.doCommand("cmd_cut");
|
||||
},
|
||||
}));
|
||||
menu.append(new MenuItem({
|
||||
id: "editmenu-copy",
|
||||
l10nID: "editmenu-copy",
|
||||
disabled: !docshell.isCommandEnabled("cmd_copy"),
|
||||
click: () => {
|
||||
docshell.doCommand("cmd_copy");
|
||||
},
|
||||
}));
|
||||
menu.append(new MenuItem({
|
||||
id: "editmenu-paste",
|
||||
l10nID: "editmenu-paste",
|
||||
disabled: !docshell.isCommandEnabled("cmd_paste"),
|
||||
click: () => {
|
||||
docshell.doCommand("cmd_paste");
|
||||
},
|
||||
}));
|
||||
menu.append(new MenuItem({
|
||||
id: "editmenu-delete",
|
||||
l10nID: "editmenu-delete",
|
||||
disabled: !docshell.isCommandEnabled("cmd_delete"),
|
||||
click: () => {
|
||||
docshell.doCommand("cmd_delete");
|
||||
},
|
||||
}));
|
||||
menu.append(new MenuItem({
|
||||
type: "separator",
|
||||
}));
|
||||
menu.append(new MenuItem({
|
||||
id: "editmenu-selectAll",
|
||||
l10nID: "editmenu-select-all",
|
||||
disabled: !docshell.isCommandEnabled("cmd_selectAll"),
|
||||
click: () => {
|
||||
docshell.doCommand("cmd_selectAll");
|
||||
},
|
||||
}));
|
||||
return menu;
|
||||
}
|
||||
|
||||
module.exports.createEditContextMenu = createEditContextMenu;
|
@ -65,8 +65,6 @@ loader.lazyRequireGetter(this, "NetMonitorAPI",
|
||||
"devtools/client/netmonitor/src/api", true);
|
||||
loader.lazyRequireGetter(this, "sortPanelDefinitions",
|
||||
"devtools/client/framework/toolbox-tabs-order-manager", true);
|
||||
loader.lazyRequireGetter(this, "createEditContextMenu",
|
||||
"devtools/client/framework/toolbox-context-menu", true);
|
||||
|
||||
loader.lazyGetter(this, "domNodeConstants", () => {
|
||||
return require("devtools/shared/dom-node-constants");
|
||||
@ -473,6 +471,10 @@ Toolbox.prototype = {
|
||||
Services.prefs.addObserver("devtools.serviceWorkers.testing.enabled",
|
||||
this._applyServiceWorkersTestingSettings);
|
||||
|
||||
this.textBoxContextMenuPopup =
|
||||
this.doc.getElementById("toolbox-textbox-context-popup");
|
||||
this.textBoxContextMenuPopup.addEventListener("popupshowing",
|
||||
this._updateTextBoxMenuItems, true);
|
||||
this.doc.addEventListener("contextmenu", (e) => {
|
||||
if (e.originalTarget.closest("input[type=text]") ||
|
||||
e.originalTarget.closest("input[type=search]") ||
|
||||
@ -2870,6 +2872,11 @@ Toolbox.prototype = {
|
||||
this._saveSplitConsoleHeight);
|
||||
this.webconsolePanel = null;
|
||||
}
|
||||
if (this.textBoxContextMenuPopup) {
|
||||
this.textBoxContextMenuPopup.removeEventListener("popupshowing",
|
||||
this._updateTextBoxMenuItems, true);
|
||||
this.textBoxContextMenuPopup = null;
|
||||
}
|
||||
if (this._componentMount) {
|
||||
this._componentMount.removeEventListener("keypress", this._onToolbarArrowKeypress);
|
||||
this.ReactDOM.unmountComponentAtNode(this._componentMount);
|
||||
@ -3033,13 +3040,7 @@ Toolbox.prototype = {
|
||||
* @param {Number} y
|
||||
*/
|
||||
openTextBoxContextMenu: function(x, y) {
|
||||
const menu = createEditContextMenu(this.win, "toolbox-menu");
|
||||
|
||||
// Fire event for tests
|
||||
menu.once("open", () => this.emit("menu-open"));
|
||||
menu.once("close", () => this.emit("menu-close"));
|
||||
|
||||
menu.popup(x, y, { doc: this.doc });
|
||||
this.textBoxContextMenuPopup.openPopupAtScreen(x, y, true);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -9,6 +9,8 @@
|
||||
<!DOCTYPE window [
|
||||
<!ENTITY % toolboxDTD SYSTEM "chrome://devtools/locale/toolbox.dtd" >
|
||||
%toolboxDTD;
|
||||
<!ENTITY % editMenuStrings SYSTEM "chrome://global/locale/editMenuOverlay.dtd">
|
||||
%editMenuStrings;
|
||||
<!ENTITY % globalKeysDTD SYSTEM "chrome://global/locale/globalKeys.dtd">
|
||||
%globalKeysDTD;
|
||||
]>
|
||||
@ -21,11 +23,32 @@
|
||||
<script type="application/javascript"
|
||||
src="chrome://global/content/viewSourceUtils.js"/>
|
||||
|
||||
<script type="application/javascript"
|
||||
src="chrome://global/content/globalOverlay.js"/>
|
||||
<script type="application/javascript" src="chrome://global/content/globalOverlay.js"/>
|
||||
<script type="application/javascript"
|
||||
src="chrome://devtools/content/framework/toolbox-init.js"/>
|
||||
|
||||
#include ../../../toolkit/content/editMenuCommands.inc.xul
|
||||
#include ../../../toolkit/content/editMenuKeys.inc.xul
|
||||
|
||||
<popupset>
|
||||
<menupopup id="toolbox-textbox-context-popup">
|
||||
<menuitem id="cMenu_undo" label="&undoCmd.label;"
|
||||
accesskey="&undoCmd.accesskey;" command="cmd_undo"/>
|
||||
<menuseparator/>
|
||||
<menuitem id="cMenu_cut" label="&cutCmd.label;"
|
||||
accesskey="&cutCmd.accesskey;" command="cmd_cut"/>
|
||||
<menuitem id="cMenu_copy" label="©Cmd.label;"
|
||||
accesskey="©Cmd.accesskey;" command="cmd_copy"/>
|
||||
<menuitem id="cMenu_paste" label="&pasteCmd.label;"
|
||||
accesskey="&pasteCmd.accesskey;" command="cmd_paste"/>
|
||||
<menuitem id="cMenu_delete" label="&deleteCmd.label;"
|
||||
accesskey="&deleteCmd.accesskey;" command="cmd_delete"/>
|
||||
<menuseparator/>
|
||||
<menuitem id="cMenu_selectAll" label="&selectAllCmd.label;"
|
||||
accesskey="&selectAllCmd.accesskey;" command="cmd_selectAll"/>
|
||||
</menupopup>
|
||||
</popupset>
|
||||
|
||||
<vbox id="toolbox-container" flex="1">
|
||||
<div xmlns="http://www.w3.org/1999/xhtml" id="toolbox-notificationbox"/>
|
||||
<div xmlns="http://www.w3.org/1999/xhtml" id="toolbox-toolbar-mount"
|
||||
|
@ -15,7 +15,18 @@ add_task(async function() {
|
||||
const {toolbox, inspector, view} = await openComputedView();
|
||||
await selectNode("h1", inspector);
|
||||
|
||||
const win = view.styleWindow;
|
||||
const searchField = view.searchField;
|
||||
const searchContextMenu = toolbox.textBoxContextMenuPopup;
|
||||
ok(searchContextMenu,
|
||||
"The search filter context menu is loaded in the computed view");
|
||||
|
||||
const cmdUndo = searchContextMenu.querySelector("[command=cmd_undo]");
|
||||
const cmdDelete = searchContextMenu.querySelector("[command=cmd_delete]");
|
||||
const cmdSelectAll = searchContextMenu.querySelector("[command=cmd_selectAll]");
|
||||
const cmdCut = searchContextMenu.querySelector("[command=cmd_cut]");
|
||||
const cmdCopy = searchContextMenu.querySelector("[command=cmd_copy]");
|
||||
const cmdPaste = searchContextMenu.querySelector("[command=cmd_paste]");
|
||||
|
||||
info("Opening context menu");
|
||||
|
||||
@ -25,20 +36,10 @@ add_task(async function() {
|
||||
searchField.focus();
|
||||
await onFocus;
|
||||
|
||||
let onContextMenuOpen = toolbox.once("menu-open");
|
||||
synthesizeContextMenuEvent(searchField);
|
||||
await onContextMenuOpen;
|
||||
|
||||
let searchContextMenu = toolbox.doc.getElementById("toolbox-menu");
|
||||
ok(searchContextMenu,
|
||||
"The search filter context menu is loaded in the computed view");
|
||||
|
||||
let cmdUndo = searchContextMenu.querySelector("#editmenu-undo");
|
||||
let cmdDelete = searchContextMenu.querySelector("#editmenu-delete");
|
||||
let cmdSelectAll = searchContextMenu.querySelector("#editmenu-selectAll");
|
||||
let cmdCut = searchContextMenu.querySelector("#editmenu-cut");
|
||||
let cmdCopy = searchContextMenu.querySelector("#editmenu-copy");
|
||||
let cmdPaste = searchContextMenu.querySelector("#editmenu-paste");
|
||||
const onContextMenuPopup = once(searchContextMenu, "popupshowing");
|
||||
EventUtils.synthesizeMouse(searchField, 2, 2,
|
||||
{type: "contextmenu", button: 2}, win);
|
||||
await onContextMenuPopup;
|
||||
|
||||
is(cmdUndo.getAttribute("disabled"), "true", "cmdUndo is disabled");
|
||||
is(cmdDelete.getAttribute("disabled"), "true", "cmdDelete is disabled");
|
||||
@ -51,39 +52,24 @@ add_task(async function() {
|
||||
is(cmdPaste.getAttribute("disabled"), "", "cmdPaste is enabled");
|
||||
|
||||
info("Closing context menu");
|
||||
let onContextMenuClose = toolbox.once("menu-close");
|
||||
EventUtils.sendKey("ESCAPE", toolbox.win);
|
||||
await onContextMenuClose;
|
||||
const onContextMenuHidden = once(searchContextMenu, "popuphidden");
|
||||
searchContextMenu.hidePopup();
|
||||
await onContextMenuHidden;
|
||||
|
||||
info("Copy text in search field using the context menu");
|
||||
searchField.setUserInput(TEST_INPUT);
|
||||
searchField.select();
|
||||
|
||||
onContextMenuOpen = toolbox.once("menu-open");
|
||||
synthesizeContextMenuEvent(searchField);
|
||||
await onContextMenuOpen;
|
||||
|
||||
searchContextMenu = toolbox.doc.getElementById("toolbox-menu");
|
||||
cmdCopy = searchContextMenu.querySelector("#editmenu-copy");
|
||||
EventUtils.synthesizeMouse(searchField, 2, 2,
|
||||
{type: "contextmenu", button: 2}, win);
|
||||
await onContextMenuPopup;
|
||||
await waitForClipboardPromise(() => cmdCopy.click(), TEST_INPUT);
|
||||
|
||||
onContextMenuClose = toolbox.once("menu-close");
|
||||
EventUtils.sendKey("ESCAPE", toolbox.win);
|
||||
await onContextMenuClose;
|
||||
searchContextMenu.hidePopup();
|
||||
await onContextMenuHidden;
|
||||
|
||||
info("Reopen context menu and check command properties");
|
||||
|
||||
onContextMenuOpen = toolbox.once("menu-open");
|
||||
synthesizeContextMenuEvent(searchField);
|
||||
await onContextMenuOpen;
|
||||
|
||||
searchContextMenu = toolbox.doc.getElementById("toolbox-menu");
|
||||
cmdUndo = searchContextMenu.querySelector("#editmenu-undo");
|
||||
cmdDelete = searchContextMenu.querySelector("#editmenu-delete");
|
||||
cmdSelectAll = searchContextMenu.querySelector("#editmenu-selectAll");
|
||||
cmdCut = searchContextMenu.querySelector("#editmenu-cut");
|
||||
cmdCopy = searchContextMenu.querySelector("#editmenu-copy");
|
||||
cmdPaste = searchContextMenu.querySelector("#editmenu-paste");
|
||||
EventUtils.synthesizeMouse(searchField, 2, 2,
|
||||
{type: "contextmenu", button: 2}, win);
|
||||
await onContextMenuPopup;
|
||||
|
||||
is(cmdUndo.getAttribute("disabled"), "", "cmdUndo is enabled");
|
||||
is(cmdDelete.getAttribute("disabled"), "", "cmdDelete is enabled");
|
||||
@ -91,8 +77,4 @@ add_task(async function() {
|
||||
is(cmdCut.getAttribute("disabled"), "", "cmdCut is enabled");
|
||||
is(cmdCopy.getAttribute("disabled"), "", "cmdCopy is enabled");
|
||||
is(cmdPaste.getAttribute("disabled"), "", "cmdPaste is enabled");
|
||||
|
||||
onContextMenuClose = toolbox.once("menu-close");
|
||||
EventUtils.sendKey("ESCAPE", toolbox.win);
|
||||
await onContextMenuClose;
|
||||
});
|
||||
|
@ -14,7 +14,18 @@ add_task(async function() {
|
||||
const {toolbox, inspector, view} = await openRuleView();
|
||||
await selectNode("h1", inspector);
|
||||
|
||||
const win = view.styleWindow;
|
||||
const searchField = view.searchField;
|
||||
const searchContextMenu = toolbox.textBoxContextMenuPopup;
|
||||
ok(searchContextMenu,
|
||||
"The search filter context menu is loaded in the rule view");
|
||||
|
||||
const cmdUndo = searchContextMenu.querySelector("[command=cmd_undo]");
|
||||
const cmdDelete = searchContextMenu.querySelector("[command=cmd_delete]");
|
||||
const cmdSelectAll = searchContextMenu.querySelector("[command=cmd_selectAll]");
|
||||
const cmdCut = searchContextMenu.querySelector("[command=cmd_cut]");
|
||||
const cmdCopy = searchContextMenu.querySelector("[command=cmd_copy]");
|
||||
const cmdPaste = searchContextMenu.querySelector("[command=cmd_paste]");
|
||||
|
||||
info("Opening context menu");
|
||||
|
||||
@ -24,20 +35,10 @@ add_task(async function() {
|
||||
searchField.focus();
|
||||
await onFocus;
|
||||
|
||||
let onContextMenuOpen = toolbox.once("menu-open");
|
||||
synthesizeContextMenuEvent(searchField);
|
||||
await onContextMenuOpen;
|
||||
|
||||
let searchContextMenu = toolbox.doc.getElementById("toolbox-menu");
|
||||
ok(searchContextMenu,
|
||||
"The search filter context menu is loaded in the rule view");
|
||||
|
||||
let cmdUndo = searchContextMenu.querySelector("#editmenu-undo");
|
||||
let cmdDelete = searchContextMenu.querySelector("#editmenu-delete");
|
||||
let cmdSelectAll = searchContextMenu.querySelector("#editmenu-selectAll");
|
||||
let cmdCut = searchContextMenu.querySelector("#editmenu-cut");
|
||||
let cmdCopy = searchContextMenu.querySelector("#editmenu-copy");
|
||||
let cmdPaste = searchContextMenu.querySelector("#editmenu-paste");
|
||||
const onContextMenuPopup = once(searchContextMenu, "popupshowing");
|
||||
EventUtils.synthesizeMouse(searchField, 2, 2,
|
||||
{type: "contextmenu", button: 2}, win);
|
||||
await onContextMenuPopup;
|
||||
|
||||
is(cmdUndo.getAttribute("disabled"), "true", "cmdUndo is disabled");
|
||||
is(cmdDelete.getAttribute("disabled"), "true", "cmdDelete is disabled");
|
||||
@ -50,39 +51,24 @@ add_task(async function() {
|
||||
is(cmdPaste.getAttribute("disabled"), "", "cmdPaste is enabled");
|
||||
|
||||
info("Closing context menu");
|
||||
let onContextMenuClose = toolbox.once("menu-close");
|
||||
EventUtils.sendKey("ESCAPE", toolbox.win);
|
||||
await onContextMenuClose;
|
||||
const onContextMenuHidden = once(searchContextMenu, "popuphidden");
|
||||
searchContextMenu.hidePopup();
|
||||
await onContextMenuHidden;
|
||||
|
||||
info("Copy text in search field using the context menu");
|
||||
searchField.setUserInput(TEST_INPUT);
|
||||
searchField.select();
|
||||
|
||||
onContextMenuOpen = toolbox.once("menu-open");
|
||||
synthesizeContextMenuEvent(searchField);
|
||||
await onContextMenuOpen;
|
||||
|
||||
searchContextMenu = toolbox.doc.getElementById("toolbox-menu");
|
||||
cmdCopy = searchContextMenu.querySelector("#editmenu-copy");
|
||||
EventUtils.synthesizeMouse(searchField, 2, 2,
|
||||
{type: "contextmenu", button: 2}, win);
|
||||
await onContextMenuPopup;
|
||||
await waitForClipboardPromise(() => cmdCopy.click(), TEST_INPUT);
|
||||
|
||||
onContextMenuClose = toolbox.once("menu-close");
|
||||
EventUtils.sendKey("ESCAPE", toolbox.win);
|
||||
await onContextMenuClose;
|
||||
searchContextMenu.hidePopup();
|
||||
await onContextMenuHidden;
|
||||
|
||||
info("Reopen context menu and check command properties");
|
||||
|
||||
onContextMenuOpen = toolbox.once("menu-open");
|
||||
synthesizeContextMenuEvent(searchField);
|
||||
await onContextMenuOpen;
|
||||
|
||||
searchContextMenu = toolbox.doc.getElementById("toolbox-menu");
|
||||
cmdUndo = searchContextMenu.querySelector("#editmenu-undo");
|
||||
cmdDelete = searchContextMenu.querySelector("#editmenu-delete");
|
||||
cmdSelectAll = searchContextMenu.querySelector("#editmenu-selectAll");
|
||||
cmdCut = searchContextMenu.querySelector("#editmenu-cut");
|
||||
cmdCopy = searchContextMenu.querySelector("#editmenu-copy");
|
||||
cmdPaste = searchContextMenu.querySelector("#editmenu-paste");
|
||||
EventUtils.synthesizeMouse(searchField, 2, 2,
|
||||
{type: "contextmenu", button: 2}, win);
|
||||
await onContextMenuPopup;
|
||||
|
||||
is(cmdUndo.getAttribute("disabled"), "", "cmdUndo is enabled");
|
||||
is(cmdDelete.getAttribute("disabled"), "", "cmdDelete is enabled");
|
||||
@ -90,8 +76,4 @@ add_task(async function() {
|
||||
is(cmdCut.getAttribute("disabled"), "", "cmdCut is enabled");
|
||||
is(cmdCopy.getAttribute("disabled"), "", "cmdCopy is enabled");
|
||||
is(cmdPaste.getAttribute("disabled"), "", "cmdPaste is enabled");
|
||||
|
||||
const onContextMenuHidden = toolbox.once("menu-close");
|
||||
EventUtils.sendKey("ESCAPE", toolbox.win);
|
||||
await onContextMenuHidden;
|
||||
});
|
||||
|
@ -14,6 +14,18 @@ add_task(async function() {
|
||||
const {searchBox} = inspector;
|
||||
await selectNode("h1", inspector);
|
||||
|
||||
const win = inspector.panelWin;
|
||||
const searchContextMenu = toolbox.textBoxContextMenuPopup;
|
||||
ok(searchContextMenu,
|
||||
"The search filter context menu is loaded in the inspector");
|
||||
|
||||
const cmdUndo = searchContextMenu.querySelector("[command=cmd_undo]");
|
||||
const cmdDelete = searchContextMenu.querySelector("[command=cmd_delete]");
|
||||
const cmdSelectAll = searchContextMenu.querySelector("[command=cmd_selectAll]");
|
||||
const cmdCut = searchContextMenu.querySelector("[command=cmd_cut]");
|
||||
const cmdCopy = searchContextMenu.querySelector("[command=cmd_copy]");
|
||||
const cmdPaste = searchContextMenu.querySelector("[command=cmd_paste]");
|
||||
|
||||
emptyClipboard();
|
||||
|
||||
info("Opening context menu");
|
||||
@ -21,20 +33,10 @@ add_task(async function() {
|
||||
searchBox.focus();
|
||||
await onFocus;
|
||||
|
||||
let onContextMenuOpen = toolbox.once("menu-open");
|
||||
synthesizeContextMenuEvent(searchBox);
|
||||
await onContextMenuOpen;
|
||||
|
||||
let searchContextMenu = toolbox.doc.getElementById("toolbox-menu");
|
||||
ok(searchContextMenu,
|
||||
"The search filter context menu is loaded in the computed view");
|
||||
|
||||
let cmdUndo = searchContextMenu.querySelector("#editmenu-undo");
|
||||
let cmdDelete = searchContextMenu.querySelector("#editmenu-delete");
|
||||
let cmdSelectAll = searchContextMenu.querySelector("#editmenu-selectAll");
|
||||
let cmdCut = searchContextMenu.querySelector("#editmenu-cut");
|
||||
let cmdCopy = searchContextMenu.querySelector("#editmenu-copy");
|
||||
let cmdPaste = searchContextMenu.querySelector("#editmenu-paste");
|
||||
const onContextMenuPopup = once(searchContextMenu, "popupshowing");
|
||||
EventUtils.synthesizeMouse(searchBox, 2, 2,
|
||||
{type: "contextmenu", button: 2}, win);
|
||||
await onContextMenuPopup;
|
||||
|
||||
is(cmdUndo.getAttribute("disabled"), "true", "cmdUndo is disabled");
|
||||
is(cmdDelete.getAttribute("disabled"), "true", "cmdDelete is disabled");
|
||||
@ -47,40 +49,25 @@ add_task(async function() {
|
||||
is(cmdPaste.getAttribute("disabled"), "", "cmdPaste is enabled");
|
||||
|
||||
info("Closing context menu");
|
||||
let onContextMenuClose = toolbox.once("menu-close");
|
||||
EventUtils.sendKey("ESCAPE", toolbox.win);
|
||||
await onContextMenuClose;
|
||||
const onContextMenuHidden = once(searchContextMenu, "popuphidden");
|
||||
searchContextMenu.hidePopup();
|
||||
await onContextMenuHidden;
|
||||
|
||||
info("Copy text in search field using the context menu");
|
||||
searchBox.setUserInput(TEST_INPUT);
|
||||
searchBox.select();
|
||||
searchBox.focus();
|
||||
|
||||
onContextMenuOpen = toolbox.once("menu-open");
|
||||
synthesizeContextMenuEvent(searchBox);
|
||||
await onContextMenuOpen;
|
||||
|
||||
searchContextMenu = toolbox.doc.getElementById("toolbox-menu");
|
||||
cmdCopy = searchContextMenu.querySelector("#editmenu-copy");
|
||||
EventUtils.synthesizeMouse(searchBox, 2, 2,
|
||||
{type: "contextmenu", button: 2}, win);
|
||||
await onContextMenuPopup;
|
||||
await waitForClipboardPromise(() => cmdCopy.click(), TEST_INPUT);
|
||||
|
||||
onContextMenuClose = toolbox.once("menu-close");
|
||||
EventUtils.sendKey("ESCAPE", toolbox.win);
|
||||
await onContextMenuClose;
|
||||
searchContextMenu.hidePopup();
|
||||
await onContextMenuHidden;
|
||||
|
||||
info("Reopen context menu and check command properties");
|
||||
|
||||
onContextMenuOpen = toolbox.once("menu-open");
|
||||
synthesizeContextMenuEvent(searchBox);
|
||||
await onContextMenuOpen;
|
||||
|
||||
searchContextMenu = toolbox.doc.getElementById("toolbox-menu");
|
||||
cmdUndo = searchContextMenu.querySelector("#editmenu-undo");
|
||||
cmdDelete = searchContextMenu.querySelector("#editmenu-delete");
|
||||
cmdSelectAll = searchContextMenu.querySelector("#editmenu-selectAll");
|
||||
cmdCut = searchContextMenu.querySelector("#editmenu-cut");
|
||||
cmdCopy = searchContextMenu.querySelector("#editmenu-copy");
|
||||
cmdPaste = searchContextMenu.querySelector("#editmenu-paste");
|
||||
EventUtils.synthesizeMouse(searchBox, 2, 2,
|
||||
{type: "contextmenu", button: 2}, win);
|
||||
await onContextMenuPopup;
|
||||
|
||||
is(cmdUndo.getAttribute("disabled"), "", "cmdUndo is enabled");
|
||||
is(cmdDelete.getAttribute("disabled"), "", "cmdDelete is enabled");
|
||||
@ -89,10 +76,6 @@ add_task(async function() {
|
||||
is(cmdCopy.getAttribute("disabled"), "", "cmdCopy is enabled");
|
||||
is(cmdPaste.getAttribute("disabled"), "", "cmdPaste is enabled");
|
||||
|
||||
const onContextMenuHidden = toolbox.once("menu-close");
|
||||
EventUtils.sendKey("ESCAPE", toolbox.win);
|
||||
await onContextMenuHidden;
|
||||
|
||||
// We have to wait for search query to avoid test failure.
|
||||
info("Waiting for search query to complete and getting the suggestions");
|
||||
await inspector.searchSuggestions._lastQuery;
|
||||
|
@ -80,23 +80,21 @@ add_task(async function() {
|
||||
EventUtils.synthesizeMouseAtCenter(tag, {}, inspector.panelWin);
|
||||
});
|
||||
|
||||
async function checkTextBox(textBox, toolbox) {
|
||||
let textboxContextMenu = toolbox.doc.getElementById("toolbox-menu");
|
||||
ok(!textboxContextMenu, "The menu is closed");
|
||||
async function checkTextBox(textBox, {textBoxContextMenuPopup}) {
|
||||
is(textBoxContextMenuPopup.state, "closed", "The menu is closed");
|
||||
|
||||
info("Simulating context click on the textbox and expecting the menu to open");
|
||||
const onContextMenu = toolbox.once("menu-open");
|
||||
synthesizeContextMenuEvent(textBox);
|
||||
const onContextMenu = once(textBoxContextMenuPopup, "popupshown");
|
||||
EventUtils.synthesizeMouse(textBox, 2, 2, {type: "contextmenu", button: 2},
|
||||
textBox.ownerDocument.defaultView);
|
||||
await onContextMenu;
|
||||
|
||||
textboxContextMenu = toolbox.doc.getElementById("toolbox-menu");
|
||||
ok(textboxContextMenu, "The menu is now visible");
|
||||
is(textBoxContextMenuPopup.state, "open", "The menu is now visible");
|
||||
|
||||
info("Closing the menu");
|
||||
const onContextMenuHidden = toolbox.once("menu-close");
|
||||
EventUtils.sendKey("ESCAPE", toolbox.win);
|
||||
const onContextMenuHidden = once(textBoxContextMenuPopup, "popuphidden");
|
||||
textBoxContextMenuPopup.hidePopup();
|
||||
await onContextMenuHidden;
|
||||
|
||||
textboxContextMenu = toolbox.doc.getElementById("toolbox-menu");
|
||||
ok(!textboxContextMenu, "The menu is closed again");
|
||||
is(textBoxContextMenuPopup.state, "closed", "The menu is closed again");
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ devtools.jar:
|
||||
content/memory/index.xhtml (memory/index.xhtml)
|
||||
content/framework/toolbox-window.xul (framework/toolbox-window.xul)
|
||||
content/framework/toolbox-options.xhtml (framework/toolbox-options.xhtml)
|
||||
content/framework/toolbox.xul (framework/toolbox.xul)
|
||||
* content/framework/toolbox.xul (framework/toolbox.xul)
|
||||
content/framework/toolbox-init.js (framework/toolbox-init.js)
|
||||
content/framework/options-panel.css (framework/options-panel.css)
|
||||
content/framework/toolbox-process-window.html (framework/toolbox-process-window.html)
|
||||
|
@ -1579,7 +1579,13 @@ class JSTerm extends Component {
|
||||
}
|
||||
|
||||
onContextMenu(e) {
|
||||
this.props.serviceContainer.openEditContextMenu(e);
|
||||
// The toolbox does it's own edit menu handling with
|
||||
// toolbox-textbox-context-popup and friends. For now, fall
|
||||
// back to use that if running inside the toolbox, but use our
|
||||
// own menu when running in the Browser Console (see Bug 1476097).
|
||||
if (this.props.hud.isBrowserConsole) {
|
||||
this.props.serviceContainer.openEditContextMenu(e);
|
||||
}
|
||||
}
|
||||
|
||||
destroy() {
|
||||
|
@ -198,3 +198,76 @@ function createContextMenu(hud, parentNode, {
|
||||
}
|
||||
|
||||
exports.createContextMenu = createContextMenu;
|
||||
|
||||
/**
|
||||
* Return an 'edit' menu for a input field. This integrates directly
|
||||
* with docshell commands to provide the right enabled state and editor
|
||||
* functionality.
|
||||
*
|
||||
* You'll need to call menu.popup() yourself, this just returns the Menu instance.
|
||||
*
|
||||
* @returns {Menu}
|
||||
*/
|
||||
function createEditContextMenu() {
|
||||
const docshell = window.docShell;
|
||||
const menu = new Menu({
|
||||
id: "webconsole-menu",
|
||||
});
|
||||
menu.append(new MenuItem({
|
||||
id: "editmenu-undo",
|
||||
l10nID: "editmenu-undo",
|
||||
disabled: !docshell.isCommandEnabled("cmd_undo"),
|
||||
click: () => {
|
||||
docshell.doCommand("cmd_undo");
|
||||
},
|
||||
}));
|
||||
menu.append(new MenuItem({
|
||||
type: "separator",
|
||||
}));
|
||||
menu.append(new MenuItem({
|
||||
id: "editmenu-cut",
|
||||
l10nID: "editmenu-cut",
|
||||
disabled: !docshell.isCommandEnabled("cmd_cut"),
|
||||
click: () => {
|
||||
docshell.doCommand("cmd_cut");
|
||||
},
|
||||
}));
|
||||
menu.append(new MenuItem({
|
||||
id: "editmenu-copy",
|
||||
l10nID: "editmenu-copy",
|
||||
disabled: !docshell.isCommandEnabled("cmd_copy"),
|
||||
click: () => {
|
||||
docshell.doCommand("cmd_copy");
|
||||
},
|
||||
}));
|
||||
menu.append(new MenuItem({
|
||||
id: "editmenu-paste",
|
||||
l10nID: "editmenu-paste",
|
||||
disabled: !docshell.isCommandEnabled("cmd_paste"),
|
||||
click: () => {
|
||||
docshell.doCommand("cmd_paste");
|
||||
},
|
||||
}));
|
||||
menu.append(new MenuItem({
|
||||
id: "editmenu-delete",
|
||||
l10nID: "editmenu-delete",
|
||||
disabled: !docshell.isCommandEnabled("cmd_delete"),
|
||||
click: () => {
|
||||
docshell.doCommand("cmd_delete");
|
||||
},
|
||||
}));
|
||||
menu.append(new MenuItem({
|
||||
type: "separator",
|
||||
}));
|
||||
menu.append(new MenuItem({
|
||||
id: "editmenu-selectAll",
|
||||
l10nID: "editmenu-select-all",
|
||||
disabled: !docshell.isCommandEnabled("cmd_selectAll"),
|
||||
click: () => {
|
||||
docshell.doCommand("cmd_selectAll");
|
||||
},
|
||||
}));
|
||||
return menu;
|
||||
}
|
||||
|
||||
exports.createEditContextMenu = createEditContextMenu;
|
||||
|
@ -10,8 +10,7 @@ const ReactDOM = require("devtools/client/shared/vendor/react-dom");
|
||||
const { Provider } = require("devtools/client/shared/vendor/react-redux");
|
||||
|
||||
const actions = require("devtools/client/webconsole/actions/index");
|
||||
const { createEditContextMenu } = require("devtools/client/framework/toolbox-context-menu");
|
||||
const { createContextMenu } = require("devtools/client/webconsole/utils/context-menu");
|
||||
const { createContextMenu, createEditContextMenu } = require("devtools/client/webconsole/utils/context-menu");
|
||||
const { configureStore } = require("devtools/client/webconsole/store");
|
||||
|
||||
const { isPacketPrivate } = require("devtools/client/webconsole/utils/messages");
|
||||
@ -165,7 +164,7 @@ WebConsoleOutputWrapper.prototype = {
|
||||
|
||||
serviceContainer.openEditContextMenu = (e) => {
|
||||
const { screenX, screenY } = e;
|
||||
const menu = createEditContextMenu(window, "webconsole-menu");
|
||||
const menu = createEditContextMenu();
|
||||
// Emit the "menu-open" event for testing.
|
||||
menu.once("open", () => this.emit("menu-open"));
|
||||
menu.popup(screenX, screenY, { doc: this.owner.chromeWindow.document });
|
||||
|
@ -3,7 +3,7 @@
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
### This file contains the entities needed for the 'edit' menu
|
||||
### It's currently only used for the Browser Console and Developer Toolbox
|
||||
### It's currently only used for the Browser Console
|
||||
|
||||
editmenu-undo =
|
||||
.label = Undo
|
||||
|
Loading…
Reference in New Issue
Block a user