[inspector] test to check that we don't hold resolved promises

Bug: v8:6197
Change-Id: I7b9e6d0979630dfd1ce5ee7f23f715cdb2f51802
R: dgozman@chromium.org
Reviewed-on: https://chromium-review.googlesource.com/524045
Reviewed-by: Dmitry Gozman <dgozman@chromium.org>
Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#45746}
This commit is contained in:
Alexey Kozyatinskiy 2017-06-05 16:04:52 +01:00 committed by Commit Bot
parent 11fc9fab94
commit 468fc74230
2 changed files with 38 additions and 0 deletions

View File

@ -0,0 +1,2 @@
Tests that we don't hold promises.
SUCCESS

View File

@ -0,0 +1,36 @@
// Copyright 2017 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.
let {session, contextGroup, Protocol} =
InspectorTest.start('Tests that we don\'t hold promises.');
(async function test() {
Protocol.Runtime.enable();
Protocol.Debugger.enable();
Protocol.Debugger.setAsyncCallStackDepth({maxDepth: 128});
Protocol.HeapProfiler.enable();
// Force inspector internal scripts compilation.
await Protocol.Runtime.evaluate({expression: ''});
let snapshot = '';
Protocol.HeapProfiler.onAddHeapSnapshotChunk(msg => snapshot += msg.params.chunk);
await Protocol.HeapProfiler.collectGarbage();
await Protocol.HeapProfiler.takeHeapSnapshot();
let initial_node_count = JSON.parse(snapshot).snapshot.node_count;
await Protocol.Runtime.evaluate({
expression: `for (let i = 0; i < ${initial_node_count / 4}; ++i) Promise.resolve()`});
snapshot = '';
Protocol.HeapProfiler.onAddHeapSnapshotChunk(msg => snapshot += msg.params.chunk);
await Protocol.HeapProfiler.collectGarbage();
await Protocol.HeapProfiler.takeHeapSnapshot();
let without_storing_node_count = JSON.parse(snapshot).snapshot.node_count;
let diff_without_storing = (without_storing_node_count - initial_node_count);
if (diff_without_storing < initial_node_count / 4) {
InspectorTest.log('SUCCESS');
} else {
InspectorTest.log('FAILED: looks like all promises were not collected.');
}
InspectorTest.completeTest();
})();