Index: LayoutTests/http/tests/local/formdata/send-form-data-with-empty-name.html |
diff --git a/LayoutTests/http/tests/local/formdata/send-form-data-with-empty-name.html b/LayoutTests/http/tests/local/formdata/send-form-data-with-empty-name.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..317b6f6e6057a09d1506c37417fdb0609e71cd07 |
--- /dev/null |
+++ b/LayoutTests/http/tests/local/formdata/send-form-data-with-empty-name.html |
@@ -0,0 +1,57 @@ |
+<!DOCTYPE html> |
+<html> |
+<body> |
+<script src="../../../../resources/js-test.js"></script> |
+<script> |
+description("Test that we can send empty name in Formdata."); |
sof
2014/10/10 06:27:10
"Test that empty names can be used in FormData.app
|
+ |
+self.jsTestIsAsync = true; |
+ |
+function shouldContain(string, substring, message) { |
+ if (string.indexOf(substring) >= 0) { |
+ testPassed(message); |
+ } else { |
+ testFailed("the formatdata containing"+ substring + " is failed to echo correctly"); |
sof
2014/10/10 06:27:10
formatdata => FormData.
is failed => failed.
Also
|
+ } |
+} |
+ |
+var formDataString = new FormData(); |
sof
2014/10/10 06:27:10
The String variable suffix doesn't seem to add muc
sof
2014/10/10 06:27:10
Could you wrap this up as firstTest() and then inv
|
+formDataString.append('', 'empty'); |
+formDataString.append('hello', 'world'); |
+var xhrString = new XMLHttpRequest(); |
+xhrString.open('POST', 'http://localhost:8000/xmlhttprequest/resources/post-echo.cgi', true); |
sof
2014/10/10 06:27:11
local/ do run as local tests (despite being in htt
|
+ |
+stringResponse = function() { |
sof
2014/10/10 06:27:10
Just inline this as
xhrString.onload = function (
|
+ if (xhrString.readyState == xhrString.DONE) { |
+ shouldContain(xhrString.response, 'name=""\r\n\r\nempty', |
+ 'the formdata of string type containing a empty name is echoed correctly'); |
+ shouldContain(xhrString.response, 'name="hello"\r\n\r\nworld', |
+ 'the formdata of string type containing a name is echoed correctly'); |
+ secondTest(); |
+ } |
+} |
+xhrString.onreadystatechange = stringResponse; |
sof
2014/10/10 06:27:10
onload is simpler, I think. Then you don't need to
|
+xhrString.send(formDataString); |
+ |
+function secondTest() { |
+ var formDataFile = new FormData(); |
sof
2014/10/10 06:27:11
The File variable suffix doesn't seem to add much,
|
+ formDataFile.append('', new Blob(), 'empty-name.txt'); |
+ formDataFile.append('testFile', new Blob(), 'custom-name.txt'); |
+ var xhrFile = new XMLHttpRequest(); |
+ xhrFile.open('POST', 'http://localhost:8000/xmlhttprequest/resources/post-echo.cgi', true); |
sof
2014/10/10 06:27:10
localhost => 127.0.0.1
|
+ |
+ fileResponse = function() { |
sof
2014/10/10 06:27:11
xhr.onload = function () {
...
};
|
+ if (xhrFile.readyState == xhrFile.DONE) { |
+ shouldContain(xhrFile.response, 'name=""; filename="empty-name.txt"', |
+ 'the formdata of file type containing a empty name is echoed correctly.'); |
+ shouldContain(xhrFile.response, 'name="testFile"; filename="custom-name.txt"', |
+ 'the formdata of file type containing a name is echoed correctly.'); |
+ finishJSTest(); |
+ } |
+ } |
+ xhrFile.onreadystatechange = fileResponse; |
+ xhrFile.send(formDataFile); |
+} |
+</script> |
+</body> |
+</html> |