--- /dev/null
+// Copyright 2009 the V8 project authors. All rights reserved.\r
+// Redistribution and use in source and binary forms, with or without\r
+// modification, are permitted provided that the following conditions are\r
+// met:\r
+//\r
+// * Redistributions of source code must retain the above copyright\r
+// notice, this list of conditions and the following disclaimer.\r
+// * Redistributions in binary form must reproduce the above\r
+// copyright notice, this list of conditions and the following\r
+// disclaimer in the documentation and/or other materials provided\r
+// with the distribution.\r
+// * Neither the name of Google Inc. nor the names of its\r
+// contributors may be used to endorse or promote products derived\r
+// from this software without specific prior written permission.\r
+//\r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+\r
+// Flags: --expose-debug-as debug\r
+// Get the Debug object exposed from the debug context global object.\r
+Debug = debug.Debug\r
+\r
+var listenerComplete = false;\r
+var exception = false;\r
+\r
+function listener(event, exec_state, event_data, data) {\r
+ try {\r
+ if (event == Debug.DebugEvent.Break) {\r
+ // Get the debug command processor.\r
+ var dcp = exec_state.debugCommandProcessor();\r
+\r
+ var request = {\r
+ seq: 0,\r
+ type: 'request',\r
+ command: 'evaluate',\r
+ arguments: {\r
+ expression: 'a',\r
+ frame: 0\r
+ }\r
+ };\r
+ request = JSON.stringify(request);\r
+\r
+ var resp = dcp.processDebugJSONRequest(request);\r
+ var response = JSON.parse(resp);\r
+ assertTrue(response.success, 'Command failed: ' + resp);\r
+ assertEquals('object', response.body.type);\r
+ assertEquals('Object', response.body.className);\r
+\r
+ // Indicate that all was processed.\r
+ listenerComplete = true;\r
+ }\r
+ } catch (e) {\r
+ exception = e\r
+ };\r
+};\r
+\r
+// Add the debug event listener.\r
+Debug.setListener(listener);\r
+\r
+function callDebugger() {\r
+ // Add set constructor field to a non-function value.\r
+ var a = {constructor:true};\r
+ debugger;\r
+}\r
+\r
+callDebugger();\r
+\r
+\r
+// Make sure that the debug event listener vas invoked.\r
+assertFalse(exception, "exception in listener")\r
+assertTrue(listenerComplete, "listener did not run to completion");\r