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

Side by Side Diff: LayoutTests/inspector/sources/debugger/debugger-script-preprocessor.html

Issue 761143003: DevTools: remove ScriptPreprocessor (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 5 years, 10 months 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 <html>
2 <head>
3 <script src="../../../http/tests/inspector/inspector-test.js"></script>
4 <script src="../../../http/tests/inspector/debugger-test.js"></script>
5 <script src="resources/script1.js"></script>
6 <script>
7
8 function load()
9 {
10 eval("function dynamic" + "Script1() {}");
11 eval("function dynamic" + "Script2() {}");
12 eval("function dynamic" + "RuntimeError() {}");
13 runTest();
14 }
15
16 function test()
17 {
18 function preprocessor(script, url, functionName)
19 {
20 function makeResponse(script, msg, url) {
21 // write into the console to verify that no internal scripts are pre processed.
22 return script + ';\nconsole.log(\"' + msg + '\");\n//# sourceURL=' + url;
23 }
24 if (script.indexOf("dynamic" + "Script1") !== -1)
25 return makeResponse(script, 'eval works', "dynamic"+"Script1");
26 if (script.indexOf("dynamic" + "Script2") !== -1) {
27 try {
28 var w = eval("window.location.href");
29 return makeResponse(script, 'verify href: ' + w, "dynamic"+"Scri pt2");
30 } catch (e) {
31 return makeResponse(script, 'Did not find window href', "dynamic "+"Script2");
32 }
33 }
34 if (script.indexOf("dynamic" + "RuntimeError") !== -1) {
35 throw new Error("fake internal preprocessor error");
36 }
37 if (!this.String) {
38 throw new Error("preprocessor environment is missing built-ins");
39 }
40 // Do not report tests/inspector files, their line numbers may change.
41 if(/-test.js/.test(url))
42 return script;
43 // Verify functionName argument for DOM event handlers.
44 if (functionName)
45 url += '_' + functionName;
46 // Verify that the |url| argument is correct.
47 url = url.replace(/\.html/, '_html') + '.js';
48 return makeResponse(script, 'preprocessed ' + url, url);
49 }
50
51 var failingPreprocessor = "(function() {throw new Error(\"failingPreprocesso r throws\");}())"
52 var syntaxError = "(function preprocessor(script, url) {\nsyntax error\n}\n) ";
53
54 InspectorTest.startDebuggerTest(step1);
55
56 function step1()
57 {
58 InspectorTest.reloadPage(step2, undefined, "(" + preprocessor + ")");
59 }
60
61 function step2()
62 {
63 function accept(script)
64 {
65 return !!script.sourceURL;
66 }
67 var scripts = InspectorTest.queryScripts(accept);
68 for (var i = 0; i < scripts.length; ++i)
69 InspectorTest.addResult("sourceURLs[" + i +"]=" + WebInspector.displ ayNameForURL(scripts[i].sourceURL));
70
71 InspectorTest.reloadPage(step3, undefined, "(" + failingPreprocessor + ")");
72 }
73
74 function step3()
75 {
76 InspectorTest.reloadPage(step4, undefined, "var notAFunctionOrSyntaxErr or;");
77 }
78
79 function step4()
80 {
81 InspectorTest.reloadPage(step5, undefined, syntaxError);
82 }
83
84 function step5()
85 {
86 InspectorTest.reloadPage(InspectorTest.completeDebuggerTest.bind(Inspect orTest));
87 }
88 }
89
90 </script>
91 </head>
92
93 <body onload="load()">
94 <p>
95 Tests script preprocessor (ability to preprocess all scripts upon reload).
96 </p>
97
98 </body>
99 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698