There're apparently a few cases where we can't simply use the .catch()
method over the Promises returned by some APIs, because there could end
up being called over an undefined object i.e. some functions inside
browserActionAPI.ts, cosmeticFilterEvents.ts and browserAction.ts,
which would results in errors like this running npm run test-unit:
Summary of all failing tests
FAIL components/test/brave_extension/background/reducers/shieldsPanelReducer_test.ts (8.315 s)
● braveShieldsPanelReducer › WINDOW_FOCUS_CHANGED › calls shieldsPanelState.updateFocusedWindow
TypeError: Cannot read property 'catch' of undefined
50 | export const setBadgeText = (tabId: number, text: string) => {
51 | if (chrome.browserAction) {
> 52 | chrome.browserAction.setBadgeText({
| ^
53 | tabId,
54 | text: String(text)
55 | }).catch((e) => { console.error(e) })
This CL fixes this using a "try { await <async func> } catch(e) { .. }"
statement instead in those cases, which implies making the functions
where this is done asynchronous and adapting tests as needed.
We need to import loadTimeData from the internal module and
use it from there instead of accessing window.loadTimeData.
ERROR in /home/work/brave-browser/src/brave/components/brave_welcome_ui/reducers/welcome_reducer.ts
in /home/work/brave-browser/src/brave/components/brave_welcome_ui/reducers/welcome_reducer.ts(47,40)
TS2339: Property \'loadTimeData\' does not exist on type \'Window & typeof globalThis\'.
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! brave-core@1.28.4 web-ui: `webpack --config
components/webpack/webpack.config.js --progress --colors "--mode=development"
"brave_welcome=/home/work/brave-browser/src/brave/components/brave_welcome_ui/brave_welcome.tsx"`
Traceback (most recent call last):
File "/home/work/brave-browser/src/out/Component/../../brave/script/transpile-web-ui.py", line 118, in <module>
sys.exit(main())
File "/home/work/brave-browser/src/out/Component/../../brave/script/transpile-web-ui.py", line 31, in main
transpile_web_uis(args.production, webpack_gen_dir, root_gen_dir,
File "/home/work/brave-browser/src/out/Component/../../brave/script/transpile-web-ui.py", line 98, in transpile_web_uis
execute_stdout(args, env)
File "/home/work/brave-browser/src/brave/script/lib/util.py", line 192, in execute_stdout
execute(argv, env)
File "/home/work/brave-browser/src/brave/script/lib/util.py", line 180, in execute
raise e
File "/home/work/brave-browser/src/brave/script/lib/util.py", line 173, in execute
output = subprocess.check_output(argv, stderr=subprocess.STDOUT,
File "/usr/lib/python3.9/subprocess.py", line 424, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
File "/usr/lib/python3.9/subprocess.py", line 528, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['npm', 'run', 'web-ui', '--', '--mode=development', 'brave_welcome=/home/work/brave-browser/src/brave/components/brave_welcome_ui/brave_welcome.tsx']' returned non-zero exit status 2.
fix https://github.com/brave/brave-browser/issues/13775
When navigting from adblock to other pages, renderer is crashed.
This crash comes from referring RFH to try update stats whlie
new naviagion occurs. As we don't need to show stats, stats updating
logic is removed.
In a previous commit we added a "bs_" (standing for "Brave Shields")
to all the settings' names for consistency, even if only "ads", cookies"
and "javascript" needed to be changed to prevent collissions with other
types from upstream when registering the types.
However this is problematic and confusing, so let's only modify the
ones strictly needed, that is, "cookies" and "ads". For "javascript"
we can simply stop registering our own ContentSettingsType for that
since the one that's actually being used is upstream's.
As part of upstream bug 1134547[1], the ResourceIdentifier that Brave
Shields relied on so far has been completely removed[2], so we need to
adapt our code not to rely on it anymore so that we can keep building
Brave correctly on the latest dev channel release of Chromium 88.
This patch implements the first step to adapt Brave to this new
scenario, by moving into using Brave-specific values of the
ContentSettingsType enumeration instead of using the PLUGINS
type plus a ResourceIdentifier as we did before.
Note that this patch adds a "bs_" prefix to all the BraveShields
constants, to avoid collisions with the COOKIES and JAVASCRIPT
upstream content types. Added prefix to all constants for
consistency + update TS code.
Note that the goal of this change is simply to keep Brave building,
running and passing the tests so that we can continue working on the
rebase. Further work will be still needed in follow-up patches to
fully migrate the code base to a post-Flash world by changing those
bits that don't make sense anymore, and simplifying things as much
as possible.
[1] https://crbug.com/1134547
[2] https://crrev.com/c/2500161
Feed is once per hour and sources is once per day
Removed a unit test that was not doing anything useful (copying functionality from function to test and comparing output).
Can't include //chrome/browser:browser (where profile is) because this
causes a circular dep. Instead, I include profile_utils which has the
include for profile.
- Updated to make the JS API calls use reducer
- Lint fixes (TypeScript)
- Check for null on service (happens in private/tor/guest tab)
This was causing a crash when trying to access the ViewCounterServiceFactory
This commit wires that up for:
- deleting a top site
- moving/re-ordering a top site
- undoing one delete action
- restoring all top sites
- handler that refreshes top sites whenever change happens
With this commit, deleting/moving/restoring is completely in sync with
chrome://new-tab-page