1fb732b17922ea75830be4db6b80534c4827d8a55jkummerow@chromium.org// Copyright 2013 the V8 project authors. All rights reserved. 2fb732b17922ea75830be4db6b80534c4827d8a55jkummerow@chromium.org// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 3fb732b17922ea75830be4db6b80534c4827d8a55jkummerow@chromium.org// 4fb732b17922ea75830be4db6b80534c4827d8a55jkummerow@chromium.org// Redistribution and use in source and binary forms, with or without 5fb732b17922ea75830be4db6b80534c4827d8a55jkummerow@chromium.org// modification, are permitted provided that the following conditions 6fb732b17922ea75830be4db6b80534c4827d8a55jkummerow@chromium.org// are met: 7fb732b17922ea75830be4db6b80534c4827d8a55jkummerow@chromium.org// 1. Redistributions of source code must retain the above copyright 8fb732b17922ea75830be4db6b80534c4827d8a55jkummerow@chromium.org// notice, this list of conditions and the following disclaimer. 9fb732b17922ea75830be4db6b80534c4827d8a55jkummerow@chromium.org// 2. Redistributions in binary form must reproduce the above copyright 10fb732b17922ea75830be4db6b80534c4827d8a55jkummerow@chromium.org// notice, this list of conditions and the following disclaimer in the 11fb732b17922ea75830be4db6b80534c4827d8a55jkummerow@chromium.org// documentation and/or other materials provided with the distribution. 12fb732b17922ea75830be4db6b80534c4827d8a55jkummerow@chromium.org// 13fb732b17922ea75830be4db6b80534c4827d8a55jkummerow@chromium.org// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY 14fb732b17922ea75830be4db6b80534c4827d8a55jkummerow@chromium.org// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15fb732b17922ea75830be4db6b80534c4827d8a55jkummerow@chromium.org// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16fb732b17922ea75830be4db6b80534c4827d8a55jkummerow@chromium.org// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY 17fb732b17922ea75830be4db6b80534c4827d8a55jkummerow@chromium.org// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 18fb732b17922ea75830be4db6b80534c4827d8a55jkummerow@chromium.org// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 19fb732b17922ea75830be4db6b80534c4827d8a55jkummerow@chromium.org// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 20fb732b17922ea75830be4db6b80534c4827d8a55jkummerow@chromium.org// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21fb732b17922ea75830be4db6b80534c4827d8a55jkummerow@chromium.org// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 22fb732b17922ea75830be4db6b80534c4827d8a55jkummerow@chromium.org// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23fb732b17922ea75830be4db6b80534c4827d8a55jkummerow@chromium.org 24fb732b17922ea75830be4db6b80534c4827d8a55jkummerow@chromium.orgdescription( 25fb732b17922ea75830be4db6b80534c4827d8a55jkummerow@chromium.org"Tests that defining a setter on the prototype of an object used for indexed storage works." 26fb732b17922ea75830be4db6b80534c4827d8a55jkummerow@chromium.org); 27fb732b17922ea75830be4db6b80534c4827d8a55jkummerow@chromium.org 28fb732b17922ea75830be4db6b80534c4827d8a55jkummerow@chromium.orgfunction Cons() { 29fb732b17922ea75830be4db6b80534c4827d8a55jkummerow@chromium.org} 30fb732b17922ea75830be4db6b80534c4827d8a55jkummerow@chromium.org 31fb732b17922ea75830be4db6b80534c4827d8a55jkummerow@chromium.orgvar ouches = 0; 32e8412be858dc48afaec4959e42c5932f71a7f29bmachenbach@chromium.orgCons.prototype.__defineSetter__("3", function() { ouches++; }); 33fb732b17922ea75830be4db6b80534c4827d8a55jkummerow@chromium.org 34fb732b17922ea75830be4db6b80534c4827d8a55jkummerow@chromium.orgfunction foo() { 35fb732b17922ea75830be4db6b80534c4827d8a55jkummerow@chromium.org var result = new Cons(); 36fb732b17922ea75830be4db6b80534c4827d8a55jkummerow@chromium.org result.length = 5; 37fb732b17922ea75830be4db6b80534c4827d8a55jkummerow@chromium.org for (var i = 0; i < result.length; ++i) 38fb732b17922ea75830be4db6b80534c4827d8a55jkummerow@chromium.org result[i] = i; 39fb732b17922ea75830be4db6b80534c4827d8a55jkummerow@chromium.org return result; 40fb732b17922ea75830be4db6b80534c4827d8a55jkummerow@chromium.org} 41fb732b17922ea75830be4db6b80534c4827d8a55jkummerow@chromium.org 42fb732b17922ea75830be4db6b80534c4827d8a55jkummerow@chromium.orgfor (var i = 0; i < 100; ++i) 43fb732b17922ea75830be4db6b80534c4827d8a55jkummerow@chromium.org shouldBe("\"" + Array.prototype.join.apply(foo(), [","]) + "\"", "\"0,1,2,,4\""); 44fb732b17922ea75830be4db6b80534c4827d8a55jkummerow@chromium.org 45fb732b17922ea75830be4db6b80534c4827d8a55jkummerow@chromium.orgshouldBe("ouches", "100"); 46