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

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

Issue 13575004: Apply script preprocessor to Web page scripts only. (Closed) Base URL: https://chromium.googlesource.com/external/WebKit_trimmed.git@master
Patch Set: Oops, no JS-builts Created 7 years, 6 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
OLDNEW
1 <html> 1 <html>
2 <head> 2 <head>
3 <script src="../../http/tests/inspector/inspector-test.js"></script> 3 <script src="../../http/tests/inspector/inspector-test.js"></script>
4 <script src="../../http/tests/inspector/debugger-test.js"></script> 4 <script src="../../http/tests/inspector/debugger-test.js"></script>
5 <script> 5 <script>
6 6
7 function load() 7 function load()
8 { 8 {
9 eval("function dynamic" + "Script1() {}"); 9 eval("function dynamic" + "Script1() {}");
10 eval("function dynamic" + "Script2() {}"); 10 eval("function dynamic" + "Script2() {}");
11 eval("function dynamic" + "RuntimeError() {}");
11 runTest(); 12 runTest();
12 } 13 }
13 14
14 function test() 15 function test()
15 { 16 {
16 function preprocessor(script, name) 17 function preprocessor(script, name)
17 { 18 {
19 function makeResponse(script, msg, name) {
20 // write into the console to verify that no internal scripts are pre processed.
21 return script + ';\nconsole.log(\"' + msg + '\");\n//@ sourceURL=' + name;
22 }
18 if (script.indexOf("dynamic" + "Script1") !== -1) 23 if (script.indexOf("dynamic" + "Script1") !== -1)
19 return script + "//@ sourceURL=dynamicScript1"; 24 return makeResponse(script, 'd1', "dynamic"+"Script1");
20 if (script.indexOf("dynamic" + "Script2") !== -1) { 25 if (script.indexOf("dynamic" + "Script2") !== -1) {
21 try { 26 try {
22 var w = eval("window"); 27 var w = eval("window");
23 return script + "//@ sourceURL=FAIL_window_should_not_be_there"; 28 return makeResponse(script, 'FAIL_window_should_not_be_there', " FAIL_window_should_not_be_there");
24 } catch (e) { 29 } catch (e) {
25 return script + "//@ sourceURL=dynamicScript2"; 30 return makeResponse(script, 'd2', "dynamic"+"Script2");
26 } 31 }
32 }
33 if (script.indexOf("dynamic" + "RuntimeError") !== -1) {
34 throw new Error("internal preprocessor error");
27 } 35 }
28 // Verify that the |name| argument is correct. Note: if name is not pass ed in 36 if (!this.String) {
29 // the results will be a script with a sourceURL equal to the original f ile name. 37 throw new Error("preprocessor environment is missing built-ins");
30 return script + "//@ sourceURL=" + name + ".js"; 38 }
39
40 // Verify that the |name| argument is correct.
41 name = name.replace(/\.html/, '_html') + '.js';
42 return makeResponse(script, 'preprocessed ' + name, name);
31 } 43 }
32 44
45 var failingPreprocessor = "(function() {throw new Error(\"failingPreprocesso r throws\");}())"
46 var syntaxError = "(function preprocessor(script, name) {\nsyntax error\n}\n )";
47
33 InspectorTest.startDebuggerTest(step1); 48 InspectorTest.startDebuggerTest(step1);
34 49
35 function step1() 50 function step1()
36 { 51 {
37 InspectorTest.reloadPage(step2, undefined, "(" + preprocessor + ")"); 52 InspectorTest.reloadPage(step2, undefined, "(" + preprocessor + ")");
38 } 53 }
39 54
40 function step2() 55 function step2()
41 { 56 {
42 function accept(script) 57 function accept(script)
43 { 58 {
44 return true; 59 return true;
45 } 60 }
46 var scripts = InspectorTest.queryScripts(accept); 61 var scripts = InspectorTest.queryScripts(accept);
47 for (var i = 0; i < scripts.length; ++i) 62 for (var i = 0; i < scripts.length; ++i)
48 InspectorTest.addResult(WebInspector.displayNameForURL(scripts[i].so urceURL)); 63 InspectorTest.addResult("sourceURLs[" + i +"]=" + WebInspector.displ ayNameForURL(scripts[i].sourceURL));
49 64
65 InspectorTest.reloadPage(step3, undefined, "(" + failingPreprocessor + ")");
66 }
67
68 function step3()
69 {
70 InspectorTest.reloadPage(step4, undefined, "1");
71 }
72
73 function step4()
74 {
75 InspectorTest.reloadPage(step5, undefined, syntaxError);
76 }
77
78 function step5()
79 {
50 InspectorTest.reloadPage(InspectorTest.completeDebuggerTest.bind(Inspect orTest)); 80 InspectorTest.reloadPage(InspectorTest.completeDebuggerTest.bind(Inspect orTest));
51 } 81 }
52 } 82 }
53 83
54 </script> 84 </script>
55 </head> 85 </head>
56 86
57 <body onload="load()"> 87 <body onload="load()">
58 <p> 88 <p>
59 Tests script preprocessor (ability to preprocess all scripts upon reload). 89 Tests script preprocessor (ability to preprocess all scripts upon reload).
60 </p> 90 </p>
61 91
62 </body> 92 </body>
63 </html> 93 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698