v8/test/inspector/debugger/set-script-source.js
Alexey Kozyatinskiy 5e57f660ae [inspector] prepare inspector tests for liveedit rework
Extracted from https://chromium-review.googlesource.com/c/v8/v8/+/1105493

R=dgozman@chromium.org

Bug: v8:7862
Cq-Include-Trybots: luci.chromium.try:linux_chromium_headless_rel;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: Ibd2fb5341e617929b07b26abea31a1579a456d93
Reviewed-on: https://chromium-review.googlesource.com/1107312
Reviewed-by: Dmitry Gozman <dgozman@chromium.org>
Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53899}
2018-06-20 21:40:46 +00:00

43 lines
1.7 KiB
JavaScript

// Copyright 2016 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.
const {session, contextGroup, Protocol} =
InspectorTest.start('Tests Debugger.setScriptSource');
contextGroup.addScript(
`function TestExpression(a, b) {
return a + b;
}`);
(async function test() {
Protocol.Debugger.enable();
const {params: {scriptId}} = await Protocol.Debugger.onceScriptParsed();
const {result: {result: {value}}} =
await Protocol.Runtime.evaluate({expression: 'TestExpression(2, 4)'});
InspectorTest.log(`TestExpression(2,4) === ${value}`);
{
const {result: {scriptSource}} =
await Protocol.Debugger.getScriptSource({scriptId});
InspectorTest.log(`Update current script source 'a + b' -> 'a * b'..`);
const {result} = await Protocol.Debugger.setScriptSource(
{scriptId, scriptSource: scriptSource.replace('a + b', 'a * b')})
InspectorTest.logMessage(result);
const {result: {result: {value}}} =
await Protocol.Runtime.evaluate({expression: 'TestExpression(2, 4)'});
InspectorTest.log(`TestExpression(2,4) === ${value}`);
}
{
const {result: {scriptSource}} =
await Protocol.Debugger.getScriptSource({scriptId});
InspectorTest.log(`Update current script source 'a * b' -> 'a # b'..`);
const {result} = await Protocol.Debugger.setScriptSource(
{scriptId, scriptSource: scriptSource.replace('a * b', 'a # b')})
InspectorTest.logMessage(result);
const {result: {result: {value}}} =
await Protocol.Runtime.evaluate({expression: 'TestExpression(2, 4)'});
InspectorTest.log(`TestExpression(2,4) === ${value}`);
}
InspectorTest.completeTest();
})();