feat(goto): assume http:// for localhost navigations (#825)
This commit is contained in:
parent
8f1df5e1e8
commit
bdf8e39786
|
|
@ -381,7 +381,7 @@ export class Frame {
|
||||||
referer = options.referer;
|
referer = options.referer;
|
||||||
}
|
}
|
||||||
const watcher = new LifecycleWatcher(this, options, false /* supportUrlMatch */);
|
const watcher = new LifecycleWatcher(this, options, false /* supportUrlMatch */);
|
||||||
|
url = helper.completeUserURL(url);
|
||||||
let navigateResult: GotoResult;
|
let navigateResult: GotoResult;
|
||||||
const navigate = async () => {
|
const navigate = async () => {
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -211,6 +211,12 @@ class Helper {
|
||||||
tokens.push('$');
|
tokens.push('$');
|
||||||
return new RegExp(tokens.join(''));
|
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) {
|
export function assert(value: any, message?: string) {
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,10 @@ module.exports.describe = function({testRunner, expect, playwright, FFOX, CHROMI
|
||||||
await page.goto(server.EMPTY_PAGE);
|
await page.goto(server.EMPTY_PAGE);
|
||||||
expect(page.url()).toBe(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}) => {
|
it('should work cross-process', async({page, server}) => {
|
||||||
await page.goto(server.EMPTY_PAGE);
|
await page.goto(server.EMPTY_PAGE);
|
||||||
expect(page.url()).toBe(server.EMPTY_PAGE);
|
expect(page.url()).toBe(server.EMPTY_PAGE);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue