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

Side by Side Diff: test/mjsunit/debug-clearbreakpoint.js

Issue 2557043005: [debugger] remove remaining uses of the debug command processor. (Closed)
Patch Set: fix Created 4 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
« no previous file with comments | « test/mjsunit/debug-changebreakpoint.js ('k') | test/mjsunit/debug-clearbreakpointgroup.js » ('j') | 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 // Simple function which stores the last debug event. 32 // Simple function which stores the last debug event.
33 listenerComplete = false; 33 listenerComplete = false;
34 exception = false; 34 exception = false;
35 35
36 var breakpoint = -1; 36 var breakpoint = -1;
37 var base_request = '"seq":0,"type":"request","command":"clearbreakpoint"'
38
39 function safeEval(code) {
40 try {
41 return eval('(' + code + ')');
42 } catch (e) {
43 assertEquals(void 0, e);
44 return undefined;
45 }
46 }
47
48 function testArguments(dcp, arguments, success) {
49 var request = '{' + base_request + ',"arguments":' + arguments + '}'
50 var json_response = dcp.processDebugJSONRequest(request);
51 var response = safeEval(json_response);
52 if (success) {
53 assertTrue(response.success, json_response);
54 } else {
55 assertFalse(response.success, json_response);
56 }
57 }
58 37
59 function listener(event, exec_state, event_data, data) { 38 function listener(event, exec_state, event_data, data) {
60 try { 39 try {
61 if (event == Debug.DebugEvent.Break) { 40 if (event == Debug.DebugEvent.Break) {
62 // Get the debug command processor. 41 // Clear once.
63 var dcp = exec_state.debugCommandProcessor("unspecified_running_state"); 42 Debug.clearBreakPoint(breakpoint);
64 43 // Indicate that all was processed.
65 // Test some illegal clearbreakpoint requests. 44 listenerComplete = true;
66 var request = '{' + base_request + '}' 45 }
67 var response = safeEval(dcp.processDebugJSONRequest(request));
68 assertFalse(response.success);
69
70 testArguments(dcp, '{}', false);
71 testArguments(dcp, '{"breakpoint":0}', false);
72 testArguments(dcp, '{"breakpoint":' + (breakpoint + 1)+ '}', false);
73 testArguments(dcp, '{"breakpoint":"xx"}', false);
74
75 // Test some legal clearbreakpoint requests.
76 testArguments(dcp, '{"breakpoint":' + breakpoint + '}', true);
77
78 // Cannot clear the same break point twice.
79 testArguments(dcp, '{"breakpoint":' + breakpoint + '}', false);
80
81 // Indicate that all was processed.
82 listenerComplete = true;
83 }
84 } catch (e) { 46 } catch (e) {
85 exception = e 47 exception = e
86 }; 48 };
87 }; 49 };
88 50
89 // Add the debug event listener. 51 // Add the debug event listener.
90 Debug.setListener(listener); 52 Debug.setListener(listener);
91 53
92 function g() {}; 54 function g() {};
93 55
94 // Set a break point and call to invoke the debug event listener. 56 // Set a break point and call to invoke the debug event listener.
95 breakpoint = Debug.setBreakPoint(g, 0, 0); 57 breakpoint = Debug.setBreakPoint(g, 0, 0);
96 g(); 58 g();
97 59
98 // Make sure that the debug event listener vas invoked. 60 // Make sure that the debug event listener vas invoked.
99 assertTrue(listenerComplete, "listener did not run to completion"); 61 assertTrue(listenerComplete, "listener did not run to completion");
100 assertFalse(exception, "exception in listener") 62 assertFalse(exception, "exception in listener")
OLDNEW
« no previous file with comments | « test/mjsunit/debug-changebreakpoint.js ('k') | test/mjsunit/debug-clearbreakpointgroup.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698