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

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

Powered by Google App Engine
This is Rietveld 408576698