Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetch: remove usage of FileReader #44893

Merged
merged 2 commits into from
Mar 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions fetch/api/request/request-consume-empty.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,7 @@ function checkBodyText(test, request) {

function checkBodyBlob(test, request) {
return request.blob().then(function(bodyAsBlob) {
var promise = new Promise(function(resolve, reject) {
var reader = new FileReader();
reader.onload = function(evt) {
resolve(reader.result)
};
reader.onerror = function() {
reject("Blob's reader failed");
};
reader.readAsText(bodyAsBlob);
});
var promise = bodyAsBlob.text();
return promise.then(function(body) {
assert_equals(body, "", "Resolved value should be empty");
assert_false(request.bodyUsed);
Expand Down
11 changes: 1 addition & 10 deletions fetch/api/request/request-consume.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,7 @@ function checkBodyBlob(request, expectedBody, checkContentType) {
if (checkContentType)
assert_equals(bodyAsBlob.type, "text/plain", "Blob body type should be computed from the request Content-Type");

var promise = new Promise(function (resolve, reject) {
var reader = new FileReader();
reader.onload = function(evt) {
resolve(reader.result)
};
reader.onerror = function() {
reject("Blob's reader failed");
};
reader.readAsText(bodyAsBlob);
});
var promise = bodyAsBlob.text();
return promise.then(function(body) {
assert_equals(body, expectedBody, "Retrieve and verify request's body");
assert_true(request.bodyUsed, "body as blob: bodyUsed turned true");
Expand Down
11 changes: 1 addition & 10 deletions fetch/api/response/response-consume-empty.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,7 @@ function checkBodyText(test, response) {

function checkBodyBlob(test, response) {
return response.blob().then(function(bodyAsBlob) {
var promise = new Promise(function(resolve, reject) {
var reader = new FileReader();
reader.onload = function(evt) {
resolve(reader.result)
};
reader.onerror = function() {
reject("Blob's reader failed");
};
reader.readAsText(bodyAsBlob);
});
var promise = bodyAsBlob.text();
return promise.then(function(body) {
assert_equals(body, "", "Resolved value should be empty");
assert_false(response.bodyUsed);
Expand Down