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

Side by Side Diff: test/mjsunit/debug-compile-event.js

Issue 7045003: Support extracting source mapping url defined by //@ sourceMappingURL=<url> comment. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 7 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
« no previous file with comments | « src/mirror-debugger.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 // For source without 'eval' there will be a compile events with the 74 // For source without 'eval' there will be a compile events with the
75 // exact source. 75 // exact source.
76 assertEquals(current_source, event_data.script().source()); 76 assertEquals(current_source, event_data.script().source());
77 } 77 }
78 // Check that script context is included into the event message. 78 // Check that script context is included into the event message.
79 var json = event_data.toJSONProtocol(); 79 var json = event_data.toJSONProtocol();
80 var msg = eval('(' + json + ')'); 80 var msg = eval('(' + json + ')');
81 assertTrue('context' in msg.body.script); 81 assertTrue('context' in msg.body.script);
82 82
83 // Check that we pick script name from //@ sourceURL, iff present 83 // Check that we pick script name from //@ sourceURL, iff present
84 assertEquals(current_source.indexOf('sourceURL') >= 0 ? 84 assertEquals(current_source.indexOf('sourceURL') >= 0 ?
85 'myscript.js' : undefined, 85 'myscript.js' : undefined,
86 event_data.script().name()); 86 event_data.script().name());
87
88 // Check that we pick source mapping url from //@ sourceMappingURL, if
89 // present.
90 assertEquals(current_source.indexOf('sourceMappingURL') >= 0 ?
91 'http://example.com/sourceMapping.json' : undefined,
92 event_data.script().sourceMappingURL());
87 } 93 }
88 } catch (e) { 94 } catch (e) {
89 exception = e 95 exception = e
90 } 96 }
91 }; 97 };
92 98
93 99
94 // Add the debug event listener. 100 // Add the debug event listener.
95 Debug.setListener(listener); 101 Debug.setListener(listener);
96 102
97 // Compile different sources. 103 // Compile different sources.
98 compileSource('a=1'); 104 compileSource('a=1');
99 compileSource('(function(){})'); 105 compileSource('(function(){})');
100 compileSource('eval("a=2")'); 106 compileSource('eval("a=2")');
101 source_count++; // Using eval causes additional compilation event. 107 source_count++; // Using eval causes additional compilation event.
102 compileSource('eval("eval(\'(function(){return a;})\')")'); 108 compileSource('eval("eval(\'(function(){return a;})\')")');
103 source_count += 2; // Using eval causes additional compilation event. 109 source_count += 2; // Using eval causes additional compilation event.
104 compileSource('JSON.parse(\'{"a":1,"b":2}\')'); 110 compileSource('JSON.parse(\'{"a":1,"b":2}\')');
105 // Using JSON.parse does not causes additional compilation events. 111 // Using JSON.parse does not causes additional compilation events.
106 compileSource('x=1; //@ sourceURL=myscript.js'); 112 compileSource('x=1; //@ sourceURL=myscript.js\n' +
113 '//@ sourceMappingURL=http://example.com/sourceMapping.json');
107 114
108 // Make sure that the debug event listener was invoked. 115 // Make sure that the debug event listener was invoked.
109 assertFalse(exception, "exception in listener") 116 assertFalse(exception, "exception in listener")
110 117
111 // Number of before and after compile events should be the same. 118 // Number of before and after compile events should be the same.
112 assertEquals(before_compile_count, after_compile_count); 119 assertEquals(before_compile_count, after_compile_count);
113 120
114 // Check the actual number of events (no compilation through the API as all 121 // Check the actual number of events (no compilation through the API as all
115 // source compiled through eval). 122 // source compiled through eval).
116 assertEquals(source_count, after_compile_count); 123 assertEquals(source_count, after_compile_count);
117 assertEquals(0, host_compilations); 124 assertEquals(0, host_compilations);
118 assertEquals(source_count, eval_compilations); 125 assertEquals(source_count, eval_compilations);
119 126
120 Debug.setListener(null); 127 Debug.setListener(null);
OLDNEW
« no previous file with comments | « src/mirror-debugger.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698