From c46ec78846335260f32954bcafa1676d600836f0 Mon Sep 17 00:00:00 2001 From: Piotr Bialecki Date: Wed, 29 Apr 2020 18:01:33 -0700 Subject: [PATCH] Fix idlharness.js' handling of Float(32/64)Array types idlharness.js does not seem to correctly handle Float32Array and Float64Array types. When an interface uses such types, the tests will fail with the exception thrown from idlharness.js:1221: `throw new IdlHarnessError("Unrecognized type " + type);` The fix is to teach idlharness.js how to handle Float(32/64)Array types, and, while at it, to teach it to handle other typed arrays. Bug: 1074548 Change-Id: I549f6ae1ea13590207bd4f49b94439ad2a43a13d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2172163 Reviewed-by: Joshua Bell Reviewed-by: Alexander Cooper Commit-Queue: Piotr Bialecki Cr-Commit-Position: refs/heads/master@{#764058} --- resources/idlharness.js | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/resources/idlharness.js b/resources/idlharness.js index 039a6bba96cddc..139ee5e167f247 100644 --- a/resources/idlharness.js +++ b/resources/idlharness.js @@ -679,6 +679,7 @@ IdlArray.prototype.is_json_type = function(type) case "Uint32Array": case "Uint8ClampedArray": case "Float32Array": + case "Float64Array": case "ArrayBuffer": case "DataView": case "any": @@ -1033,6 +1034,13 @@ IdlArray.prototype.assert_type_is = function(value, type) this.assert_type_is(value, this.members[type.idlType].idlType); return; } + + if (type.nullable && value === null) + { + // This is fine + return; + } + if (type.union) { for (var i = 0; i < type.idlType.length; i++) { try { @@ -1066,12 +1074,6 @@ IdlArray.prototype.assert_type_is = function(value, type) return; } - if (type.nullable && value === null) - { - // This is fine - return; - } - if (type.array) { // TODO: not supported yet @@ -1207,8 +1209,18 @@ IdlArray.prototype.assert_type_is = function(value, type) assert_regexp_match(value, /^([\x00-\ud7ff\ue000-\uffff]|[\ud800-\udbff][\udc00-\udfff])*$/); return; + case "Int8Array": + case "Int16Array": + case "Int32Array": + case "Uint8Array": + case "Uint16Array": + case "Uint32Array": + case "Uint8ClampedArray": + case "Float32Array": + case "Float64Array": + case "ArrayBuffer": case "DataView": - assert_equals(typeof value, "DataView"); + assert_true(value instanceof self[type], "wrong type: not a " + type); return; case "object":