Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Javascript window.close() not closing window #7796

Closed
JustinHook opened this issue Jul 28, 2023 · 2 comments · Fixed by #7797
Closed

Javascript window.close() not closing window #7796

JustinHook opened this issue Jul 28, 2023 · 2 comments · Fixed by #7797

Comments

@JustinHook
Copy link

Description:

The behaviour of the javascript window.close() function is not consistent with Brave Android or Safari iOS.

Steps to Reproduce

  1. Navigate to https://peach-tina-74.tiiny.site/ from a link. Not by pasting it into the browser address bar.

The contents of the website are:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
    <script>
        window.close();
    </script>
    Test
</body>
</html>

Actual result:

The website is shown and "Test" is displayed.

Expected result:

The website (tab) should be closed.

On both Brave Android and Safari iOS the website behaves as expected, the tab is closed.

Mozilla MDN states the following about window.close()1:

This method can only be called on windows that were opened by a script using the Window.open() method, or on top-level windows that have a single history entry.

The window in the tab was NOT opened by a script so it doesn't meet the first criteria, but I think it should meet the second as it is a new window being opened from a link.

Reproduces how often:

Every time - Tested on multiple phones.

Brave Version:

Version: 1.52.1 (23.7.11.14)
BraveCode: 1.52.129 (114.0.5735.198)

  • Can you reproduce this issue with the most recent build from TestFlight? Not tested
  • Can you reproduce this issue with the previous version of the current build from TestFlight? Not tested
  • Can you reproduce this issue with the current build from AppStore? Yes

Device details:

iPhone 14 (iOS 16.5.1)

Website problems only:

  • did you check with Brave Shields down? Yes
  • did you check in Safari/Firefox (WkWebView-based browsers)? Yes

Additional Information

Footnotes

  1. https://developer.mozilla.org/en-US/docs/Web/API/Window/close

@kylehickinson
Copy link
Collaborator

Likely related #6966

@hffvld
Copy link
Collaborator

hffvld commented Aug 24, 2023

Verified on iPhone 14 using version(s):

Device/OS: iPhone 14 [iOS 17.0]
Brave build: 1.57 (23.8.23.20)
BraveCore: 1.57.53 (116.0.5845.114)

STEPS:

  1. Launch Brave
  2. Navigate to https://github.com/brave/brave-ios/issues/7796
  3. In STR find the URL https://peach-tina-74.tiiny.site/ > Tap and hold > Open in New Tab > Verify
  4. Navigate to https://tunein.com or https://lookielooapp.com > Sign up/Sign in > Continue with Google
  5. Enter account credentials > Finish sign in > Verify

ACTUAL RESULTS:

  • Verified that the website (tab) https://peach-tina-74.tiiny.site/ is not opened
  • Verified that signing in with Google to websites like https://tunein.com or https://lookielooapp.com temporarily opens a new tab, and when the sign-in flow is done, that tab closes automatically

Sign.in.with.Google.mov

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

Successfully merging a pull request may close this issue.

3 participants