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

Commit

Permalink
separate rules for whether a tab can be created discarded and whether…
Browse files Browse the repository at this point in the history
… it can be autoDiscardable

Fix #12976
  • Loading branch information
petemill committed Feb 1, 2018
1 parent 94e5e15 commit b1c3d10
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions app/browser/tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const tabState = require('../common/state/tabState')
const {app, BrowserWindow, extensions, session, ipcMain} = require('electron')
const {makeImmutable, makeJS} = require('../common/state/immutableUtil')
const {getTargetAboutUrl, getSourceAboutUrl, isSourceAboutUrl, newFrameUrl, isTargetAboutUrl, isIntermediateAboutPage, isTargetMagnetUrl, getSourceMagnetUrl} = require('../../js/lib/appUrlUtil')
const {isURL, getUrlFromInput, toPDFJSLocation, getDefaultFaviconUrl, getLocationIfPDF} = require('../../js/lib/urlutil')
const {isURL, getUrlFromInput, toPDFJSLocation, getDefaultFaviconUrl, isHttpOrHttps, getLocationIfPDF} = require('../../js/lib/urlutil')
const {isSessionPartition} = require('../../js/state/frameStateUtil')
const {getOrigin} = require('../../js/lib/urlutil')
const settingsStore = require('../../js/settings')
Expand Down Expand Up @@ -112,12 +112,6 @@ const needsPartitionAssigned = (createProperties) => {
createProperties.partition
}

const isAutoDiscardable = (createProperties) => {
// Temporarily disabled due to bad handling for auto discarded tabs
// See https://github.com/brave/browser-laptop/issues/10673
return false
}

const aboutTabs = {}
const aboutTabUpdateListener = (tabId) => {
if (parseInt(tabId)) {
Expand Down Expand Up @@ -912,8 +906,24 @@ const api = {
createProperties.parent_partition = ''
}
}
if (!isAutoDiscardable(createProperties)) {

// Tabs are allowed to be initially discarded (unloaded) if they are regular tabs
// i.e not about: pages, and not pinned
// and only if the tab creation request passes in `discarded: true`
const isRegularContent = isHttpOrHttps(createProperties.url)
const preventLazyLoad = createProperties.pinned || !isRegularContent
if (preventLazyLoad) {
createProperties.discarded = false
}
// Similarly, autoDiscardable will happen for regular tabs (not about: tabs)
const preventAutoDiscard = createProperties.pinned || !isRegularContent
if (preventAutoDiscard) {
createProperties.autoDiscardable = false
} else {
// (temporarily) forced autoDiscardable to ALWAYS false due to
// inability to switch to auto-discarded tabs.
// See https://github.com/brave/browser-laptop/issues/10673
// remove this forced 'else' condition when #10673 is resolved
createProperties.autoDiscardable = false
}

Expand Down

0 comments on commit b1c3d10

Please sign in to comment.