Skip to content

Commit 3175391

Browse files
RReverserMylesBorins
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 Backport-PR-URL: #21668 PR-URL: #21079 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Yang Guo <[email protected]>
1 parent 48ab7dc commit 3175391

File tree

1 file changed

+7
-27
lines changed

1 file changed

+7
-27
lines changed

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

+7-27
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,17 @@ const script = `
99
'use strict';
1010
const assert = require('assert');
1111
const vm = require('vm');
12-
const { kParsingContext } = process.binding('contextify');
1312
global.outer = true;
1413
global.inner = false;
1514
const context = vm.createContext({
1615
outer: false,
1716
inner: true
1817
});
18+
const script = new vm.Script("outer");
1919
debugger;
2020
21-
const scriptMain = new vm.Script("outer");
22-
debugger;
23-
24-
const scriptContext = new vm.Script("inner", {
25-
[kParsingContext]: context
26-
});
27-
debugger;
28-
29-
assert.strictEqual(scriptMain.runInThisContext(), true);
30-
assert.strictEqual(scriptMain.runInContext(context), false);
31-
assert.strictEqual(scriptContext.runInThisContext(), false);
32-
assert.strictEqual(scriptContext.runInContext(context), true);
21+
assert.strictEqual(script.runInThisContext(), true);
22+
assert.strictEqual(script.runInContext(context), false);
3323
debugger;
3424
3525
vm.runInContext('inner', context);
@@ -64,35 +54,25 @@ async function runTests() {
6454
await session.waitForBreakOnLine(0, '[eval]');
6555

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

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

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

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

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

0 commit comments

Comments
 (0)