summaryrefslogtreecommitdiffstats
path: root/testing/xpcshell/odoh-wasm/pkg/odoh_wasm.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/xpcshell/odoh-wasm/pkg/odoh_wasm.js
parentInitial commit. (diff)
downloadfirefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz
firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/xpcshell/odoh-wasm/pkg/odoh_wasm.js')
-rw-r--r--testing/xpcshell/odoh-wasm/pkg/odoh_wasm.js132
1 files changed, 132 insertions, 0 deletions
diff --git a/testing/xpcshell/odoh-wasm/pkg/odoh_wasm.js b/testing/xpcshell/odoh-wasm/pkg/odoh_wasm.js
new file mode 100644
index 0000000000..14b97d7436
--- /dev/null
+++ b/testing/xpcshell/odoh-wasm/pkg/odoh_wasm.js
@@ -0,0 +1,132 @@
+let imports = {};
+imports['__wbindgen_placeholder__'] = module.exports;
+let wasm;
+const { TextDecoder } = require(`util`);
+
+const heap = new Array(32).fill(undefined);
+
+heap.push(undefined, null, true, false);
+
+function getObject(idx) { return heap[idx]; }
+
+let heap_next = heap.length;
+
+function dropObject(idx) {
+ if (idx < 36) return;
+ heap[idx] = heap_next;
+ heap_next = idx;
+}
+
+function takeObject(idx) {
+ const ret = getObject(idx);
+ dropObject(idx);
+ return ret;
+}
+
+let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
+
+cachedTextDecoder.decode();
+
+let cachegetUint8Memory0 = null;
+function getUint8Memory0() {
+ if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) {
+ cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer);
+ }
+ return cachegetUint8Memory0;
+}
+
+function getStringFromWasm0(ptr, len) {
+ return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
+}
+
+function addHeapObject(obj) {
+ if (heap_next === heap.length) heap.push(heap.length + 1);
+ const idx = heap_next;
+ heap_next = heap[idx];
+
+ heap[idx] = obj;
+ return idx;
+}
+/**
+* @returns {Uint8Array}
+*/
+module.exports.get_odoh_config = function() {
+ var ret = wasm.get_odoh_config();
+ return takeObject(ret);
+};
+
+let WASM_VECTOR_LEN = 0;
+
+function passArray8ToWasm0(arg, malloc) {
+ const ptr = malloc(arg.length * 1);
+ getUint8Memory0().set(arg, ptr / 1);
+ WASM_VECTOR_LEN = arg.length;
+ return ptr;
+}
+/**
+* @param {Uint8Array} odoh_encrypted_query_msg
+* @returns {Uint8Array}
+*/
+module.exports.decrypt_query = function(odoh_encrypted_query_msg) {
+ var ptr0 = passArray8ToWasm0(odoh_encrypted_query_msg, wasm.__wbindgen_malloc);
+ var len0 = WASM_VECTOR_LEN;
+ var ret = wasm.decrypt_query(ptr0, len0);
+ return takeObject(ret);
+};
+
+/**
+* @param {Uint8Array} response
+* @returns {Uint8Array}
+*/
+module.exports.create_response = function(response) {
+ var ptr0 = passArray8ToWasm0(response, wasm.__wbindgen_malloc);
+ var len0 = WASM_VECTOR_LEN;
+ var ret = wasm.create_response(ptr0, len0);
+ return takeObject(ret);
+};
+
+module.exports.__wbindgen_object_drop_ref = function(arg0) {
+ takeObject(arg0);
+};
+
+module.exports.__wbg_log_b3f203d9e6882397 = function(arg0, arg1) {
+ console.log(getStringFromWasm0(arg0, arg1));
+};
+
+module.exports.__wbg_buffer_eb2155f17856c20b = function(arg0) {
+ var ret = getObject(arg0).buffer;
+ return addHeapObject(ret);
+};
+
+module.exports.__wbg_newwithbyteoffsetandlength_7d07f77c6d0d8e26 = function(arg0, arg1, arg2) {
+ var ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
+ return addHeapObject(ret);
+};
+
+module.exports.__wbg_new_ff8b26f7b2d7e2fb = function(arg0) {
+ var ret = new Uint8Array(getObject(arg0));
+ return addHeapObject(ret);
+};
+
+module.exports.__wbg_newwithlength_a49b32b2030b93c3 = function(arg0) {
+ var ret = new Uint8Array(arg0 >>> 0);
+ return addHeapObject(ret);
+};
+
+module.exports.__wbindgen_throw = function(arg0, arg1) {
+ throw new Error(getStringFromWasm0(arg0, arg1));
+};
+
+module.exports.__wbindgen_memory = function() {
+ var ret = wasm.memory;
+ return addHeapObject(ret);
+};
+
+const path = require('path').join(__dirname, 'odoh_wasm_bg.wasm');
+const bytes = require('fs').readFileSync(path);
+
+const wasmModule = new WebAssembly.Module(bytes);
+const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
+wasm = wasmInstance.exports;
+module.exports.__wasm = wasm;
+