Bug 1550561 - Support edit context menu on HTML inputs in chrome documents. r=bgrins
☠☠ backed out by b5ed012d2b53 ☠ ☠
authorTim Nguyen <ntim.bugs@gmail.com>
Sun, 12 May 2019 13:45:53 +0000
changeset 532365 4b3945b758896f5153e61a1b84a2b3614a98021a
parent 532364 40377335c3b5597fef5a638ea42870039b34d34c
child 532369 b83d8a064f1694627e66f2dd3a683b66c350b3b3
child 532370 3a4913c11d873988958f0ecae58ab4ec90265884
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [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();
     }