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

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

Issue 781623004: [V8] Report v8::AfterCompile and v8::CompileError to listener on pause (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years 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 // 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 19 matching lines...) Expand all
30 Debug = debug.Debug 30 Debug = debug.Debug
31 31
32 var exception = false; // Exception in debug event listener. 32 var exception = false; // Exception in debug event listener.
33 var before_compile_count = 0; 33 var before_compile_count = 0;
34 var after_compile_count = 0; 34 var after_compile_count = 0;
35 var compile_error_count = 0; 35 var compile_error_count = 0;
36 var current_source = ''; // Current source being compiled. 36 var current_source = ''; // Current source being compiled.
37 var source_count = 0; // Total number of scources compiled. 37 var source_count = 0; // Total number of scources compiled.
38 var host_compilations = 0; // Number of scources compiled through the API. 38 var host_compilations = 0; // Number of scources compiled through the API.
39 var eval_compilations = 0; // Number of scources compiled through eval. 39 var eval_compilations = 0; // Number of scources compiled through eval.
40 40 var mute_listener = false;
41 41
42 function compileSource(source) { 42 function compileSource(source) {
43 current_source = source; 43 current_source = source;
44 eval(current_source); 44 eval(current_source);
45 source_count++; 45 source_count++;
46 } 46 }
47 47
48 48
49 function listener(event, exec_state, event_data, data) { 49 function listener(event, exec_state, event_data, data) {
50 if (mute_listener) return;
50 try { 51 try {
51 if (event == Debug.DebugEvent.BeforeCompile || 52 if (event == Debug.DebugEvent.BeforeCompile ||
52 event == Debug.DebugEvent.AfterCompile || 53 event == Debug.DebugEvent.AfterCompile ||
53 event == Debug.DebugEvent.CompileError) { 54 event == Debug.DebugEvent.CompileError) {
54 // Count the events. 55 // Count the events.
55 if (event == Debug.DebugEvent.BeforeCompile) { 56 if (event == Debug.DebugEvent.BeforeCompile) {
56 before_compile_count++; 57 before_compile_count++;
57 } else if (event == Debug.DebugEvent.AfterCompile) { 58 } else if (event == Debug.DebugEvent.AfterCompile) {
58 after_compile_count++; 59 after_compile_count++;
59 switch (event_data.script().compilationType()) { 60 switch (event_data.script().compilationType()) {
(...skipping 14 matching lines...) Expand all
74 // For source with 'eval' there will be compile events with substrings 75 // For source with 'eval' there will be compile events with substrings
75 // as well as with with the exact source. 76 // as well as with with the exact source.
76 assertTrue(current_source.indexOf(event_data.script().source()) >= 0); 77 assertTrue(current_source.indexOf(event_data.script().source()) >= 0);
77 } else { 78 } else {
78 // For source without 'eval' there will be a compile events with the 79 // For source without 'eval' there will be a compile events with the
79 // exact source. 80 // exact source.
80 assertEquals(current_source, event_data.script().source()); 81 assertEquals(current_source, event_data.script().source());
81 } 82 }
82 // Check that script context is included into the event message. 83 // Check that script context is included into the event message.
83 var json = event_data.toJSONProtocol(); 84 var json = event_data.toJSONProtocol();
85 mute_listener = true;
84 var msg = eval('(' + json + ')'); 86 var msg = eval('(' + json + ')');
yurys 2014/12/08 14:31:22 try/finally
kozy 2014/12/08 14:53:01 Done.
87 mute_listener = false;
85 assertTrue('context' in msg.body.script); 88 assertTrue('context' in msg.body.script);
86 89
87 // Check that we pick script name from //# sourceURL, iff present 90 // Check that we pick script name from //# sourceURL, iff present
88 if (event == Debug.DebugEvent.AfterCompile) { 91 if (event == Debug.DebugEvent.AfterCompile) {
89 assertEquals(current_source.indexOf('sourceURL') >= 0 ? 92 assertEquals(current_source.indexOf('sourceURL') >= 0 ?
90 'myscript.js' : undefined, 93 'myscript.js' : undefined,
91 event_data.script().name()); 94 event_data.script().name());
92 } 95 }
93 } 96 }
94 } catch (e) { 97 } catch (e) {
(...skipping 28 matching lines...) Expand all
123 assertEquals(before_compile_count, after_compile_count + compile_error_count); 126 assertEquals(before_compile_count, after_compile_count + compile_error_count);
124 assertEquals(compile_error_count, 1); 127 assertEquals(compile_error_count, 1);
125 128
126 // Check the actual number of events (no compilation through the API as all 129 // Check the actual number of events (no compilation through the API as all
127 // source compiled through eval). 130 // source compiled through eval).
128 assertEquals(source_count, after_compile_count); 131 assertEquals(source_count, after_compile_count);
129 assertEquals(0, host_compilations); 132 assertEquals(0, host_compilations);
130 assertEquals(source_count, eval_compilations); 133 assertEquals(source_count, eval_compilations);
131 134
132 Debug.setListener(null); 135 Debug.setListener(null);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698