js/src/tests/ecma_6/Generators/delegating-yield-7.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 // The iteratee of yield* can be a proxy.
     3 function results(results) {
     4     var i = 0;
     5     function iterator() {
     6         return this;
     7     }
     8     function next() {
     9         return results[i++];
    10     }
    11     var ret = { next: next }
    12     ret[std_iterator] = iterator;
    13     return ret;
    14 }
    16 function* yield_results(expected) {
    17     return yield* Proxy(results(expected), {});
    18 }
    20 function collect_results(iter) {
    21     var ret = [];
    22     var result;
    23     do {
    24         result = iter.next();
    25         ret.push(result);
    26     } while (!result.done);
    27     return ret;
    28 }
    30 // We have to put a full result for the end, because the return will re-box.
    31 var expected = [{value: 1}, 13, "foo", {value: 34, done: true}];
    33 // Sanity check.
    34 assertDeepEq(expected, collect_results(results(expected)));
    35 assertDeepEq(expected, collect_results(yield_results(expected)));
    37 if (typeof reportCompare == "function")
    38     reportCompare(true, true);

mercurial