-
Notifications
You must be signed in to change notification settings - Fork 47
Closed
Description
Based on my reading of blob.slice(), it seems that the resulting blobs content type should be the empty string under the following cases:
contentType
is not givencontentType
has a value outside the range of U+0020 to U+007E
After writing a simple wpt test, it seems like no browser does 1 and only one does 2.
Test | Safari | Chrome | Firefox |
---|---|---|---|
no contentType |
❌ | ❌ | ❌ |
bad contentType |
✅ | ❌ | ❌ |
Just in case the issue is actually my test cases 😄, I've attached the example I used below:
promise_test(function(test) {
var blob = new Blob(["this has no content type"]);
let slice = blob.slice(12, 24, "\0");
return fetch(URL.createObjectURL(slice)).then(function (resp) {
assert_equals(resp.status, 200, "HTTP status is 200");
assert_equals(resp.type, "basic", "response type is basic");
assert_equals(resp.headers.get("Content-Type"), "");
assert_equals(resp.headers.get("Content-Length"), "12");
return resp.text();
}).then(function(bodyAsText) {
assert_equals("content type", bodyAsText)
});
}, "Set content type to the empty string for slice with invalid content type");
promise_test(function(test) {
var blob = new Blob(["this has a content type"], {"type": "application/xml"});
let slice = blob.slice(11, 23);
return fetch(URL.createObjectURL(slice)).then(function (resp) {
assert_equals(resp.status, 200, "HTTP status is 200");
assert_equals(resp.type, "basic", "response type is basic");
assert_equals(resp.headers.get("Content-Type"), "");
assert_equals(resp.headers.get("Content-Length"), "12");
return resp.text();
}).then(function(bodyAsText) {
assert_equals("content type", bodyAsText)
});
}, "Set content type to the empty string for slice with no content type ");
Metadata
Metadata
Assignees
Labels
No labels