2018-02-27 18:17:06 +00:00
|
|
|
// 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.");
|
|
|
|
|
2018-03-26 08:35:25 +00:00
|
|
|
session.setupScriptMap();
|
|
|
|
contextGroup.addScript(`
|
|
|
|
function f() {
|
|
|
|
return 2;
|
|
|
|
} //# sourceURL=test.js`);
|
2018-02-27 18:17:06 +00:00
|
|
|
Protocol.Runtime.enable();
|
|
|
|
Protocol.Debugger.enable();
|
2018-03-26 08:35:25 +00:00
|
|
|
|
|
|
|
Protocol.Debugger.onPaused(message => {
|
|
|
|
InspectorTest.log("paused");
|
|
|
|
Protocol.Debugger.resume();
|
|
|
|
});
|
|
|
|
|
2018-02-27 18:17:06 +00:00
|
|
|
(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
|
|
|
|
}));
|
|
|
|
|
2018-03-26 08:35:25 +00:00
|
|
|
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
|
|
|
|
}));
|
|
|
|
|
2018-02-27 18:17:06 +00:00
|
|
|
InspectorTest.completeTest();
|
|
|
|
})();
|