Skip to content

Commit c1cca19

Browse files
authored
test: extract tests for webkit provisional page (#609)
1 parent 4cf2180 commit c1cca19

File tree

4 files changed

+64
-28
lines changed

4 files changed

+64
-28
lines changed

test/interception.spec.js

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -561,19 +561,6 @@ module.exports.describe = function({testRunner, expect, defaultBrowserOptions, p
561561
await page.setOfflineMode(false);
562562
expect(await page.evaluate(() => window.navigator.onLine)).toBe(true);
563563
});
564-
it('should continue if the interception gets disabled during provisional load', async({page, server}) => {
565-
await page.goto(server.EMPTY_PAGE);
566-
await page.setRequestInterception(true);
567-
expect(await page.evaluate(() => navigator.onLine)).toBe(true);
568-
let intercepted;
569-
page.on('request', async request => {
570-
intercepted = true;
571-
await page.setRequestInterception(false);
572-
});
573-
const response = await page.goto(server.CROSS_PROCESS_PREFIX + '/empty.html');
574-
expect(intercepted).toBe(true);
575-
expect(response.status()).toBe(200);
576-
});
577564
});
578565

579566
describe('Interception vs isNavigationRequest', () => {

test/network.spec.js

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -337,21 +337,6 @@ module.exports.describe = function({testRunner, expect, FFOX, CHROMIUM, WEBKIT})
337337
}
338338
expect(error.message).toBe('Expected value of header "foo" to be String, but "number" is found.');
339339
});
340-
WEBKIT && it('should be pushed to cross-process provisional page', async({page, server}) => {
341-
await page.goto(server.EMPTY_PAGE);
342-
const pagePath = '/one-style.html';
343-
server.setRoute(pagePath, async (req, res) => {
344-
await page.setExtraHTTPHeaders({ foo: 'bar' });
345-
server.serveFile(req, res, pagePath);
346-
});
347-
const [htmlReq, cssReq] = await Promise.all([
348-
server.waitForRequest(pagePath),
349-
server.waitForRequest('/one-style.css'),
350-
page.goto(server.CROSS_PROCESS_PREFIX + pagePath)
351-
]);
352-
expect(htmlReq.headers['foo']).toBe(undefined);
353-
expect(cssReq.headers['foo']).toBe('bar');
354-
});
355340
});
356341

357342
false && describe.skip(FFOX)('WebSocket', function() {

test/playwright.spec.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,9 @@ module.exports.describe = ({testRunner, product, playwrightPath}) => {
181181
testRunner.loadTests(require('./features/permissions.spec.js'), testOptions);
182182
}
183183

184+
if (WEBKIT) {
185+
testRunner.loadTests(require('./webkit/provisional.spec.js'), testOptions);
186+
}
184187
});
185188

186189
// Browser-level tests that are given a browser.

test/webkit/provisional.spec.js

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/**
2+
* Copyright (c) Microsoft Corporation.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
module.exports.describe = function ({ testRunner, expect }) {
18+
const {describe, xdescribe, fdescribe} = testRunner;
19+
const {it, fit, xit, dit} = testRunner;
20+
const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;
21+
22+
describe('provisional page', function() {
23+
it('extraHttpHeaders should be pushed to provisional page', async({page, server}) => {
24+
await page.goto(server.EMPTY_PAGE);
25+
const pagePath = '/one-style.html';
26+
server.setRoute(pagePath, async (req, res) => {
27+
await page.setExtraHTTPHeaders({ foo: 'bar' });
28+
server.serveFile(req, res, pagePath);
29+
});
30+
const [htmlReq, cssReq] = await Promise.all([
31+
server.waitForRequest(pagePath),
32+
server.waitForRequest('/one-style.css'),
33+
page.goto(server.CROSS_PROCESS_PREFIX + pagePath)
34+
]);
35+
expect(htmlReq.headers['foo']).toBe(undefined);
36+
expect(cssReq.headers['foo']).toBe('bar');
37+
});
38+
it('should continue load when interception gets disabled during provisional load', async({page, server}) => {
39+
await page.goto(server.EMPTY_PAGE);
40+
await page.setRequestInterception(true);
41+
expect(await page.evaluate(() => navigator.onLine)).toBe(true);
42+
let intercepted = null;
43+
const order = [];
44+
page.on('request', request => {
45+
intercepted = page.setRequestInterception(false).then(() => order.push('setRequestInterception'));
46+
});
47+
const response = await page.goto(server.CROSS_PROCESS_PREFIX + '/empty.html').then(response => {
48+
order.push('goto');
49+
return response;
50+
});
51+
// Should intercept a request.
52+
expect(intercepted).not.toBe(null);
53+
await intercepted;
54+
// Should continue on disabling and load successfully.
55+
expect(response.status()).toBe(200);
56+
// Should resolve setRequestInterception before goto.
57+
expect(order[0]).toBe('setRequestInterception');
58+
expect(order[1]).toBe('goto');
59+
});
60+
});
61+
};

0 commit comments

Comments
 (0)