Skip to content

Commit 57b5a18

Browse files
RReversertargos
authored andcommitted
test: fix scriptParsed event expectations
As per Node.js docs, vm.Script instance is not bound to any context. However, this test was expecting otherwise and depended on implementation details which are going to change. Refs: https://chromium-review.googlesource.com/c/v8/v8/+/1013581
1 parent 34d425f commit 57b5a18

File tree

1 file changed

+7
-27
lines changed

1 file changed

+7
-27
lines changed

test/sequential/test-inspector-scriptparsed-context.js

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,17 @@ const script = `
1010
'use strict';
1111
const assert = require('assert');
1212
const vm = require('vm');
13-
const { kParsingContext } = process.binding('contextify');
1413
global.outer = true;
1514
global.inner = false;
1615
const context = vm.createContext({
1716
outer: false,
1817
inner: true
1918
});
19+
const script = new vm.Script("outer");
2020
debugger;
2121
22-
const scriptMain = new vm.Script("outer");
23-
debugger;
24-
25-
const scriptContext = new vm.Script("inner", {
26-
[kParsingContext]: context
27-
});
28-
debugger;
29-
30-
assert.strictEqual(scriptMain.runInThisContext(), true);
31-
assert.strictEqual(scriptMain.runInContext(context), false);
32-
assert.strictEqual(scriptContext.runInThisContext(), false);
33-
assert.strictEqual(scriptContext.runInContext(context), true);
22+
assert.strictEqual(script.runInThisContext(), true);
23+
assert.strictEqual(script.runInContext(context), false);
3424
debugger;
3525
3626
vm.runInContext('inner', context);
@@ -65,35 +55,25 @@ async function runTests() {
6555
await session.waitForBreakOnLine(0, '[eval]');
6656

6757
await session.send({ 'method': 'Runtime.enable' });
68-
const topContext = await getContext(session);
58+
await getContext(session);
6959
await session.send({ 'method': 'Debugger.resume' });
7060
const childContext = await getContext(session);
7161
await session.waitForBreakOnLine(13, '[eval]');
7262

73-
console.error('[test]', 'Script associated with current context by default');
74-
await session.send({ 'method': 'Debugger.resume' });
75-
await checkScriptContext(session, topContext);
76-
await session.waitForBreakOnLine(16, '[eval]');
77-
78-
console.error('[test]', 'Script associated with selected context');
79-
await session.send({ 'method': 'Debugger.resume' });
80-
await checkScriptContext(session, childContext);
81-
await session.waitForBreakOnLine(21, '[eval]');
82-
8363
console.error('[test]', 'Script is unbound');
8464
await session.send({ 'method': 'Debugger.resume' });
85-
await session.waitForBreakOnLine(27, '[eval]');
65+
await session.waitForBreakOnLine(17, '[eval]');
8666

8767
console.error('[test]', 'vm.runInContext associates script with context');
8868
await session.send({ 'method': 'Debugger.resume' });
8969
await checkScriptContext(session, childContext);
90-
await session.waitForBreakOnLine(30, '[eval]');
70+
await session.waitForBreakOnLine(20, '[eval]');
9171

9272
console.error('[test]', 'vm.runInNewContext associates script with context');
9373
await session.send({ 'method': 'Debugger.resume' });
9474
const thirdContext = await getContext(session);
9575
await checkScriptContext(session, thirdContext);
96-
await session.waitForBreakOnLine(33, '[eval]');
76+
await session.waitForBreakOnLine(23, '[eval]');
9777

9878
console.error('[test]', 'vm.runInNewContext can contain debugger statements');
9979
await session.send({ 'method': 'Debugger.resume' });

0 commit comments

Comments
 (0)