gecko-dev/dom/file/tests/test_file_from_blob.html
Andrea Marchesini 8bbeee69cf Bug 1321261 - create dom/file for File APIs, r=qdot
--HG--
rename : dom/base/BlobSet.cpp => dom/file/BlobSet.cpp
rename : dom/base/BlobSet.h => dom/file/BlobSet.h
rename : dom/base/File.cpp => dom/file/File.cpp
rename : dom/base/File.h => dom/file/File.h
rename : dom/base/FileList.cpp => dom/file/FileList.cpp
rename : dom/base/FileList.h => dom/file/FileList.h
rename : dom/base/FileReader.cpp => dom/file/FileReader.cpp
rename : dom/base/FileReader.h => dom/file/FileReader.h
rename : dom/base/MultipartBlobImpl.cpp => dom/file/MultipartBlobImpl.cpp
rename : dom/base/MultipartBlobImpl.h => dom/file/MultipartBlobImpl.h
rename : dom/base/MutableBlobStorage.cpp => dom/file/MutableBlobStorage.cpp
rename : dom/base/MutableBlobStorage.h => dom/file/MutableBlobStorage.h
rename : dom/base/MutableBlobStreamListener.cpp => dom/file/MutableBlobStreamListener.cpp
rename : dom/base/MutableBlobStreamListener.h => dom/file/MutableBlobStreamListener.h
rename : dom/ipc/Blob.cpp => dom/file/ipc/Blob.cpp
rename : dom/ipc/BlobChild.h => dom/file/ipc/BlobChild.h
rename : dom/ipc/BlobParent.h => dom/file/ipc/BlobParent.h
rename : dom/ipc/BlobTypes.ipdlh => dom/file/ipc/BlobTypes.ipdlh
rename : dom/ipc/PBlob.ipdl => dom/file/ipc/PBlob.ipdl
rename : dom/ipc/PBlobStream.ipdl => dom/file/ipc/PBlobStream.ipdl
rename : dom/ipc/nsIRemoteBlob.h => dom/file/ipc/nsIRemoteBlob.h
rename : dom/base/nsHostObjectProtocolHandler.cpp => dom/file/nsHostObjectProtocolHandler.cpp
rename : dom/base/nsHostObjectProtocolHandler.h => dom/file/nsHostObjectProtocolHandler.h
rename : dom/base/nsHostObjectURI.cpp => dom/file/nsHostObjectURI.cpp
rename : dom/base/nsHostObjectURI.h => dom/file/nsHostObjectURI.h
rename : dom/base/nsIDOMBlob.idl => dom/file/nsIDOMBlob.idl
rename : dom/base/nsIDOMFileList.idl => dom/file/nsIDOMFileList.idl
rename : dom/base/test/create_file_objects.js => dom/file/tests/create_file_objects.js
rename : dom/base/test/file_blobURL_expiring.html => dom/file/tests/file_blobURL_expiring.html
rename : dom/base/test/file_mozfiledataurl_audio.ogg => dom/file/tests/file_mozfiledataurl_audio.ogg
rename : dom/base/test/file_mozfiledataurl_doc.html => dom/file/tests/file_mozfiledataurl_doc.html
rename : dom/base/test/file_mozfiledataurl_img.jpg => dom/file/tests/file_mozfiledataurl_img.jpg
rename : dom/base/test/file_mozfiledataurl_inner.html => dom/file/tests/file_mozfiledataurl_inner.html
rename : dom/base/test/file_mozfiledataurl_text.txt => dom/file/tests/file_mozfiledataurl_text.txt
rename : dom/base/test/file_nonascii_blob_url.html => dom/file/tests/file_nonascii_blob_url.html
rename : dom/base/test/fileapi_chromeScript.js => dom/file/tests/fileapi_chromeScript.js
rename : dom/base/test/fileutils.js => dom/file/tests/fileutils.js
rename : dom/base/test/test_blobURL_expiring.html => dom/file/tests/test_blobURL_expiring.html
rename : dom/base/test/test_blob_fragment_and_query.html => dom/file/tests/test_blob_fragment_and_query.html
rename : dom/base/test/test_blobconstructor.html => dom/file/tests/test_blobconstructor.html
rename : dom/base/test/test_file_from_blob.html => dom/file/tests/test_file_from_blob.html
rename : dom/base/test/test_file_negative_date.html => dom/file/tests/test_file_negative_date.html
rename : dom/base/test/test_fileapi.html => dom/file/tests/test_fileapi.html
rename : dom/base/test/test_fileapi_slice.html => dom/file/tests/test_fileapi_slice.html
rename : dom/base/test/test_ipc_messagemanager_blob.html => dom/file/tests/test_ipc_messagemanager_blob.html
rename : dom/base/test/test_mozfiledataurl.html => dom/file/tests/test_mozfiledataurl.html
rename : dom/base/test/test_nonascii_blob_url.html => dom/file/tests/test_nonascii_blob_url.html
2016-12-01 15:12:42 +01:00

112 lines
2.6 KiB
HTML

<!doctype html>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=819900
-->
<head>
<title>Test for crash caused by unloading and reloading srcdoc iframes</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=819900">Mozilla Bug 819900</a>
<pre id="test">
<script>
var b = new Blob(['1234567890']);
ok(b, 'Blob created');
is(b.size, 10, 'Blob has the right size');
var status = false;
try {
f = new File(b);
} catch(e) {
status = true;
}
ok(status, "File throws if the second argument is missing");
status = false;
try {
f = new File(42, 'foobar.txt');
} catch(e) {
status = true;
}
ok(status, "File throws if the argument is not an array");
status = false;
try {
f = new File({}, 'foobar.txt');
} catch(e) {
status = true;
}
ok(status, "File throws if the argument is not an array");
status = false;
try {
f = new File("hello world", 'foobar.txt');
} catch(e) {
status = true;
}
ok(status, "File throws if the argument is not an array");
f = new File(['1234567890'], '');
ok(f, 'File created');
is(f.size, 10, 'File has the right size');
is(f.name, '');
is(f.type, '');
f = new File(['1234567890'], 42);
ok(f, 'File created');
is(f.size, 10, 'File has the right size');
is(f.name, '42');
is(f.type, '');
f = new File(['1234567890'], 'text.txt');
ok(f, 'File created');
is(f.size, 10, 'File has the right size');
is(f.name, 'text.txt');
is(f.type, '');
f = new File(['1234567890'], 'text.txt', { type: 'plain/text' });
ok(f, 'File created');
is(f.size, 10, 'File has the right size');
is(f.name, 'text.txt');
is(f.type, 'plain/text');
f = new File([b], 'text.txt');
ok(f, 'File created');
is(f.name, 'text.txt');
is(f.type, '');
is(f.size, b.size);
f = new File([b], 'test.txt', { type: 'plain/text' });
ok(f, 'File created');
is(f.name, 'test.txt');
is(f.type, 'plain/text');
is(f.size, b.size);
f = new File([b, b], 'test.txt', { type: 'plain/text' });
ok(f, 'File created');
is(f.name, 'test.txt');
is(f.type, 'plain/text');
is(f.size, b.size * 2);
var f2 = new File([f, f], 'test.txt', { type: 'plain/text' });
ok(f2, 'File created');
is(f2.name, 'test.txt');
is(f2.type, 'plain/text');
is(f2.size, f.size * 2);
var f2 = new File([f, f], 'test.txt', b);
ok(f2, 'File created');
is(f2.name, 'test.txt');
is(f2.type, b.type);
is(f2.size, f.size * 2);
</script>
</pre>
</body>
</html>