19a21ec41a2007f01ba18cf5fa48f7987e40e5109ulan@chromium.org// Copyright 2011 the V8 project authors. All rights reserved. 29a21ec41a2007f01ba18cf5fa48f7987e40e5109ulan@chromium.org// Redistribution and use in source and binary forms, with or without 39a21ec41a2007f01ba18cf5fa48f7987e40e5109ulan@chromium.org// modification, are permitted provided that the following conditions are 49a21ec41a2007f01ba18cf5fa48f7987e40e5109ulan@chromium.org// met: 59a21ec41a2007f01ba18cf5fa48f7987e40e5109ulan@chromium.org// 69a21ec41a2007f01ba18cf5fa48f7987e40e5109ulan@chromium.org// * Redistributions of source code must retain the above copyright 79a21ec41a2007f01ba18cf5fa48f7987e40e5109ulan@chromium.org// notice, this list of conditions and the following disclaimer. 89a21ec41a2007f01ba18cf5fa48f7987e40e5109ulan@chromium.org// * Redistributions in binary form must reproduce the above 99a21ec41a2007f01ba18cf5fa48f7987e40e5109ulan@chromium.org// copyright notice, this list of conditions and the following 109a21ec41a2007f01ba18cf5fa48f7987e40e5109ulan@chromium.org// disclaimer in the documentation and/or other materials provided 119a21ec41a2007f01ba18cf5fa48f7987e40e5109ulan@chromium.org// with the distribution. 129a21ec41a2007f01ba18cf5fa48f7987e40e5109ulan@chromium.org// * Neither the name of Google Inc. nor the names of its 139a21ec41a2007f01ba18cf5fa48f7987e40e5109ulan@chromium.org// contributors may be used to endorse or promote products derived 149a21ec41a2007f01ba18cf5fa48f7987e40e5109ulan@chromium.org// from this software without specific prior written permission. 159a21ec41a2007f01ba18cf5fa48f7987e40e5109ulan@chromium.org// 169a21ec41a2007f01ba18cf5fa48f7987e40e5109ulan@chromium.org// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 179a21ec41a2007f01ba18cf5fa48f7987e40e5109ulan@chromium.org// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 189a21ec41a2007f01ba18cf5fa48f7987e40e5109ulan@chromium.org// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 199a21ec41a2007f01ba18cf5fa48f7987e40e5109ulan@chromium.org// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 209a21ec41a2007f01ba18cf5fa48f7987e40e5109ulan@chromium.org// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 219a21ec41a2007f01ba18cf5fa48f7987e40e5109ulan@chromium.org// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 229a21ec41a2007f01ba18cf5fa48f7987e40e5109ulan@chromium.org// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 239a21ec41a2007f01ba18cf5fa48f7987e40e5109ulan@chromium.org// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 249a21ec41a2007f01ba18cf5fa48f7987e40e5109ulan@chromium.org// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 259a21ec41a2007f01ba18cf5fa48f7987e40e5109ulan@chromium.org// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 269a21ec41a2007f01ba18cf5fa48f7987e40e5109ulan@chromium.org// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 279a21ec41a2007f01ba18cf5fa48f7987e40e5109ulan@chromium.org 289a21ec41a2007f01ba18cf5fa48f7987e40e5109ulan@chromium.org// See: http://code.google.com/p/v8/issues/detail?id=1980 299a21ec41a2007f01ba18cf5fa48f7987e40e5109ulan@chromium.org 309a21ec41a2007f01ba18cf5fa48f7987e40e5109ulan@chromium.orgvar invalid_this = [ "invalid", 23, undefined, null ]; 319a21ec41a2007f01ba18cf5fa48f7987e40e5109ulan@chromium.orgfor (var i = 0; i < invalid_this.length; i++) { 329a21ec41a2007f01ba18cf5fa48f7987e40e5109ulan@chromium.org var exception = false; 339a21ec41a2007f01ba18cf5fa48f7987e40e5109ulan@chromium.org try { 349a21ec41a2007f01ba18cf5fa48f7987e40e5109ulan@chromium.org Error.prototype.toString.call(invalid_this[i]); 359a21ec41a2007f01ba18cf5fa48f7987e40e5109ulan@chromium.org } catch (e) { 369a21ec41a2007f01ba18cf5fa48f7987e40e5109ulan@chromium.org exception = true; 37fb37721ea34922d8758d5cb26ae465aaf241e6b6yangguo@chromium.org assertEquals("Error.prototype.toString called on non-object", e.message); 389a21ec41a2007f01ba18cf5fa48f7987e40e5109ulan@chromium.org } 399a21ec41a2007f01ba18cf5fa48f7987e40e5109ulan@chromium.org assertTrue(exception); 409a21ec41a2007f01ba18cf5fa48f7987e40e5109ulan@chromium.org} 41