Skip to content

Commit

Permalink
Merge pull request brave#9507 from brave/issue-9506
Browse files Browse the repository at this point in the history
don’t add the tab to tab state until the tab_helper has updated the v…
  • Loading branch information
bridiver authored Jun 19, 2017
2 parents 129522d + e261b9e commit 8ead2c8
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions app/browser/tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,19 +364,16 @@ const api = {

let displayURL = newTab.getURL()
let location = displayURL || 'about:blank'

const openerTabId = !source.isDestroyed() ? source.getId() : -1
let newTabValue = getTabValue(newTab.getId())

let rendererInitiated = false
if (source.isGuest()) {
rendererInitiated = true
}

let index
if (parseInt(newTabValue.get('index')) > -1) {
index = newTabValue.get('index')
}
const tabId = newTab.getId()
updateWebContents(tabId, newTab)
let newTabValue = getTabValue(newTab.getId())

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

let index
if (parseInt(newTabValue.get('index')) > -1) {
index = newTabValue.get('index')
}

const frameOpts = {
location,
displayURL,
Expand All @@ -397,14 +399,17 @@ const api = {
openerTabId,
disposition,
index,
tabId: newTabValue.get('id'),
tabId,
unloaded: !!newTabValue.get('discarded')
}

appActions.tabCreated(newTabValue)

if (disposition === 'new-window' || disposition === 'new-popup') {
const windowOpts = makeImmutable(size)
appActions.newWindow(makeImmutable(frameOpts), windowOpts)
} else {
// TODO(bridiver) - use tabCreated in place of newWebContentsAdded
appActions.newWebContentsAdded(windowId, frameOpts, newTabValue)
}
})
Expand Down Expand Up @@ -476,13 +481,6 @@ const api = {
windowActions.gotResponseDetails(tabId, {status, newURL, originalURL, httpResponseCode, requestMethod, referrer, headers, resourceType})
}
})

updateWebContents(tabId, tab)

let tabValue = getTabValue(tabId)
if (tabValue) {
appActions.tabCreated(tabValue)
}
})

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

0 comments on commit 8ead2c8

Please sign in to comment.