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

Allow for assigning of default search engine based on country #15154

Merged
merged 5 commits into from
Sep 8, 2018
Merged

Allow for assigning of default search engine based on country #15154

merged 5 commits into from
Sep 8, 2018

Conversation

bsclifton
Copy link
Member

@bsclifton bsclifton commented Sep 5, 2018

Fixes #14647

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.)

Test Plan:

(perform steps on Windows, macOS, and Linux)

Changing the country

macOS

Settings > Language & Region
screen shot 2018-09-05 at 8 58 25 am

Windows

  • Open up settings (on Windows 10, click the notifications icon in bottom right and then pick All settings)
  • Pick "Time & Language"
  • Pick "Region & Language"
    settings

You'll also need to go into Control Panel > Region and set the Format
screen shot 2018-09-06 at 1 36 11 pm

Linux

  • Push the Windows key and search for region (or language)

  • Pick Language Support
    screen shot 2018-09-05 at 9 10 20 am

  • Install other languages as needed

  • Pick the appropriate language (all choices should show country)
    screen shot 2018-09-05 at 9 10 57 am

  • reboot for changes to take effect

Setup

  1. Check out source code; do a fresh rebuild
  2. Either Delete or move out of the way your brave-development profile directory
  3. Uncomment these two lines: https://github.com/bsclifton/browser-laptop/blob/222c500977f77a6de63eaa587c4cc11f5d820505/js/constants/config.js#L48-L49

Test default (new install - country doesn't match any config entry)

  1. Delete your brave-development profile directory
  2. Set your country to USA
  3. Launch browser (npm run watch / npm start)
  4. Verify default search is Google
  5. Open a new PRIVATE tab and ensure DuckDuckGo option DOES show on private tab. Try a search and verify it uses the proper engine
  6. Open a new PRIVATE TOR tab and ensure DuckDuckGo DOES show (is mentioned). Try a search and verify it uses the proper engine
  7. Go to about:preferences#search
  8. Verify your default search engine is Google
  9. Verify the "Private tab" options show up on the page
  10. Exit Brave
  11. Set your country back to original setting

Test country matches a config entry (new install)

  1. Delete your brave-development profile directory
  2. Set your country as France
  3. Re-launch browser
  4. Verify default search is GitHub
  5. Open a new PRIVATE tab and ensure DuckDuckGo option DOES NOT show on private tab. Try a search and verify it uses the proper engine
  6. Open a new PRIVATE TOR tab and ensure DuckDuckGo DOES NOT show (is NOT mentioned). Try a search and verify it uses the proper engine
  7. Go to about:preferences#search
  8. Verify your default search engine is GitHub
  9. Verify the "Private tab" options DO NOT show up on the page
  10. Change your default to Google
  11. Verify that "Private tab" options DO show up
  12. Exit Brave
  13. Set your country back to original setting

Ensure default not changed for existing profile

  1. Delete your brave-development profile directory
  2. Set your country as USA
  3. Launch browser
  4. Verify default search is Google
  5. Exit Brave
  6. Set your country as France
  7. Re-launch brave
  8. Ensure default search engine is still Google (no change made)
  9. Exit Brave
  10. Set your country back to original setting

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

darkdh
darkdh previously approved these changes Sep 5, 2018
Depends on brave/muon#647 being merged / available

Fixes #14647

- Don't show private tab options on search tab (preferences) if default browser was set
- Re-show DDG after user manually changes search engine
- Use default search engine for private/tor tabs when search engine is defaulted.
  If user overrides, it'll fall back to DDG
@bsclifton
Copy link
Member Author

@darkdh made a few more changes - ready for re-review 😄

@LaurenWags
Copy link
Member

Test Cases + fix for context menu search lgtm on macOS 👍

@diracdeltas
Copy link
Member

with this PR there seems to be no way to use a different search engine in Tor mode than for regular browsing. is that intentional?

@bsclifton
Copy link
Member Author

@diracdeltas that is correct- it'll use the default search engine. However, if the user modifies their search engine preferences in any way, it'll change back to the default behavior (ex: DuckDuckGo is default for Tor- and DDG can also be default (up to user) for regular private tabs)

@diracdeltas
Copy link
Member

@bsclifton i see. i tried changing my default search engine to google, and the options for Use DDG in (Tor) Private Tabs appeared in about:preferences. However I did not see the switches in about:newtab in private or tor tabs until i restarted.

@bsclifton
Copy link
Member Author

@diracdeltas that is correct (and that is known; apologies for not calling it out). I wasn't sure if that was worth fixing or not

@kjozwiak
Copy link
Member

kjozwiak commented Sep 7, 2018

Went through the above STR that @bsclifton mentioned using Ubuntu 18.04 x64. Results:

  • Case 1 - Test default (new install - country doesn't match any config entry) - PASSED
  • Case 2 - Test country matches a config entry (new install) (using German) - PASSED
  • Case 2 - Test country matches a config entry (new install) (using France) - PASSED
  • Case 3 - Ensure default not changed for existing profile (using German) - PASSED
  • Case 3 - Ensure default not changed for existing profile (using France) - PASSED

Issues:

Only issue that I managed to find was the one @diracdeltas mentioned above regarding the DDG snippet not appearing under PT when the search engine is switched. However, once you either restart or toggle Use DDG by default for search in Private Tabs, the snippet will appear under both PT and Tor PT.

@bsclifton
Copy link
Member Author

@kjozwiak @diracdeltas I fixed the issue with private & tor tabs not immediately re-showing the DDG options (ended up being a lot easier than I had thought 😄). Ready for re-review! 👍

- only change value if going from false=>true (should only be called once)
- private tab options are reflected immediately on new private/tor tabs

Auditors: @kjozwiak, @diracdeltas
This has the new electron.app.getCountryName functionality (with Chromium 68)

Auditors: @darkdh
@bsclifton
Copy link
Member Author

@kjozwiak @LaurenWags @srirambv I also updated this to use Chromium 68 (instead of Chromium 69). Can we give the methods a spot check? 😄

@kjozwiak
Copy link
Member

kjozwiak commented Sep 7, 2018

Awesome, thanks @bsclifton! We'll recheck the above cases on all the platforms with the new updated PR that uses C68 instead of C69 👍

@srirambv
Copy link
Collaborator

srirambv commented Sep 7, 2018

Still an issue on Windows. Verified setting France as region and system format still shows as Google. Same for Germany as well.

Issue reproduced by @GeetaSarvadnya as well

Recording of the issue: https://drive.google.com/open?id=1eXV-j8An1efM44rQUyK_-Y_-PNPIVmrr

@LaurenWags
Copy link
Member

LaurenWags commented Sep 7, 2018

Using Test Cases/STR from description, verified on macOS 10.12.6 x64 with commit 7d5264d

Results:

  • Case 1 - Test default (new install - country doesn't match any config entry) - PASSED
  • Case 2 - Test country matches a config entry (new install) (using Germany) - PASSED
    • Verified context menu issue (found previously) still works as expected
    • Verified Private & Tor tabs immediately re-show the DDG options
    • Verified muon version 8.0.10
  • Case 2 - Test country matches a config entry (new install) (using France) - PASSED
    • Verified context menu issue (found previously) still works as expected
    • Verified Private & Tor tabs immediately re-show the DDG options
    • Verified muon version 8.0.10
  • Case 3 - Ensure default not changed for existing profile (using Germany) - PASSED
  • Case 3 - Ensure default not changed for existing profile (using France) - PASSED

@kjozwiak
Copy link
Member

kjozwiak commented Sep 7, 2018

Still an issue on Windows. Verified setting France as region and system format still shows as Google. Same for Germany as well.

Issue reproduced by @GeetaSarvadnya as well

Recording of the issue: https://drive.google.com/open?id=1eXV-j8An1efM44rQUyK_-Y_-PNPIVmrr

Same results on my machine as the above. Seems like this PR doesn't work on Win for some reason but works fine on macOS & Ubuntu. @srirambv also mentioned that he tried changing the language of the OS but that didn't work either.

@btlechowski
Copy link
Contributor

Tested on Ubuntu 17.10 on commit 7d5264d

Default Search engine - new install - PASS

Search engine for Germany/France - new install
- normal tab URL search - PASS
- normal tab Context Menu search - PASS
- private tab URL search - PASS
- private tab Context Menu search - PASS
- private tab duckduckgo not shown on new tab - PASS
- private tor tab URL search - PASS
- private tor tab Context Menu search - PASS

Search engine for Germany/France - new install - changed search engine to google in about:preferences#search
- normal tab URL search - PASS (google)
- normal tab Context Menu search - PASS (google)
- private tab URL search - PASS (google)
- private tab Context Menu search - PASS (google)
- private tab duckduckgo shown on new tab - PASS
- private tor tab URL search - PASS (duckduckgo)
- private tor tab Context Menu search - PASS (duckduckgo)

Search engine for Germany/France - update
- normal tab URL search - PASS (google)
- normal tab Context Menu search - PASS (google)
- private tab URL search - PASS (google)
- private tab Context Menu search - PASS (google)
- private tab duckduckgo shown on new tab - PASS
- private tor tab URL search - PASS (duckduckgo)
- private tor tab Context Menu search - PASS (duckduckgo)

@bsclifton
Copy link
Member Author

@srirambv @kjozwiak @GeetaSarvadnya fixed the issue on Windows! Chrome 68 was putting a unicode null terminator (\u0000) at the end of the string, which caused a comparison problem. 2366ee1 removes this with RegEx

We didn't see it with previous code because that was using Chromium 69 (which must have changed this)

@srirambv
Copy link
Collaborator

srirambv commented Sep 7, 2018

Verified the following scenarios on Windows
Region: France

  1. Clean install from source
  2. Set System Country and Format to France
  3. Open a new tab and search, uses YouTube as default search engine
  4. Highlight a text and search from context menu, opens a YT page with highlighted term as search term
  5. Open a private tab and search, uses YT as default search engine, Context menu search used YT as well in a new private tab
  6. Open a Tor private tab and search, uses YT as default search engine, Context menu search in Tor PT opens a new Tor tab with YT as default search engine
  7. Open about:preferences#search, no private tabs search options is shown
  8. Change default search engine to other, private tab search options shows up
  9. Change back default search engine to YT, private tab search engine is retained

Region: Germany

  1. Clean install from source
  2. Set System Country and Format to Germany
  3. Open a new tab and search, uses GitHub as default search engine
  4. Highlight a text and search from context menu, opens a GH page with highlighted term as search term
  5. Open a private tab and search, uses GH as default search engine, Context menu search used GH as well in a new private tab
  6. Open a Tor private tab and search, uses GH as default search engine, Context menu search in Tor PT opens a new Tor tab with GH as default search engine
  7. Open about:preferences#search, no private tabs search options is shown
  8. Change default search engine to other, private tab search options shows up
  9. Change back default search engine to GH, private tab search engine is retained

Region: US

  1. Clean install from source
  2. Set system country and format to US
  3. Normal tab uses Google as search engine. Context menu search opens google in a new tab
  4. Private tab uses Google as search engine. Context menu search opens google in a private tab
  5. Tor PT uses Google as search engine. Context menu search opens google in a new Tor private tab
  6. Open about:preferences#search, private tabs search options is shown
  7. Change default search engine to other, private tab search options is retained

Copy link
Collaborator

@srirambv srirambv left a comment

Choose a reason for hiding this comment

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

++ works on Windows now

@bsclifton bsclifton merged commit f0c9489 into brave:master Sep 8, 2018
@bsclifton bsclifton deleted the get-country-name branch September 8, 2018 05:55
bsclifton added a commit that referenced this pull request Sep 8, 2018
Allow for assigning of default search engine based on country
bsclifton added a commit that referenced this pull request Sep 8, 2018
Allow for assigning of default search engine based on country
@bsclifton
Copy link
Member Author

master f0c9489
0.24.x 4522810
0.23.x 31c46fb

bsclifton added a commit that referenced this pull request Sep 8, 2018
Allow for assigning of default search engine based on country
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants