test(android): run selected page tests on android (3) (#5910)
This commit is contained in:
parent
3a27bdd3e6
commit
ca35da0a33
35
test/browsercontext-set-extra-http-headers.spec.ts
Normal file
35
test/browsercontext-set-extra-http-headers.spec.ts
Normal file
|
|
@ -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');
|
||||
});
|
||||
|
|
@ -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');
|
||||
|
|
@ -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++)
|
||||
|
|
@ -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;
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { it, expect } from './fixtures';
|
||||
import { it, expect } from '../fixtures';
|
||||
|
||||
|
||||
async function giveItAChanceToResolve(page) {
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { it, expect } from './fixtures';
|
||||
import { it, expect } from '../fixtures';
|
||||
|
||||
const expectedOutput = '<html><head></head><body><div>hello</div></body></html>';
|
||||
|
||||
|
|
@ -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);
|
||||
|
|
@ -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(`<input type=file>`);
|
||||
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(`<input type=file>`);
|
||||
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}) => {
|
|||
<input type="file" name="file2">
|
||||
<input type="submit" value="Submit">
|
||||
</form>`);
|
||||
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}) => {
|
||||
|
|
@ -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();
|
||||
|
|
@ -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}) => {
|
||||
|
|
@ -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);
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { it, expect } from './fixtures';
|
||||
import { it, expect } from '../fixtures';
|
||||
|
||||
import vm from 'vm';
|
||||
|
||||
|
|
@ -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);
|
||||
|
|
@ -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))));
|
||||
|
|
@ -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));
|
||||
|
||||
Loading…
Reference in a new issue