diff --git a/test/interception.spec.js b/test/interception.spec.js index 90fa5e33b52d3..035f84295d865 100644 --- a/test/interception.spec.js +++ b/test/interception.spec.js @@ -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; -} diff --git a/test/navigation.spec.js b/test/navigation.spec.js index 3c94b42b94a1d..5bf278171af5c 100644 --- a/test/navigation.spec.js +++ b/test/navigation.spec.js @@ -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 } } }; +