mirror of
https://github.com/servo/servo.git
synced 2025-08-29 09:08:20 +01:00
Update web-platform-tests to revision c26470dac73f2df9d4822a0d3482f7eb1ebf57d9
This commit is contained in:
parent
7de87c487b
commit
4d3c932c47
648 changed files with 9014 additions and 4821 deletions
98
tests/wpt/web-platform-tests/xhr/formdata-set.htm
Normal file
98
tests/wpt/web-platform-tests/xhr/formdata-set.htm
Normal file
|
@ -0,0 +1,98 @@
|
|||
<!doctype html>
|
||||
<meta charset="utf-8">
|
||||
<title>FormData: set</title>
|
||||
<link rel="help" href="https://xhr.spec.whatwg.org/#dom-formdata-set">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<form id="form" />
|
||||
<script>
|
||||
function test_formdata(creator, verifier, description) {
|
||||
async_test(description).step(function() {
|
||||
var fd = creator();
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.onload = this.step_func(function() {
|
||||
verifier(xhr.responseText);
|
||||
this.done();
|
||||
});
|
||||
xhr.open("POST", "resources/upload.py");
|
||||
xhr.send(fd);
|
||||
});
|
||||
}
|
||||
|
||||
test_formdata(function() {
|
||||
var fd = new FormData();
|
||||
fd.set("name", new String("value"));
|
||||
return fd;
|
||||
}, function(data) {
|
||||
assert_equals(data, "name=value,\n");
|
||||
}, "Passing a String object to FormData.set should work");
|
||||
|
||||
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(document.getElementById("form"));
|
||||
fd.set('key', 'value1');
|
||||
assert_equals(fd.get('key'), "value1");
|
||||
}, 'testFormDataSetToForm1');
|
||||
test(function() {
|
||||
var fd = new FormData(document.getElementById("form"));
|
||||
fd.set('key', 'value2');
|
||||
fd.set('key', 'value1');
|
||||
assert_equals(fd.get('key'), "value1");
|
||||
}, 'testFormDataSetToForm2');
|
||||
test(function() {
|
||||
var fd = new FormData(document.getElementById("form"));
|
||||
fd.set('key', undefined);
|
||||
assert_equals(fd.get('key'), "undefined");
|
||||
}, 'testFormDataSetToFormUndefined1');
|
||||
test(function() {
|
||||
var fd = new FormData(document.getElementById("form"));
|
||||
fd.set('key', undefined);
|
||||
fd.set('key', 'value1');
|
||||
assert_equals(fd.get('key'), "value1");
|
||||
}, 'testFormDataSetToFormUndefined2');
|
||||
test(function() {
|
||||
var fd = new FormData(document.getElementById("form"));
|
||||
fd.set('key', null);
|
||||
assert_equals(fd.get('key'), "null");
|
||||
}, 'testFormDataSetToFormNull1');
|
||||
test(function() {
|
||||
var fd = new FormData(document.getElementById("form"));
|
||||
fd.set('key', null);
|
||||
fd.set('key', 'value1');
|
||||
assert_equals(fd.get('key'), "value1");
|
||||
}, 'testFormDataSetToFormNull2');
|
||||
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;
|
||||
}
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue