Index: test/mjsunit/debug-setbreakpoint.js |
diff --git a/test/mjsunit/debug-setbreakpoint.js b/test/mjsunit/debug-setbreakpoint.js |
index 7c996e5de0c71d7a41b3ff9f98e961742c22c339..dd541f3744c5077deeda4b1bb40e8d090d41a75d 100644 |
--- a/test/mjsunit/debug-setbreakpoint.js |
+++ b/test/mjsunit/debug-setbreakpoint.js |
@@ -37,95 +37,29 @@ var g_script_id = 0; |
var h_script_id = 0; |
var f_line = 0; |
var g_line = 0; |
- |
-var base_request = '"seq":0,"type":"request","command":"setbreakpoint"' |
- |
-function safeEval(code) { |
- try { |
- return eval('(' + code + ')'); |
- } catch (e) { |
- assertEquals(void 0, e); |
- return undefined; |
- } |
-} |
- |
-function testArguments(dcp, arguments, success, is_script) { |
- var request = '{' + base_request + ',"arguments":' + arguments + '}' |
- var json_response = dcp.processDebugJSONRequest(request); |
- var response = safeEval(json_response); |
- if (success) { |
- assertTrue(response.success, request + ' -> ' + json_response); |
- if (is_script) { |
- assertEquals('scriptName', response.body.type, request + ' -> ' + json_response); |
- } else { |
- assertEquals('scriptId', response.body.type, request + ' -> ' + json_response); |
- } |
- } else { |
- assertFalse(response.success, request + ' -> ' + json_response); |
- } |
- return response; |
-} |
+var h_line = 0; |
function listener(event, exec_state, event_data, data) { |
try { |
- if (event == Debug.DebugEvent.Break) { |
- // Get the debug command processor. |
- var dcp = exec_state.debugCommandProcessor("unspecified_running_state"); |
- |
- // Test some illegal setbreakpoint requests. |
- var request = '{' + base_request + '}' |
- var response = safeEval(dcp.processDebugJSONRequest(request)); |
- assertFalse(response.success); |
- |
- var mirror; |
- |
- testArguments(dcp, '{}', false); |
- testArguments(dcp, '{"type":"xx"}', false); |
- testArguments(dcp, '{"type":"function"}', false); |
- testArguments(dcp, '{"type":"script"}', false); |
- testArguments(dcp, '{"target":"f"}', false); |
- testArguments(dcp, '{"type":"xx","target":"xx"}', false); |
- testArguments(dcp, '{"type":"function","target":1}', false); |
- testArguments(dcp, '{"type":"function","target":"f","line":-1}', false); |
- testArguments(dcp, '{"type":"function","target":"f","column":-1}', false); |
- testArguments(dcp, '{"type":"handle","target":"-1"}', false); |
- mirror = debug.MakeMirror(o); |
- testArguments(dcp, '{"type":"handle","target":' + mirror.handle() + '}', false); |
- |
- // Test some legal setbreakpoint requests. |
- testArguments(dcp, '{"type":"function","target":"f"}', true, false); |
- testArguments(dcp, '{"type":"function","target":"h"}', true, false); |
- testArguments(dcp, '{"type":"function","target":"f","line":1}', true, false); |
- testArguments(dcp, '{"type":"function","target":"f","position":1}', true, false); |
- testArguments(dcp, '{"type":"function","target":"f","condition":"i == 1"}', true, false); |
- testArguments(dcp, '{"type":"function","target":"f","enabled":true}', true, false); |
- testArguments(dcp, '{"type":"function","target":"f","enabled":false}', true, false); |
- |
- testArguments(dcp, '{"type":"script","target":"test"}', true, true); |
- testArguments(dcp, '{"type":"script","target":"test"}', true, true); |
- testArguments(dcp, '{"type":"script","target":"test","line":1}', true, true); |
- testArguments(dcp, '{"type":"script","target":"test","column":1}', true, true); |
- |
- testArguments(dcp, '{"type":"scriptId","target":' + f_script_id + ',"line":' + f_line + '}', true, false); |
- testArguments(dcp, '{"type":"scriptId","target":' + g_script_id + ',"line":' + g_line + '}', true, false); |
- testArguments(dcp, '{"type":"scriptId","target":' + h_script_id + ',"line":' + h_line + '}', true, false); |
- |
- mirror = debug.MakeMirror(f); |
- testArguments(dcp, '{"type":"handle","target":' + mirror.handle() + '}', true, false); |
- mirror = debug.MakeMirror(o.a); |
- testArguments(dcp, '{"type":"handle","target":' + mirror.handle() + '}', true, false); |
- |
- testArguments(dcp, '{"type":"script","target":"sourceUrlScript","line":0}', true, true); |
- |
- // Set a break point on a line with the comment, and check that actual position |
- // is the next line after the comment. |
- request = '{"type":"scriptId","target":' + g_script_id + ',"line":' + (g_line + 1) + '}'; |
- response = testArguments(dcp, request, true, false); |
- assertEquals(g_line + 2, response.body.actual_locations[0].line); |
- |
- // Indicate that all was processed. |
- listenerComplete = true; |
- } |
+ if (event == Debug.DebugEvent.Break) { |
+ Debug.setBreakPoint(exec_state.evaluateGlobal("f").value()); |
+ Debug.setBreakPoint(exec_state.evaluateGlobal("h").value()); |
+ Debug.setBreakPoint(exec_state.evaluateGlobal("f").value(), 1); |
+ Debug.setBreakPoint(exec_state.evaluateGlobal("f").value(), 1); |
+ Debug.setBreakPoint(exec_state.evaluateGlobal("f").value(), |
+ undefined, undefined, "i == 1"); |
+ |
+ Debug.setScriptBreakPointByName("test"); |
+ Debug.setScriptBreakPointByName("test", 1); |
+ Debug.setScriptBreakPointByName("test", 1, 1); |
+ |
+ Debug.setScriptBreakPointByName(f_script_id, f_line); |
+ Debug.setScriptBreakPointByName(g_script_id, g_line); |
+ Debug.setScriptBreakPointByName(h_script_id, h_line); |
+ |
+ // Indicate that all was processed. |
+ listenerComplete = true; |
+ } |
} catch (e) { |
exception = e |
}; |
@@ -185,6 +119,8 @@ function breakListener(event) { |
breakListenerCalled = true; |
} |
+Debug.setBreakPoint(sourceUrlFunc); |
+ |
Debug.setListener(breakListener); |
sourceUrlFunc(); |