summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/canvas/canvas-lineDash-input-sequence.html
diff options
context:
space:
mode:
authorch.dumez@sisa.samsung.com <ch.dumez@sisa.samsung.com@bbb929c8-8fbe-4397-9dbb-9b2b20218538>2013-07-25 22:17:07 +0000
committerch.dumez@sisa.samsung.com <ch.dumez@sisa.samsung.com@bbb929c8-8fbe-4397-9dbb-9b2b20218538>2013-07-25 22:17:07 +0000
commitfa4a72ebc96a8616d61fb4b645c0abf24b3f64a0 (patch)
treed0bc66bbe7bb4e149be420753c9936c002980241 /third_party/WebKit/LayoutTests/fast/canvas/canvas-lineDash-input-sequence.html
parent7612b59e8ec860614d6ec95f2d1a8ef4bdb22966 (diff)
downloadchromium_src-fa4a72ebc96a8616d61fb4b645c0abf24b3f64a0.zip
chromium_src-fa4a72ebc96a8616d61fb4b645c0abf24b3f64a0.tar.gz
chromium_src-fa4a72ebc96a8616d61fb4b645c0abf24b3f64a0.tar.bz2
Update toNativeArray() / toRefPtrNativeArray() do not match Web IDL specification
Update toNativeArray() / toRefPtrNativeArray() do not match the latest Web IDL specification: - http://dev.w3.org/2006/webapi/WebIDL/#es-array - http://dev.w3.org/2006/webapi/WebIDL/#es-sequence In particular, we no longer generate an empty Vector if the JavaScript value is not an array but can still be converted to an IDL sequence. If the JavaScript value is an object (Other than a Date or a RegExp), we now call [[Get]] on it with a property name of "length" and call ToUint32() on the result. If this succeeds, we then retrieve each item by calling [[Get]] with a property name corresponding to the index. This essentially means that IDL operations taking an array or a sequence in argument will now be more permissive and convert non v8::Array by converting them to sequences. BUG=263758 Review URL: https://chromiumcodereview.appspot.com/19969004 git-svn-id: svn://svn.chromium.org/blink/trunk@154940 bbb929c8-8fbe-4397-9dbb-9b2b20218538
Diffstat (limited to 'third_party/WebKit/LayoutTests/fast/canvas/canvas-lineDash-input-sequence.html')
-rw-r--r--third_party/WebKit/LayoutTests/fast/canvas/canvas-lineDash-input-sequence.html78
1 files changed, 78 insertions, 0 deletions
diff --git a/third_party/WebKit/LayoutTests/fast/canvas/canvas-lineDash-input-sequence.html b/third_party/WebKit/LayoutTests/fast/canvas/canvas-lineDash-input-sequence.html
new file mode 100644
index 0000000..9960dd2
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/canvas/canvas-lineDash-input-sequence.html
@@ -0,0 +1,78 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="help" href="http://www.w3.org/TR/2013/WD-2dcontext2-20130528/#dom-context-2d-setlinedash">
+<script src="../js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<script>
+description("Test that setLineDash converts input argument into a Web IDL sequence");
+
+var canvas = document.createElement('canvas');
+document.body.appendChild(canvas);
+canvas.setAttribute('width', '700');
+canvas.setAttribute('height', '700');
+var ctx = canvas.getContext('2d');
+
+var arrayValues = [5, 15, 25];
+
+function createTestArray(arrayType) {
+ var array;
+ if (arrayType == Object) {
+ // Test a "sequence" (Object with length property).
+ array = {length: arrayValues.length};
+ } else {
+ array = new arrayType(arrayValues.length);
+ }
+
+ for (var i = 0; i < arrayValues.length; ++i)
+ array[i] = arrayValues[i]
+ return array;
+}
+
+var lineDash;
+var inputArray;
+function checkLineDash(testArray, shouldFail) {
+ inputArray = testArray;
+ // Reset line dash.
+ ctx.setLineDash([]);
+ // Set line dash.
+ if (shouldFail) {
+ shouldThrow("ctx.setLineDash(inputArray)", "'TypeError: Type error'");
+ } else {
+ ctx.setLineDash(inputArray);
+ lineDash = ctx.getLineDash();
+ for (var i = 0; i < arrayValues.length; ++i)
+ shouldBe("lineDash[" + i + "]", "" + arrayValues[i]);
+ }
+}
+
+var arrayTypes = [Array, Int8Array, Int16Array, Int32Array, Uint8Array, Uint16Array, Uint32Array, Float32Array, Float64Array, Uint8ClampedArray, Object];
+
+// Success cases.
+for (var i = 0; i < arrayTypes.length; ++i) {
+ debug("* Test passing a " + arrayTypes[i].name + " as input.");
+ checkLineDash(createTestArray(arrayTypes[i]), false);
+}
+
+// Failure cases.
+debug("* Test passing a Date as input.");
+checkLineDash(new Date(), true);
+debug("* Test passing a RegExp as input.");
+checkLineDash(new RegExp(), true);
+debug("* Test passing an Object without length as input.");
+checkLineDash({test: 1}, true);
+debug("* Test passing a Number as input.");
+checkLineDash(3, true);
+debug("* Test passing a String as input.");
+checkLineDash("Test", true);
+debug("* Test passing a Boolean as input.");
+checkLineDash(true, true);
+debug("* Test passing null as input.");
+checkLineDash(null, true);
+debug("* Test passing undefined as input.");
+checkLineDash(undefined, true);
+</script>
+<script src="../js/resources/js-test-post.js"></script>
+</body>
+</html>