Skip to content

Commit 9ec0267

Browse files
authored
chore(test): use pathToFileURL (microsoft#3292)
1 parent 3c2fcb7 commit 9ec0267

File tree

3 files changed

+3
-13
lines changed

3 files changed

+3
-13
lines changed

test/capabilities.spec.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616

1717
const path = require('path');
18+
const url = require('url');
1819

1920
const {FFOX, CHROMIUM, WEBKIT, WIN, LINUX, ASSETS_DIR} = testOptions;
2021

@@ -58,10 +59,7 @@ it.fail(WEBKIT && WIN)('should play video', async({page}) => {
5859
const absolutePath = path.join(ASSETS_DIR, fileName);
5960
// Our test server doesn't support range requests required to play on Mac,
6061
// so we load the page using a file url.
61-
const url = WIN
62-
? 'file:///' + absolutePath.replace(/\\/g, '/')
63-
: 'file://' + absolutePath;
64-
await page.goto(url);
62+
await page.goto(url.pathToFileURL(absolutePath).href);
6563
await page.$eval('video', v => v.play());
6664
await page.$eval('video', v => v.pause());
6765
});

test/navigation.spec.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@
1515
* limitations under the License.
1616
*/
1717

18-
const utils = require('./utils');
19-
const path = require('path');
20-
const url = require('url');
21-
const {FFOX, CHROMIUM, WEBKIT, ASSETS_DIR, MAC, WIN} = testOptions;
22-
2318
it('should work with _blank target', async({page, server}) => {
2419
server.setRoute('/empty.html', (req, res) => {
2520
res.end(`<a href="${server.EMPTY_PAGE}" target="_blank">Click me</a>`);

test/page-history.spec.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
* limitations under the License.
1616
*/
1717

18-
const utils = require('./utils');
1918
const path = require('path');
2019
const url = require('url');
2120
const {FFOX, CHROMIUM, WEBKIT, ASSETS_DIR, MAC, WIN} = testOptions;
@@ -56,9 +55,7 @@ it('page.goBack should work with HistoryAPI', async({page, server}) => {
5655

5756
it.fail(WEBKIT && MAC)('page.goBack should work for file urls', async ({page, server}) => {
5857
// WebKit embedder fails to go back/forward to the file url.
59-
const url1 = WIN
60-
? 'file:///' + path.join(ASSETS_DIR, 'empty.html').replace(/\\/g, '/')
61-
: 'file://' + path.join(ASSETS_DIR, 'empty.html');
58+
const url1 = url.pathToFileURL(path.join(ASSETS_DIR, 'empty.html')).href;
6259
const url2 = server.EMPTY_PAGE;
6360
await page.goto(url1);
6461
await page.setContent(`<a href='${url2}'>url2</a>`);

0 commit comments

Comments
 (0)