-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
Expand file tree
/
Copy pathtest-inspector-uriencode~d.js
More file actions
67 lines (55 loc) · 1.68 KB
/
test-inspector-uriencode~d.js
File metadata and controls
67 lines (55 loc) · 1.68 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
57
58
59
60
61
62
63
64
65
66
67
'use strict';
const common = require('../common');
common.skipIfInspectorDisabled();
const assert = require('assert');
const { Session } = require('inspector');
const path = require('path');
const { pathToFileURL } = require('url');
function debugged() {
return 42;
}
async function test() {
// Check without properly decoding
const session1 = new Session();
session1.connect();
let session1Paused = false;
session1.on('Debugger.paused', () => session1Paused = true);
session1.post('Debugger.enable');
await new Promise((resolve, reject) => {
session1.post('Debugger.setBreakpointByUrl', {
'lineNumber': 12,
'url': pathToFileURL(path.resolve(__dirname, __filename)).toString(),
'columnNumber': 0,
'condition': ''
}, (error, result) => {
return error ? reject(error) : resolve(result);
});
});
debugged();
assert(!session1Paused);
session1.disconnect();
// Check correctly with another session
let session2Paused = false;
const session2 = new Session();
session2.connect();
session2.on('Debugger.paused', () => session2Paused = true);
session2.post('Debugger.enable');
await new Promise((resolve, reject) => {
session2.post('Debugger.setBreakpointByUrl', {
'lineNumber': 12,
'url': decodeURIComponent(pathToFileURL(path.resolve(__dirname, __filename)).toString()),
'columnNumber': 0,
'condition': ''
}, (error, result) => {
return error ? reject(error) : resolve(result);
});
});
debugged();
assert(session2Paused);
session2.disconnect();
}
const interval = setInterval(() => {}, 1000);
test().then(common.mustCall(() => {
clearInterval(interval);
console.log('Done!');
}));