Skip to content

Commit 61df0b9

Browse files
pwnallchromium-wpt-export-bot
authored andcommitted
File API: Match Firefox on readAsDataURL default MIME type.
In Firefox, File.readAsDataURL's default MIME type is to application/octet-stream. Chrome currently leaves the MIME type out when it is unknown. While this meets all relevant specifications, matching Firefox's behavior makes the platform easier to reason about. Bug: 48368 Change-Id: If480df5cc3a1177a58c7c3dc68c57f3d6408b9eb Reviewed-on: https://chromium-review.googlesource.com/1104183 Commit-Queue: Victor Costan <[email protected]> Reviewed-by: Marijn Kruisselbrink <[email protected]> Cr-Commit-Position: refs/heads/master@{#568292}
1 parent 2052baf commit 61df0b9

File tree

1 file changed

+51
-39
lines changed

1 file changed

+51
-39
lines changed
Lines changed: 51 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,51 @@
1-
<!DOCTYPE html>
2-
<html>
3-
<head>
4-
<meta charset="utf-8">
5-
<title>FileAPI Test: filereader_readAsDataURL</title>
6-
<link rel="author" title="Intel" href="http://www.intel.com">
7-
<link rel="help" href="http://dev.w3.org/2006/webapi/FileAPI/#readAsDataURL">
8-
<script src="/resources/testharness.js"></script>
9-
<script src="/resources/testharnessreport.js"></script>
10-
</head>
11-
<body>
12-
<div id="log"></div>
13-
14-
<script>
15-
async_test(function() {
16-
var blob = new Blob(["TEST"]);
17-
var reader = new FileReader();
18-
19-
reader.onload = this.step_func(function(evt) {
20-
assert_equals(typeof reader.result, "string", "The result is string");
21-
assert_equals(reader.result.indexOf("data:"), 0, "The result attribute starts with 'data'");
22-
assert_true(reader.result.indexOf("base64") > 0, "The result attribute contains 'base64'");
23-
assert_equals(reader.readyState, reader.DONE);
24-
this.done();
25-
});
26-
27-
reader.onloadstart = this.step_func(function(evt) {
28-
assert_equals(reader.readyState, reader.LOADING);
29-
});
30-
31-
reader.onprogress = this.step_func(function(evt) {
32-
assert_equals(reader.readyState, reader.LOADING);
33-
});
34-
35-
reader.readAsDataURL(blob);
36-
});
37-
</script>
38-
</body>
39-
</html>
1+
<!doctype html>
2+
<meta charset="utf-8">
3+
<title>FileAPI Test: FileReader.readAsDataURL</title>
4+
<link rel="author" title="Intel" href="http://www.intel.com">
5+
<link rel="help" href="https://w3c.github.io/FileAPI/#readAsDataURL">
6+
<script src="/resources/testharness.js"></script>
7+
<script src="/resources/testharnessreport.js"></script>
8+
9+
<script>
10+
async_test(function(testCase) {
11+
var blob = new Blob(["TEST"]);
12+
var reader = new FileReader();
13+
14+
reader.onload = this.step_func(function(evt) {
15+
assert_equals(reader.readyState, reader.DONE);
16+
testCase.done();
17+
});
18+
reader.onloadstart = this.step_func(function(evt) {
19+
assert_equals(reader.readyState, reader.LOADING);
20+
});
21+
reader.onprogress = this.step_func(function(evt) {
22+
assert_equals(reader.readyState, reader.LOADING);
23+
});
24+
25+
reader.readAsDataURL(blob);
26+
}, 'FileReader readyState during readAsDataURL');
27+
28+
async_test(function(testCase) {
29+
var blob = new Blob(["TEST"], { type: 'text/plain' });
30+
var reader = new FileReader();
31+
32+
reader.onload = this.step_func(function() {
33+
assert_equals(reader.result, "data:text/plain;base64,VEVTVA==");
34+
testCase.done();
35+
});
36+
reader.readAsDataURL(blob);
37+
}, 'readAsDataURL result for Blob with specified MIME type');
38+
39+
async_test(function(testCase) {
40+
var blob = new Blob(["TEST"]);
41+
var reader = new FileReader();
42+
43+
reader.onload = this.step_func(function() {
44+
assert_equals(reader.result,
45+
"data:application/octet-stream;base64,VEVTVA==");
46+
testCase.done();
47+
});
48+
reader.readAsDataURL(blob);
49+
}, 'readAsDataURL result for Blob with unspecified MIME type');
50+
51+
</script>

0 commit comments

Comments
 (0)