tor-browser

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

elements-added-after.js (1067B)


      1 // Copyright 2015 Microsoft Corporation. All rights reserved.
      2 // This code is governed by the license found in the LICENSE file.
      3 
      4 /*---
      5 description: Elements added after the call to from
      6 esid: sec-array.from
      7 ---*/
      8 
      9 var arrayIndex = -1;
     10 var originalLength = 7;
     11 var obj = {
     12  length: originalLength,
     13  0: 2,
     14  1: 4,
     15  2: 8,
     16  3: 16,
     17  4: 32,
     18  5: 64,
     19  6: 128
     20 };
     21 var array = [2, 4, 8, 16, 32, 64, 128];
     22 
     23 function mapFn(value, index) {
     24  arrayIndex++;
     25  assert.sameValue(value, obj[arrayIndex], 'The value of value is expected to equal the value of obj[arrayIndex]');
     26  assert.sameValue(index, arrayIndex, 'The value of index is expected to equal the value of arrayIndex');
     27  obj[originalLength + arrayIndex] = 2 * arrayIndex + 1;
     28 
     29  return obj[arrayIndex];
     30 }
     31 
     32 
     33 var a = Array.from(obj, mapFn);
     34 assert.sameValue(a.length, array.length, 'The value of a.length is expected to equal the value of array.length');
     35 
     36 for (var j = 0; j < a.length; j++) {
     37  assert.sameValue(a[j], array[j], 'The value of a[j] is expected to equal the value of array[j]');
     38 }
     39 
     40 reportCompare(0, 0);