1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/js1_5/extensions/regress-434837-01.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,90 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +//----------------------------------------------------------------------------- 1.10 +var BUGNUMBER = 434837; 1.11 +var summary = '|this| in accessors in prototype chain of array'; 1.12 +var actual = ''; 1.13 +var expect = ''; 1.14 + 1.15 + 1.16 +//----------------------------------------------------------------------------- 1.17 +test(); 1.18 +//----------------------------------------------------------------------------- 1.19 + 1.20 +function test() 1.21 +{ 1.22 + enterFunc ('test'); 1.23 + printBugNumber(BUGNUMBER); 1.24 + printStatus (summary); 1.25 + 1.26 + try 1.27 + { 1.28 + expect = true; 1.29 + actual = null; 1.30 + x = [ "one", "two" ]; 1.31 + Array.prototype.__defineGetter__('test1', function() { actual = (this === x); }); 1.32 + x.test1; 1.33 + } 1.34 + catch(ex) 1.35 + { 1.36 + actual = ex + ''; 1.37 + } 1.38 + reportCompare(expect, actual, summary + ': x.test1'); 1.39 + 1.40 + try 1.41 + { 1.42 + expect = false; 1.43 + actual = null; 1.44 + Array.prototype.__defineGetter__('test2', function() { actual = (this === Array.prototype) }); 1.45 + x.test2; 1.46 + } 1.47 + catch(ex) 1.48 + { 1.49 + actual = ex + ''; 1.50 + } 1.51 + reportCompare(expect, actual, summary + ': x.test2'); 1.52 + 1.53 + Array.prototype.__defineGetter__('test3', function() { actual = (this === x) }); 1.54 + Array.prototype.__defineSetter__('test3', function() { actual = (this === x) }); 1.55 + 1.56 + try 1.57 + { 1.58 + expect = true; 1.59 + actual = null; 1.60 + x.test3; 1.61 + } 1.62 + catch(ex) 1.63 + { 1.64 + actual = ex + ''; 1.65 + } 1.66 + reportCompare(expect, actual, summary + ': x.test3 (1)'); 1.67 + 1.68 + try 1.69 + { 1.70 + expect = true; 1.71 + actual = null; 1.72 + x.test3 = 5; 1.73 + } 1.74 + catch(ex) 1.75 + { 1.76 + actual = ex + ''; 1.77 + } 1.78 + reportCompare(expect, actual, summary + ': x.test3 = 5'); 1.79 + 1.80 + try 1.81 + { 1.82 + expect = true; 1.83 + actual = null; 1.84 + x.test3; 1.85 + } 1.86 + catch(ex) 1.87 + { 1.88 + actual = ex + ''; 1.89 + } 1.90 + reportCompare(expect, actual, summary + ': x.test3 (2)'); 1.91 + 1.92 + exitFunc ('test'); 1.93 +}