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

Commit

Permalink
don’t add the tab to tab state until the tab_helper has updated the v…
Browse files Browse the repository at this point in the history
…alues

fix #9506 along with brave/muon@4189da5
change is backwards compatible and muon commit is not required for merging
  • Loading branch information
bridiver committed Jun 16, 2017
1 parent e8f4f25 commit e261b9e
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 e261b9e

Please sign in to comment.