diff --git a/test/browsercontext-set-extra-http-headers.spec.ts b/test/browsercontext-set-extra-http-headers.spec.ts
new file mode 100644
index 0000000000..2ee4a1fe79
--- /dev/null
+++ b/test/browsercontext-set-extra-http-headers.spec.ts
@@ -0,0 +1,35 @@
+/**
+ * Copyright 2018 Google Inc. All rights reserved.
+ * Modifications copyright (c) Microsoft Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.
+ */
+
+import { it, expect } from './fixtures';
+
+it('should override extra headers from browser context', async ({browser, server}) => {
+ const context = await browser.newContext({
+ extraHTTPHeaders: { 'fOo': 'bAr', 'baR': 'foO' },
+ });
+ const page = await context.newPage();
+ await page.setExtraHTTPHeaders({
+ 'Foo': 'Bar'
+ });
+ const [request] = await Promise.all([
+ server.waitForRequest('/empty.html'),
+ page.goto(server.EMPTY_PAGE),
+ ]);
+ await context.close();
+ expect(request.headers['foo']).toBe('Bar');
+ expect(request.headers['bar']).toBe('foO');
+});
diff --git a/test/page-dispatchevent.spec.ts b/test/page/page-dispatchevent.spec.ts
similarity index 99%
rename from test/page-dispatchevent.spec.ts
rename to test/page/page-dispatchevent.spec.ts
index 1d831d216d..1fb9f58ba6 100644
--- a/test/page-dispatchevent.spec.ts
+++ b/test/page/page-dispatchevent.spec.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import { it, expect } from './fixtures';
+import { it, expect } from '../fixtures';
it('should dispatch click event', async ({page, server}) => {
await page.goto(server.PREFIX + '/input/button.html');
diff --git a/test/page-fill.spec.ts b/test/page/page-fill.spec.ts
similarity index 99%
rename from test/page-fill.spec.ts
rename to test/page/page-fill.spec.ts
index d2ecd6102c..e1bb839692 100644
--- a/test/page-fill.spec.ts
+++ b/test/page/page-fill.spec.ts
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-import { it, expect } from './fixtures';
+import { it, expect } from '../fixtures';
async function giveItAChanceToFill(page) {
for (let i = 0; i < 5; i++)
diff --git a/test/page-route.spec.ts b/test/page/page-route.spec.ts
similarity index 99%
rename from test/page-route.spec.ts
rename to test/page/page-route.spec.ts
index cf62c89e3d..beb02ef2d5 100644
--- a/test/page-route.spec.ts
+++ b/test/page/page-route.spec.ts
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-import { it, expect } from './fixtures';
+import { it, expect } from '../fixtures';
it('should intercept', async ({page, server}) => {
let intercepted = false;
diff --git a/test/page-select-option.spec.ts b/test/page/page-select-option.spec.ts
similarity index 99%
rename from test/page-select-option.spec.ts
rename to test/page/page-select-option.spec.ts
index 91cc66c23c..0c52a8402c 100644
--- a/test/page-select-option.spec.ts
+++ b/test/page/page-select-option.spec.ts
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-import { it, expect } from './fixtures';
+import { it, expect } from '../fixtures';
async function giveItAChanceToResolve(page) {
diff --git a/test/page-set-content.spec.ts b/test/page/page-set-content.spec.ts
similarity index 98%
rename from test/page-set-content.spec.ts
rename to test/page/page-set-content.spec.ts
index e658771337..aaeaf80119 100644
--- a/test/page-set-content.spec.ts
+++ b/test/page/page-set-content.spec.ts
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-import { it, expect } from './fixtures';
+import { it, expect } from '../fixtures';
const expectedOutput = '
hello
';
diff --git a/test/page-set-extra-http-headers.spec.ts b/test/page/page-set-extra-http-headers.spec.ts
similarity index 76%
rename from test/page-set-extra-http-headers.spec.ts
rename to test/page/page-set-extra-http-headers.spec.ts
index 2244fe7f6a..011c330bf7 100644
--- a/test/page-set-extra-http-headers.spec.ts
+++ b/test/page/page-set-extra-http-headers.spec.ts
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-import { it, expect } from './fixtures';
+import { it, expect } from '../fixtures';
it('should work', async ({page, server}) => {
await page.setExtraHTTPHeaders({
@@ -42,37 +42,17 @@ it('should work with redirects', async ({page, server}) => {
expect(request.headers['foo']).toBe('bar');
});
-it('should work with extra headers from browser context', async ({browser, server}) => {
- const context = await browser.newContext();
- await context.setExtraHTTPHeaders({
+it('should work with extra headers from browser context', async ({page, server}) => {
+ await page.context().setExtraHTTPHeaders({
'foo': 'bar',
});
- const page = await context.newPage();
const [request] = await Promise.all([
server.waitForRequest('/empty.html'),
page.goto(server.EMPTY_PAGE),
]);
- await context.close();
expect(request.headers['foo']).toBe('bar');
});
-it('should override extra headers from browser context', async ({browser, server}) => {
- const context = await browser.newContext({
- extraHTTPHeaders: { 'fOo': 'bAr', 'baR': 'foO' },
- });
- const page = await context.newPage();
- await page.setExtraHTTPHeaders({
- 'Foo': 'Bar'
- });
- const [request] = await Promise.all([
- server.waitForRequest('/empty.html'),
- page.goto(server.EMPTY_PAGE),
- ]);
- await context.close();
- expect(request.headers['foo']).toBe('Bar');
- expect(request.headers['bar']).toBe('foO');
-});
-
it('should throw for non-string header values', async ({browser, page}) => {
// @ts-expect-error headers must be strings
const error1 = await page.setExtraHTTPHeaders({ 'foo': 1 }).catch(e => e);
diff --git a/test/page-set-input-files.spec.ts b/test/page/page-set-input-files.spec.ts
similarity index 95%
rename from test/page-set-input-files.spec.ts
rename to test/page/page-set-input-files.spec.ts
index 3e7640489d..8f60306687 100644
--- a/test/page-set-input-files.spec.ts
+++ b/test/page/page-set-input-files.spec.ts
@@ -15,13 +15,13 @@
* limitations under the License.
*/
-import { it, expect } from './fixtures';
+import { it, expect } from '../fixtures';
import path from 'path';
import fs from 'fs';
import formidable from 'formidable';
-const FILE_TO_UPLOAD = path.join(__dirname, '/assets/file-to-upload.txt');
+const FILE_TO_UPLOAD = path.join(__dirname, '../assets/file-to-upload.txt');
it('should upload the file', async ({page, server}) => {
await page.goto(server.PREFIX + '/input/fileupload.html');
@@ -39,7 +39,7 @@ it('should upload the file', async ({page, server}) => {
it('should work', async ({page}) => {
await page.setContent(``);
- await page.setInputFiles('input', path.join(__dirname, '/assets/file-to-upload.txt'));
+ await page.setInputFiles('input', path.join(__dirname, '../assets/file-to-upload.txt'));
expect(await page.$eval('input', input => input.files.length)).toBe(1);
expect(await page.$eval('input', input => input.files[0].name)).toBe('file-to-upload.txt');
});
@@ -168,7 +168,7 @@ it('should work with CSP', async ({page, server}) => {
server.setCSP('/empty.html', 'default-src "none"');
await page.goto(server.EMPTY_PAGE);
await page.setContent(``);
- await page.setInputFiles('input', path.join(__dirname, '/assets/file-to-upload.txt'));
+ await page.setInputFiles('input', path.join(__dirname, '../assets/file-to-upload.txt'));
expect(await page.$eval('input', input => input.files.length)).toBe(1);
expect(await page.$eval('input', input => input.files[0].name)).toBe('file-to-upload.txt');
});
@@ -244,8 +244,8 @@ it('should detect mime type', async ({page, server}) => {
`);
- await (await page.$('input[name=file1]')).setInputFiles(path.join(__dirname, '/assets/file-to-upload.txt'));
- await (await page.$('input[name=file2]')).setInputFiles(path.join(__dirname, '/assets/pptr.png'));
+ await (await page.$('input[name=file1]')).setInputFiles(path.join(__dirname, '../assets/file-to-upload.txt'));
+ await (await page.$('input[name=file2]')).setInputFiles(path.join(__dirname, '../assets/pptr.png'));
await Promise.all([
page.click('input[type=submit]'),
server.waitForRequest('/upload'),
@@ -254,11 +254,11 @@ it('should detect mime type', async ({page, server}) => {
expect(file1.name).toBe('file-to-upload.txt');
expect(file1.type).toBe('text/plain');
expect(fs.readFileSync(file1.path).toString()).toBe(
- fs.readFileSync(path.join(__dirname, '/assets/file-to-upload.txt')).toString());
+ fs.readFileSync(path.join(__dirname, '../assets/file-to-upload.txt')).toString());
expect(file2.name).toBe('pptr.png');
expect(file2.type).toBe('image/png');
expect(fs.readFileSync(file2.path).toString()).toBe(
- fs.readFileSync(path.join(__dirname, '/assets/pptr.png')).toString());
+ fs.readFileSync(path.join(__dirname, '../assets/pptr.png')).toString());
});
it('should be able to read selected file', async ({page, server}) => {
diff --git a/test/page-wait-for-function.spec.ts b/test/page/page-wait-for-function.spec.ts
similarity index 99%
rename from test/page-wait-for-function.spec.ts
rename to test/page/page-wait-for-function.spec.ts
index 907b571646..273ff1abf8 100644
--- a/test/page-wait-for-function.spec.ts
+++ b/test/page/page-wait-for-function.spec.ts
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-import { it, expect } from './fixtures';
+import { it, expect } from '../fixtures';
it('should timeout', async ({page}) => {
const startTime = Date.now();
diff --git a/test/page-wait-for-load-state.spec.ts b/test/page/page-wait-for-load-state.spec.ts
similarity index 96%
rename from test/page-wait-for-load-state.spec.ts
rename to test/page/page-wait-for-load-state.spec.ts
index 10fb28fa92..3c5e162f68 100644
--- a/test/page-wait-for-load-state.spec.ts
+++ b/test/page/page-wait-for-load-state.spec.ts
@@ -15,8 +15,8 @@
* limitations under the License.
*/
-import { it, expect } from './fixtures';
-import type { Route } from '..';
+import { it, expect } from '../fixtures';
+import type { Route } from '../..';
it('should pick up ongoing navigation', async ({page, server}) => {
let response = null;
@@ -140,9 +140,7 @@ it('should wait for load state of newPage', async ({browser, context, page, serv
expect(await newPage.evaluate(() => document.readyState)).toBe('complete');
});
-it('should resolve after popup load', async ({browser, server}) => {
- const context = await browser.newContext();
- const page = await context.newPage();
+it('should resolve after popup load', async ({page, server}) => {
await page.goto(server.EMPTY_PAGE);
// Stall the 'load' by delaying css.
let cssResponse;
@@ -162,7 +160,6 @@ it('should resolve after popup load', async ({browser, server}) => {
await loadSatePromise;
expect(resolved).toBe(true);
expect(popup.url()).toBe(server.PREFIX + '/one-style.html');
- await context.close();
});
it('should work for frame', async ({page, server}) => {
diff --git a/test/page-wait-for-navigation.spec.ts b/test/page/page-wait-for-navigation.spec.ts
similarity index 98%
rename from test/page-wait-for-navigation.spec.ts
rename to test/page/page-wait-for-navigation.spec.ts
index d02e59f926..d381bc5f63 100644
--- a/test/page-wait-for-navigation.spec.ts
+++ b/test/page/page-wait-for-navigation.spec.ts
@@ -15,9 +15,9 @@
* limitations under the License.
*/
-import { it, expect } from './fixtures';
-import type { Frame } from '../index';
-import { expectedSSLError } from './utils';
+import { it, expect } from '../fixtures';
+import type { Frame } from '../../index';
+import { expectedSSLError } from '../utils';
it('should work', async ({page, server}) => {
await page.goto(server.EMPTY_PAGE);
diff --git a/test/page-wait-for-request.spec.ts b/test/page/page-wait-for-request.spec.ts
similarity index 98%
rename from test/page-wait-for-request.spec.ts
rename to test/page/page-wait-for-request.spec.ts
index 506a25fac8..0fd97770bf 100644
--- a/test/page-wait-for-request.spec.ts
+++ b/test/page/page-wait-for-request.spec.ts
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-import { it, expect } from './fixtures';
+import { it, expect } from '../fixtures';
import vm from 'vm';
diff --git a/test/page-wait-for-response.spec.ts b/test/page/page-wait-for-response.spec.ts
similarity index 98%
rename from test/page-wait-for-response.spec.ts
rename to test/page/page-wait-for-response.spec.ts
index ab75f75e35..c83f7dab70 100644
--- a/test/page-wait-for-response.spec.ts
+++ b/test/page/page-wait-for-response.spec.ts
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-import { it, expect } from './fixtures';
+import { it, expect } from '../fixtures';
it('should work', async ({page, server}) => {
await page.goto(server.EMPTY_PAGE);
diff --git a/test/page-wait-for-selector-1.spec.ts b/test/page/page-wait-for-selector-1.spec.ts
similarity index 99%
rename from test/page-wait-for-selector-1.spec.ts
rename to test/page/page-wait-for-selector-1.spec.ts
index 75cd859f7c..3d8440996c 100644
--- a/test/page-wait-for-selector-1.spec.ts
+++ b/test/page/page-wait-for-selector-1.spec.ts
@@ -15,8 +15,8 @@
* limitations under the License.
*/
-import { it, expect } from './fixtures';
-import { attachFrame, detachFrame } from './utils';
+import { it, expect } from '../fixtures';
+import { attachFrame, detachFrame } from '../utils';
async function giveItTimeToLog(frame) {
await frame.evaluate(() => new Promise(f => requestAnimationFrame(() => requestAnimationFrame(f))));
diff --git a/test/page-wait-for-selector-2.spec.ts b/test/page/page-wait-for-selector-2.spec.ts
similarity index 99%
rename from test/page-wait-for-selector-2.spec.ts
rename to test/page/page-wait-for-selector-2.spec.ts
index b81addcb2b..dad6016639 100644
--- a/test/page-wait-for-selector-2.spec.ts
+++ b/test/page/page-wait-for-selector-2.spec.ts
@@ -15,8 +15,8 @@
* limitations under the License.
*/
-import { it, expect } from './fixtures';
-import { attachFrame, detachFrame } from './utils';
+import { it, expect } from '../fixtures';
+import { attachFrame, detachFrame } from '../utils';
const addElement = tag => document.body.appendChild(document.createElement(tag));