Closed Bug 1588616 Opened 5 years ago Closed 4 years ago

ext-menus.js doesn't properly call withLastError (null instead of caller)

Categories

(WebExtensions :: General, defect, P3)

defect

Tracking

(firefox87 fixed)

RESOLVED FIXED
87 Branch
Tracking Status
firefox87 --- fixed

People

(Reporter: mkaply, Assigned: digitalsimboja, Mentored)

References

Details

(Keywords: good-first-bug)

Attachments

(2 files, 1 obsolete file)

ext-menus.js calls withLastError explicitly with a null instead of a caller:

https://searchfox.org/mozilla-central/rev/17756e2a5c180d980a4b08d99f8cc0c97290ae8d/browser/components/extensions/child/ext-menus.js#148

As a result, you can't trace errors in adding menus back from where they came from

Per kmag:

John-Galt
It can probably just pass context.getCaller()
John-Galt
And maybe withLastError should assert that caller is not null :/

Priority: -- → P3

To fix this bug, save context.getCaller() in a variable at the start of the create method and pass that value instead of null.

https://searchfox.org/mozilla-central/rev/165e8d8f80c02605c2f3e89c5de462abfce91c32/browser/components/extensions/child/ext-menus.js#131,148

Mentor: rob
Keywords: good-first-bug

Hi Rob, I'm an Outreachy applicant. Can I fix this bug? Thank you.

Flags: needinfo?(rob)
Assignee: nobody → italooko
Status: NEW → ASSIGNED

I'll comment on the patch.

Flags: needinfo?(rob)

Depends on D93290

Attachment #9181162 - Attachment description: Bug 1588616 - Change create method passing context.getCaller to context.withLastError. r=robwu → Bug 1588616 - Tests added to ext-menus. r=robwu
Attachment #9181162 - Attachment description: Bug 1588616 - Tests added to ext-menus. r=robwu → Bug 1588616 - Fix ext-menus.js and tests added. r=robwu
Attachment #9182841 - Attachment is obsolete: true

Hi italo! Just checking in since we haven't heard from you in awhile. How's it going with this bug? Is there anything we can do to help you get unstuck?

Flags: needinfo?(libertadoritos)

Cleared needinfo and assignee because of patch stale for longer than a month.

Assignee: libertadoritos → nobody
Status: ASSIGNED → NEW
Flags: needinfo?(libertadoritos)

Hello,

I am new to Open Source and would like to take on this bug if it is still open and unassigned.
can I work on it?

I would appreciate all guidance.

Thanks

Hi Sunday, go for it! You can find tips for getting started at https://wiki.mozilla.org/WebExtensions/Contribution_Onramp. Rob also describes how to fix the bug in comment #1. :)

Feel free to share your patch as soon as you would like some feedback! We'll assign the bug to you once you have the patch up.

Alright, I am taking it on

Dear Rob,

I am trying to work on the bug but yet to reproduce the error on my local machine.
Could you direct me if I am mistaking something when I ran the test

./mach test browser/components/extensions/test/browser/browser_ext_menus.js

I could not trace out the error on the output. Kindly point me to the right tests to use so I can be in the right track.
However, I am going over the web extension documentation.

Thanks and appreciate

Flags: needinfo?(rob)

There are no existing unit tests for this bug. A previous contributor has started a patch at https://phabricator.services.mozilla.com/D93290?id=356450 which shows the correct logic in the test, but I added some review comments that have not been addressed.

To reproduce locally and manually (in the browser), outside of a unit test:

  1. Load an extension with the menus permission.
  2. Open the global Browser Console (Ctrl-Shift-J).
  3. Call the browser.menus.create API with invalid parameters (e.g. by creating a menu with the same ID twice, like the linked unit test does).
  4. Look at the global browser console, and see if there is a useful stack trace associated with the printed error (Unchecked lastError value: ID already exists: ...")
    (currently, there is no useful stack trace that references the extension file; the desired result is that there is)
Flags: needinfo?(rob)
Assignee: nobody → digitalsimboja
Status: NEW → ASSIGNED
Flags: needinfo?(rob)
Flags: needinfo?(rob)
Attachment #9199983 - Attachment description: Bug 1588616 - Fix ext-menus.js to call withLastError with caller r=robwu → Bug 1588616 -Test case added Fix ext-menus.js to call withLastError with caller r=robwu
Flags: needinfo?(rob)

When you update the patch, I'll automatically be notified. There is no need to use needinfo too. It results in two extra emails on top of the one that I get from Phabricator.

Flags: needinfo?(rob)

Okay noted

Dear Rob,
Just to let you know that I am applying for this round of Outreachy. I would love to hear if you are planning on proposing a project. I will be very glad to make contributions on your Outreachy project. For this particular bug fix, I shall be sending my unit test with your revisions tonight.

I am currently mentoring an Outreachy project, but am not planning to participate in the next round.

I have updated the patch.

Okay I would appreciate if you know of mentors participating so I can also get in touch with them

Thanks

I have added your review.
Please check.
Thanks

Pushed by archaeopteryx@coole-files.de:
https://hg.mozilla.org/integration/autoland/rev/ea9a50dbf12f
Test case added Fix ext-menus.js to call withLastError with caller  r=robwu

Dear Rob,
My attention is drawn to this test by one of the contributors

https://treeherder.mozilla.org/logviewer?job_id=329331725&repo=autoland&lineNumber=1931

Seems the test failed on Andriod. Is this a device restriction? How do I proceed to resolve this?
I appreciate all guides.
Thanks

Flags: needinfo?(digitalsimboja)

I have skipped the testcase for Andriod since the menus API isn't yet supported on Firefox for Android based on the compatibility table.

Flags: needinfo?(rob)

I'm following both this bug and the Phabricator revision. Since we're already discussing on Phabricator, there is no need for a needinfo here as well, it just results in extra emails (and some noise here). Comments about the implementation direction can be posted on the Phabricator revision.

Flags: needinfo?(rob)
Pushed by archaeopteryx@coole-files.de:
https://hg.mozilla.org/integration/autoland/rev/3b9a479c0705
Test case added Fix ext-menus.js to call withLastError with caller  r=robwu
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 87 Branch
Regressions: 1692349

Congrats on landing this patch, Sunday! 🎉 Your contribution has been added to our recognition wiki at https://wiki.mozilla.org/Add-ons/Contribute/Recognition.

Welcome onboard, and good luck with your Outreachy application! While the Add-ons Team isn't running any projects for the upcoming round, you may want to take a look at other projects Mozilla is sponsoring. They are listed on the Outreachy website. :)

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