1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/js1_5/Array/regress-310351.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,54 @@ 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 = 310351; 1.11 +var summary = 'Convert host "list" objects to arrays'; 1.12 +var actual = ''; 1.13 +var expect = ''; 1.14 + 1.15 +printBugNumber(BUGNUMBER); 1.16 +printStatus (summary); 1.17 + 1.18 +var nodeList = []; 1.19 +if (typeof document != 'undefined') 1.20 +{ 1.21 + nodeList = document.getElementsByTagName('*'); 1.22 +} 1.23 +else 1.24 +{ 1.25 + printStatus('test using dummy array since no document available'); 1.26 +} 1.27 + 1.28 +var array = Array.prototype.slice.call(nodeList, 0); 1.29 + 1.30 +expect = 'Array'; 1.31 +actual = array.constructor.name; 1.32 + 1.33 +// nodeList is live and may change 1.34 +var saveLength = nodeList.length; 1.35 + 1.36 +reportCompare(expect, actual, summary + ': constructor test'); 1.37 + 1.38 +expect = saveLength; 1.39 +actual = array.length; 1.40 + 1.41 +reportCompare(expect, actual, summary + ': length test'); 1.42 +expect = true; 1.43 +actual = true; 1.44 + 1.45 +for (var i = 0; i < saveLength; i++) 1.46 +{ 1.47 + if (array[i] != nodeList[i]) 1.48 + { 1.49 + actual = false; 1.50 + summary += ' Comparison failed: array[' + i + ']=' + array[i] + 1.51 + ', nodeList[' + i + ']=' + nodeList[i]; 1.52 + break; 1.53 + } 1.54 +} 1.55 + 1.56 +reportCompare(expect, actual, summary + ': identical elements test'); 1.57 +