</div>
<pre id="test">
<script class="testbody" type="text/javascript"> "use strict";
/** Test for Bug 721569 **/ var blob = new Blob();
ok(blob, "Blob should exist");
ok(blob.size !== undefined, "Blob should have a size property");
ok(blob.type !== undefined, "Blob should have a type property");
ok(blob.slice, "Blob should have a slice method");
blob = new Blob([], {type: null});
ok(blob, "Blob should exist");
is(blob.type, "null", "Blob type should be stringified");
blob = new Blob([], {type: undefined});
ok(blob, "Blob should exist");
is(blob.type, "", "Blob type should be treated as missing");
try {
blob = new Blob([]);
ok(true, "an empty blobParts argument should not throw");
} catch(e) {
ok(false, "NOT REACHED");
}
try {
blob = new Blob(null);
ok(false, "NOT REACHED");
} catch(e) {
ok(true, "a null blobParts member should throw");
}
try {
blob = new Blob([], null);
ok(true, "a null options member should not throw");
} catch(e) {
ok(false, "NOT REACHED");
}
try {
blob = new Blob([], undefined);
ok(true, "an undefined options member should not throw");
} catch(e) {
ok(false, "NOT REACHED");
}
try {
blob = new Blob([], false);
ok(false, "NOT REACHED");
} catch(e) {
ok(true, "a boolean options member should throw");
}
try {
blob = new Blob([], 0);
ok(false, "NOT REACHED");
} catch(e) {
ok(true, "a numeric options member should throw");
}
try {
blob = new Blob([], "");
ok(false, "NOT REACHED");
} catch(e) {
ok(true, "a string options member should throw");
}
/** Test for dictionary initialization order **/
(function() { var o = {}; var p = {type: "text/plain", endings: "transparent"}; var called = [];
function add_to_called(n) {
called.push(n);
return p[n];
}
["type", "endings"].forEach(function(n) { Object.defineProperty(o, n, { get: add_to_called.bind(null, n) });
}); var b = new Blob([], o);
is(JSON.stringify(called), JSON.stringify(["endings", "type"]), "dictionary members should be get in lexicographical order");
})();
let blob1 = new Blob(["squiggle"]);
ok(blob1 instanceof Blob, "Blob constructor should produce Blobs");
ok(!(blob1 instanceof File), "Blob constructor should not produce Files");
is(blob1.type, "", "Blob constructor with no options should return Blob with empty type");
is(blob1.size, 8, "Blob constructor should return Blob with correct size");
let blob2 = new Blob(["steak"], {type: "content/type"});
ok(blob2 instanceof Blob, "Blob constructor should produce Blobs");
ok(!(blob2 instanceof File), "Blob constructor should not produce Files");
is(blob2.type, "content/type", "Blob constructor with a type option should return Blob with the type");
is(blob2.size, 5, "Blob constructor should return Blob with correct size");
let aB = new ArrayBuffer(16); var int8View = new Int8Array(aB);
for (var i = 0; i < 16; i++) {
int8View[i] = i+65;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.