diff --git a/experimental/puppeteer-firefox/completeness.sh b/experimental/puppeteer-firefox/completeness.sh
deleted file mode 100755
index 1a3a59cb255..00000000000
--- a/experimental/puppeteer-firefox/completeness.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-set -e
-
-total=`git grep ' \* \[' README.md| wc -l`
-complete=`git grep ' \* \[x' README.md | wc -l`
-ratio=`echo "$complete / $total * 100" | bc -l`
-printf "%.2f%%\n" $ratio
-
diff --git a/experimental/puppeteer-firefox/package.json b/experimental/puppeteer-firefox/package.json
index 0dd0e9749b1..035dcc69f97 100644
--- a/experimental/puppeteer-firefox/package.json
+++ b/experimental/puppeteer-firefox/package.json
@@ -13,9 +13,6 @@
},
"scripts": {
"install": "node install.js",
- "unit": "node test/test.js",
- "funit": "cross-env DUMPIO=1 PRODUCT=firefox node test/test.js",
- "cunit": "cross-env PRODUCT=chromium node test/test.js",
"tsc": "tsc -p ."
},
"author": "The Chromium Authors",
@@ -28,27 +25,5 @@
"progress": "^2.0.1",
"proxy-from-env": "^1.0.0",
"rimraf": "^2.6.1"
- },
- "devDependencies": {
- "puppeteer": "^1.11.0",
- "@pptr/testrunner": "^0.5.0",
- "@pptr/testserver": "^0.5.0",
- "@types/debug": "0.0.31",
- "@types/extract-zip": "^1.6.2",
- "@types/mime": "^2.0.0",
- "@types/node": "^8.10.34",
- "@types/rimraf": "^2.0.2",
- "@types/ws": "^6.0.1",
- "commonmark": "^0.28.1",
- "cross-env": "^5.0.5",
- "eslint": "^5.9.0",
- "esprima": "^4.0.0",
- "jpeg-js": "^0.3.4",
- "minimist": "^1.2.0",
- "ncp": "^2.0.0",
- "pixelmatch": "^4.0.2",
- "pngjs": "^3.3.3",
- "text-diff": "^1.0.1",
- "typescript": "3.1.6"
}
}
diff --git a/experimental/puppeteer-firefox/test/assets/consolelog.html b/experimental/puppeteer-firefox/test/assets/consolelog.html
deleted file mode 100644
index 7fa1b211a4d..00000000000
--- a/experimental/puppeteer-firefox/test/assets/consolelog.html
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
- console.log test
-
-
-
-
-
diff --git a/experimental/puppeteer-firefox/test/assets/csp.html b/experimental/puppeteer-firefox/test/assets/csp.html
deleted file mode 100644
index 34fc1fc1a5c..00000000000
--- a/experimental/puppeteer-firefox/test/assets/csp.html
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/experimental/puppeteer-firefox/test/assets/detect-touch.html b/experimental/puppeteer-firefox/test/assets/detect-touch.html
deleted file mode 100644
index 80a4123fbd9..00000000000
--- a/experimental/puppeteer-firefox/test/assets/detect-touch.html
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
- Detect Touch Test
-
-
-
-
-
-
diff --git a/experimental/puppeteer-firefox/test/assets/digits/0.png b/experimental/puppeteer-firefox/test/assets/digits/0.png
deleted file mode 100644
index ac3c4768edf..00000000000
Binary files a/experimental/puppeteer-firefox/test/assets/digits/0.png and /dev/null differ
diff --git a/experimental/puppeteer-firefox/test/assets/digits/1.png b/experimental/puppeteer-firefox/test/assets/digits/1.png
deleted file mode 100644
index 6768222729b..00000000000
Binary files a/experimental/puppeteer-firefox/test/assets/digits/1.png and /dev/null differ
diff --git a/experimental/puppeteer-firefox/test/assets/digits/2.png b/experimental/puppeteer-firefox/test/assets/digits/2.png
deleted file mode 100644
index b1daa4735d8..00000000000
Binary files a/experimental/puppeteer-firefox/test/assets/digits/2.png and /dev/null differ
diff --git a/experimental/puppeteer-firefox/test/assets/digits/3.png b/experimental/puppeteer-firefox/test/assets/digits/3.png
deleted file mode 100644
index 6eca99b21bd..00000000000
Binary files a/experimental/puppeteer-firefox/test/assets/digits/3.png and /dev/null differ
diff --git a/experimental/puppeteer-firefox/test/assets/digits/4.png b/experimental/puppeteer-firefox/test/assets/digits/4.png
deleted file mode 100644
index a721071e2cc..00000000000
Binary files a/experimental/puppeteer-firefox/test/assets/digits/4.png and /dev/null differ
diff --git a/experimental/puppeteer-firefox/test/assets/digits/5.png b/experimental/puppeteer-firefox/test/assets/digits/5.png
deleted file mode 100644
index 15cb19932a5..00000000000
Binary files a/experimental/puppeteer-firefox/test/assets/digits/5.png and /dev/null differ
diff --git a/experimental/puppeteer-firefox/test/assets/digits/6.png b/experimental/puppeteer-firefox/test/assets/digits/6.png
deleted file mode 100644
index 639f38439d9..00000000000
Binary files a/experimental/puppeteer-firefox/test/assets/digits/6.png and /dev/null differ
diff --git a/experimental/puppeteer-firefox/test/assets/digits/7.png b/experimental/puppeteer-firefox/test/assets/digits/7.png
deleted file mode 100644
index 5c1150b005a..00000000000
Binary files a/experimental/puppeteer-firefox/test/assets/digits/7.png and /dev/null differ
diff --git a/experimental/puppeteer-firefox/test/assets/digits/8.png b/experimental/puppeteer-firefox/test/assets/digits/8.png
deleted file mode 100644
index abb8b48b0b1..00000000000
Binary files a/experimental/puppeteer-firefox/test/assets/digits/8.png and /dev/null differ
diff --git a/experimental/puppeteer-firefox/test/assets/digits/9.png b/experimental/puppeteer-firefox/test/assets/digits/9.png
deleted file mode 100644
index 6a40a21c6f5..00000000000
Binary files a/experimental/puppeteer-firefox/test/assets/digits/9.png and /dev/null differ
diff --git a/experimental/puppeteer-firefox/test/assets/empty.html b/experimental/puppeteer-firefox/test/assets/empty.html
deleted file mode 100644
index e69de29bb2d..00000000000
diff --git a/experimental/puppeteer-firefox/test/assets/empty2.html b/experimental/puppeteer-firefox/test/assets/empty2.html
deleted file mode 100644
index e69de29bb2d..00000000000
diff --git a/experimental/puppeteer-firefox/test/assets/error.html b/experimental/puppeteer-firefox/test/assets/error.html
deleted file mode 100644
index 130400c0061..00000000000
--- a/experimental/puppeteer-firefox/test/assets/error.html
+++ /dev/null
@@ -1,15 +0,0 @@
-
diff --git a/experimental/puppeteer-firefox/test/assets/es6/es6import.js b/experimental/puppeteer-firefox/test/assets/es6/es6import.js
deleted file mode 100644
index 9a0a1095d15..00000000000
--- a/experimental/puppeteer-firefox/test/assets/es6/es6import.js
+++ /dev/null
@@ -1,2 +0,0 @@
-import num from './es6module.js';
-window.__es6injected = num;
\ No newline at end of file
diff --git a/experimental/puppeteer-firefox/test/assets/es6/es6module.js b/experimental/puppeteer-firefox/test/assets/es6/es6module.js
deleted file mode 100644
index a4012bff06c..00000000000
--- a/experimental/puppeteer-firefox/test/assets/es6/es6module.js
+++ /dev/null
@@ -1 +0,0 @@
-export default 42;
\ No newline at end of file
diff --git a/experimental/puppeteer-firefox/test/assets/es6/es6pathimport.js b/experimental/puppeteer-firefox/test/assets/es6/es6pathimport.js
deleted file mode 100644
index 99919621a82..00000000000
--- a/experimental/puppeteer-firefox/test/assets/es6/es6pathimport.js
+++ /dev/null
@@ -1,2 +0,0 @@
-import num from './es6/es6module.js';
-window.__es6injected = num;
\ No newline at end of file
diff --git a/experimental/puppeteer-firefox/test/assets/frames/frame.html b/experimental/puppeteer-firefox/test/assets/frames/frame.html
deleted file mode 100644
index 8f20d2da9fb..00000000000
--- a/experimental/puppeteer-firefox/test/assets/frames/frame.html
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-Hi, I'm frame
diff --git a/experimental/puppeteer-firefox/test/assets/frames/frameset.html b/experimental/puppeteer-firefox/test/assets/frames/frameset.html
deleted file mode 100644
index 4d56f888390..00000000000
--- a/experimental/puppeteer-firefox/test/assets/frames/frameset.html
+++ /dev/null
@@ -1,8 +0,0 @@
-
diff --git a/experimental/puppeteer-firefox/test/assets/frames/nested-frames.html b/experimental/puppeteer-firefox/test/assets/frames/nested-frames.html
deleted file mode 100644
index de1987586ff..00000000000
--- a/experimental/puppeteer-firefox/test/assets/frames/nested-frames.html
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
-
diff --git a/experimental/puppeteer-firefox/test/assets/frames/one-frame.html b/experimental/puppeteer-firefox/test/assets/frames/one-frame.html
deleted file mode 100644
index e941d795a27..00000000000
--- a/experimental/puppeteer-firefox/test/assets/frames/one-frame.html
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/experimental/puppeteer-firefox/test/assets/frames/script.js b/experimental/puppeteer-firefox/test/assets/frames/script.js
deleted file mode 100644
index be22256d16b..00000000000
--- a/experimental/puppeteer-firefox/test/assets/frames/script.js
+++ /dev/null
@@ -1 +0,0 @@
-console.log('Cheers!');
diff --git a/experimental/puppeteer-firefox/test/assets/frames/style.css b/experimental/puppeteer-firefox/test/assets/frames/style.css
deleted file mode 100644
index 5b5436e8740..00000000000
--- a/experimental/puppeteer-firefox/test/assets/frames/style.css
+++ /dev/null
@@ -1,3 +0,0 @@
-div {
- color: blue;
-}
diff --git a/experimental/puppeteer-firefox/test/assets/frames/two-frames.html b/experimental/puppeteer-firefox/test/assets/frames/two-frames.html
deleted file mode 100644
index b2ee853edac..00000000000
--- a/experimental/puppeteer-firefox/test/assets/frames/two-frames.html
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
diff --git a/experimental/puppeteer-firefox/test/assets/global-var.html b/experimental/puppeteer-firefox/test/assets/global-var.html
deleted file mode 100644
index b6be975038f..00000000000
--- a/experimental/puppeteer-firefox/test/assets/global-var.html
+++ /dev/null
@@ -1,3 +0,0 @@
-
\ No newline at end of file
diff --git a/experimental/puppeteer-firefox/test/assets/grid.html b/experimental/puppeteer-firefox/test/assets/grid.html
deleted file mode 100644
index 0bdbb1220e5..00000000000
--- a/experimental/puppeteer-firefox/test/assets/grid.html
+++ /dev/null
@@ -1,52 +0,0 @@
-
-
-
diff --git a/experimental/puppeteer-firefox/test/assets/injectedfile.js b/experimental/puppeteer-firefox/test/assets/injectedfile.js
deleted file mode 100644
index 6cb04f1bba0..00000000000
--- a/experimental/puppeteer-firefox/test/assets/injectedfile.js
+++ /dev/null
@@ -1,2 +0,0 @@
-window.__injected = 42;
-window.__injectedError = new Error('hi');
\ No newline at end of file
diff --git a/experimental/puppeteer-firefox/test/assets/injectedstyle.css b/experimental/puppeteer-firefox/test/assets/injectedstyle.css
deleted file mode 100644
index aa1634c2550..00000000000
--- a/experimental/puppeteer-firefox/test/assets/injectedstyle.css
+++ /dev/null
@@ -1,3 +0,0 @@
-body {
- background-color: red;
-}
diff --git a/experimental/puppeteer-firefox/test/assets/input/button.html b/experimental/puppeteer-firefox/test/assets/input/button.html
deleted file mode 100644
index d4c6e13fd28..00000000000
--- a/experimental/puppeteer-firefox/test/assets/input/button.html
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
- Button test
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/experimental/puppeteer-firefox/test/assets/input/checkbox.html b/experimental/puppeteer-firefox/test/assets/input/checkbox.html
deleted file mode 100644
index ca56762e2b3..00000000000
--- a/experimental/puppeteer-firefox/test/assets/input/checkbox.html
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
-
- Selection Test
-
-
-
-
-
-
-
diff --git a/experimental/puppeteer-firefox/test/assets/input/keyboard.html b/experimental/puppeteer-firefox/test/assets/input/keyboard.html
deleted file mode 100644
index 9f1d48152d9..00000000000
--- a/experimental/puppeteer-firefox/test/assets/input/keyboard.html
+++ /dev/null
@@ -1,44 +0,0 @@
-
-
-
- Keyboard test
-
-
-
-
-
-
\ No newline at end of file
diff --git a/experimental/puppeteer-firefox/test/assets/input/scrollable.html b/experimental/puppeteer-firefox/test/assets/input/scrollable.html
deleted file mode 100644
index 885d3739d5f..00000000000
--- a/experimental/puppeteer-firefox/test/assets/input/scrollable.html
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-
- Scrollable test
-
-
-
-
-
-
\ No newline at end of file
diff --git a/experimental/puppeteer-firefox/test/assets/input/select.html b/experimental/puppeteer-firefox/test/assets/input/select.html
deleted file mode 100644
index 879a537a766..00000000000
--- a/experimental/puppeteer-firefox/test/assets/input/select.html
+++ /dev/null
@@ -1,69 +0,0 @@
-
-
-
- Selection Test
-
-
-
-
-
-
diff --git a/experimental/puppeteer-firefox/test/assets/input/textarea.html b/experimental/puppeteer-firefox/test/assets/input/textarea.html
deleted file mode 100644
index 6d5be760740..00000000000
--- a/experimental/puppeteer-firefox/test/assets/input/textarea.html
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
- Textarea test
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/experimental/puppeteer-firefox/test/assets/mobile.html b/experimental/puppeteer-firefox/test/assets/mobile.html
deleted file mode 100644
index 8e94b2fe291..00000000000
--- a/experimental/puppeteer-firefox/test/assets/mobile.html
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/experimental/puppeteer-firefox/test/assets/modernizr.js b/experimental/puppeteer-firefox/test/assets/modernizr.js
deleted file mode 100644
index 7991a4ec402..00000000000
--- a/experimental/puppeteer-firefox/test/assets/modernizr.js
+++ /dev/null
@@ -1,3 +0,0 @@
-/*! modernizr 3.5.0 (Custom Build) | MIT *
-* https://modernizr.com/download/?-touchevents-setclasses !*/
-!function(e,n,t){function o(e,n){return typeof e===n}function s(){var e,n,t,s,a,i,r;for(var l in c)if(c.hasOwnProperty(l)){if(e=[],n=c[l],n.name&&(e.push(n.name.toLowerCase()),n.options&&n.options.aliases&&n.options.aliases.length))for(t=0;t
- button {
- position: absolute;
- width: 100px;
- height: 20px;
- }
-
- #btn0 { right: 0px; top: 0; }
- #btn1 { right: -10px; top: 25px; }
- #btn2 { right: -20px; top: 50px; }
- #btn3 { right: -30px; top: 75px; }
- #btn4 { right: -40px; top: 100px; }
- #btn5 { right: -50px; top: 125px; }
- #btn6 { right: -60px; top: 150px; }
- #btn7 { right: -70px; top: 175px; }
- #btn8 { right: -80px; top: 200px; }
- #btn9 { right: -90px; top: 225px; }
- #btn10 { right: -100px; top: 250px; }
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/experimental/puppeteer-firefox/test/assets/one-style.css b/experimental/puppeteer-firefox/test/assets/one-style.css
deleted file mode 100644
index 7b26410d8a1..00000000000
--- a/experimental/puppeteer-firefox/test/assets/one-style.css
+++ /dev/null
@@ -1,3 +0,0 @@
-body {
- background-color: pink;
-}
diff --git a/experimental/puppeteer-firefox/test/assets/one-style.html b/experimental/puppeteer-firefox/test/assets/one-style.html
deleted file mode 100644
index 4760f2b9f7e..00000000000
--- a/experimental/puppeteer-firefox/test/assets/one-style.html
+++ /dev/null
@@ -1,2 +0,0 @@
-
-hello, world!
diff --git a/experimental/puppeteer-firefox/test/assets/tamperable.html b/experimental/puppeteer-firefox/test/assets/tamperable.html
deleted file mode 100644
index d027e970385..00000000000
--- a/experimental/puppeteer-firefox/test/assets/tamperable.html
+++ /dev/null
@@ -1,3 +0,0 @@
-
\ No newline at end of file
diff --git a/experimental/puppeteer-firefox/test/assets/title.html b/experimental/puppeteer-firefox/test/assets/title.html
deleted file mode 100644
index 88a86ce412b..00000000000
--- a/experimental/puppeteer-firefox/test/assets/title.html
+++ /dev/null
@@ -1 +0,0 @@
-Woof-Woof
diff --git a/experimental/puppeteer-firefox/test/assets/wrappedlink.html b/experimental/puppeteer-firefox/test/assets/wrappedlink.html
deleted file mode 100644
index 429b6e91567..00000000000
--- a/experimental/puppeteer-firefox/test/assets/wrappedlink.html
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
diff --git a/experimental/puppeteer-firefox/test/browser.spec.js b/experimental/puppeteer-firefox/test/browser.spec.js
deleted file mode 100644
index d2eb98de316..00000000000
--- a/experimental/puppeteer-firefox/test/browser.spec.js
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * Copyright 2018 Google Inc. All rights reserved.
- *
- * 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.
- */
-
-module.exports.addTests = function({testRunner, expect, product}) {
- const {describe, xdescribe, fdescribe} = testRunner;
- const {it, fit, xit} = testRunner;
- const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;
-
- describe('Browser.process', function() {
- it('should return child_process instance', async function({browser}) {
- const process = await browser.process();
- expect(process.pid).toBeGreaterThan(0);
- });
- });
-};
-
-
diff --git a/experimental/puppeteer-firefox/test/browsercontext.spec.js b/experimental/puppeteer-firefox/test/browsercontext.spec.js
deleted file mode 100644
index 11cf3c0ca91..00000000000
--- a/experimental/puppeteer-firefox/test/browsercontext.spec.js
+++ /dev/null
@@ -1,160 +0,0 @@
-/**
- * Copyright 2018 Google Inc. All rights reserved.
- *
- * 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 utils = require('./utils');
-const {TimeoutError} = require('../Errors');
-
-module.exports.addTests = function({testRunner, expect, puppeteer, product}) {
- const {describe, xdescribe, fdescribe} = testRunner;
- const {it, fit, xit} = testRunner;
- const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;
-
- const FFOX = product === 'firefox';
- const CHROME = product === 'chromium';
-
- describe('BrowserContext', function() {
- it('should have default context', async function({browser, server}) {
- expect(browser.browserContexts().length).toBe(1);
- const defaultContext = browser.browserContexts()[0];
- expect(defaultContext.isIncognito()).toBe(false);
- let error = null;
- await defaultContext.close().catch(e => error = e);
- expect(browser.defaultBrowserContext()).toBe(defaultContext);
- expect(error.message).toContain('cannot be closed');
- });
- it('should create new incognito context', async function({browser, server}) {
- expect(browser.browserContexts().length).toBe(1);
- const context = await browser.createIncognitoBrowserContext();
- expect(context.isIncognito()).toBe(true);
- expect(browser.browserContexts().length).toBe(2);
- expect(browser.browserContexts().indexOf(context) !== -1).toBe(true);
- await context.close();
- expect(browser.browserContexts().length).toBe(1);
- });
- it('should close all belonging targets once closing context', async function({browser, server}) {
- expect((await browser.pages()).length).toBe(1);
-
- const context = await browser.createIncognitoBrowserContext();
- await context.newPage();
- expect((await browser.pages()).length).toBe(2);
- expect((await context.pages()).length).toBe(1);
-
- await context.close();
- expect((await browser.pages()).length).toBe(1);
- });
- it('window.open should use parent tab context', async function({browser, server}) {
- const context = await browser.createIncognitoBrowserContext();
- const page = await context.newPage();
- await page.goto(server.EMPTY_PAGE);
- const [popupTarget] = await Promise.all([
- utils.waitEvent(browser, 'targetcreated'),
- page.evaluate(url => window.open(url), server.EMPTY_PAGE)
- ]);
- expect(popupTarget.browserContext()).toBe(context);
- await context.close();
- });
- it('should fire target events', async function({browser, server}) {
- const context = await browser.createIncognitoBrowserContext();
- const events = [];
- context.on('targetcreated', target => events.push('CREATED: ' + target.url()));
- context.on('targetchanged', target => events.push('CHANGED: ' + target.url()));
- context.on('targetdestroyed', target => events.push('DESTROYED: ' + target.url()));
- const page = await context.newPage();
- await page.goto(server.EMPTY_PAGE);
- await page.close();
- expect(events).toEqual([
- 'CREATED: about:blank',
- `CHANGED: ${server.EMPTY_PAGE}`,
- `DESTROYED: ${server.EMPTY_PAGE}`
- ]);
- await context.close();
- });
- it('should wait for a target', async function({browser, server}) {
- const context = await browser.createIncognitoBrowserContext();
- let resolved = false;
- const targetPromise = context.waitForTarget(target => target.url() === server.EMPTY_PAGE);
- targetPromise.then(() => resolved = true);
- const page = await context.newPage();
- expect(resolved).toBe(false);
- await page.goto(server.EMPTY_PAGE);
- const target = await targetPromise;
- expect(await target.page()).toBe(page);
- await context.close();
- });
- it('should timeout waiting for a non-existent target', async function({browser, server}) {
- const context = await browser.createIncognitoBrowserContext();
- const error = await context.waitForTarget(target => target.url() === server.EMPTY_PAGE, {timeout: 1}).catch(e => e);
- expect(error).toBeInstanceOf(TimeoutError);
- await context.close();
- });
- it('should isolate localStorage and cookies', async function({browser, server}) {
- // Create two incognito contexts.
- const context1 = await browser.createIncognitoBrowserContext();
- const context2 = await browser.createIncognitoBrowserContext();
- expect(context1.targets().length).toBe(0);
- expect(context2.targets().length).toBe(0);
-
- // Create a page in first incognito context.
- const page1 = await context1.newPage();
- await page1.goto(server.EMPTY_PAGE);
- await page1.evaluate(() => {
- localStorage.setItem('name', 'page1');
- document.cookie = 'name=page1';
- });
-
- expect(context1.targets().length).toBe(1);
- expect(context2.targets().length).toBe(0);
-
- // Create a page in second incognito context.
- const page2 = await context2.newPage();
- await page2.goto(server.EMPTY_PAGE);
- await page2.evaluate(() => {
- localStorage.setItem('name', 'page2');
- document.cookie = 'name=page2';
- });
-
- expect(context1.targets().length).toBe(1);
- expect(context1.targets()[0]).toBe(page1.target());
- expect(context2.targets().length).toBe(1);
- expect(context2.targets()[0]).toBe(page2.target());
-
- // Make sure pages don't share localstorage or cookies.
- expect(await page1.evaluate(() => localStorage.getItem('name'))).toBe('page1');
- expect(await page1.evaluate(() => document.cookie)).toBe('name=page1');
- expect(await page2.evaluate(() => localStorage.getItem('name'))).toBe('page2');
- expect(await page2.evaluate(() => document.cookie)).toBe('name=page2');
-
- // Cleanup contexts.
- await Promise.all([
- context1.close(),
- context2.close()
- ]);
- expect(browser.browserContexts().length).toBe(1);
- });
- (FFOX ? xit : it)('should work across sessions', async function({browser, server}) {
- expect(browser.browserContexts().length).toBe(1);
- const context = await browser.createIncognitoBrowserContext();
- expect(browser.browserContexts().length).toBe(2);
- const remoteBrowser = await puppeteer.connect({
- browserWSEndpoint: browser.wsEndpoint()
- });
- const contexts = remoteBrowser.browserContexts();
- expect(contexts.length).toBe(2);
- await remoteBrowser.disconnect();
- await context.close();
- });
- });
-};
diff --git a/experimental/puppeteer-firefox/test/chromiumonly.spec.js b/experimental/puppeteer-firefox/test/chromiumonly.spec.js
deleted file mode 100644
index 00b21c716ae..00000000000
--- a/experimental/puppeteer-firefox/test/chromiumonly.spec.js
+++ /dev/null
@@ -1,24 +0,0 @@
-module.exports.addTests = function({testRunner, expect, product}) {
- const {describe, xdescribe, fdescribe} = testRunner;
- const {it, fit, xit} = testRunner;
- const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;
-
- describe('Chromium-specific tests', function() {
- describe('Browser.version', function() {
- xit('should return whether we are in headless', async({browser}) => {
- const version = await browser.version();
- expect(version.length).toBeGreaterThan(0);
- expect(version.startsWith('Headless')).toBe(headless);
- });
- });
-
- describe('Browser.userAgent', function() {
- it('should include WebKit', async({browser}) => {
- const userAgent = await browser.userAgent();
- expect(userAgent.length).toBeGreaterThan(0);
- expect(userAgent).toContain('WebKit');
- });
- });
- });
-};
-
diff --git a/experimental/puppeteer-firefox/test/click.spec.js b/experimental/puppeteer-firefox/test/click.spec.js
deleted file mode 100644
index 1384660a5a7..00000000000
--- a/experimental/puppeteer-firefox/test/click.spec.js
+++ /dev/null
@@ -1,211 +0,0 @@
-/**
- * Copyright 2018 Google Inc. All rights reserved.
- *
- * 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 utils = require('./utils');
-const os = require('os');
-const DeviceDescriptors = require('puppeteer/DeviceDescriptors');
-const iPhone = DeviceDescriptors['iPhone 6'];
-
-module.exports.addTests = function({testRunner, expect, product}) {
- const {describe, xdescribe, fdescribe} = testRunner;
- const {it, fit, xit} = testRunner;
- const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;
-
- const FFOX = product === 'firefox';
- const CHROME = product === 'chromium';
-
- describe('Page.click', () => {
- it('should click the button', async({page, server}) => {
- await page.goto(server.PREFIX + '/input/button.html');
- await page.click('button');
- expect(await page.evaluate(() => result)).toBe('Clicked');
- });
- it('should click offscreen buttons', async({page, server}) => {
- await page.goto(server.PREFIX + '/offscreenbuttons.html');
- const messages = [];
- page.on('console', msg => messages.push(msg.text()));
- for (let i = 0; i < 11; ++i) {
- // We might've scrolled to click a button - reset to (0, 0).
- await page.evaluate(() => window.scrollTo(0, 0));
- await page.click(`#btn${i}`);
- }
- expect(messages).toEqual([
- 'button #0 clicked',
- 'button #1 clicked',
- 'button #2 clicked',
- 'button #3 clicked',
- 'button #4 clicked',
- 'button #5 clicked',
- 'button #6 clicked',
- 'button #7 clicked',
- 'button #8 clicked',
- 'button #9 clicked',
- 'button #10 clicked'
- ]);
- });
- it('should click wrapped links', async({page, server}) => {
- await page.goto(server.PREFIX + '/wrappedlink.html');
- await page.click('a');
- expect(await page.evaluate(() => window.__clicked)).toBe(true);
- });
- it('should click on checkbox input and toggle', async({page, server}) => {
- await page.goto(server.PREFIX + '/input/checkbox.html');
- expect(await page.evaluate(() => result.check)).toBe(null);
- await page.click('input#agree');
- expect(await page.evaluate(() => result.check)).toBe(true);
- expect(await page.evaluate(() => result.events)).toEqual([
- 'mouseover',
- 'mouseenter',
- 'mousemove',
- 'mousedown',
- 'mouseup',
- 'click',
- 'input',
- 'change',
- ]);
- await page.click('input#agree');
- expect(await page.evaluate(() => result.check)).toBe(false);
- });
- it('should click on checkbox label and toggle', async({page, server}) => {
- await page.goto(server.PREFIX + '/input/checkbox.html');
- expect(await page.evaluate(() => result.check)).toBe(null);
- await page.click('label[for="agree"]');
- expect(await page.evaluate(() => result.check)).toBe(true);
- expect(await page.evaluate(() => result.events)).toEqual([
- 'click',
- 'input',
- 'change',
- ]);
- await page.click('label[for="agree"]');
- expect(await page.evaluate(() => result.check)).toBe(false);
- });
- it('should fail to click a missing button', async({page, server}) => {
- await page.goto(server.PREFIX + '/input/button.html');
- let error = null;
- await page.click('button.does-not-exist').catch(e => error = e);
- expect(error.message).toBe('No node found for selector: button.does-not-exist');
- });
- // @see https://github.com/GoogleChrome/puppeteer/issues/161
- it('should not hang with touch-enabled viewports', async({page, server}) => {
- await page.setViewport(iPhone.viewport);
- await page.mouse.down();
- await page.mouse.move(100, 10);
- await page.mouse.up();
- });
- it('should click the button after navigation ', async({page, server}) => {
- await page.goto(server.PREFIX + '/input/button.html');
- await page.click('button');
- await page.goto(server.PREFIX + '/input/button.html');
- await page.click('button');
- expect(await page.evaluate(() => result)).toBe('Clicked');
- });
- it('should scroll and click the button', async({page, server}) => {
- await page.goto(server.PREFIX + '/input/scrollable.html');
- await page.click('#button-5');
- expect(await page.evaluate(() => document.querySelector('#button-5').textContent)).toBe('clicked');
- await page.click('#button-80');
- expect(await page.evaluate(() => document.querySelector('#button-80').textContent)).toBe('clicked');
- });
- it('should double click the button', async({page, server}) => {
- await page.goto(server.PREFIX + '/input/button.html');
- await page.evaluate(() => {
- window.double = false;
- const button = document.querySelector('button');
- button.addEventListener('dblclick', event => {
- window.double = true;
- });
- });
- const button = await page.$('button');
- await button.click({ clickCount: 2 });
- expect(await page.evaluate('double')).toBe(true);
- expect(await page.evaluate('result')).toBe('Clicked');
- });
- it('should click a partially obscured button', async({page, server}) => {
- await page.goto(server.PREFIX + '/input/button.html');
- await page.evaluate(() => {
- const button = document.querySelector('button');
- button.textContent = 'Some really long text that will go offscreen';
- button.style.position = 'absolute';
- button.style.left = '368px';
- });
- await page.click('button');
- expect(await page.evaluate(() => window.result)).toBe('Clicked');
- });
- it('should select the text by triple clicking', async({page, server}) => {
- await page.goto(server.PREFIX + '/input/textarea.html');
- await page.focus('textarea');
- const text = 'This is the text that we are going to try to select. Let\'s see how it goes.';
- await page.keyboard.type(text);
- await page.click('textarea');
- await page.click('textarea', {clickCount: 2});
- await page.click('textarea', {clickCount: 3});
- expect(await page.evaluate(() => {
- const textarea = document.querySelector('textarea');
- return textarea.value.substring(textarea.selectionStart, textarea.selectionEnd);
- })).toBe(text);
- });
- it('should fire contextmenu event on right click', async({page, server}) => {
- await page.goto(server.PREFIX + '/input/scrollable.html');
- await page.click('#button-8', {button: 'right'});
- expect(await page.evaluate(() => document.querySelector('#button-8').textContent)).toBe('context menu');
- });
- it('should set modifier keys on click', async({page, server}) => {
- await page.goto(server.PREFIX + '/input/scrollable.html');
- await page.evaluate(() => document.querySelector('#button-3').addEventListener('mousedown', e => window.lastEvent = e, true));
- const modifiers = {'Shift': 'shiftKey', 'Control': 'ctrlKey', 'Alt': 'altKey', 'Meta': 'metaKey'};
- // In Firefox, the Meta modifier only exists on Mac
- if (FFOX && os.platform() !== 'darwin')
- delete modifiers['Meta'];
- for (const modifier in modifiers) {
- await page.keyboard.down(modifier);
- await page.click('#button-3');
- if (!(await page.evaluate(mod => window.lastEvent[mod], modifiers[modifier])))
- throw new Error(modifiers[modifier] + ' should be true');
- await page.keyboard.up(modifier);
- }
- await page.click('#button-3');
- for (const modifier in modifiers) {
- if ((await page.evaluate(mod => window.lastEvent[mod], modifiers[modifier])))
- throw new Error(modifiers[modifier] + ' should be false');
- }
- });
- // @see https://github.com/GoogleChrome/puppeteer/issues/206
- it('should click links which cause navigation', async({page, server}) => {
- await page.setContent(`empty.html`);
- // This await should not hang.
- await page.click('a');
- });
- it('should click the button inside an iframe', async({page, server}) => {
- await page.goto(server.EMPTY_PAGE);
- await page.setContent('spacer
');
- await utils.attachFrame(page, 'button-test', server.PREFIX + '/input/button.html');
- const frame = page.frames()[1];
- const button = await frame.$('button');
- await button.click();
- expect(await frame.evaluate(() => window.result)).toBe('Clicked');
- });
- it('should click the button with deviceScaleFactor set', async({page, server}) => {
- await page.setViewport({width: 400, height: 400, deviceScaleFactor: 5});
- expect(await page.evaluate(() => window.devicePixelRatio)).toBe(5);
- await page.setContent('spacer
');
- await utils.attachFrame(page, 'button-test', server.PREFIX + '/input/button.html');
- const frame = page.frames()[1];
- const button = await frame.$('button');
- await button.click();
- expect(await frame.evaluate(() => window.result)).toBe('Clicked');
- });
- });
-};
-
diff --git a/experimental/puppeteer-firefox/test/dialog.spec.js b/experimental/puppeteer-firefox/test/dialog.spec.js
deleted file mode 100644
index ac4211b1dab..00000000000
--- a/experimental/puppeteer-firefox/test/dialog.spec.js
+++ /dev/null
@@ -1,39 +0,0 @@
-const utils = require('./utils');
-
-module.exports.addTests = function({testRunner, expect, product}) {
- const {describe, xdescribe, fdescribe} = testRunner;
- const {it, fit, xit} = testRunner;
- const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;
-
- const FFOX = product === 'firefox';
- const CHROME = product === 'chromium';
-
- describe('Page.Events.Dialog', function() {
- it('should fire', async({page, server}) => {
- page.on('dialog', dialog => {
- expect(dialog.type()).toBe('alert');
- expect(dialog.defaultValue()).toBe('');
- expect(dialog.message()).toBe('yo');
- dialog.accept();
- });
- await page.evaluate(() => alert('yo'));
- });
- it('should allow accepting prompts', async({page, server}) => {
- page.on('dialog', dialog => {
- expect(dialog.type()).toBe('prompt');
- expect(dialog.defaultValue()).toBe('yes.');
- expect(dialog.message()).toBe('question?');
- dialog.accept('answer!');
- });
- const result = await page.evaluate(() => prompt('question?', 'yes.'));
- expect(result).toBe('answer!');
- });
- it('should dismiss the prompt', async({page, server}) => {
- page.on('dialog', dialog => {
- dialog.dismiss();
- });
- const result = await page.evaluate(() => prompt('question?'));
- expect(result).toBe(null);
- });
- });
-};
diff --git a/experimental/puppeteer-firefox/test/elementhandle.spec.js b/experimental/puppeteer-firefox/test/elementhandle.spec.js
deleted file mode 100644
index 7d8909f4084..00000000000
--- a/experimental/puppeteer-firefox/test/elementhandle.spec.js
+++ /dev/null
@@ -1,103 +0,0 @@
-/**
- * Copyright 2018 Google Inc. All rights reserved.
- *
- * 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 utils = require('./utils');
-
-module.exports.addTests = function({testRunner, expect, product}) {
- const {describe, xdescribe, fdescribe} = testRunner;
- const {it, fit, xit} = testRunner;
- const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;
-
- const FFOX = product === 'firefox';
- const CHROME = product === 'chromium';
-
- describe('JSHandle.asElement', function() {
- it('should work', async({page, server}) => {
- await page.setContent('');
- const handle = await page.evaluateHandle(() => document.querySelector('section'));
- const element = handle.asElement();
- expect(element).not.toBe(null);
- });
- it('should work with nullified Node', async({page, server}) => {
- await page.setContent('');
- await page.evaluate(() => delete Node);
- const handle = await page.evaluateHandle(() => document.querySelector('section'));
- const element = handle.asElement();
- expect(element).not.toBe(null);
- });
- it('should return null for non-elements', async({page, server}) => {
- const handle = await page.evaluateHandle(() => ({foo: 'bar'}));
- expect(handle.asElement()).toBe(null);
- });
- });
-
- describe('ElementHandle.isIntersectingViewport', function() {
- it('should work', async({page, server}) => {
- await page.goto(server.PREFIX + '/offscreenbuttons.html');
- for (let i = 0; i < 11; ++i) {
- const button = await page.$('#btn' + i);
- // All but last button are visible.
- const visible = i < 10;
- expect(await button.isIntersectingViewport()).toBe(visible);
- }
- });
- });
-
- describe('ElementHandle.boundingBox', function() {
- it('should work', async({page, server}) => {
- await page.setViewport({width: 500, height: 500});
- await page.goto(server.PREFIX + '/grid.html');
- const elementHandle = await page.$('.box:nth-of-type(13)');
- const box = await elementHandle.boundingBox();
- expect(box).toEqual({ x: 100, y: 50, width: 50, height: 50 });
- });
- xit('should handle nested frames', async({page, server}) => {
- await page.setViewport({width: 500, height: 500});
- await page.goto(server.PREFIX + '/frames/nested-frames.html');
- const nestedFrame = page.frames()[1].childFrames()[1];
- const elementHandle = await nestedFrame.$('div');
- const box = await elementHandle.boundingBox();
- await new Promise(() => {});
- expect(box).toEqual({ x: 28, y: 260, width: 264, height: 18 });
- });
- it('should return null for invisible elements', async({page, server}) => {
- await page.setContent('hi
');
- const element = await page.$('div');
- expect(await element.boundingBox()).toBe(null);
- });
- it('should force a layout', async({page, server}) => {
- await page.setViewport({ width: 500, height: 500 });
- await page.setContent('hello
');
- const elementHandle = await page.$('div');
- await page.evaluate(element => element.style.height = '200px', elementHandle);
- const box = await elementHandle.boundingBox();
- expect(box).toEqual({ x: 8, y: 8, width: 100, height: 200 });
- });
- it('should work with SVG nodes', async({page, server}) => {
- await page.setContent(`
-
- `);
- const element = await page.$('#therect');
- const pptrBoundingBox = await element.boundingBox();
- const webBoundingBox = await page.evaluate(e => {
- const rect = e.getBoundingClientRect();
- return {x: rect.x, y: rect.y, width: rect.width, height: rect.height};
- }, element);
- expect(pptrBoundingBox).toEqual(webBoundingBox);
- });
- });
-};
diff --git a/experimental/puppeteer-firefox/test/emulation.spec.js b/experimental/puppeteer-firefox/test/emulation.spec.js
deleted file mode 100644
index 61acb7cf3d8..00000000000
--- a/experimental/puppeteer-firefox/test/emulation.spec.js
+++ /dev/null
@@ -1,86 +0,0 @@
-/**
- * Copyright 2018 Google Inc. All rights reserved.
- *
- * 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 DeviceDescriptors = require('puppeteer/DeviceDescriptors');
-const iPhone = DeviceDescriptors['iPhone 6'];
-const iPhoneLandscape = DeviceDescriptors['iPhone 6 landscape'];
-
-module.exports.addTests = function({testRunner, expect, product}) {
- const {describe, xdescribe, fdescribe} = testRunner;
- const {it, fit, xit} = testRunner;
- const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;
-
- const FFOX = product === 'firefox';
- const CHROME = product === 'chromium';
-
- describe('Page.viewport', function() {
- it('should get the proper viewport size', async({page, server}) => {
- expect(page.viewport()).toEqual({width: 800, height: 600});
- await page.setViewport({width: 123, height: 456});
- expect(page.viewport()).toEqual({width: 123, height: 456});
- });
- it('should support mobile emulation', async({page, server}) => {
- await page.goto(server.PREFIX + '/mobile.html');
- expect(await page.evaluate(() => window.innerWidth)).toBe(800);
- await page.setViewport(iPhone.viewport);
- expect(await page.evaluate(() => window.innerWidth)).toBe(375);
- await page.setViewport({width: 400, height: 300});
- expect(await page.evaluate(() => window.innerWidth)).toBe(400);
- });
- it('should support touch emulation', async({page, server}) => {
- await page.goto(server.PREFIX + '/mobile.html');
- expect(await page.evaluate(() => 'ontouchstart' in window)).toBe(false);
- await page.setViewport(iPhone.viewport);
- expect(await page.evaluate(() => 'ontouchstart' in window)).toBe(true);
- expect(await page.evaluate(dispatchTouch)).toBe('Received touch');
- await page.setViewport({width: 100, height: 100});
- expect(await page.evaluate(() => 'ontouchstart' in window)).toBe(false);
-
- function dispatchTouch() {
- let fulfill;
- const promise = new Promise(x => fulfill = x);
- window.ontouchstart = function(e) {
- fulfill('Received touch');
- };
- window.dispatchEvent(new Event('touchstart'));
-
- fulfill('Did not receive touch');
-
- return promise;
- }
- });
- it('should be detectable by Modernizr', async({page, server}) => {
- await page.goto(server.PREFIX + '/detect-touch.html');
- expect(await page.evaluate(() => document.body.textContent.trim())).toBe('NO');
- await page.setViewport(iPhone.viewport);
- await page.goto(server.PREFIX + '/detect-touch.html');
- expect(await page.evaluate(() => document.body.textContent.trim())).toBe('YES');
- });
- it('should detect touch when applying viewport with touches', async({page, server}) => {
- await page.setViewport({ width: 800, height: 600, hasTouch: true });
- await page.addScriptTag({url: server.PREFIX + '/modernizr.js'});
- expect(await page.evaluate(() => Modernizr.touchevents)).toBe(true);
- });
- xit('should support landscape emulation', async({page, server}) => {
- await page.goto(server.PREFIX + '/mobile.html');
- expect(await page.evaluate(() => screen.orientation.type)).toBe('portrait-primary');
- await page.setViewport(iPhoneLandscape.viewport);
- expect(await page.evaluate(() => screen.orientation.type)).toBe('landscape-primary');
- await page.setViewport({width: 100, height: 100});
- expect(await page.evaluate(() => screen.orientation.type)).toBe('portrait-primary');
- });
- });
-};
-
diff --git a/experimental/puppeteer-firefox/test/evaluation.spec.js b/experimental/puppeteer-firefox/test/evaluation.spec.js
deleted file mode 100644
index 0a726397d95..00000000000
--- a/experimental/puppeteer-firefox/test/evaluation.spec.js
+++ /dev/null
@@ -1,181 +0,0 @@
-/**
- * Copyright 2018 Google Inc. All rights reserved.
- *
- * 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 utils = require('./utils');
-
-module.exports.addTests = function({testRunner, expect, product}) {
- const {describe, xdescribe, fdescribe} = testRunner;
- const {it, fit, xit} = testRunner;
- const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;
-
- const FFOX = product === 'firefox';
- const CHROME = product === 'chromium';
-
- describe('Page.evaluate', function() {
- it('should work', async({page, server}) => {
- const result = await page.evaluate(() => 7 * 3);
- expect(result).toBe(21);
- });
- it('should throw when evaluation triggers reload', async({page, server}) => {
- let error = null;
- await page.evaluate(() => {
- location.reload();
- return new Promise(resolve => {
- setTimeout(() => resolve(1), 0);
- });
- }).catch(e => error = e);
- expect(error.message).toContain('Protocol error');
- });
- it('should await promise', async({page, server}) => {
- const result = await page.evaluate(() => Promise.resolve(8 * 7));
- expect(result).toBe(56);
- });
- it('should reject promise with exception', async({page, server}) => {
- let error = null;
- await page.evaluate(() => not.existing.object.property).catch(e => error = e);
- expect(error).toBeTruthy();
- expect(error.message).toContain('not is not defined');
- });
- it('should support thrown strings as error messages', async({page, server}) => {
- let error = null;
- await page.evaluate(() => { throw 'qwerty'; }).catch(e => error = e);
- expect(error).toBeTruthy();
- expect(error.message).toContain('qwerty');
- });
- it('should support thrown numbers as error messages', async({page, server}) => {
- let error = null;
- await page.evaluate(() => { throw 100500; }).catch(e => error = e);
- expect(error).toBeTruthy();
- expect(error.message).toContain('100500');
- });
- it('should return complex objects', async({page, server}) => {
- const object = {foo: 'bar!'};
- const result = await page.evaluate(a => a, object);
- expect(result).not.toBe(object);
- expect(result).toEqual(object);
- });
- it('should transfer NaN', async({page, server}) => {
- const result = await page.evaluate(a => a, NaN);
- expect(Object.is(result, NaN)).toBe(true);
- });
- it('should transfer -0', async({page, server}) => {
- const result = await page.evaluate(a => a, -0);
- expect(Object.is(result, -0)).toBe(true);
- });
- it('should transfer Infinity', async({page, server}) => {
- const result = await page.evaluate(a => a, Infinity);
- expect(Object.is(result, Infinity)).toBe(true);
- });
- it('should transfer -Infinity', async({page, server}) => {
- const result = await page.evaluate(a => a, -Infinity);
- expect(Object.is(result, -Infinity)).toBe(true);
- });
- it('should transfer arrays', async({page, server}) => {
- const result = await page.evaluate(a => a, [1, 2, 3]);
- expect(result).toEqual([1,2,3]);
- });
- it('should transfer arrays as arrays, not objects', async({page, server}) => {
- const result = await page.evaluate(a => Array.isArray(a), [1, 2, 3]);
- expect(result).toBe(true);
- });
- it('should accept "undefined" as one of multiple parameters', async({page, server}) => {
- const result = await page.evaluate((a, b) => Object.is(a, undefined) && Object.is(b, 'foo'), undefined, 'foo');
- expect(result).toBe(true);
- });
- it('should properly serialize null fields', async({page}) => {
- expect(await page.evaluate(() => ({a: undefined}))).toEqual({});
- });
- it('should return undefined for non-serializable objects', async({page, server}) => {
- expect(await page.evaluate(() => window)).toBe(undefined);
- });
- xit('should return undefined for objects with symbols', async({page, server}) => {
- expect(await page.evaluate(() => [Symbol('foo4')])).toBe(undefined);
- });
- it('should fail for circular object', async({page, server}) => {
- const result = await page.evaluate(() => {
- const a = {};
- const b = {a};
- a.b = b;
- return a;
- });
- expect(result).toBe(undefined);
- });
- it('should accept a string', async({page, server}) => {
- const result = await page.evaluate('1 + 2');
- expect(result).toBe(3);
- });
- it('should accept a string with semi colons', async({page, server}) => {
- const result = await page.evaluate('1 + 5;');
- expect(result).toBe(6);
- });
- it('should accept a string with comments', async({page, server}) => {
- const result = await page.evaluate('2 + 5;\n// do some math!');
- expect(result).toBe(7);
- });
- it('should simulate a user gesture', async({page, server}) => {
- const result = await page.evaluate(() => document.execCommand('copy'));
- expect(result).toBe(true);
- });
- it('should evaluate in the page context', async({page, server}) => {
- await page.goto(server.PREFIX + '/global-var.html');
- expect(await page.evaluate('globalVar')).toBe(123);
- });
- it('should modify global environment', async({page}) => {
- await page.evaluate(() => window.globalVar = 123);
- expect(await page.evaluate('globalVar')).toBe(123);
- });
- });
-
- describe('Frame.evaluate', function() {
- it('should have different execution contexts', async({page, server}) => {
- await page.goto(server.EMPTY_PAGE);
- await utils.attachFrame(page, 'frame1', server.EMPTY_PAGE2);
- expect(page.frames().length).toBe(2);
- await page.frames()[0].evaluate(() => window.FOO = 'foo');
- await page.frames()[1].evaluate(() => window.FOO = 'bar');
- expect(await page.frames()[0].evaluate(() => window.FOO)).toBe('foo');
- expect(await page.frames()[1].evaluate(() => window.FOO)).toBe('bar');
- });
- it('should have correct execution contexts', async({page, server}) => {
- await page.goto(server.PREFIX + '/frames/one-frame.html');
- expect(page.frames().length).toBe(2);
- expect(await page.frames()[0].evaluate(() => document.body.textContent.trim())).toBe('');
- expect(await page.frames()[1].evaluate(() => document.body.textContent.trim())).toBe(`Hi, I'm frame`);
- });
- });
-
- describe('Page.evaluateOnNewDocument', function() {
- it('should evaluate before anything else on the page', async({page, server}) => {
- await page.evaluateOnNewDocument(function(){
- window.injected = 123;
- });
- await page.goto(server.PREFIX + '/tamperable.html');
- expect(await page.evaluate(() => window.result)).toBe(123);
- });
- it('should work with CSP', async({page, server}) => {
- server.setCSP('/empty.html', 'script-src ' + server.PREFIX);
- await page.evaluateOnNewDocument(function(){
- window.injected = 123;
- });
- await page.goto(server.PREFIX + '/empty.html');
- expect(await page.evaluate(() => window.injected)).toBe(123);
-
- // Make sure CSP works.
- await page.addScriptTag({content: 'window.e = 10;'}).catch(e => void e);
- expect(await page.evaluate(() => window.e)).toBe(undefined);
- });
- });
-};
-
diff --git a/experimental/puppeteer-firefox/test/firefoxonly.spec.js b/experimental/puppeteer-firefox/test/firefoxonly.spec.js
deleted file mode 100644
index 5babfda2824..00000000000
--- a/experimental/puppeteer-firefox/test/firefoxonly.spec.js
+++ /dev/null
@@ -1,24 +0,0 @@
-module.exports.addTests = function({testRunner, expect, product}) {
- const {describe, xdescribe, fdescribe} = testRunner;
- const {it, fit, xit} = testRunner;
- const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;
-
- describe('Firefox-specific tests', function() {
- describe('Browser.version', function() {
- it('should return whether we are in headless', async({browser}) => {
- const version = await browser.version();
- expect(version.length).toBeGreaterThan(0);
- expect(version.startsWith('Firefox/')).toBe(true);
- });
- });
-
- describe('Browser.userAgent', function() {
- it('should include WebKit', async({browser}) => {
- const userAgent = await browser.userAgent();
- expect(userAgent.length).toBeGreaterThan(0);
- expect(userAgent).toContain('Gecko');
- });
- });
- });
-};
-
diff --git a/experimental/puppeteer-firefox/test/frame.spec.js b/experimental/puppeteer-firefox/test/frame.spec.js
deleted file mode 100644
index d386aa333ce..00000000000
--- a/experimental/puppeteer-firefox/test/frame.spec.js
+++ /dev/null
@@ -1,137 +0,0 @@
-/**
- * Copyright 2018 Google Inc. All rights reserved.
- *
- * 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 utils = require('./utils');
-
-module.exports.addTests = function({testRunner, expect, product}) {
- const {describe, xdescribe, fdescribe} = testRunner;
- const {it, fit, xit} = testRunner;
- const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;
-
- const FFOX = product === 'firefox';
- const CHROME = product === 'chromium';
-
- describe('Frame Management', function() {
- it('should handle nested frames', async({page, server}) => {
- await page.goto(server.PREFIX + '/frames/nested-frames.html');
- expect(utils.dumpFrames(page.mainFrame())).toEqual([
- 'http://localhost:/frames/nested-frames.html',
- ' http://localhost:/frames/two-frames.html (2frames)',
- ' http://localhost:/frames/frame.html (uno)',
- ' http://localhost:/frames/frame.html (dos)',
- ' http://localhost:/frames/frame.html (aframe)'
- ]);
- });
- it('should send events when frames are manipulated dynamically', async({page, server}) => {
- await page.goto(server.EMPTY_PAGE);
- // validate frameattached events
- const attachedFrames = [];
- page.on('frameattached', frame => attachedFrames.push(frame));
- await utils.attachFrame(page, 'frame1', '/frames/frame.html');
- expect(attachedFrames.length).toBe(1);
- expect(attachedFrames[0].url()).toContain('/frames/frame.html');
-
- // validate framenavigated events
- const navigatedFrames = [];
- page.on('framenavigated', frame => navigatedFrames.push(frame));
- await utils.navigateFrame(page, 'frame1', server.PREFIX + '/empty2.html');
- expect(navigatedFrames.length).toBe(1);
- expect(navigatedFrames[0].url()).toBe(server.PREFIX + '/empty2.html');
-
- // validate framedetached events
- const detachedFrames = [];
- page.on('framedetached', frame => detachedFrames.push(frame));
- await utils.detachFrame(page, 'frame1');
- expect(detachedFrames.length).toBe(1);
- expect(detachedFrames[0].isDetached()).toBe(true);
- });
- it('should send "framenavigated" when navigating on anchor URLs', async({page, server}) => {
- await page.goto(server.EMPTY_PAGE);
- await Promise.all([
- page.goto(server.EMPTY_PAGE + '#foo'),
- utils.waitEvent(page, 'framenavigated')
- ]);
- expect(page.url()).toBe(server.EMPTY_PAGE + '#foo');
- });
- it('should not send attach/detach events for main frame', async({page, server}) => {
- let hasEvents = false;
- page.on('frameattached', frame => hasEvents = true);
- page.on('framedetached', frame => hasEvents = true);
- await page.goto(server.EMPTY_PAGE);
- expect(hasEvents).toBe(false);
- });
- it('should detach child frames on navigation', async({page, server}) => {
- let attachedFrames = [];
- let detachedFrames = [];
- let navigatedFrames = [];
- page.on('frameattached', frame => attachedFrames.push(frame));
- page.on('framedetached', frame => detachedFrames.push(frame));
- page.on('framenavigated', frame => navigatedFrames.push(frame));
- await page.goto(server.PREFIX + '/frames/nested-frames.html');
- expect(attachedFrames.length).toBe(4);
- expect(detachedFrames.length).toBe(0);
- expect(navigatedFrames.length).toBe(5);
-
- attachedFrames = [];
- detachedFrames = [];
- navigatedFrames = [];
- await page.goto(server.EMPTY_PAGE);
- expect(attachedFrames.length).toBe(0);
- expect(detachedFrames.length).toBe(4);
- expect(navigatedFrames.length).toBe(1);
- });
- it('should support framesets', async({page, server}) => {
- let attachedFrames = [];
- let detachedFrames = [];
- let navigatedFrames = [];
- page.on('frameattached', frame => attachedFrames.push(frame));
- page.on('framedetached', frame => detachedFrames.push(frame));
- page.on('framenavigated', frame => navigatedFrames.push(frame));
- await page.goto(server.PREFIX + '/frames/frameset.html');
- expect(attachedFrames.length).toBe(4);
- expect(detachedFrames.length).toBe(0);
- expect(navigatedFrames.length).toBe(5);
-
- attachedFrames = [];
- detachedFrames = [];
- navigatedFrames = [];
- await page.goto(server.EMPTY_PAGE);
- expect(attachedFrames.length).toBe(0);
- expect(detachedFrames.length).toBe(4);
- expect(navigatedFrames.length).toBe(1);
- });
- it('should report frame.name()', async({page, server}) => {
- await utils.attachFrame(page, 'theFrameId', server.EMPTY_PAGE2);
- await page.evaluate(url => {
- const frame = document.createElement('iframe');
- frame.name = 'theFrameName';
- frame.src = url;
- document.body.appendChild(frame);
- return new Promise(x => frame.onload = x);
- }, server.EMPTY_PAGE);
- expect(page.frames()[0].name()).toBe('');
- expect(page.frames()[1].name()).toBe('theFrameId');
- expect(page.frames()[2].name()).toBe('theFrameName');
- });
- it('should report frame.parent()', async({page, server}) => {
- await utils.attachFrame(page, 'frame1', server.EMPTY_PAGE);
- await utils.attachFrame(page, 'frame2', server.EMPTY_PAGE);
- expect(page.frames()[0].parentFrame()).toBe(null);
- expect(page.frames()[1].parentFrame()).toBe(page.mainFrame());
- expect(page.frames()[2].parentFrame()).toBe(page.mainFrame());
- });
- });
-
-};
diff --git a/experimental/puppeteer-firefox/test/golden-chromium/grid-cell-0.png b/experimental/puppeteer-firefox/test/golden-chromium/grid-cell-0.png
deleted file mode 100644
index 248fdb340f2..00000000000
Binary files a/experimental/puppeteer-firefox/test/golden-chromium/grid-cell-0.png and /dev/null differ
diff --git a/experimental/puppeteer-firefox/test/golden-chromium/grid-cell-1.png b/experimental/puppeteer-firefox/test/golden-chromium/grid-cell-1.png
deleted file mode 100644
index b0483e92c22..00000000000
Binary files a/experimental/puppeteer-firefox/test/golden-chromium/grid-cell-1.png and /dev/null differ
diff --git a/experimental/puppeteer-firefox/test/golden-chromium/screenshot-clip-odd-size.png b/experimental/puppeteer-firefox/test/golden-chromium/screenshot-clip-odd-size.png
deleted file mode 100644
index b010d1f87f0..00000000000
Binary files a/experimental/puppeteer-firefox/test/golden-chromium/screenshot-clip-odd-size.png and /dev/null differ
diff --git a/experimental/puppeteer-firefox/test/golden-chromium/screenshot-clip-rect.png b/experimental/puppeteer-firefox/test/golden-chromium/screenshot-clip-rect.png
deleted file mode 100644
index 64f8e792e31..00000000000
Binary files a/experimental/puppeteer-firefox/test/golden-chromium/screenshot-clip-rect.png and /dev/null differ
diff --git a/experimental/puppeteer-firefox/test/golden-chromium/screenshot-element-bounding-box.png b/experimental/puppeteer-firefox/test/golden-chromium/screenshot-element-bounding-box.png
deleted file mode 100644
index 32e05bf05b4..00000000000
Binary files a/experimental/puppeteer-firefox/test/golden-chromium/screenshot-element-bounding-box.png and /dev/null differ
diff --git a/experimental/puppeteer-firefox/test/golden-chromium/screenshot-element-larger-than-viewport.png b/experimental/puppeteer-firefox/test/golden-chromium/screenshot-element-larger-than-viewport.png
deleted file mode 100644
index 5fcdb923555..00000000000
Binary files a/experimental/puppeteer-firefox/test/golden-chromium/screenshot-element-larger-than-viewport.png and /dev/null differ
diff --git a/experimental/puppeteer-firefox/test/golden-chromium/screenshot-element-padding-border.png b/experimental/puppeteer-firefox/test/golden-chromium/screenshot-element-padding-border.png
deleted file mode 100644
index 917dd48188d..00000000000
Binary files a/experimental/puppeteer-firefox/test/golden-chromium/screenshot-element-padding-border.png and /dev/null differ
diff --git a/experimental/puppeteer-firefox/test/golden-chromium/screenshot-element-rotate.png b/experimental/puppeteer-firefox/test/golden-chromium/screenshot-element-rotate.png
deleted file mode 100644
index 52e2a0f6d3c..00000000000
Binary files a/experimental/puppeteer-firefox/test/golden-chromium/screenshot-element-rotate.png and /dev/null differ
diff --git a/experimental/puppeteer-firefox/test/golden-chromium/screenshot-element-scrolled-into-view.png b/experimental/puppeteer-firefox/test/golden-chromium/screenshot-element-scrolled-into-view.png
deleted file mode 100644
index 917dd48188d..00000000000
Binary files a/experimental/puppeteer-firefox/test/golden-chromium/screenshot-element-scrolled-into-view.png and /dev/null differ
diff --git a/experimental/puppeteer-firefox/test/golden-chromium/screenshot-grid-fullpage.png b/experimental/puppeteer-firefox/test/golden-chromium/screenshot-grid-fullpage.png
deleted file mode 100644
index db627293a81..00000000000
Binary files a/experimental/puppeteer-firefox/test/golden-chromium/screenshot-grid-fullpage.png and /dev/null differ
diff --git a/experimental/puppeteer-firefox/test/golden-chromium/screenshot-offscreen-clip.png b/experimental/puppeteer-firefox/test/golden-chromium/screenshot-offscreen-clip.png
deleted file mode 100644
index 10ec8a02b15..00000000000
Binary files a/experimental/puppeteer-firefox/test/golden-chromium/screenshot-offscreen-clip.png and /dev/null differ
diff --git a/experimental/puppeteer-firefox/test/golden-chromium/screenshot-sanity.png b/experimental/puppeteer-firefox/test/golden-chromium/screenshot-sanity.png
deleted file mode 100644
index 37d4136d031..00000000000
Binary files a/experimental/puppeteer-firefox/test/golden-chromium/screenshot-sanity.png and /dev/null differ
diff --git a/experimental/puppeteer-firefox/test/golden-chromium/transparent.png b/experimental/puppeteer-firefox/test/golden-chromium/transparent.png
deleted file mode 100644
index 1cf45d8688f..00000000000
Binary files a/experimental/puppeteer-firefox/test/golden-chromium/transparent.png and /dev/null differ
diff --git a/experimental/puppeteer-firefox/test/golden-chromium/white.jpg b/experimental/puppeteer-firefox/test/golden-chromium/white.jpg
deleted file mode 100644
index fb9070def3d..00000000000
Binary files a/experimental/puppeteer-firefox/test/golden-chromium/white.jpg and /dev/null differ
diff --git a/experimental/puppeteer-firefox/test/golden-firefox/grid-cell-0.png b/experimental/puppeteer-firefox/test/golden-firefox/grid-cell-0.png
deleted file mode 100644
index 4677bdbc4f8..00000000000
Binary files a/experimental/puppeteer-firefox/test/golden-firefox/grid-cell-0.png and /dev/null differ
diff --git a/experimental/puppeteer-firefox/test/golden-firefox/grid-cell-1.png b/experimental/puppeteer-firefox/test/golden-firefox/grid-cell-1.png
deleted file mode 100644
index 532dc8db65b..00000000000
Binary files a/experimental/puppeteer-firefox/test/golden-firefox/grid-cell-1.png and /dev/null differ
diff --git a/experimental/puppeteer-firefox/test/golden-firefox/screenshot-clip-odd-size.png b/experimental/puppeteer-firefox/test/golden-firefox/screenshot-clip-odd-size.png
deleted file mode 100644
index 8e86dc90178..00000000000
Binary files a/experimental/puppeteer-firefox/test/golden-firefox/screenshot-clip-odd-size.png and /dev/null differ
diff --git a/experimental/puppeteer-firefox/test/golden-firefox/screenshot-clip-rect.png b/experimental/puppeteer-firefox/test/golden-firefox/screenshot-clip-rect.png
deleted file mode 100644
index 7a744578693..00000000000
Binary files a/experimental/puppeteer-firefox/test/golden-firefox/screenshot-clip-rect.png and /dev/null differ
diff --git a/experimental/puppeteer-firefox/test/golden-firefox/screenshot-element-bounding-box.png b/experimental/puppeteer-firefox/test/golden-firefox/screenshot-element-bounding-box.png
deleted file mode 100644
index f4e059c300c..00000000000
Binary files a/experimental/puppeteer-firefox/test/golden-firefox/screenshot-element-bounding-box.png and /dev/null differ
diff --git a/experimental/puppeteer-firefox/test/golden-firefox/screenshot-element-larger-than-viewport.png b/experimental/puppeteer-firefox/test/golden-firefox/screenshot-element-larger-than-viewport.png
deleted file mode 100644
index 6d28cddcea3..00000000000
Binary files a/experimental/puppeteer-firefox/test/golden-firefox/screenshot-element-larger-than-viewport.png and /dev/null differ
diff --git a/experimental/puppeteer-firefox/test/golden-firefox/screenshot-element-padding-border.png b/experimental/puppeteer-firefox/test/golden-firefox/screenshot-element-padding-border.png
deleted file mode 100644
index 2b72c7528b2..00000000000
Binary files a/experimental/puppeteer-firefox/test/golden-firefox/screenshot-element-padding-border.png and /dev/null differ
diff --git a/experimental/puppeteer-firefox/test/golden-firefox/screenshot-element-rotate.png b/experimental/puppeteer-firefox/test/golden-firefox/screenshot-element-rotate.png
deleted file mode 100644
index 0a78fb1ae7b..00000000000
Binary files a/experimental/puppeteer-firefox/test/golden-firefox/screenshot-element-rotate.png and /dev/null differ
diff --git a/experimental/puppeteer-firefox/test/golden-firefox/screenshot-element-scrolled-into-view.png b/experimental/puppeteer-firefox/test/golden-firefox/screenshot-element-scrolled-into-view.png
deleted file mode 100644
index 2b72c7528b2..00000000000
Binary files a/experimental/puppeteer-firefox/test/golden-firefox/screenshot-element-scrolled-into-view.png and /dev/null differ
diff --git a/experimental/puppeteer-firefox/test/golden-firefox/screenshot-grid-fullpage.png b/experimental/puppeteer-firefox/test/golden-firefox/screenshot-grid-fullpage.png
deleted file mode 100644
index ac47ec83b19..00000000000
Binary files a/experimental/puppeteer-firefox/test/golden-firefox/screenshot-grid-fullpage.png and /dev/null differ
diff --git a/experimental/puppeteer-firefox/test/golden-firefox/screenshot-offscreen-clip.png b/experimental/puppeteer-firefox/test/golden-firefox/screenshot-offscreen-clip.png
deleted file mode 100644
index 791496e5da7..00000000000
Binary files a/experimental/puppeteer-firefox/test/golden-firefox/screenshot-offscreen-clip.png and /dev/null differ
diff --git a/experimental/puppeteer-firefox/test/golden-firefox/screenshot-sanity.png b/experimental/puppeteer-firefox/test/golden-firefox/screenshot-sanity.png
deleted file mode 100644
index 07890a04b34..00000000000
Binary files a/experimental/puppeteer-firefox/test/golden-firefox/screenshot-sanity.png and /dev/null differ
diff --git a/experimental/puppeteer-firefox/test/golden-utils.js b/experimental/puppeteer-firefox/test/golden-utils.js
deleted file mode 100644
index 86989ac6541..00000000000
--- a/experimental/puppeteer-firefox/test/golden-utils.js
+++ /dev/null
@@ -1,149 +0,0 @@
-/**
- * Copyright 2017 Google Inc. All rights reserved.
- *
- * 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 path = require('path');
-const fs = require('fs');
-const Diff = require('text-diff');
-const mime = require('mime');
-const PNG = require('pngjs').PNG;
-const jpeg = require('jpeg-js');
-const pixelmatch = require('pixelmatch');
-
-module.exports = {compare};
-
-const GoldenComparators = {
- 'image/png': compareImages,
- 'image/jpeg': compareImages,
- 'text/plain': compareText
-};
-
-
-/**
- * @param {?Object} actualBuffer
- * @param {!Buffer} expectedBuffer
- * @param {!string} mimeType
- * @return {?{diff: (!Object:undefined), errorMessage: (string|undefined)}}
- */
-function compareImages(actualBuffer, expectedBuffer, mimeType) {
- if (!actualBuffer || !(actualBuffer instanceof Buffer))
- return { errorMessage: 'Actual result should be Buffer.' };
-
- const actual = mimeType === 'image/png' ? PNG.sync.read(actualBuffer) : jpeg.decode(actualBuffer);
- const expected = mimeType === 'image/png' ? PNG.sync.read(expectedBuffer) : jpeg.decode(expectedBuffer);
- if (expected.width !== actual.width || expected.height !== actual.height) {
- return {
- errorMessage: `Sizes differ: expected image ${expected.width}px X ${expected.height}px, but got ${actual.width}px X ${actual.height}px. `
- };
- }
- const diff = new PNG({width: expected.width, height: expected.height});
- const count = pixelmatch(expected.data, actual.data, diff.data, expected.width, expected.height, {threshold: 0.1});
- return count > 0 ? { diff: PNG.sync.write(diff) } : null;
-}
-
-/**
- * @param {?Object} actual
- * @param {!Buffer} expectedBuffer
- * @return {?{diff: (!Object:undefined), errorMessage: (string|undefined)}}
- */
-function compareText(actual, expectedBuffer) {
- if (typeof actual !== 'string')
- return { errorMessage: 'Actual result should be string' };
- const expected = expectedBuffer.toString('utf-8');
- if (expected === actual)
- return null;
- const diff = new Diff();
- const result = diff.main(expected, actual);
- diff.cleanupSemantic(result);
- let html = diff.prettyHtml(result);
- const diffStylePath = path.join(__dirname, 'diffstyle.css');
- html = `` + html;
- return {
- diff: html,
- diffExtension: '.html'
- };
-}
-
-/**
- * @param {?Object} actual
- * @param {string} goldenName
- * @return {!{pass: boolean, message: (undefined|string)}}
- */
-function compare(goldenPath, outputPath, actual, goldenName) {
- goldenPath = path.normalize(goldenPath);
- outputPath = path.normalize(outputPath);
- const expectedPath = path.join(goldenPath, goldenName);
- const actualPath = path.join(outputPath, goldenName);
-
- const messageSuffix = 'Output is saved in "' + path.basename(outputPath + '" directory');
-
- if (!fs.existsSync(expectedPath)) {
- ensureOutputDir();
- fs.writeFileSync(actualPath, actual);
- return {
- pass: false,
- message: goldenName + ' is missing in golden results. ' + messageSuffix
- };
- }
- const expected = fs.readFileSync(expectedPath);
- const mimeType = mime.getType(goldenName);
- const comparator = GoldenComparators[mimeType];
- if (!comparator) {
- return {
- pass: false,
- message: 'Failed to find comparator with type ' + mimeType + ': ' + goldenName
- };
- }
- const result = comparator(actual, expected, mimeType);
- if (!result)
- return { pass: true };
- ensureOutputDir();
- if (goldenPath === outputPath) {
- fs.writeFileSync(addSuffix(actualPath, '-actual'), actual);
- } else {
- fs.writeFileSync(actualPath, actual);
- // Copy expected to the output/ folder for convenience.
- fs.writeFileSync(addSuffix(actualPath, '-expected'), expected);
- }
- if (result.diff) {
- const diffPath = addSuffix(actualPath, '-diff', result.diffExtension);
- fs.writeFileSync(diffPath, result.diff);
- }
-
- let message = goldenName + ' mismatch!';
- if (result.errorMessage)
- message += ' ' + result.errorMessage;
- return {
- pass: false,
- message: message + ' ' + messageSuffix
- };
-
- function ensureOutputDir() {
- if (!fs.existsSync(outputPath))
- fs.mkdirSync(outputPath);
- }
-}
-
-/**
- * @param {string} filePath
- * @param {string} suffix
- * @param {string=} customExtension
- * @return {string}
- */
-function addSuffix(filePath, suffix, customExtension) {
- const dirname = path.dirname(filePath);
- const ext = path.extname(filePath);
- const name = path.basename(filePath, ext);
- return path.join(dirname, name + suffix + (customExtension || ext));
-}
diff --git a/experimental/puppeteer-firefox/test/hover.spec.js b/experimental/puppeteer-firefox/test/hover.spec.js
deleted file mode 100644
index 485ab1e225e..00000000000
--- a/experimental/puppeteer-firefox/test/hover.spec.js
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * Copyright 2018 Google Inc. All rights reserved.
- *
- * 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.
- */
-
-module.exports.addTests = function({testRunner, expect, product}) {
- const {describe, xdescribe, fdescribe} = testRunner;
- const {it, fit, xit} = testRunner;
- const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;
-
- const FFOX = product === 'firefox';
- const CHROME = product === 'chromium';
-
- describe('Hover', function() {
- it('should trigger hover state', async({page, server}) => {
- await page.goto(server.PREFIX + '/input/scrollable.html');
- await page.hover('#button-6');
- expect(await page.evaluate(() => document.querySelector('button:hover').id)).toBe('button-6');
- await page.hover('#button-2');
- expect(await page.evaluate(() => document.querySelector('button:hover').id)).toBe('button-2');
- await page.hover('#button-91');
- expect(await page.evaluate(() => document.querySelector('button:hover').id)).toBe('button-91');
- });
- });
-};
-
diff --git a/experimental/puppeteer-firefox/test/ignorehttpserrors.spec.js b/experimental/puppeteer-firefox/test/ignorehttpserrors.spec.js
deleted file mode 100644
index 64e6e61bcbb..00000000000
--- a/experimental/puppeteer-firefox/test/ignorehttpserrors.spec.js
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * Copyright 2018 Google Inc. All rights reserved.
- *
- * 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.
- */
-
-module.exports.addTests = function({testRunner, expect, product, puppeteer, defaultBrowserOptions}) {
- const {describe, xdescribe, fdescribe} = testRunner;
- const {it, fit, xit} = testRunner;
- const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;
- const FFOX = product === 'firefox';
- const CHROME = product === 'chromium';
-
- describe('ignoreHTTPSErrors', function() {
- beforeAll(async state => {
- const options = Object.assign({ignoreHTTPSErrors: true}, defaultBrowserOptions);
- state.browser = await puppeteer.launch(options);
- });
- afterAll(async state => {
- await state.browser.close();
- delete state.browser;
- });
- beforeEach(async state => {
- state.page = await state.browser.newPage();
- });
- afterEach(async state => {
- await state.page.close();
- delete state.page;
- });
- it('should work', async({page, httpsServer}) => {
- let error = null;
- await page.goto(httpsServer.EMPTY_PAGE).catch(e => error = e);
- expect(error).toBe(null);
- });
- it('should work with mixed content', async({page, server, httpsServer}) => {
- httpsServer.setRoute('/mixedcontent.html', (req, res) => {
- res.end(``);
- });
- await page.goto(httpsServer.PREFIX + '/mixedcontent.html', {waitUntil: 'load'});
- expect(page.frames().length).toBe(2);
- // Make sure blocked iframe has functional execution context
- // @see https://github.com/GoogleChrome/puppeteer/issues/2709
- expect(await page.frames()[0].evaluate('1 + 2')).toBe(3);
- expect(await page.frames()[1].evaluate('2 + 3')).toBe(5);
- });
- });
-};
diff --git a/experimental/puppeteer-firefox/test/jshandle.spec.js b/experimental/puppeteer-firefox/test/jshandle.spec.js
deleted file mode 100644
index c4845bb3a22..00000000000
--- a/experimental/puppeteer-firefox/test/jshandle.spec.js
+++ /dev/null
@@ -1,157 +0,0 @@
-/**
- * Copyright 2018 Google Inc. All rights reserved.
- *
- * 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 utils = require('./utils');
-
-module.exports.addTests = function({testRunner, expect, product}) {
- const {describe, xdescribe, fdescribe} = testRunner;
- const {it, fit, xit} = testRunner;
- const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;
-
- const FFOX = product === 'firefox';
- const CHROME = product === 'chromium';
-
- describe('Page.evaluateHandle', function() {
- it('should work', async({page, server}) => {
- const windowHandle = await page.evaluateHandle(() => window);
- expect(windowHandle).toBeTruthy();
- });
- it('should accept object handle as an argument', async({page, server}) => {
- const navigatorHandle = await page.evaluateHandle(() => navigator);
- const text = await page.evaluate(e => e.userAgent, navigatorHandle);
- expect(text).toContain('Mozilla');
- });
- it('should accept object handle to primitive types', async({page, server}) => {
- const aHandle = await page.evaluateHandle(() => 5);
- const isFive = await page.evaluate(e => Object.is(e, 5), aHandle);
- expect(isFive).toBeTruthy();
- });
- it('should accept object handle to unserializable value', async({page, server}) => {
- const aHandle = await page.evaluateHandle(() => Infinity);
- expect(await page.evaluate(e => Object.is(e, Infinity), aHandle)).toBe(true);
- });
- it('should use the same JS wrappers', async({page, server}) => {
- const aHandle = await page.evaluateHandle(() => {
- window.FOO = 123;
- return window;
- });
- expect(await page.evaluate(e => e.FOO, aHandle)).toBe(123);
- });
- it('should work with primitives', async({page, server}) => {
- const aHandle = await page.evaluateHandle(() => {
- window.FOO = 123;
- return window;
- });
- expect(await page.evaluate(e => e.FOO, aHandle)).toBe(123);
- });
- });
-
- describe('JSHandle.jsonValue', function() {
- it('should work', async({page, server}) => {
- const aHandle = await page.evaluateHandle(() => ({foo: 'bar'}));
- const json = await aHandle.jsonValue();
- expect(json).toEqual({foo: 'bar'});
- });
- // This relies on Chrome's internal serialization. We can either repeat it
- // in FFOX, or migrate to JSON.stringify() logic altogether.
- (FFOX ? xit : it)('should not work with dates', async({page, server}) => {
- const dateHandle = await page.evaluateHandle(() => new Date('2017-09-26T00:00:00.000Z'));
- const json = await dateHandle.jsonValue();
- expect(json).toEqual({});
- });
- it('should throw for circular objects', async({page, server}) => {
- const windowHandle = await page.evaluateHandle('window');
- let error = null;
- await windowHandle.jsonValue().catch(e => error = e);
- expect(error).not.toBe(null);
- });
- });
-
- describe('JSHandle.toString', function() {
- it('should work for primitives', async({page, server}) => {
- const numberHandle = await page.evaluateHandle(() => 2);
- expect(numberHandle.toString()).toBe('JSHandle:2');
- const stringHandle = await page.evaluateHandle(() => 'a');
- expect(stringHandle.toString()).toBe('JSHandle:a');
- });
- it('should work for complicated objects', async({page, server}) => {
- const aHandle = await page.evaluateHandle(() => window);
- expect(aHandle.toString()).toBe('JSHandle@object');
- });
- it('should work with different subtypes', async({page, server}) => {
- expect((await page.evaluateHandle('(function(){})')).toString()).toBe('JSHandle@function');
- expect((await page.evaluateHandle('12')).toString()).toBe('JSHandle:12');
- expect((await page.evaluateHandle('true')).toString()).toBe('JSHandle:true');
- expect((await page.evaluateHandle('undefined')).toString()).toBe('JSHandle:undefined');
- expect((await page.evaluateHandle('"foo"')).toString()).toBe('JSHandle:foo');
- expect((await page.evaluateHandle('Symbol()')).toString()).toBe('JSHandle@symbol');
- expect((await page.evaluateHandle('new Map()')).toString()).toBe('JSHandle@map');
- expect((await page.evaluateHandle('new Set()')).toString()).toBe('JSHandle@set');
- expect((await page.evaluateHandle('[]')).toString()).toBe('JSHandle@array');
- expect((await page.evaluateHandle('null')).toString()).toBe('JSHandle:null');
- expect((await page.evaluateHandle('/foo/')).toString()).toBe('JSHandle@regexp');
- expect((await page.evaluateHandle('document.body')).toString()).toBe('JSHandle@node');
- expect((await page.evaluateHandle('new Date()')).toString()).toBe('JSHandle@date');
- expect((await page.evaluateHandle('new WeakMap()')).toString()).toBe('JSHandle@weakmap');
- expect((await page.evaluateHandle('new WeakSet()')).toString()).toBe('JSHandle@weakset');
- expect((await page.evaluateHandle('new Error()')).toString()).toBe('JSHandle@error');
- expect((await page.evaluateHandle('new Int32Array()')).toString()).toBe('JSHandle@typedarray');
- expect((await page.evaluateHandle('new Proxy({}, {})')).toString()).toBe('JSHandle@proxy');
- });
- });
-
- describe('JSHandle.getProperties', function() {
- it('should work', async({page, server}) => {
- const aHandle = await page.evaluateHandle(() => ({
- foo: 'bar'
- }));
- const properties = await aHandle.getProperties();
- const foo = properties.get('foo');
- expect(foo).toBeTruthy();
- expect(await foo.jsonValue()).toBe('bar');
- });
- it('should return even non-own properties', async({page, server}) => {
- const aHandle = await page.evaluateHandle(() => {
- class A {
- constructor() {
- this.a = '1';
- }
- }
- class B extends A {
- constructor() {
- super();
- this.b = '2';
- }
- }
- return new B();
- });
- const properties = await aHandle.getProperties();
- expect(await properties.get('a').jsonValue()).toBe('1');
- expect(await properties.get('b').jsonValue()).toBe('2');
- });
- });
-
- describe('JSHandle.getProperty', function() {
- it('should work', async({page, server}) => {
- const aHandle = await page.evaluateHandle(() => ({
- one: 1,
- two: 2,
- three: 3
- }));
- const twoHandle = await aHandle.getProperty('two');
- expect(await twoHandle.jsonValue()).toEqual(2);
- });
- });
-};
diff --git a/experimental/puppeteer-firefox/test/keyboard.spec.js b/experimental/puppeteer-firefox/test/keyboard.spec.js
deleted file mode 100644
index 66e054f6d62..00000000000
--- a/experimental/puppeteer-firefox/test/keyboard.spec.js
+++ /dev/null
@@ -1,193 +0,0 @@
-/**
- * Copyright 2018 Google Inc. All rights reserved.
- *
- * 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 utils = require('./utils');
-const os = require('os');
-
-module.exports.addTests = function({testRunner, expect, product}) {
- const {describe, xdescribe, fdescribe} = testRunner;
- const {it, fit, xit} = testRunner;
- const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;
-
- const FFOX = product === 'firefox';
- const CHROME = product === 'chromium';
-
- describe('Keyboard', function() {
- it('should type into a textarea', async({page, server}) => {
- await page.evaluate(() => {
- const textarea = document.createElement('textarea');
- document.body.appendChild(textarea);
- textarea.focus();
- });
- const text = 'Hello world. I am the text that was typed!';
- await page.keyboard.type(text);
- expect(await page.evaluate(() => document.querySelector('textarea').value)).toBe(text);
- });
- it('should type emoji', async({page, server}) => {
- await page.evaluate(() => {
- const textarea = document.createElement('textarea');
- document.body.appendChild(textarea);
- textarea.focus();
- });
- await page.keyboard.type('👹 Tokyo street Japan 🇯🇵');
- expect(await page.evaluate(() => document.querySelector('textarea').value)).toBe('👹 Tokyo street Japan 🇯🇵');
- });
- it('should type emoji', async({page, server}) => {
- await page.goto(server.PREFIX + '/input/textarea.html');
- await page.type('textarea', '👹 Tokyo street Japan 🇯🇵');
- expect(await page.$eval('textarea', textarea => textarea.value)).toBe('👹 Tokyo street Japan 🇯🇵');
- });
- it('should type emoji into an iframe', async({page, server}) => {
- await page.goto(server.EMPTY_PAGE);
- await utils.attachFrame(page, 'emoji-test', server.PREFIX + '/input/textarea.html');
- const frame = page.frames()[1];
- const textarea = await frame.$('textarea');
- await textarea.type('👹 Tokyo street Japan 🇯🇵');
- expect(await frame.$eval('textarea', textarea => textarea.value)).toBe('👹 Tokyo street Japan 🇯🇵');
- });
- it('should send a character with sendCharacter', async({page, server}) => {
- await page.goto(server.PREFIX + '/input/textarea.html');
- await page.focus('textarea');
- await page.keyboard.sendCharacter('å—¨');
- expect(await page.evaluate(() => document.querySelector('textarea').value)).toBe('å—¨');
- await page.evaluate(() => window.addEventListener('keydown', e => e.preventDefault(), true));
- await page.keyboard.sendCharacter('a');
- expect(await page.evaluate(() => document.querySelector('textarea').value)).toBe('å—¨a');
- });
- it('should press the metaKey', async({page}) => {
- await page.evaluate(() => {
- window.keyPromise = new Promise(resolve => document.addEventListener('keydown', event => resolve(event.key)));
- });
- await page.keyboard.press('Meta');
- expect(await page.evaluate('keyPromise')).toBe(FFOX && os.platform() !== 'darwin' ? 'OS' : 'Meta');
- });
- xit('should report shiftKey', async({page, server}) => {
- await page.goto(server.PREFIX + '/input/keyboard.html');
- const keyboard = page.keyboard;
- const codeForKey = {'Shift': 16, 'Alt': 18, 'Meta': 91, 'Control': 17};
- // Firefox has no Meta modifier on Windows/Linux
- if (FFOX && os.platform() !== 'darwin')
- delete codeForKey['Meta'];
- for (const modifierKey in codeForKey) {
- await keyboard.down(modifierKey);
- expect(await page.evaluate(() => getResult())).toBe('Keydown: ' + modifierKey + ' ' + modifierKey + 'Left ' + codeForKey[modifierKey] + ' [' + modifierKey + ']');
- await keyboard.down('!');
- // Shift+! will generate a keypress
- if (modifierKey === 'Shift')
- expect(await page.evaluate(() => getResult())).toBe('Keydown: ! Digit1 49 [' + modifierKey + ']\nKeypress: ! Digit1 33 33 [' + modifierKey + ']');
- else
- expect(await page.evaluate(() => getResult())).toBe('Keydown: ! Digit1 49 [' + modifierKey + ']');
-
- await keyboard.up('!');
- expect(await page.evaluate(() => getResult())).toBe('Keyup: ! Digit1 49 [' + modifierKey + ']');
- await keyboard.up(modifierKey);
- expect(await page.evaluate(() => getResult())).toBe('Keyup: ' + modifierKey + ' ' + modifierKey + 'Left ' + codeForKey[modifierKey] + ' []');
- }
- });
- xit('should report multiple modifiers', async({page, server}) => {
- await page.goto(server.PREFIX + '/input/keyboard.html');
- const keyboard = page.keyboard;
- await keyboard.down('Control');
- expect(await page.evaluate(() => getResult())).toBe('Keydown: Control ControlLeft 17 [Control]');
- await keyboard.down('Alt');
- expect(await page.evaluate(() => getResult())).toBe('Keydown: Alt AltLeft 18 [Alt Control]');
- await keyboard.down(';');
- expect(await page.evaluate(() => getResult())).toBe('Keydown: ; Semicolon 186 [Alt Control]');
- await keyboard.up(';');
- expect(await page.evaluate(() => getResult())).toBe('Keyup: ; Semicolon 186 [Alt Control]');
- await keyboard.up('Control');
- expect(await page.evaluate(() => getResult())).toBe('Keyup: Control ControlLeft 17 [Alt]');
- await keyboard.up('Alt');
- expect(await page.evaluate(() => getResult())).toBe('Keyup: Alt AltLeft 18 []');
- });
- it('should send proper codes while typing', async({page, server}) => {
- await page.goto(server.PREFIX + '/input/keyboard.html');
- await page.keyboard.type('!');
- expect(await page.evaluate(() => getResult())).toBe(
- [ 'Keydown: ! Digit1 49 []',
- 'Keypress: ! Digit1 33 33 []',
- 'Keyup: ! Digit1 49 []'].join('\n'));
- await page.keyboard.type('^');
- expect(await page.evaluate(() => getResult())).toBe(
- [ 'Keydown: ^ Digit6 54 []',
- 'Keypress: ^ Digit6 94 94 []',
- 'Keyup: ^ Digit6 54 []'].join('\n'));
- });
- it('should send proper codes while typing with shift', async({page, server}) => {
- await page.goto(server.PREFIX + '/input/keyboard.html');
- const keyboard = page.keyboard;
- await keyboard.down('Shift');
- await page.keyboard.type('~');
- expect(await page.evaluate(() => getResult())).toBe(
- [ 'Keydown: Shift ShiftLeft 16 [Shift]',
- 'Keydown: ~ Backquote 192 [Shift]', // 192 is ` keyCode
- 'Keypress: ~ Backquote 126 126 [Shift]', // 126 is ~ charCode
- 'Keyup: ~ Backquote 192 [Shift]'].join('\n'));
- await keyboard.up('Shift');
- });
- it('should not type canceled events', async({page, server}) => {
- await page.goto(server.PREFIX + '/input/textarea.html');
- await page.focus('textarea');
- await page.evaluate(() => {
- window.addEventListener('keydown', event => {
- event.stopPropagation();
- event.stopImmediatePropagation();
- if (event.key === 'l')
- event.preventDefault();
- if (event.key === 'o')
- event.preventDefault();
- }, false);
- });
- await page.keyboard.type('Hello World!');
- expect(await page.evaluate(() => textarea.value)).toBe('He Wrd!');
- });
- it('should specify repeat property', async({page, server}) => {
- await page.goto(server.PREFIX + '/input/textarea.html');
- await page.focus('textarea');
- await page.evaluate(() => document.querySelector('textarea').addEventListener('keydown', e => window.lastEvent = e, true));
- await page.keyboard.down('a');
- expect(await page.evaluate(() => window.lastEvent.repeat)).toBe(false);
- await page.keyboard.press('a');
- expect(await page.evaluate(() => window.lastEvent.repeat)).toBe(true);
-
- await page.keyboard.down('b');
- expect(await page.evaluate(() => window.lastEvent.repeat)).toBe(false);
- await page.keyboard.down('b');
- expect(await page.evaluate(() => window.lastEvent.repeat)).toBe(true);
-
- await page.keyboard.up('a');
- await page.keyboard.down('a');
- expect(await page.evaluate(() => window.lastEvent.repeat)).toBe(false);
- });
- it('should type all kinds of characters', async({page, server}) => {
- await page.goto(server.PREFIX + '/input/textarea.html');
- await page.focus('textarea');
- const text = 'This text goes onto two lines.\nThis character is å—¨.';
- await page.keyboard.type(text);
- expect(await page.evaluate('result')).toBe(text);
- });
- it('should throw on unknown keys', async({page, server}) => {
- let error = await page.keyboard.press('NotARealKey').catch(e => e);
- expect(error.message).toBe('Unknown key: "NotARealKey"');
-
- error = await page.keyboard.press('Ñ‘').catch(e => e);
- expect(error && error.message).toBe('Unknown key: "Ñ‘"');
-
- error = await page.keyboard.press('😊').catch(e => e);
- expect(error && error.message).toBe('Unknown key: "😊"');
- });
- });
-};
-
diff --git a/experimental/puppeteer-firefox/test/launcher.spec.js b/experimental/puppeteer-firefox/test/launcher.spec.js
deleted file mode 100644
index da874933d12..00000000000
--- a/experimental/puppeteer-firefox/test/launcher.spec.js
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
- * Copyright 2018 Google Inc. All rights reserved.
- *
- * 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');
-
-module.exports.addTests = function({testRunner, expect, product, puppeteer, defaultBrowserOptions}) {
- const {describe, xdescribe, fdescribe} = testRunner;
- const {it, fit, xit} = testRunner;
- const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;
-
- const FFOX = product === 'firefox';
- const CHROME = product === 'chromium';
- describe('Launcher.executablePath', function() {
- it('should work', async({server}) => {
- const executablePath = puppeteer.executablePath();
- expect(fs.existsSync(executablePath)).toBe(true);
- });
- });
-
- describe('Launcher.launch', () => {
- it('should set the default viewport', async() => {
- const options = Object.assign({}, defaultBrowserOptions, {
- defaultViewport: {
- width: 456,
- height: 789
- }
- });
- const browser = await puppeteer.launch(options);
- const page = await browser.newPage();
- expect(await page.evaluate('window.innerWidth')).toBe(456);
- expect(await page.evaluate('window.innerHeight')).toBe(789);
- await browser.close();
- });
- it('should disable the default viewport', async() => {
- const options = Object.assign({}, defaultBrowserOptions, {
- defaultViewport: null
- });
- const browser = await puppeteer.launch(options);
- const page = await browser.newPage();
- expect(page.viewport()).toBe(null);
- await browser.close();
- });
- });
-}
diff --git a/experimental/puppeteer-firefox/test/mouse.spec.js b/experimental/puppeteer-firefox/test/mouse.spec.js
deleted file mode 100644
index 5d0312fd41e..00000000000
--- a/experimental/puppeteer-firefox/test/mouse.spec.js
+++ /dev/null
@@ -1,108 +0,0 @@
-/**
- * Copyright 2018 Google Inc. All rights reserved.
- *
- * 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.
- */
-
-module.exports.addTests = function({testRunner, expect, product}) {
- const {describe, xdescribe, fdescribe} = testRunner;
- const {it, fit, xit} = testRunner;
- const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;
-
- const FFOX = product === 'firefox';
- const CHROME = product === 'chromium';
-
- describe('Mouse', function() {
- it('should click the document', async({page, server}) => {
- await page.evaluate(() => {
- window.clickPromise = new Promise(resolve => {
- document.addEventListener('click', event => {
- resolve({
- type: event.type,
- detail: event.detail,
- clientX: event.clientX,
- clientY: event.clientY,
- isTrusted: event.isTrusted,
- button: event.button
- });
- });
- });
- });
- await page.mouse.click(50, 60);
- const event = await page.evaluate(() => window.clickPromise);
- expect(event.type).toBe('click');
- expect(event.detail).toBe(1);
- expect(event.clientX).toBe(50);
- expect(event.clientY).toBe(60);
- expect(event.isTrusted).toBe(true);
- expect(event.button).toBe(0);
- });
- it('should resize the textarea', async({page, server}) => {
- await page.goto(server.PREFIX + '/input/textarea.html');
- const {x, y, width, height} = await page.evaluate(dimensions);
- const mouse = page.mouse;
- await mouse.move(x + width - 4, y + height - 4);
- await mouse.down();
- await mouse.move(x + width + 100, y + height + 100);
- await mouse.up();
- const newDimensions = await page.evaluate(dimensions);
- expect(newDimensions.width).toBe(Math.round(width + 104));
- expect(newDimensions.height).toBe(Math.round(height + 104));
- });
- it('should select the text with mouse', async({page, server}) => {
- await page.goto(server.PREFIX + '/input/textarea.html');
- await page.focus('textarea');
- const text = 'This is the text that we are going to try to select. Let\'s see how it goes.';
- await page.keyboard.type(text);
- // Firefox needs an extra frame here after typing or it will fail to set the scrollTop
- await page.evaluate(() => new Promise(requestAnimationFrame));
- await page.evaluate(() => document.querySelector('textarea').scrollTop = 0);
- const {x, y} = await page.evaluate(dimensions);
- await page.mouse.move(x + 2,y + 2);
- await page.mouse.down();
- await page.mouse.move(200,100);
- await page.mouse.up();
- expect(await page.evaluate(() => {
- const textarea = document.querySelector('textarea');
- return textarea.value.substring(textarea.selectionStart, textarea.selectionEnd);
- })).toBe(text);
- });
- it('should tween mouse movement', async({page, server}) => {
- await page.mouse.move(100, 100);
- await page.evaluate(() => {
- window.result = [];
- document.addEventListener('mousemove', event => {
- window.result.push([event.clientX, event.clientY]);
- });
- });
- await page.mouse.move(200, 300, {steps: 5});
- expect(await page.evaluate('result')).toEqual([
- [120, 140],
- [140, 180],
- [160, 220],
- [180, 260],
- [200, 300]
- ]);
- });
- });
-};
-
-function dimensions() {
- const rect = document.querySelector('textarea').getBoundingClientRect();
- return {
- x: rect.left,
- y: rect.top,
- width: rect.width,
- height: rect.height
- };
-}
diff --git a/experimental/puppeteer-firefox/test/navigation.spec.js b/experimental/puppeteer-firefox/test/navigation.spec.js
deleted file mode 100644
index 2029e5c5ab3..00000000000
--- a/experimental/puppeteer-firefox/test/navigation.spec.js
+++ /dev/null
@@ -1,285 +0,0 @@
-/**
- * Copyright 2018 Google Inc. All rights reserved.
- *
- * 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 utils = require('./utils');
-
-module.exports.addTests = function({testRunner, expect, product}) {
- const {describe, xdescribe, fdescribe} = testRunner;
- const {it, fit, xit} = testRunner;
- const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;
-
- const FFOX = product === 'firefox';
- const CHROME = product === 'chromium';
-
- describe('Page.goto', function () {
- it('should work', async({page, server}) => {
- await page.goto(server.EMPTY_PAGE);
- expect(page.url()).toBe(server.EMPTY_PAGE);
- });
- it('should work with anchor navigation', async({page, server}) => {
- await page.goto(server.EMPTY_PAGE);
- expect(page.url()).toBe(server.EMPTY_PAGE);
- await page.goto(server.EMPTY_PAGE + '#foo');
- expect(page.url()).toBe(server.EMPTY_PAGE + '#foo');
- await page.goto(server.EMPTY_PAGE + '#bar');
- expect(page.url()).toBe(server.EMPTY_PAGE + '#bar');
- });
- it('should navigate to about:blank', async({page, server}) => {
- await page.goto('about:blank');
- expect(page.url()).toBe('about:blank');
- });
- it('should work with redirects', async({page, server}) => {
- server.setRedirect('/redirect/1.html', '/redirect/2.html');
- server.setRedirect('/redirect/2.html', '/empty.html');
- await page.goto(server.PREFIX + '/redirect/1.html');
- expect(page.url()).toBe(server.EMPTY_PAGE);
- });
- it('should work with subframes return 204', async({page, server}) => {
- server.setRoute('/frames/frame.html', (req, res) => {
- res.statusCode = 204;
- res.end();
- });
- await page.goto(server.PREFIX + '/frames/one-frame.html');
- });
- it('should fail when server returns 204', async({page, server}) => {
- server.setRoute('/empty.html', (req, res) => {
- res.statusCode = 204;
- res.end();
- });
- let error = null;
- await page.goto(server.EMPTY_PAGE).catch(e => error = e);
- expect(error).not.toBe(null);
- expect(error.message).toContain('ABORTED');
- });
- it('should work when page calls history API in beforeunload', async({page, server}) => {
- await page.goto(server.EMPTY_PAGE);
- await page.evaluate(() => {
- window.addEventListener('beforeunload', () => history.replaceState(null, 'initial', window.location.href), false);
- });
- await page.goto(server.PREFIX + '/grid.html');
- });
- it('should fail when navigating to bad url', async({page, server}) => {
- let error = null;
- await page.goto('asdfasdf').catch(e => error = e);
- expect(error).not.toBe(null);
- });
- it('should fail when navigating to bad url', async({page, server}) => {
- let error = null;
- await page.goto('asdf').catch(e => error = e);
- expect(error).not.toBe(null);
- });
- it('should fail when navigating to bad SSL', async({page, httpsServer}) => {
- let error = null;
- await page.goto(httpsServer.EMPTY_PAGE).catch(e => error = e);
- expect(error).not.toBe(null);
- });
- it('should fail when navigating to bad SSL after redirects', async({page, server, httpsServer}) => {
- httpsServer.setRedirect('/redirect/1.html', '/redirect/2.html');
- httpsServer.setRedirect('/redirect/2.html', '/empty.html');
- let error = null;
- await page.goto(httpsServer.PREFIX + '/redirect/1.html').catch(e => error = e);
- expect(error).not.toBe(null);
- });
- it('should fail when main resources failed to load', async({page, server}) => {
- let error = null;
- await page.goto('http://localhost:44123/non-existing-url').catch(e => error = e);
- expect(error).not.toBe(null);
- });
- it('should fail when exceeding maximum navigation timeout', async({page, server}) => {
- // Hang for request to the empty.html
- server.setRoute('/empty.html', (req, res) => { });
- let error = null;
- await page.goto(server.PREFIX + '/empty.html', {timeout: 1}).catch(e => error = e);
- expect(error.message).toContain('Navigation Timeout Exceeded: 1ms');
- });
- it('should disable timeout when its set to 0', async({page, server}) => {
- await page.goto(server.PREFIX + '/grid.html', {timeout: 0});
- });
- it('should work when navigating to data url', async({page, server}) => {
- await page.goto('data:text/html,hello');
- });
- it('should work when navigating to 404', async({page, server}) => {
- await page.goto(server.PREFIX + '/not-found');
- });
- it('should not leak listeners during navigation', async({page, server}) => {
- let warning = null;
- const warningHandler = w => warning = w;
- process.on('warning', warningHandler);
- for (let i = 0; i < 20; ++i)
- await page.goto(server.EMPTY_PAGE);
- process.removeListener('warning', warningHandler);
- expect(warning).toBe(null);
- });
- it('should fail when navigating and show the url at the error message', async function({page, server, httpsServer}) {
- const url = httpsServer.PREFIX + '/redirect/1.html';
- let error = null;
- try {
- await page.goto(url);
- } catch (e) {
- error = e;
- }
- expect(error.message).toContain(url);
- });
- });
-
- describe('Page.waitForNavigation', function() {
- it('should work', async({page, server}) => {
- await page.goto(server.EMPTY_PAGE);
- const [response] = await Promise.all([
- page.waitForNavigation(),
- page.evaluate(url => window.location.href = url, server.PREFIX + '/grid.html')
- ]);
- expect(page.url()).toBe(server.PREFIX + '/grid.html');
- });
- it('should work with both domcontentloaded and load', async({page, server}) => {
- let response = null;
- server.setRoute('/one-style.css', (req, res) => response = res);
- const navigationPromise = page.goto(server.PREFIX + '/one-style.html');
- const domContentLoadedPromise = page.waitForNavigation({
- waitUntil: 'domcontentloaded'
- });
-
- let bothFired = false;
- const bothFiredPromise = page.waitForNavigation({
- waitUntil: ['load', 'domcontentloaded']
- }).then(() => bothFired = true);
-
- await server.waitForRequest('/one-style.css');
- await domContentLoadedPromise;
- expect(bothFired).toBe(false);
- response.end();
- await bothFiredPromise;
- await navigationPromise;
- });
- it('should work with clicking on anchor links', async({page, server}) => {
- await page.goto(server.EMPTY_PAGE);
- await page.setContent(`foobar`);
- await Promise.all([
- page.waitForNavigation(),
- page.click('a'),
- ]);
- expect(page.url()).toBe(server.EMPTY_PAGE + '#foobar');
- });
- it('should work with history.pushState()', async({page, server}) => {
- await page.goto(server.EMPTY_PAGE);
- await page.setContent(`
- SPA
-
- `);
- await Promise.all([
- page.waitForNavigation(),
- page.click('a'),
- ]);
- expect(page.url()).toBe(server.PREFIX + '/wow.html');
- });
- it('should work with history.replaceState()', async({page, server}) => {
- await page.goto(server.EMPTY_PAGE);
- await page.setContent(`
- SPA
-
- `);
- await Promise.all([
- page.waitForNavigation(),
- page.click('a'),
- ]);
- expect(page.url()).toBe(server.PREFIX + '/replaced.html');
- });
- xit('should work with DOM history.back()/history.forward()', async({page, server}) => {
- await page.goto(server.EMPTY_PAGE);
- await page.setContent(`
- back
- forward
-
- `);
- expect(page.url()).toBe(server.PREFIX + '/second.html');
- await Promise.all([
- page.waitForNavigation(),
- page.click('a#back'),
- ]);
- expect(page.url()).toBe(server.PREFIX + '/first.html');
- await Promise.all([
- page.waitForNavigation(),
- page.click('a#forward'),
- ]);
- expect(page.url()).toBe(server.PREFIX + '/second.html');
- });
- it('should work when subframe issues window.stop()', async({page, server}) => {
- server.setRoute('/frames/style.css', (req, res) => {});
- const navigationPromise = page.goto(server.PREFIX + '/frames/one-frame.html');
- const frame = await utils.waitEvent(page, 'frameattached');
- await new Promise(fulfill => {
- page.on('framenavigated', f => {
- if (f === frame)
- fulfill();
- });
- });
- await Promise.all([
- frame.evaluate(() => window.stop()),
- navigationPromise
- ]);
- });
- });
-
- describe('Page.goBack + Page.goForward', function() {
- it('should work', async({page, server}) => {
- await page.goto(server.EMPTY_PAGE);
- await page.goto(server.PREFIX + '/grid.html');
-
- await page.goBack();
- expect(page.url()).toBe(server.EMPTY_PAGE);
-
- await page.goForward();
- expect(page.url()).toContain('/grid.html');
-
- await page.goForward();
- expect(page.url()).toContain('/grid.html');
- });
- it('should work with HistoryAPI', async({page, server}) => {
- await page.goto(server.EMPTY_PAGE);
- await page.evaluate(() => {
- history.pushState({}, '', '/first.html');
- history.pushState({}, '', '/second.html');
- });
- expect(page.url()).toBe(server.PREFIX + '/second.html');
-
- await page.goBack();
- expect(page.url()).toBe(server.PREFIX + '/first.html');
- await page.goBack();
- expect(page.url()).toBe(server.EMPTY_PAGE);
- await page.goForward();
- expect(page.url()).toBe(server.PREFIX + '/first.html');
- });
- });
-
- describe('Page.reload', function() {
- it('should work', async({page, server}) => {
- await page.goto(server.EMPTY_PAGE);
- await page.evaluate(() => window._foo = 10);
- await page.reload();
- expect(await page.evaluate(() => window._foo)).toBe(undefined);
- });
- });
-};
-
diff --git a/experimental/puppeteer-firefox/test/page.spec.js b/experimental/puppeteer-firefox/test/page.spec.js
deleted file mode 100644
index 3a26a9b7135..00000000000
--- a/experimental/puppeteer-firefox/test/page.spec.js
+++ /dev/null
@@ -1,403 +0,0 @@
-/**
- * Copyright 2018 Google Inc. All rights reserved.
- *
- * 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 utils = require('./utils');
-const path = require('path');
-
-module.exports.addTests = function({testRunner, expect, product}) {
- const {describe, xdescribe, fdescribe} = testRunner;
- const {it, fit, xit} = testRunner;
- const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;
-
- const FFOX = product === 'firefox';
- const CHROME = product === 'chromium';
-
- describe('Page.Events.DOMContentLoaded', function() {
- it('should fire when expected', async({page, server}) => {
- await Promise.all([
- page.goto('about:blank'),
- utils.waitEvent(page, 'domcontentloaded'),
- ]);
- });
- });
- describe('Page.Events.Load', function() {
- it('should fire when expected', async({page, server}) => {
- await Promise.all([
- page.goto('about:blank'),
- utils.waitEvent(page, 'load'),
- ]);
- });
- });
-
- describe('Page.Events.PageError', function() {
- it('should fire', async({page, server}) => {
- let error = null;
- page.once('pageerror', e => error = e);
- await Promise.all([
- page.goto(server.PREFIX + '/error.html'),
- utils.waitEvent(page, 'pageerror')
- ]);
- expect(error.message).toContain('Fancy');
- });
- });
-
-
- describe('Page.close', function() {
- it('should reject all promises when page is closed', async({browser}) => {
- const newPage = await browser.newPage();
- const neverResolves = newPage.evaluate(() => new Promise(r => {}));
- newPage.close();
- let error = null;
- await neverResolves.catch(e => error = e);
- expect(error).not.toBe(null);
- });
- it('should not be visible in browser.pages', async({browser}) => {
- const newPage = await browser.newPage();
- expect(await browser.pages()).toContain(newPage);
- await newPage.close();
- expect(await browser.pages()).not.toContain(newPage);
- });
- it('should set the page close state', async({browser}) => {
- const newPage = await browser.newPage();
- expect(newPage.isClosed()).toBe(false);
- await newPage.close();
- expect(newPage.isClosed()).toBe(true);
- });
- it('should work with page.close', async function({ page, context, server }) {
- const newPage = await context.newPage();
- const closedPromise = new Promise(x => newPage.on('close', x));
- await newPage.close();
- await closedPromise;
- });
- });
-
- describe('Page.Events.Console', function() {
- it('should work', async({page, server}) => {
- let message = null;
- page.once('console', m => message = m);
- await Promise.all([
- page.evaluate(() => console.log('hello', 5, {foo: 'bar'})),
- utils.waitEvent(page, 'console')
- ]);
- expect(message.text()).toEqual('hello 5 JSHandle@object');
- expect(message.type()).toEqual('log');
- expect(await message.args()[0].jsonValue()).toEqual('hello');
- expect(await message.args()[1].jsonValue()).toEqual(5);
- expect(await message.args()[2].jsonValue()).toEqual({foo: 'bar'});
- });
- it('should work for different console API calls', async({page, server}) => {
- const messages = [];
- page.on('console', msg => messages.push(msg));
- // All console events will be reported before `page.evaluate` is finished.
- await page.evaluate(() => {
- // A pair of time/timeEnd generates only one Console API call.
- console.time('calling console.time');
- console.timeEnd('calling console.time');
- console.trace('calling console.trace');
- console.dir('calling console.dir');
- console.warn('calling console.warn');
- console.error('calling console.error');
- console.log(Promise.resolve('should not wait until resolved!'));
- });
- expect(messages.map(msg => msg.type())).toEqual([
- 'timeEnd', 'trace', 'dir', 'warning', 'error', 'log'
- ]);
- expect(messages[0].text()).toContain('calling console.time');
- expect(messages.slice(1).map(msg => msg.text())).toEqual([
- 'calling console.trace',
- 'calling console.dir',
- 'calling console.warn',
- 'calling console.error',
- 'JSHandle@promise',
- ]);
- });
- it('should not fail for window object', async({page, server}) => {
- let message = null;
- page.once('console', msg => message = msg);
- await Promise.all([
- page.evaluate(() => console.error(window)),
- utils.waitEvent(page, 'console')
- ]);
- expect(message.text()).toBe('JSHandle@object');
- });
- });
-
- describe('Page.content / Page.setContent', function() {
- const expectedOutput = 'hello
';
- it('should work', async({page, server}) => {
- await page.setContent('hello
');
- const result = await page.content();
- expect(result).toBe(expectedOutput);
- });
- it('should work with doctype', async({page, server}) => {
- const doctype = '';
- await page.setContent(`${doctype}hello
`);
- const result = await page.content();
- expect(result).toBe(`${doctype}${expectedOutput}`);
- });
- it('should work with HTML 4 doctype', async({page, server}) => {
- const doctype = '';
- await page.setContent(`${doctype}hello
`);
- const result = await page.content();
- expect(result).toBe(`${doctype}${expectedOutput}`);
- });
- });
-
- describe('Page.addScriptTag', function() {
- it('should throw an error if no options are provided', async({page, server}) => {
- let error = null;
- try {
- await page.addScriptTag('/injectedfile.js');
- } catch (e) {
- error = e;
- }
- expect(error.message).toBe('Provide an object with a `url`, `path` or `content` property');
- });
-
- it('should work with a url', async({page, server}) => {
- await page.goto(server.EMPTY_PAGE);
- const scriptHandle = await page.addScriptTag({ url: '/injectedfile.js' });
- expect(scriptHandle.asElement()).not.toBeNull();
- expect(await page.evaluate(() => __injected)).toBe(42);
- });
-
- it('should work with a url and type=module', async({page, server}) => {
- await page.goto(server.EMPTY_PAGE);
- await page.addScriptTag({ url: '/es6/es6import.js', type: 'module' });
- expect(await page.evaluate(() => __es6injected)).toBe(42);
- });
-
- it('should work with a path and type=module', async({page, server}) => {
- await page.goto(server.EMPTY_PAGE);
- await page.addScriptTag({ path: path.join(__dirname, 'assets/es6/es6pathimport.js'), type: 'module' });
- await page.waitForFunction('window.__es6injected');
- expect(await page.evaluate(() => __es6injected)).toBe(42);
- });
-
- it('should work with a content and type=module', async({page, server}) => {
- await page.goto(server.EMPTY_PAGE);
- await page.addScriptTag({ content: `import num from '/es6/es6module.js';window.__es6injected = num;`, type: 'module' });
- await page.waitForFunction('window.__es6injected');
- expect(await page.evaluate(() => __es6injected)).toBe(42);
- });
-
- it('should throw an error if loading from url fail', async({page, server}) => {
- await page.goto(server.EMPTY_PAGE);
- let error = null;
- try {
- await page.addScriptTag({ url: '/nonexistfile.js' });
- } catch (e) {
- error = e;
- }
- expect(error.message).toBe('Loading script from /nonexistfile.js failed');
- });
-
- it('should work with a path', async({page, server}) => {
- await page.goto(server.EMPTY_PAGE);
- const scriptHandle = await page.addScriptTag({ path: path.join(__dirname, 'assets/injectedfile.js') });
- expect(scriptHandle.asElement()).not.toBeNull();
- expect(await page.evaluate(() => __injected)).toBe(42);
- });
-
- it('should include sourcemap when path is provided', async({page, server}) => {
- await page.goto(server.EMPTY_PAGE);
- await page.addScriptTag({ path: path.join(__dirname, 'assets/injectedfile.js') });
- const result = await page.evaluate(() => __injectedError.stack);
- expect(result).toContain(path.join('assets', 'injectedfile.js'));
- });
-
- it('should work with content', async({page, server}) => {
- await page.goto(server.EMPTY_PAGE);
- const scriptHandle = await page.addScriptTag({ content: 'window.__injected = 35;' });
- expect(scriptHandle.asElement()).not.toBeNull();
- expect(await page.evaluate(() => __injected)).toBe(35);
- });
-
- xit('should throw when added with content to the CSP page', async({page, server}) => {
- await page.goto(server.PREFIX + '/csp.html');
- let error = null;
- await page.addScriptTag({ content: 'window.__injected = 35;' }).catch(e => error = e);
- expect(error).toBeTruthy();
- });
-
- it('should throw when added with URL to the CSP page', async({page, server}) => {
- await page.goto(server.PREFIX + '/csp.html');
- let error = null;
- await page.addScriptTag({ url: server.CROSS_PROCESS_PREFIX + '/injectedfile.js' }).catch(e => error = e);
- expect(error).toBeTruthy();
- });
- });
-
- describe('Page.addStyleTag', function() {
- it('should throw an error if no options are provided', async({page, server}) => {
- let error = null;
- try {
- await page.addStyleTag('/injectedstyle.css');
- } catch (e) {
- error = e;
- }
- expect(error.message).toBe('Provide an object with a `url`, `path` or `content` property');
- });
-
- it('should work with a url', async({page, server}) => {
- await page.goto(server.EMPTY_PAGE);
- const styleHandle = await page.addStyleTag({ url: '/injectedstyle.css' });
- expect(styleHandle.asElement()).not.toBeNull();
- expect(await page.evaluate(`window.getComputedStyle(document.querySelector('body')).getPropertyValue('background-color')`)).toBe('rgb(255, 0, 0)');
- });
-
- it('should throw an error if loading from url fail', async({page, server}) => {
- await page.goto(server.EMPTY_PAGE);
- let error = null;
- try {
- await page.addStyleTag({ url: '/nonexistfile.js' });
- } catch (e) {
- error = e;
- }
- expect(error.message).toBe('Loading style from /nonexistfile.js failed');
- });
-
- it('should work with a path', async({page, server}) => {
- await page.goto(server.EMPTY_PAGE);
- const styleHandle = await page.addStyleTag({ path: path.join(__dirname, 'assets/injectedstyle.css') });
- expect(styleHandle.asElement()).not.toBeNull();
- expect(await page.evaluate(`window.getComputedStyle(document.querySelector('body')).getPropertyValue('background-color')`)).toBe('rgb(255, 0, 0)');
- });
-
- it('should include sourcemap when path is provided', async({page, server}) => {
- await page.goto(server.EMPTY_PAGE);
- await page.addStyleTag({ path: path.join(__dirname, 'assets/injectedstyle.css') });
- const styleHandle = await page.$('style');
- const styleContent = await page.evaluate(style => style.innerHTML, styleHandle);
- expect(styleContent).toContain(path.join('assets', 'injectedstyle.css'));
- });
-
- it('should work with content', async({page, server}) => {
- await page.goto(server.EMPTY_PAGE);
- const styleHandle = await page.addStyleTag({ content: 'body { background-color: green; }' });
- expect(styleHandle.asElement()).not.toBeNull();
- expect(await page.evaluate(`window.getComputedStyle(document.querySelector('body')).getPropertyValue('background-color')`)).toBe('rgb(0, 128, 0)');
- });
-
- xit('should throw when added with content to the CSP page', async({page, server}) => {
- await page.goto(server.PREFIX + '/csp.html');
- let error = null;
- await page.addStyleTag({ content: 'body { background-color: green; }' }).catch(e => error = e);
- expect(error).toBeTruthy();
- });
-
- it('should throw when added with URL to the CSP page', async({page, server}) => {
- await page.goto(server.PREFIX + '/csp.html');
- let error = null;
- await page.addStyleTag({ url: server.CROSS_PROCESS_PREFIX + '/injectedstyle.css' }).catch(e => error = e);
- expect(error).toBeTruthy();
- });
- });
-
- describe('Page.title', function() {
- it('should return the page title', async({page, server}) => {
- await page.goto(server.PREFIX + '/title.html');
- expect(await page.title()).toBe('Woof-Woof');
- });
- });
-
- describe('Page.select', function() {
- it('should select single option', async({page, server}) => {
- await page.goto(server.PREFIX + '/input/select.html');
- await page.select('select', 'blue');
- expect(await page.evaluate(() => result.onInput)).toEqual(['blue']);
- expect(await page.evaluate(() => result.onChange)).toEqual(['blue']);
- });
- it('should select only first option', async({page, server}) => {
- await page.goto(server.PREFIX + '/input/select.html');
- await page.select('select', 'blue', 'green', 'red');
- expect(await page.evaluate(() => result.onInput)).toEqual(['blue']);
- expect(await page.evaluate(() => result.onChange)).toEqual(['blue']);
- });
- it('should select multiple options', async({page, server}) => {
- await page.goto(server.PREFIX + '/input/select.html');
- await page.evaluate(() => makeMultiple());
- await page.select('select', 'blue', 'green', 'red');
- expect(await page.evaluate(() => result.onInput)).toEqual(['blue', 'green', 'red']);
- expect(await page.evaluate(() => result.onChange)).toEqual(['blue', 'green', 'red']);
- });
- it('should respect event bubbling', async({page, server}) => {
- await page.goto(server.PREFIX + '/input/select.html');
- await page.select('select', 'blue');
- expect(await page.evaluate(() => result.onBubblingInput)).toEqual(['blue']);
- expect(await page.evaluate(() => result.onBubblingChange)).toEqual(['blue']);
- });
- it('should throw when element is not a