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

Ensure tabs are not created in hidden window and correct window is focused #13866

Merged
merged 1 commit into from
Apr 19, 2018

Conversation

petemill
Copy link
Member

@petemill petemill commented Apr 19, 2018

Fix #13859
Fix #13860
Fix #13865

Makes sure tabs are created in a shown window, or creates a new window, that the window is focused, and if the shown window is minimized, then that window is restored.

Fixes for the following scenarios...

  • There are no windows open
  • There are only minimized windows open

...with the following actions:

  • Brave is default browser and link clicked in another application
  • macOS dock icon is clicked
  • 'Brave' menu actions such as 'New Tab' or 'About Brave'

About the code

  • Replaces custom code in cmdLine.js with store action: notably the feature of CREATE_TAB_REQUESTED which will create a window for the tab if it does not exist. That was introduced recently for a very similar issue (with menu items) in Menu items which need a window will create / show one if needed #13749.
  • Introduces new similar action (FOCUS_OR_CREATE_MENU) for when we want to focus any existing window, or create a new one if it does not exist (when the macOS dock icon is clicked and the app receives the activate event).
  • Fixes the window api getActiveWindow to return a minimized window if there are no un-minimized windows. The risk here should be minimal since this api method is only used by these two actions (menu items, cli URLs, and URLs from external applications).

Test plan:

Browser must be set as default. If testing from source, the best way is to create a build CHANNEL=dev npm run build-package, run that, and set it as default.

  • Click URL link in external application and ensure that tab opens in an active window, and the window is focused with the following scenarios:
    - 1 window open
    - 2+ windows open
    - 0 windows open
    - 1 minimized window open
    - 1 minimized window open and 1 non-minimized window open
    - Application exited
  • macOS: click dock icon, ensure window is focused or created:
    - 1 window open
    - 2+ windows open
    - 0 windows open
    - 1 minimized window open
    - 1 minimized window open and 1 non-minimized

Even though the reported issues were macOS only, this test plan should be carried out on other platforms to ensure no regressions.

Submitter Checklist:

  • 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).
  • Tagged reviewers and labelled the pull request as needed.
  • Request a security/privacy review as needed. (Ask a Brave employee to help if you cannot access this document.)

Reviewer Checklist:

  • Request a security/privacy review as needed if one was not already requested.

Tests

  • Adequate test coverage exists to prevent regressions
  • Tests should be independent and work correctly when run individually or as a suite ref
  • New files have MPL2 license header

…cused

Fix #13859
Fix #13860
Fix #13865

Makes sure tabs are created in a shown window, or creates a new window, that the window is focused, and if the shown window is minimized, then that window is restored.
Fixes for the following scenarios...:
    - There are no windows open
    - There are only minimized windows open
...For the following actions:
    - Brave is default browser and link clicked in another application
    - macOS dock icon is clicked
    - 'Brave' menu actions such as 'New Tab' or 'About Brave'

Test plan:
Browser must be set as default. If testing from source, the best way is to create a build `CHANNEL=dev npm run build-package`, run that, and set it as default.
    - Click URL link in external application
      - Ensure that tab opens in an active window, and the window is focused with the following scenarios:
        - 1 window open
        - 2+ windows open
        - 0 windows open
        - 1 minimized window open
        - 1 minimized window open and 1 non-minimized window open
        - Application exited
      - macOS: click dock icon, ensure window is focused or created:
        - 1 window open
        - 2+ windows open
        - 0 windows open
        - 1 minimized window open
        - 1 minimized window open and 1 non-minimized

Even though the reported issues were macOS only, this test plan should be carried out on other platforms to ensure no regressions.
@petemill petemill added regression 0.22.x issue first seen in 0.22.x labels Apr 19, 2018
@petemill petemill added this to the 0.22.x w/ Chromium 66 milestone Apr 19, 2018
@petemill petemill self-assigned this Apr 19, 2018
@codecov-io
Copy link

codecov-io commented Apr 19, 2018

Codecov Report

Merging #13866 into master will decrease coverage by 0.06%.
The diff coverage is 2.5%.

@@            Coverage Diff             @@
##           master   #13866      +/-   ##
==========================================
- Coverage   56.63%   56.56%   -0.07%     
==========================================
  Files         283      283              
  Lines       28848    28885      +37     
  Branches     4784     4786       +2     
==========================================
+ Hits        16338    16339       +1     
- Misses      12510    12546      +36
Flag Coverage Δ
#unittest 56.56% <2.5%> (-0.07%) ⬇️
Impacted Files Coverage Δ
js/constants/appConstants.js 100% <ø> (ø) ⬆️
app/cmdLine.js 39.47% <0%> (-1.65%) ⬇️
js/actions/appActions.js 19.03% <0%> (-0.11%) ⬇️
app/browser/windows.js 32.58% <0%> (-0.86%) ⬇️
app/common/commonMenu.js 54% <0%> (ø) ⬆️
app/browser/reducers/tabsReducer.js 37.56% <0%> (-0.5%) ⬇️
app/browser/reducers/windowsReducer.js 77.39% <11.11%> (-2.14%) ⬇️

Copy link
Contributor

@NejcZdovc NejcZdovc left a comment

Choose a reason for hiding this comment

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

++ test plan is working and code looks good to me

@NejcZdovc NejcZdovc merged commit 622ef4b into master Apr 19, 2018
NejcZdovc added a commit that referenced this pull request Apr 19, 2018
Ensure tabs are not created in hidden window and correct window is focused
NejcZdovc added a commit that referenced this pull request Apr 19, 2018
Ensure tabs are not created in hidden window and correct window is focused
@NejcZdovc
Copy link
Contributor

master 622ef4b
0.23 6346017
0.22 48d809e

@petemill I didn't merge into 0.22.x-c66 because there is a conflict and it looks like that some code doesn't exists that was added here #13749 which is targeted for 0.22 v3. What should we do here? Push it back into v3 or will work correctly without this PR?

@petemill
Copy link
Member Author

Thanks for the merge @NejcZdovc. #13749 will be uplifted to 0.22.x-c66 along with this one. I can do those cherry-picks for that branch.

petemill pushed a commit that referenced this pull request Apr 19, 2018
Ensure tabs are not created in hidden window and correct window is focused
@petemill
Copy link
Member Author

0.22.x-c66 1339f92

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
0.22.x issue first seen in 0.22.x regression
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants