js/xpconnect/tests/unit/test_blob2.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 /* 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 const Ci = Components.interfaces;
     7 function run_test() {
     8   // throw if anything goes wrong
     9   let testContent = "<a id=\"a\"><b id=\"b\">hey!<\/b><\/a>";
    10   // should be able to construct a file
    11   var f1 = Blob([testContent], {"type" : "text/xml"});
    12   // with either constructor syntax
    13   var f2 = new Blob([testContent], {"type" : "text/xml"});
    15   // do some tests
    16   do_check_true(f1 instanceof Ci.nsIDOMBlob, "Should be a DOM Blob");
    17   do_check_true(f2 instanceof Ci.nsIDOMBlob, "Should be a DOM Blob");
    19   do_check_true(!(f1 instanceof Ci.nsIDOMFile), "Should not be a DOM File");
    20   do_check_true(!(f2 instanceof Ci.nsIDOMFile), "Should not be a DOM File");
    22   do_check_true(f1.type == "text/xml", "Wrong type");
    23   do_check_true(f2.type == "text/xml", "Wrong type");
    25   do_check_true(f1.size == testContent.length, "Wrong content size");
    26   do_check_true(f2.size == testContent.length, "Wrong content size");
    28   var f3 = new Blob();
    29   do_check_true(f3.size == 0, "Wrong size");
    30   do_check_true(f3.type == "", "Wrong type");
    32   var threw = false;
    33   try {
    34     // Needs a valid ctor argument
    35     var f3 = Blob(Date(132131532));
    36   } catch (e) {
    37     threw = true;
    38   }
    39   do_check_true(threw, "Passing a random object should fail");
    40 }

mercurial