v8/test/inspector/runtime/evaluate-without-side-effects.js
Yang Guo cc9736a1c0 [debug] disable debug breaks in side-effect free debug-evaluate.
We don't want to run into the situation of breaking inside of
debug-evaluate. That would get even more confusing with throw-on-side-effect.

R=kozyatinskiy@chromium.org

Bug: v8:7592
Change-Id: I93f5de63d8943792ff000dbf7c6311df655d3793
Reviewed-on: https://chromium-review.googlesource.com/978164
Reviewed-by: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Commit-Queue: Yang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52227}
2018-03-26 16:27:32 +00:00

54 lines
1.7 KiB
JavaScript

// Copyright 2018 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 Runtime.evaluate can run without side effects.");
session.setupScriptMap();
contextGroup.addScript(`
function f() {
return 2;
} //# sourceURL=test.js`);
Protocol.Runtime.enable();
Protocol.Debugger.enable();
Protocol.Debugger.onPaused(message => {
InspectorTest.log("paused");
Protocol.Debugger.resume();
});
(async function() {
InspectorTest.log("Test throwOnSideEffect: false");
InspectorTest.logMessage(await Protocol.Runtime.evaluate({
expression: "var x = 2; x;",
throwOnSideEffect: false
}));
InspectorTest.log("Test expression with side-effect, with throwOnSideEffect: true");
InspectorTest.logMessage(await Protocol.Runtime.evaluate({
expression: "x = 3; x;",
throwOnSideEffect: true
}));
InspectorTest.log("Test expression without side-effect, with throwOnSideEffect: true");
InspectorTest.logMessage(await Protocol.Runtime.evaluate({
expression: "x * 2",
throwOnSideEffect: true
}));
InspectorTest.log("Test that debug break triggers without throwOnSideEffect");
await Protocol.Debugger.setBreakpointByUrl({ url: 'test.js', lineNumber: 2 });
InspectorTest.logMessage(await Protocol.Runtime.evaluate({
expression: "f()",
throwOnSideEffect: false
}));
InspectorTest.log("Test that debug break does not trigger with throwOnSideEffect");
InspectorTest.logMessage(await Protocol.Runtime.evaluate({
expression: "f()",
throwOnSideEffect: true
}));
InspectorTest.completeTest();
})();