Index: test/mjsunit/debug-script-breakpoints-closure.js |
diff --git a/test/mjsunit/debug-set-script-source.js b/test/mjsunit/debug-script-breakpoints-closure.js |
similarity index 67% |
copy from test/mjsunit/debug-set-script-source.js |
copy to test/mjsunit/debug-script-breakpoints-closure.js |
index 34ae8488a4de608543c543555e11236e1c65726e..e2bb58863fe7bdec9485f2ddcba60f7a840b4573 100644 |
--- a/test/mjsunit/debug-set-script-source.js |
+++ b/test/mjsunit/debug-script-breakpoints-closure.js |
@@ -29,36 +29,39 @@ |
// Get the Debug object exposed from the debug context global object. |
Debug = debug.Debug |
-var script_number = 0; |
-var script_names = []; |
-var exception = null; |
+// Simple debug event handler which just counts the number of break points hit. |
+var break_point_hit_count = 0; |
function listener(event, exec_state, event_data, data) { |
- if (event == Debug.DebugEvent.BeforeCompile) { |
- event_data.script().setSource(event_data.script().source() + |
- " //@ sourceURL=proper_location_" + (++script_number)); |
- } else if (event == Debug.DebugEvent.AfterCompile) { |
- try { |
- event_data.script().setSource("a=1 //@ sourceURL=wrong_location"); |
- } catch(e) { |
- exception = e; |
- } |
- script_names.push(event_data.script().name()); |
+ if (event == Debug.DebugEvent.Break) { |
+ break_point_hit_count++; |
} |
}; |
- |
// Add the debug event listener. |
Debug.setListener(listener); |
-// Compile different sources. |
-eval('a=1'); |
-eval('(function(){})'); |
+function makeClosure() { |
+ var x; |
+ return function() { |
+ return x; // Breakpoint line ( #47 ) |
+ }; |
+} |
+ |
+// Create closure before break point is set. |
+var closure = makeClosure(); |
-assertEquals(2, script_names.length); |
-assertEquals("proper_location_1", script_names[0]); |
-assertEquals("proper_location_2", script_names[1]); |
+// The debugger triggers re-compilation. |
+assertEquals(0, Debug.scriptBreakPoints().length); |
+var scr = Debug.findScript(makeClosure); |
+var sbp = Debug.setScriptBreakPointById(scr.id, 47); |
+assertEquals(1, Debug.scriptBreakPoints().length); |
-assertEquals("illegal access", exception); |
+// Ensure the closure actually triggers a break point hit. |
+closure(); |
+assertEquals(1, break_point_hit_count); |
-Debug.setListener(null); |
+// Remove script break point. |
+assertEquals(1, Debug.scriptBreakPoints().length); |
+Debug.clearBreakPoint(sbp); |
+assertEquals(0, Debug.scriptBreakPoints().length); |