test(firefox): support loading of file URLs (#1132)

Fixes #822
This commit is contained in:
Andrey Lushnikov 2020-02-26 15:02:59 -08:00 committed by GitHub
parent 7a7575461c
commit 22c28b6615
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 12 deletions

View File

@ -642,15 +642,3 @@ module.exports.describe = function({testRunner, expect, defaultBrowserOptions, p
});
});
};
/**
* @param {string} path
* @return {string}
*/
function pathToFileURL(path) {
let pathName = path.replace(/\\/g, '/');
// Windows drive letter must be prefixed with a slash.
if (!pathName.startsWith('/'))
pathName = '/' + pathName;
return 'file://' + pathName;
}

View File

@ -16,6 +16,8 @@
*/
const utils = require('./utils');
const path = require('path');
const url = require('url');
/**
* @type {PageTestSuite}
@ -30,6 +32,12 @@ module.exports.describe = function({testRunner, expect, playwright, MAC, WIN, FF
await page.goto(server.EMPTY_PAGE);
expect(page.url()).toBe(server.EMPTY_PAGE);
});
it('should work with file URL', async({page, server}) => {
const fileurl = url.pathToFileURL(path.join(__dirname, 'assets', 'frames', 'two-frames.html')).href;
await page.goto(fileurl);
expect(page.url().toLowerCase()).toBe(fileurl.toLowerCase());
expect(page.frames().length).toBe(3);
});
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);
@ -978,3 +986,4 @@ module.exports.describe = function({testRunner, expect, playwright, MAC, WIN, FF
}
}
};