js/xpconnect/tests/unit/test_blob2.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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