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/regress/regress-1081309.js

Issue 18092: Added handles to the mirror objects. When a mirror for an object is created... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 11 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 | « test/mjsunit/mirror-unresolved-function.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 2008 the V8 project authors. All rights reserved. 1 // Copyright 2008 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 16 matching lines...) Expand all
27 27
28 // Flags: --expose-debug-as debug 28 // Flags: --expose-debug-as debug
29 // Get the Debug object exposed from the debug context global object. 29 // Get the Debug object exposed from the debug context global object.
30 Debug = debug.Debug 30 Debug = debug.Debug
31 31
32 // Make sure that the backtrace command can be processed when the receiver is 32 // Make sure that the backtrace command can be processed when the receiver is
33 // undefined. 33 // undefined.
34 listenerCalled = false; 34 listenerCalled = false;
35 exception = false; 35 exception = false;
36 36
37 function safeEval(code) { 37 function ParsedResponse(json) {
38 try { 38 this.response_ = eval('(' + json + ')');
39 return eval('(' + code + ')'); 39 this.refs_ = [];
40 } catch (e) { 40 if (this.response_.refs) {
41 return undefined; 41 for (var i = 0; i < this.response_.refs.length; i++) {
42 this.refs_[this.response_.refs[i].handle] = this.response_.refs[i];
43 }
42 } 44 }
43 } 45 }
44 46
47
48 ParsedResponse.prototype.response = function() {
49 return this.response_;
50 }
51
52
53 ParsedResponse.prototype.body = function() {
54 return this.response_.body;
55 }
56
57
58 ParsedResponse.prototype.lookup = function(handle) {
59 return this.refs_[handle];
60 }
61
62
45 function listener(event, exec_state, event_data, data) { 63 function listener(event, exec_state, event_data, data) {
46 try { 64 try {
47 if (event == Debug.DebugEvent.Exception) 65 if (event == Debug.DebugEvent.Exception)
48 { 66 {
49 // The expected backtrace is 67 // The expected backtrace is
50 // 1: g 68 // 1: g
51 // 0: [anonymous] 69 // 0: [anonymous]
52 70
53 // Get the debug command processor. 71 // Get the debug command processor.
54 var dcp = exec_state.debugCommandProcessor(); 72 var dcp = exec_state.debugCommandProcessor();
55 73
56 // Get the backtrace. 74 // Get the backtrace.
57 var json; 75 var json;
58 json = '{"seq":0,"type":"request","command":"backtrace"}' 76 json = '{"seq":0,"type":"request","command":"backtrace"}'
59 var backtrace = safeEval(dcp.processDebugJSONRequest(json)).body; 77 var response = new ParsedResponse(dcp.processDebugJSONRequest(json));
78 var backtrace = response.body();
60 assertEquals(2, backtrace.totalFrames); 79 assertEquals(2, backtrace.totalFrames);
61 assertEquals(2, backtrace.frames.length); 80 assertEquals(2, backtrace.frames.length);
62 81
63 assertEquals("g", backtrace.frames[0].func.name); 82 assertEquals("g", response.lookup(backtrace.frames[0].func.ref).name);
64 assertEquals("", backtrace.frames[1].func.name); 83 assertEquals("", response.lookup(backtrace.frames[1].func.ref).name);
65 84
66 listenerCalled = true; 85 listenerCalled = true;
67 } 86 }
68 } catch (e) { 87 } catch (e) {
69 exception = e 88 exception = e
70 }; 89 };
71 }; 90 };
72 91
73 // Add the debug event listener. 92 // Add the debug event listener.
74 Debug.addListener(listener); 93 Debug.addListener(listener);
75 94
76 // Call method on undefined. 95 // Call method on undefined.
77 function g() { 96 function g() {
78 (void 0).f(); 97 (void 0).f();
79 }; 98 };
80 99
81 // Break on the exception to do a backtrace with undefined as receiver. 100 // Break on the exception to do a backtrace with undefined as receiver.
82 Debug.setBreakOnException(true); 101 Debug.setBreakOnException(true);
83 try { 102 try {
84 g(); 103 g();
85 } catch(e) { 104 } catch(e) {
86 // Ignore the exception "Cannot call method 'x' of undefined" 105 // Ignore the exception "Cannot call method 'x' of undefined"
87 } 106 }
88 107
89 // Make sure that the debug event listener vas invoked. 108 // Make sure that the debug event listener vas invoked.
90 assertTrue(listenerCalled, "listener not called"); 109 assertTrue(listenerCalled, "listener not called");
91 assertFalse(exception, "exception in listener", exception) 110 assertFalse(exception, "exception in listener", exception)
OLDNEW
« no previous file with comments | « test/mjsunit/mirror-unresolved-function.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698