Skip to content
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 a JS API for a search provider to ask permission to set itself as the default provider #16270

Closed
petemill opened this issue Jun 8, 2021 · 2 comments · Fixed by brave/brave-core#8819

Comments

@petemill
Copy link
Member

petemill commented Jun 8, 2021

Test plan

Not on search.brave.com (negative test)

  1. Visit https://github.com
  2. Open dev tools / console (ex: F12)
  3. In console paste window.brave.getCanSetDefaultSearchProvider and hit enter
  4. You should get an error like Uncaught TypeError: Cannot read property 'getCanSetDefaultSearchProvider' of undefined
  5. Also try pasting in window.brave.setIsDefaultSearchProvider and hit enter
  6. You should get same error as step 4

On search.brave.com

Dev tools test

  1. Visit search.brave.com
  2. Open dev tools / console (ex: F12)
  3. In console paste window.brave.getCanSetDefaultSearchProvider and hit enter
  4. A function definition should show
  5. Also try pasting in window.brave.setIsDefaultSearchProvider and hit enter
  6. You should get similar output to step 4 (function definition showing)

Real test

courtesy of @kjozwiak

  1. Launch Brave
  2. Ensured that Google is set as default
  3. Open https://search.brave.com in a new tab (or https://search-dev.brave.com)
  4. Search Brave Browser
  5. Click on Set Default
  6. Check brave://settings/search
  7. Brave Search beta set as the default
  8. Search for Basic Attention Token via omnibox and Brave Search is being used

Description

The API should be limited to a specific set of URLs.

The API should contain 2 methods:

  • window.brave.getCanSetDefaultSearchProvider():
    --> Returns Promise<bool>: false if current site is the default provider or has asked > X times in current day or > Y times in total, or is in private / TOR context. Returns true otherwise.

  • window.brave.setIsDefaultSearchProvider():
    --> Returns void: Sets current site to be the default provider. Must be done inside user gesture. Internally checks same logic as getCanSetDefaultSearchProvider.

The API should be able to be disabled via feature flag / griffin.

@stephendonner
Copy link

stephendonner commented Jun 14, 2021

Verified PASSED using the inline testplan with build

Brave 1.27.62 Chromium: 91.0.4472.101 (Official Build) nightly (x86_64)
Revision af52a90bf87030dd1523486a1cd3ae25c5d76c9b-refs/branch-heads/4472@{#1462}
OS macOS Version 11.4 (Build 20F71)

Steps:

Not on search.brave.com (negative test)

  1. visited https://github.com
  2. opened dev tools / console (ex: F12)
  3. in console, pasted window.brave.getCanSetDefaultSearchProvider and hit enter
  4. confirmed I got an error Uncaught TypeError: Cannot read property "getCanSetDefaultSearchProvider" of undefined
  5. also pasted in window.brave.setIsDefaultSearchProvider and hit enter
  6. confirmed I got the same error as in step 4

On search.brave.com

  1. visited https://search.brave.com
  2. opened dev tools / console (ex: F12)
  3. in console, pasted window.brave.getCanSetDefaultSearchProvider and hit enter
  4. confirmed I saw a function definition
  5. also pasted in window.brave.setIsDefaultSearchProvider and hit enter
  6. confirmed I saw a function definition
github.com search.brave.com
Screen Shot 2021-06-14 at 11 45 52 AM Screen Shot 2021-06-14 at 11 48 36 AM

Verification passed on

<!--StartFragment-->
Brave | 1.26.63 Chromium: 91.0.4472.106&nbsp;(Official Build)&nbsp;(64-bit)
-- | --
Revision | 574f7b38e4e7244c92c4675e902e8f8e3d299ea7-refs/branch-heads/4472@{#1477}
OS | Windows&nbsp;10 OS Version 2004 (Build 19041.1052)

<!--EndFragment-->

Not on search.brave.com (negative test)

image

On search.brave.com

image


Verification passed on

Brave 1.26.63 Chromium: 91.0.4472.106 (Official Build) (64-bit)
Revision 574f7b38e4e7244c92c4675e902e8f8e3d299ea7-refs/branch-heads/4472@{#1477}
OS Ubuntu 18.04 LTS

Not on search.brave.com (negative test)

image

On search.brave.com

image

@stephendonner
Copy link

Verified PASSED using the inline testplan with Brave - Nightly 1.27.62, Chromium 91.0.4472.101 on Google Pixel XL, arm64.

Not on search.brave.com (negative test)

Steps:

  1. new profile
  2. launched Brave
  3. loaded brave://inspect/#devices on desktop Brave
  4. navigated to github.com on device
  5. clicked on inspect on desktop Brave
  6. in console, pasted window.brave.getCanSetDefaultSearchProvider and hit enter
    confirmed I got an error Uncaught TypeError: Cannot read property "getCanSetDefaultSearchProvider" of undefined
    also pasted in window.brave.setIsDefaultSearchProvider and hit enter
    confirmed I got the same error as in step 4

Screen Shot 2021-06-14 at 2 22 43 PM

On search.brave.com

Steps:

  1. new profile
  2. launched Brave
  3. loaded brave://inspect/#devices on desktop Brave
  4. visited https://search.brave.com
  5. opened dev tools / console (ex: F12)
  6. in console, pasted window.brave.getCanSetDefaultSearchProvider and hit enter
  7. confirmed I saw a function definition
  8. also pasted in window.brave.setIsDefaultSearchProvider and hit enter
  9. confirmed I saw a function definition

Screen Shot 2021-06-14 at 2 22 12 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment