|
1 | 1 | <!DOCTYPE html> |
2 | 2 | <script src="../testing.js"></script> |
3 | 3 |
|
4 | | -<script id=Blob> |
| 4 | +<script id=Blob/Blob.text> |
5 | 5 | { |
6 | 6 | const parts = ["\r\nthe quick brown\rfo\rx\r", "\njumps over\r\nthe\nlazy\r", "\ndog"]; |
7 | 7 | // "transparent" ending should not modify the final buffer. |
8 | | - const blob = new Blob(parts); |
| 8 | + const blob = new Blob(parts, { type: "text/html" }); |
9 | 9 |
|
10 | 10 | const expected = parts.join(""); |
11 | 11 | testing.expectEqual(expected.length, blob.size); |
| 12 | + testing.expectEqual("text/html", blob.type); |
12 | 13 | testing.async(blob.text(), result => testing.expectEqual(expected, result)); |
13 | 14 | } |
14 | 15 |
|
|
20 | 21 | const expected = "\nhello\n\nwor\nld"; |
21 | 22 | testing.expectEqual(expected.length, blob.size); |
22 | 23 | testing.async(blob.text(), result => testing.expectEqual(expected, result)); |
| 24 | + |
| 25 | + testing.async(blob.arrayBuffer(), result => testing.expectEqual(true, result instanceof ArrayBuffer)); |
23 | 26 | } |
24 | 27 | </script> |
25 | 28 |
|
|
41 | 44 | } |
42 | 45 | </script> |
43 | 46 |
|
| 47 | +<script id=Blob.arrayBuffer/Blob.slice> |
| 48 | + { |
| 49 | + const parts = ["la", "symphonie", "des", "éclairs"]; |
| 50 | + const blob = new Blob(parts); |
| 51 | + testing.async(blob.arrayBuffer(), result => testing.expectEqual(true, result instanceof ArrayBuffer)); |
| 52 | + |
| 53 | + let temp = blob.slice(0); |
| 54 | + testing.expectEqual(blob.size, temp.size); |
| 55 | + testing.async(temp.text(), result => { |
| 56 | + testing.expectEqual("lasymphoniedeséclairs", result); |
| 57 | + }); |
| 58 | + |
| 59 | + temp = blob.slice(-4, -2, "custom"); |
| 60 | + testing.expectEqual(2, temp.size); |
| 61 | + testing.expectEqual("custom", temp.type); |
| 62 | + testing.async(temp.text(), result => testing.expectEqual("ai", result)); |
| 63 | + |
| 64 | + temp = blob.slice(14); |
| 65 | + testing.expectEqual(8, temp.size); |
| 66 | + testing.async(temp.text(), result => testing.expectEqual("éclairs", result)); |
| 67 | + |
| 68 | + temp = blob.slice(6, -10, "text/eclair"); |
| 69 | + testing.expectEqual(6, temp.size); |
| 70 | + testing.expectEqual("text/eclair", temp.type); |
| 71 | + testing.async(temp.text(), result => testing.expectEqual("honied", result)); |
| 72 | + } |
| 73 | +</script> |
| 74 | + |
44 | 75 | <!-- Firefox and Safari only --> |
45 | 76 | <script id=Blob.bytes> |
46 | 77 | { |
|
0 commit comments