feat(goto): assume http:// for localhost navigations (#825)

This commit is contained in:
Pavel Feldman 2020-02-04 19:39:52 -08:00 committed by GitHub
parent 8f1df5e1e8
commit bdf8e39786
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 1 deletions

View File

@ -381,7 +381,7 @@ export class Frame {
referer = options.referer;
}
const watcher = new LifecycleWatcher(this, options, false /* supportUrlMatch */);
url = helper.completeUserURL(url);
let navigateResult: GotoResult;
const navigate = async () => {
try {

View File

@ -211,6 +211,12 @@ class Helper {
tokens.push('$');
return new RegExp(tokens.join(''));
}
static completeUserURL(urlString: string): string {
if (urlString.startsWith('localhost') || urlString.startsWith('127.0.0.1'))
urlString = 'http://' + urlString;
return urlString;
}
}
export function assert(value: any, message?: string) {

View File

@ -28,6 +28,10 @@ module.exports.describe = function({testRunner, expect, playwright, FFOX, CHROMI
await page.goto(server.EMPTY_PAGE);
expect(page.url()).toBe(server.EMPTY_PAGE);
});
it('should use http for no protocol', async({page, server}) => {
await page.goto(server.EMPTY_PAGE.substring('http://'.length));
expect(page.url()).toBe(server.EMPTY_PAGE);
});
it('should work cross-process', async({page, server}) => {
await page.goto(server.EMPTY_PAGE);
expect(page.url()).toBe(server.EMPTY_PAGE);