Index: LayoutTests/http/tests/local/formdata/send-form-data-with-bad-string.html |
diff --git a/LayoutTests/http/tests/local/formdata/send-form-data-with-bad-string.html b/LayoutTests/http/tests/local/formdata/send-form-data-with-bad-string.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..5ab287191f7d91dd5c35261e149f0760ed7c2319 |
--- /dev/null |
+++ b/LayoutTests/http/tests/local/formdata/send-form-data-with-bad-string.html |
@@ -0,0 +1,28 @@ |
+<!DOCTYPE html> |
+<html> |
+<body> |
+<script src="../../../../resources/js-test.js"></script> |
+<script> |
+description("Test that passing bad strings to FormData.append() throws and aborts properly."); |
+ |
+var xhr = new XMLHttpRequest(); |
+xhr.open('POST', 'http://127.0.0.1:8000/xmlhttprequest/resources/post-echo.cgi', false); |
+var badString = { toString: function() { throw "Exception in toString()"; } }; |
+ |
+var formData = new FormData(); |
+shouldThrow("formData.append(badString, 'test')", "'Exception in toString()'"); |
+shouldThrow("formData.append('textarea', badString)", "'Exception in toString()'"); |
+shouldThrow("formData.append('blob', new Blob(['']), badString)", "'Exception in toString()'"); |
+ |
+xhr.send(formData); |
+if (xhr.readyState !== 4 || xhr.status !== 200) { |
+ testFailed('xhr.readyState = ' + xhr.readyState + ', xhr.status = ' + xhr.status); |
+ return; |
+} |
+ |
+shouldBe("xhr.response.indexOf('test')", "-1"); |
+shouldBe("xhr.response.indexOf('textarea')", "-1"); |
+shouldBe("xhr.response.indexOf('blob')", "-1"); |
+</script> |
+</body> |
+</html> |