From a0b2fa7d356d010a2ac63f654933292cda7742af Mon Sep 17 00:00:00 2001 From: yan Date: Mon, 24 Jul 2017 14:38:40 -0700 Subject: [PATCH] fix PDF pinned tabs being duplicated fix #9954 Test Plan: npm run test -- --grep='Pins an existing frame' try pinning a PDF frame. it should not be duplicated --- app/browser/windows.js | 3 ++- test/tab-components/pinnedTabTest.js | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/browser/windows.js b/app/browser/windows.js index 028aee44eed..5cf6767c228 100644 --- a/app/browser/windows.js +++ b/app/browser/windows.js @@ -5,6 +5,7 @@ const {app, BrowserWindow, ipcMain} = require('electron') const appActions = require('../../js/actions/appActions') const appUrlUtil = require('../../js/lib/appUrlUtil') +const {getLocationIfPDF} = require('../../js/lib/urlutil') const debounce = require('../../js/lib/debounce') const {getSetting} = require('../../js/settings') const locale = require('../locale') @@ -75,7 +76,7 @@ const updatePinnedTabs = (win) => { pinnedSites.filter((site) => pinnedTabs.find((tab) => - tab.get('url') === site.get('location') && + getLocationIfPDF(tab.get('url')) === site.get('location') && (tab.get('partitionNumber') || 0) === (site.get('partitionNumber') || 0))).forEach((site) => { win.__alreadyPinnedSites = win.__alreadyPinnedSites.add(site) }) diff --git a/test/tab-components/pinnedTabTest.js b/test/tab-components/pinnedTabTest.js index 513cef1da6c..8ad4b799c4d 100644 --- a/test/tab-components/pinnedTabTest.js +++ b/test/tab-components/pinnedTabTest.js @@ -51,6 +51,17 @@ describe('pinnedTabs', function () { .waitForElementCount(pinnedTabsTabs, 1) .waitForElementCount(tabsTabs, 1) }) + it('can pin a PDF', function * () { + const pdfUrl = 'http://orimi.com/pdf-test.pdf' + yield this.app.client + .tabByIndex(0) + .url(pdfUrl) + .pause(1000) // wait for PDF load + .windowByUrl(Brave.browserWindowUrl) + .pinTabByIndex(0, true) + .waitForElementCount(pinnedTabsTabs, 2) + .waitForElementCount(tabsTabs, 0) + }) }) describe('Pinning with partitions', function () {