| <!doctype html> |
| <title>XMLHttpRequest: overrideMimeType() and responseType = "blob"</title> |
| <meta charset="utf-8"> |
| <script src="/resources/testharness.js"></script> |
| <script src="/resources/testharnessreport.js"></script> |
| <div id="log"></div> |
| <script> |
| async_test(t => { |
| const client = new XMLHttpRequest() |
| client.onload = t.step_func_done(() => { |
| assert_equals(client.getResponseHeader("Content-Type"), "") |
| assert_equals(client.response.type, "text/xml") |
| }) |
| client.open("GET", "resources/status.py") |
| client.responseType = "blob" |
| client.send() |
| }, "Use text/xml as fallback MIME type") |
| |
| async_test(t => { |
| const client = new XMLHttpRequest() |
| client.onload = t.step_func_done(() => { |
| assert_equals(client.getResponseHeader("Content-Type"), "") |
| assert_equals(client.response.type, "text/xml") |
| }) |
| client.open("GET", "resources/status.py?content=thisshouldnotmakeadifferencebutdoes") |
| client.responseType = "blob" |
| client.send() |
| }, "Use text/xml as fallback MIME type, 2") |
| |
| async_test(t => { |
| const client = new XMLHttpRequest() |
| client.onload = t.step_func_done(() => { |
| assert_equals(client.getResponseHeader("Content-Type"), "") |
| assert_equals(client.response.type, "application/octet-stream") |
| }) |
| client.open("GET", "resources/status.py") |
| client.responseType = "blob" |
| client.overrideMimeType("bogus") |
| client.send() |
| }, "Bogus MIME type should end up as application/octet-stream") |
| |
| async_test(t => { |
| const client = new XMLHttpRequest() |
| client.onload = t.step_func_done(() => { |
| assert_equals(client.getResponseHeader("Content-Type"), "") |
| assert_equals(client.response.type, "application/octet-stream") |
| }) |
| client.open("GET", "resources/status.py") |
| client.responseType = "blob" |
| client.overrideMimeType("text/xml;charset=†") |
| client.send() |
| }, "Bogus MIME type should end up as application/octet-stream, 2") |
| |
| async_test(t => { |
| const client = new XMLHttpRequest() |
| client.onload = t.step_func_done(() => { |
| assert_equals(client.getResponseHeader("Content-Type"), "") |
| assert_equals(client.response.type, "hi/x") |
| }) |
| client.open("GET", "resources/status.py") |
| client.responseType = "blob" |
| client.overrideMimeType("HI/x;test=test") |
| client.send() |
| }, "Valid MIME types need to be normalized") |
| </script> |