149edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// Copyright 2011 the V8 project authors. All rights reserved. 249edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// Redistribution and use in source and binary forms, with or without 349edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// modification, are permitted provided that the following conditions are 449edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// met: 549edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// 649edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// * Redistributions of source code must retain the above copyright 749edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// notice, this list of conditions and the following disclaimer. 849edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// * Redistributions in binary form must reproduce the above 949edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// copyright notice, this list of conditions and the following 1049edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// disclaimer in the documentation and/or other materials provided 1149edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// with the distribution. 1249edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// * Neither the name of Google Inc. nor the names of its 1349edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// contributors may be used to endorse or promote products derived 1449edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// from this software without specific prior written permission. 1549edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// 1649edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1749edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1849edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1949edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2049edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2149edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2249edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2349edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2449edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2549edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2649edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2749edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org 2849edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// Test that we do not try to create prototypes on objects that has the, 2949edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org// should_have_prototype flag set to false. 3049edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org 3149edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org__defineSetter__.__proto__ = function() {}; 3249edbdf52640c88918f8e6638ab4965819eb1dfekmillikin@chromium.org__defineSetter__['prototype'] 333a5fd78f0ca6c2827bb05f69a373d152a9ce6ff3fschneider@chromium.org 343a5fd78f0ca6c2827bb05f69a373d152a9ce6ff3fschneider@chromium.orgeval.__proto__ = function () { }; 353a5fd78f0ca6c2827bb05f69a373d152a9ce6ff3fschneider@chromium.orgeval['prototype'] = {}; 363a5fd78f0ca6c2827bb05f69a373d152a9ce6ff3fschneider@chromium.org 373a5fd78f0ca6c2827bb05f69a373d152a9ce6ff3fschneider@chromium.org// Test that we are compatible with Safari on prototypes set locally and 383a5fd78f0ca6c2827bb05f69a373d152a9ce6ff3fschneider@chromium.org// on the actual prototype set using __proto__ on objects that has the 393a5fd78f0ca6c2827bb05f69a373d152a9ce6ff3fschneider@chromium.org// should_have_prototype set to false. 403a5fd78f0ca6c2827bb05f69a373d152a9ce6ff3fschneider@chromium.orgfunction f() { return 42; } 413a5fd78f0ca6c2827bb05f69a373d152a9ce6ff3fschneider@chromium.orgf.prototype = 43; 423a5fd78f0ca6c2827bb05f69a373d152a9ce6ff3fschneider@chromium.org__defineGetter__.__proto__ = f; 433a5fd78f0ca6c2827bb05f69a373d152a9ce6ff3fschneider@chromium.org 443a5fd78f0ca6c2827bb05f69a373d152a9ce6ff3fschneider@chromium.org// Regression test for not returning undefined. 453a5fd78f0ca6c2827bb05f69a373d152a9ce6ff3fschneider@chromium.orgassertEquals(__defineGetter__.prototype, 43); 463a5fd78f0ca6c2827bb05f69a373d152a9ce6ff3fschneider@chromium.org 473a5fd78f0ca6c2827bb05f69a373d152a9ce6ff3fschneider@chromium.org// Regression test for not crashing. 483a5fd78f0ca6c2827bb05f69a373d152a9ce6ff3fschneider@chromium.org__defineGetter__.prototype = "foo"; 493a5fd78f0ca6c2827bb05f69a373d152a9ce6ff3fschneider@chromium.orgassertEquals(__defineGetter__.prototype, "foo"); 50