OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <body> |
| 4 <script src="../../../../resources/js-test.js"></script> |
| 5 <script> |
| 6 description("Test that passing bad strings to FormData.append() throws and abort
s properly."); |
| 7 |
| 8 var xhr = new XMLHttpRequest(); |
| 9 xhr.open('POST', 'http://127.0.0.1:8000/xmlhttprequest/resources/post-echo.cgi',
false); |
| 10 var badString = { toString: function() { throw "Exception in toString()"; } }; |
| 11 |
| 12 var formData = new FormData(); |
| 13 shouldThrow("formData.append(badString, 'test')", "'Exception in toString()'"); |
| 14 shouldThrow("formData.append('textarea', badString)", "'Exception in toString()'
"); |
| 15 shouldThrow("formData.append('blob', new Blob(['']), badString)", "'Exception in
toString()'"); |
| 16 |
| 17 xhr.send(formData); |
| 18 if (xhr.readyState !== 4 || xhr.status !== 200) { |
| 19 testFailed('xhr.readyState = ' + xhr.readyState + ', xhr.status = ' + xhr.st
atus); |
| 20 return; |
| 21 } |
| 22 |
| 23 shouldBe("xhr.response.indexOf('test')", "-1"); |
| 24 shouldBe("xhr.response.indexOf('textarea')", "-1"); |
| 25 shouldBe("xhr.response.indexOf('blob')", "-1"); |
| 26 </script> |
| 27 </body> |
| 28 </html> |
OLD | NEW |