Commit Graph
1237 Commits
Author SHA1 Message Date
Mario Sanchez Prada bbf5fd3fe9 Remove deprecated DISALLOW_ macros from Brave-specific code
Macros such as DISALLOW_COPY_AND_ASSIGN() are deprecated since r711900
per style arbitration [1]. This commit replaces the macros with deleted
constructors and methods, which is preferred by the Google C++ Style
Guide [2][3].

Also remove unneeded "base/macros.h" #includes when possible.

This CL is created semi-mechanically with remove_disallow and
remove_base_macros [4].

[1]: https://groups.google.com/a/chromium.org/g/cxx/c/qwH2hxaEjac/m/TUKq6eqfCwAJ
[2]: https://chromium.googlesource.com/chromium/src/+/main/styleguide/c++/c++-dos-and-donts.md#explicitly-declare-class-copyability_movability
[3]: https://google.github.io/styleguide/cppguide.html#Copyable_Movable_Types
[4]: https://pkg.go.dev/go.timothygu.me/tools/cr/cmd

Chromium change:

https://chromium.googlesource.com/chromium/src.git/+/d002a3bee7ae75780b604d17df19291a3dd303fb

commit d002a3bee7ae75780b604d17df19291a3dd303fb
Author: Peter Boström <pbos@chromium.org>
Date:   Fri Nov 5 17:17:19 2021 +0000

    Remove DISALLOW_ macros from base/macros.h

    This removes DISALLOW_COPY(), DISALLOW_ASSIGN() and
    DISALLOW_COPY_AND_ASSIGN() from base/macros.h. PRESUBMITs are also
    updated to no longer check for these macros.

    IWYU removal is left as a separate change just in case this needs to be
    reverted.

    Bug: 1010217
2022-01-24 15:33:37 -05:00
Cepera f337a47cf8 Add chain validation to wallet_addEthereumChain api call (#11930) 2022-01-22 11:26:36 +03:00
Deep 005fa87ba8 Reformat code 2022-01-21 12:22:19 -05:00
Taher 952a9adb52 Merge pull request #11817 from brave/shields_panel_adblock_types
Added a method that returns AdblockMode
2022-01-20 07:35:30 -08:00
Taher be4df7d877 Added unit test for shields data controller 2022-01-19 16:47:14 -08:00
Brian R. Bondy 8c1fd1b113 Handle eth_sendTransaction data errors
Before it would crash because of a null parse data result that was being used

You can see the null check added in this commit with !tx_data_1559
2022-01-19 13:05:05 -05:00
Brian Clifton 45486c613b Fixes found as CI ran
- Fix for Android (VPN enabled flag check)
- Fix for iOS (include file was renamed)
- lint fixes
- initialize SKU feature for VPN tests
2022-01-15 00:18:52 -07:00
Brian R. Bondy 819279a801 Disallow deletion of ethereum properties
This is for webcompat with MetaMask.

The https://wallet.polygon.technology/ site does this when web3 is
defined:
```
void 0 !== n.ethereumProvider ?
  i = n.ethereumProvider :
  void 0 !== n.web3 &&
  n.web3.currentProvider &&
  (
    n.web3.currentProvider.sendAsync &&
    (n.web3.currentProvider.send = n.web3.currentProvider.sendAsync, delete n.web3.currentProvider.sendAsync),
```

We used to not include web3 at all, then this code is not hit and
there's no problem.
Recently we started including a web3 shim so that's why it's hit now.

Now that it's hit, we were failing because the Polygon site deleted
`window.ethereum.sendAsync` and then tried to use it.
We allowed this property deletion but MetaMask did not.

Instead of the fix in this commit (with the proxy method), I wanted to instead do this in `components/brave_wallet/renderer/brave_wallet_js_handler.cc`
but that won't work because it makes delete return false.

```
- ->Set(context, gin::StringToSymbol(isolate, "networkVersion"),
+ ->DefineOwnProperty(context, gin::StringToSymbol(isolate, "networkVersion", DontDelete),
        gin::StringToV8(isolate, std::to_string(networkVersion)))
         .Check();
```

The Polygon site won't load at all if it thinks it can't delete the
property.
2022-01-11 15:30:28 -05:00
Aleksey Khoroshilov 3b7488d8af Add ServiceWorker tests. 2021-12-30 11:20:32 +07:00
Aleksey Khoroshilov ced9ecda64 Use top frame origin if possible for resource pool keying. 2021-12-30 11:20:32 +07:00
Aleksey Khoroshilov 3bbbb0e322 Add browser tests for in-page WebSockets. 2021-12-30 11:20:31 +07:00
mkarolin b918803198 Disables HaTS.
Prevents HaTS service from showing any surveys.

Fixes brave/brave-browser#19685
2021-12-23 22:03:31 -05:00
Aleksey Khoroshilov 80c33b2aca Add ephemeral storage enabler to domain block throttler. 2021-12-16 19:18:02 +07:00
Mark Pilgrim 41dd7c974a Farble service and shared workers (#11452)
* Farble service and shared workers

* fewer patches

* use chromium_src override for mojom changes

* update chromium_src includes

* fix patch spacing

* fix patch spacing

* fewer patches, more chromium_src overrides

* remove comment

* use browser_context directly

* remove unused render_frames parameter

* remove final patch
2021-12-15 09:45:34 -05:00
Jocelyn Liu 7be9fb06dd Tests for wallet_watchAsset 2021-12-09 17:08:01 -08:00
Aleksey Seren 0b6ae7fa6c Moved NotificationHelper to //brave/browser/brave_ads
fix https://github.com/brave/brave-browser/issues/17630
2021-12-08 12:05:09 +07:00
Aleksey Seren e164f1a02f Moved AdsServiceImpl to //brave/browser/brave_ads
fix https://github.com/brave/brave-browser/issues/17628
2021-12-08 12:05:06 +07:00
Mario Sanchez Prada d46e47c3dd Disable Remote Optimization Guide features.
From cr97 on, having this feature enabled means that the browser will
attempt to reach the Optimization Guide Server every now and then at
the https://optimizationguide-pa.googleapis.com endpoint, as it was
detected by the npm run network-audit command:

  [:ERROR:brave_network_audit_browsertest.cc(151)] NETWORK AUDIT FAIL:https://optimizationguide-pa.googleapis.com/v1:GetModels?key=dummytoken
  [:ERROR:brave_network_audit_browsertest.cc(151)] NETWORK AUDIT FAIL:https://optimizationguide-pa.googleapis.com/v1:GetModels?key=dummytoken

    [...]

  [:ERROR:brave_network_audit_browsertest.cc(151)] NETWORK AUDIT FAIL:https://optimizationguide-pa.googleapis.com/v1:GetModels?key=dummytoken
  ../../brave/browser/net/brave_network_audit_browsertest.cc:249: Failure
  Value of: PerformNetworkAuditProcess(events)
    Actual: false
  Expected: true
  network-audit FAILED. Import /home/mario/work/brave-rebases/brave-browser/src/network_log.json in chrome://net-internals for more details.
  Stack trace:
  #0 0x55f213f6cc10 brave::(anonymous namespace)::BraveNetworkAuditTest::TearDownInProcessBrowserTestFixture()
  #1 0x55f215bda3be content::BrowserTestBase::SetUp()
  #2 0x55f215bd741e InProcessBrowserTest::SetUp()

This patch disables the kkOptimizationHints feature. TBD if this is
needed.

This patch disables the kRemoteOptimizationGuideFetching features that
are otherwise enabled by default, avoiding this URL requests.

PS: I couldn't pinpoint yet where exactly in Chromium 97 this started
happening, but I can consistently reproduce it on my local cr97 branch
setting kMaxTimeoutPerLoadedURL in brave_network_audit_browsertest.cc
to at least 20 seconds, while this doesn't happen on cr96 even when
using the default timeout of 5 minutes, so it's cr97-related.
2021-12-07 14:46:10 -05:00
samartnik bc400fb4c8 [Android] [Tests] Adds ability to include both v8 snapshot types
Chromium change:
https://github.com/chromium/chromium/commit/f7e3a4176bff898bbcfeba7dfc709a018fe08924

Adds ability to include both v8 snapshot types
And adds feature as to which one is used at runtime. Specific
parts:
. adds gn arg: include_both_v8_snapshots. At this time this is
  only supported on android. I will likely make it work on chromeos
  next.
. Adds feature kUseContextSnapshot. This feature is available if
  include_both_v8_snapshots is set.
. Adds switch kUseContextSnapshotSwitch. This is passed from browser
  to renderer if kUseContextSnapshot is enabled. A separate switch is
  used as at the time the v8 snapshot is loaded features have not been
  loaded.
And this updates a bunch of build targets accordingly.

BUG=1257321
TEST=none

Change-Id: I225a9235ac00e1c25ceaf0423587a00a1aafc740
2021-12-07 14:45:56 -05:00
Anthony Tseng 11d338ae26 Use bundled torrc 2021-12-03 15:26:24 -08:00
Serg 9ae26a7804 Adds tests coverage for Android wallet Utils 2021-11-30 16:34:03 -05:00
AlexeyBarabash e9c0560e55 QrCodeData class and tests 2021-11-26 14:52:05 +02:00
Jocelyn Liu f785f8efbd Fix send transaction browser tests 2021-11-24 00:52:04 -08:00
Brian R. Bondy 04efce03ee Implement ethereum._metamask.isUnlocked 2021-11-21 09:04:04 -05:00
Brian R. Bondy d0be53a4ea Add networkVersion property 2021-11-20 23:45:21 -05:00
Francois Marier 5e415ed9df Add browsertest for cross-origin .onion requests. 2021-11-18 16:03:25 -08:00
Mark Pilgrim ee55d8600c Migrate contentSettingsAgent tests away from kIgnoreCertificateErrors 2021-11-15 12:11:37 -05:00
mkarolin 33458ac5fb Lint fixes. 2021-11-12 21:12:16 -05:00
mkarolin 000d81d021 Added unit tests for //net/base/proxy_string_util.cc override. 2021-11-12 17:15:32 -05:00
Sergey ef019ce960 Signing Transaction with Trezor accounts (#10902) 2021-11-12 00:57:01 +03:00
Ralph Giles 24066560c7 Rename network audit allow list file.
Prefer a longer name for this file. Review nit from Mario Sanchez Prada.
2021-11-11 08:03:57 -08:00
Ralph Giles be5c766946 Rename network audit allow list data.
Replace the outdated 'whitelist' term with more inclusive language.
These data structures and their references were recently refactored
to move the `network-audit` script into a browsertest, but the names
weren't updated. This changes them to match current style.

Resolves brave/brave-browser#19357
2021-11-10 11:27:21 -08:00
Mario Sanchez Prada a3839717fa Rework npm run network-audit into a browser test suite (#10389)
* Rework npm run network-audit into a browser test suite

This change adds a new browser test to brave_browser_tests that runs
similar tests to what Brave used to do when running the network-audit
npm script, via the --network_log command line parameter.

As with that previous script, this test makes sure Brave is launched
with --net-log-capture-mode=Everything and --log-net-log, and that
the network_log.json and network-audit-results.json files are written
to disk after the network audit process is completed. However, in this
case we're also prepending the name of the browser test to the names
of such files, so that we can have more than one browser test without
overriding each others' results.

Last, this tests adds two browser tests to check both the case of
loading the simple.html file via the embedded test server and the
more real world scenario of loading brave://welcome, in a final
attempt to replicate what npm run network-audit did for me on a
recent build (and also as a way to validate that having multiple
browser tests will work fine).

Resolves https://github.com/brave/brave-browser/issues/7207
Resolves https://github.com/brave/brave-browser/issues/7281

* Remove all trace of npm run network-audit and replace it where needed

Drop code related to the npm run network-audit command, including the
command itself, and then make sure that the newly added browser tests
are run as part of the npm run test-security command.

Also, this change moves the definitions of the three whitelists used
by the network audit process (i.e. protocols, prefixes and patterns)
to a separate header file so that we can adapt .github/CODEOWNERS to
only cover those lists and not the browser tests themselves.

Last, also adapt Jenkinsfile to remove all references to the former
npm run network-audit command.

* Remove Google-owned prefixes and patterns from network audit whitelist

As noted by @diracdeltas on Slack, these entries should be removed as
they correspond with internal 307 responses that should not be going
out to the network, so we're dropping them as part of this work.

* Extract brave_network_audit_browsertest.cc to a separate binary

A proper re-implementation of these tests will require to "leave the
browser open" for at least 2 minutes, for which we'd need to pass a
big timeout parameters when running the browser tests, delaying the
execution of the brave_browser_tests for no good reason.

Instead, we create a new test suite 'brave_network_audit_tests' that
will exclusively perform the network audit process, so that we can
specify a different timeout only for it (in a follow-up patch).

* Force BraveNetworkAuditTest tests to keep the browser open after load

Similarly to what was done via the npm run network-audit script, we
make sure that we wait ~2 minutes after loading an URL to make sure
we gather enough information (i.e. network requests) before verifying
that no allowed URL requests are made during that time.

In one hand, this means explicitly waiting test until such amount of
time has passed in the tests themselves. In the other hand, this also
means passing specific timeout values to the brave_network_audit_tests
when running it via the npm run test-security script.

* Simplify BraveNetworkAuditTest test suite by having one browser test

Having separate tests was nice in order to be able to run them in
parallel but, at the same time, was probably not necessary because
we want to test the behaviour of firing up one browser and monitoring
network requests after loading some URLs, so probably better to go
back to having one test only.

Additionally, this allows simplifying a bit the creation of the json
files with the log of the requests and the result of the audit, which
don't need having a test-based prefix anymore.

* Whitelist https://laptop-updates-staging.brave.com for network audit

This staging-related URL might be present on devs' machines if they
have it set on their .npmrc file, for instance, so let's add it to
the whitelisted entries similarly to how other staging-related URLs
are already present there.

* Don't whitelist http://componentupdater.brave.com/service/update2

As suggested by @diracdeltas, we can remove the HTTP version of this
URL from the whitelist for the network audit (see [1]).

[1] github.com/brave/brave-core/pull/10389#discussion_r723587821

* Increase timeout for network-audit browser tests to 5min after loads

It seems some network requests might take longer than 2 minutes to
happen, so let's increase the timeout to 5 minutes after loading the
URLs, and adapt the caller script to account for that.

* Also check network requests on brave://rewards with Brave Rewards enabled

Add one more case to the network audit process to double check whether
only allowed network requests happen when Brave Rewards is enabled.

* Whitelist Brave Rewards-related URL prefixes for the network audit

This means whitelisting the following prefixes, found to be hit in
the test after enabling Rewards and waiting for ~5 minutes:

On production environments (e.g. Relese builds on CI):

  - https://api.rewards.brave.com/v1/parameters
  - https://rewards.brave.com/publishers/prefix-list
  - https://grant.rewards.brave.com/v1/promotions

On development environments:

  - https://api.rewards.bravesoftware.com/v1/parameters",
  - https://rewards-stg.bravesoftware.com/publishers/prefix-list",
  - https://grant.rewards.bravesoftware.com/v1/promotions",

* Restore network-audit and define test-security in terms of it

* Disable the ThinLTO cache for the brave_network_audit_tests GN target

We need to disable the ThinLTO cache or the linker will die with
a "Resource temporarily unavailable" error due to the linking
reaching the vm.max_map_count limit of 65530 memory mappings.

* Use JSONFileValueSerializer instead of base::JSONWriter

* Replaced use of deprecated APIs with the correct ones
2021-11-10 19:09:13 +01:00
Brian Clifton 806379d4e2 Merge pull request #9946 from brave/news-mojom
Brave News: convert backend from extension typescript to mojom c++
2021-11-09 01:33:43 -07:00
Sergey d0c1333d2c Change HID bubble title to Brave Wallet for page and panel (#10929) 2021-11-09 06:36:52 +03:00
Pete Miller 565458bf1d Brave News: implement backend in mojom, removing extension backend and webui message handler.
This facilitates both a frontend implementation in Android as well and eventually removing the built-in extension.
2021-11-08 15:20:59 -08:00
Brian R. Bondy e91853bdab Fix test deps 2021-11-08 11:59:05 -05:00
Brian R. Bondy 09972c4270 Fix chainChanged event to have string arg not obj 2021-11-07 18:50:17 -05:00
Brian R. Bondy 692d872b06 Add ethereum.selectedAddress and ethereum.chainId properties
For MM webcompat
2021-11-07 14:43:50 -05:00
Mark Pilgrim 8a6e84d049 Add a farbling-determined voice name to getVoices
call upstream function if farbling is off
add DEPS
exit early if no voices
extend test timeout
move exit condition earlier
feedback
2021-11-05 10:44:19 -04:00
Brian R. Bondy cf2b2872b8 Merge pull request #10852 from brave/remove-wallet-build-flag
Remove wallet build flag
2021-11-03 20:38:44 -04:00
Brian Clifton f78efb260c Merge pull request #10100 from brave/cr96
Upgrade from Chromium 95 to Chromium 96
2021-11-03 11:17:24 -07:00
Pranjal Jumde e6fa4be654 Fix #19069 - IsWebstoreUpdateUrl should return true for kChromeWebstoreUpdateURL even when component-updater switch is set 2021-11-03 09:36:04 -05:00
Brian R. Bondy 6a232513e7 Remove wallet buildtime flag brave_wallet_enabled 2021-11-03 10:34:23 -04:00
Brian R. Bondy 2f2dbc19cc Add more tests around signing for all methods 2021-11-02 14:39:56 -04:00
mkarolin 23081e88c1 Extend CH browser test with additional CH features.
Adds all current CH feature switches to the test to make sure the
feature switch state doesn't affect disablement of CH in Brave.

Alphabetized CH headers in the test data.
2021-11-02 12:41:31 -04:00
samartnik 4bfb74ca2f [Android] Fix for brave_browser_tests 2021-11-02 12:38:05 -04:00
Aleksey Seren 8249ab7f13 Delete redundant brave_stats_test_util.{h|cc} files.
fix https://github.com/brave/brave-browser/issues/17663
2021-11-01 23:17:27 +07:00
Aleksey Seren b10e62ec58 Move browser/brave_ads/BUILD.gn to sources.gni
fix https://github.com/brave/brave-browser/issues/17663
2021-11-01 23:17:26 +07:00
Aleksey Seren a4576ce5b7 Remove deps components/brave_ads from browser/brave_ads
fix https://github.com/brave/brave-browser/issues/17663
2021-11-01 23:17:26 +07:00