quickwin 3.0.1 → 3.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +3 -0
- package/README.md +2 -0
- package/package.json +2 -3
- package/qwin-nowasm-x86.exe +0 -0
- package/qwin-nowasm.exe +0 -0
- package/qwin-x86.exe +0 -0
- package/qwin.exe +0 -0
- package/examples/PdfCanvas.js +0 -38
- package/examples/PdfCanvas.tsx +0 -54
- package/examples/execd/main.js +0 -23379
- package/examples/execd/tray.js +0 -192
- package/examples/execd/worker.js +0 -122
- package/examples/pdf_preview2.js +0 -398
- package/examples/pdf_preview2.ts +0 -353
- package/examples/pdf_viewer.js +0 -22515
- package/examples/pdf_viewer.tsx +0 -228
- package/examples/test_gallery.js +0 -18692
- package/examples/test_gallery.tsx +0 -291
- package/examples/test_react_lazy.js +0 -18560
- package/examples/test_react_lazy.tsx +0 -65
- package/examples/test_react_listbox.js +0 -18562
- package/examples/test_react_listbox.tsx +0 -73
- package/examples/test_root_window.js +0 -18532
- package/examples/test_root_window.tsx +0 -41
- package/examples/test_tab.js +0 -18563
- package/examples/test_tab.tsx +0 -77
- package/examples/tray_demo.js +0 -86
- package/examples/tray_demo.tsx +0 -89
- package/test/add.wasm +0 -0
- package/test/bench_ffi_callraw.js +0 -235
- package/test/bench_ffi_callraw.ts +0 -235
- package/test/bench_ffi_overhead.js +0 -139
- package/test/bench_ffi_overhead.ts +0 -141
- package/test/bench_sendmessage.js +0 -104
- package/test/bench_sendmessage.ts +0 -100
- package/test/bench_sendmessage_nonnull.js +0 -187
- package/test/bench_sendmessage_nonnull.ts +0 -188
- package/test/complex.wasm +0 -0
- package/test/complex_imports.wasm +0 -0
- package/test/debug/http_server_e2e.js +0 -31
- package/test/debug/minwasm.js +0 -52
- package/test/debug/mupdf_debug.js +0 -86
- package/test/debug/wasm.js +0 -122
- package/test/debug/wasm_export_debug.js +0 -54
- package/test/debug/wasm_names.js +0 -36
- package/test/example.pdf +0 -0
- package/test/global_imports.wasm +0 -0
- package/test/import_func.wasm +0 -0
- package/test/imports.wasm +0 -0
- package/test/mupdf-cdn.js +0 -40
- package/test/mupdf-cdn.ts +0 -43
- package/test/run.js +0 -111
- package/test/run.ts +0 -116
- package/test/sjlj.wasm +0 -0
- package/test/test_basic.js +0 -7
- package/test/test_basic.ts +0 -9
- package/test/test_basic_fetch.js +0 -63
- package/test/test_basic_fetch.ts +0 -59
- package/test/test_brotli.js +0 -48
- package/test/test_brotli.ts +0 -52
- package/test/test_fetch_cache.js +0 -169
- package/test/test_fetch_cache.ts +0 -187
- package/test/test_ffi.js +0 -157
- package/test/test_ffi.ts +0 -170
- package/test/test_ffi_abi.js +0 -290
- package/test/test_ffi_abi.ts +0 -274
- package/test/test_ffi_array.js +0 -116
- package/test/test_ffi_array.ts +0 -141
- package/test/test_ffi_bind.js +0 -656
- package/test/test_ffi_bind.ts +0 -670
- package/test/test_ffi_struct.js +0 -779
- package/test/test_ffi_struct.ts +0 -828
- package/test/test_ffi_struct_layout.js +0 -495
- package/test/test_ffi_struct_layout.ts +0 -543
- package/test/test_ffi_user32.js +0 -103
- package/test/test_ffi_user32.ts +0 -113
- package/test/test_ffi_windows.js +0 -172
- package/test/test_ffi_windows.ts +0 -187
- package/test/test_files.js +0 -102
- package/test/test_files.ts +0 -121
- package/test/test_frame_encoding.js +0 -128
- package/test/test_frame_encoding.ts +0 -132
- package/test/test_gdi_draw.js +0 -681
- package/test/test_gdi_draw.ts +0 -725
- package/test/test_helper.js +0 -91
- package/test/test_helper.ts +0 -88
- package/test/test_http_import.js +0 -96
- package/test/test_http_import.ts +0 -93
- package/test/test_http_server.js +0 -214
- package/test/test_http_server.ts +0 -211
- package/test/test_import_dir.js +0 -4
- package/test/test_import_dir.ts +0 -5
- package/test/test_ipv6.js +0 -134
- package/test/test_ipv6.ts +0 -130
- package/test/test_jsx.js +0 -1314
- package/test/test_meta_url.js +0 -3
- package/test/test_meta_url.ts +0 -4
- package/test/test_mupdf_render.js +0 -51
- package/test/test_mupdf_render.ts +0 -55
- package/test/test_mupdf_twice.js +0 -62
- package/test/test_mupdf_twice.ts +0 -65
- package/test/test_mupdf_wasm.js +0 -39
- package/test/test_mupdf_wasm.ts +0 -32
- package/test/test_net_event.js +0 -57
- package/test/test_net_event.ts +0 -56
- package/test/test_net_fetch.js +0 -384
- package/test/test_net_fetch.ts +0 -373
- package/test/test_net_websocket.js +0 -180
- package/test/test_net_websocket.ts +0 -164
- package/test/test_polyfill.js +0 -144
- package/test/test_polyfill.ts +0 -159
- package/test/test_printer.js +0 -137
- package/test/test_printer.ts +0 -148
- package/test/test_proc.js +0 -141
- package/test/test_proc.ts +0 -163
- package/test/test_react_complex.js +0 -18678
- package/test/test_react_counter.js +0 -18555
- package/test/test_react_flex.js +0 -18871
- package/test/test_react_hidden.js +0 -18560
- package/test/test_react_listview_link.js +0 -18590
- package/test/test_react_notify.js +0 -18797
- package/test/test_react_render.js +0 -18550
- package/test/test_registry.js +0 -74
- package/test/test_registry.ts +0 -95
- package/test/test_sysinfo.js +0 -122
- package/test/test_sysinfo.ts +0 -141
- package/test/test_url.js +0 -173
- package/test/test_url.ts +0 -183
- package/test/test_wasm_basic.js +0 -85
- package/test/test_wasm_basic.ts +0 -73
- package/test/test_wasm_import_global.js +0 -41
- package/test/test_wasm_import_global.ts +0 -45
- package/test/test_wasm_sjlj.js +0 -145
- package/test/test_wasm_sjlj.ts +0 -125
- package/test/test_wasm_types.js +0 -97
- package/test/test_wasm_types.ts +0 -124
- package/test/test_wolfssl_read.js +0 -203
- package/test/test_wolfssl_read.ts +0 -184
- package/test/test_worker.js +0 -21
- package/test/test_worker.ts +0 -24
- package/test/test_worker_concurrent.js +0 -45
- package/test/test_worker_concurrent.ts +0 -56
- package/test/test_worker_data_url.js +0 -46
- package/test/test_worker_data_url.ts +0 -51
- package/test/test_worker_fetch.js +0 -26
- package/test/test_worker_fetch.ts +0 -27
- package/test/test_worker_net.js +0 -69
- package/test/test_worker_net.ts +0 -66
- package/test/test_worker_wasm_concurrent.js +0 -44
- package/test/test_worker_wasm_concurrent.ts +0 -45
- package/test/types.wasm +0 -0
- package/test/worker_fetch.js +0 -13
- package/test/worker_fetch.ts +0 -13
- package/test/worker_helper.js +0 -1
- package/test/worker_helper.ts +0 -1
- package/test/worker_http.js +0 -18
- package/test/worker_http.ts +0 -20
- package/test/worker_import_lib.js +0 -12
- package/test/worker_import_lib.ts +0 -13
- package/test/worker_module.js +0 -16
- package/test/worker_module.ts +0 -17
- package/test/worker_wasm_concurrent.js +0 -22
- package/test/worker_wasm_concurrent.ts +0 -22
package/test/test_wasm_sjlj.ts
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import { Tester, readWasmFile } from './test_helper.js'
|
|
2
|
-
|
|
3
|
-
class EmscriptenEH {}
|
|
4
|
-
class EmscriptenSjLj extends EmscriptenEH {}
|
|
5
|
-
|
|
6
|
-
export const suite = {
|
|
7
|
-
name: 'wasm-sjlj',
|
|
8
|
-
run: (t: Tester) => {
|
|
9
|
-
;(globalThis as any).EmscriptenEH = EmscriptenEH
|
|
10
|
-
;(globalThis as any).EmscriptenSjLj = EmscriptenSjLj
|
|
11
|
-
|
|
12
|
-
const buf = readWasmFile('./sjlj.wasm')
|
|
13
|
-
if (!buf) { t.fail++; return }
|
|
14
|
-
|
|
15
|
-
t.section('Module')
|
|
16
|
-
var mod: WebAssembly.Module | null = null
|
|
17
|
-
try {
|
|
18
|
-
mod = new WebAssembly.Module(buf)
|
|
19
|
-
t.check('Module created', true, mod instanceof WebAssembly.Module)
|
|
20
|
-
} catch (e) { t.fail++; return }
|
|
21
|
-
|
|
22
|
-
t.section('Instance with SjLj imports')
|
|
23
|
-
var inst: WebAssembly.Instance | null = null
|
|
24
|
-
var threwBit = 0
|
|
25
|
-
|
|
26
|
-
function getWasmTableEntry(index: number): Function {
|
|
27
|
-
const table = inst!.exports['__indirect_function_table'] as { get(index: number): Function }
|
|
28
|
-
const fn = table.get(index)
|
|
29
|
-
return fn as Function
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function _setThrew(val: number, _v: number): void {
|
|
33
|
-
if (threwBit === 0) {
|
|
34
|
-
threwBit = val
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function invoke_ii(index: number, a1: number): number {
|
|
39
|
-
try {
|
|
40
|
-
return getWasmTableEntry(index)(a1)
|
|
41
|
-
} catch (e) {
|
|
42
|
-
if (!(e instanceof EmscriptenEH)) throw e
|
|
43
|
-
_setThrew(1, 0)
|
|
44
|
-
return 0
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
try {
|
|
49
|
-
inst = new WebAssembly.Instance(mod, {
|
|
50
|
-
env: {
|
|
51
|
-
throw_longjmp: () => { throw new EmscriptenSjLj },
|
|
52
|
-
invoke_ii: invoke_ii,
|
|
53
|
-
}
|
|
54
|
-
})
|
|
55
|
-
t.check('Instance created', true, inst instanceof WebAssembly.Instance)
|
|
56
|
-
} catch (e) {
|
|
57
|
-
t.fail++
|
|
58
|
-
return
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
t.section('identity (no throw)')
|
|
62
|
-
try {
|
|
63
|
-
threwBit = 0
|
|
64
|
-
const result = (inst.exports as { identity: (x: number) => number }).identity(42)
|
|
65
|
-
t.check('identity(42) = 42', 42, result)
|
|
66
|
-
} catch (e) { t.fail++ }
|
|
67
|
-
|
|
68
|
-
t.section('invoke_ii with no-throw function')
|
|
69
|
-
try {
|
|
70
|
-
threwBit = 0
|
|
71
|
-
const result = (inst.exports as { test_no_throw: () => number }).test_no_throw()
|
|
72
|
-
t.check('test_no_throw() returns 10', 10, result)
|
|
73
|
-
t.check('threwBit is 0', 0, threwBit)
|
|
74
|
-
} catch (e) { t.fail++ }
|
|
75
|
-
|
|
76
|
-
t.section('invoke_ii with throwing function')
|
|
77
|
-
try {
|
|
78
|
-
threwBit = 0
|
|
79
|
-
const result = (inst.exports as { test_throw: () => number }).test_throw()
|
|
80
|
-
t.check('test_throw() detects threwBit', true, result !== 0)
|
|
81
|
-
t.check('threwBit is set', true, threwBit !== 0)
|
|
82
|
-
} catch (e) { t.fail++ }
|
|
83
|
-
|
|
84
|
-
t.section('nested invoke (invoke_ii calls invoke_ii)')
|
|
85
|
-
try {
|
|
86
|
-
threwBit = 0
|
|
87
|
-
const result = (inst.exports as { test_nested_invoke: () => number }).test_nested_invoke()
|
|
88
|
-
t.check('test_nested_invoke() detects threwBit', true, result !== 0)
|
|
89
|
-
t.check('threwBit is set', true, threwBit !== 0)
|
|
90
|
-
} catch (e) { t.fail++ }
|
|
91
|
-
|
|
92
|
-
t.section('setjmp_test pattern')
|
|
93
|
-
try {
|
|
94
|
-
threwBit = 0
|
|
95
|
-
const result = (inst.exports as { setjmp_test: (x: number) => number }).setjmp_test(0)
|
|
96
|
-
t.check('setjmp_test detects throw', -1, result)
|
|
97
|
-
t.check('threwBit is set', true, threwBit !== 0)
|
|
98
|
-
} catch (e) { t.fail++ }
|
|
99
|
-
|
|
100
|
-
t.section('setjmp/longjmp: a(x) normal path')
|
|
101
|
-
try {
|
|
102
|
-
threwBit = 0
|
|
103
|
-
const result = (inst.exports as { a: (x: number) => number }).a(5)
|
|
104
|
-
t.check('a(5) returns 10 (b returns x*2)', 10, result)
|
|
105
|
-
t.check('threwBit is 0', 0, threwBit)
|
|
106
|
-
} catch (e) { t.fail++ }
|
|
107
|
-
|
|
108
|
-
t.section('setjmp/longjmp: a(x) longjmp path')
|
|
109
|
-
try {
|
|
110
|
-
threwBit = 0
|
|
111
|
-
const result = (inst.exports as { a: (x: number) => number }).a(-1)
|
|
112
|
-
t.check('a(-1) returns -1 (longjmp caught)', -1, result)
|
|
113
|
-
t.check('threwBit is set', true, threwBit !== 0)
|
|
114
|
-
} catch (e) { t.fail++ }
|
|
115
|
-
|
|
116
|
-
t.section('EmscriptenSjLj instanceof check')
|
|
117
|
-
try {
|
|
118
|
-
const exc = new EmscriptenSjLj()
|
|
119
|
-
t.check('instanceof EmscriptenEH', true, exc instanceof EmscriptenEH)
|
|
120
|
-
t.check('instanceof EmscriptenSjLj', true, exc instanceof EmscriptenSjLj)
|
|
121
|
-
const regularErr = new Error('test')
|
|
122
|
-
t.check('Error not instanceof EmscriptenEH', false, regularErr instanceof EmscriptenEH)
|
|
123
|
-
} catch (e) { t.fail++ }
|
|
124
|
-
}
|
|
125
|
-
}
|
package/test/test_wasm_types.js
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { readWasmFile } from './test_helper.js';
|
|
2
|
-
export const suite = {
|
|
3
|
-
name: 'wasm-types',
|
|
4
|
-
run: (t) => {
|
|
5
|
-
const buf = readWasmFile('./types.wasm');
|
|
6
|
-
if (!buf) {
|
|
7
|
-
t.fail++;
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
const m = new WebAssembly.Module(buf);
|
|
11
|
-
const i = new WebAssembly.Instance(m);
|
|
12
|
-
const e = i.exports;
|
|
13
|
-
t.section('i32');
|
|
14
|
-
t.check('add_i32(10, 20)', 30, e.add_i32(10, 20));
|
|
15
|
-
t.check('add_i32(-5, 3)', -2, e.add_i32(-5, 3));
|
|
16
|
-
t.section('i64');
|
|
17
|
-
t.check('add_i64(100, 200)', 300, e.add_i64(100, 200));
|
|
18
|
-
t.check('add_i64(10000000000, 20000000000)', 30000000000, e.add_i64(10000000000, 20000000000));
|
|
19
|
-
t.check('add_i64(-10000000000, 5000000000)', -5000000000, e.add_i64(-10000000000, 5000000000));
|
|
20
|
-
t.check('factorial_i64(5)', 120, e.factorial_i64(5));
|
|
21
|
-
t.check('factorial_i64(10)', 3628800, e.factorial_i64(10));
|
|
22
|
-
t.section('f32');
|
|
23
|
-
t.check('add_f32(1.5, 2.5)', 4.0, e.add_f32(1.5, 2.5));
|
|
24
|
-
t.check('add_f32(-1.0, 1.0)', 0.0, e.add_f32(-1.0, 1.0));
|
|
25
|
-
t.section('f64');
|
|
26
|
-
t.check('add_f64(3.14, 2.86)', 6.0, e.add_f64(3.14, 2.86));
|
|
27
|
-
t.check('sqrt_f64(144.0)', 12.0, e.sqrt_f64(144.0));
|
|
28
|
-
t.section('mixed');
|
|
29
|
-
t.check('mixed_args(1, 2, 3.0, 4.0)', 10.0, e.mixed_args(1, 2, 3.0, 4.0));
|
|
30
|
-
t.section('memory');
|
|
31
|
-
e.write_memory(0, 12345678);
|
|
32
|
-
t.check('write/read memory', 12345678, e.read_memory(0));
|
|
33
|
-
t.section('JS-side TypedArray');
|
|
34
|
-
t.check('Int32Array[0]', 12345678, new Int32Array(e.memory.buffer)[0]);
|
|
35
|
-
e.write_memory(4, 999);
|
|
36
|
-
t.check('Int32Array[1] after write', 999, new Int32Array(e.memory.buffer)[1]);
|
|
37
|
-
t.section('exported globals');
|
|
38
|
-
t.check('const_i32.value', 42, e.const_i32.value);
|
|
39
|
-
t.check('const_f64.value', 3.14, e.const_f64.value);
|
|
40
|
-
t.check('mutable_i32 is Global', true, e.mutable_i32 instanceof WebAssembly.Global);
|
|
41
|
-
t.check('mutable_i32.value', 99, e.mutable_i32.value);
|
|
42
|
-
e.mutable_i32.value = 500;
|
|
43
|
-
t.check('mutable_i32 after set from JS', 500, e.mutable_i32.value);
|
|
44
|
-
t.check('mutable_i32 after set from WASM', 500, e.read_mut_global());
|
|
45
|
-
t.section('Global constructor');
|
|
46
|
-
var g;
|
|
47
|
-
g = new WebAssembly.Global({ value: 'i32', mutable: false }, 42);
|
|
48
|
-
t.check('Global(i32)', 42, g.value);
|
|
49
|
-
g = new WebAssembly.Global({ value: 'i64' }, 10000000000);
|
|
50
|
-
t.check('Global(i64)', 10000000000, g.value);
|
|
51
|
-
g = new WebAssembly.Global({ value: 'f64' }, 3.14);
|
|
52
|
-
t.check('Global(f64)', 3.14, g.value);
|
|
53
|
-
g = new WebAssembly.Global({ value: 'f32' }, 2.5);
|
|
54
|
-
t.check('Global(f32)', 2.5, g.value);
|
|
55
|
-
t.section('Global mutable set');
|
|
56
|
-
g = new WebAssembly.Global({ value: 'i32', mutable: true }, 0);
|
|
57
|
-
t.check('initial', 0, g.value);
|
|
58
|
-
g.value = 77;
|
|
59
|
-
t.check('after set', 77, g.value);
|
|
60
|
-
t.section('Global immutable set throws');
|
|
61
|
-
g = new WebAssembly.Global({ value: 'i32', mutable: false }, 10);
|
|
62
|
-
try {
|
|
63
|
-
g.value = 999;
|
|
64
|
-
t.fail++;
|
|
65
|
-
}
|
|
66
|
-
catch (e) {
|
|
67
|
-
t.ok++;
|
|
68
|
-
}
|
|
69
|
-
t.section('Global.valueOf');
|
|
70
|
-
g = new WebAssembly.Global({ value: 'i32' }, 55);
|
|
71
|
-
t.check('valueOf()', 55, g.valueOf());
|
|
72
|
-
t.section('Memory constructor');
|
|
73
|
-
var mem;
|
|
74
|
-
mem = new WebAssembly.Memory({ initial: 1 });
|
|
75
|
-
t.check('Memory created', true, mem instanceof WebAssembly.Memory);
|
|
76
|
-
t.check('buffer byteLength', 65536, mem.buffer.byteLength);
|
|
77
|
-
mem = new WebAssembly.Memory({ initial: 2, maximum: 4 });
|
|
78
|
-
t.check('Memory(2,4) buffer', 131072, mem.buffer.byteLength);
|
|
79
|
-
t.check('grow(1) returned', 2, mem.grow(1));
|
|
80
|
-
t.check('after grow buffer', 196608, mem.buffer.byteLength);
|
|
81
|
-
t.section('instance.exports.memory');
|
|
82
|
-
t.check('memory is Memory', true, e.memory instanceof WebAssembly.Memory);
|
|
83
|
-
t.check('memory.buffer.byteLength', 65536, e.memory.buffer.byteLength);
|
|
84
|
-
t.section('standalone Memory + TypedArray');
|
|
85
|
-
mem = new WebAssembly.Memory({ initial: 1 });
|
|
86
|
-
var arr = new Int32Array(mem.buffer);
|
|
87
|
-
arr[0] = 42;
|
|
88
|
-
arr[1] = 7;
|
|
89
|
-
t.check('Int32Array[0]', 42, arr[0]);
|
|
90
|
-
t.check('Int32Array[1]', 7, arr[1]);
|
|
91
|
-
t.section('buffer identity');
|
|
92
|
-
arr[2] = 100;
|
|
93
|
-
t.check('old view[2]', 100, arr[2]);
|
|
94
|
-
t.check('new view[2]', 100, new Int32Array(mem.buffer)[2]);
|
|
95
|
-
t.check('buffer is same object', true, mem.buffer === mem.buffer);
|
|
96
|
-
}
|
|
97
|
-
};
|
package/test/test_wasm_types.ts
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import { Tester, readWasmFile } from './test_helper.js'
|
|
2
|
-
|
|
3
|
-
export const suite = {
|
|
4
|
-
name: 'wasm-types',
|
|
5
|
-
run: (t: Tester) => {
|
|
6
|
-
const buf = readWasmFile('./types.wasm')
|
|
7
|
-
if (!buf) { t.fail++; return }
|
|
8
|
-
const m = new WebAssembly.Module(buf)
|
|
9
|
-
const i = new WebAssembly.Instance<{
|
|
10
|
-
add_i32: (a: number, b: number) => number
|
|
11
|
-
add_i64: (a: number, b: number) => number
|
|
12
|
-
factorial_i64: (n: number) => number
|
|
13
|
-
add_f32: (a: number, b: number) => number
|
|
14
|
-
add_f64: (a: number, b: number) => number
|
|
15
|
-
sqrt_f64: (x: number) => number
|
|
16
|
-
mixed_args: (a: number, b: number, c: number, d: number) => number
|
|
17
|
-
write_memory: (offset: number, value: number) => void
|
|
18
|
-
read_memory: (offset: number) => number
|
|
19
|
-
read_mut_global: () => number
|
|
20
|
-
memory: WebAssembly.Memory
|
|
21
|
-
const_i32: WebAssembly.Global
|
|
22
|
-
const_f64: WebAssembly.Global
|
|
23
|
-
mutable_i32: WebAssembly.Global
|
|
24
|
-
}>(m)
|
|
25
|
-
const e = i.exports
|
|
26
|
-
|
|
27
|
-
t.section('i32')
|
|
28
|
-
t.check('add_i32(10, 20)', 30, e.add_i32(10, 20))
|
|
29
|
-
t.check('add_i32(-5, 3)', -2, e.add_i32(-5, 3))
|
|
30
|
-
|
|
31
|
-
t.section('i64')
|
|
32
|
-
t.check('add_i64(100, 200)', 300, e.add_i64(100, 200))
|
|
33
|
-
t.check('add_i64(10000000000, 20000000000)', 30000000000, e.add_i64(10000000000, 20000000000))
|
|
34
|
-
t.check('add_i64(-10000000000, 5000000000)', -5000000000, e.add_i64(-10000000000, 5000000000))
|
|
35
|
-
t.check('factorial_i64(5)', 120, e.factorial_i64(5))
|
|
36
|
-
t.check('factorial_i64(10)', 3628800, e.factorial_i64(10))
|
|
37
|
-
|
|
38
|
-
t.section('f32')
|
|
39
|
-
t.check('add_f32(1.5, 2.5)', 4.0, e.add_f32(1.5, 2.5))
|
|
40
|
-
t.check('add_f32(-1.0, 1.0)', 0.0, e.add_f32(-1.0, 1.0))
|
|
41
|
-
|
|
42
|
-
t.section('f64')
|
|
43
|
-
t.check('add_f64(3.14, 2.86)', 6.0, e.add_f64(3.14, 2.86))
|
|
44
|
-
t.check('sqrt_f64(144.0)', 12.0, e.sqrt_f64(144.0))
|
|
45
|
-
|
|
46
|
-
t.section('mixed')
|
|
47
|
-
t.check('mixed_args(1, 2, 3.0, 4.0)', 10.0, e.mixed_args(1, 2, 3.0, 4.0))
|
|
48
|
-
|
|
49
|
-
t.section('memory')
|
|
50
|
-
e.write_memory(0, 12345678)
|
|
51
|
-
t.check('write/read memory', 12345678, e.read_memory(0))
|
|
52
|
-
|
|
53
|
-
t.section('JS-side TypedArray')
|
|
54
|
-
t.check('Int32Array[0]', 12345678, new Int32Array(e.memory.buffer)[0])
|
|
55
|
-
e.write_memory(4, 999)
|
|
56
|
-
t.check('Int32Array[1] after write', 999, new Int32Array(e.memory.buffer)[1])
|
|
57
|
-
|
|
58
|
-
t.section('exported globals')
|
|
59
|
-
t.check('const_i32.value', 42, e.const_i32.value)
|
|
60
|
-
t.check('const_f64.value', 3.14, e.const_f64.value)
|
|
61
|
-
t.check('mutable_i32 is Global', true, e.mutable_i32 instanceof WebAssembly.Global)
|
|
62
|
-
t.check('mutable_i32.value', 99, e.mutable_i32.value)
|
|
63
|
-
e.mutable_i32.value = 500
|
|
64
|
-
t.check('mutable_i32 after set from JS', 500, e.mutable_i32.value)
|
|
65
|
-
t.check('mutable_i32 after set from WASM', 500, e.read_mut_global())
|
|
66
|
-
|
|
67
|
-
t.section('Global constructor')
|
|
68
|
-
var g: WebAssembly.Global
|
|
69
|
-
g = new WebAssembly.Global({ value: 'i32', mutable: false }, 42)
|
|
70
|
-
t.check('Global(i32)', 42, g.value)
|
|
71
|
-
g = new WebAssembly.Global({ value: 'i64' }, 10000000000)
|
|
72
|
-
t.check('Global(i64)', 10000000000, g.value)
|
|
73
|
-
g = new WebAssembly.Global({ value: 'f64' }, 3.14)
|
|
74
|
-
t.check('Global(f64)', 3.14, g.value)
|
|
75
|
-
g = new WebAssembly.Global({ value: 'f32' }, 2.5)
|
|
76
|
-
t.check('Global(f32)', 2.5, g.value)
|
|
77
|
-
|
|
78
|
-
t.section('Global mutable set')
|
|
79
|
-
g = new WebAssembly.Global({ value: 'i32', mutable: true }, 0)
|
|
80
|
-
t.check('initial', 0, g.value)
|
|
81
|
-
g.value = 77
|
|
82
|
-
t.check('after set', 77, g.value)
|
|
83
|
-
|
|
84
|
-
t.section('Global immutable set throws')
|
|
85
|
-
g = new WebAssembly.Global({ value: 'i32', mutable: false }, 10)
|
|
86
|
-
try {
|
|
87
|
-
g.value = 999
|
|
88
|
-
t.fail++
|
|
89
|
-
} catch (e) {
|
|
90
|
-
t.ok++
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
t.section('Global.valueOf')
|
|
94
|
-
g = new WebAssembly.Global({ value: 'i32' }, 55)
|
|
95
|
-
t.check('valueOf()', 55, g.valueOf())
|
|
96
|
-
|
|
97
|
-
t.section('Memory constructor')
|
|
98
|
-
var mem: WebAssembly.Memory
|
|
99
|
-
mem = new WebAssembly.Memory({ initial: 1 })
|
|
100
|
-
t.check('Memory created', true, mem instanceof WebAssembly.Memory)
|
|
101
|
-
t.check('buffer byteLength', 65536, mem.buffer.byteLength)
|
|
102
|
-
mem = new WebAssembly.Memory({ initial: 2, maximum: 4 })
|
|
103
|
-
t.check('Memory(2,4) buffer', 131072, mem.buffer.byteLength)
|
|
104
|
-
t.check('grow(1) returned', 2, mem.grow(1))
|
|
105
|
-
t.check('after grow buffer', 196608, mem.buffer.byteLength)
|
|
106
|
-
|
|
107
|
-
t.section('instance.exports.memory')
|
|
108
|
-
t.check('memory is Memory', true, e.memory instanceof WebAssembly.Memory)
|
|
109
|
-
t.check('memory.buffer.byteLength', 65536, e.memory.buffer.byteLength)
|
|
110
|
-
|
|
111
|
-
t.section('standalone Memory + TypedArray')
|
|
112
|
-
mem = new WebAssembly.Memory({ initial: 1 })
|
|
113
|
-
var arr = new Int32Array(mem.buffer)
|
|
114
|
-
arr[0] = 42; arr[1] = 7
|
|
115
|
-
t.check('Int32Array[0]', 42, arr[0])
|
|
116
|
-
t.check('Int32Array[1]', 7, arr[1])
|
|
117
|
-
|
|
118
|
-
t.section('buffer identity')
|
|
119
|
-
arr[2] = 100
|
|
120
|
-
t.check('old view[2]', 100, arr[2])
|
|
121
|
-
t.check('new view[2]', 100, new Int32Array(mem.buffer)[2])
|
|
122
|
-
t.check('buffer is same object', true, mem.buffer === mem.buffer)
|
|
123
|
-
}
|
|
124
|
-
}
|
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
import * as sock from 'sock';
|
|
2
|
-
import * as wolfssl from 'wolfssl';
|
|
3
|
-
import * as os from 'os';
|
|
4
|
-
import * as std from 'std';
|
|
5
|
-
const HTTPS_PORT = 18924;
|
|
6
|
-
const WANT_READ = 2;
|
|
7
|
-
const WANT_WRITE = 3;
|
|
8
|
-
const ZERO_RETURN = 6;
|
|
9
|
-
export const suite = {
|
|
10
|
-
name: 'net-wolfssl-read',
|
|
11
|
-
run: async (t) => {
|
|
12
|
-
function assert(name, ok) {
|
|
13
|
-
if (ok) {
|
|
14
|
-
t.ok++;
|
|
15
|
-
std.printf(' PASS: %s\n', name);
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
t.fail++;
|
|
19
|
-
std.printf(' FAIL: %s\n', name);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
// ── wolfSSL_read return contract: raw int, data lands in the
|
|
23
|
-
// caller-owned buffer (thin wrapper — errors stay numbers) ──
|
|
24
|
-
t.section('wolfSSL_read contract (HTTPS /large/65536)');
|
|
25
|
-
await new Promise((resolve) => {
|
|
26
|
-
const s = sock.socket();
|
|
27
|
-
if (s === null || s < 0) {
|
|
28
|
-
assert('socket() ok', false);
|
|
29
|
-
resolve();
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
let ssl = null;
|
|
33
|
-
let ctx = null;
|
|
34
|
-
let connected = false;
|
|
35
|
-
let handshakeDone = false;
|
|
36
|
-
let sentRequest = false;
|
|
37
|
-
let total = 0;
|
|
38
|
-
const EXPECTED = 65536;
|
|
39
|
-
let sawNonNumber = false;
|
|
40
|
-
let sawEof = false;
|
|
41
|
-
let errOk = true;
|
|
42
|
-
let done = false;
|
|
43
|
-
const finish = () => {
|
|
44
|
-
if (done)
|
|
45
|
-
return;
|
|
46
|
-
done = true;
|
|
47
|
-
os.clearTimeout(timeoutId);
|
|
48
|
-
assert('connected', connected);
|
|
49
|
-
assert('handshake ok', handshakeDone);
|
|
50
|
-
assert('request sent', sentRequest);
|
|
51
|
-
assert('received full body', total >= EXPECTED);
|
|
52
|
-
assert('wolfSSL_read always returned number', !sawNonNumber);
|
|
53
|
-
assert('no-data/EOF observed via int (0 or ZERO_RETURN)', sawEof);
|
|
54
|
-
assert('n<=0 get_error in {WANT_READ,WANT_WRITE,ZERO_RETURN}', errOk);
|
|
55
|
-
if (ssl) {
|
|
56
|
-
wolfssl.wolfSSL_free(ssl);
|
|
57
|
-
ssl = null;
|
|
58
|
-
}
|
|
59
|
-
if (ctx) {
|
|
60
|
-
wolfssl.wolfSSL_CTX_free(ctx);
|
|
61
|
-
ctx = null;
|
|
62
|
-
}
|
|
63
|
-
sock.closesocket(s);
|
|
64
|
-
resolve();
|
|
65
|
-
};
|
|
66
|
-
const timeoutId = os.setTimeout(() => {
|
|
67
|
-
assert('wolfSSL_read contract timeout (15s)', false);
|
|
68
|
-
finish();
|
|
69
|
-
}, 15000);
|
|
70
|
-
const sendReq = () => {
|
|
71
|
-
const req = 'GET /large/65536 HTTP/1.1\r\nHost: localhost\r\nConnection: close\r\n\r\n';
|
|
72
|
-
const buf = new ArrayBuffer(req.length);
|
|
73
|
-
const v = new Uint8Array(buf);
|
|
74
|
-
for (let i = 0; i < req.length; i++)
|
|
75
|
-
v[i] = req.charCodeAt(i);
|
|
76
|
-
wolfssl.wolfSSL_write(ssl, buf);
|
|
77
|
-
sentRequest = true;
|
|
78
|
-
};
|
|
79
|
-
const onReadable = () => {
|
|
80
|
-
// Drain until EOF (n===0 / ZERO_RETURN) or WANT_* hands back
|
|
81
|
-
// to the event loop.
|
|
82
|
-
for (let guard = 0; guard < 10000; guard++) {
|
|
83
|
-
const buf = new ArrayBuffer(8192);
|
|
84
|
-
const n = wolfssl.wolfSSL_read(ssl, buf);
|
|
85
|
-
if (typeof n !== 'number') {
|
|
86
|
-
sawNonNumber = true;
|
|
87
|
-
std.printf(' FAIL got non-number %s (want int)\n', String(n));
|
|
88
|
-
finish();
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
if (n > 0) {
|
|
92
|
-
total += n;
|
|
93
|
-
// Keep draining after the body is complete: the point of
|
|
94
|
-
// this suite is the no-data/EOF contract, so a full body
|
|
95
|
-
// must not short-circuit the read that would observe it.
|
|
96
|
-
continue;
|
|
97
|
-
}
|
|
98
|
-
const err = wolfssl.wolfSSL_get_error(ssl, n);
|
|
99
|
-
if (err !== WANT_READ && err !== WANT_WRITE && err !== ZERO_RETURN) {
|
|
100
|
-
errOk = false;
|
|
101
|
-
std.printf(' n=%d get_error=%d outside {WANT_READ,WANT_WRITE,ZERO_RETURN}\n', n, err);
|
|
102
|
-
finish();
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
if (n === 0 || err === ZERO_RETURN) {
|
|
106
|
-
sawEof = true;
|
|
107
|
-
break;
|
|
108
|
-
}
|
|
109
|
-
// WANT_*: wait for next FD_READ/WRITE
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
if (sawEof)
|
|
113
|
-
finish();
|
|
114
|
-
};
|
|
115
|
-
sock.set_on_event(s, (event) => {
|
|
116
|
-
if (done)
|
|
117
|
-
return;
|
|
118
|
-
if (event.lNetworkEvents & 16 /* FdEvent.FD_CONNECT */) {
|
|
119
|
-
if (event.iErrorCode[0] !== 0) {
|
|
120
|
-
assert('connect error code 0', false);
|
|
121
|
-
finish();
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
connected = true;
|
|
125
|
-
const method = wolfssl.wolfTLSv1_2_client_method();
|
|
126
|
-
ctx = wolfssl.wolfSSL_CTX_new(method);
|
|
127
|
-
if (!ctx) {
|
|
128
|
-
assert('CTX_new', false);
|
|
129
|
-
finish();
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
wolfssl.wolfSSL_CTX_set_verify(ctx, 0 /* VerifyMode.SSL_VERIFY_NONE */);
|
|
133
|
-
ssl = wolfssl.wolfSSL_new(ctx);
|
|
134
|
-
if (!ssl) {
|
|
135
|
-
assert('SSL_new', false);
|
|
136
|
-
finish();
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
wolfssl.wolfSSL_set_fd(ssl, sock.get_fd(s));
|
|
140
|
-
wolfssl.wolfSSL_UseSNI(ssl, 0 /* SniType.WOLFSSL_SNI_HOST_NAME */, 'localhost');
|
|
141
|
-
// kick handshake immediately (FD_WRITE may not re-fire)
|
|
142
|
-
{
|
|
143
|
-
const ret = wolfssl.wolfSSL_connect(ssl);
|
|
144
|
-
if (ret === 1 /* ReturnCode.SSL_SUCCESS */) {
|
|
145
|
-
handshakeDone = true;
|
|
146
|
-
sendReq();
|
|
147
|
-
}
|
|
148
|
-
else {
|
|
149
|
-
const err = wolfssl.wolfSSL_get_error(ssl, ret);
|
|
150
|
-
if (err !== WANT_READ && err !== WANT_WRITE) {
|
|
151
|
-
assert('TLS handshake failed err=' + err, false);
|
|
152
|
-
finish();
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
if ((event.lNetworkEvents & 1 /* FdEvent.FD_READ */) ||
|
|
158
|
-
(event.lNetworkEvents & 2 /* FdEvent.FD_WRITE */)) {
|
|
159
|
-
if (!ssl)
|
|
160
|
-
return;
|
|
161
|
-
if (!handshakeDone) {
|
|
162
|
-
const ret = wolfssl.wolfSSL_connect(ssl);
|
|
163
|
-
if (ret === 1 /* ReturnCode.SSL_SUCCESS */) {
|
|
164
|
-
handshakeDone = true;
|
|
165
|
-
sendReq();
|
|
166
|
-
}
|
|
167
|
-
else {
|
|
168
|
-
const err = wolfssl.wolfSSL_get_error(ssl, ret);
|
|
169
|
-
if (err !== WANT_READ && err !== WANT_WRITE) {
|
|
170
|
-
assert('TLS handshake failed err=' + err, false);
|
|
171
|
-
finish();
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
if (sentRequest)
|
|
177
|
-
onReadable();
|
|
178
|
-
}
|
|
179
|
-
if (event.lNetworkEvents & 32 /* FdEvent.FD_CLOSE */) {
|
|
180
|
-
// drain remaining then finish
|
|
181
|
-
if (ssl && sentRequest && !sawNonNumber) {
|
|
182
|
-
onReadable();
|
|
183
|
-
}
|
|
184
|
-
if (!sawNonNumber) {
|
|
185
|
-
// Server close without an observed EOF read is an edge —
|
|
186
|
-
// don't fail if the body already completed.
|
|
187
|
-
if (!sawEof && total < EXPECTED && total > 0) {
|
|
188
|
-
sawEof = true;
|
|
189
|
-
}
|
|
190
|
-
if (total >= EXPECTED || sawEof)
|
|
191
|
-
finish();
|
|
192
|
-
else {
|
|
193
|
-
assert('data before close', false);
|
|
194
|
-
if (!done)
|
|
195
|
-
finish();
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
});
|
|
200
|
-
sock.connect(s, '127.0.0.1', HTTPS_PORT);
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
};
|