forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-source-map-invalid-url.js
More file actions
56 lines (48 loc) · 1.36 KB
/
Copy pathtest-source-map-invalid-url.js
File metadata and controls
56 lines (48 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Flags: --enable-source-maps
'use strict';
const common = require('../common');
const assert = require('node:assert');
const childProcess = require('node:child_process');
// TODO(legendecas): c8 will complain if non-file-scheme is used in source maps.
// https://github.com/bcoe/c8/blob/ee2f1cfc5584d41bb2d51b788d0953dab0c798f8/lib/report.js#L517
if (process.env.NODE_V8_COVERAGE) {
console.log('Spawning with coverage disabled.');
const { status } = childProcess.spawnSync(
process.execPath,
[__filename],
{
stdio: 'inherit',
env: {
...process.env,
NODE_V8_COVERAGE: '',
},
},
);
assert.strictEqual(status, 0);
return;
}
const sources = [
`
//# sourceMappingURL=unknown-protocol://invalid/url
//# sourceURL=unknown-protocol://invalid/url
`,
`
//# sourceMappingURL=file://invalid:/file/url
//# sourceURL=file://invalid:/file/url
`,
`
//# sourceMappingURL=invalid-url
//# sourceURL=invalid-url
`,
];
sources.forEach(test);
function test(source) {
// Eval should tolerate invalid source map url
eval(source);
const base64 = Buffer.from(source).toString('base64url');
// Dynamic import should tolerate invalid source map url
import(`data:text/javascript;base64,${base64}`)
.then(common.mustCall());
}
// eslint-disable-next-line @stylistic/js/spaced-comment
//# sourceMappingURL=invalid-url