diff options
Diffstat (limited to 'third_party/WebKit/LayoutTests')
22 files changed, 1033 insertions, 380 deletions
diff --git a/third_party/WebKit/LayoutTests/fast/files/blob-constructor-expected.txt b/third_party/WebKit/LayoutTests/fast/files/blob-constructor-expected.txt index 35e7b05..8d65661 100644 --- a/third_party/WebKit/LayoutTests/fast/files/blob-constructor-expected.txt +++ b/third_party/WebKit/LayoutTests/fast/files/blob-constructor-expected.txt @@ -24,13 +24,13 @@ PASS (new Blob([document])).size is 21 PASS (new Blob([toStringingObj])).size is 8 PASS new Blob([throwingObj]) threw exception Error. PASS (new Blob([], {unknownKey:'value'})) instanceof window.Blob is true -PASS new Blob([], {endings:'illegalValue'}) threw exception TypeError: Failed to construct 'Blob': The 2nd argument's "endings" property must be either "transparent" or "native".. +PASS new Blob([], {endings:'illegalValue'}) threw exception TypeError: Failed to construct 'Blob': The "endings" property must be either "transparent" or "native".. PASS new Blob([], {endings:throwingObj}) threw exception Error. PASS new Blob([], {type:throwingObj}) threw exception Error. -PASS new Blob([], {type:'helloî'}) threw exception SyntaxError: Failed to construct 'Blob': The 2nd argument's "type" property must consist of ASCII characters.. +PASS new Blob([], {type:'helloî'}) threw exception SyntaxError: Failed to construct 'Blob': The "type" property must consist of ASCII characters.. PASS new Blob([], {endings:throwingObj1, type:throwingObj2}) threw exception Error 1. PASS new Blob([], {type:throwingObj2, endings:throwingObj1}) threw exception Error 1. -PASS new Blob([], {type:throwingObj2, endings:'illegal'}) threw exception TypeError: Failed to construct 'Blob': The 2nd argument's "endings" property must be either "transparent" or "native".. +PASS new Blob([], {type:throwingObj2, endings:'illegal'}) threw exception TypeError: Failed to construct 'Blob': The "endings" property must be either "transparent" or "native".. PASS (new Blob([], null)) instanceof window.Blob threw exception TypeError: Failed to construct 'Blob': The 2nd argument is not of type Object.. PASS (new Blob([], undefined)) instanceof window.Blob threw exception TypeError: Failed to construct 'Blob': The 2nd argument is not of type Object.. PASS (new Blob([], 123)) instanceof window.Blob threw exception TypeError: Failed to construct 'Blob': The 2nd argument is not of type Object.. @@ -43,7 +43,7 @@ PASS (new Blob([], function () {})) instanceof window.Blob is true PASS (new Blob([], {type:'text/html'})).type is 'text/html' PASS (new Blob([], {type:'text/html'})).size is 0 PASS (new Blob([], {type:'text/plain;charset=UTF-8'})).type is 'text/plain;charset=utf-8' -FAIL window.Blob.length should be 2. Was 0. +PASS window.Blob.length is 0 PASS new Blob([new DataView(new ArrayBuffer(100))]).size is 100 PASS new Blob([new Uint8Array(100)]).size is 100 PASS new Blob([new Uint8ClampedArray(100)]).size is 100 @@ -73,7 +73,7 @@ PASS new Blob({length: 0}).size is 0 PASS new Blob({length: 1, 0: 'string'}).size is 6 PASS new Blob({length: 2, 0: new Uint8Array(100), 1: new Int16Array(100)}).size is 300 PASS new Blob({length: 1, 0: 'string'}, {type: 'text/html'}).type is 'text/html' -PASS new Blob({length: 0}, {endings:'illegal'}) threw exception TypeError: Failed to construct 'Blob': The 2nd argument's "endings" property must be either "transparent" or "native".. +PASS new Blob({length: 0}, {endings:'illegal'}) threw exception TypeError: Failed to construct 'Blob': The "endings" property must be either "transparent" or "native".. PASS new Blob(throwingSequence) threw exception Error: Misbehaving property. PASS successfullyParsed is true diff --git a/third_party/WebKit/LayoutTests/fast/files/blob-constructor.html b/third_party/WebKit/LayoutTests/fast/files/blob-constructor.html index 08e22a9..f5c125f 100644 --- a/third_party/WebKit/LayoutTests/fast/files/blob-constructor.html +++ b/third_party/WebKit/LayoutTests/fast/files/blob-constructor.html @@ -1,9 +1,119 @@ -<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> -<html> -<head> +<!DOCTYPE html> + <script src="../../resources/js-test.js"></script> -</head> -<body> -<script src="script-tests/blob-constructor.js"></script> -</body> -</html> +<script> +description("Test the Blob constructor."); + +// Test the different ways you can construct a Blob. +shouldBeTrue("(new Blob()) instanceof window.Blob"); +shouldBeTrue("(new Blob([])) instanceof window.Blob"); +shouldBeTrue("(new Blob(['hello'])) instanceof window.Blob"); +shouldBeTrue("(new Blob(['hello'], {})) instanceof window.Blob"); +shouldBeTrue("(new Blob(['hello'], {type:'text/html'})) instanceof window.Blob"); +shouldBeTrue("(new Blob(['hello'], {type:'text/html', endings:'native'})) instanceof window.Blob"); +shouldBeTrue("(new Blob(['hello'], {type:'text/html', endings:'transparent'})) instanceof window.Blob"); + +// Test invalid blob parts. +shouldThrow("new Blob('hello')", '"TypeError: Failed to construct \'Blob\': The 1st argument is neither an array, nor does it have indexed properties."'); +shouldThrow("new Blob(0)", '"TypeError: Failed to construct \'Blob\': The 1st argument is neither an array, nor does it have indexed properties."'); + +// Test valid blob parts. +shouldBeTrue("(new Blob([])) instanceof window.Blob"); +shouldBeTrue("(new Blob(['stringPrimitive'])) instanceof window.Blob"); +shouldBeTrue("(new Blob([String('stringObject')])) instanceof window.Blob"); +shouldBeTrue("(new Blob([new Blob])) instanceof window.Blob"); +shouldBeTrue("(new Blob([new Blob([new Blob])])) instanceof window.Blob"); + +// Test some conversions to string in the parts array. +shouldBe("(new Blob([12])).size", "2"); +shouldBe("(new Blob([[]])).size", "0"); // [].toString() is the empty string +shouldBe("(new Blob([{}])).size", "15");; // {}.toString() is the string "[object Object]" +shouldBe("(new Blob([document])).size", "21"); // document.toString() is the string "[object HTMLDocument]" + +var toStringingObj = { toString: function() { return "A string"; } }; +shouldBe("(new Blob([toStringingObj])).size", "8"); + +var throwingObj = { toString: function() { throw "Error"; } }; +shouldThrow("new Blob([throwingObj])", "'Error'"); + +// Test some invalid property bags. +shouldBeTrue("(new Blob([], {unknownKey:'value'})) instanceof window.Blob"); // Ignore invalid keys +shouldThrow("new Blob([], {endings:'illegalValue'})", "'TypeError: Failed to construct \\'Blob\\': The \"endings\" property must be either \"transparent\" or \"native\".'"); +shouldThrow("new Blob([], {endings:throwingObj})", "'Error'"); +shouldThrow("new Blob([], {type:throwingObj})", "'Error'"); +shouldThrow("new Blob([], {type:'hello\u00EE'})", "'SyntaxError: Failed to construct \\'Blob\\': The \"type\" property must consist of ASCII characters.'"); + +// Test that order of property bag evaluation is lexigraphical +var throwingObj1 = { toString: function() { throw "Error 1"; } }; +var throwingObj2 = { toString: function() { throw "Error 2"; } }; +shouldThrow("new Blob([], {endings:throwingObj1, type:throwingObj2})", "'Error 1'"); +shouldThrow("new Blob([], {type:throwingObj2, endings:throwingObj1})", "'Error 1'"); +shouldThrow("new Blob([], {type:throwingObj2, endings:'illegal'})", "'TypeError: Failed to construct \\'Blob\\': The \"endings\" property must be either \"transparent\" or \"native\".'"); + +// Test various non-object literals being used as property bags. +shouldThrow("(new Blob([], null)) instanceof window.Blob", "'TypeError: Failed to construct \\'Blob\\': The 2nd argument is not of type Object.'"); +shouldThrow("(new Blob([], undefined)) instanceof window.Blob", "'TypeError: Failed to construct \\'Blob\\': The 2nd argument is not of type Object.'"); +shouldThrow("(new Blob([], 123)) instanceof window.Blob", "'TypeError: Failed to construct \\'Blob\\': The 2nd argument is not of type Object.'"); +shouldThrow("(new Blob([], 123.4)) instanceof window.Blob", "'TypeError: Failed to construct \\'Blob\\': The 2nd argument is not of type Object.'"); +shouldThrow("(new Blob([], true)) instanceof window.Blob", "'TypeError: Failed to construct \\'Blob\\': The 2nd argument is not of type Object.'"); +shouldThrow("(new Blob([], 'abc')) instanceof window.Blob", "'TypeError: Failed to construct \\'Blob\\': The 2nd argument is not of type Object.'"); +shouldBeTrue("(new Blob([], [])) instanceof window.Blob"); +shouldBeTrue("(new Blob([], /abc/)) instanceof window.Blob"); +shouldBeTrue("(new Blob([], function () {})) instanceof window.Blob"); + +// Test that the type/size is correctly added to the Blob +shouldBe("(new Blob([], {type:'text/html'})).type", "'text/html'"); +shouldBe("(new Blob([], {type:'text/html'})).size", "0"); +shouldBe("(new Blob([], {type:'text/plain;charset=UTF-8'})).type", "'text/plain;charset=utf-8'"); + +// Test the number of expected arguments in the Blob constructor. +shouldBe("window.Blob.length", "0"); + +// Test ArrayBufferView parameters. +shouldBe("new Blob([new DataView(new ArrayBuffer(100))]).size", "100"); +shouldBe("new Blob([new Uint8Array(100)]).size", "100"); +shouldBe("new Blob([new Uint8ClampedArray(100)]).size", "100"); +shouldBe("new Blob([new Uint16Array(100)]).size", "200"); +shouldBe("new Blob([new Uint32Array(100)]).size", "400"); +shouldBe("new Blob([new Int8Array(100)]).size", "100"); +shouldBe("new Blob([new Int16Array(100)]).size", "200"); +shouldBe("new Blob([new Int32Array(100)]).size", "400"); +shouldBe("new Blob([new Float32Array(100)]).size", "400"); +shouldBe("new Blob([new Float64Array(100)]).size", "800"); +shouldBe("new Blob([new Float64Array(100), new Int32Array(100), new Uint8Array(100), new DataView(new ArrayBuffer(100))]).size", "1400"); +shouldBe("new Blob([new Blob([new Int32Array(100)]), new Uint8Array(100), new Float32Array(100), new DataView(new ArrayBuffer(100))]).size", "1000"); + +// Test ArrayBuffer parameters. +shouldBe("new Blob([(new DataView(new ArrayBuffer(100))).buffer]).size", "100"); +shouldBe("new Blob([(new Uint8Array(100)).buffer]).size", "100"); +shouldBe("new Blob([(new Uint8ClampedArray(100)).buffer]).size", "100"); +shouldBe("new Blob([(new Uint16Array(100)).buffer]).size", "200"); +shouldBe("new Blob([(new Uint32Array(100)).buffer]).size", "400"); +shouldBe("new Blob([(new Int8Array(100)).buffer]).size", "100"); +shouldBe("new Blob([(new Int16Array(100)).buffer]).size", "200"); +shouldBe("new Blob([(new Int32Array(100)).buffer]).size", "400"); +shouldBe("new Blob([(new Float32Array(100)).buffer]).size", "400"); +shouldBe("new Blob([(new Float64Array(100)).buffer]).size", "800"); +shouldBe("new Blob([(new Float64Array(100)).buffer, (new Int32Array(100)).buffer, (new Uint8Array(100)).buffer, (new DataView(new ArrayBuffer(100))).buffer]).size", "1400"); +shouldBe("new Blob([new Blob([(new Int32Array(100)).buffer]), (new Uint8Array(100)).buffer, (new Float32Array(100)).buffer, (new DataView(new ArrayBuffer(100))).buffer]).size", "1000"); + +// Test passing blob parts in sequences. +shouldBeTrue("new Blob({length: 0}) instanceof window.Blob"); +shouldBe("new Blob({length: 0}).size", "0"); +shouldBe("new Blob({length: 1, 0: 'string'}).size", "6"); +shouldBe("new Blob({length: 2, 0: new Uint8Array(100), 1: new Int16Array(100)}).size", "300"); +shouldBe("new Blob({length: 1, 0: 'string'}, {type: 'text/html'}).type", "'text/html'"); +shouldThrow("new Blob({length: 0}, {endings:'illegal'})", "'TypeError: Failed to construct \\'Blob\\': The \"endings\" property must be either \"transparent\" or \"native\".'"); + +// Test passing blog parts in a sequence-like object that throws on property access. +var throwingSequence = {length: 4, 0: 'hello', 3: 'world'}; +Object.defineProperty(throwingSequence, "1", { + get: function() { throw new Error("Misbehaving property"); }, + enumerable: true, configurable: true +}); +Object.defineProperty(throwingSequence, "2", { + get: function() { throw new Error("This should not be thrown"); }, + enumerable: true, configurable: true +}); +shouldThrow("new Blob(throwingSequence)", "'Error: Misbehaving property'"); +</script> diff --git a/third_party/WebKit/LayoutTests/fast/files/blob-parts-slice-test-expected.txt b/third_party/WebKit/LayoutTests/fast/files/blob-parts-slice-test-expected.txt new file mode 100644 index 0000000..87727d8 --- /dev/null +++ b/third_party/WebKit/LayoutTests/fast/files/blob-parts-slice-test-expected.txt @@ -0,0 +1,117 @@ +Test the Blob.slice() behavior for Blobs made of multiple parts. + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +Blob .slice(2, 3) +PASS blobContents is "2" +File .slice(2, 3) +PASS fileContents is "2" +Blob .slice(2, 12) +PASS blobContents is "23456789" +File .slice(2, 12) +PASS fileContents is "23456789" +Blob .slice(2, 2) +PASS blobContents is "" +File .slice(2, 2) +PASS fileContents is "" +Blob .slice(2, 1) +PASS blobContents is "" +File .slice(2, 1) +PASS fileContents is "" +Blob .slice(2, -12) +PASS blobContents is "" +File .slice(2, -12) +PASS fileContents is "" +Blob .slice(2, 2147483647) +PASS blobContents is "23456789" +File .slice(2, 2147483647) +PASS fileContents is "23456789" +Blob .slice(2, -2147483648) +PASS blobContents is "" +File .slice(2, -2147483648) +PASS fileContents is "" +Blob .slice(2, 9223372036854775000) +PASS blobContents is "23456789" +File .slice(2, 9223372036854775000) +PASS fileContents is "23456789" +Blob .slice(2, -9223372036854775000) +PASS blobContents is "" +File .slice(2, -9223372036854775000) +PASS fileContents is "" +Blob .slice(-2, -1) +PASS blobContents is "8" +File .slice(-2, -1) +PASS fileContents is "8" +Blob .slice(-2, -2) +PASS blobContents is "" +File .slice(-2, -2) +PASS fileContents is "" +Blob .slice(-2, -3) +PASS blobContents is "" +File .slice(-2, -3) +PASS fileContents is "" +Blob .slice(-2, -12) +PASS blobContents is "" +File .slice(-2, -12) +PASS fileContents is "" +Blob .slice(-2, 2147483647) +PASS blobContents is "89" +File .slice(-2, 2147483647) +PASS fileContents is "89" +Blob .slice(-2, -2147483648) +PASS blobContents is "" +File .slice(-2, -2147483648) +PASS fileContents is "" +Blob .slice(-2, 9223372036854775000) +PASS blobContents is "89" +File .slice(-2, 9223372036854775000) +PASS fileContents is "89" +Blob .slice(-2, -9223372036854775000) +PASS blobContents is "" +File .slice(-2, -9223372036854775000) +PASS fileContents is "" +Blob .slice(0) +PASS blobContents is "0123456789" +File .slice(0) +PASS fileContents is "0123456789" +Blob .slice(2) +PASS blobContents is "23456789" +File .slice(2) +PASS fileContents is "23456789" +Blob .slice(-2) +PASS blobContents is "89" +File .slice(-2) +PASS fileContents is "89" +Blob .slice(12) +PASS blobContents is "" +File .slice(12) +PASS fileContents is "" +Blob .slice(-12) +PASS blobContents is "0123456789" +File .slice(-12) +PASS fileContents is "0123456789" +Blob .slice(2147483647) +PASS blobContents is "" +File .slice(2147483647) +PASS fileContents is "" +Blob .slice(-2147483648) +PASS blobContents is "0123456789" +File .slice(-2147483648) +PASS fileContents is "0123456789" +Blob .slice(9223372036854775000) +PASS blobContents is "" +File .slice(9223372036854775000) +PASS fileContents is "" +Blob .slice(-9223372036854775000) +PASS blobContents is "0123456789" +File .slice(-9223372036854775000) +PASS fileContents is "0123456789" +Blob .slice() +PASS blobContents is "0123456789" +File .slice() +PASS fileContents is "0123456789" +PASS successfullyParsed is true + +TEST COMPLETE + diff --git a/third_party/WebKit/LayoutTests/fast/files/blob-parts-slice-test.html b/third_party/WebKit/LayoutTests/fast/files/blob-parts-slice-test.html new file mode 100644 index 0000000..9f2f47b --- /dev/null +++ b/third_party/WebKit/LayoutTests/fast/files/blob-parts-slice-test.html @@ -0,0 +1,55 @@ +<!DOCTYPE html> +<html> +<head> +<script src="../../resources/js-test.js"></script> +<script src="resources/blob-slice-common.js"></script> +<script> +description("Test the Blob.slice() behavior for Blobs made of multiple parts."); + +var sliceTestCases = [ + [2, 3, "2"], + [2, 12, "23456789"], + [2, 2, ""], + [2, 1, ""], + [2, -12, ""], + [2, 2147483647, "23456789"], + [2, -2147483648, ""], + [2, 9223372036854775000, "23456789"], + [2, -9223372036854775000, ""], + [-2, -1, "8"], + [-2, -2, ""], + [-2, -3, ""], + [-2, -12, ""], + [-2, 2147483647, "89"], + [-2, -2147483648, ""], + [-2, 9223372036854775000, "89"], + [-2, -9223372036854775000, ""], + [0, null, "0123456789"], + [2, null, "23456789"], + [-2, null, "89"], + [12, null, ""], + [-12, null, "0123456789"], + [2147483647, null, ""], + [-2147483648, null, "0123456789"], + [9223372036854775000, null, ""], + [-9223372036854775000, null, "0123456789"], + [null, null, "0123456789"], +]; + +function runTests() +{ + blob = new Blob(["0", new File(["12"], "slice-piece.txt"), + new Blob(["345"]), "6789"]); + file = new File(["0", new File(["12"], "slice-piece.txt"), + new Blob(["345"]), "6789"], "slice-text.txt"); + + runNextTest(); +} + +window.jsTestIsAsync = true; +</script> +</head> +<body onload="runTests()"> +<pre id='console'></pre> +</body> +</html> diff --git a/third_party/WebKit/LayoutTests/fast/files/blob-slice-test-expected.txt b/third_party/WebKit/LayoutTests/fast/files/blob-slice-test-expected.txt index 0f274d3..2f12c4f 100644 --- a/third_party/WebKit/LayoutTests/fast/files/blob-slice-test-expected.txt +++ b/third_party/WebKit/LayoutTests/fast/files/blob-slice-test-expected.txt @@ -1,28 +1,117 @@ -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 2147483647: 23456789 -Slicing from 2 to -2147483648: -Slicing from 2 to 9223372036854775000: 23456789 -Slicing from 2 to -9223372036854775000: -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 2147483647: 89 -Slicing from -2 to -2147483648: -Slicing from -2 to 9223372036854775000: 89 -Slicing from -2 to -9223372036854775000: -Slicing from 0: 0123456789 -Slicing from 2: 23456789 -Slicing from -2: 89 -Slicing from 12: -Slicing from -12: 0123456789 -Slicing from 2147483647: -Slicing from -2147483648: 0123456789 -Slicing from 9223372036854775000: -Slicing from -9223372036854775000: 0123456789 -Slicing without parameters: 0123456789 +Test Blob.slice(). + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +Blob .slice(2, 3) +PASS blobContents is "2" +File .slice(2, 3) +PASS fileContents is "2" +Blob .slice(2, 12) +PASS blobContents is "23456789" +File .slice(2, 12) +PASS fileContents is "23456789" +Blob .slice(2, 2) +PASS blobContents is "" +File .slice(2, 2) +PASS fileContents is "" +Blob .slice(2, 1) +PASS blobContents is "" +File .slice(2, 1) +PASS fileContents is "" +Blob .slice(2, -12) +PASS blobContents is "" +File .slice(2, -12) +PASS fileContents is "" +Blob .slice(2, 2147483647) +PASS blobContents is "23456789" +File .slice(2, 2147483647) +PASS fileContents is "23456789" +Blob .slice(2, -2147483648) +PASS blobContents is "" +File .slice(2, -2147483648) +PASS fileContents is "" +Blob .slice(2, 9223372036854775000) +PASS blobContents is "23456789" +File .slice(2, 9223372036854775000) +PASS fileContents is "23456789" +Blob .slice(2, -9223372036854775000) +PASS blobContents is "" +File .slice(2, -9223372036854775000) +PASS fileContents is "" +Blob .slice(-2, -1) +PASS blobContents is "8" +File .slice(-2, -1) +PASS fileContents is "8" +Blob .slice(-2, -2) +PASS blobContents is "" +File .slice(-2, -2) +PASS fileContents is "" +Blob .slice(-2, -3) +PASS blobContents is "" +File .slice(-2, -3) +PASS fileContents is "" +Blob .slice(-2, -12) +PASS blobContents is "" +File .slice(-2, -12) +PASS fileContents is "" +Blob .slice(-2, 2147483647) +PASS blobContents is "89" +File .slice(-2, 2147483647) +PASS fileContents is "89" +Blob .slice(-2, -2147483648) +PASS blobContents is "" +File .slice(-2, -2147483648) +PASS fileContents is "" +Blob .slice(-2, 9223372036854775000) +PASS blobContents is "89" +File .slice(-2, 9223372036854775000) +PASS fileContents is "89" +Blob .slice(-2, -9223372036854775000) +PASS blobContents is "" +File .slice(-2, -9223372036854775000) +PASS fileContents is "" +Blob .slice(0) +PASS blobContents is "0123456789" +File .slice(0) +PASS fileContents is "0123456789" +Blob .slice(2) +PASS blobContents is "23456789" +File .slice(2) +PASS fileContents is "23456789" +Blob .slice(-2) +PASS blobContents is "89" +File .slice(-2) +PASS fileContents is "89" +Blob .slice(12) +PASS blobContents is "" +File .slice(12) +PASS fileContents is "" +Blob .slice(-12) +PASS blobContents is "0123456789" +File .slice(-12) +PASS fileContents is "0123456789" +Blob .slice(2147483647) +PASS blobContents is "" +File .slice(2147483647) +PASS fileContents is "" +Blob .slice(-2147483648) +PASS blobContents is "0123456789" +File .slice(-2147483648) +PASS fileContents is "0123456789" +Blob .slice(9223372036854775000) +PASS blobContents is "" +File .slice(9223372036854775000) +PASS fileContents is "" +Blob .slice(-9223372036854775000) +PASS blobContents is "0123456789" +File .slice(-9223372036854775000) +PASS fileContents is "0123456789" +Blob .slice() +PASS blobContents is "0123456789" +File .slice() +PASS fileContents is "0123456789" +PASS successfullyParsed is true + +TEST COMPLETE diff --git a/third_party/WebKit/LayoutTests/fast/files/blob-slice-test.html b/third_party/WebKit/LayoutTests/fast/files/blob-slice-test.html index 06fec6e..e6a2989 100644 --- a/third_party/WebKit/LayoutTests/fast/files/blob-slice-test.html +++ b/third_party/WebKit/LayoutTests/fast/files/blob-slice-test.html @@ -1,96 +1,50 @@ <!DOCTYPE html> <html> <head> +<script src="../../resources/js-test.js"></script> +<script src="resources/blob-slice-common.js"></script> <script> -var blob; -var testIndex = 0; -var sliceParams = [ - [2, 3], - [2, 12], - [2, 2], - [2, 1], - [2, -12], - [2, 2147483647], - [2, -2147483648], - [2, 9223372036854775000], - [2, -9223372036854775000], - [-2, -1], - [-2, -2], - [-2, -3], - [-2, -12], - [-2, 2147483647], - [-2, -2147483648], - [-2, 9223372036854775000], - [-2, -9223372036854775000], - [0], - [2], - [-2], - [12], - [-12], - [2147483647], - [-2147483648], - [9223372036854775000], - [-9223372036854775000], - [], -]; - -function log(message) -{ - document.getElementById('console').appendChild(document.createTextNode(message + "\n")); -} - -function testSlicing(start, end) -{ - var subBlob; - var reader = new FileReader(); - var message = "Slicing "; - if (start == undefined && end == undefined) { - message += "without parameters"; - subBlob = blob.slice(); - } else if (end == undefined) { - message += "from " + start; - subBlob = blob.slice(start); - } else { - message += "from " + start + " to " + end; - subBlob = blob.slice(start, end); - } - message += ": "; - reader.onload = function(event) { - log(message + event.target.result); - runNextTest(); - }; - reader.onerror = function(event) { - log(message + "error " + event.target.error.code); - runNextTest(); - }; - reader.readAsText(subBlob); -} - -function runNextTest() -{ - if (testIndex >= sliceParams.length) { - if (window.testRunner) - testRunner.notifyDone(); - return; - } +description("Test Blob.slice()."); - var start = sliceParams[testIndex][0]; - var end = sliceParams[testIndex][1]; - testIndex++; - testSlicing(start, end); -} +var sliceTestCases = [ + [2, 3, "2"], + [2, 12, "23456789"], + [2, 2, ""], + [2, 1, ""], + [2, -12, ""], + [2, 2147483647, "23456789"], + [2, -2147483648, ""], + [2, 9223372036854775000, "23456789"], + [2, -9223372036854775000, ""], + [-2, -1, "8"], + [-2, -2, ""], + [-2, -3, ""], + [-2, -12, ""], + [-2, 2147483647, "89"], + [-2, -2147483648, ""], + [-2, 9223372036854775000, "89"], + [-2, -9223372036854775000, ""], + [0, null, "0123456789"], + [2, null, "23456789"], + [-2, null, "89"], + [12, null, ""], + [-12, null, "0123456789"], + [2147483647, null, ""], + [-2147483648, null, "0123456789"], + [9223372036854775000, null, ""], + [-9223372036854775000, null, "0123456789"], + [null, null, "0123456789"], +]; function runTests() { blob = new Blob(["0123456789"]); + file = new File(["0123456789"], "slice-test.txt"); runNextTest(); } -if (window.testRunner) { - testRunner.dumpAsText(); - testRunner.waitUntilDone(); -} +window.jsTestIsAsync = true; </script> </head> <body onload="runTests()"> diff --git a/third_party/WebKit/LayoutTests/fast/files/file-constructor-expected.txt b/third_party/WebKit/LayoutTests/fast/files/file-constructor-expected.txt new file mode 100644 index 0000000..2c4bf48 --- /dev/null +++ b/third_party/WebKit/LayoutTests/fast/files/file-constructor-expected.txt @@ -0,0 +1,100 @@ +Test the File constructor. + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +PASS (new File([], 'world.html')) instanceof window.File is true +PASS (new File(['hello'], 'world.html')) instanceof window.File is true +PASS (new File(['hello'], 'world.html', {})) instanceof window.File is true +PASS (new File(['hello'], 'world.html', {type:'text/html'})) instanceof window.File is true +PASS (new File(['hello'], 'world.html', {type:'text/html', endings:'native'})) instanceof window.File is true +PASS (new File(['hello'], 'world.html', {type:'text/html', endings:'transparent'})) instanceof window.File is true +PASS (new File([], 'world.html')) instanceof window.File is true +PASS (new File()) threw exception TypeError: File constructor requires at least two arguments. +PASS (new File([])) threw exception TypeError: File constructor requires at least two arguments. +PASS (new File([], null)) instanceof window.File is true +PASS (new File([], 1)) instanceof window.File is true +PASS (new File([], '')) instanceof window.File is true +PASS (new File([], document)) instanceof window.File is true +PASS new File('hello', 'world.html') threw exception TypeError: Failed to construct 'File': The 1st argument is neither an array, nor does it have indexed properties.. +PASS new File(0, 'world.html') threw exception TypeError: Failed to construct 'File': The 1st argument is neither an array, nor does it have indexed properties.. +PASS (new File([], 'world.html')) instanceof window.File is true +PASS (new File(['stringPrimitive'], 'world.html')) instanceof window.File is true +PASS (new File([String('stringObject')], 'world.html')) instanceof window.File is true +PASS (new File([new Blob], 'world.html')) instanceof window.File is true +PASS (new File([new Blob([new Blob])], 'world.html')) instanceof window.File is true +PASS (new Blob([new File([], 'world.txt')])) instanceof window.Blob is true +PASS (new Blob([new Blob([new File([new Blob], 'world.txt')])])) instanceof window.Blob is true +PASS (new File([new File([], 'world.txt')], 'world.html')) instanceof window.File is true +PASS (new File([new Blob([new File([new Blob], 'world.txt')])], 'world.html')) instanceof window.File is true +PASS (new File([12], 'world.html')).size is 2 +PASS (new File([[]], 'world.html')).size is 0 +PASS (new File([{}], 'world.html')).size is 15 +PASS (new File([document], 'world.html')).size is 21 +PASS (new File([toStringingObj], 'world.html')).size is 8 +PASS new File([throwingObj], 'world.html') threw exception Error. +PASS (new File([], null)).name is 'null' +PASS (new File([], 12)).name is '12' +PASS (new File([], '')).name is '' +PASS (new File([], {})).name is '[object Object]' +PASS (new File([], document)).name is '[object HTMLDocument]' +PASS (new File([], toStringingObj)).name is 'A string' +PASS (new File([], throwingObj)).name threw exception Error. +PASS (new File([], 'world.html', {unknownKey:'value'})) instanceof window.File is true +PASS new File([], 'world.html', {endings:'illegalValue'}) threw exception TypeError: Failed to construct 'File': The "endings" property must be either "transparent" or "native".. +PASS new File([], 'world.html', {endings:throwingObj}) threw exception Error. +PASS new File([], 'world.html', {type:throwingObj}) threw exception Error. +PASS new File([], 'world.html', {type:'helloî'}) threw exception SyntaxError: Failed to construct 'File': The "type" property must consist of ASCII characters.. +PASS (new File([], 'world.html', null)) instanceof window.File threw exception TypeError: Failed to construct 'File': The 3rd argument is not of type Object.. +PASS (new File([], 'world.html', undefined)) instanceof window.File threw exception TypeError: Failed to construct 'File': The 3rd argument is not of type Object.. +PASS (new File([], 'world.html', 123)) instanceof window.File threw exception TypeError: Failed to construct 'File': The 3rd argument is not of type Object.. +PASS (new File([], 'world.html', 123.4)) instanceof window.File threw exception TypeError: Failed to construct 'File': The 3rd argument is not of type Object.. +PASS (new File([], 'world.html', true)) instanceof window.File threw exception TypeError: Failed to construct 'File': The 3rd argument is not of type Object.. +PASS (new File([], 'world.html', 'abc')) instanceof window.File threw exception TypeError: Failed to construct 'File': The 3rd argument is not of type Object.. +PASS (new File([], 'world.html', [])) instanceof window.File is true +PASS (new File([], 'world.html', /abc/)) instanceof window.File is true +PASS (new File([], 'world.html', function () {})) instanceof window.File is true +PASS (new File([], 'world.html', {type:'text/html'})).name is 'world.html' +PASS (new File([], 'world.html', {type:'text/html'})).type is 'text/html' +PASS (new File([], 'world.html', {type:'text/html'})).size is 0 +PASS (new File([], 'world.html', {type:'text/plain;charset=UTF-8'})).type is 'text/plain;charset=utf-8' +PASS window.File.length is 2 +PASS new File([new DataView(new ArrayBuffer(100))], 'world.html').size is 100 +PASS new File([new Uint8Array(100)], 'world.html').size is 100 +PASS new File([new Uint8ClampedArray(100)], 'world.html').size is 100 +PASS new File([new Uint16Array(100)], 'world.html').size is 200 +PASS new File([new Uint32Array(100)], 'world.html').size is 400 +PASS new File([new Int8Array(100)], 'world.html').size is 100 +PASS new File([new Int16Array(100)], 'world.html').size is 200 +PASS new File([new Int32Array(100)], 'world.html').size is 400 +PASS new File([new Float32Array(100)], 'world.html').size is 400 +PASS new File([new Float64Array(100)], 'world.html').size is 800 +PASS new File([new Float64Array(100), new Int32Array(100), new Uint8Array(100), new DataView(new ArrayBuffer(100))], 'world.html').size is 1400 +PASS new File([new Blob([new Int32Array(100)]), new Uint8Array(100), new Float32Array(100), new DataView(new ArrayBuffer(100))], 'world.html').size is 1000 +PASS new File([new Blob([new Int32Array(100)]), new File([new Uint16Array(100)], 'world.txt'), new Uint8Array(100), new Float32Array(100), new DataView(new ArrayBuffer(100))], 'world.html').size is 1200 +PASS new File([(new DataView(new ArrayBuffer(100))).buffer], 'world.html').size is 100 +PASS new File([(new Uint8Array(100)).buffer], 'world.html').size is 100 +PASS new File([(new Uint8ClampedArray(100)).buffer], 'world.html').size is 100 +PASS new File([(new Uint16Array(100)).buffer], 'world.html').size is 200 +PASS new File([(new Uint32Array(100)).buffer], 'world.html').size is 400 +PASS new File([(new Int8Array(100)).buffer], 'world.html').size is 100 +PASS new File([(new Int16Array(100)).buffer], 'world.html').size is 200 +PASS new File([(new Int32Array(100)).buffer], 'world.html').size is 400 +PASS new File([(new Float32Array(100)).buffer], 'world.html').size is 400 +PASS new File([(new Float64Array(100)).buffer], 'world.html').size is 800 +PASS new File([(new Float64Array(100)).buffer, (new Int32Array(100)).buffer, (new Uint8Array(100)).buffer, (new DataView(new ArrayBuffer(100))).buffer], 'world.html').size is 1400 +PASS new File([new Blob([(new Int32Array(100)).buffer]), (new Uint8Array(100)).buffer, (new Float32Array(100)).buffer, (new DataView(new ArrayBuffer(100))).buffer], 'world.html').size is 1000 +PASS new File([new Blob([(new Int32Array(100)).buffer]), new File([new Uint16Array(100).buffer], 'world.txt'), (new Uint8Array(100)).buffer, (new Float32Array(100)).buffer, (new DataView(new ArrayBuffer(100))).buffer], 'world.html').size is 1200 +PASS new Blob([new Blob([new Int32Array(100)]), new File([new Uint16Array(100)], 'world.txt'), new Uint8Array(100), new Float32Array(100), new DataView(new ArrayBuffer(100))]).size is 1200 +PASS new Blob([new Blob([(new Int32Array(100)).buffer]), new File([new Uint16Array(100).buffer], 'world.txt'), (new Uint8Array(100)).buffer, (new Float32Array(100)).buffer, (new DataView(new ArrayBuffer(100))).buffer]).size is 1200 +PASS new File({length: 0}, 'world.txt') instanceof window.File is true +PASS new File({length: 0}, 'world.txt').size is 0 +PASS new File({length: 1, 0: 'string'}, 'world.txt').size is 6 +PASS new File({length: 2, 0: new Uint8Array(100), 1: new Int16Array(100)}, 'world.txt').size is 300 +PASS new File({length: 1, 0: 'string'}, 'world.txt', {type: 'text/html'}).type is 'text/html' +PASS new File({length: 0}, 'world.txt', {endings:'illegal'}) threw exception TypeError: Failed to construct 'File': The "endings" property must be either "transparent" or "native".. +PASS new File(throwingSequence, 'world.txt') threw exception Error: Misbehaving property. +PASS successfullyParsed is true + +TEST COMPLETE + diff --git a/third_party/WebKit/LayoutTests/fast/files/file-constructor.html b/third_party/WebKit/LayoutTests/fast/files/file-constructor.html new file mode 100644 index 0000000..f615864 --- /dev/null +++ b/third_party/WebKit/LayoutTests/fast/files/file-constructor.html @@ -0,0 +1,146 @@ +<!DOCTYPE html> + +<script src="../../resources/js-test.js"></script> +<script> +description("Test the File constructor."); + +// Test the different ways you can construct a File. +shouldBeTrue("(new File([], 'world.html')) instanceof window.File"); +shouldBeTrue("(new File(['hello'], 'world.html')) instanceof window.File"); +shouldBeTrue("(new File(['hello'], 'world.html', {})) instanceof window.File"); +shouldBeTrue("(new File(['hello'], 'world.html', {type:'text/html'})) instanceof window.File"); +shouldBeTrue("(new File(['hello'], 'world.html', {type:'text/html', endings:'native'})) instanceof window.File"); +shouldBeTrue("(new File(['hello'], 'world.html', {type:'text/html', endings:'transparent'})) instanceof window.File"); + +// Test that File inherits from File. +shouldBeTrue("(new File([], 'world.html')) instanceof window.File") + +// Verify that the file name argument is required. +shouldThrow("(new File())", "'TypeError: File constructor requires at least two arguments'"); +shouldThrow("(new File([]))", "'TypeError: File constructor requires at least two arguments'"); + +// Test valid file names. +shouldBeTrue("(new File([], null)) instanceof window.File"); +shouldBeTrue("(new File([], 1)) instanceof window.File"); +shouldBeTrue("(new File([], '')) instanceof window.File"); +shouldBeTrue("(new File([], document)) instanceof window.File"); + +// Test invalid blob parts. +shouldThrow("new File('hello', 'world.html')", '"TypeError: Failed to construct \'File\': The 1st argument is neither an array, nor does it have indexed properties."'); +shouldThrow("new File(0, 'world.html')", '"TypeError: Failed to construct \'File\': The 1st argument is neither an array, nor does it have indexed properties."'); + +// Test valid blob parts. +shouldBeTrue("(new File([], 'world.html')) instanceof window.File"); +shouldBeTrue("(new File(['stringPrimitive'], 'world.html')) instanceof window.File"); +shouldBeTrue("(new File([String('stringObject')], 'world.html')) instanceof window.File"); +shouldBeTrue("(new File([new Blob], 'world.html')) instanceof window.File"); +shouldBeTrue("(new File([new Blob([new Blob])], 'world.html')) instanceof window.File"); + +// Test File instances used as blob parts. +shouldBeTrue("(new Blob([new File([], 'world.txt')])) instanceof window.Blob"); +shouldBeTrue("(new Blob([new Blob([new File([new Blob], 'world.txt')])])) instanceof window.Blob"); +shouldBeTrue("(new File([new File([], 'world.txt')], 'world.html')) instanceof window.File"); +shouldBeTrue("(new File([new Blob([new File([new Blob], 'world.txt')])], 'world.html')) instanceof window.File"); + +// Test some conversions to string in the parts array. +shouldBe("(new File([12], 'world.html')).size", "2"); +shouldBe("(new File([[]], 'world.html')).size", "0"); // [].toString() is the empty string +shouldBe("(new File([{}], 'world.html')).size", "15");; // {}.toString() is the string "[object Object]" +shouldBe("(new File([document], 'world.html')).size", "21"); // document.toString() is the string "[object HTMLDocument]" + +var toStringingObj = { toString: function() { return "A string"; } }; +shouldBe("(new File([toStringingObj], 'world.html')).size", "8"); + +var throwingObj = { toString: function() { throw "Error"; } }; +shouldThrow("new File([throwingObj], 'world.html')", "'Error'"); + +// Test some conversions to string in the file name. +shouldBe("(new File([], null)).name", "'null'"); +shouldBe("(new File([], 12)).name", "'12'"); +shouldBe("(new File([], '')).name", "''"); +shouldBe("(new File([], {})).name", "'[object Object]'"); +shouldBe("(new File([], document)).name", "'[object HTMLDocument]'"); +shouldBe("(new File([], toStringingObj)).name", "'A string'"); +shouldThrow("(new File([], throwingObj)).name", "'Error'"); + +// Test some invalid property bags. +shouldBeTrue("(new File([], 'world.html', {unknownKey:'value'})) instanceof window.File"); // Ignore invalid keys +shouldThrow("new File([], 'world.html', {endings:'illegalValue'})", "'TypeError: Failed to construct \\'File\\': The \"endings\" property must be either \"transparent\" or \"native\".'"); +shouldThrow("new File([], 'world.html', {endings:throwingObj})", "'Error'"); +shouldThrow("new File([], 'world.html', {type:throwingObj})", "'Error'"); +shouldThrow("new File([], 'world.html', {type:'hello\u00EE'})", "'SyntaxError: Failed to construct \\'File\\': The \"type\" property must consist of ASCII characters.'"); + +// Test various non-object literals being used as property bags. +shouldThrow("(new File([], 'world.html', null)) instanceof window.File", "'TypeError: Failed to construct \\'File\\': The 3rd argument is not of type Object.'"); +shouldThrow("(new File([], 'world.html', undefined)) instanceof window.File", "'TypeError: Failed to construct \\'File\\': The 3rd argument is not of type Object.'"); +shouldThrow("(new File([], 'world.html', 123)) instanceof window.File", "'TypeError: Failed to construct \\'File\\': The 3rd argument is not of type Object.'"); +shouldThrow("(new File([], 'world.html', 123.4)) instanceof window.File", "'TypeError: Failed to construct \\'File\\': The 3rd argument is not of type Object.'"); +shouldThrow("(new File([], 'world.html', true)) instanceof window.File", "'TypeError: Failed to construct \\'File\\': The 3rd argument is not of type Object.'"); +shouldThrow("(new File([], 'world.html', 'abc')) instanceof window.File", "'TypeError: Failed to construct \\'File\\': The 3rd argument is not of type Object.'"); +shouldBeTrue("(new File([], 'world.html', [])) instanceof window.File"); +shouldBeTrue("(new File([], 'world.html', /abc/)) instanceof window.File"); +shouldBeTrue("(new File([], 'world.html', function () {})) instanceof window.File"); + +// Test that the name/type/size are correctly added to the File. +shouldBe("(new File([], 'world.html', {type:'text/html'})).name", "'world.html'"); +shouldBe("(new File([], 'world.html', {type:'text/html'})).type", "'text/html'"); +shouldBe("(new File([], 'world.html', {type:'text/html'})).size", "0"); +shouldBe("(new File([], 'world.html', {type:'text/plain;charset=UTF-8'})).type", "'text/plain;charset=utf-8'"); + +// Test the number of expected arguments in the File constructor. +shouldBe("window.File.length", "2"); + +// Test ArrayBufferView parameters. +shouldBe("new File([new DataView(new ArrayBuffer(100))], 'world.html').size", "100"); +shouldBe("new File([new Uint8Array(100)], 'world.html').size", "100"); +shouldBe("new File([new Uint8ClampedArray(100)], 'world.html').size", "100"); +shouldBe("new File([new Uint16Array(100)], 'world.html').size", "200"); +shouldBe("new File([new Uint32Array(100)], 'world.html').size", "400"); +shouldBe("new File([new Int8Array(100)], 'world.html').size", "100"); +shouldBe("new File([new Int16Array(100)], 'world.html').size", "200"); +shouldBe("new File([new Int32Array(100)], 'world.html').size", "400"); +shouldBe("new File([new Float32Array(100)], 'world.html').size", "400"); +shouldBe("new File([new Float64Array(100)], 'world.html').size", "800"); +shouldBe("new File([new Float64Array(100), new Int32Array(100), new Uint8Array(100), new DataView(new ArrayBuffer(100))], 'world.html').size", "1400"); +shouldBe("new File([new Blob([new Int32Array(100)]), new Uint8Array(100), new Float32Array(100), new DataView(new ArrayBuffer(100))], 'world.html').size", "1000"); +shouldBe("new File([new Blob([new Int32Array(100)]), new File([new Uint16Array(100)], 'world.txt'), new Uint8Array(100), new Float32Array(100), new DataView(new ArrayBuffer(100))], 'world.html').size", "1200"); + +// Test ArrayBuffer parameters. +shouldBe("new File([(new DataView(new ArrayBuffer(100))).buffer], 'world.html').size", "100"); +shouldBe("new File([(new Uint8Array(100)).buffer], 'world.html').size", "100"); +shouldBe("new File([(new Uint8ClampedArray(100)).buffer], 'world.html').size", "100"); +shouldBe("new File([(new Uint16Array(100)).buffer], 'world.html').size", "200"); +shouldBe("new File([(new Uint32Array(100)).buffer], 'world.html').size", "400"); +shouldBe("new File([(new Int8Array(100)).buffer], 'world.html').size", "100"); +shouldBe("new File([(new Int16Array(100)).buffer], 'world.html').size", "200"); +shouldBe("new File([(new Int32Array(100)).buffer], 'world.html').size", "400"); +shouldBe("new File([(new Float32Array(100)).buffer], 'world.html').size", "400"); +shouldBe("new File([(new Float64Array(100)).buffer], 'world.html').size", "800"); +shouldBe("new File([(new Float64Array(100)).buffer, (new Int32Array(100)).buffer, (new Uint8Array(100)).buffer, (new DataView(new ArrayBuffer(100))).buffer], 'world.html').size", "1400"); +shouldBe("new File([new Blob([(new Int32Array(100)).buffer]), (new Uint8Array(100)).buffer, (new Float32Array(100)).buffer, (new DataView(new ArrayBuffer(100))).buffer], 'world.html').size", "1000"); +shouldBe("new File([new Blob([(new Int32Array(100)).buffer]), new File([new Uint16Array(100).buffer], 'world.txt'), (new Uint8Array(100)).buffer, (new Float32Array(100)).buffer, (new DataView(new ArrayBuffer(100))).buffer], 'world.html').size", "1200"); + +// Test building Blobs with ArrayBuffer / ArrayBufferView parts enclosed in files. +shouldBe("new Blob([new Blob([new Int32Array(100)]), new File([new Uint16Array(100)], 'world.txt'), new Uint8Array(100), new Float32Array(100), new DataView(new ArrayBuffer(100))]).size", "1200"); +shouldBe("new Blob([new Blob([(new Int32Array(100)).buffer]), new File([new Uint16Array(100).buffer], 'world.txt'), (new Uint8Array(100)).buffer, (new Float32Array(100)).buffer, (new DataView(new ArrayBuffer(100))).buffer]).size", "1200"); + +// Test passing blob parts in sequences. +shouldBeTrue("new File({length: 0}, 'world.txt') instanceof window.File"); +shouldBe("new File({length: 0}, 'world.txt').size", "0"); +shouldBe("new File({length: 1, 0: 'string'}, 'world.txt').size", "6"); +shouldBe("new File({length: 2, 0: new Uint8Array(100), 1: new Int16Array(100)}, 'world.txt').size", "300"); +shouldBe("new File({length: 1, 0: 'string'}, 'world.txt', {type: 'text/html'}).type", "'text/html'"); +shouldThrow("new File({length: 0}, 'world.txt', {endings:'illegal'})", "'TypeError: Failed to construct \\'File\\': The \"endings\" property must be either \"transparent\" or \"native\".'"); + +// Test passing blog parts in a sequence-like object that throws on property access. +var throwingSequence = {length: 4, 0: 'hello', 3: 'world'}; +Object.defineProperty(throwingSequence, "1", { + get: function() { throw new Error("Misbehaving property"); }, + enumerable: true, configurable: true +}); +Object.defineProperty(throwingSequence, "2", { + get: function() { throw new Error("This should not be thrown"); }, + enumerable: true, configurable: true +}); +shouldThrow("new File(throwingSequence, 'world.txt')", "'Error: Misbehaving property'"); +</script> diff --git a/third_party/WebKit/LayoutTests/fast/files/resources/blob-slice-common.js b/third_party/WebKit/LayoutTests/fast/files/resources/blob-slice-common.js new file mode 100644 index 0000000..ba7a251 --- /dev/null +++ b/third_party/WebKit/LayoutTests/fast/files/resources/blob-slice-common.js @@ -0,0 +1,49 @@ +var blob, file; // Populated by runTests() in individual tests. +var sliceParams = []; // Populated by individual tests. +var testIndex = 0; + +function testSlicing(start, end, expectedResult, blob, doneCallback) +{ + var blobClass = blob.constructor.name; + var sliced; + var reader = new FileReader(); + var message = ".slice"; + if (start === null && end === null) { + message += "()"; + sliced = blob.slice(); + } else if (end == undefined) { + message += "(" + start + ")"; + sliced = blob.slice(start); + } else { + message += "(" + start + ", " + end + ")"; + sliced = blob.slice(start, end); + } + reader.onloadend = function(event) { + var error = event.target.error; + if (error) { + testFailed("File read error " + message + error); + doneCallback(); + return; + } + var blobContentsVar = blobClass.toLowerCase() + "Contents"; + window[blobContentsVar] = event.target.result; + shouldBeEqualToString(blobContentsVar, expectedResult); + doneCallback(); + }; + debug(blobClass + " " + message); + reader.readAsText(sliced); +} + +function runNextTest() +{ + if (testIndex >= sliceTestCases.length) { + finishJSTest(); + return; + } + + var testCase = sliceTestCases[testIndex]; + testIndex++; + testSlicing(testCase[0], testCase[1], testCase[2], blob, function() { + testSlicing(testCase[0], testCase[1], testCase[2], file, runNextTest); + }); +} diff --git a/third_party/WebKit/LayoutTests/fast/files/script-tests/blob-constructor.js b/third_party/WebKit/LayoutTests/fast/files/script-tests/blob-constructor.js deleted file mode 100644 index 77ad34a..0000000 --- a/third_party/WebKit/LayoutTests/fast/files/script-tests/blob-constructor.js +++ /dev/null @@ -1,114 +0,0 @@ -description("Test the Blob constructor."); - -// Test the diffrent ways you can construct a Blob. -shouldBeTrue("(new Blob()) instanceof window.Blob"); -shouldBeTrue("(new Blob([])) instanceof window.Blob"); -shouldBeTrue("(new Blob(['hello'])) instanceof window.Blob"); -shouldBeTrue("(new Blob(['hello'], {})) instanceof window.Blob"); -shouldBeTrue("(new Blob(['hello'], {type:'text/html'})) instanceof window.Blob"); -shouldBeTrue("(new Blob(['hello'], {type:'text/html', endings:'native'})) instanceof window.Blob"); -shouldBeTrue("(new Blob(['hello'], {type:'text/html', endings:'transparent'})) instanceof window.Blob"); - -// Test invalid blob parts -shouldThrow("new Blob('hello')", '"TypeError: Failed to construct \'Blob\': The 1st argument is neither an array, nor does it have indexed properties."'); -shouldThrow("new Blob(0)", '"TypeError: Failed to construct \'Blob\': The 1st argument is neither an array, nor does it have indexed properties."'); - -// Test valid blob parts. -shouldBeTrue("(new Blob([])) instanceof window.Blob"); -shouldBeTrue("(new Blob(['stringPrimitive'])) instanceof window.Blob"); -shouldBeTrue("(new Blob([String('stringObject')])) instanceof window.Blob"); -shouldBeTrue("(new Blob([new Blob])) instanceof window.Blob"); -shouldBeTrue("(new Blob([new Blob([new Blob])])) instanceof window.Blob"); - -// Test some conversions to string in the parts array. -shouldBe("(new Blob([12])).size", "2"); -shouldBe("(new Blob([[]])).size", "0"); // [].toString() is the empty string -shouldBe("(new Blob([{}])).size", "15");; // {}.toString() is the string "[object Object]" -shouldBe("(new Blob([document])).size", "21"); // document.toString() is the string "[object HTMLDocument]" - -var toStringingObj = { toString: function() { return "A string"; } }; -shouldBe("(new Blob([toStringingObj])).size", "8"); - -var throwingObj = { toString: function() { throw "Error"; } }; -shouldThrow("new Blob([throwingObj])", "'Error'"); - -// Test some invalid property bags -shouldBeTrue("(new Blob([], {unknownKey:'value'})) instanceof window.Blob"); // Ignore invalid keys -shouldThrow("new Blob([], {endings:'illegalValue'})", "'TypeError: Failed to construct \\'Blob\\': The 2nd argument\\'s \"endings\" property must be either \"transparent\" or \"native\".'"); -shouldThrow("new Blob([], {endings:throwingObj})", "'Error'"); -shouldThrow("new Blob([], {type:throwingObj})", "'Error'"); -shouldThrow("new Blob([], {type:'hello\u00EE'})", "'SyntaxError: Failed to construct \\'Blob\\': The 2nd argument\\'s \"type\" property must consist of ASCII characters.'"); - -// Test that order of property bag evaluation is lexigraphical -var throwingObj1 = { toString: function() { throw "Error 1"; } }; -var throwingObj2 = { toString: function() { throw "Error 2"; } }; -shouldThrow("new Blob([], {endings:throwingObj1, type:throwingObj2})", "'Error 1'"); -shouldThrow("new Blob([], {type:throwingObj2, endings:throwingObj1})", "'Error 1'"); -shouldThrow("new Blob([], {type:throwingObj2, endings:'illegal'})", "'TypeError: Failed to construct \\'Blob\\': The 2nd argument\\'s \"endings\" property must be either \"transparent\" or \"native\".'"); - -// Test various non-object literals being used as property bags -shouldThrow("(new Blob([], null)) instanceof window.Blob", "'TypeError: Failed to construct \\'Blob\\': The 2nd argument is not of type Object.'"); -shouldThrow("(new Blob([], undefined)) instanceof window.Blob", "'TypeError: Failed to construct \\'Blob\\': The 2nd argument is not of type Object.'"); -shouldThrow("(new Blob([], 123)) instanceof window.Blob", "'TypeError: Failed to construct \\'Blob\\': The 2nd argument is not of type Object.'"); -shouldThrow("(new Blob([], 123.4)) instanceof window.Blob", "'TypeError: Failed to construct \\'Blob\\': The 2nd argument is not of type Object.'"); -shouldThrow("(new Blob([], true)) instanceof window.Blob", "'TypeError: Failed to construct \\'Blob\\': The 2nd argument is not of type Object.'"); -shouldThrow("(new Blob([], 'abc')) instanceof window.Blob", "'TypeError: Failed to construct \\'Blob\\': The 2nd argument is not of type Object.'"); -shouldBeTrue("(new Blob([], [])) instanceof window.Blob"); -shouldBeTrue("(new Blob([], /abc/)) instanceof window.Blob"); -shouldBeTrue("(new Blob([], function () {})) instanceof window.Blob"); - -// Test that the type/size is correctly added to the Blob -shouldBe("(new Blob([], {type:'text/html'})).type", "'text/html'"); -shouldBe("(new Blob([], {type:'text/html'})).size", "0"); -shouldBe("(new Blob([], {type:'text/plain;charset=UTF-8'})).type", "'text/plain;charset=utf-8'"); - -// Odds and ends -shouldBe("window.Blob.length", "2"); - -// Test ArrayBufferView Parameters -shouldBe("new Blob([new DataView(new ArrayBuffer(100))]).size", "100"); -shouldBe("new Blob([new Uint8Array(100)]).size", "100"); -shouldBe("new Blob([new Uint8ClampedArray(100)]).size", "100"); -shouldBe("new Blob([new Uint16Array(100)]).size", "200"); -shouldBe("new Blob([new Uint32Array(100)]).size", "400"); -shouldBe("new Blob([new Int8Array(100)]).size", "100"); -shouldBe("new Blob([new Int16Array(100)]).size", "200"); -shouldBe("new Blob([new Int32Array(100)]).size", "400"); -shouldBe("new Blob([new Float32Array(100)]).size", "400"); -shouldBe("new Blob([new Float64Array(100)]).size", "800"); -shouldBe("new Blob([new Float64Array(100), new Int32Array(100), new Uint8Array(100), new DataView(new ArrayBuffer(100))]).size", "1400"); -shouldBe("new Blob([new Blob([new Int32Array(100)]), new Uint8Array(100), new Float32Array(100), new DataView(new ArrayBuffer(100))]).size", "1000"); - -// Test ArrayBuffer Parameters -shouldBe("new Blob([(new DataView(new ArrayBuffer(100))).buffer]).size", "100"); -shouldBe("new Blob([(new Uint8Array(100)).buffer]).size", "100"); -shouldBe("new Blob([(new Uint8ClampedArray(100)).buffer]).size", "100"); -shouldBe("new Blob([(new Uint16Array(100)).buffer]).size", "200"); -shouldBe("new Blob([(new Uint32Array(100)).buffer]).size", "400"); -shouldBe("new Blob([(new Int8Array(100)).buffer]).size", "100"); -shouldBe("new Blob([(new Int16Array(100)).buffer]).size", "200"); -shouldBe("new Blob([(new Int32Array(100)).buffer]).size", "400"); -shouldBe("new Blob([(new Float32Array(100)).buffer]).size", "400"); -shouldBe("new Blob([(new Float64Array(100)).buffer]).size", "800"); -shouldBe("new Blob([(new Float64Array(100)).buffer, (new Int32Array(100)).buffer, (new Uint8Array(100)).buffer, (new DataView(new ArrayBuffer(100))).buffer]).size", "1400"); -shouldBe("new Blob([new Blob([(new Int32Array(100)).buffer]), (new Uint8Array(100)).buffer, (new Float32Array(100)).buffer, (new DataView(new ArrayBuffer(100))).buffer]).size", "1000"); - -// Test passing blob parts in sequences. -shouldBeTrue("new Blob({length: 0}) instanceof window.Blob"); -shouldBe("new Blob({length: 0}).size", "0"); -shouldBe("new Blob({length: 1, 0: 'string'}).size", "6"); -shouldBe("new Blob({length: 2, 0: new Uint8Array(100), 1: new Int16Array(100)}).size", "300"); -shouldBe("new Blob({length: 1, 0: 'string'}, {type: 'text/html'}).type", "'text/html'"); -shouldThrow("new Blob({length: 0}, {endings:'illegal'})", "'TypeError: Failed to construct \\'Blob\\': The 2nd argument\\'s \"endings\" property must be either \"transparent\" or \"native\".'"); - -// Test passing blog parts in a sequence-like object that throws on property access. -var throwingSequence = {length: 4, 0: 'hello', 3: 'world'}; -Object.defineProperty(throwingSequence, "1", { - get: function() { throw new Error("Misbehaving property"); }, - enumerable: true, configurable: true -}); -Object.defineProperty(throwingSequence, "2", { - get: function() { throw new Error("This should not be thrown"); }, - enumerable: true, configurable: true -}); -shouldThrow("new Blob(throwingSequence)", "'Error: Misbehaving property'"); diff --git a/third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/post-blob-content-type-async-expected.txt b/third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/post-blob-content-type-async-expected.txt index 062c72f..420e464 100644 --- a/third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/post-blob-content-type-async-expected.txt +++ b/third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/post-blob-content-type-async-expected.txt @@ -4,19 +4,24 @@ Test verifies that content MIME type is set correctly when Blob is sent using XM On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". -PASS expectedMimeType is "text/plain;charset=utf-8" -PASS expectedMimeType is "" -PASS expectedMimeType is "" -PASS expectedMimeType is "" -PASS expectedMimeType is "" -PASS expectedMimeType is "" -PASS expectedMimeType is "" -PASS expectedMimeType is "" -PASS expectedMimeType is "multipart/mixed;boundary=\"--blob-boundary\"" -PASS expectedMimeType is "" +PASS postedMimeType is "text/plain;charset=utf-8" +PASS postedMimeType is "" +PASS postedMimeType is "" +PASS postedMimeType is "" +PASS postedMimeType is "" +PASS postedMimeType is "" +PASS postedMimeType is "" +PASS postedMimeType is "" +PASS postedMimeType is "multipart/mixed;boundary=\"--blob-boundary\"" +PASS postedMimeType is "" PASS Exception should be thrown. PASS Cross-origin request without CORS headers should fail. -PASS expectedMimeType is "text/plain;charset=utf-8" +PASS postedMimeType is "text/plain;charset=utf-8" +PASS postedMimeType is "text/plain;charset=utf-8" +PASS postedMimeType is "" +PASS postedMimeType is "" +PASS postedMimeType is "multipart/mixed;boundary=\"--blob-boundary\"" +PASS Exception should be thrown. PASS successfullyParsed is true TEST COMPLETE diff --git a/third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/post-blob-content-type-async.html b/third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/post-blob-content-type-async.html index 1315f3e5..1dc1fb05 100644 --- a/third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/post-blob-content-type-async.html +++ b/third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/post-blob-content-type-async.html @@ -1,73 +1,78 @@ <!DOCTYPE html> -<html> -<head> - <script src="/js-test-resources/js-test.js"></script> -</head> -<body> - <script src="post-blob-content-type-tests.js"></script> - <script type="text/javascript"> - description("Test verifies that content MIME type is set correctly " + - "when Blob is sent using " + - "<a href='http://www.w3.org/TR/XMLHttpRequest/#the-send-method'>XMLHttpRequest asynchronously.</a>"); - var xhr; - var expectedMimeType; - window.jsTestIsAsync = true; - var asyncTestCase = 0; +<script src="/js-test-resources/js-test.js"></script> +<script src="post-blob-content-type-tests.js"></script> +<script type="text/javascript"> + description("Test verifies that content MIME type is set correctly " + + "when Blob is sent using " + + "<a href='http://www.w3.org/TR/XMLHttpRequest/#the-send-method'>XMLHttpRequest asynchronously.</a>"); - function runNextAsyncTest() { - asyncTestCase++; - runAsyncTests(); - } + var xhr; + var expectedMimeType; + window.jsTestIsAsync = true; + var asyncTestCase = 0; - function reportResult(e) { - if (xhr.status === 200) { - expectedMimeType = JSON.parse(xhr.response)['content-type'] || ""; - shouldBeEqualToString("expectedMimeType", xhrBlobTestCases[asyncTestCase].expectedMime); - } else if (xhr.status === 0 && xhrBlobTestCases[asyncTestCase].shouldThrow){ - testPassed("Cross-origin request without CORS headers should fail."); - } else { - testFailed("Unknown error"); - } + function runNextAsyncTest() { + asyncTestCase++; + runAsyncTests(); + } - runNextAsyncTest(); - } + function reportResult(e) { + var testCase = xhrBlobTestCases[asyncTestCase]; + if (xhr.status === 200) { + postedMimeType = JSON.parse(xhr.response)['content-type'] || ""; + shouldBeEqualToString("postedMimeType", testCase.expectedMime); + } else if (xhr.status === 0 && testCase.shouldThrow){ + testPassed("Cross-origin request without CORS headers should fail."); + } else { + testFailed("Unknown error"); + } - function runAsyncTests() { - if (asyncTestCase >= xhrBlobTestCases.length) { - finishJSTest(); - return; - } else { - var mime = xhrBlobTestCases[asyncTestCase].mime; - var url = xhrBlobTestCases[asyncTestCase].url !== undefined ? xhrBlobTestCases[asyncTestCase].url + xhrBlobTestUrl : xhrBlobTestUrl; - url += xhrBlobTestCases[asyncTestCase].allowOrigin || ""; - if (xhrBlobTestCases[asyncTestCase].shouldThrow !== undefined) { - try { - testBlobContentTypeAsync(url, mime); - } catch (e) { - testPassed("Exception should be thrown.") - runNextAsyncTest(); - } - } else - testBlobContentTypeAsync(url, mime); - } - } + runNextAsyncTest(); + } - function testBlobContentTypeAsync(url, mimeType) { - var blob; - if (mimeType !== "") - blob = new Blob(["Test content"], {type: mimeType}); - else - blob = new Blob(["Test content"]); + function runAsyncTests() { + if (asyncTestCase >= xhrBlobTestCases.length) { + finishJSTest(); + return; + } else { + var testCase = xhrBlobTestCases[asyncTestCase]; + var mime = testCase.mime; + var file = testCase.file; + var url = testCase.url !== undefined ? testCase.url + xhrBlobTestUrl : xhrBlobTestUrl; + url += testCase.allowOrigin || ""; + if (testCase.shouldThrow !== undefined) { + try { + testBlobContentTypeAsync(url, mime, file); + } catch (e) { + testPassed("Exception should be thrown.") + runNextAsyncTest(); + } + } else + testBlobContentTypeAsync(url, mime); + } + } - xhr = new XMLHttpRequest(); - xhr.onloadend = reportResult; - xhr.open("POST", url, true); - xhr.send(blob); - } + function testBlobContentTypeAsync(url, mimeType, fileName) { + var blob; + if (fileName) { + if (mimeType !== "") + blob = new File(["Test content"], fileName, {type: mimeType}); + else + blob = new File(["Test content"], fileName); + } else { + if (mimeType !== "") + blob = new Blob(["Test content"], {type: mimeType}); + else + blob = new Blob(["Test content"]); + } - runAsyncTests(); + xhr = new XMLHttpRequest(); + xhr.onloadend = reportResult; + xhr.open("POST", url, true); + xhr.send(blob); + } - </script> -</body> -</html> + runAsyncTests(); + +</script> diff --git a/third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/post-blob-content-type-sync-expected.txt b/third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/post-blob-content-type-sync-expected.txt index 853476f..90920def 100644 --- a/third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/post-blob-content-type-sync-expected.txt +++ b/third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/post-blob-content-type-sync-expected.txt @@ -4,19 +4,24 @@ Test verifies that content MIME type is set correctly when Blob is sent using XM On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". -PASS expectedMimeType is "text/plain;charset=utf-8" -PASS expectedMimeType is "" -PASS expectedMimeType is "" -PASS expectedMimeType is "" -PASS expectedMimeType is "" -PASS expectedMimeType is "" -PASS expectedMimeType is "" -PASS expectedMimeType is "" -PASS expectedMimeType is "multipart/mixed;boundary=\"--blob-boundary\"" -PASS expectedMimeType is "" +PASS postedMimeType is "text/plain;charset=utf-8" +PASS postedMimeType is "" +PASS postedMimeType is "" +PASS postedMimeType is "" +PASS postedMimeType is "" +PASS postedMimeType is "" +PASS postedMimeType is "" +PASS postedMimeType is "" +PASS postedMimeType is "multipart/mixed;boundary=\"--blob-boundary\"" +PASS postedMimeType is "" PASS Exception should be thrown. PASS Exception should be thrown. -PASS expectedMimeType is "text/plain;charset=utf-8" +PASS postedMimeType is "text/plain;charset=utf-8" +PASS postedMimeType is "text/plain;charset=utf-8" +PASS postedMimeType is "" +PASS postedMimeType is "" +PASS postedMimeType is "multipart/mixed;boundary=\"--blob-boundary\"" +PASS Exception should be thrown. PASS successfullyParsed is true TEST COMPLETE diff --git a/third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/post-blob-content-type-sync.html b/third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/post-blob-content-type-sync.html index 4a78bd6..e111c94 100644 --- a/third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/post-blob-content-type-sync.html +++ b/third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/post-blob-content-type-sync.html @@ -1,57 +1,61 @@ <!DOCTYPE html> -<html> -<head> - <script src="/js-test-resources/js-test.js"></script> -</head> -<body> - <script src="post-blob-content-type-tests.js"></script> - <script type="text/javascript"> - description("Test verifies that content MIME type is set correctly " + - "when Blob is sent using " + - "<a href='http://www.w3.org/TR/XMLHttpRequest/#the-send-method'>XMLHttpRequest synchronously.</a>"); - - var xhr; - var expectedMimeType; - - function runSyncTests() { - var testCount = xhrBlobTestCases.length; - for (var i = 0; i < testCount; i++) { - var mime = xhrBlobTestCases[i].mime; - var expectedMime = xhrBlobTestCases[i].expectedMime; - var url = xhrBlobTestCases[i].url !== undefined ? xhrBlobTestCases[i].url + xhrBlobTestUrl : xhrBlobTestUrl; - url += xhrBlobTestCases[i].allowOrigin || ""; - if (xhrBlobTestCases[i].shouldThrow !== undefined) { - try { - testBlobContentTypeSync(url, mime, expectedMime); - } catch (e) { - testPassed("Exception should be thrown.") - } - } else { - testBlobContentTypeSync(url, mime, expectedMime); - } - } - } - - function testBlobContentTypeSync(url, mimeType, expectedMime) { - var blob; - if (mimeType !== "") - blob = new Blob(["Test content"], {type: mimeType}); - else - blob = new Blob(["Test content"]); - - xhr = new XMLHttpRequest(); - xhr.open("POST", url, false); - xhr.send(blob); - if (xhr.status === 200) { - expectedMimeType = JSON.parse(xhr.response)['content-type'] || ""; - shouldBeEqualToString("expectedMimeType", expectedMime); - } else - testFailed("Unknown error"); - - } - - runSyncTests(); - - </script> -</body> -</html> + +<script src="/js-test-resources/js-test.js"></script> +<script src="post-blob-content-type-tests.js"></script> +<script type="text/javascript"> + description("Test verifies that content MIME type is set correctly " + + "when Blob is sent using " + + "<a href='http://www.w3.org/TR/XMLHttpRequest/#the-send-method'>XMLHttpRequest synchronously.</a>"); + + var xhr; + var expectedMimeType; + + function runSyncTests() { + var testCount = xhrBlobTestCases.length; + for (var i = 0; i < testCount; i++) { + var testCase = xhrBlobTestCases[i]; + var mime = testCase.mime; + var file = testCase.file; + var expectedMime = testCase.expectedMime; + var url = testCase.url !== undefined ? testCase.url + xhrBlobTestUrl : xhrBlobTestUrl; + url += testCase.allowOrigin || ""; + if (testCase.shouldThrow !== undefined) { + try { + testBlobContentTypeSync(url, file, mime, expectedMime); + } catch (e) { + testPassed("Exception should be thrown.") + } + } else { + testBlobContentTypeSync(url, file, mime, expectedMime); + } + } + } + + function testBlobContentTypeSync(url, fileName, mimeType, expectedMime) { + var blob; + if (fileName) { + if (mimeType !== "") + blob = new File(["Test content"], fileName, {type: mimeType}); + else + blob = new File(["Test content"], fileName); + } else { + if (mimeType !== "") + blob = new Blob(["Test content"], {type: mimeType}); + else + blob = new Blob(["Test content"]); + } + + xhr = new XMLHttpRequest(); + xhr.open("POST", url, false); + xhr.send(blob); + if (xhr.status === 200) { + postedMimeType = JSON.parse(xhr.response)['content-type'] || ""; + shouldBeEqualToString("postedMimeType", expectedMime); + } else + testFailed("Unknown error"); + + } + + runSyncTests(); + +</script> diff --git a/third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/post-blob-content-type-tests.js b/third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/post-blob-content-type-tests.js index b2f29bc..6b5c611 100644 --- a/third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/post-blob-content-type-tests.js +++ b/third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/post-blob-content-type-tests.js @@ -45,4 +45,25 @@ var xhrBlobTestCases = [{ expectedMime: 'text/plain;charset=utf-8', url: 'http://localhost:8000', allowOrigin: '?origin=http://127.0.0.1:8000' -}];
\ No newline at end of file +}, { + mime: 'text/plain;charset=utf-8', + expectedMime: 'text/plain;charset=utf-8', + file: 'hello.txt' +}, { + mime: 'ASCII/CR\r;charset=invalid', + expectedMime: '', + file: 'hello.txt' +}, { + mime: '', + expectedMime: '', + file: 'hello.txt' +}, { + mime: 'multipart/mixed;boundary="--blob-boundary"', + expectedMime: 'multipart/mixed;boundary="--blob-boundary"', + file: 'hello.txt' +}, { + mime: '\u0422\u0435\u0441\u0442', + expectedMime: '', + shouldThrow: true, + file: 'hello.txt' +}]; diff --git a/third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/post-content-type.html b/third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/post-content-type.html index bc7aff4..973b95e 100644 --- a/third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/post-content-type.html +++ b/third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/post-content-type.html @@ -1,5 +1,5 @@ -<html> -<body> +<!DOCTYPE html> + <p>Test for <a href="http://crbug.com/172802">bug 172802</a> - Wrong default Content-Type set in XMLHttpRequest.send(DOMString)</p> <p>Should be text/plain;charset=UTF-8:</p> @@ -12,5 +12,3 @@ objXmlHttp.send(""); document.write("<pre>" + objXmlHttp.responseText + "</pre>"); </script> -</body> -</html> diff --git a/third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/post-formdata-expected.txt b/third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/post-formdata-expected.txt new file mode 100644 index 0000000..296dc7b --- /dev/null +++ b/third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/post-formdata-expected.txt @@ -0,0 +1,16 @@ +Test verifies that FormData is sent correctly when using XMLHttpRequest asynchronously. + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +PASS echoResult is "string=string value" +PASS echoResult is "bareBlob=blob:application/octet-stream:blob-value" +PASS echoResult is "mimeBlob=blob:text/html:blob-value" +PASS echoResult is "namedBlob=blob-file.txt:application/octet-stream:blob-value" +PASS echoResult is "bareFile=file-name.txt:application/octet-stream:file-value" +PASS echoResult is "mimeFile=file-name.html:text/html:file-value" +PASS echoResult is "renamedFile=file-name-override.html:text/html:file-value" +PASS successfullyParsed is true + +TEST COMPLETE + diff --git a/third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/post-formdata.html b/third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/post-formdata.html new file mode 100644 index 0000000..8777ddc --- /dev/null +++ b/third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/post-formdata.html @@ -0,0 +1,89 @@ +<!DOCTYPE html> + +<script src="/js-test-resources/js-test.js"></script> +<script> +description("Test verifies that FormData is sent correctly when using " + + "<a href='http://www.w3.org/TR/XMLHttpRequest/#the-send-method'>XMLHttpRequest asynchronously.</a>"); + +var xhrFormDataTestUrl = '/xmlhttprequest/resources/multipart-post-echo.php'; +var xhrFormDataTestCases = [{ + data: { string: 'string value' }, + result: "string=string value" +}, { + data: { bareBlob: new Blob(['blob-value']) }, + result: 'bareBlob=blob:application/octet-stream:blob-value' +}, { + data: { mimeBlob: new Blob(['blob-value'], { type: 'text/html' }) }, + result: 'mimeBlob=blob:text/html:blob-value' +}, { + data: { + namedBlob: { + value: new Blob(['blob-value']), + fileName: 'blob-file.txt' + } + }, + result: 'namedBlob=blob-file.txt:application/octet-stream:blob-value' +}, { + data: { bareFile: new File(['file-value'], 'file-name.txt') }, + result: 'bareFile=file-name.txt:application/octet-stream:file-value' +}, { + data: { + mimeFile: new File(['file-value'], 'file-name.html', { type: 'text/html' }) + }, + result: 'mimeFile=file-name.html:text/html:file-value' +}, { + data: { + renamedFile: { + value: new File(['file-value'], 'file-name.html', { type: 'text/html' }), + fileName: 'file-name-override.html' + } + }, + result: 'renamedFile=file-name-override.html:text/html:file-value' +}]; + +var xhr; +var expectedMimeType; +window.jsTestIsAsync = true; +var asyncTestCase = 0; + +function runNextAsyncTest() { + asyncTestCase++; + runAsyncTests(); +} + +function reportResult(e) { + var testCase = xhrFormDataTestCases[asyncTestCase]; + if (xhr.status === 200) { + echoResult = xhr.response; + shouldBeEqualToString("echoResult", testCase.result); + } else { + testFailed("Unknown error"); + } + + runNextAsyncTest(); +} + +function runAsyncTests() { + if (asyncTestCase >= xhrFormDataTestCases.length) { + finishJSTest(); + return; + } + + var testCase = xhrFormDataTestCases[asyncTestCase]; + var formData = new FormData(); + for (var fieldName in testCase.data) { + fieldValue = testCase.data[fieldName]; + if (fieldValue.constructor === Object) + formData.append(fieldName, fieldValue.value, fieldValue.fileName); + else + formData.append(fieldName, fieldValue); + } + + xhr = new XMLHttpRequest(); + xhr.onloadend = reportResult; + xhr.open("POST", xhrFormDataTestUrl, true); + xhr.send(formData); +} + +runAsyncTests(); +</script> diff --git a/third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-constructors-listing-dedicated-worker-expected.txt b/third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-constructors-listing-dedicated-worker-expected.txt index 9a63e99..165afe3 100644 --- a/third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-constructors-listing-dedicated-worker-expected.txt +++ b/third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-constructors-listing-dedicated-worker-expected.txt @@ -14,6 +14,7 @@ Starting worker: resources/global-context-constructors-listing.js [Worker] Error [Worker] EvalError [Worker] EventSource +[Worker] File [Worker] FileError [Worker] FileReader [Worker] FileReaderSync diff --git a/third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-constructors-listing-shared-worker-expected.txt b/third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-constructors-listing-shared-worker-expected.txt index ac0ee39..8cb2046 100644 --- a/third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-constructors-listing-shared-worker-expected.txt +++ b/third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-constructors-listing-shared-worker-expected.txt @@ -13,6 +13,7 @@ Starting worker: resources/global-context-constructors-listing.js [Worker] Error [Worker] EvalError [Worker] EventSource +[Worker] File [Worker] FileError [Worker] FileReader [Worker] FileReaderSync diff --git a/third_party/WebKit/LayoutTests/webexposed/global-constructors-listing-dedicated-worker-expected.txt b/third_party/WebKit/LayoutTests/webexposed/global-constructors-listing-dedicated-worker-expected.txt index 45da6b0..e3912c7 100644 --- a/third_party/WebKit/LayoutTests/webexposed/global-constructors-listing-dedicated-worker-expected.txt +++ b/third_party/WebKit/LayoutTests/webexposed/global-constructors-listing-dedicated-worker-expected.txt @@ -14,6 +14,7 @@ Starting worker: resources/global-context-constructors-listing.js [Worker] Error [Worker] EvalError [Worker] EventSource +[Worker] File [Worker] FileError [Worker] FileReader [Worker] FileReaderSync diff --git a/third_party/WebKit/LayoutTests/webexposed/global-constructors-listing-shared-worker-expected.txt b/third_party/WebKit/LayoutTests/webexposed/global-constructors-listing-shared-worker-expected.txt index 35d341b..a06d5e2 100644 --- a/third_party/WebKit/LayoutTests/webexposed/global-constructors-listing-shared-worker-expected.txt +++ b/third_party/WebKit/LayoutTests/webexposed/global-constructors-listing-shared-worker-expected.txt @@ -13,6 +13,7 @@ Starting worker: resources/global-context-constructors-listing.js [Worker] Error [Worker] EvalError [Worker] EventSource +[Worker] File [Worker] FileError [Worker] FileReader [Worker] FileReaderSync |