mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-18 15:55:36 +00:00
Bug 1510182 - Load edit menu strings for each new toolbox window;r=Honza
Differential Revision: https://phabricator.services.mozilla.com/D13222 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
5fd1cd8036
commit
f4898fa9c5
@ -9,18 +9,20 @@
|
||||
const Menu = require("devtools/client/framework/menu");
|
||||
const MenuItem = require("devtools/client/framework/menu-item");
|
||||
|
||||
var stringsLoaded = false;
|
||||
// This WeakMap will be used to know if strings have already been loaded in a given
|
||||
// window, which will be used as key.
|
||||
const stringsLoaded = new WeakMap();
|
||||
|
||||
/**
|
||||
* Lazily load strings for the edit menu.
|
||||
*/
|
||||
function loadEditMenuStrings(win) {
|
||||
if (stringsLoaded) {
|
||||
if (stringsLoaded.has(win)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (win.MozXULElement) {
|
||||
stringsLoaded = true;
|
||||
stringsLoaded.set(win, true);
|
||||
win.MozXULElement.insertFTLIfNeeded("toolkit/main-window/editmenu.ftl");
|
||||
}
|
||||
}
|
||||
|
@ -197,3 +197,4 @@ skip-if = (os == 'linux' && bits == 32 && debug) # bug 1328915, disable linux32
|
||||
[browser_inspector_startup.js]
|
||||
[browser_inspector_switch-to-inspector-on-pick.js]
|
||||
[browser_inspector_textbox-menu.js]
|
||||
[browser_inspector_textbox-menu_reopen_toolbox.js]
|
||||
|
@ -0,0 +1,45 @@
|
||||
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
"use strict";
|
||||
|
||||
// Test that textbox context menu elements are still displayed correctly after reopening
|
||||
// the toolbox. Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1510182.
|
||||
|
||||
add_task(async function() {
|
||||
await addTab(`data:text/html;charset=utf-8,<div>test</div>`);
|
||||
|
||||
info("Testing the textbox context menu a first time");
|
||||
const {toolbox, inspector} = await openInspector();
|
||||
await checkContextMenuOnSearchbox(inspector, toolbox);
|
||||
|
||||
// Destroy the toolbox and try the context menu again with a new toolbox.
|
||||
await toolbox.destroy();
|
||||
|
||||
info("Testing the textbox context menu after reopening the toolbox");
|
||||
const {toolbox: newToolbox, inspector: newInspector} = await openInspector();
|
||||
await checkContextMenuOnSearchbox(newInspector, newToolbox);
|
||||
});
|
||||
|
||||
async function checkContextMenuOnSearchbox(inspector, toolbox) {
|
||||
// The same context menu is used for any text input.
|
||||
// Here we use the inspector searchbox for this test because it is always available.
|
||||
const searchbox = inspector.panelDoc.getElementById("inspector-searchbox");
|
||||
|
||||
info("Simulating context click on the textbox and expecting the menu to open");
|
||||
const onContextMenu = toolbox.once("menu-open");
|
||||
synthesizeContextMenuEvent(searchbox);
|
||||
await onContextMenu;
|
||||
|
||||
const textboxContextMenu = toolbox.doc.getElementById("toolbox-menu");
|
||||
info("Wait until menu items are rendered");
|
||||
const pasteElement = textboxContextMenu.querySelector("#editmenu-paste");
|
||||
await waitUntil(() => !!pasteElement.getAttribute("label"));
|
||||
|
||||
is(pasteElement.getAttribute("label"), "Paste", "Paste is visible and localized");
|
||||
|
||||
info("Closing the menu");
|
||||
const onContextMenuHidden = toolbox.once("menu-close");
|
||||
EventUtils.sendKey("ESCAPE", toolbox.win);
|
||||
await onContextMenuHidden;
|
||||
}
|
Loading…
Reference in New Issue
Block a user