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

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

Issue 21076: Fixed the debugger compile events.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 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
« no previous file with comments | « src/debug-delay.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')
Property Changes:
Added: svn:eol-style
+ native
OLDNEW
(Empty)
1 // Copyright 2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 // Flags: --expose-debug-as debug
29 // Get the Debug object exposed from the debug context global object.
30 Debug = debug.Debug
31
32 var exception = false; // Exception in debug event listener.
33 var before_compile_count = 0;
34 var after_compile_count = 0;
35 var current_source = ''; // Current source compiled.
36 var source_count = 0; // Total number of scource sompiled.
37
38
39 function compileSource(source) {
40 current_source = source;
41 eval(current_source);
42 source_count++;
43 }
44
45
46 function listener(event, exec_state, event_data, data) {
47 try {
48 if (event == Debug.DebugEvent.BeforeCompile ||
49 event == Debug.DebugEvent.AfterCompile) {
50 // Count the events.
51 if (event == Debug.DebugEvent.BeforeCompile) {
52 before_compile_count++;
53 } else {
54 after_compile_count++;
55 }
56
57 // If the compiled source contains 'eval' there will be additional compile
58 // events for the source inside eval.
59 if (current_source.indexOf('eval') == 0) {
60 // For source with 'eval' there will be compile events with substrings
61 // as well as with with the exact source.
62 assertTrue(current_source.indexOf(event_data.script().source()) >= 0);
63 } else {
64 // For source without 'eval' there will be a compile events with the
65 // exact source.
66 assertEquals(current_source, event_data.script().source());
67 }
68 }
69 } catch (e) {
70 exception = e
71 }
72 };
73
74
75 // Add the debug event listener.
76 Debug.setListener(listener);
77
78 // Compile different sources.
79 compileSource('a=1');
80 compileSource('function(){}');
81 compileSource('eval("a=2")');
82 source_count++; // Using eval causes additional compilation event.
83 compileSource('eval("eval(\'function(){return a;}\')")');
84 source_count += 2; // Using eval causes additional compilation event.
85
86 // Make sure that the debug event listener was invoked.
87 assertFalse(exception, "exception in listener")
88
89 // Number of before and after compile events should be the same.
90 assertEquals(before_compile_count, after_compile_count);
91
92 // Check the actual number of events.
93 assertEquals(source_count, after_compile_count);
94
95 Debug.setListener(null);
OLDNEW
« no previous file with comments | « src/debug-delay.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698