diff --git a/package.json b/package.json index 152315dee95..197d8017767 100644 --- a/package.json +++ b/package.json @@ -151,7 +151,7 @@ "nsp": "^2.2.0", "pre-commit": "brave/pre-commit", "react-addons-perf": "^15.2.1", - "spectron": "^1.37.0", + "spectron": "brave/spectron", "sqlite3": "^3.1.1", "standard": "8.1.0", "style-loader": "^0.13.0", diff --git a/test/about/adblockTest.js b/test/about/adblockTest.js index 9da2bb74fc7..a6100bc1f25 100644 --- a/test/about/adblockTest.js +++ b/test/about/adblockTest.js @@ -9,7 +9,6 @@ describe('about:adblock', function () { before(function * () { const url = getTargetAboutUrl('about:adblock') yield this.app.client - .waitUntilWindowLoaded() .waitForUrl(Brave.newTabUrl) .waitForBrowserWindow() .waitForVisible(urlInput) diff --git a/test/about/extensionsTest.js b/test/about/extensionsTest.js index 50a359d8c32..cdbf16b8e01 100644 --- a/test/about/extensionsTest.js +++ b/test/about/extensionsTest.js @@ -10,7 +10,6 @@ const aboutExtensionsUrl = getTargetAboutUrl('about:extensions') describe('about:extensions', function () { function * setup (client) { yield client - .waitUntilWindowLoaded() .waitForUrl(Brave.newTabUrl) .waitForBrowserWindow() .waitForVisible(urlInput) diff --git a/test/about/historyTest.js b/test/about/historyTest.js index 9d1320cb174..85a8b619f4e 100644 --- a/test/about/historyTest.js +++ b/test/about/historyTest.js @@ -10,7 +10,6 @@ describe('about:history', function () { before(function * () { yield this.app.client - .waitUntilWindowLoaded() .waitForUrl(Brave.newTabUrl) .waitForBrowserWindow() .waitForVisible(urlInput) diff --git a/test/app/sessionStoreTest.js b/test/app/sessionStoreTest.js index 454f0fb4b45..d02f436720a 100644 --- a/test/app/sessionStoreTest.js +++ b/test/app/sessionStoreTest.js @@ -7,23 +7,17 @@ const siteTags = require('../../js/constants/siteTags') describe('sessionStore', function () { function * setup (client) { Brave.addCommands() - yield client - .waitUntilWindowLoaded() - .waitForBrowserWindow() - .waitForVisible(urlInput) } describe('state is preserved', function () { Brave.beforeAllServerSetup(this) before(function * () { const page1Url = Brave.server.url('page1.html') - this.timeout(30000) yield Brave.startApp() yield setup(Brave.app.client) yield Brave.app.client - .tabByUrl(Brave.newTabUrl) - .url(page1Url) - .waitForUrl(page1Url) + .waitForUrl(Brave.newTabUrl) + .loadUrl(page1Url) .windowParentByUrl(page1Url) .moveToObject(navigator) .waitForExist(navigatorNotBookmarked) @@ -31,11 +25,11 @@ describe('sessionStore', function () { location: page1Url, title: 'some page' }, siteTags.BOOKMARK) - yield Brave.app.client - .moveToObject(navigator) - .waitForExist(navigatorBookmarked) .waitUntil(function () { - return this.getValue(urlInput).then((val) => val === page1Url) + return this.getAppState().then((val) => { + let state = val.value + return state.sites.length === 1 && state.sites[0].location === page1Url + }) }) yield Brave.stopApp(false) yield Brave.startApp() @@ -49,6 +43,8 @@ describe('sessionStore', function () { it('windowState by preserving open page', function * () { const page1Url = Brave.server.url('page1.html') yield Brave.app.client + .waitForUrl(page1Url) + .waitForBrowserWindow() .moveToObject(urlInput) .waitUntil(function () { return this.getValue(urlInput).then((val) => val === page1Url) @@ -56,7 +52,9 @@ describe('sessionStore', function () { }) it('appstate by preserving a bookmark', function * () { - yield Brave.app.client.waitForExist(navigatorBookmarked) + yield Brave.app.client + .waitForBrowserWindow() + .waitForExist(navigatorBookmarked) }) }) @@ -75,6 +73,8 @@ describe('sessionStore', function () { const timestamp = new Date().getTime() let firstRunTimestamp yield Brave.app.client + .waitForUrl(Brave.newTabUrl) + .waitForBrowserWindow() .waitUntil(function () { return this.getAppState().then((val) => { firstRunTimestamp = val.value.firstRunTimestamp @@ -89,6 +89,8 @@ describe('sessionStore', function () { yield Brave.startApp() yield setup(Brave.app.client) yield Brave.app.client + .waitForUrl(Brave.newTabUrl) + .waitForBrowserWindow() .waitUntil(function () { return this.getAppState().then((val) => { return (val.value.firstRunTimestamp === firstRunTimestamp) diff --git a/test/components/autofillTest.js b/test/components/autofillTest.js index 8c29377718f..4e2895f95fa 100644 --- a/test/components/autofillTest.js +++ b/test/components/autofillTest.js @@ -26,7 +26,6 @@ const expYear = new Date().getFullYear() + 2 describe('Autofill', function () { function * setup (client) { yield client - .waitUntilWindowLoaded() .waitForUrl(Brave.newTabUrl) .waitForBrowserWindow() .waitForVisible(urlInput) diff --git a/test/components/bookmarksTest.js b/test/components/bookmarksTest.js index aa1d8b89903..53e32631693 100644 --- a/test/components/bookmarksTest.js +++ b/test/components/bookmarksTest.js @@ -8,7 +8,6 @@ const siteTags = require('../../js/constants/siteTags') describe('bookmark tests', function () { function * setup (client) { yield client - .waitUntilWindowLoaded() .waitForUrl(Brave.newTabUrl) .waitForBrowserWindow() .waitForEnabled(urlInput) diff --git a/test/components/bookmarksToolbarTest.js b/test/components/bookmarksToolbarTest.js index 3ce1c71d4ba..dbbb9207a66 100644 --- a/test/components/bookmarksToolbarTest.js +++ b/test/components/bookmarksToolbarTest.js @@ -8,10 +8,8 @@ const assert = require('assert') function * setup (client) { yield client - .waitUntilWindowLoaded() .waitForUrl(Brave.newTabUrl) .waitForBrowserWindow() - .waitForVisible('#window') .waitForEnabled(urlInput) } diff --git a/test/components/braveryPanelTest.js b/test/components/braveryPanelTest.js index a124b27de1c..9522d892f28 100644 --- a/test/components/braveryPanelTest.js +++ b/test/components/braveryPanelTest.js @@ -8,7 +8,6 @@ const {getTargetAboutUrl} = require('../../js/lib/appUrlUtil') describe('Bravery Panel', function () { function * setup (client) { yield client - .waitUntilWindowLoaded() .waitForUrl(Brave.newTabUrl) .waitForBrowserWindow() .waitForVisible(urlInput) @@ -213,6 +212,8 @@ describe('Bravery Panel', function () { .then((blocked) => blocked === '2') }) }) + // TODO(bridiver) using slashdot won't provide reliable results so we should + // create our own iframe page with urls we expect to be blocked it('detects blocked elements in iframe in private tab', function * () { const url = Brave.server.url('slashdot.html') yield this.app.client @@ -223,7 +224,7 @@ describe('Bravery Panel', function () { yield this.app.client .waitUntil(function () { return this.getText(adsBlockedStat) - .then((blocked) => Number(blocked) > 10) + .then((blocked) => Number(blocked) > 1) }) }) it('detects blocked elements in iframe', function * () { @@ -235,7 +236,7 @@ describe('Bravery Panel', function () { yield this.app.client .waitUntil(function () { return this.getText(adsBlockedStat) - .then((blocked) => Number(blocked) > 10) + .then((blocked) => Number(blocked) > 1) }) }) it('detects https upgrades in private tab', function * () { diff --git a/test/components/clearBrowsingDataPanelTest.js b/test/components/clearBrowsingDataPanelTest.js index 3c1f0aa1159..7f0585508a4 100644 --- a/test/components/clearBrowsingDataPanelTest.js +++ b/test/components/clearBrowsingDataPanelTest.js @@ -8,7 +8,6 @@ const messages = require('../../js/constants/messages') describe('Clear Browsing Panel', function () { function * setup (client) { yield client - .waitUntilWindowLoaded() .waitForUrl(Brave.newTabUrl) .waitForBrowserWindow() .waitForVisible(urlInput) diff --git a/test/components/errorPageTest.js b/test/components/errorPageTest.js index 8d30079d8e3..3886f36f050 100644 --- a/test/components/errorPageTest.js +++ b/test/components/errorPageTest.js @@ -9,7 +9,6 @@ describe('errorPage', function () { before(function * () { yield this.app.client - .waitUntilWindowLoaded() .waitForBrowserWindow() .waitForVisible(urlInput) }) diff --git a/test/components/frameTest.js b/test/components/frameTest.js index c78f860fe0b..78bbdcef104 100644 --- a/test/components/frameTest.js +++ b/test/components/frameTest.js @@ -166,12 +166,18 @@ describe('clone tab', function () { }) it('opens a new foreground tab', function * () { + let url1 = this.url1 yield this.app.client .waitUntil(function () { return this.getTabCount().then((count) => { return count === 2 }) }) + .waitUntil(function () { + return this.tabByIndex(1).getUrl().then((url) => { + return url === url1 + }) + }) .windowByUrl(Brave.browserWindowUrl) .waitForExist(this.webview1) .waitForExist(this.webview2) @@ -194,7 +200,6 @@ describe('clone tab', function () { yield setup(this.app.client) yield this.app.client - .waitUntilWindowLoaded() .windowByUrl(Brave.browserWindowUrl) .waitForUrl(Brave.newTabUrl) .url(this.clickWithTargetPage) @@ -301,8 +306,7 @@ describe('view source', function () { yield setup(this.app.client) yield this.app.client .tabByIndex(0) - .url(this.url) - .waitForUrl(this.url) + .loadUrl(this.url) .windowByUrl(Brave.browserWindowUrl) .waitForExist('.tab[data-frame-key="1"]') .waitForExist(this.webview1) @@ -311,6 +315,11 @@ describe('view source', function () { it('should open in new tab', function * () { yield this.app.client .ipcSend(messages.SHORTCUT_ACTIVE_FRAME_VIEW_SOURCE) + .waitUntil(function () { + return this.getTabCount().then((count) => { + return count === 2 + }) + }) .windowByUrl(Brave.browserWindowUrl) .waitForExist(this.webview2) }) @@ -319,6 +328,11 @@ describe('view source', function () { yield this.app.client .setPinned(this.url, true) .ipcSend(messages.SHORTCUT_ACTIVE_FRAME_VIEW_SOURCE) + .waitUntil(function () { + return this.getTabCount().then((count) => { + return count === 2 + }) + }) .windowByUrl(Brave.browserWindowUrl) .waitForExist(this.webview2) }) @@ -359,7 +373,6 @@ describe('resource loading', function () { function * setup (client) { yield client - .waitUntilWindowLoaded() .waitForUrl(Brave.newTabUrl) .waitForBrowserWindow() .waitForVisible(urlInput) diff --git a/test/components/ledgerPanelTest.js b/test/components/ledgerPanelTest.js index c60d3457156..25d157c38a8 100644 --- a/test/components/ledgerPanelTest.js +++ b/test/components/ledgerPanelTest.js @@ -8,7 +8,6 @@ const prefsUrl = 'about:preferences' function * setup (client) { yield client - .waitUntilWindowLoaded() .waitForUrl(Brave.newTabUrl) .waitForBrowserWindow() .waitForVisible(urlInput) @@ -39,6 +38,7 @@ describe('Payments Panel', function () { .waitForVisible(paymentsTab) .click(paymentsTab) .waitForVisible(paymentsWelcomePage) + .waitForVisible(walletSwitch) .click(walletSwitch) .windowByUrl(Brave.browserWindowUrl) .waitUntil(function () { @@ -56,6 +56,7 @@ describe('Payments Panel', function () { .waitForVisible(paymentsTab) .click(paymentsTab) .waitForVisible(paymentsWelcomePage) + .waitForVisible(walletSwitch) .click(walletSwitch) .windowByUrl(Brave.browserWindowUrl) .waitUntil(function () { @@ -65,6 +66,7 @@ describe('Payments Panel', function () { }) }) .tabByUrl(prefsUrl) + .waitForVisible(walletSwitch) .click(walletSwitch) .windowByUrl(Brave.browserWindowUrl) .waitUntil(function () { @@ -82,6 +84,7 @@ describe('Payments Panel', function () { .waitForVisible(paymentsTab) .click(paymentsTab) .waitForVisible(paymentsWelcomePage) + .waitForVisible(walletSwitch) .click(walletSwitch) .waitUntil(function () { return this.getText(paymentsStatus).then((val) => val.includes('Creating')) @@ -106,6 +109,7 @@ describe('synopsis', function () { .waitForVisible(paymentsTab) .click(paymentsTab) .waitForVisible(paymentsWelcomePage) + .waitForVisible(walletSwitch) .click(walletSwitch) .waitUntil(function () { return this.getText(paymentsStatus).then((val) => val.includes('Creating')) @@ -153,6 +157,7 @@ describe('synopsis', function () { .loadUrl(prefsUrl) .waitForVisible(paymentsTab) .click(paymentsTab) + .waitForVisible('[data-l10n-id="publisher"]') .click('[data-l10n-id="publisher"]') .waitUntil(function () { return this.getText(ledgerTable + ' a').then((text) => { @@ -176,7 +181,9 @@ describe('synopsis', function () { .loadUrl(prefsUrl) .waitForVisible(paymentsTab) .click(paymentsTab) + .waitForVisible('[data-l10n-id="publisher"]') .click('[data-l10n-id="publisher"]') + .waitForVisible(ledgerTable + ' .switchBackground') .click(ledgerTable + ' .switchBackground') .windowByUrl(Brave.browserWindowUrl) .waitUntil(function () { diff --git a/test/components/navigationBarTest.js b/test/components/navigationBarTest.js index b228521d21a..57579516818 100644 --- a/test/components/navigationBarTest.js +++ b/test/components/navigationBarTest.js @@ -15,7 +15,6 @@ const messages = require('../../js/constants/messages') describe('navigationBar', function () { function * setup (client) { yield client - .waitUntilWindowLoaded() .waitForUrl(Brave.newTabUrl) .waitForBrowserWindow() .waitForEnabled(urlInput) @@ -883,6 +882,9 @@ describe('navigationBar', function () { // tab with typing yield newFrame(this.app.client, 2) yield this.app.client + .waitUntil(function () { + return this.getTabCount().then((count) => count === 2) + }) .windowByUrl(Brave.browserWindowUrl) .waitUntil(function () { return this.keys('a').getValue(urlInput).then((val) => val === 'a') @@ -890,6 +892,9 @@ describe('navigationBar', function () { // tab with loaded url yield newFrame(this.app.client, 3) yield this.app.client + .waitUntil(function () { + return this.getTabCount().then((count) => count === 3) + }) .tabByIndex(2) .url(Brave.server.url('page1.html')) .waitForUrl(Brave.server.url('page1.html')) diff --git a/test/components/notificationBarTest.js b/test/components/notificationBarTest.js index 99710d953c7..b3e4688a460 100644 --- a/test/components/notificationBarTest.js +++ b/test/components/notificationBarTest.js @@ -6,7 +6,6 @@ const {activeWebview, notificationBar, titleBar, urlInput} = require('../lib/sel describe('notificationBar', function () { function * setup (client) { yield client - .waitUntilWindowLoaded() .waitForBrowserWindow() .waitForVisible(urlInput) } @@ -165,7 +164,6 @@ describe('notificationBar', function () { describe('permissions state', function () { function * setup (client) { yield client - .waitUntilWindowLoaded() .waitForBrowserWindow() .waitForVisible(urlInput) } diff --git a/test/components/pinnedTabTest.js b/test/components/pinnedTabTest.js index e21a2711d90..1ffd0ba28c0 100644 --- a/test/components/pinnedTabTest.js +++ b/test/components/pinnedTabTest.js @@ -9,7 +9,6 @@ const {urlInput, tabsTabs, pinnedTabsTabs} = require('../lib/selectors') describe('pinnedTabs', function () { function * setup (client) { yield client - .waitUntilWindowLoaded() .waitForUrl(Brave.newTabUrl) .waitForBrowserWindow() .waitForVisible(urlInput) diff --git a/test/components/tabPagesTest.js b/test/components/tabPagesTest.js index b199f0cc2a7..5124a74a883 100644 --- a/test/components/tabPagesTest.js +++ b/test/components/tabPagesTest.js @@ -9,7 +9,6 @@ const assert = require('assert') describe('tab pages', function () { function * setup (client) { yield client - .waitUntilWindowLoaded() .waitForUrl(Brave.newTabUrl) .waitForBrowserWindow() .waitForVisible(urlInput) diff --git a/test/components/tabTest.js b/test/components/tabTest.js index 2e8cedb78f1..70a3684275a 100644 --- a/test/components/tabTest.js +++ b/test/components/tabTest.js @@ -8,7 +8,6 @@ const {urlInput, backButton, forwardButton, activeTabTitle} = require('../lib/se describe('tabs', function () { function * setup (client) { yield client - .waitUntilWindowLoaded() .waitForUrl(Brave.newTabUrl) .waitForBrowserWindow() .waitForVisible(urlInput) diff --git a/test/components/urlBarSuggestionsTest.js b/test/components/urlBarSuggestionsTest.js index 1cb34aa7ba7..6694d03dc65 100644 --- a/test/components/urlBarSuggestionsTest.js +++ b/test/components/urlBarSuggestionsTest.js @@ -7,7 +7,6 @@ const {urlInput, urlBarSuggestions} = require('../lib/selectors') describe('urlbarSuggestions', function () { function * setup (client) { yield client - .waitUntilWindowLoaded() .waitForUrl(Brave.newTabUrl) .waitForBrowserWindow() .waitForVisible(urlInput) diff --git a/test/components/urlBarTest.js b/test/components/urlBarTest.js index ba2ab45b98c..51e1e85d515 100644 --- a/test/components/urlBarTest.js +++ b/test/components/urlBarTest.js @@ -6,7 +6,6 @@ const {urlInput} = require('../lib/selectors') describe('urlBar', function () { function * setup (client) { yield client - .waitUntilWindowLoaded() .waitForUrl(Brave.newTabUrl) .waitForBrowserWindow() .waitForEnabled(urlInput) diff --git a/test/components/windowTest.js b/test/components/windowTest.js index b8afa5de7ed..881fb1f2b82 100644 --- a/test/components/windowTest.js +++ b/test/components/windowTest.js @@ -10,31 +10,30 @@ describe('application window', function () { it('opens a window and loads the UI', function * () { yield this.app.client - .waitUntilWindowLoaded() .waitForUrl(Brave.newTabUrl) - .windowByUrl(Brave.browserWindowUrl) + .windowByIndex(0) .waitForVisible(activeWebview) yield this.app.client - .windowByUrl(Brave.browserWindowUrl) + .windowByIndex(0) .getWindowCount().should.become(1) yield this.app.client - .windowByUrl(Brave.browserWindowUrl) - .isWindowMinimized().should.eventually.be.false + .windowByIndex(0) + .browserWindow.isMinimized().should.eventually.be.false yield this.app.client - .windowByUrl(Brave.browserWindowUrl) - .isWindowDevToolsOpened().should.eventually.be.false + .windowByIndex(0) + .browserWindow.isDevToolsOpened().should.eventually.be.false yield this.app.client - .windowByUrl(Brave.browserWindowUrl) - .isWindowVisible().should.eventually.be.true + .windowByIndex(0) + .browserWindow.isVisible().should.eventually.be.true yield this.app.client - .windowByUrl(Brave.browserWindowUrl) - .isWindowFocused().should.eventually.be.true + .windowByIndex(0) + .browserWindow.isFocused().should.eventually.be.true yield this.app.client - .windowByUrl(Brave.browserWindowUrl) - .getWindowWidth().should.eventually.be.getDefaultWindowWidth() + .windowByIndex(0) + .browserWindow.getBounds().should.eventually.have.property('width').should.eventually.be.getDefaultWindowWidth() yield this.app.client - .windowByUrl(Brave.browserWindowUrl) - .getWindowHeight().should.eventually.be.getDefaultWindowHeight() + .windowByIndex(0) + .browserWindow.getBounds().should.eventually.have.property('height').should.eventually.be.getDefaultWindowHeight() }) }) @@ -44,7 +43,6 @@ describe('application window', function () { before(function * () { yield this.app.client - .waitUntilWindowLoaded() .waitForUrl(Brave.newTabUrl) .windowByIndex(0) .newWindowAction() @@ -54,23 +52,22 @@ describe('application window', function () { }) }) .windowByIndex(1) - .waitUntilWindowLoaded() }) it('offsets from the focused window', function * () { yield this.app.client - .windowByIndex(1).getWindowBounds().then((res) => res.x).should.eventually.be - .windowByIndex(0).getWindowBounds().then((res) => res.x + 20) + .windowByIndex(1).browserWindow.getBounds().then((res) => res.x).should.eventually.be + .windowByIndex(0).browserWindow.getBounds().then((res) => res.x + 20) yield this.app.client - .windowByIndex(1).getWindowBounds().then((res) => res.y).should.eventually.be - .windowByIndex(0).getWindowBounds().then((res) => res.y + 20) + .windowByIndex(1).browserWindow.getBounds().then((res) => res.y).should.eventually.be + .windowByIndex(0).browserWindow.getBounds().then((res) => res.y + 20) }) it('has the default width and height', function * () { yield this.app.client - .windowByIndex(1).getWindowWidth().should.eventually.be.getDefaultWindowWidth() + .windowByIndex(1).browserWindow.getBounds().should.eventually.have.property('width').should.eventually.be.getDefaultWindowWidth() yield this.app.client - .windowByIndex(1).getWindowHeight().should.eventually.be.getDefaultWindowHeight() + .windowByIndex(1).browserWindow.getBounds().should.eventually.have.property('height').should.eventually.be.getDefaultWindowHeight() }) }) @@ -79,7 +76,6 @@ describe('application window', function () { before(function * () { yield this.app.client - .waitUntilWindowLoaded() .waitForUrl(Brave.newTabUrl) .windowByIndex(0) .resizeWindow(600, 700) @@ -90,22 +86,21 @@ describe('application window', function () { }) }) .windowByIndex(1) - .waitUntilWindowLoaded() }) it('offsets from the focused window', function * () { yield this.app.client - .windowByIndex(1).getWindowBounds().then((res) => res.x).should.eventually.be - .windowByIndex(0).getWindowBounds().then((res) => res.x + 20) + .windowByIndex(1).browserWindow.getBounds().then((res) => res.x).should.eventually.be + .windowByIndex(0).browserWindow.getBounds().then((res) => res.x + 20) yield this.app.client - .windowByIndex(1).getWindowBounds().then((res) => res.y).should.eventually.be - .windowByIndex(0).getWindowBounds().then((res) => res.y + 20) + .windowByIndex(1).browserWindow.getBounds().then((res) => res.y).should.eventually.be + .windowByIndex(0).browserWindow.getBounds().then((res) => res.y + 20) }) it('has the width and height of the last window resize', function * () { - yield this.app.client.windowByIndex(1) - .getWindowWidth().should.become(600) - .getWindowHeight().should.become(700) + yield this.app.client + .windowByIndex(1).browserWindow.getBounds().should.eventually.have.property('width').should.become(600) + .windowByIndex(1).browserWindow.getBounds().should.eventually.have.property('height').should.become(700) }) }) @@ -114,10 +109,9 @@ describe('application window', function () { before(function * () { yield this.app.client - .waitUntilWindowLoaded() .waitForUrl(Brave.newTabUrl) .windowByIndex(0) - .maximizeWindow() + .maximize() .newWindowAction() .waitUntil(function () { return this.getWindowCount().then((count) => { @@ -125,24 +119,23 @@ describe('application window', function () { }) }) .windowByIndex(1) // the new browser window - .waitUntilWindowLoaded() .waitForVisible(activeWebview) }) it('is maximized', function * () { yield this.app.client - .windowByIndex(1).getWindowWidth().should.eventually.be.getPrimaryDisplayWidth() + .windowByIndex(1).browserWindow.getBounds().should.eventually.have.property('width').should.eventually.be.getPrimaryDisplayWidth() yield this.app.client - .windowByIndex(1).getWindowHeight().should.eventually.be.getPrimaryDisplayHeight() + .windowByIndex(1).browserWindow.getBounds().should.eventually.have.property('height').should.eventually.be.getPrimaryDisplayHeight() }) it('opens without an offset', function * () { yield this.app.client - .windowByIndex(1).getWindowBounds().then((res) => res.x).should.eventually.be - .windowByIndex(0).getWindowBounds().then((res) => res.x) + .windowByIndex(1).browserWindow.getBounds().then((res) => res.x).should.eventually.be + .windowByIndex(0).browserWindow.getBounds().then((res) => res.x) yield this.app.client - .windowByIndex(1).getWindowBounds().then((res) => res.y).should.eventually.be - .windowByIndex(0).getWindowBounds().then((res) => res.y) + .windowByIndex(1).browserWindow.getBounds().then((res) => res.y).should.eventually.be + .windowByIndex(0).browserWindow.getBounds().then((res) => res.y) }) }) }) @@ -153,26 +146,23 @@ describe('application window', function () { before(function * () { yield this.app.client - .waitUntilWindowLoaded() .waitForUrl(Brave.newTabUrl) .windowByIndex(0) .resizeWindow(600, 700) - .waitUntilWindowLoaded() }) it('should be maximized when maximize button is clicked', function * () { yield this.app.client .click(maximizeButton) - .windowByIndex(0) - .getWindowWidth().should.eventually.be.getPrimaryDisplayWidth() - .getWindowHeight().should.eventually.be.getPrimaryDisplayHeight() + .windowByIndex(0).browserWindow.getBounds().should.eventually.have.property('width').should.eventually.be.getPrimaryDisplayWidth() + .windowByIndex(0).browserWindow.getBounds().should.eventually.have.property('height').should.eventually.be.getPrimaryDisplayHeight() }) it('should be minimized when minimize button is clicked', function * () { yield this.app.client .click(minimizeButton) .waitUntil(function () { - return this.windowByIndex(0).isWindowMinimized() + return this.windowByIndex(0).browserWindow.isMinimized() }) }) @@ -186,7 +176,6 @@ describe('application window', function () { }) }) .windowByIndex(1) - .waitUntilWindowLoaded() .click(closeButton) .waitUntil(function () { return this.getWindowCount().then((count) => { @@ -205,7 +194,6 @@ describe('application window', function () { this.page1 = Brave.server.url('page1.html') yield this.app.client - .waitUntilWindowLoaded() .windowByUrl(Brave.browserWindowUrl) .waitForUrl(Brave.newTabUrl) .url(Brave.server.url('window_open.html')) @@ -234,19 +222,19 @@ describe('application window', function () { it('sets the width and height', function * () { yield this.app.client .windowParentByUrl(this.page1) - .getWindowHeight().should.eventually.be.equal(375) // height plus navbar + .browserWindow.getBounds().should.eventually.have.property('height').should.eventually.be.equal(375) // height plus navbar yield this.app.client .windowParentByUrl(this.page1) - .getWindowWidth().should.eventually.be.equal(480) + .browserWindow.getBounds().should.eventually.have.property('width').should.eventually.be.equal(480) }) it('sets the window position', function * () { yield this.app.client .windowParentByUrl(this.page1) - .getWindowBounds().then((res) => res.x).should.eventually.be.equal(0) + .browserWindow.getBounds().then((res) => res.x).should.eventually.be.equal(0) yield this.app.client .windowParentByUrl(this.page1) - .getWindowBounds().then((res) => res.y).should.eventually.be.equal(100) + .browserWindow.getBounds().then((res) => res.y).should.eventually.be.equal(100) }) }) @@ -275,10 +263,10 @@ describe('application window', function () { it('has a min width of 480 and height of 300', function * () { yield this.app.client .windowParentByUrl(this.page1) - .getWindowHeight().should.become(300) + .browserWindow.getBounds().should.eventually.have.property('height').should.become(300) yield this.app.client .windowParentByUrl(this.page1) - .getWindowWidth().should.become(480) + .browserWindow.getBounds().should.eventually.have.property('width').should.become(480) }) }) @@ -323,7 +311,6 @@ describe('application window', function () { this.page1 = Brave.server.urlWithIpAddress('page1.html') yield this.app.client - .waitUntilWindowLoaded() .windowByUrl(Brave.browserWindowUrl) .waitForUrl(Brave.newTabUrl) .url(this.window_open_page) @@ -410,7 +397,6 @@ describe('application window', function () { var page1 = this.page1 // for wait closure yield this.app.client - .waitUntilWindowLoaded() .windowByUrl(Brave.browserWindowUrl) .waitForUrl(Brave.newTabUrl) .url(this.window_open_page) @@ -528,7 +514,6 @@ describe('application window', function () { this.page1 = Brave.server.urlWithIpAddress('page1.html') yield this.app.client - .waitUntilWindowLoaded() .waitForUrl(Brave.newTabUrl) .windowByUrl(Brave.browserWindowUrl) .waitForVisible(activeWebview) @@ -565,7 +550,6 @@ describe('application window', function () { var page1 = Brave.server.url('page1.html') yield this.app.client - .waitUntilWindowLoaded() .waitForUrl(Brave.newTabUrl) .windowByUrl(Brave.browserWindowUrl) .waitForVisible(activeWebview) @@ -608,7 +592,6 @@ describe('application window', function () { this.page2 = Brave.server.url('page2.html') yield this.app.client - .waitUntilWindowLoaded() .windowByUrl(Brave.browserWindowUrl) .waitForUrl(Brave.newTabUrl) .url(this.clickWithTargetPage) @@ -660,7 +643,6 @@ describe('application window', function () { this.page2 = Brave.server.url('page2.html') yield this.app.client - .waitUntilWindowLoaded() .windowByUrl(Brave.browserWindowUrl) .waitForUrl(Brave.newTabUrl) .url(this.clickWithTargetPage) @@ -688,7 +670,6 @@ describe('application window', function () { this.page2 = Brave.server.url('page2.html') yield this.app.client - .waitUntilWindowLoaded() .windowByUrl(Brave.browserWindowUrl) .waitForUrl(Brave.newTabUrl) .url(this.clickWithTargetPage) @@ -716,7 +697,6 @@ describe('application window', function () { this.page2 = Brave.server.url('page2.html') yield this.app.client - .waitUntilWindowLoaded() .windowByUrl(Brave.browserWindowUrl) .waitForUrl(Brave.newTabUrl) .url(this.clickWithTargetPage) @@ -745,7 +725,6 @@ describe('application window', function () { this.page2 = Brave.server.url('page2.html') yield this.app.client - .waitUntilWindowLoaded() .windowByUrl(Brave.browserWindowUrl) .waitForUrl(Brave.newTabUrl) .url(this.clickWithTargetPage) diff --git a/test/lib/brave.js b/test/lib/brave.js index 4e302a61e9b..f5ff1a036a5 100644 --- a/test/lib/brave.js +++ b/test/lib/brave.js @@ -458,8 +458,6 @@ var exports = { }) }) }) - - this.app.client.waitUntilWindowLoaded().windowByUrl(exports.browserWindowUrl) }, startApp: function () { @@ -471,6 +469,9 @@ var exports = { BRAVE_USER_DATA_DIR: userDataDir } this.app = new Application({ + waitforInterval: 100, + waitforTimeout: 1000, + quitTimeout: 0, path: './node_modules/.bin/electron', env, args: ['./', '--debug=5858', '--enable-logging', '--v=1'] @@ -479,12 +480,16 @@ var exports = { }, stopApp: function (cleanSessionStore = true) { - if (cleanSessionStore) { - if (!process.env.KEEP_BRAVE_USER_DATA_DIR) { - userDataDir && rmDir(userDataDir) + let stop = this.app.stop().then((app) => { + if (cleanSessionStore) { + if (!process.env.KEEP_BRAVE_USER_DATA_DIR) { + userDataDir && rmDir(userDataDir) + } + userDataDir = generateUserDataDir() } - userDataDir = generateUserDataDir() - } + return app + }) + // this.app.client.getMainProcessLogs().then(function (logs) { // logs.forEach(function (log) { // console.log(log) @@ -495,7 +500,7 @@ var exports = { // console.log(log) // }) // }) - return this.app.stop() + return stop } }