| <!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); |
| } else { |
| shouldBe("xhr.response.indexOf('test')", "-1"); |
| shouldBe("xhr.response.indexOf('textarea')", "-1"); |
| shouldBe("xhr.response.indexOf('blob')", "-1"); |
| } |
| </script> |
| </body> |
| </html> |