tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

regress-310351.js (1366B)


      1 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
      2 /* This Source Code Form is subject to the terms of the Mozilla Public
      3 * License, v. 2.0. If a copy of the MPL was not distributed with this
      4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      5 
      6 //-----------------------------------------------------------------------------
      7 var BUGNUMBER = 310351;
      8 var summary = 'Convert host "list" objects to arrays';
      9 var actual = '';
     10 var expect = '';
     11 
     12 printBugNumber(BUGNUMBER);
     13 printStatus (summary);
     14 
     15 var nodeList = [];
     16 if (typeof document != 'undefined')
     17 {
     18  nodeList = document.getElementsByTagName('*');
     19 }
     20 else
     21 {
     22  printStatus('test using dummy array since no document available');
     23 }
     24 
     25 var array = Array.prototype.slice.call(nodeList, 0);
     26 
     27 expect = 'Array';
     28 actual = array.constructor.name;
     29 
     30 // nodeList is live and may change
     31 var saveLength = nodeList.length;
     32 
     33 reportCompare(expect, actual, summary + ': constructor test');
     34 
     35 expect = saveLength;
     36 actual = array.length;
     37 
     38 reportCompare(expect, actual, summary + ': length test');
     39 expect = true;
     40 actual = true;
     41 
     42 for (var i = 0; i < saveLength; i++)
     43 {
     44  if (array[i] != nodeList[i])
     45  {
     46    actual = false;
     47    summary += ' Comparison failed: array[' + i + ']=' + array[i] +
     48      ', nodeList[' + i + ']=' + nodeList[i];
     49    break;
     50  }
     51 }
     52 
     53 reportCompare(expect, actual, summary + ': identical elements test');