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