- Revision
- 118620
- Author
- [email protected]
- Date
- 2012-05-26 18:51:03 -0700 (Sat, 26 May 2012)
Log Message
[FileAPI] The result attribute of FileReader shuold use null to replace empty string
https://bugs.webkit.org/show_bug.cgi?id=87578
Patch by Li Yin <[email protected]> on 2012-05-26
Reviewed by Kentaro Hara.
Source/WebCore:
>From Spec: http://www.w3.org/TR/FileAPI/#filedata-attr
Before read method has been called or an error in reading has occurred,
the result attribute should be null, not empty string.
Currently, Firefox, Opera and IE 10 follows the spec, but Webkit based
browser don't.
WebKit should change the returned value empty string into null to keep
conformance with the spec.
Tests: fast/files/read-file-async.html
fast/files/blob-slice-test.html
fast/files/read-blob-async.html
fast/files/workers/worker-read-blob-async.html
fast/files/workers/worker-read-file-async.html
* fileapi/FileReader.cpp:
(WebCore::FileReader::stringResult):
LayoutTests:
>From Spec: http://www.w3.org/TR/FileAPI/#filedata-attr
Before read method has been called or an error in reading has occurred,
the result attribute should be null, not empty string.
WebKit should change the returned value empty string into null to keep
conformance with the spec.
* fast/files/blob-slice-test-expected.txt:
* fast/files/read-blob-async-expected.txt:
* fast/files/read-file-async-expected.txt:
* fast/files/resources/read-common.js:
(logResult):
* fast/files/workers/worker-read-blob-async-expected.txt:
* fast/files/workers/worker-read-file-async-expected.txt:
Modified Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (118619 => 118620)
--- trunk/LayoutTests/ChangeLog 2012-05-27 01:16:25 UTC (rev 118619)
+++ trunk/LayoutTests/ChangeLog 2012-05-27 01:51:03 UTC (rev 118620)
@@ -1,3 +1,24 @@
+2012-05-26 Li Yin <[email protected]>
+
+ [FileAPI] The result attribute of FileReader shuold use null to replace empty string
+ https://bugs.webkit.org/show_bug.cgi?id=87578
+
+ Reviewed by Kentaro Hara.
+
+ From Spec: http://www.w3.org/TR/FileAPI/#filedata-attr
+ Before read method has been called or an error in reading has occurred,
+ the result attribute should be null, not empty string.
+ WebKit should change the returned value empty string into null to keep
+ conformance with the spec.
+
+ * fast/files/blob-slice-test-expected.txt:
+ * fast/files/read-blob-async-expected.txt:
+ * fast/files/read-file-async-expected.txt:
+ * fast/files/resources/read-common.js:
+ (logResult):
+ * fast/files/workers/worker-read-blob-async-expected.txt:
+ * fast/files/workers/worker-read-file-async-expected.txt:
+
2012-05-26 Nate Chapin <[email protected]>
Test for https://bugs.webkit.org/show_bug.cgi?id=35377.
Modified: trunk/LayoutTests/fast/files/blob-slice-test-expected.txt (118619 => 118620)
--- trunk/LayoutTests/fast/files/blob-slice-test-expected.txt 2012-05-27 01:16:25 UTC (rev 118619)
+++ trunk/LayoutTests/fast/files/blob-slice-test-expected.txt 2012-05-27 01:51:03 UTC (rev 118620)
@@ -1,28 +1,28 @@
Slicing from 2 to 3: 2
Slicing from 2 to 12: 23456789
-Slicing from 2 to 2:
-Slicing from 2 to 1:
-Slicing from 2 to -12:
+Slicing from 2 to 2: null
+Slicing from 2 to 1: null
+Slicing from 2 to -12: null
Slicing from 2 to 2147483647: 23456789
-Slicing from 2 to -2147483648:
+Slicing from 2 to -2147483648: null
Slicing from 2 to 9223372036854775000: 23456789
-Slicing from 2 to -9223372036854775000:
+Slicing from 2 to -9223372036854775000: null
Slicing from -2 to -1: 8
-Slicing from -2 to -2:
-Slicing from -2 to -3:
-Slicing from -2 to -12:
+Slicing from -2 to -2: null
+Slicing from -2 to -3: null
+Slicing from -2 to -12: null
Slicing from -2 to 2147483647: 89
-Slicing from -2 to -2147483648:
+Slicing from -2 to -2147483648: null
Slicing from -2 to 9223372036854775000: 89
-Slicing from -2 to -9223372036854775000:
+Slicing from -2 to -9223372036854775000: null
Slicing from 0: 0123456789
Slicing from 2: 23456789
Slicing from -2: 89
-Slicing from 12:
+Slicing from 12: null
Slicing from -12: 0123456789
-Slicing from 2147483647:
+Slicing from 2147483647: null
Slicing from -2147483648: 0123456789
-Slicing from 9223372036854775000:
+Slicing from 9223372036854775000: null
Slicing from -9223372036854775000: 0123456789
Slicing without parameters: 0123456789
Modified: trunk/LayoutTests/fast/files/read-blob-async-expected.txt (118619 => 118620)
--- trunk/LayoutTests/fast/files/read-blob-async-expected.txt 2012-05-27 01:16:25 UTC (rev 118619)
+++ trunk/LayoutTests/fast/files/read-blob-async-expected.txt 2012-05-27 01:51:03 UTC (rev 118620)
@@ -17,8 +17,7 @@
readyState: 1
Received load event
readyState: 2
-result size: 0
-result:
+result: null
Received loadend event
Test reading a blob containing empty text
readyState: 0
@@ -26,8 +25,7 @@
readyState: 1
Received load event
readyState: 2
-result size: 0
-result:
+result: null
Received loadend event
Test reading a blob containing empty files and empty texts
readyState: 0
@@ -35,8 +33,7 @@
readyState: 1
Received load event
readyState: 2
-result size: 0
-result:
+result: null
Received loadend event
Test reading a blob containing single file
readyState: 0
Modified: trunk/LayoutTests/fast/files/read-file-async-expected.txt (118619 => 118620)
--- trunk/LayoutTests/fast/files/read-file-async-expected.txt 2012-05-27 01:16:25 UTC (rev 118619)
+++ trunk/LayoutTests/fast/files/read-file-async-expected.txt 2012-05-27 01:51:03 UTC (rev 118620)
@@ -38,8 +38,7 @@
readyState: 1
Received load event
readyState: 2
-result size: 0
-result:
+result: null
Received loadend event
Test reading an empty file as text
readyState: 0
@@ -47,8 +46,7 @@
readyState: 1
Received load event
readyState: 2
-result size: 0
-result:
+result: null
Received loadend event
Test reading an empty file as data URL
readyState: 0
@@ -190,7 +188,7 @@
result: Hello
Received loadend event
readyState after recalling read method: 1
-result after recalling read method:
+result after recalling read method: null
error after recalling read method: null
Received loadstart event
readyState: 1
@@ -206,7 +204,7 @@
error code: 1
Received loadend event
readyState after recalling read method: 1
-result after recalling read method:
+result after recalling read method: null
error after recalling read method: null
Received loadstart event
readyState: 1
Modified: trunk/LayoutTests/fast/files/resources/read-common.js (118619 => 118620)
--- trunk/LayoutTests/fast/files/resources/read-common.js 2012-05-27 01:16:25 UTC (rev 118619)
+++ trunk/LayoutTests/fast/files/resources/read-common.js 2012-05-27 01:51:03 UTC (rev 118620)
@@ -168,9 +168,13 @@
return new FileReaderSync();
}
-// 'result' can be either an ArrayBuffer object or a string.
+// 'result' can be an ArrayBuffer object, a string or null.
function logResult(result)
{
+ if (result === null) {
+ log("result: null");
+ return;
+ }
if (typeof result == 'object') {
log("result size: " + result.byteLength);
result = new Uint8Array(result, 0, result.byteLength);
Modified: trunk/LayoutTests/fast/files/workers/worker-read-blob-async-expected.txt (118619 => 118620)
--- trunk/LayoutTests/fast/files/workers/worker-read-blob-async-expected.txt 2012-05-27 01:16:25 UTC (rev 118619)
+++ trunk/LayoutTests/fast/files/workers/worker-read-blob-async-expected.txt 2012-05-27 01:51:03 UTC (rev 118620)
@@ -18,8 +18,7 @@
readyState: 1
Received load event
readyState: 2
-result size: 0
-result:
+result: null
Received loadend event
Test reading a blob containing empty text
readyState: 0
@@ -27,8 +26,7 @@
readyState: 1
Received load event
readyState: 2
-result size: 0
-result:
+result: null
Received loadend event
Test reading a blob containing empty files and empty texts
readyState: 0
@@ -36,8 +34,7 @@
readyState: 1
Received load event
readyState: 2
-result size: 0
-result:
+result: null
Received loadend event
Test reading a blob containing single file
readyState: 0
Modified: trunk/LayoutTests/fast/files/workers/worker-read-file-async-expected.txt (118619 => 118620)
--- trunk/LayoutTests/fast/files/workers/worker-read-file-async-expected.txt 2012-05-27 01:16:25 UTC (rev 118619)
+++ trunk/LayoutTests/fast/files/workers/worker-read-file-async-expected.txt 2012-05-27 01:51:03 UTC (rev 118620)
@@ -39,8 +39,7 @@
readyState: 1
Received load event
readyState: 2
-result size: 0
-result:
+result: null
Received loadend event
Test reading an empty file as text
readyState: 0
@@ -48,8 +47,7 @@
readyState: 1
Received load event
readyState: 2
-result size: 0
-result:
+result: null
Received loadend event
Test reading an empty file as data URL
readyState: 0
@@ -191,7 +189,7 @@
result: Hello
Received loadend event
readyState after recalling read method: 1
-result after recalling read method:
+result after recalling read method: null
error after recalling read method: null
Received loadstart event
readyState: 1
@@ -207,7 +205,7 @@
error code: 1
Received loadend event
readyState after recalling read method: 1
-result after recalling read method:
+result after recalling read method: null
error after recalling read method: null
Received loadstart event
readyState: 1
Modified: trunk/Source/WebCore/ChangeLog (118619 => 118620)
--- trunk/Source/WebCore/ChangeLog 2012-05-27 01:16:25 UTC (rev 118619)
+++ trunk/Source/WebCore/ChangeLog 2012-05-27 01:51:03 UTC (rev 118620)
@@ -1,3 +1,28 @@
+2012-05-26 Li Yin <[email protected]>
+
+ [FileAPI] The result attribute of FileReader shuold use null to replace empty string
+ https://bugs.webkit.org/show_bug.cgi?id=87578
+
+ Reviewed by Kentaro Hara.
+
+ From Spec: http://www.w3.org/TR/FileAPI/#filedata-attr
+ Before read method has been called or an error in reading has occurred,
+ the result attribute should be null, not empty string.
+
+ Currently, Firefox, Opera and IE 10 follows the spec, but Webkit based
+ browser don't.
+ WebKit should change the returned value empty string into null to keep
+ conformance with the spec.
+
+ Tests: fast/files/read-file-async.html
+ fast/files/blob-slice-test.html
+ fast/files/read-blob-async.html
+ fast/files/workers/worker-read-blob-async.html
+ fast/files/workers/worker-read-file-async.html
+
+ * fileapi/FileReader.cpp:
+ (WebCore::FileReader::stringResult):
+
2012-05-26 Andy Estes <[email protected]>
Fix the build when NETSCAPE_PLUGIN_API is disabled by marking a
Modified: trunk/Source/WebCore/fileapi/FileReader.cpp (118619 => 118620)
--- trunk/Source/WebCore/fileapi/FileReader.cpp 2012-05-27 01:16:25 UTC (rev 118619)
+++ trunk/Source/WebCore/fileapi/FileReader.cpp 2012-05-27 01:51:03 UTC (rev 118620)
@@ -254,7 +254,10 @@
String FileReader::stringResult()
{
- return m_loader ? m_loader->stringResult() : "";
+ String ret = m_loader ? m_loader->stringResult() : "";
+ if (ret.isEmpty())
+ return String();
+ return ret;
}
} // namespace WebCore