2017-01-31 00:19:41 +00:00
|
|
|
// 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.
|
|
|
|
|
2017-05-19 00:35:45 +00:00
|
|
|
let {session, contextGroup, Protocol} = InspectorTest.start('Checks basic ES6 modules support.');
|
2017-01-31 00:19:41 +00:00
|
|
|
|
|
|
|
var module1 = `
|
|
|
|
export function foo() {
|
|
|
|
console.log('module1');
|
|
|
|
return 42;
|
|
|
|
}
|
|
|
|
export let a1 = 1`;
|
|
|
|
|
|
|
|
var module2 = `
|
|
|
|
export function foo() {
|
|
|
|
console.log('module2');
|
|
|
|
return 239;
|
|
|
|
}
|
|
|
|
export let a2 = 2`;
|
|
|
|
|
|
|
|
var module3 = `
|
|
|
|
import { foo as foo1 } from 'module1';
|
|
|
|
import { foo as foo2 } from 'module2';
|
|
|
|
console.log(foo1());
|
|
|
|
console.log(foo2());
|
|
|
|
import { a1 } from 'module1';
|
|
|
|
import { a2 } from 'module2';
|
|
|
|
debugger;
|
|
|
|
`;
|
|
|
|
|
|
|
|
var module4 = '}';
|
|
|
|
|
2017-05-19 00:35:45 +00:00
|
|
|
session.setupScriptMap();
|
2017-01-31 00:19:41 +00:00
|
|
|
// We get scriptParsed events for modules ..
|
2017-02-03 07:17:09 +00:00
|
|
|
Protocol.Debugger.onScriptParsed(InspectorTest.logMessage);
|
2017-01-31 00:19:41 +00:00
|
|
|
// .. scriptFailed to parse for modules with syntax error ..
|
|
|
|
Protocol.Debugger.onScriptFailedToParse(InspectorTest.logMessage);
|
|
|
|
// .. API messages from modules contain correct stack trace ..
|
|
|
|
Protocol.Runtime.onConsoleAPICalled(message => {
|
|
|
|
InspectorTest.log(`console.log(${message.params.args[0].value})`);
|
2017-05-19 00:35:45 +00:00
|
|
|
session.logCallFrames(message.params.stackTrace.callFrames);
|
2017-01-31 00:19:41 +00:00
|
|
|
InspectorTest.log('');
|
|
|
|
});
|
|
|
|
// .. we could break inside module and scope contains correct list of variables ..
|
|
|
|
Protocol.Debugger.onPaused(message => {
|
|
|
|
InspectorTest.logMessage(message);
|
|
|
|
Protocol.Runtime.getProperties({ objectId: message.params.callFrames[0].scopeChain[0].object.objectId})
|
|
|
|
.then(InspectorTest.logMessage)
|
|
|
|
.then(() => Protocol.Debugger.resume());
|
|
|
|
});
|
|
|
|
// .. we process uncaught errors from modules correctly.
|
|
|
|
Protocol.Runtime.onExceptionThrown(InspectorTest.logMessage);
|
|
|
|
|
|
|
|
Protocol.Runtime.enable();
|
|
|
|
Protocol.Debugger.enable()
|
2017-05-19 00:35:45 +00:00
|
|
|
.then(() => contextGroup.addModule(module1, "module1"))
|
|
|
|
.then(() => contextGroup.addModule(module2, "module2"))
|
|
|
|
.then(() => contextGroup.addModule(module3, "module3"))
|
|
|
|
.then(() => contextGroup.addModule(module4, "module4"))
|
|
|
|
.then(() => InspectorTest.waitForPendingTasks())
|
2017-01-31 00:19:41 +00:00
|
|
|
.then(InspectorTest.completeTest);
|