-
Notifications
You must be signed in to change notification settings - Fork 30.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
inspector: add promisified result for session.post
- Loading branch information
1 parent
472edc7
commit b1947d2
Showing
3 changed files
with
88 additions
and
3 deletions.
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
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,61 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
common.skipIfInspectorDisabled(); | ||
|
||
const assert = require('assert'); | ||
const { | ||
Session | ||
} = require('inspector'); | ||
const { | ||
basename | ||
} = require('path'); | ||
const currentFilename = basename(__filename); | ||
|
||
{ | ||
// Ensure that given a callback to session.post it won't return a promise result | ||
const session = new Session(); | ||
session.connect(); | ||
|
||
const postResult = session.post('Profiler.enable', () => { | ||
session.post('Profiler.start', () => { | ||
session.post('Profiler.stop', (err, { profile }) => { | ||
|
||
const { callFrame: { url } } = profile.nodes.find(({ | ||
callFrame | ||
}) => callFrame.url.includes(currentFilename)); | ||
session.disconnect(); | ||
assert.deepStrictEqual(basename(url), currentFilename); | ||
}); | ||
}); | ||
}); | ||
|
||
assert.strictEqual(postResult, undefined); | ||
} | ||
|
||
(async () => { | ||
{ | ||
// Ensure that session.post returns a valid promisified result | ||
const session = new Session(); | ||
session.connect(); | ||
|
||
await session.post('Profiler.enable'); | ||
await session.post('Profiler.start'); | ||
|
||
const { | ||
profile | ||
} = await session.post('Profiler.stop'); | ||
|
||
const { | ||
callFrame: { | ||
url | ||
} | ||
} = profile.nodes.find(({ | ||
callFrame | ||
}) => { | ||
return callFrame.url.includes(currentFilename); | ||
}); | ||
session.disconnect(); | ||
assert.deepStrictEqual(basename(url), currentFilename); | ||
} | ||
})().then(common.mustCall()); |