Closed Bug 1688743 Opened 4 years ago Closed 2 months ago

menus.remove doesn't return an error when removing a non-existing menu item

Categories

(WebExtensions :: General, defect, P5)

defect

Tracking

(firefox136 fixed)

RESOLVED FIXED
136 Branch
Tracking Status
firefox136 --- fixed

People

(Reporter: fluks.github, Assigned: kernp25, Mentored)

References

()

Details

(Keywords: dev-doc-complete, good-first-bug)

Attachments

(2 files, 1 obsolete file)

Attached file menus-remove.tar.gz

menus.remove should return an error when a menu item can't be found for example, but it doesn't. I attached a test case where it should throw an error but it only prints undefined.

Firefox version: 85.0b9
Build ID: 20210114193053
User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:85.0) Gecko/20100101 Firefox/85.0

Bugbug thinks this bug should belong to this component, but please revert this change in case of error.

Component: Untriaged → Menus
Product: WebExtensions → Firefox
Component: Menus → General
Product: Firefox → WebExtensions

verified that we are not throwing, though docs suggest exactly this scenario should throw

Severity: -- → S4
Priority: -- → P3
Keywords: good-first-bug
Priority: P3 → P5
Mentor: rob

Just getting started with my first bug + setting up my dev env, I would like to work on this!

Hello! So I need a little help proceeding with this bug:

  1. I'm pretty sure the fix will be in browser\components\extensions\parent\ext-menus.js
  2. It looks like a logical place for its accompanying unit test would be in: browser\components\extensions\test\browser and the filename could be something like browser_ext_themes_menus.js

I was able to run the unit tests in this folder with: ./mach test toolkit/components/extensions/test/browser/browser.ini

Where I'm stuck:

  1. I noticed the attached unit test looks more like a geckoview unit test that would belong in the: mobile\android\geckoview\src\androidTest\assets\web_extensions\ folder
  2. I can't seem to figure out how to run tests in this folder locally
  3. I'm having doubts about whether I'm looking in the wrong spot because of the provided unit test
Flags: needinfo?(rob)

I'm sorry for not responding to the above message; if you're still interested please ping me and I'll get back to you.

To answer the above questions, this API is not supported on Android, so you don't need to touch any code in mobile/android/.

Note that menus.update has a similar issue: it silently fails to update the menu if the given menu ID is invalid. It should also throw instead. Let's update both for consistency. The relevant parts of the implementation to modify is at https://searchfox.org/mozilla-central/source/browser/components/extensions/parent/ext-menus.js#1409,1424

A good place to add tests would be at https://searchfox.org/mozilla-central/rev/f9139f56bbcc0d587966c007178910ea31df7d58/browser/components/extensions/test/browser/browser_ext_menus_errors.js#90-116

Flags: needinfo?(rob)
Assignee: nobody → kernp25
Status: NEW → ASSIGNED
Attachment #9442338 - Flags: approval-mozilla-beta?
Attachment #9442338 - Flags: approval-mozilla-beta? → approval-mozilla-beta-
Attachment #9442338 - Attachment is obsolete: true
Attachment #9443722 - Attachment description: Bug 1688743 - Make menus.update and menus.remove throw when menu item is not found. r?robwu → Bug 1688743 - Make menus.update and menus.remove throw when menu item is not found. r=robwu
Pushed by archaeopteryx@coole-files.de: https://hg.mozilla.org/integration/autoland/rev/2c5db6ac9fcb Make menus.update and menus.remove throw when menu item is not found. r=robwu
Status: ASSIGNED → RESOLVED
Closed: 2 months ago
Resolution: --- → FIXED
Target Milestone: --- → 136 Branch

The menus.update and menus.remove (and their aliases contextMenus.update and contextMenus.remove) now reject with an error instead ignoring non-existing menu items.

This should be documented in the MDN "Firefox 136 for developers" release notes, the BCD and the reference documentation.

Keywords: dev-doc-needed

Doc updates in:

Regressions: 1944505
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: