-
-
Notifications
You must be signed in to change notification settings - Fork 13
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
fix(18194): fix trigger to close window when clicking "back to safety" #84
Conversation
Huh, interesting solution! It seems that this is an attempt to circumvent browser protections against programmatically closing a window, by "opening" the window programmatically first before closing it. I have seen references to this approach not working on some browser versions, but I don't know how that affects the range of versions we support. The e2e tests here are passing, but the test for this close button might not be sufficient. Right now that test is configured to ensure the length of history on the phishing warning page is exactly 1 so that the browser considers it as being opened programmatically. The reason this test didn't catch the bug in the extension is that today the extension redirects to this page, resulting in a history length of 2. We should try to ensure the test accurately captures this scenario, so that it can protect against future regressions. So I have 2 suggestions overall: consider browser support, and ensure the test is updated to catch this problem. |
with the change here, the tab is now left open, right? fca89f3 |
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.
Looks good. Just Mark's test suggestion to address
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.
LGTM
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.
LGTM!
Fixes: https://app.zenhub.com/workspaces/extension-client-team-63529dce65cbb100265a3842/issues/gh/metamask/metamask-extension/18194
Before:
Trials:
[user visits blocked page] -> [ location.href = "warning page URL" ] -> [warning page] -> [user clicks "Back to safety"] -> [window.open('location', '_self', '');window.close();] -> not working for Firefox
[user visits blocked page] -> [window.location.replace("warning page URL") ] -> [warning page] -> [user clicks "Back to safety"] -> [window.close() ] -> not working for Firefox
[user visits blocked page] -> [window.location.hrer("warning page URL") ] -> [warning page] -> [user clicks "Back to safety"] -> [open a new blank page] -> [document.visibilitystate === hidden, detect user has left previous warning page] -> [window.close() inactive page] -> not working for Firefox
Temporary solution:
Proposed by @danjm :
- [user visits blocked page] -> [ location.href = "warning page URL" ] -> [warning page] -> [user clicks "Back to safety"] -> [ location.replace(MM extension expanded view)] -> page stays open on a specific route, works for both browsers
After:
phishing.mov