Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Prevent duplicate separators for all context menu items #5869

Merged
merged 1 commit into from
Nov 29, 2016
Merged

Prevent duplicate separators for all context menu items #5869

merged 1 commit into from
Nov 29, 2016

Conversation

bsclifton
Copy link
Member

@bsclifton bsclifton commented Nov 28, 2016

  • Submitted a ticket for my issue if one did not already exist.
  • Used Github auto-closing keywords in the commit message.
  • Added/updated tests for this change (for new code or code which already has tests).
  • Ran git rebase -i to squash commits (if needed).

Includes all content PLUS a fix for a bug found in the original PR #5846
(which was reverted with #5867)

This PR fixes #5765

Auditors: @bbondy

Includes these changes

  • Added new sanitizeTemplateItems method to filter out bad entries
  • Moved menuUtil from app/browser => app/common
  • Moved some tests to match the new directory structure (ex: test/unit/app, instead of test/unit/lib)
  • Rename template functions in menuUtil and items in contextMenu.js to reinforce distinction between template items and electron menu items (the compiled template)
  • The new sanitize method is called in each method which builds a context menu

Automated test plan

  • npm run uitest -- --grep="bookmarksToolbar" (this was the one which had a failing test which I missed)
  • npm run unittest -- --grep="sanitizeTemplateItems"

Manual test plan

  • Launch Brave on Windows or Linux
  • Right click on each of the about pages and ensure there are no double separators (might be easy to go to about:about to launch each)
  • Try other context menus
    • Right clicking on a tab
    • right clicking on page
    • right clicking a bookmark / bookmark folder in the bookmarks toolbar
    • right clicking inside the downloads bar (shown after downloading an item)

Includes all content PLUS a fix for a bug found in the original PR #5846
(which was reverted with #5867)

This PR fixes #5765

Auditors: @bbondy

Includes these changes:
- Added new `sanitizeTemplateItems` method to filter out bad entries
- Moved `menuUtil` from `app/browser` => `app/common`
- Moved some tests to match the new directory structure (ex: `test/unit/app`, instead of `test/unit/lib`)
- Rename template functions in `menuUtil` and items in `contextMenu.js` to reinforce distinction between **template** items and **electron  menu** items (the compiled template)
- **The new sanitize method is called in each method which builds a context menu**

Automated test plan:
- `npm run uitest -- --grep="bookmarksToolbar"`
- `npm run unittest -- --grep="sanitizeTemplateItems"`

Manual test plan:
- Launch Brave on Windows or Linux
- Right click on each of the about pages and ensure there are no double separators (might be easy to go to about:about to launch each)
- Try other context menus
  - Right clicking on a tab
  - right clicking on page
  - right clicking a bookmark / bookmark folder in the bookmarks toolbar
  - right clicking inside the downloads bar (shown after downloading an item)
@bsclifton
Copy link
Member Author

Gonna check back in here tomorrow- hoping Travis CI loves the tests this go-around 😄

const expectedResult = [{label: 'lol'}]
assert.deepEqual(result, expectedResult)
})
it('always returns an array (even for one item)', function () {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This last test here is the one I added which failed (revealing the bug). The Array.reduce that I was doing would returning a non-array when only 1 entry exists (it now properly returns an array)

return Array.isArray(result)
? result
: [result]
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is the fix for the bug which led to the revert (which happened with #5867)

@bbondy
Copy link
Member

bbondy commented Nov 29, 2016

thanks!

@luixxiul
Copy link
Contributor

luixxiul commented Jan 16, 2017

I cleared the label and the milestone as this has been superseded with #6374

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

About pages right click context menu has an extra separator
3 participants