Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(238)

Side by Side Diff: LayoutTests/imported/web-platform-tests/FileAPI/support/Blob.js

Issue 1236713002: Import FileAPI tests from web-platform-tests (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Ugh, stupid baselines Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 function test_blob(fn, expectations) {
2 var expected = expectations.expected,
3 type = expectations.type,
4 desc = expectations.desc;
5
6 var t = async_test(desc);
7 t.step(function() {
8 var blob = fn();
9 assert_true(blob instanceof Blob);
10 assert_false(blob instanceof File);
11 assert_equals(blob.type, type);
12 assert_equals(blob.size, expected.length);
13
14 var fr = new FileReader();
15 fr.onload = t.step_func_done(function(event) {
16 assert_equals(this.result, expected);
17 }, fr);
18 fr.onerror = t.step_func(function(e) {
19 assert_unreached("got error event on FileReader");
20 });
21 fr.readAsText(blob, "UTF-8");
22 });
23 }
24
25 function test_blob_binary(fn, expectations) {
26 var expected = expectations.expected,
27 type = expectations.type,
28 desc = expectations.desc;
29
30 var t = async_test(desc);
31 t.step(function() {
32 var blob = fn();
33 assert_true(blob instanceof Blob);
34 assert_false(blob instanceof File);
35 assert_equals(blob.type, type);
36 assert_equals(blob.size, expected.length);
37
38 var fr = new FileReader();
39 fr.onload = t.step_func_done(function(event) {
40 assert_true(this.result instanceof ArrayBuffer,
41 "Result should be an ArrayBuffer");
42 assert_array_equals(new Uint8Array(this.result), expected);
43 }, fr);
44 fr.onerror = t.step_func(function(e) {
45 assert_unreached("got error event on FileReader");
46 });
47 fr.readAsArrayBuffer(blob);
48 });
49 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698