-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
Expand file tree
/
Copy pathtest-inspector.js
More file actions
51 lines (40 loc) · 1.58 KB
/
test-inspector.js
File metadata and controls
51 lines (40 loc) · 1.58 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
'use strict';
const common = require('../../common');
common.skipIfInspectorDisabled();
const assert = require('node:assert');
const { once } = require('node:events');
const { Session } = require('node:inspector');
const binding = require(`./build/${common.buildType}/binding`);
const session = new Session();
session.connect();
(async function() {
const mainContextPromise =
once(session, 'Runtime.executionContextCreated');
session.post('Runtime.enable', assert.ifError);
await mainContextPromise;
// Addon-created context should be reported to the inspector.
{
const addonContextPromise =
once(session, 'Runtime.executionContextCreated');
const ctx = binding.makeContext();
const result = binding.runInContext(ctx, '1 + 1');
assert.strictEqual(result, 2);
const { 0: contextCreated } = await addonContextPromise;
const { name, origin, auxData } = contextCreated.params.context;
assert.strictEqual(name, 'Addon Context',
JSON.stringify(contextCreated));
assert.strictEqual(origin, 'addon://about',
JSON.stringify(contextCreated));
assert.strictEqual(auxData.isDefault, false,
JSON.stringify(contextCreated));
}
// `debugger` statement should pause in addon-created context.
{
session.post('Debugger.enable', assert.ifError);
const pausedPromise = once(session, 'Debugger.paused');
const ctx = binding.makeContext();
binding.runInContext(ctx, 'debugger');
await pausedPromise;
session.post('Debugger.resume');
}
})().then(common.mustCall());