mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Update web-platform-tests to revision 0d318188757a9c996e20b82db201fd04de5aa255
This commit is contained in:
parent
b2a5225831
commit
1a81b18b9f
12321 changed files with 544385 additions and 6 deletions
|
@ -0,0 +1,72 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<title>File constructor</title>
|
||||
<link rel=help href="http://dev.w3.org/2006/webapi/FileAPI/#dfn-file">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
test(function() {
|
||||
assert_true("File" in window, "window should have a File property.");
|
||||
}, "File interface object exists");
|
||||
|
||||
function test_first_argument(arg1, expectedSize, testName) {
|
||||
test(function() {
|
||||
var file = new File(arg1, "dummy");
|
||||
assert_true(file instanceof File);
|
||||
assert_equals(file.name, "dummy");
|
||||
assert_equals(file.size, expectedSize);
|
||||
assert_equals(file.type, "");
|
||||
// assert_false(file.isClosed); XXX: File.isClosed doesn't seem to be implemented
|
||||
assert_not_equals(file.lastModified, "");
|
||||
}, testName);
|
||||
}
|
||||
|
||||
test_first_argument(["bits"], 4, "DOMString fileBits");
|
||||
test_first_argument(["𝓽𝓮𝔁𝓽"], 16, "Unicode DOMString fileBits");
|
||||
test_first_argument([new Blob()], 0, "Empty Blob fileBits");
|
||||
test_first_argument([new Blob(["bits"])], 4, "Blob fileBits");
|
||||
test_first_argument([new ArrayBuffer(8)], 8, "ArrayBuffer fileBits");
|
||||
test_first_argument([new Uint8Array([0x50, 0x41, 0x53, 0x53])], 4, "Typed array fileBits");
|
||||
test_first_argument(["bits", new Blob(["bits"]), new Blob(), new Uint8Array([0x50, 0x41]),
|
||||
new Uint16Array([0x5353]), new Uint32Array([0x53534150])], 16, "Various fileBits");
|
||||
|
||||
function test_second_argument(arg2, expectedFileName, testName) {
|
||||
test(function() {
|
||||
var file = new File(["bits"], arg2);
|
||||
assert_true(file instanceof File);
|
||||
assert_equals(file.name, expectedFileName);
|
||||
}, testName);
|
||||
}
|
||||
|
||||
test_second_argument("dummy", "dummy", "Using fileName");
|
||||
test_second_argument("dummy/foo", "dummy:foo", "Using special character in fileName");
|
||||
|
||||
// testing the third argument
|
||||
test(function() {
|
||||
var file = new File(["bits"], "dummy", { type: "text/plain"});
|
||||
assert_true(file instanceof File);
|
||||
assert_equals(file.type, "text/plain");
|
||||
}, "Using type on the File constructor");
|
||||
test(function() {
|
||||
var file = new File(["bits"], "dummy", { type: "TEXT/PLAIN"});
|
||||
assert_true(file instanceof File);
|
||||
assert_equals(file.type, "text/plain");
|
||||
}, "Using uppercase characters in type");
|
||||
test(function() {
|
||||
var file = new File(["bits"], "dummy", { type: "𝓽𝓮𝔁𝓽/𝔭𝔩𝔞𝔦𝔫"});
|
||||
assert_true(file instanceof File);
|
||||
assert_equals(file.type, "");
|
||||
}, "Using illegal character for type");
|
||||
test(function() {
|
||||
var file = new File(["bits"], "dummy", { lastModified: 42 });
|
||||
assert_true(file instanceof File);
|
||||
assert_equals(file.lastModified, 42);
|
||||
}, "Using lastModified");
|
||||
test(function() {
|
||||
var file = new File(["bits"], "dummy", { name: "foo" });
|
||||
assert_true(file instanceof File);
|
||||
assert_equals(file.name, "dummy");
|
||||
}, "Misusing name");
|
||||
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue