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

Unified Diff: test/mjsunit/debug-setbreakpoint.js

Issue 40317: Added unique id to all scripts (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/mjsunit/debug-script-breakpoints.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/debug-setbreakpoint.js
===================================================================
--- test/mjsunit/debug-setbreakpoint.js (revision 1464)
+++ test/mjsunit/debug-setbreakpoint.js (working copy)
@@ -30,8 +30,13 @@
Debug = debug.Debug
// Simple function which stores the last debug event.
-listenerComplete = false;
-exception = false;
+var listenerComplete = false;
+var exception = false;
+var f_script_id = 0;
+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"'
@@ -44,13 +49,18 @@
}
}
-function testArguments(dcp, arguments, success, type) {
+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, json_response);
- assertEquals(type ? type : 'script', response.body.type, json_response);
+ if (is_script) {
+ assertEquals('scriptName', response.body.type, json_response);
+ } else {
+ assertEquals('scriptId', response.body.type, json_response);
+ print(response.body.script_id);
+ }
} else {
assertFalse(response.success, json_response);
}
@@ -79,19 +89,24 @@
testArguments(dcp, '{"type":"function","target":"f","ignoreCount":-1}', false);
// Test some legal setbreakpoint requests.
- testArguments(dcp, '{"type":"function","target":"f"}', true);
- testArguments(dcp, '{"type":"function","target":"h"}', true, 'function');
- testArguments(dcp, '{"type":"function","target":"f","line":1}', true);
- testArguments(dcp, '{"type":"function","target":"f","position":1}', true);
- testArguments(dcp, '{"type":"function","target":"f","condition":"i == 1"}', true);
- testArguments(dcp, '{"type":"function","target":"f","enabled":true}', true);
- testArguments(dcp, '{"type":"function","target":"f","enabled":false}', true);
- testArguments(dcp, '{"type":"function","target":"f","ignoreCount":7}', true);
- testArguments(dcp, '{"type":"script","target":"test"}', true);
- testArguments(dcp, '{"type":"script","target":"test"}', true);
- testArguments(dcp, '{"type":"script","target":"test","line":1}', true);
- testArguments(dcp, '{"type":"script","target":"test","column":1}', true);
+ 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":"function","target":"f","ignoreCount":7}', 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);
+
// Indicate that all was processed.
listenerComplete = true;
}
@@ -113,10 +128,27 @@
eval('function h(){}');
+// Check the script ids for the test functions.
+f_script_id = Debug.findScript(f).id;
+g_script_id = Debug.findScript(g).id;
+h_script_id = Debug.findScript(h).id;
+assertTrue(f_script_id > 0, "invalid script id for f");
+assertTrue(g_script_id > 0, "invalid script id for g");
+assertTrue(h_script_id > 0, "invalid script id for h");
+assertEquals(f_script_id, g_script_id);
+
+// Get the source line for the test functions.
+f_line = Debug.findFunctionSourceLocation(f).line;
+g_line = Debug.findFunctionSourceLocation(g).line;
+h_line = Debug.findFunctionSourceLocation(h).line;
+assertTrue(f_line > 0, "invalid line for f");
+assertTrue(g_line > 0, "invalid line for g");
+assertTrue(f_line < g_line);
+assertEquals(h_line, 0, "invalid line for h");
+
// Set a break point and call to invoke the debug event listener.
Debug.setBreakPoint(g, 0, 0);
g();
// Make sure that the debug event listener vas invoked.
-assertTrue(listenerComplete, "listener did not run to completion");
-assertFalse(exception, "exception in listener")
+assertTrue(listenerComplete, "listener did not run to completion: " + exception);
« no previous file with comments | « test/mjsunit/debug-script-breakpoints.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698