11805e21b0aece8c05f4960a5c0751c4463557891fschneider@chromium.org// Copyright 2011 the V8 project authors. All rights reserved.
21805e21b0aece8c05f4960a5c0751c4463557891fschneider@chromium.org// Redistribution and use in source and binary forms, with or without
31805e21b0aece8c05f4960a5c0751c4463557891fschneider@chromium.org// modification, are permitted provided that the following conditions are
41805e21b0aece8c05f4960a5c0751c4463557891fschneider@chromium.org// met:
51805e21b0aece8c05f4960a5c0751c4463557891fschneider@chromium.org//
61805e21b0aece8c05f4960a5c0751c4463557891fschneider@chromium.org//     * Redistributions of source code must retain the above copyright
71805e21b0aece8c05f4960a5c0751c4463557891fschneider@chromium.org//       notice, this list of conditions and the following disclaimer.
81805e21b0aece8c05f4960a5c0751c4463557891fschneider@chromium.org//     * Redistributions in binary form must reproduce the above
91805e21b0aece8c05f4960a5c0751c4463557891fschneider@chromium.org//       copyright notice, this list of conditions and the following
101805e21b0aece8c05f4960a5c0751c4463557891fschneider@chromium.org//       disclaimer in the documentation and/or other materials provided
111805e21b0aece8c05f4960a5c0751c4463557891fschneider@chromium.org//       with the distribution.
121805e21b0aece8c05f4960a5c0751c4463557891fschneider@chromium.org//     * Neither the name of Google Inc. nor the names of its
131805e21b0aece8c05f4960a5c0751c4463557891fschneider@chromium.org//       contributors may be used to endorse or promote products derived
141805e21b0aece8c05f4960a5c0751c4463557891fschneider@chromium.org//       from this software without specific prior written permission.
151805e21b0aece8c05f4960a5c0751c4463557891fschneider@chromium.org//
161805e21b0aece8c05f4960a5c0751c4463557891fschneider@chromium.org// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
171805e21b0aece8c05f4960a5c0751c4463557891fschneider@chromium.org// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
181805e21b0aece8c05f4960a5c0751c4463557891fschneider@chromium.org// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
191805e21b0aece8c05f4960a5c0751c4463557891fschneider@chromium.org// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
201805e21b0aece8c05f4960a5c0751c4463557891fschneider@chromium.org// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
211805e21b0aece8c05f4960a5c0751c4463557891fschneider@chromium.org// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
221805e21b0aece8c05f4960a5c0751c4463557891fschneider@chromium.org// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
231805e21b0aece8c05f4960a5c0751c4463557891fschneider@chromium.org// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
241805e21b0aece8c05f4960a5c0751c4463557891fschneider@chromium.org// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
251805e21b0aece8c05f4960a5c0751c4463557891fschneider@chromium.org// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
261805e21b0aece8c05f4960a5c0751c4463557891fschneider@chromium.org// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
271805e21b0aece8c05f4960a5c0751c4463557891fschneider@chromium.org
281805e21b0aece8c05f4960a5c0751c4463557891fschneider@chromium.org// Test that the caller and arguments objects are not available on native
291805e21b0aece8c05f4960a5c0751c4463557891fschneider@chromium.org// functions.
301805e21b0aece8c05f4960a5c0751c4463557891fschneider@chromium.org
311805e21b0aece8c05f4960a5c0751c4463557891fschneider@chromium.orgfunction testfn(f) { return [1].map(f)[0]; }
321805e21b0aece8c05f4960a5c0751c4463557891fschneider@chromium.orgfunction foo() { return [].map.caller; }
33c2e08d7d6b03e672e13fc3bf274a292009decce6machenbach@chromium.orgassertThrows(function() { testfn(foo); } );
341805e21b0aece8c05f4960a5c0751c4463557891fschneider@chromium.org
351805e21b0aece8c05f4960a5c0751c4463557891fschneider@chromium.org// Try to delete the caller property (to make sure that we can't get to the
361805e21b0aece8c05f4960a5c0751c4463557891fschneider@chromium.org// caller accessor on the prototype.
371805e21b0aece8c05f4960a5c0751c4463557891fschneider@chromium.orgdelete Array.prototype.map.caller;
38c2e08d7d6b03e672e13fc3bf274a292009decce6machenbach@chromium.orgassertThrows(function() { testfn(foo); } );
391805e21b0aece8c05f4960a5c0751c4463557891fschneider@chromium.org
401805e21b0aece8c05f4960a5c0751c4463557891fschneider@chromium.org// Redo tests with arguments object.
411805e21b0aece8c05f4960a5c0751c4463557891fschneider@chromium.orgfunction testarguments(f) { return [1].map(f)[0]; }
421805e21b0aece8c05f4960a5c0751c4463557891fschneider@chromium.orgfunction bar() { return [].map.arguments; }
43c2e08d7d6b03e672e13fc3bf274a292009decce6machenbach@chromium.orgassertThrows(function() { testarguments(bar); } );
441805e21b0aece8c05f4960a5c0751c4463557891fschneider@chromium.org
451805e21b0aece8c05f4960a5c0751c4463557891fschneider@chromium.org// Try to delete the arguments property (to make sure that we can't get to the
461805e21b0aece8c05f4960a5c0751c4463557891fschneider@chromium.org// caller accessor on the prototype.
471805e21b0aece8c05f4960a5c0751c4463557891fschneider@chromium.orgdelete Array.prototype.map.arguments;
48c2e08d7d6b03e672e13fc3bf274a292009decce6machenbach@chromium.orgassertThrows(function() { testarguments(bar); } );
49