From f1f65dfe438a8343a5846d1b9da3869b3435dabf Mon Sep 17 00:00:00 2001 From: Andrey Lushnikov Date: Tue, 25 Feb 2020 14:05:50 -0800 Subject: [PATCH 1/2] fix(firefox): support loading of file URLs Fixes #822 --- test/interception.spec.js | 12 ------------ test/navigation.spec.js | 9 +++++++++ 2 files changed, 9 insertions(+), 12 deletions(-) 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..ea8012d572934 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()).toBe(fileurl); + 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 } } }; + From dc4a4de7071dcf1850670b575c70b59aa8222028 Mon Sep 17 00:00:00 2001 From: Andrey Lushnikov Date: Wed, 26 Feb 2020 14:20:53 -0800 Subject: [PATCH 2/2] fix test --- test/navigation.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/navigation.spec.js b/test/navigation.spec.js index ea8012d572934..5bf278171af5c 100644 --- a/test/navigation.spec.js +++ b/test/navigation.spec.js @@ -35,7 +35,7 @@ module.exports.describe = function({testRunner, expect, playwright, MAC, WIN, FF 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()).toBe(fileurl); + expect(page.url().toLowerCase()).toBe(fileurl.toLowerCase()); expect(page.frames().length).toBe(3); }); it('should use http for no protocol', async({page, server}) => {