js/src/builtin/Map.js

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 /* ES6 20121122 draft 15.14.4.4. */
     7 function MapForEach(callbackfn, thisArg = undefined) {
     8     /* Step 1-2. */
     9     var M = this;
    10     if (!IsObject(M))
    11         ThrowError(JSMSG_BAD_TYPE, typeof M);
    13     /* Step 3-4. */
    14     try {
    15         callFunction(std_Map_has, M);
    16     } catch (e) {
    17         ThrowError(JSMSG_BAD_TYPE, typeof M);
    18     }
    20     /* Step 5. */
    21     if (!IsCallable(callbackfn))
    22         ThrowError(JSMSG_NOT_FUNCTION, DecompileArg(0, callbackfn));
    24     /* Step 6-8. */
    25     var entries = callFunction(std_Map_iterator, M);
    26     while (true) {
    27         var result = callFunction(std_Map_iterator_next, entries);
    28         if (result.done)
    29             break;
    30         var entry = result.value;
    31         callFunction(callbackfn, thisArg, entry[1], entry[0], M);
    32     }
    33 }

mercurial