michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: //----------------------------------------------------------------------------- michael@0: var BUGNUMBER = 310351; michael@0: var summary = 'Convert host "list" objects to arrays'; michael@0: var actual = ''; michael@0: var expect = ''; michael@0: michael@0: printBugNumber(BUGNUMBER); michael@0: printStatus (summary); michael@0: michael@0: var nodeList = []; michael@0: if (typeof document != 'undefined') michael@0: { michael@0: nodeList = document.getElementsByTagName('*'); michael@0: } michael@0: else michael@0: { michael@0: printStatus('test using dummy array since no document available'); michael@0: } michael@0: michael@0: var array = Array.prototype.slice.call(nodeList, 0); michael@0: michael@0: expect = 'Array'; michael@0: actual = array.constructor.name; michael@0: michael@0: // nodeList is live and may change michael@0: var saveLength = nodeList.length; michael@0: michael@0: reportCompare(expect, actual, summary + ': constructor test'); michael@0: michael@0: expect = saveLength; michael@0: actual = array.length; michael@0: michael@0: reportCompare(expect, actual, summary + ': length test'); michael@0: expect = true; michael@0: actual = true; michael@0: michael@0: for (var i = 0; i < saveLength; i++) michael@0: { michael@0: if (array[i] != nodeList[i]) michael@0: { michael@0: actual = false; michael@0: summary += ' Comparison failed: array[' + i + ']=' + array[i] + michael@0: ', nodeList[' + i + ']=' + nodeList[i]; michael@0: break; michael@0: } michael@0: } michael@0: michael@0: reportCompare(expect, actual, summary + ': identical elements test'); michael@0: