forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add
Debugger.setInstrumentationBreakpoint
known issue
PR-URL: nodejs#31137 Refs: nodejs#31138 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
- Loading branch information
Showing
4 changed files
with
58 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log('dep loaded'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require('./dep'); |
54 changes: 54 additions & 0 deletions
54
test/known_issues/test-inspector-instrumentation-breakpoint.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// This test validates inspector's Debugger.setInstrumentationBreakpoint method. | ||
// Refs: https://github.com/nodejs/node/issues/31138 | ||
|
||
'use strict'; | ||
const common = require('../common'); | ||
|
||
common.skipIfInspectorDisabled(); | ||
|
||
const assert = require('assert'); | ||
const { resolve: UrlResolve } = require('url'); | ||
const fixtures = require('../common/fixtures'); | ||
const { NodeInstance } = require('../common/inspector-helper.js'); | ||
|
||
async function testBreakpointBeforeScriptExecution(session) { | ||
console.log('[test]', | ||
'Verifying debugger stops on start of each script ' + | ||
'(Debugger.setInstrumentationBreakpoint with beforeScriptExecution)'); | ||
const commands = [ | ||
{ 'method': 'Runtime.enable' }, | ||
{ 'method': 'Debugger.enable' }, | ||
{ 'method': 'Debugger.setInstrumentationBreakpoint', | ||
'params': { 'instrumentation': 'beforeScriptExecution' } }, | ||
{ 'method': 'Runtime.runIfWaitingForDebugger' }, | ||
]; | ||
|
||
await session.send(commands); | ||
|
||
// Break on start | ||
await session.waitForBreakOnLine( | ||
0, UrlResolve(session.scriptURL().toString(), 'main.js')); | ||
await session.send([{ 'method': 'Debugger.resume' }]); | ||
|
||
// Script loaded | ||
await session.waitForBreakOnLine( | ||
0, UrlResolve(session.scriptURL().toString(), 'main.js')); | ||
await session.send([{ 'method': 'Debugger.resume' }]); | ||
|
||
// Script loaded | ||
await session.waitForBreakOnLine( | ||
0, UrlResolve(session.scriptURL().toString(), 'dep.js')); | ||
await session.send([{ 'method': 'Debugger.resume' }]); | ||
} | ||
|
||
async function runTest() { | ||
const main = fixtures.path('inspector-instrumentation-breakpoint', 'main.js'); | ||
const child = new NodeInstance(['--inspect-brk=0'], '', main); | ||
|
||
const session = await child.connectInspectorSession(); | ||
await testBreakpointBeforeScriptExecution(session); | ||
await session.runToCompletion(); | ||
assert.strictEqual((await child.expectShutdown()).exitCode, 0); | ||
} | ||
|
||
runTest(); |