Skip to content

Commit 22c28b6

Browse files
authored
test(firefox): support loading of file URLs (#1132)
Fixes #822
1 parent 7a75754 commit 22c28b6

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

test/interception.spec.js

-12
Original file line numberDiff line numberDiff line change
@@ -642,15 +642,3 @@ module.exports.describe = function({testRunner, expect, defaultBrowserOptions, p
642642
});
643643
});
644644
};
645-
646-
/**
647-
* @param {string} path
648-
* @return {string}
649-
*/
650-
function pathToFileURL(path) {
651-
let pathName = path.replace(/\\/g, '/');
652-
// Windows drive letter must be prefixed with a slash.
653-
if (!pathName.startsWith('/'))
654-
pathName = '/' + pathName;
655-
return 'file://' + pathName;
656-
}

test/navigation.spec.js

+9
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
*/
1717

1818
const utils = require('./utils');
19+
const path = require('path');
20+
const url = require('url');
1921

2022
/**
2123
* @type {PageTestSuite}
@@ -30,6 +32,12 @@ module.exports.describe = function({testRunner, expect, playwright, MAC, WIN, FF
3032
await page.goto(server.EMPTY_PAGE);
3133
expect(page.url()).toBe(server.EMPTY_PAGE);
3234
});
35+
it('should work with file URL', async({page, server}) => {
36+
const fileurl = url.pathToFileURL(path.join(__dirname, 'assets', 'frames', 'two-frames.html')).href;
37+
await page.goto(fileurl);
38+
expect(page.url().toLowerCase()).toBe(fileurl.toLowerCase());
39+
expect(page.frames().length).toBe(3);
40+
});
3341
it('should use http for no protocol', async({page, server}) => {
3442
await page.goto(server.EMPTY_PAGE.substring('http://'.length));
3543
expect(page.url()).toBe(server.EMPTY_PAGE);
@@ -978,3 +986,4 @@ module.exports.describe = function({testRunner, expect, playwright, MAC, WIN, FF
978986
}
979987
}
980988
};
989+

0 commit comments

Comments
 (0)