-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create right-click menu #284
Open
fkneist
wants to merge
11
commits into
browserpass:master
Choose a base branch
from
fkneist:feature/right-click-menu-2
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
0d52930
Create right-click menu
fkneist 8874b79
Don't show menu entry when there are zero matching logins
fkneist 646c7e5
Static menu title
fkneist 3a7f61d
trow error + fix docs
fkneist 025c98e
Fix slow load & tab switch issue
fkneist fcc3d39
Update GIF
fkneist 7aaf9c4
Merge branch 'master' of github.com:fkneist/browserpass-extension int…
fkneist 48a3d35
Cover edge cases for context menu creation
fkneist 434affd
Handle cache expired
fkneist f880d43
Refactor
fkneist f9b23ee
Adjust inline documentation
fkneist File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While testing I managed to get some errors in the console when I was opening a new tab, which is because of concurrent attempts to recreate context menu. Here's what happens:
createContextMenu
isasync
, so by calling it here we don't really block browser, there's no way of knowing when the function completes. In the beginning ofcreateContextMenu
we first remove the context menu and then try to recreate it. At the same time,chrome.tabs.onActivated
will get called, in turn callingcreateContextMenu
in parallel. The previous run has just created the parent menu, this run removes it, and then the previous run tries to create children to a now gone parent, and crashes.Of course one way to reduce the chances of a crash is to move
chrome.contextMenus.removeAll()
from the beginning of the function to as much later as possible - but this will not entirely eliminate the problem, but rather just reduce its chances.Another problem is that here you actually call
createContextMenu
only oncomplete
event - I understand why you did it, but it presents a problem on slow websites. I open github.com and my context menu is filled with entries. I then go in this tab to some very slow website, which loads a ton of images, and socomplete
event will only fire in say 5 seconds. During the first 5 seconds if I right click, I will still see entries for github.I propose to repeat what
updateMatchingPasswordsCount
function does:complete
isRefreshing
variable to prevent concurrent runschrome.tabs.onActivated
below, because badge seems to not need it...Let me know if it makes sense and if you have any questions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the thorough review, I can reproduce but haven't figured out how to solve it completely yet. I'll keep you posted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I figured it out 🎉. I call
createContextMenu
now on every status, but I needchrome.tabs.onActivated
to "kill" callbacks that are being called from an "old" tab.It's a bit hard to formulate, so here's an example: I'm in
tab A
with a slow page, I switch totab B
beforetab A
finished loading, whentab A
finally finished loading I don't want it to mess up the context menu.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fkneist Would simply including the origin in the callback be sufficient? That way you can just discard any calls that have a different origin than the currently active one.