Bug 1945965 – remove new tab April Fools logo. r=home-newtab-reviewers,reemhamz
[gecko.git] / dom / mls / tests / head_mls.js
blobe82a25394b70f9dceff7a7ead0f29de0c25b138d
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
4 */
6 "use strict";
8 //
9 // Array equality
11 function arraysAreEqual(arr1, arr2) {
12 if (arr1.length !== arr2.length) {
13 return false;
15 for (let i = 0; i < arr1.length; i++) {
16 if (arr1[i] !== arr2[i]) {
17 return false;
20 return true;
24 // Serialization / Derserialization helpers
26 function stringToByteArray(str) {
27 return new TextEncoder().encode(str);
30 function byteArrayToString(byteArray) {
31 return new TextDecoder().decode(new Uint8Array(byteArray).buffer);
34 function stringToArrayBuffer(str) {
35 return new Uint8Array(new TextEncoder().encode(str)).buffer;
38 function byteArrayToHexString(buffer) {
39 const byteArray = new Uint8Array(buffer);
40 const hexParts = [];
41 for (let i = 0; i < byteArray.length; i++) {
42 const hex = byteArray[i].toString(16);
43 const paddedHex = ("00" + hex).slice(-2);
44 hexParts.push(paddedHex);
46 return hexParts.join("");