Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(99)

Unified Diff: LayoutTests/fast/canvas/script-tests/canvas-lineDash-input-sequence.js

Issue 19969004: Update toNativeArray() / toRefPtrNativeArray() do not match Web IDL specification (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: LayoutTests/fast/canvas/script-tests/canvas-lineDash-input-sequence.js
diff --git a/LayoutTests/fast/canvas/script-tests/canvas-lineDash-input-sequence.js b/LayoutTests/fast/canvas/script-tests/canvas-lineDash-input-sequence.js
new file mode 100644
index 0000000000000000000000000000000000000000..a18a5a0c88a76dc7952fa9f1d109875e838127ae
--- /dev/null
+++ b/LayoutTests/fast/canvas/script-tests/canvas-lineDash-input-sequence.js
@@ -0,0 +1,43 @@
+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 = new Object();
arv (Not doing code reviews) 2013/07/24 16:38:13 array = {length: arrayValues.length};
do-not-use 2013/07/25 08:01:26 OK.
+ array.length = arrayValues.length;
+ } else {
+ eval("array = new " + arrayType + "(" + arrayValues.length + ");");
arv (Not doing code reviews) 2013/07/24 16:38:13 No need for eval here array = new window[arrayTyp
do-not-use 2013/07/25 08:01:26 Ok.
+ }
+
+ for (var i = 0; i < arrayValues.length; ++i)
+ array[i] = arrayValues[i]
+ return array;
+}
+
+var lineDash;
+function checkLineDash(inputArray) {
+ // Reset line dash.
+ ctx.setLineDash([]);
+ // Set line dash and validate that it worked.
+ 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", "Object"];
haraken 2013/07/24 15:59:30 Shall we also test Uint8ClampedArray?
arv (Not doing code reviews) 2013/07/24 16:38:13 Change this to pass the constructors instead of th
do-not-use 2013/07/25 08:01:26 Good idea.
do-not-use 2013/07/25 08:01:26 OK.
+
+for (var i = 0; i < arrayTypes.length; ++i) {
+ debug("* Test passing a " + arrayTypes[i] + " as input.");
arv (Not doing code reviews) 2013/07/24 16:38:13 then do arrayType[i].name
do-not-use 2013/07/25 08:01:26 OK.
+ checkLineDash(createTestArray(arrayTypes[i]));
+}
+

Powered by Google App Engine
This is Rietveld 408576698