js/src/tests/ecma_6/Generators/delegating-yield-12.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 // yield* calls @@iterator on the iterable to produce the iterator.
     3 var log = '';
     5 function IteratorWrapper(iterator) {
     6     return {
     7         next: function (val) {
     8             log += 'n';
     9             return iterator.next(val);
    10         },
    12         throw: function (exn) {
    13             log += 't';
    14             return iterator.throw(exn);
    15         }
    16     };
    17 }
    19 function IterableWrapper(iterable) {
    20     var ret = {};
    22     ret[std_iterator] = function () {
    23         log += 'i';
    24         return IteratorWrapper(iterable[std_iterator]());
    25     }
    27     return ret;
    28 }
    30 function* delegate(iter) { return yield* iter; }
    32 var iter = delegate(IterableWrapper([1, 2, 3]));
    33 assertIteratorNext(iter, 1);
    34 assertIteratorNext(iter, 2);
    35 assertIteratorNext(iter, 3);
    36 assertIteratorDone(iter, undefined);
    38 assertEq(log, 'innnn');
    40 iter = delegate([1, 2, 3]);
    41 assertIteratorNext(iter, 1);
    42 assertIteratorNext(iter, 2);
    43 assertIteratorNext(iter, 3);
    44 assertIteratorDone(iter, undefined);
    46 assertEq(log, 'innnn');
    48 if (typeof reportCompare == "function")
    49     reportCompare(true, true);

mercurial