node/deps/v8/test/inspector/debugger/debugger-restore.js
Michaël Zasso 09a8440b45
deps: update V8 to 12.2.281.27
PR-URL: https://github.com/nodejs/node/pull/51362
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
2024-03-31 15:36:07 +02:00

44 lines
1.4 KiB
JavaScript

// Copyright 2023 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --no-stress-incremental-marking
const {session, contextGroup, Protocol} = InspectorTest.start('Checks that Debugger agent correctly restore its state.');
const line = '// ' + '-'.repeat(512);
const script = `
${line}
${line}
console.log('Hello from script');
`;
function reconnect() {
InspectorTest.log('will reconnect...');
session.reconnect();
}
InspectorTest.runAsyncTestSuite([
async function testMaxScriptsCacheSize() {
InspectorTest.log('Enable debugger agent with script cache of 4k');
await Protocol.Debugger.enable({ maxScriptsCacheSize: 4096 }); // 'script' fits into cache.
reconnect();
InspectorTest.log('Evaluate large script');
contextGroup.addScript(script);
const { params: { scriptId } } = await Protocol.Debugger.onceScriptParsed();
InspectorTest.log('Trigger GC');
await Protocol.HeapProfiler.collectGarbage();
InspectorTest.log('Request script content...');
const result = await Protocol.Debugger.getScriptSource({ scriptId });
if (result.error) {
InspectorTest.log('Failed to retrieve script content');
return;
}
InspectorTest.log(`Received script content of length: ${result.result.scriptSource.length}`);
},
]);