Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(386)

Side by Side Diff: test/inspector/debugger/script-on-after-compile.js

Issue 2449213002: [inspector] migrate scriptParsed and getCompiledScripts to native (Closed)
Patch Set: addressed comments Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4 // Flags: --expose_gc
5
6 print("Checks that inspector correctly process compiled scripts");
7
8 function addScripts() {
9 // sourceURL in the same line
10 return addScript("function foo1(){}//# sourceURL=oneline.js\n")
11 // sourceURL without end line
12 .then(() => addScript("function foo2(){}//# sourceURL=oneline-without-nl.js" ))
13 // other source urls
14 .then(() => addScript("function foo3(){}\n//# sourceURL=twoline.js\n"))
15 .then(() => addScript("function foo4(){}\n\n//# sourceURL=threeline.js\n"))
16
17 // sourceMappingURL in the same line
18 .then(() => addScript("function foo5(){}//# sourceMappingURL=oneline-map\n") )
19 // sourceMappingURL without end line
20 .then(() => addScript("function foo6(){}//# sourceMappingURL=oneline-without -nl-map"))
21 // other sourceMappingURLs
22 .then(() => addScript("function foo7(){}\n//# sourceMappingURL=twoline-map\n "))
23 .then(() => addScript("function foo8(){}\n\n//# sourceMappingURL=threeline-m ap\n"))
24
25 // sourceURL + sourceMappingURL
26 .then(() => addScript("function foo9(){}//# sourceMappingURL=source-mapping- url-map\n//# sourceURL=source-url.js"))
27 .then(() => addScript("function foo10(){}//# sourceURL=source-url.js\n//# so urceMappingURL=source-mapping-url-map"))
28
29 // non zero endLine and endColumn..
30 .then(() => addScript("function foo11(){}\n//# sourceURL=end1.js"))
31 // .. + 1 character
32 .then(() => addScript("function foo12(){}\n//# sourceURL=end2.js "))
33 // script without sourceURL
34 .then(() => addScript("function foo13(){}"))
35 // script in eval
36 .then(() => addScript("function foo15(){}; eval(\"function foo14(){}//# sour ceURL=eval.js\")//# sourceURL=eval-wrapper.js"))
37 // sourceURL and sourceMappingURL works even for script with syntax error
38 .then(() => addScript("}//# sourceURL=failed.js\n//# sourceMappingURL=failed -map"))
39 // empty lines at end
40 .then(() => addScript("function foo16(){}\n"))
41 .then(() => addScript("function foo17(){}\n\n"))
42 .then(() => addScript("function foo18(){}\n\n\n"))
43 .then(() => addScript("function foo19(){}\n\n\n\n"));
44 }
45
46 Protocol.Debugger.onScriptParsed((message) => requestSourceAndDump(message, true ));
47 Protocol.Debugger.onScriptFailedToParse((message) => requestSourceAndDump(messag e, false));
48 addScripts()
49 .then(() => Protocol.Debugger.enable())
50 .then(addScripts)
51 .then(() => Protocol.Debugger.disable())
52
53 .then(() => InspectorTest.log("Run gc and then Debugger.enable().."))
54 .then(() => Protocol.Runtime.evaluate({ expression: "for (let i = 1; i < 20; + +i) eval(`foo${i} = undefined`); gc();" }))
55 .then(() => Protocol.Debugger.enable())
56 .then(InspectorTest.completeTest);
57
58 function addScript(source) {
59 return Protocol.Runtime.evaluate({ expression: source });
60 }
61
62 function requestSourceAndDump(scriptParsedMessage, scriptParsed) {
63 Protocol.Debugger.getScriptSource({ scriptId: scriptParsedMessage.params.scrip tId })
64 .then((sourceMessage) => dumpScriptParsed(scriptParsedMessage, sourceMessage , scriptParsed));
65 }
66
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;
84 sourceResult.scriptSource = sourceResult.scriptSource.replace(/\n/g, "<nl>");
85 InspectorTest.log(scriptParsed ? "scriptParsed" : "scriptFailedToParse");
86 InspectorTest.logObject(sourceResult);
87 InspectorTest.logObject(params);
88 }
89
90 function matchExact(re, str) {
91 var match = str.match(re);
92 return match !== null && str === match[0];
93 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698