| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <meta charset=utf-8> | 2 <meta charset=utf-8> |
| 3 <title>Blob constructor</title> | 3 <title>Blob constructor</title> |
| 4 <link rel=help href="http://dev.w3.org/2006/webapi/FileAPI/#constructorBlob"> | 4 <link rel=help href="http://dev.w3.org/2006/webapi/FileAPI/#constructorBlob"> |
| 5 <link rel=help href="https://heycam.github.io/webidl/#es-union"> | 5 <link rel=help href="https://heycam.github.io/webidl/#es-union"> |
| 6 <link rel=help href="https://heycam.github.io/webidl/#es-dictionary"> | 6 <link rel=help href="https://heycam.github.io/webidl/#es-dictionary"> |
| 7 <link rel=help href="https://heycam.github.io/webidl/#es-sequence"> | 7 <link rel=help href="https://heycam.github.io/webidl/#es-sequence"> |
| 8 <script src="/resources/testharness.js"></script> | 8 <script src="/resources/testharness.js"></script> |
| 9 <script src="/resources/testharnessreport.js"></script> | 9 <script src="/resources/testharnessreport.js"></script> |
| 10 <script src="../support/Blob.js"></script> | 10 <script src="../support/Blob.js"></script> |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 test_blob(function() { | 323 test_blob(function() { |
| 324 var select = document.createElement("select"); | 324 var select = document.createElement("select"); |
| 325 select.appendChild(document.createElement("option")); | 325 select.appendChild(document.createElement("option")); |
| 326 return new Blob(select); | 326 return new Blob(select); |
| 327 }, { | 327 }, { |
| 328 expected: "[object HTMLOptionElement]", | 328 expected: "[object HTMLOptionElement]", |
| 329 type: "", | 329 type: "", |
| 330 desc: "Passing an platform object that supports indexed properties as the blob
Parts array should work (select)." | 330 desc: "Passing an platform object that supports indexed properties as the blob
Parts array should work (select)." |
| 331 }); | 331 }); |
| 332 | 332 |
| 333 var t_ports = async_test("Passing a platform array object as the blobParts array
should work (MessagePort[])."); | 333 test_blob(function() { |
| 334 var elm = document.createElement("div"); |
| 335 elm.setAttribute("foo", "bar"); |
| 336 return new Blob(elm.attributes); |
| 337 }, { |
| 338 expected: "[object Attr]", |
| 339 type: "", |
| 340 desc: "Passing an platform object that supports indexed properties as the blob
Parts array should work (attributes)." |
| 341 }); |
| 342 |
| 343 var t_ports = async_test("Passing a FrozenArray as the blobParts array should wo
rk (FrozenArray<MessagePort>)."); |
| 334 t_ports.step(function() { | 344 t_ports.step(function() { |
| 335 var channel = new MessageChannel(); | 345 var channel = new MessageChannel(); |
| 336 channel.port2.onmessage = this.step_func(function(e) { | 346 channel.port2.onmessage = this.step_func(function(e) { |
| 337 var b_ports = new Blob(e.ports); | 347 var b_ports = new Blob(e.ports); |
| 338 assert_equals(b_ports.size, "[object MessagePort]".length); | 348 assert_equals(b_ports.size, "[object MessagePort]".length); |
| 339 this.done(); | 349 this.done(); |
| 340 }); | 350 }); |
| 341 var channel2 = new MessageChannel(); | 351 var channel2 = new MessageChannel(); |
| 342 channel.port1.postMessage('', [channel2.port1]); | 352 channel.port1.postMessage('', [channel2.port1]); |
| 343 }); | 353 }); |
| 344 | 354 |
| 345 test_blob(function() { | 355 test_blob(function() { |
| 346 var elm = document.createElement("div"); | |
| 347 elm.setAttribute("foo", "bar"); | |
| 348 return new Blob(elm.attributes); | |
| 349 }, { | |
| 350 expected: "[object Attr]", | |
| 351 type: "", | |
| 352 desc: "Passing a platform array object as the blobParts array should work (Att
r[])." | |
| 353 }); | |
| 354 | |
| 355 test_blob(function() { | |
| 356 var blob = new Blob(['foo']); | 356 var blob = new Blob(['foo']); |
| 357 return new Blob([blob, blob]); | 357 return new Blob([blob, blob]); |
| 358 }, { | 358 }, { |
| 359 expected: "foofoo", | 359 expected: "foofoo", |
| 360 type: "", | 360 type: "", |
| 361 desc: "Array with two blobs" | 361 desc: "Array with two blobs" |
| 362 }); | 362 }); |
| 363 | 363 |
| 364 test_blob_binary(function() { | 364 test_blob_binary(function() { |
| 365 var view = new Uint8Array([0, 255, 0]); | 365 var view = new Uint8Array([0, 255, 0]); |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 ]; | 486 ]; |
| 487 | 487 |
| 488 type_tests.forEach(function(t) { | 488 type_tests.forEach(function(t) { |
| 489 test(function() { | 489 test(function() { |
| 490 var arr = new Uint8Array([t[0]]).buffer; | 490 var arr = new Uint8Array([t[0]]).buffer; |
| 491 var b = new Blob([arr], {type:t[1]}); | 491 var b = new Blob([arr], {type:t[1]}); |
| 492 assert_equals(b.type, t[2]); | 492 assert_equals(b.type, t[2]); |
| 493 }, "Blob with type " + format_value(t[1])); | 493 }, "Blob with type " + format_value(t[1])); |
| 494 }); | 494 }); |
| 495 </script> | 495 </script> |
| OLD | NEW |