OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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 var executionContextId; | 5 var executionContextId; |
6 | 6 |
7 InspectorTest.sendCommand("Debugger.enable", {}, onDebuggerEnabled); | 7 Protocol.Debugger.enable().then(onDebuggerEnabled); |
8 | 8 |
9 function onDebuggerEnabled() | 9 function onDebuggerEnabled() |
10 { | 10 { |
11 InspectorTest.sendCommand("Runtime.enable", {}); | 11 Protocol.Runtime.enable(); |
12 InspectorTest.eventHandler["Debugger.scriptParsed"] = onScriptParsed; | 12 Protocol.Debugger.onScriptParsed(onScriptParsed); |
13 InspectorTest.eventHandler["Runtime.executionContextCreated"] = onExecutionCon
textCreated; | 13 Protocol.Runtime.onExecutionContextCreated(onExecutionContextCreated); |
14 } | 14 } |
15 | 15 |
16 function onScriptParsed(messageObject) | 16 function onScriptParsed(messageObject) |
17 { | 17 { |
18 if (!messageObject.params.url) | 18 if (!messageObject.params.url) |
19 return; | 19 return; |
20 InspectorTest.log("Debugger.scriptParsed: " + messageObject.params.url); | 20 InspectorTest.log("Debugger.scriptParsed: " + messageObject.params.url); |
21 } | 21 } |
22 | 22 |
23 function onExecutionContextCreated(messageObject) | 23 function onExecutionContextCreated(messageObject) |
24 { | 24 { |
25 executionContextId = messageObject.params.context.id; | 25 executionContextId = messageObject.params.context.id; |
26 testCompileScript("\n (", false, "foo1.js") | 26 testCompileScript("\n (", false, "foo1.js") |
27 .then(() => testCompileScript("239", true, "foo2.js")) | 27 .then(() => testCompileScript("239", true, "foo2.js")) |
28 .then(() => testCompileScript("239", false, "foo3.js")) | 28 .then(() => testCompileScript("239", false, "foo3.js")) |
29 .then(() => testCompileScript("testfunction f()\n{\n return 0;\n}\n", fal
se, "foo4.js")) | 29 .then(() => testCompileScript("testfunction f()\n{\n return 0;\n}\n", fal
se, "foo4.js")) |
30 .then(() => InspectorTest.completeTest()); | 30 .then(() => InspectorTest.completeTest()); |
31 } | 31 } |
32 | 32 |
33 function testCompileScript(expression, persistScript, sourceURL) | 33 function testCompileScript(expression, persistScript, sourceURL) |
34 { | 34 { |
35 InspectorTest.log("Compiling script: " + sourceURL); | 35 InspectorTest.log("Compiling script: " + sourceURL); |
36 InspectorTest.log(" persist: " + persistScript); | 36 InspectorTest.log(" persist: " + persistScript); |
37 var callback; | 37 return Protocol.Runtime.compileScript({ |
38 var promise = new Promise(resolver => callback = resolver); | |
39 InspectorTest.sendCommand("Runtime.compileScript", { | |
40 expression: expression, | 38 expression: expression, |
41 sourceURL: sourceURL, | 39 sourceURL: sourceURL, |
42 persistScript: persistScript, | 40 persistScript: persistScript, |
43 executionContextId: executionContextId | 41 executionContextId: executionContextId |
44 }, onCompiled); | 42 }).then(onCompiled); |
45 return promise; | |
46 | 43 |
47 function onCompiled(messageObject) | 44 function onCompiled(messageObject) |
48 { | 45 { |
49 var result = messageObject.result; | 46 InspectorTest.log("compilation result: "); |
50 if (result.exceptionDetails) { | 47 InspectorTest.logMessage(messageObject); |
51 result.exceptionDetails.exceptionId = 0; | |
52 result.exceptionDetails.exception.objectId = 0; | |
53 result.exceptionDetails.scriptId = 0; | |
54 } | |
55 if (result.scriptId) | |
56 result.scriptId = 0; | |
57 InspectorTest.logObject(result, "compilation result: "); | |
58 InspectorTest.log("-----"); | 48 InspectorTest.log("-----"); |
59 callback(); | |
60 } | 49 } |
61 } | 50 } |
OLD | NEW |