Commit 0cec56a4 authored by Alexey Kozyatinskiy's avatar Alexey Kozyatinskiy Committed by Commit Bot

inspector: allow es6 module liveedit

After total liveedit rewrite, liveedit works with module, we can remove
the guard.

R=dgozman@chromium.org

Bug: chromium:806261
Cq-Include-Trybots: luci.chromium.try:linux_chromium_headless_rel;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: Ide15eca2ab6d8ba7df4e7fae541c4a65794eeea8
Reviewed-on: https://chromium-review.googlesource.com/1238914Reviewed-by: 's avatarDmitry Gozman <dgozman@chromium.org>
Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56151}
parent 1e6d9607
......@@ -858,10 +858,6 @@ Response V8DebuggerAgentImpl::setScriptSource(
if (it == m_scripts.end()) {
return Response::Error("No script with given id found");
}
if (it->second->isModule()) {
// TODO(kozyatinskiy): LiveEdit should support ES6 module
return Response::Error("Editing module's script is not supported.");
}
int contextId = it->second->executionContextId();
InspectedContext* inspected = m_inspector->getContext(contextId);
if (!inspected) {
......
......@@ -160,7 +160,6 @@ class ActualScript : public V8DebuggerScript {
void setSource(const String16& newSource, bool preview,
v8::debug::LiveEditResult* result) override {
DCHECK(!isModule());
v8::EscapableHandleScope scope(m_isolate);
v8::Local<v8::String> v8Source = toV8String(m_isolate, newSource);
if (!m_script.Get(m_isolate)->SetScriptSource(v8Source, preview, result)) {
......
Checks liveedit with ES6 modules.
console.log message from function before patching:
{
type : string
value : module1
}
Debugger.setScriptSource result:
{
callFrames : [
]
stackChanged : false
}
console.log message from function after patching:
{
type : string
value : patched module1
}
// 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.
const {session, contextGroup, Protocol} =
InspectorTest.start('Checks liveedit with ES6 modules.');
const moduleSource = `
export function foo() {
console.log('module1');
return 42;
}
foo()`;
const newModuleSource = `
export function foo() {
console.log('patched module1');
return 42;
}
foo()`;
const callFooSource = `
import { foo } from 'module';
foo();`;
(async function test() {
await Protocol.Runtime.enable();
await Protocol.Debugger.enable();
contextGroup.addModule(moduleSource, 'module');
const [{ params: { scriptId } }, { params: { args }}] = [
await Protocol.Debugger.onceScriptParsed(),
await Protocol.Runtime.onceConsoleAPICalled()
];
InspectorTest.log('console.log message from function before patching:')
InspectorTest.logMessage(args[0]);
const {result} = await Protocol.Debugger.setScriptSource({
scriptId,
scriptSource: newModuleSource
});
InspectorTest.log('Debugger.setScriptSource result:');
InspectorTest.logMessage(result);
contextGroup.addModule(callFooSource, 'callFoo');
const { params: {args: patchedArgs } } =
await Protocol.Runtime.onceConsoleAPICalled();
InspectorTest.log('console.log message from function after patching:')
InspectorTest.logMessage(patchedArgs[0]);
InspectorTest.completeTest();
})()
Checks that Debugger.setScriptSource doesn't crash with modules
{
error : {
code : -32000
message : Editing module's script is not supported.
}
id : <messageId>
}
// 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('Checks that Debugger.setScriptSource doesn\'t crash with modules');
var module1 = `
export function foo() {
return 42;
}`;
var editedModule1 = `
export function foo() {
return 239;
}`;
var module2 = `
import { foo } from 'module1';
console.log(foo());
`;
var module1Id;
Protocol.Debugger.onScriptParsed(message => {
if (message.params.url === 'module1')
module1Id = message.params.scriptId;
});
Protocol.Debugger.enable()
.then(() => contextGroup.addModule(module1, 'module1'))
.then(() => contextGroup.addModule(module2, 'module2'))
.then(() => InspectorTest.waitForPendingTasks())
.then(() => Protocol.Debugger.setScriptSource({ scriptId: module1Id, scriptSource: editedModule1 }))
.then(InspectorTest.logMessage)
.then(InspectorTest.completeTest);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment