tor-browser

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

testDirectProxySetArray1.js (633B)


      1 // Assigning to a missing array element (a hole) via a proxy with no set handler
      2 // calls the defineProperty handler.
      3 
      4 function test(id) {
      5    var arr = [, 1, 2, 3];
      6    var p = new Proxy(arr, {
      7        defineProperty(t, id, desc) {
      8            hits++;
      9            assertEq(desc.value, "ponies");
     10            assertEq(desc.enumerable, true);
     11            assertEq(desc.configurable, true);
     12            assertEq(desc.writable, true);
     13            return true;
     14        }
     15    });
     16    var hits = 0;
     17    p[id] = "ponies";
     18    assertEq(hits, 1);
     19    assertEq(id in arr, false);
     20    assertEq(arr.length, 4);
     21 }
     22 
     23 test(0);
     24 test(4);
     25 test("str");