js/src/jit-test/tests/for-of/proxy-2.js

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

     1 // Basic for-of test with Proxy whose iterator method is a generator.
     3 var arr = ['a', 'b', 'c', 'd'];
     4 var proxy = Proxy.create({
     5     getPropertyDescriptor: function (name) {
     6         if (name == 'iterator') {
     7             return {
     8                 configurable: false,
     9                 enumerable: false,
    10                 writeable: false,
    11                 value:  function () {
    12                     for (var i = 0; i < arr.length; i++)
    13                         yield arr[i];
    14                 }
    15             };
    16         }
    18         // Otherwise, inherit the property from arr.
    19         for (var obj = arr; obj; obj = Object.getPrototypeOf(obj)) {
    20             var desc = Object.getOwnPropertyDescriptor(obj, name);
    21             if (desc)
    22                 return desc;
    23         }
    24         return undefined;
    25     }
    26 });
    28 for (var i = 0; i < 2; i++)
    29     assertEq([v for (v of proxy)].join(","), "a,b,c,d");

mercurial