Skip to content

Commit 9016063

Browse files
Alex Christensenwebkit-commit-queue
authored andcommitted
FileReaderLoader::convertToDataURL should use application/octet-stream if MIME type is empty
https://bugs.webkit.org/show_bug.cgi?id=218993 Patch by Alex Christensen <achristensen@webkit.org> on 2020-11-16 Reviewed by Geoffrey Garen. LayoutTests/imported/w3c: * web-platform-tests/FileAPI/reading-data-section/filereader_readAsDataURL-expected.txt: Source/WebCore: This matches Chrome and Firefox, and is covered by a web platform test. * fileapi/FileReaderLoader.cpp: (WebCore::FileReaderLoader::convertToDataURL): LayoutTests: * fast/files/read-blob-async-expected.txt: * fast/files/workers/worker-read-blob-async-expected.txt: * fast/files/workers/worker-read-blob-sync-expected.txt: Canonical link: https://commits.webkit.org/231632@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@269875 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 11680ed commit 9016063

8 files changed

Lines changed: 43 additions & 8 deletions

File tree

LayoutTests/ChangeLog

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
2020-11-16 Alex Christensen <achristensen@webkit.org>
2+
3+
FileReaderLoader::convertToDataURL should use application/octet-stream if MIME type is empty
4+
https://bugs.webkit.org/show_bug.cgi?id=218993
5+
6+
Reviewed by Geoffrey Garen.
7+
8+
* fast/files/read-blob-async-expected.txt:
9+
* fast/files/workers/worker-read-blob-async-expected.txt:
10+
* fast/files/workers/worker-read-blob-sync-expected.txt:
11+
112
2020-11-13 Ryan Haddad <ryanhaddad@apple.com>
213

314
Unreviewed test gardening, land expectations for rdar://71039166.

LayoutTests/fast/files/read-blob-async-expected.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ Received loadstart event
6464
readyState: 1
6565
Received load event
6666
readyState: 2
67-
result size: 21
68-
result: data:;base64,Rmlyc3Q=
67+
result size: 45
68+
result: data:application/octet-stream;base64,Rmlyc3Q=
6969
Received loadend event
7070
Test reading a blob containing single text as data URL (optional content type provided)
7171
readyState: 0

LayoutTests/fast/files/workers/worker-read-blob-async-expected.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ Received loadstart event
6565
readyState: 1
6666
Received load event
6767
readyState: 2
68-
result size: 21
69-
result: data:;base64,Rmlyc3Q=
68+
result size: 45
69+
result: data:application/octet-stream;base64,Rmlyc3Q=
7070
Received loadend event
7171
Test reading a blob containing single text as data URL (optional content type provided)
7272
readyState: 0

LayoutTests/fast/files/workers/worker-read-blob-sync-expected.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ result size: 5
2727
result: First
2828
Received exception undefined: TypeError
2929
Test reading a blob containing single text as data URL
30-
result size: 21
31-
result: data:;base64,Rmlyc3Q=
30+
result size: 45
31+
result: data:application/octet-stream;base64,Rmlyc3Q=
3232
Received exception undefined: TypeError
3333
Test reading a blob containing single text as data URL (optional content type provided)
3434
result size: 29

LayoutTests/imported/w3c/ChangeLog

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
2020-11-16 Alex Christensen <achristensen@webkit.org>
2+
3+
FileReaderLoader::convertToDataURL should use application/octet-stream if MIME type is empty
4+
https://bugs.webkit.org/show_bug.cgi?id=218993
5+
6+
Reviewed by Geoffrey Garen.
7+
8+
* web-platform-tests/FileAPI/reading-data-section/filereader_readAsDataURL-expected.txt:
9+
110
2020-11-16 Yusuke Suzuki <ysuzuki@apple.com>
211

312
Import latest wpt/wasm tests
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

22
PASS FileReader readyState during readAsDataURL
33
PASS readAsDataURL result for Blob with specified MIME type
4-
FAIL readAsDataURL result for Blob with unspecified MIME type assert_equals: expected "data:application/octet-stream;base64,VEVTVA==" but got "data:;base64,VEVTVA=="
4+
PASS readAsDataURL result for Blob with unspecified MIME type
55

Source/WebCore/ChangeLog

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
2020-11-16 Alex Christensen <achristensen@webkit.org>
2+
3+
FileReaderLoader::convertToDataURL should use application/octet-stream if MIME type is empty
4+
https://bugs.webkit.org/show_bug.cgi?id=218993
5+
6+
Reviewed by Geoffrey Garen.
7+
8+
This matches Chrome and Firefox, and is covered by a web platform test.
9+
10+
* fileapi/FileReaderLoader.cpp:
11+
(WebCore::FileReaderLoader::convertToDataURL):
12+
113
2020-11-16 Megan Gardner <megan_gardner@apple.com>
214

315
Speculative fix for localizableStrings.string in WebCore

Source/WebCore/fileapi/FileReaderLoader.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,10 @@ void FileReaderLoader::convertToDataURL()
346346
return;
347347
}
348348

349-
builder.append(m_dataType);
349+
if (m_dataType.isEmpty())
350+
builder.append("application/octet-stream");
351+
else
352+
builder.append(m_dataType);
350353
builder.appendLiteral(";base64,");
351354

352355
Vector<char> out;

0 commit comments

Comments
 (0)