michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: const Ci = Components.interfaces; michael@0: michael@0: function run_test() { michael@0: // throw if anything goes wrong michael@0: let testContent = "hey!<\/b><\/a>"; michael@0: // should be able to construct a file michael@0: var f1 = Blob([testContent], {"type" : "text/xml"}); michael@0: // with either constructor syntax michael@0: var f2 = new Blob([testContent], {"type" : "text/xml"}); michael@0: michael@0: // do some tests michael@0: do_check_true(f1 instanceof Ci.nsIDOMBlob, "Should be a DOM Blob"); michael@0: do_check_true(f2 instanceof Ci.nsIDOMBlob, "Should be a DOM Blob"); michael@0: michael@0: do_check_true(!(f1 instanceof Ci.nsIDOMFile), "Should not be a DOM File"); michael@0: do_check_true(!(f2 instanceof Ci.nsIDOMFile), "Should not be a DOM File"); michael@0: michael@0: do_check_true(f1.type == "text/xml", "Wrong type"); michael@0: do_check_true(f2.type == "text/xml", "Wrong type"); michael@0: michael@0: do_check_true(f1.size == testContent.length, "Wrong content size"); michael@0: do_check_true(f2.size == testContent.length, "Wrong content size"); michael@0: michael@0: var f3 = new Blob(); michael@0: do_check_true(f3.size == 0, "Wrong size"); michael@0: do_check_true(f3.type == "", "Wrong type"); michael@0: michael@0: var threw = false; michael@0: try { michael@0: // Needs a valid ctor argument michael@0: var f3 = Blob(Date(132131532)); michael@0: } catch (e) { michael@0: threw = true; michael@0: } michael@0: do_check_true(threw, "Passing a random object should fail"); michael@0: }