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

Commit 1cf53e1

Browse files
authored
Merge pull request #14709 from brave/fix/tor-bookmarks
Block tab.loadURL in tor tabs until tor is initialized
2 parents e78fc93 + bef471d commit 1cf53e1

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

app/browser/tabs.js

+18
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,18 @@ const getPartitionNumber = (partition) => {
9595
return Number(partition.split('persist:partition-')[1] || 0)
9696
}
9797

98+
const shouldWaitForTorLoad = (webContents, appState) => {
99+
if (webContents &&
100+
webContents.session &&
101+
webContents.session.partition === appConfig.tor.partition) {
102+
appState = appState || appStore.getState()
103+
if (appState.getIn(['tor', 'online']) !== true) {
104+
console.log('Blocking page load until Tor tab is initialized')
105+
return true
106+
}
107+
}
108+
}
109+
98110
/**
99111
* Obtains the current partition.
100112
* Warning: This function has global side effects in that it increments the
@@ -905,6 +917,9 @@ const api = {
905917
action = makeImmutable(action)
906918
const tabId = action.get('tabId')
907919
const tab = webContentsCache.getWebContents(tabId)
920+
if (shouldWaitForTorLoad(tab)) {
921+
return
922+
}
908923
if (tab && !tab.isDestroyed()) {
909924
const url = normalizeUrl(action.get('url'))
910925
const currentUrl = tab.getURL()
@@ -944,6 +959,9 @@ const api = {
944959

945960
loadURLInTab: (state, tabId, url) => {
946961
const tab = webContentsCache.getWebContents(tabId)
962+
if (shouldWaitForTorLoad(tab)) {
963+
return
964+
}
947965
if (tab && !tab.isDestroyed()) {
948966
url = normalizeUrl(url)
949967
tab.loadURL(url)

0 commit comments

Comments
 (0)