Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

test: extract chromium-specific connect tests

Pavel Feldmanf37d9bfe95b1
diff --git a/test/browser.spec.js b/test/browser.spec.js
index 87b70e8092..345f832b9d 100644
--- a/test/browser.spec.js
+++ b/test/browser.spec.js
@@ -1,5 +1,6 @@
/**
* Copyright 2018 Google Inc. All rights reserved.
+ * Modifications copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/test/browsercontext.spec.js b/test/browsercontext.spec.js
index d9548e93b0..491a8ef0ba 100644
--- a/test/browsercontext.spec.js
+++ b/test/browsercontext.spec.js
@@ -1,5 +1,6 @@
/**
* Copyright 2018 Google Inc. All rights reserved.
+ * Modifications copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/test/chromium/connect.spec.js b/test/chromium/connect.spec.js
new file mode 100644
index 0000000000..a104e6ba7f
--- /dev/null
+++ b/test/chromium/connect.spec.js
@@ -0,0 +1,148 @@
+/**
+ * Copyright 2017 Google Inc. All rights reserved.
+ * Modifications copyright (c) Microsoft Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+const fs = require('fs');
+const os = require('os');
+const path = require('path');
+const {helper} = require('../../lib/helper');
+const utils = require('../utils');
+
+module.exports.addTests = function({testRunner, expect, defaultBrowserOptions, playwright, FFOX, CHROME, WEBKIT}) {
+ const {describe, xdescribe, fdescribe} = testRunner;
+ const {it, fit, xit} = testRunner;
+ const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;
+
+ describe('Playwright.connect', function() {
+ it('should be able to connect multiple times to the same browser', async({server}) => {
+ const originalBrowser = await playwright.launch(defaultBrowserOptions);
+ const browser = await playwright.connect({
+ ...defaultBrowserOptions,
+ browserWSEndpoint: originalBrowser.chromium.wsEndpoint()
+ });
+ const page = await browser.newPage();
+ expect(await page.evaluate(() => 7 * 8)).toBe(56);
+ browser.disconnect();
+
+ const secondPage = await originalBrowser.newPage();
+ expect(await secondPage.evaluate(() => 7 * 6)).toBe(42, 'original browser should still work');
+ await originalBrowser.close();
+ });
+ it('should be able to close remote browser', async({server}) => {
+ const originalBrowser = await playwright.launch(defaultBrowserOptions);
+ const remoteBrowser = await playwright.connect({
+ ...defaultBrowserOptions,
+ browserWSEndpoint: originalBrowser.chromium.wsEndpoint()
+ });
+ await Promise.all([
+ utils.waitEvent(originalBrowser, 'disconnected'),
+ remoteBrowser.close(),
+ ]);
+ });
+ it('should support ignoreHTTPSErrors option', async({httpsServer}) => {
+ const originalBrowser = await playwright.launch(defaultBrowserOptions);
+ const browserWSEndpoint = originalBrowser.chromium.wsEndpoint();
+
+ const browser = await playwright.connect({...defaultBrowserOptions, browserWSEndpoint, ignoreHTTPSErrors: true});
+ const page = await browser.newPage();
+ let error = null;
+ const [serverRequest, response] = await Promise.all([
+ httpsServer.waitForRequest('/empty.html'),
+ page.goto(httpsServer.EMPTY_PAGE).catch(e => error = e)
+ ]);
+ expect(error).toBe(null);
+ expect(response.ok()).toBe(true);
+ await page.close();
+ await browser.close();
+ });
+ it('should be able to reconnect to a disconnected browser', async({server}) => {
+ const originalBrowser = await playwright.launch(defaultBrowserOptions);
+ const browserWSEndpoint = originalBrowser.chromium.wsEndpoint();
+ const page = await originalBrowser.newPage();
+ await page.goto(server.PREFIX + '/frames/nested-frames.html');
+ originalBrowser.disconnect();
+
+ const browser = await playwright.connect({...defaultBrowserOptions, browserWSEndpoint});
+ const pages = await browser.pages();
+ const restoredPage = pages.find(page => page.url() === server.PREFIX + '/frames/nested-frames.html');
+ expect(utils.dumpFrames(restoredPage.mainFrame())).toEqual([
+ 'http://localhost:<PORT>/frames/nested-frames.html',
+ ' http://localhost:<PORT>/frames/frame.html (aframe)',
+ ' http://localhost:<PORT>/frames/two-frames.html (2frames)',
+ ' http://localhost:<PORT>/frames/frame.html (dos)',
+ ' http://localhost:<PORT>/frames/frame.html (uno)',
+ ]);
+ expect(await restoredPage.evaluate(() => 7 * 8)).toBe(56);
+ await browser.close();
+ });
+ // @see https://github.com/GoogleChrome/puppeteer/issues/4197#issuecomment-481793410
+ it('should be able to connect to the same page simultaneously', async({server}) => {
+ const browserOne = await playwright.launch(defaultBrowserOptions);
+ const browserTwo = await playwright.connect({ ...defaultBrowserOptions, browserWSEndpoint: browserOne.chromium.wsEndpoint() });
+ const [page1, page2] = await Promise.all([
+ new Promise(x => browserOne.chromium.once('targetcreated', target => x(target.page()))),
+ browserTwo.newPage(),
+ ]);
+ expect(await page1.evaluate(() => 7 * 8)).toBe(56);
+ expect(await page2.evaluate(() => 7 * 6)).toBe(42);
+ await browserOne.close();
+ });
+ });
+
+ describe('Browser.disconnect', function() {
+ it('should reject navigation when browser closes', async({server}) => {
+ server.setRoute('/one-style.css', () => {});
+ const browser = await playwright.launch(defaultBrowserOptions);
+ const remote = await playwright.connect({...defaultBrowserOptions, browserWSEndpoint: browser.chromium.wsEndpoint()});
+ const page = await remote.newPage();
+ const navigationPromise = page.goto(server.PREFIX + '/one-style.html', {timeout: 60000}).catch(e => e);
+ await server.waitForRequest('/one-style.css');
+ remote.disconnect();
+ const error = await navigationPromise;
+ expect(error.message).toBe('Navigation failed because browser has disconnected!');
+ await browser.close();
+ });
+ it('should reject waitForSelector when browser closes', async({server}) => {
+ server.setRoute('/empty.html', () => {});
+ const browser = await playwright.launch(defaultBrowserOptions);
+ const remote = await playwright.connect({...defaultBrowserOptions, browserWSEndpoint: browser.chromium.wsEndpoint()});
+ const page = await remote.newPage();
+ const watchdog = page.waitForSelector('div', {timeout: 60000}).catch(e => e);
+ remote.disconnect();
+ const error = await watchdog;
+ expect(error.message).toContain('Protocol error');
+ await browser.close();
+ });
+ });
+
+ describe('Browser.close', function() {
+ it('should terminate network waiters', async({context, server}) => {
+ const browser = await playwright.launch(defaultBrowserOptions);
+ const remote = await playwright.connect({...defaultBrowserOptions, browserWSEndpoint: browser.chromium.wsEndpoint()});
+ const newPage = await remote.newPage();
+ const results = await Promise.all([
+ newPage.waitForRequest(server.EMPTY_PAGE).catch(e => e),
+ newPage.waitForResponse(server.EMPTY_PAGE).catch(e => e),
+ browser.close()
+ ]);
+ for (let i = 0; i < 2; i++) {
+ const message = results[i].message;
+ expect(message).toContain('Target closed');
+ expect(message).not.toContain('Timeout');
+ }
+ });
+ });
+
+};
diff --git a/test/chromium/launcher.spec.js b/test/chromium/launcher.spec.js
index 3c3c359bbd..4356bc5112 100644
--- a/test/chromium/launcher.spec.js
+++ b/test/chromium/launcher.spec.js
@@ -24,7 +24,7 @@ const mkdtempAsync = util.promisify(fs.mkdtemp);
const TMP_FOLDER = path.join(os.tmpdir(), 'pptr_tmp_folder-');
-module.exports.addTests = function({testRunner, expect, defaultBrowserOptions, playwright}) {
+module.exports.addTests = function({testRunner, expect, defaultBrowserOptions, playwright, WEBKIT, FFOX, WIN}) {
const {describe, xdescribe, fdescribe} = testRunner;
const {it, fit, xit} = testRunner;
const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;
@@ -190,4 +190,33 @@ module.exports.addTests = function({testRunner, expect, defaultBrowserOptions, p
});
});
+ describe('BrowserFetcher', function() {
+ it.skip(WEBKIT || FFOX)('should download and extract linux binary', async({server}) => {
+ const downloadsFolder = await mkdtempAsync(TMP_FOLDER);
+ const browserFetcher = playwright.createBrowserFetcher({
+ platform: 'linux',
+ path: downloadsFolder,
+ host: server.PREFIX
+ });
+ let revisionInfo = browserFetcher.revisionInfo('123456');
+ server.setRoute(revisionInfo.url.substring(server.PREFIX.length), (req, res) => {
+ server.serveFile(req, res, '/chromium-linux.zip');
+ });
+
+ expect(revisionInfo.local).toBe(false);
+ expect(browserFetcher.platform()).toBe('linux');
+ expect(await browserFetcher.canDownload('100000')).toBe(false);
+ expect(await browserFetcher.canDownload('123456')).toBe(true);
+
+ revisionInfo = await browserFetcher.download('123456');
+ expect(revisionInfo.local).toBe(true);
+ expect(await readFileAsync(revisionInfo.executablePath, 'utf8')).toBe('LINUX BINARY\n');
+ const expectedPermissions = WIN ? 0666 : 0755;
+ expect((await statAsync(revisionInfo.executablePath)).mode & 0777).toBe(expectedPermissions);
+ expect(await browserFetcher.localRevisions()).toEqual(['123456']);
+ await browserFetcher.remove('123456');
+ expect(await browserFetcher.localRevisions()).toEqual([]);
+ await rmAsync(downloadsFolder);
+ });
+ });
};
diff --git a/test/click.spec.js b/test/click.spec.js
index a389918150..68b2f5cb92 100644
--- a/test/click.spec.js
+++ b/test/click.spec.js
@@ -1,5 +1,6 @@
/**
* Copyright 2018 Google Inc. All rights reserved.
+ * Modifications copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/test/cookies.spec.js b/test/cookies.spec.js
index a44b66faec..ce2f6b68a4 100644
--- a/test/cookies.spec.js
+++ b/test/cookies.spec.js
@@ -1,5 +1,6 @@
/**
* Copyright 2018 Google Inc. All rights reserved.
+ * Modifications copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/test/defaultbrowsercontext.spec.js b/test/defaultbrowsercontext.spec.js
index eb232de6c9..fd3e178c70 100644
--- a/test/defaultbrowsercontext.spec.js
+++ b/test/defaultbrowsercontext.spec.js
@@ -1,5 +1,6 @@
/**
* Copyright 2017 Google Inc. All rights reserved.
+ * Modifications copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/test/dialog.spec.js b/test/dialog.spec.js
index 501b828108..d904d063eb 100644
--- a/test/dialog.spec.js
+++ b/test/dialog.spec.js
@@ -1,5 +1,6 @@
/**
* Copyright 2018 Google Inc. All rights reserved.
+ * Modifications copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/test/elementhandle.spec.js b/test/elementhandle.spec.js
index bbeb3fd3a7..97d83a1c3e 100644
--- a/test/elementhandle.spec.js
+++ b/test/elementhandle.spec.js
@@ -1,5 +1,6 @@
/**
* Copyright 2018 Google Inc. All rights reserved.
+ * Modifications copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/test/emulation.spec.js b/test/emulation.spec.js
index c1bdf51bf2..bb6cfb9135 100644
--- a/test/emulation.spec.js
+++ b/test/emulation.spec.js
@@ -1,5 +1,6 @@
/**
* Copyright 2018 Google Inc. All rights reserved.
+ * Modifications copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/test/evaluation.spec.js b/test/evaluation.spec.js
index de31394566..2230680330 100644
--- a/test/evaluation.spec.js
+++ b/test/evaluation.spec.js
@@ -1,5 +1,6 @@
/**
* Copyright 2018 Google Inc. All rights reserved.
+ * Modifications copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/test/features/accessibility.spec.js b/test/features/accessibility.spec.js
index b1bafc3174..e02034479b 100644
--- a/test/features/accessibility.spec.js
+++ b/test/features/accessibility.spec.js
@@ -1,5 +1,6 @@
/**
* Copyright 2018 Google Inc. All rights reserved.
+ * Modifications copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/test/features/interception.spec.js b/test/features/interception.spec.js
index b6bdee8e2e..6d37860abf 100644
--- a/test/features/interception.spec.js
+++ b/test/features/interception.spec.js
@@ -1,5 +1,6 @@
/**
* Copyright 2018 Google Inc. All rights reserved.
+ * Modifications copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -607,7 +608,6 @@ module.exports.addTests = function({testRunner, expect, FFOX, CHROME, WEBKIT}) {
expect(response.status()).toBe(401);
});
});
-
describe.skip(FFOX)('Interception.setOfflineMode', function() {
it('should work', async({page, server}) => {
diff --git a/test/features/permissions.spec.js b/test/features/permissions.spec.js
index ce87d1d203..c2a29d4eda 100644
--- a/test/features/permissions.spec.js
+++ b/test/features/permissions.spec.js
@@ -1,5 +1,6 @@
/**
* Copyright 2017 Google Inc. All rights reserved.
+ * Modifications copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/test/fixtures.spec.js b/test/fixtures.spec.js
index 17230a3f20..e201ff36ae 100644
--- a/test/fixtures.spec.js
+++ b/test/fixtures.spec.js
@@ -1,5 +1,6 @@
/**
* Copyright 2019 Google Inc. All rights reserved.
+ * Modifications copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/test/frame.spec.js b/test/frame.spec.js
index b4d6951664..fc9e81fbfe 100644
--- a/test/frame.spec.js
+++ b/test/frame.spec.js
@@ -1,5 +1,6 @@
/**
* Copyright 2018 Google Inc. All rights reserved.
+ * Modifications copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/test/golden-utils.js b/test/golden-utils.js
index 86989ac654..7d5f28f5ee 100644
--- a/test/golden-utils.js
+++ b/test/golden-utils.js
@@ -1,5 +1,6 @@
/**
* Copyright 2017 Google Inc. All rights reserved.
+ * Modifications copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/test/ignorehttpserrors.spec.js b/test/ignorehttpserrors.spec.js
index 4857c61ad5..5adb6faac0 100644
--- a/test/ignorehttpserrors.spec.js
+++ b/test/ignorehttpserrors.spec.js
@@ -1,5 +1,6 @@
/**
* Copyright 2018 Google Inc. All rights reserved.
+ * Modifications copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/test/input.spec.js b/test/input.spec.js
index ac39308142..896847ec37 100644
--- a/test/input.spec.js
+++ b/test/input.spec.js
@@ -1,5 +1,6 @@
/**
* Copyright 2017 Google Inc. All rights reserved.
+ * Modifications copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/test/jshandle.spec.js b/test/jshandle.spec.js
index f0c90055dc..ad2ce53dae 100644
--- a/test/jshandle.spec.js
+++ b/test/jshandle.spec.js
@@ -1,5 +1,6 @@
/**
* Copyright 2018 Google Inc. All rights reserved.
+ * Modifications copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/test/keyboard.spec.js b/test/keyboard.spec.js
index 1654705ccd..424711ce0c 100644
--- a/test/keyboard.spec.js
+++ b/test/keyboard.spec.js
@@ -1,5 +1,6 @@
/**
* Copyright 2018 Google Inc. All rights reserved.
+ * Modifications copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/test/launcher.spec.js b/test/launcher.spec.js
index 806b46fc57..c01d3ba8fd 100644
--- a/test/launcher.spec.js
+++ b/test/launcher.spec.js
@@ -1,5 +1,6 @@
/**
* Copyright 2017 Google Inc. All rights reserved.
+ * Modifications copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,77 +31,6 @@ module.exports.addTests = function({testRunner, expect, defaultBrowserOptions, p
const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;
describe('Playwright', function() {
- describe('BrowserFetcher', function() {
- it.skip(WEBKIT || FFOX)('should download and extract linux binary', async({server}) => {
- const downloadsFolder = await mkdtempAsync(TMP_FOLDER);
- const browserFetcher = playwright.createBrowserFetcher({
- platform: 'linux',
- path: downloadsFolder,
- host: server.PREFIX
- });
- let revisionInfo = browserFetcher.revisionInfo('123456');
- server.setRoute(revisionInfo.url.substring(server.PREFIX.length), (req, res) => {
- server.serveFile(req, res, '/chromium-linux.zip');
- });
-
- expect(revisionInfo.local).toBe(false);
- expect(browserFetcher.platform()).toBe('linux');
- expect(await browserFetcher.canDownload('100000')).toBe(false);
- expect(await browserFetcher.canDownload('123456')).toBe(true);
-
- revisionInfo = await browserFetcher.download('123456');
- expect(revisionInfo.local).toBe(true);
- expect(await readFileAsync(revisionInfo.executablePath, 'utf8')).toBe('LINUX BINARY\n');
- const expectedPermissions = WIN ? 0666 : 0755;
- expect((await statAsync(revisionInfo.executablePath)).mode & 0777).toBe(expectedPermissions);
- expect(await browserFetcher.localRevisions()).toEqual(['123456']);
- await browserFetcher.remove('123456');
- expect(await browserFetcher.localRevisions()).toEqual([]);
- await rmAsync(downloadsFolder);
- });
- });
- describe.skip(WEBKIT || FFOX)('Browser.disconnect', function() {
- it('should reject navigation when browser closes', async({server}) => {
- server.setRoute('/one-style.css', () => {});
- const browser = await playwright.launch(defaultBrowserOptions);
- const remote = await playwright.connect({...defaultBrowserOptions, browserWSEndpoint: browser.chromium.wsEndpoint()});
- const page = await remote.newPage();
- const navigationPromise = page.goto(server.PREFIX + '/one-style.html', {timeout: 60000}).catch(e => e);
- await server.waitForRequest('/one-style.css');
- remote.disconnect();
- const error = await navigationPromise;
- expect(error.message).toBe('Navigation failed because browser has disconnected!');
- await browser.close();
- });
- it('should reject waitForSelector when browser closes', async({server}) => {
- server.setRoute('/empty.html', () => {});
- const browser = await playwright.launch(defaultBrowserOptions);
- const remote = await playwright.connect({...defaultBrowserOptions, browserWSEndpoint: browser.chromium.wsEndpoint()});
- const page = await remote.newPage();
- const watchdog = page.waitForSelector('div', {timeout: 60000}).catch(e => e);
- remote.disconnect();
- const error = await watchdog;
- expect(error.message).toContain('Protocol error');
- await browser.close();
- });
- });
- describe('Browser.close', function() {
- it.skip(WEBKIT || FFOX)('should terminate network waiters', async({context, server}) => {
- const browser = await playwright.launch(defaultBrowserOptions);
- const remote = await playwright.connect({...defaultBrowserOptions, browserWSEndpoint: browser.chromium.wsEndpoint()});
- const newPage = await remote.newPage();
- const results = await Promise.all([
- newPage.waitForRequest(server.EMPTY_PAGE).catch(e => e),
- newPage.waitForResponse(server.EMPTY_PAGE).catch(e => e),
- browser.close()
- ]);
- for (let i = 0; i < 2; i++) {
- const message = results[i].message;
- expect(message).toContain('Target closed');
- expect(message).not.toContain('Timeout');
- }
- });
- });
describe('Playwright.launch', function() {
it('should reject all promises when browser is closed', async() => {
const browser = await playwright.launch(defaultBrowserOptions);
@@ -242,82 +172,7 @@ module.exports.addTests = function({testRunner, expect, defaultBrowserOptions, p
await browser.close();
});
});
- describe.skip(WEBKIT || FFOX)('Playwright.connect', function() {
- it('should be able to connect multiple times to the same browser', async({server}) => {
- const originalBrowser = await playwright.launch(defaultBrowserOptions);
- const browser = await playwright.connect({
- ...defaultBrowserOptions,
- browserWSEndpoint: originalBrowser.chromium.wsEndpoint()
- });
- const page = await browser.newPage();
- expect(await page.evaluate(() => 7 * 8)).toBe(56);
- browser.disconnect();
-
- const secondPage = await originalBrowser.newPage();
- expect(await secondPage.evaluate(() => 7 * 6)).toBe(42, 'original browser should still work');
- await originalBrowser.close();
- });
- it('should be able to close remote browser', async({server}) => {
- const originalBrowser = await playwright.launch(defaultBrowserOptions);
- const remoteBrowser = await playwright.connect({
- ...defaultBrowserOptions,
- browserWSEndpoint: originalBrowser.chromium.wsEndpoint()
- });
- await Promise.all([
- utils.waitEvent(originalBrowser, 'disconnected'),
- remoteBrowser.close(),
- ]);
- });
- it('should support ignoreHTTPSErrors option', async({httpsServer}) => {
- const originalBrowser = await playwright.launch(defaultBrowserOptions);
- const browserWSEndpoint = originalBrowser.chromium.wsEndpoint();
-
- const browser = await playwright.connect({...defaultBrowserOptions, browserWSEndpoint, ignoreHTTPSErrors: true});
- const page = await browser.newPage();
- let error = null;
- const [serverRequest, response] = await Promise.all([
- httpsServer.waitForRequest('/empty.html'),
- page.goto(httpsServer.EMPTY_PAGE).catch(e => error = e)
- ]);
- expect(error).toBe(null);
- expect(response.ok()).toBe(true);
- await page.close();
- await browser.close();
- });
- it('should be able to reconnect to a disconnected browser', async({server}) => {
- const originalBrowser = await playwright.launch(defaultBrowserOptions);
- const browserWSEndpoint = originalBrowser.chromium.wsEndpoint();
- const page = await originalBrowser.newPage();
- await page.goto(server.PREFIX + '/frames/nested-frames.html');
- originalBrowser.disconnect();
- const browser = await playwright.connect({...defaultBrowserOptions, browserWSEndpoint});
- const pages = await browser.pages();
- const restoredPage = pages.find(page => page.url() === server.PREFIX + '/frames/nested-frames.html');
- expect(utils.dumpFrames(restoredPage.mainFrame())).toEqual([
- 'http://localhost:<PORT>/frames/nested-frames.html',
- ' http://localhost:<PORT>/frames/frame.html (aframe)',
- ' http://localhost:<PORT>/frames/two-frames.html (2frames)',
- ' http://localhost:<PORT>/frames/frame.html (dos)',
- ' http://localhost:<PORT>/frames/frame.html (uno)',
- ]);
- expect(await restoredPage.evaluate(() => 7 * 8)).toBe(56);
- await browser.close();
- });
- // @see https://github.com/GoogleChrome/puppeteer/issues/4197#issuecomment-481793410
- it('should be able to connect to the same page simultaneously', async({server}) => {
- const browserOne = await playwright.launch(defaultBrowserOptions);
- const browserTwo = await playwright.connect({ ...defaultBrowserOptions, browserWSEndpoint: browserOne.chromium.wsEndpoint() });
- const [page1, page2] = await Promise.all([
- new Promise(x => browserOne.chromium.once('targetcreated', target => x(target.page()))),
- browserTwo.newPage(),
- ]);
- expect(await page1.evaluate(() => 7 * 8)).toBe(56);
- expect(await page2.evaluate(() => 7 * 6)).toBe(42);
- await browserOne.close();
- });
-
- });
describe('Playwright.executablePath', function() {
it('should work', async({server}) => {
const executablePath = playwright.executablePath();
diff --git a/test/mouse.spec.js b/test/mouse.spec.js
index 9566ad36f1..536318c6e2 100644
--- a/test/mouse.spec.js
+++ b/test/mouse.spec.js
@@ -1,5 +1,6 @@
/**
* Copyright 2018 Google Inc. All rights reserved.
+ * Modifications copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/test/navigation.spec.js b/test/navigation.spec.js
index 6f485179f6..9603c9c2e6 100644
--- a/test/navigation.spec.js
+++ b/test/navigation.spec.js
@@ -1,5 +1,6 @@
/**
* Copyright 2018 Google Inc. All rights reserved.
+ * Modifications copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/test/network.spec.js b/test/network.spec.js
index 1647b0bf97..0980d699fc 100644
--- a/test/network.spec.js
+++ b/test/network.spec.js
@@ -1,5 +1,6 @@
/**
* Copyright 2018 Google Inc. All rights reserved.
+ * Modifications copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/test/page.spec.js b/test/page.spec.js
index f3521ed20c..0a56966f09 100644
--- a/test/page.spec.js
+++ b/test/page.spec.js
@@ -1,5 +1,6 @@
/**
* Copyright 2017 Google Inc. All rights reserved.
+ * Modifications copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/test/playwright.spec.js b/test/playwright.spec.js
index d34239324b..b38ed29e81 100644
--- a/test/playwright.spec.js
+++ b/test/playwright.spec.js
@@ -1,5 +1,6 @@
/**
* Copyright 2019 Google Inc. All rights reserved.
+ * Modifications copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -185,7 +186,8 @@ module.exports.addTests = ({testRunner, product, playwrightPath}) => {
require('./launcher.spec.js').addTests(testOptions);
if (CHROME) {
require('./chromium/headful.spec.js').addTests(testOptions);
- require('./chromium/launcher.spec.js').addTests(testOptions);
+ require('./chromium/connect.spec.js').addTests(testOptions);
+ require('./chromium/headful.spec.js').addTests(testOptions);
require('./chromium/oopif.spec.js').addTests(testOptions);
require('./chromium/tracing.spec.js').addTests(testOptions);
}
diff --git a/test/queryselector.spec.js b/test/queryselector.spec.js
index 27a47726be..a11273f008 100644
--- a/test/queryselector.spec.js
+++ b/test/queryselector.spec.js
@@ -1,5 +1,6 @@
/**
* Copyright 2018 Google Inc. All rights reserved.
+ * Modifications copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/test/screenshot.spec.js b/test/screenshot.spec.js
index a8f316854d..fc8a6a607c 100644
--- a/test/screenshot.spec.js
+++ b/test/screenshot.spec.js
@@ -1,5 +1,6 @@
/**
* Copyright 2018 Google Inc. All rights reserved.
+ * Modifications copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/test/test.js b/test/test.js
index b3fa3c9282..b7df791dc9 100644
--- a/test/test.js
+++ b/test/test.js
@@ -1,5 +1,6 @@
/**
* Copyright 2017 Google Inc. All rights reserved.
+ * Modifications copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/test/utils.js b/test/utils.js
index ceea2f0c51..defb4f3265 100644
--- a/test/utils.js
+++ b/test/utils.js
@@ -1,5 +1,6 @@
/**
* Copyright 2017 Google Inc. All rights reserved.
+ * Modifications copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/test/waittask.spec.js b/test/waittask.spec.js
index 6808e1a156..9244c6c08c 100644
--- a/test/waittask.spec.js
+++ b/test/waittask.spec.js
@@ -1,5 +1,6 @@
/**
* Copyright 2018 Google Inc. All rights reserved.
+ * Modifications copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.