Check that constructor is a FunctionMirror before calling .name(), otherwise we may...
authoryurys@chromium.org <yurys@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 13 Oct 2009 14:28:09 +0000 (14:28 +0000)
committeryurys@chromium.org <yurys@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 13 Oct 2009 14:28:09 +0000 (14:28 +0000)
Review URL: http://codereview.chromium.org/271053

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3057 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/mirror-delay.js
test/mjsunit/debug-evaluate-bool-constructor.js [new file with mode: 0644]

index c4ab7b8ee85df3c6c3712dcd694c36b24d4f13ac..cde553432149a14b4293eede4d4dc19b5dfef224 100644 (file)
@@ -764,7 +764,7 @@ ObjectMirror.prototype.referencedBy = function(opt_max_objects) {
 ObjectMirror.prototype.toText = function() {
   var name;
   var ctor = this.constructorFunction();
-  if (ctor.isUndefined()) {
+  if (!ctor.isFunction()) {
     name = this.className();
   } else {
     name = ctor.name();
diff --git a/test/mjsunit/debug-evaluate-bool-constructor.js b/test/mjsunit/debug-evaluate-bool-constructor.js
new file mode 100644 (file)
index 0000000..809a5cc
--- /dev/null
@@ -0,0 +1,80 @@
+// 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