js/xpconnect/tests/unit/test_blob2.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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