Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
266 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { WPTRunner } from './runner/runner/runner.mjs' | ||
import { once } from 'events' | ||
|
||
const runner = new WPTRunner('xhr', 'http://localhost:3333') | ||
runner.run() | ||
|
||
await once(runner, 'completion') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// META: title=FormData.append | ||
|
||
test(function() { | ||
assert_equals(create_formdata(['key', 'value1']).get('key'), "value1"); | ||
}, 'testFormDataAppend1'); | ||
test(function() { | ||
assert_equals(create_formdata(['key', 'value2'], ['key', 'value1']).get('key'), "value2"); | ||
}, 'testFormDataAppend2'); | ||
test(function() { | ||
assert_equals(create_formdata(['key', undefined]).get('key'), "undefined"); | ||
}, 'testFormDataAppendUndefined1'); | ||
test(function() { | ||
assert_equals(create_formdata(['key', undefined], ['key', 'value1']).get('key'), "undefined"); | ||
}, 'testFormDataAppendUndefined2'); | ||
test(function() { | ||
assert_equals(create_formdata(['key', null]).get('key'), "null"); | ||
}, 'testFormDataAppendNull1'); | ||
test(function() { | ||
assert_equals(create_formdata(['key', null], ['key', 'value1']).get('key'), "null"); | ||
}, 'testFormDataAppendNull2'); | ||
test(function() { | ||
var before = new Date(new Date().getTime() - 2000); // two seconds ago, in case there's clock drift | ||
var fd = create_formdata(['key', new Blob(), 'blank.txt']).get('key'); | ||
assert_equals(fd.name, "blank.txt"); | ||
assert_equals(fd.type, ""); | ||
assert_equals(fd.size, 0); | ||
assert_greater_than_equal(fd.lastModified, before); | ||
assert_less_than_equal(fd.lastModified, new Date()); | ||
}, 'testFormDataAppendEmptyBlob'); | ||
|
||
function create_formdata() { | ||
var fd = new FormData(); | ||
for (var i = 0; i < arguments.length; i++) { | ||
fd.append.apply(fd, arguments[i]); | ||
}; | ||
return fd; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// META: title=FormData: constructor | ||
|
||
test(() => { | ||
assert_throws_js(TypeError, () => { new FormData(null); }); | ||
assert_throws_js(TypeError, () => { new FormData("string"); }); | ||
}, "Constructors should throw a type error"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// META: title=FormData: delete | ||
|
||
test(function() { | ||
var fd = create_formdata(['key', 'value1'], ['key', 'value2']); | ||
fd.delete('key'); | ||
assert_equals(fd.get('key'), null); | ||
}, 'testFormDataDelete'); | ||
test(function() { | ||
var fd = create_formdata(['key', 'value1'], ['key', 'value2']); | ||
fd.delete('nil'); | ||
assert_equals(fd.get('key'), 'value1'); | ||
}, 'testFormDataDeleteNonExistentKey'); | ||
test(function() { | ||
var fd = create_formdata(['key1', 'value1'], ['key2', 'value2']); | ||
fd.delete('key1'); | ||
assert_equals(fd.get('key1'), null); | ||
assert_equals(fd.get('key2'), 'value2'); | ||
}, 'testFormDataDeleteOtherKey'); | ||
|
||
function create_formdata() { | ||
var fd = new FormData(); | ||
for (var i = 0; i < arguments.length; i++) { | ||
fd.append.apply(fd, arguments[i]); | ||
}; | ||
return fd; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// META: title=FormData: foreach | ||
|
||
var fd = new FormData(); | ||
fd.append('n1', 'v1'); | ||
fd.append('n2', 'v2'); | ||
fd.append('n3', 'v3'); | ||
fd.append('n1', 'v4'); | ||
fd.append('n2', 'v5'); | ||
fd.append('n3', 'v6'); | ||
fd.delete('n2'); | ||
|
||
var file = new File(['hello'], "hello.txt"); | ||
fd.append('f1', file); | ||
|
||
var expected_keys = ['n1', 'n3', 'n1', 'n3', 'f1']; | ||
var expected_values = ['v1', 'v3', 'v4', 'v6', file]; | ||
test(function() { | ||
var mykeys = [], myvalues = []; | ||
for(var entry of fd) { | ||
assert_equals(entry.length, 2, | ||
'Default iterator should yield key/value pairs'); | ||
mykeys.push(entry[0]); | ||
myvalues.push(entry[1]); | ||
} | ||
assert_array_equals(mykeys, expected_keys, | ||
'Default iterator should see duplicate keys'); | ||
assert_array_equals(myvalues, expected_values, | ||
'Default iterator should see non-deleted values'); | ||
}, 'Iterator should return duplicate keys and non-deleted values'); | ||
test(function() { | ||
var mykeys = [], myvalues = []; | ||
for(var entry of fd.entries()) { | ||
assert_equals(entry.length, 2, | ||
'entries() iterator should yield key/value pairs'); | ||
mykeys.push(entry[0]); | ||
myvalues.push(entry[1]); | ||
} | ||
assert_array_equals(mykeys, expected_keys, | ||
'entries() iterator should see duplicate keys'); | ||
assert_array_equals(myvalues, expected_values, | ||
'entries() iterator should see non-deleted values'); | ||
}, 'Entries iterator should return duplicate keys and non-deleted values'); | ||
test(function() { | ||
var mykeys = []; | ||
for(var entry of fd.keys()) | ||
mykeys.push(entry); | ||
assert_array_equals(mykeys, expected_keys, | ||
'keys() iterator should see duplicate keys'); | ||
}, 'Keys iterator should return duplicates'); | ||
test(function() { | ||
var myvalues = []; | ||
for(var entry of fd.values()) | ||
myvalues.push(entry); | ||
assert_array_equals(myvalues, expected_values, | ||
'values() iterator should see non-deleted values'); | ||
}, 'Values iterator should return non-deleted values'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// META: title=FormData: get and getAll | ||
|
||
test(function() { | ||
assert_equals(create_formdata(['key', 'value1'], ['key', 'value2']).get('key'), "value1"); | ||
}, 'testFormDataGet'); | ||
test(function() { | ||
assert_equals(create_formdata(['key', 'value1'], ['key', 'value2']).get('nil'), null); | ||
}, 'testFormDataGetNull1'); | ||
test(function() { | ||
assert_equals(create_formdata().get('key'), null); | ||
}, 'testFormDataGetNull2'); | ||
test(function() { | ||
assert_array_equals(create_formdata(['key', 'value1'], ['key', 'value2']).getAll('key'), ["value1", "value2"]); | ||
}, 'testFormDataGetAll'); | ||
test(function() { | ||
assert_array_equals(create_formdata(['key', 'value1'], ['key', 'value2']).getAll('nil'), []); | ||
}, 'testFormDataGetAllEmpty1'); | ||
test(function() { | ||
assert_array_equals(create_formdata().getAll('key'), []); | ||
}, 'testFormDataGetAllEmpty2'); | ||
|
||
function create_formdata() { | ||
var fd = new FormData(); | ||
for (var i = 0; i < arguments.length; i++) { | ||
fd.append.apply(fd, arguments[i]); | ||
}; | ||
return fd; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// META: title=FormData: has | ||
|
||
test(function() { | ||
assert_equals(create_formdata(['key', 'value1'], ['key', 'value2']).has('key'), true); | ||
}, 'testFormDataHas'); | ||
test(function() { | ||
assert_equals(create_formdata(['key', 'value1'], ['key', 'value2']).has('nil'), false); | ||
}, 'testFormDataHasEmpty1'); | ||
test(function() { | ||
assert_equals(create_formdata().has('key'), false); | ||
}, 'testFormDataHasEmpty2'); | ||
|
||
function create_formdata() { | ||
var fd = new FormData(); | ||
for (var i = 0; i < arguments.length; i++) { | ||
fd.append.apply(fd, arguments[i]); | ||
}; | ||
return fd; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// META: title=formData.set(blob) and formData.set(file) | ||
|
||
"use strict"; | ||
|
||
const formData = new FormData(); | ||
|
||
test(() => { | ||
formData.set("blob-1", new Blob()); | ||
const blob1 = formData.get("blob-1"); | ||
assert_equals(blob1.constructor.name, "File"); | ||
assert_equals(blob1.name, "blob"); | ||
assert_equals(blob1.type, ""); | ||
assert_less_than(Math.abs(blob1.lastModified - Date.now()), 200, "lastModified should be now"); | ||
}, "blob without type"); | ||
|
||
test(() => { | ||
formData.set("blob-2", new Blob([], { type: "text/plain" })); | ||
const blob2 = formData.get("blob-2"); | ||
assert_equals(blob2.constructor.name, "File"); | ||
assert_equals(blob2.name, "blob"); | ||
assert_equals(blob2.type, "text/plain"); | ||
assert_less_than(Math.abs(blob2.lastModified - Date.now()), 200, "lastModified should be now"); | ||
}, "blob with type"); | ||
|
||
test(() => { | ||
formData.set("blob-3", new Blob(), "custom name"); | ||
const blob3 = formData.get("blob-3"); | ||
assert_equals(blob3.constructor.name, "File"); | ||
assert_equals(blob3.name, "custom name"); | ||
assert_equals(blob3.type, ""); | ||
assert_less_than(Math.abs(blob3.lastModified - Date.now()), 200, "lastModified should be now"); | ||
}, "blob with custom name"); | ||
|
||
test(() => { | ||
formData.set("file-1", new File([], "name")); | ||
const file1 = formData.get("file-1"); | ||
assert_equals(file1.constructor.name, "File"); | ||
assert_equals(file1.name, "name"); | ||
assert_equals(file1.type, ""); | ||
assert_less_than(Math.abs(file1.lastModified - Date.now()), 200, "lastModified should be now"); | ||
}, "file without lastModified or custom name"); | ||
|
||
test(() => { | ||
formData.set("file-2", new File([], "name", { lastModified: 123 }), "custom name"); | ||
const file2 = formData.get("file-2"); | ||
assert_equals(file2.constructor.name, "File"); | ||
assert_equals(file2.name, "custom name"); | ||
assert_equals(file2.type, ""); | ||
assert_equals(file2.lastModified, 123, "lastModified should be 123"); | ||
}, "file with lastModified and custom name"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// META: title=FormData: set | ||
|
||
test(function() { | ||
assert_equals(create_formdata(['key', 'value1']).get('key'), "value1"); | ||
}, 'testFormDataSet1'); | ||
test(function() { | ||
assert_equals(create_formdata(['key', 'value2'], ['key', 'value1']).get('key'), "value1"); | ||
}, 'testFormDataSet2'); | ||
test(function() { | ||
assert_equals(create_formdata(['key', undefined]).get('key'), "undefined"); | ||
}, 'testFormDataSetUndefined1'); | ||
test(function() { | ||
assert_equals(create_formdata(['key', undefined], ['key', 'value1']).get('key'), "value1"); | ||
}, 'testFormDataSetUndefined2'); | ||
test(function() { | ||
assert_equals(create_formdata(['key', null]).get('key'), "null"); | ||
}, 'testFormDataSetNull1'); | ||
test(function() { | ||
assert_equals(create_formdata(['key', null], ['key', 'value1']).get('key'), "value1"); | ||
}, 'testFormDataSetNull2'); | ||
test(function() { | ||
var fd = new FormData(); | ||
fd.set('key', new Blob([]), 'blank.txt'); | ||
var file = fd.get('key'); | ||
|
||
assert_true(file instanceof File); | ||
assert_equals(file.name, 'blank.txt'); | ||
}, 'testFormDataSetEmptyBlob'); | ||
|
||
function create_formdata() { | ||
var fd = new FormData(); | ||
for (var i = 0; i < arguments.length; i++) { | ||
fd.set.apply(fd, arguments[i]); | ||
}; | ||
return fd; | ||
} |