1 // |reftest| shell-option(--enable-uint8array-base64) skip-if(!Uint8Array.fromBase64||!xulRuntime.shell) -- uint8array-base64 is not enabled unconditionally, requires shell-options
2 // Copyright (C) 2024 Kevin Gibbons. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
5 esid: sec-uint8array.prototype.setfromhex
6 description: Uint8Array.prototype.setFromHex behavior when target buffer is small
7 includes: [compareArray.js]
8 features: [uint8array-base64, TypedArray]
12 var target = new Uint8Array([255, 255]);
13 var result = target.setFromHex('aabbcc');
14 assert.sameValue(result.read, 4);
15 assert.sameValue(result.written, 2);
16 assert.compareArray(target, [170, 187]);
19 var target = new Uint8Array([255, 255, 255]);
20 var result = target.setFromHex('aabbcc');
21 assert.sameValue(result.read, 6);
22 assert.sameValue(result.written, 3);
23 assert.compareArray(target, [170, 187, 204]);
26 var target = new Uint8Array([255, 255, 255, 255]);
27 var result = target.setFromHex('aabbcc');
28 assert.sameValue(result.read, 6);
29 assert.sameValue(result.written, 3);
30 assert.compareArray(target, [170, 187, 204, 255]);