OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2017 the V8 project authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 print('Checks basic ES6 modules support.'); | |
dgozman
2017/01/30 19:42:09
Let's rename the file to es6-modules.js.
kozy
2017/01/30 21:23:33
Done.
| |
6 | |
7 var module1 = ` | |
8 export function foo() { | |
9 console.log('module1'); | |
10 return 42; | |
11 } | |
12 export let a1 = 1`; | |
13 | |
14 var module2 = ` | |
15 export function foo() { | |
16 console.log('module2'); | |
17 return 239; | |
18 } | |
19 export let a2 = 2`; | |
20 | |
21 var module3 = ` | |
22 import { foo as foo1 } from 'module1'; | |
23 import { foo as foo2 } from 'module2'; | |
24 console.log(foo1()); | |
25 console.log(foo2()); | |
26 import { a1 } from 'module1'; | |
27 import { a2 } from 'module2'; | |
28 debugger; | |
29 `; | |
30 | |
31 var module4 = '}'; | |
32 | |
33 InspectorTest.setupScriptMap(); | |
34 // We get scriptParsed events for modules .. | |
35 Protocol.Debugger.onScriptParsed(message => { | |
36 if (message.params.url === 'wait-pending-tasks.js') return; | |
37 InspectorTest.logMessage(message); | |
38 }); | |
39 // .. scriptFailed to parse for modules with syntax error .. | |
40 Protocol.Debugger.onScriptFailedToParse(InspectorTest.logMessage); | |
41 // .. API messages from modules contain correct stack trace .. | |
42 Protocol.Runtime.onConsoleAPICalled(message => { | |
43 InspectorTest.log(`console.log(${message.params.args[0].value})`); | |
44 InspectorTest.logCallFrames(message.params.stackTrace.callFrames); | |
45 InspectorTest.log(''); | |
46 }); | |
47 // .. we could break inside module and scope contains correct list of variables .. | |
48 Protocol.Debugger.onPaused(message => { | |
49 InspectorTest.logMessage(message); | |
50 Protocol.Runtime.getProperties({ objectId: message.params.callFrames[0].scopeC hain[0].object.objectId}) | |
51 .then(InspectorTest.logMessage) | |
52 .then(() => Protocol.Debugger.resume()); | |
53 }); | |
54 // .. we process uncaught errors from modules correctly. | |
55 Protocol.Runtime.onExceptionThrown(InspectorTest.logMessage); | |
56 | |
57 Protocol.Runtime.enable(); | |
58 Protocol.Debugger.enable() | |
59 .then(() => InspectorTest.addModule(module1, "module1")) | |
60 .then(() => InspectorTest.addModule(module2, "module2")) | |
61 .then(() => InspectorTest.addModule(module3, "module3")) | |
62 .then(() => InspectorTest.addModule(module4, "module4")) | |
63 .then(() => InspectorTest.waitPendingTasks()) | |
64 .then(InspectorTest.completeTest); | |
OLD | NEW |