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

Side by Side Diff: test/mjsunit/debug-changebreakpoint.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 | « no previous file | test/mjsunit/debug-clearbreakpoint.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":"changebreakpoint"'
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 // Test some legal clearbreakpoint requests.
63 var dcp = exec_state.debugCommandProcessor("unspecified_running_state"); 42 Debug.enableBreakPoint(breakpoint);
64 43 Debug.disableBreakPoint(breakpoint);
65 // Test some illegal clearbreakpoint requests. 44 Debug.changeBreakPointCondition(breakpoint, "1==2");
66 var request = '{' + base_request + '}' 45 Debug.changeBreakPointCondition(breakpoint, "false");
67 var response = safeEval(dcp.processDebugJSONRequest(request)); 46 listenerComplete = true;
68 assertFalse(response.success); 47 }
69
70 testArguments(dcp, '{}', false);
71 testArguments(dcp, '{"breakpoint":0,"condition":"false"}', false);
72 testArguments(dcp, '{"breakpoint":' + (breakpoint + 1) + ',"condition":"fals e"}', false);
73 testArguments(dcp, '{"breakpoint":"xx","condition":"false"}', false);
74
75 // Test some legal clearbreakpoint requests.
76 var bp_str = '"breakpoint":' + breakpoint;;
77 testArguments(dcp, '{' + bp_str + '}', true);
78 testArguments(dcp, '{' + bp_str + ',"enabled":"true"}', true);
79 testArguments(dcp, '{' + bp_str + ',"enabled":"false"}', true);
80 testArguments(dcp, '{' + bp_str + ',"condition":"1==2"}', true);
81 testArguments(dcp, '{' + bp_str + ',"condition":"false"}', true);
82
83 // Indicate that all was processed.
84 listenerComplete = true;
85 }
86 } catch (e) { 48 } catch (e) {
87 exception = e 49 exception = e
88 }; 50 };
89 }; 51 };
90 52
91 // Add the debug event listener. 53 // Add the debug event listener.
92 Debug.setListener(listener); 54 Debug.setListener(listener);
93 55
94 function g() {}; 56 function g() {};
95 57
96 // Set a break point and call to invoke the debug event listener. 58 // Set a break point and call to invoke the debug event listener.
97 breakpoint = Debug.setBreakPoint(g, 0, 0); 59 breakpoint = Debug.setBreakPoint(g, 0, 0);
98 g(); 60 g();
99 61
100 // Make sure that the debug event listener vas invoked. 62 // Make sure that the debug event listener vas invoked.
101 assertTrue(listenerComplete, "listener did not run to completion"); 63 assertTrue(listenerComplete, "listener did not run to completion");
102 assertFalse(exception, "exception in listener") 64 assertFalse(exception, "exception in listener")
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/debug-clearbreakpoint.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698