Bug 1550561 - Support edit context menu on HTML inputs in chrome documents. r=bgrins
authorTim Nguyen <ntim.bugs@gmail.com>
Mon, 13 May 2019 05:56:52 +0000
changeset 535627 a219fd210a0422bf9eccbcdb4ff49f179e1b735e
parent 535626 22dc1f7f426beafab8b1bb4c5a8b4ba3528cb0b8
child 535628 db99095ae0b53c30927add34be3dc20a7bdcb52e
push id2082
push userffxbld-merge
push dateMon, 01 Jul 2019 08:34:18 +0000
treeherdermozilla-release@2fb19d0466d2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbgrins
bugs1550561
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1550561 - Support edit context menu on HTML inputs in chrome documents. r=bgrins Differential Revision: https://phabricator.services.mozilla.com/D30552
toolkit/content/editMenuOverlay.js
toolkit/content/tests/chrome/file_edit_contextmenu.xul
toolkit/content/tests/chrome/test_edit_contextmenu.html
--- a/toolkit/content/editMenuOverlay.js
+++ b/toolkit/content/editMenuOverlay.js
@@ -59,17 +59,17 @@ window.addEventListener("DOMContentLoade
 }, { once: true });
 
 // Support context menus on html textareas in the parent process:
 window.addEventListener("contextmenu", (e) => {
   const HTML_NS = "http://www.w3.org/1999/xhtml";
   // Note that there's not a risk of e.target being XBL anonymous content for <textbox> (which manages
   // its own context menu), because e.target will be the XBL binding parent in that case.
   let needsContextMenu = e.target.ownerDocument == document && !e.defaultPrevented && (
-    (e.target.localName == "textarea" && e.target.namespaceURI == HTML_NS)
+    (["textarea", "input"].includes(e.target.localName) && e.target.namespaceURI == HTML_NS)
     || e.target.closest("textbox[is='search-textbox']")
   );
 
   if (!needsContextMenu) {
     return;
   }
 
   let popup = document.getElementById("textbox-contextmenu");
--- a/toolkit/content/tests/chrome/file_edit_contextmenu.xul
+++ b/toolkit/content/tests/chrome/file_edit_contextmenu.xul
@@ -19,12 +19,12 @@
   <command id="cmd_copy" oncommand="goDoCommand('cmd_copy')"/>
   <command id="cmd_paste" oncommand="goDoCommand('cmd_paste')"/>
   <command id="cmd_delete" oncommand="goDoCommand('cmd_delete')"/>
   <command id="cmd_selectAll" oncommand="goDoCommand('cmd_selectAll')"/>
   <command id="cmd_switchTextDirection" oncommand="goDoCommand('cmd_switchTextDirection');"/>
 </commandset>
 
 <html:textarea />
-
+<html:input />
 <textbox is="search-textbox"/>
 
 </window>
--- a/toolkit/content/tests/chrome/test_edit_contextmenu.html
+++ b/toolkit/content/tests/chrome/test_edit_contextmenu.html
@@ -16,16 +16,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 
     async function runTest() {
       let win = window.open("file_edit_contextmenu.xul", "context-menu", "chrome,width=600,height=600");
       await new Promise(r => win.addEventListener("load", r, { once: true}));
       await SimpleTest.promiseFocus(win);
 
       const elements = [
         win.document.querySelector("textarea"),
+        win.document.querySelector("input"),
         win.document.querySelector("textbox[is='search-textbox']"),
       ];
       for (const element of elements) {
         await testElement(element, win);
       }
       SimpleTest.finish();
     }