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 InspectorTest.log("Checks that inspector correctly process compiled scripts"); | 5 InspectorTest.log("Checks that inspector correctly process compiled scripts"); |
6 | 6 |
7 function addScripts() { | 7 function addScripts() { |
8 // sourceURL in the same line | 8 // sourceURL in the same line |
9 return addScript("function foo1(){}//# sourceURL=oneline.js\n") | 9 return addScript("function foo1(){}//# sourceURL=oneline.js\n") |
10 // sourceURL without end line | 10 // sourceURL without end line |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 function addScript(source) { | 58 function addScript(source) { |
59 return Protocol.Runtime.evaluate({ expression: source }); | 59 return Protocol.Runtime.evaluate({ expression: source }); |
60 } | 60 } |
61 | 61 |
62 function requestSourceAndDump(scriptParsedMessage, scriptParsed) { | 62 function requestSourceAndDump(scriptParsedMessage, scriptParsed) { |
63 Protocol.Debugger.getScriptSource({ scriptId: scriptParsedMessage.params.scrip
tId }) | 63 Protocol.Debugger.getScriptSource({ scriptId: scriptParsedMessage.params.scrip
tId }) |
64 .then((sourceMessage) => dumpScriptParsed(scriptParsedMessage, sourceMessage
, scriptParsed)); | 64 .then((sourceMessage) => dumpScriptParsed(scriptParsedMessage, sourceMessage
, scriptParsed)); |
65 } | 65 } |
66 | 66 |
67 function dumpScriptParsed(scriptParsedMessage, sourceMessage, scriptParsed) { | 67 function dumpScriptParsed(scriptParsedMessage, sourceMessage, scriptParsed) { |
68 var params = scriptParsedMessage.params; | |
69 var re = /[A-Z0-9]{40,40}/; | |
70 if (!params.hash || !matchExact(re, params.hash)) | |
71 params.hash = "Invalid hash: " + params.hash; | |
72 else | |
73 params.hash = "<hash>"; | |
74 if (params.executionContextId <= 0) | |
75 params.executionContextId = "Invalid executionContextId: " + params.executio
nContextId; | |
76 else | |
77 params.executionContextId = "<executionContextId>"; | |
78 if (params.scriptId * 1 <= 0) | |
79 params.scriptId = "Invalid scriptId: " + params.scriptId; | |
80 else | |
81 params.scriptId = "<scriptId>"; | |
82 | |
83 var sourceResult = sourceMessage.result; | 68 var sourceResult = sourceMessage.result; |
84 sourceResult.scriptSource = sourceResult.scriptSource.replace(/\n/g, "<nl>"); | 69 sourceResult.scriptSource = sourceResult.scriptSource.replace(/\n/g, "<nl>"); |
85 InspectorTest.log(scriptParsed ? "scriptParsed" : "scriptFailedToParse"); | 70 InspectorTest.log(scriptParsed ? "scriptParsed" : "scriptFailedToParse"); |
86 InspectorTest.logObject(sourceResult); | 71 InspectorTest.logObject(sourceResult); |
87 InspectorTest.logObject(params); | 72 InspectorTest.logMessage(scriptParsedMessage.params); |
88 } | 73 } |
89 | |
90 function matchExact(re, str) { | |
91 var match = str.match(re); | |
92 return match !== null && str === match[0]; | |
93 } | |
OLD | NEW |