()
| 57 | } |
| 58 | |
| 59 | function testSampleDebugSession() { |
| 60 | let cur = 0; |
| 61 | const failures = []; |
| 62 | const expects = { |
| 63 | i: [0, 1, 2, 3, 4], |
| 64 | accum: [0, 0, 1, 3, 6] |
| 65 | }; |
| 66 | scopeCallback = function(error, result) { |
| 67 | const i = cur++; |
| 68 | let v, actual, expected; |
| 69 | for (v of result.result) { |
| 70 | actual = v.value.value; |
| 71 | expected = expects[v.name][i]; |
| 72 | if (actual !== expected) { |
| 73 | failures.push(`Iteration ${i} variable: ${v.name} ` + |
| 74 | `expected: ${expected} actual: ${actual}`); |
| 75 | } |
| 76 | } |
| 77 | }; |
| 78 | const session = new inspector.Session(); |
| 79 | session.connect(); |
| 80 | session.on('Debugger.paused', |
| 81 | (notification) => debuggerPausedCallback(session, notification)); |
| 82 | let cbAsSecondArgCalled = false; |
| 83 | assert.throws(() => { |
| 84 | session.post('Debugger.enable', function() {}, function() {}); |
| 85 | }, TypeError); |
| 86 | session.post('Debugger.enable', () => cbAsSecondArgCalled = true); |
| 87 | session.post('Debugger.setBreakpointByUrl', { |
| 88 | 'lineNumber': 13, |
| 89 | 'url': pathToFileURL(path.resolve(__dirname, __filename)).toString(), |
| 90 | 'columnNumber': 0, |
| 91 | 'condition': '' |
| 92 | }); |
| 93 | |
| 94 | debuggedFunction(); |
| 95 | assert.strictEqual(cbAsSecondArgCalled, true); |
| 96 | assert.deepStrictEqual(failures, []); |
| 97 | assert.strictEqual(cur, 5); |
| 98 | scopeCallback = null; |
| 99 | session.disconnect(); |
| 100 | assert.throws(() => session.post('Debugger.enable'), (e) => !!e); |
| 101 | } |
| 102 | |
| 103 | async function testNoCrashConsoleLogBeforeThrow() { |
| 104 | const session = new inspector.Session(); |
no test coverage detected
searching dependent graphs…