diff options
author | Ms2ger <Ms2ger@gmail.com> | 2016-03-15 15:55:36 +0100 |
---|---|---|
committer | Ms2ger <Ms2ger@gmail.com> | 2016-03-15 16:34:24 +0100 |
commit | a91433f0c87a8ef094be98d8849b7f661d5ad5e5 (patch) | |
tree | 6b6ffdf85096c309d7be8c63e825615c05487221 /tests/wpt/web-platform-tests/FileAPI/blob | |
parent | 183772583fcbb1f8103e8d6542a620134ba9182e (diff) | |
download | servo-a91433f0c87a8ef094be98d8849b7f661d5ad5e5.tar.gz servo-a91433f0c87a8ef094be98d8849b7f661d5ad5e5.zip |
Update web-platform-tests to revision 66c4613f823c4384c78ada77346eda17bb128947
Diffstat (limited to 'tests/wpt/web-platform-tests/FileAPI/blob')
3 files changed, 95 insertions, 45 deletions
diff --git a/tests/wpt/web-platform-tests/FileAPI/blob/Blob-constructor.html b/tests/wpt/web-platform-tests/FileAPI/blob/Blob-constructor.html index dced17de0a5..799091d55ac 100644 --- a/tests/wpt/web-platform-tests/FileAPI/blob/Blob-constructor.html +++ b/tests/wpt/web-platform-tests/FileAPI/blob/Blob-constructor.html @@ -8,11 +8,7 @@ <script src="/resources/testharness.js"></script> <script src="/resources/testharnessreport.js"></script> <script src="../support/Blob.js"></script> -<p><strong><a href="https://www.w3.org/Bugs/Public/show_bug.cgi?id=23683">Discussion</a> -is ongoing that will affect a number of the following tests.</strong> <div id="log"></div> -<!-- used by "platform object that supports indexed properties" tests --> -<iframe style="display:none"></iframe> <script> test(function() { assert_true("Blob" in window, "window should have a Blob property."); @@ -51,6 +47,10 @@ test(function() { "FAIL", new Date(), new RegExp(), + {}, + { 0: "FAIL", length: 1 }, + document.createElement("div"), + window, ]; args.forEach(function(arg) { assert_throws(new TypeError(), function() { @@ -60,18 +60,24 @@ test(function() { }, "Passing non-objects, Dates and RegExps for blobParts should throw a TypeError."); test_blob(function() { - return new Blob({}); + return new Blob({ + [Symbol.iterator]: Array.prototype[Symbol.iterator], + }); }, { expected: "", type: "", - desc: "A plain object should be treated as a sequence for the blobParts argument." + desc: "A plain object with @@iterator should be treated as a sequence for the blobParts argument." }); test_blob(function() { - return new Blob({ 0: "PASS", length: 1 }); + return new Blob({ + [Symbol.iterator]: Array.prototype[Symbol.iterator], + 0: "PASS", + length: 1 + }); }, { expected: "PASS", type: "", - desc: "A plain object with a length property should be treated as a sequence for the blobParts argument." + desc: "A plain object with @@iterator and a length property should be treated as a sequence for the blobParts argument." }); test_blob(function() { return new Blob(new String("xyz")); @@ -88,10 +94,14 @@ test_blob(function() { desc: "A Uint8Array object should be treated as a sequence for the blobParts argument." }); -var test_error = { name: "test" }; +var test_error = { + name: "test", + message: "test error", +}; test(function() { var obj = { + [Symbol.iterator]: Array.prototype[Symbol.iterator], get length() { throw test_error; } }; assert_throws(test_error, function() { @@ -99,7 +109,7 @@ test(function() { }); }, "The length getter should be invoked and any exceptions should be propagated."); -test_blob(function() { +test(function() { var element = document.createElement("div"); element.appendChild(document.createElement("div")); element.appendChild(document.createElement("p")); @@ -107,16 +117,15 @@ test_blob(function() { Object.defineProperty(list, "length", { get: function() { throw test_error; } }); - return new Blob(list); -}, { - expected: "[object HTMLDivElement][object HTMLParagraphElement]", - type: "", - desc: "A platform object that supports indexed properties should be treated as a sequence for the blobParts argument (overwritten 'length'.)" -}); + assert_throws(test_error, function() { + new Blob(list); + }); +}, "A platform object that supports indexed properties should be treated as a sequence for the blobParts argument (overwritten 'length'.)"); test(function() { assert_throws(test_error, function() { var obj = { + [Symbol.iterator]: Array.prototype[Symbol.iterator], length: { valueOf: null, toString: function() { throw test_error; } @@ -126,6 +135,7 @@ test(function() { }); assert_throws(test_error, function() { var obj = { + [Symbol.iterator]: Array.prototype[Symbol.iterator], length: { valueOf: function() { throw test_error; } } }; new Blob(obj); @@ -135,6 +145,10 @@ test(function() { test(function() { var received = []; var obj = { + get [Symbol.iterator]() { + received.push("Symbol.iterator"); + return Array.prototype[Symbol.iterator]; + }, get length() { received.push("length getter"); return { @@ -166,15 +180,18 @@ test(function() { new Blob(obj); }); assert_array_equals(received, [ + "Symbol.iterator", "length getter", "length valueOf", "0 getter", "0 toString", - "1 getter" + "length getter", + "length valueOf", + "1 getter", ]); }, "Getters and value conversions should happen in order until an exception is thrown."); -// XXX should add tests edge cases of ToUint32(length) +// XXX should add tests edge cases of ToLength(length) test(function() { assert_throws(test_error, function() { @@ -201,7 +218,7 @@ test_blob(function() { ]; return new Blob(arr); }, { - expected: "PASSundefined", + expected: "PASS", type: "", desc: "Changes to the blobParts array should be reflected in the returned Blob (pop)." }); @@ -211,19 +228,19 @@ test_blob(function() { { toString: function() { if (arr.length === 3) { - return "SS"; + return "A"; } arr.unshift({ toString: function() { assert_unreached("Should only access index 0 once."); } }); - return "PA"; + return "P"; } }, { toString: function() { - assert_unreached("Should not access the final element."); + return "SS"; } } ]; @@ -298,29 +315,6 @@ test_blob(function() { }); test_blob(function() { - return new Blob(document.createElement("div")); -}, { - expected: "", - type: "", - desc: "Passing an element as the blobParts array should work." -}); - -test_blob(function() { - return new Blob(window); -}, { - expected: "[object Window]", - type: "", - desc: "Passing an platform object that supports indexed properties as the blobParts array should work (window)." -}); -test_blob(function() { - window[0].toString = function() { return "foo"; }; - return new Blob(window); -}, { - expected: "foo", - type: "", - desc: "Passing an platform object that supports indexed properties as the blobParts array should work (window with custom toString)." -}); -test_blob(function() { var select = document.createElement("select"); select.appendChild(document.createElement("option")); return new Blob(select); diff --git a/tests/wpt/web-platform-tests/FileAPI/blob/Blob-in-worker.worker.js b/tests/wpt/web-platform-tests/FileAPI/blob/Blob-in-worker.worker.js new file mode 100644 index 00000000000..a67060e7b85 --- /dev/null +++ b/tests/wpt/web-platform-tests/FileAPI/blob/Blob-in-worker.worker.js @@ -0,0 +1,14 @@ +importScripts("/resources/testharness.js"); + +async_test(function() { + var data = "TEST"; + var blob = new Blob([data], {type: "text/plain"}); + var reader = new FileReader(); + reader.onload = this.step_func_done(function() { + assert_equals(reader.result, data); + }); + reader.onerror = this.unreached_func("Unexpected error event"); + reader.readAsText(blob); +}, "Create Blob in Worker"); + +done(); diff --git a/tests/wpt/web-platform-tests/FileAPI/blob/Blob-slice-overflow.html b/tests/wpt/web-platform-tests/FileAPI/blob/Blob-slice-overflow.html new file mode 100644 index 00000000000..56891af5f17 --- /dev/null +++ b/tests/wpt/web-platform-tests/FileAPI/blob/Blob-slice-overflow.html @@ -0,0 +1,42 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>Blob slice overflow</title> +<link rel="author" title="Intel" href="http://www.intel.com"> +<link rel="help" href="https://w3c.github.io/FileAPI/#dfn-slice"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> + +var text = ''; + +for (var i = 0; i < 2000; ++i) { + text += 'A'; +} + +test(function() { + var blob = new Blob([text]); + var sliceBlob = blob.slice(-1, 2000); + assert_equals(sliceBlob.size, 2000-(2000-1), "Bolb slice size"); +}, "slice start is negative, relativeStart will be max((size + start), 0)"); + +test(function() { + var blob = new Blob([text]); + var sliceBlob = blob.slice(2001, 2000); + assert_equals(sliceBlob.size, 0, "Bolb slice size"); +}, "slice start is greater than blob size, relativeStart will be min(start, size)"); + +test(function() { + var blob = new Blob([text]); + var sliceBlob = blob.slice(1998, -1); + assert_equals(sliceBlob.size, (2000-1)-1998, "Bolb slice size"); +}, "slice end is negative, relativeEnd will be max((size + end), 0)"); + +test(function() { + var blob = new Blob([text]); + var sliceBlob = blob.slice(1998, 2999); + assert_equals(sliceBlob.size, 2000-1998, "Bolb slice size"); +}, "slice end is greater than blob size, relativeEnd will be min(end, size)"); + +</script> + |