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

Commit ce8e853

Browse files
committed
don’t add the tab to tab state until the tab_helper has updated the values
fix #9506 along with brave/muon@4189da5 change is backwards compatible and muon commit is not required for merging
1 parent 129522d commit ce8e853

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

app/browser/tabs.js

+12-14
Original file line numberDiff line numberDiff line change
@@ -364,19 +364,16 @@ const api = {
364364

365365
let displayURL = newTab.getURL()
366366
let location = displayURL || 'about:blank'
367-
368367
const openerTabId = !source.isDestroyed() ? source.getId() : -1
369-
let newTabValue = getTabValue(newTab.getId())
370368

371369
let rendererInitiated = false
372370
if (source.isGuest()) {
373371
rendererInitiated = true
374372
}
375373

376-
let index
377-
if (parseInt(newTabValue.get('index')) > -1) {
378-
index = newTabValue.get('index')
379-
}
374+
const tabId = newTab.getId()
375+
updateWebContents(tabId, newTab)
376+
let newTabValue = getTabValue(newTab.getId())
380377

381378
let windowId
382379
if (newTabValue && parseInt(newTabValue.get('windowId')) > -1) {
@@ -386,6 +383,11 @@ const api = {
386383
windowId = hostWebContents.getOwnerBrowserWindow().id
387384
}
388385

386+
let index
387+
if (parseInt(newTabValue.get('index')) > -1) {
388+
index = newTabValue.get('index')
389+
}
390+
389391
const frameOpts = {
390392
location,
391393
displayURL,
@@ -397,14 +399,17 @@ const api = {
397399
openerTabId,
398400
disposition,
399401
index,
400-
tabId: newTabValue.get('id'),
402+
tabId,
401403
unloaded: !!newTabValue.get('discarded')
402404
}
403405

406+
appActions.tabCreated(newTabValue)
407+
404408
if (disposition === 'new-window' || disposition === 'new-popup') {
405409
const windowOpts = makeImmutable(size)
406410
appActions.newWindow(makeImmutable(frameOpts), windowOpts)
407411
} else {
412+
// TODO(bridiver) - use tabCreated in place of newWebContentsAdded
408413
appActions.newWebContentsAdded(windowId, frameOpts, newTabValue)
409414
}
410415
})
@@ -476,13 +481,6 @@ const api = {
476481
windowActions.gotResponseDetails(tabId, {status, newURL, originalURL, httpResponseCode, requestMethod, referrer, headers, resourceType})
477482
}
478483
})
479-
480-
updateWebContents(tabId, tab)
481-
482-
let tabValue = getTabValue(tabId)
483-
if (tabValue) {
484-
appActions.tabCreated(tabValue)
485-
}
486484
})
487485

488486
process.on('on-tab-created', (tab, options) => {

0 commit comments

Comments
 (0)