Add a "password" context to contextMenus API.

VERIFIED FIXED in Firefox 53


3 years ago
10 months ago


(Reporter: jura, Assigned: srivatsav1998, Mentored)


({dev-doc-complete, good-first-bug})

50 Branch

Firefox Tracking Flags

(firefox53 verified)


(Whiteboard: [contextMenus][triaged])


(2 attachments, 3 obsolete attachments)



3 years ago
User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:49.0) Gecko/20100101 Firefox/49.0
Build ID: 20160922113459

Steps to reproduce:

In a WebExtension I add a context menu using the following command:

chrome.contextMenus.create({"title": "Test menu item", "contexts": ["editable"]});

A sample extension is attached.

Actual results:

The menu item is displayed when I right mouse click on a regular input field, but the item is NOT displayed when clicking on a password input field.

Expected results:

The context menu item must be displayed for password input fields too. It works this way in Chrome.


3 years ago
Severity: normal → major
OS: Unspecified → Windows
Hardware: Unspecified → All


3 years ago
Component: Untriaged → WebExtensions: Untriaged
Product: Firefox → Toolkit
What's your use case for this? The core context menu code intentionally excludes password fields from the editable context, for a number of reasons. I suppose we could add a "password" context, to match the one we have internally.
Flags: needinfo?(jura)

Comment 2

3 years ago
I am creating an extension for an external password manager application. When clicking on a password input field, the context menu should contain items to save and fill out a password from the application.

The "editable" context works for password fields in Chrome. The proposed "password" context is fine for me. 

It's up to the Mozilla developers to decide either keep the Chrome compatibility or introduce the new "password" context.



3 years ago
Flags: needinfo?(jura)
This should be simple enough to implement. A "password" context needs to be added, similar to "editable", here:

And then a test here:
Mentor: kmaglione+bmo
Severity: major → normal
Component: WebExtensions: Untriaged → WebExtensions: Frontend
Ever confirmed: true
Keywords: good-first-bug
Summary: contextMenus: context "editable" is not applied for a password input fields → Add a "password" context to contextMenus API.
Whiteboard: [contextMenus]
Whiteboard: [contextMenus] → [contextMenus][triaged]

Comment 4

3 years ago
I would like to work on this bug
I assigned the bug to you.  Please feel free to ask if you need help with anything, either here or in #webextensions irc for quicker answers.
Assignee: nobody → srivatsav1998

Comment 6

3 years ago
I added the password context in the respective fields as mentioned.
Attachment #8812421 - Flags: review?(kmaglione+bmo)
This is a good start, and looks like it fixes the bug, but we also need a test to confirm that.

We need to add a password field to [1], and some test code similar to [2], but for a password field instead just a plain input.


Also, you might find submitting patches using mozreview [3] a better experience, especially if you plan to work on more bugs.

Comment on attachment 8812421 [details] [diff] [review]
Bug 1312466: Added a password context to contextMenus API.

Review of attachment 8812421 [details] [diff] [review]:

I don't think I have anything to add to what zombie already said. It looks good apart from the missing test.

Attachment #8812421 - Flags: review?(kmaglione+bmo)

Comment 9

3 years ago
Posted patch bug-1312466-fix-v2.patch (obsolete) — Splinter Review
I think I have added the required test for the contextMenu "password".
Attachment #8812527 - Flags: review?(kmaglione+bmo)
Attachment #8812421 - Attachment is obsolete: true
Comment on attachment 8812527 [details] [diff] [review]

Review of attachment 8812527 [details] [diff] [review]:

This is very nearly perfect, however, in addition to the two issues below, I apparently forgot one more place we need to change:

We need to copy over `onPassword` there the same way that we do `onEditableArea`.

Have you managed to test these changes locally? If not, you might want to try doing an artifact build[1] and running `mach mochitest browser/components/extensions/test/mochitest` or just `mach run` to launch an instance of Firefox.


::: browser/components/extensions/test/browser/browser_ext_contextMenus.js
@@ +205,5 @@
>    checkClickInfo(result);
> +  extensionMenuRoot = yield openExtensionContextMenu("#password");
> +  items = extensionMenuRoot.getElementsByAttribute("label", "password");
> +  is(items.length, 1, "contextMenu item for text input element was found (context=password)");


@@ +211,5 @@
> +  yield closeExtensionContextMenu(password);
> +  expectedClickInfo = {
> +    menuItemId: "ext-password",
> +    pageUrl: PAGE,
> +    editable: true,

In order for this to work, the following:

needs to be changed to something like `contextData.onEditableArea || contextData.onPassword`
Attachment #8812527 - Flags: review?(kmaglione+bmo)

Comment 11

3 years ago
Posted patch bug-1312466-fix-v3.patch (obsolete) — Splinter Review
I have made all the changes you have said and also tested it.
Attachment #8812527 - Attachment is obsolete: true
Attachment #8812734 - Flags: review?(kmaglione+bmo)
Comment on attachment 8812734 [details] [diff] [review]

Review of attachment 8812734 [details] [diff] [review]:

Great. Thanks!

Please add the checkin-needed keyword when you've fixed the whitespace issue (ESLint will reject the checkin otherwise), and are ready for this to land.

::: browser/components/extensions/ext-contextMenus.js
@@ +415,5 @@
>      }
>      let info = {
>        menuItemId:,
> +      editable: contextData.onEditableArea || contextData.onPassword,      

Nit: Please remove trailing whitespace.
Attachment #8812734 - Flags: review?(kmaglione+bmo) → review+

Comment 13

3 years ago
I have removed the trailing white space as mentioned. Push it to the try server once again.
Attachment #8812734 - Attachment is obsolete: true
Attachment #8813157 - Flags: review?(kmaglione+bmo)

Comment 14

3 years ago
Comment on attachment 8813157 [details] [diff] [review]

Please help me with the next steps since I am new to bug fixing
Attachment #8813157 - Flags: checkin?(kmaglione+bmo)
Comment on attachment 8813157 [details] [diff] [review]

Sorry, but it looks like you accidentally added changes to browser/config/mozconfig to this patch.

Generally, you shouldn't need to change that file directly. You can just create a `mozconfig` file in the top-level of your source tree and add the changes there.

I'll checkin the patch without those changes, though.
Attachment #8813157 - Flags: review?(kmaglione+bmo)
Attachment #8813157 - Flags: checkin?(kmaglione+bmo)

Comment 17

2 years ago
Last Resolved: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla53

Comment 18

2 years ago
I can reproduce this issue on Firefox 53.0a1 (20161121030224) under Windows 7 64-bit.

This issue is verified as fixed on Firefox 53.0a1 (20161127030208) under Windows 7 64-bit, after right clicking in the password field the context menu is displayed.
Here is a video:
Thank you so much, Srivatsav! Your work has been added to our contribution wiki at Welcome onboard!
I've noted this in 

Please let me know if this covers it!
Flags: needinfo?(tomica)
Thanks Will, this covers it, though maybe collapse all the contexts added in 53 to a single bullet?
Flags: needinfo?(tomica)


10 months ago
Product: Toolkit → WebExtensions
You need to log in before you can comment on or make changes to this bug.