js/src/tests/js1_8_5/extensions/file-mapped-arraybuffers.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 // |reftest| skip-if(!xulRuntime.shell)
     2 // Any copyright is dedicated to the Public Domain.
     3 // http://creativecommons.org/licenses/publicdomain/
     5 function viewToString(view)
     6 {
     7   return String.fromCharCode.apply(null, view);
     8 }
    10 function assertThrows(f, wantException)
    11 {
    12     try {
    13       f();
    14       assertEq(true, false, "expected " + wantException + " exception");
    15     } catch (e) {
    16       assertEq(e.name, wantException.name, e.toString());
    17     }
    18 }
    20 function test() {
    21     var filename = "file-mapped-arraybuffers.txt";
    22     var buffer = createMappedArrayBuffer(filename);
    23     var view = new Uint8Array(buffer);
    24     assertEq(viewToString(view), "01234567abcdefghijkl");
    26     var buffer2 = createMappedArrayBuffer(filename, 8);
    27     view = new Uint8Array(buffer2);
    28     assertEq(viewToString(view), "abcdefghijkl");
    30     var buffer3 = createMappedArrayBuffer(filename, 0, 8);
    31     view = new Uint8Array(buffer3);
    32     assertEq(viewToString(view), "01234567");
    34     // Check that invalid sizes and offsets are caught
    35     assertThrows(() => createMappedArrayBuffer("empty.txt", 8), RangeError);
    36     assertThrows(() => createMappedArrayBuffer("empty.txt", 0, 8), Error);
    37 }
    39 test();
    40 reportCompare(0, 0, 'ok');

mercurial