quickwin 3.0.1 → 3.0.2

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.
Files changed (163) hide show
  1. package/README.en.md +3 -0
  2. package/README.md +2 -0
  3. package/package.json +1 -3
  4. package/qwin-nowasm-x86.exe +0 -0
  5. package/qwin-nowasm.exe +0 -0
  6. package/qwin-x86.exe +0 -0
  7. package/qwin.exe +0 -0
  8. package/examples/PdfCanvas.js +0 -38
  9. package/examples/PdfCanvas.tsx +0 -54
  10. package/examples/execd/main.js +0 -23379
  11. package/examples/execd/tray.js +0 -192
  12. package/examples/execd/worker.js +0 -122
  13. package/examples/pdf_preview2.js +0 -398
  14. package/examples/pdf_preview2.ts +0 -353
  15. package/examples/pdf_viewer.js +0 -22515
  16. package/examples/pdf_viewer.tsx +0 -228
  17. package/examples/test_gallery.js +0 -18692
  18. package/examples/test_gallery.tsx +0 -291
  19. package/examples/test_react_lazy.js +0 -18560
  20. package/examples/test_react_lazy.tsx +0 -65
  21. package/examples/test_react_listbox.js +0 -18562
  22. package/examples/test_react_listbox.tsx +0 -73
  23. package/examples/test_root_window.js +0 -18532
  24. package/examples/test_root_window.tsx +0 -41
  25. package/examples/test_tab.js +0 -18563
  26. package/examples/test_tab.tsx +0 -77
  27. package/examples/tray_demo.js +0 -86
  28. package/examples/tray_demo.tsx +0 -89
  29. package/test/add.wasm +0 -0
  30. package/test/bench_ffi_callraw.js +0 -235
  31. package/test/bench_ffi_callraw.ts +0 -235
  32. package/test/bench_ffi_overhead.js +0 -139
  33. package/test/bench_ffi_overhead.ts +0 -141
  34. package/test/bench_sendmessage.js +0 -104
  35. package/test/bench_sendmessage.ts +0 -100
  36. package/test/bench_sendmessage_nonnull.js +0 -187
  37. package/test/bench_sendmessage_nonnull.ts +0 -188
  38. package/test/complex.wasm +0 -0
  39. package/test/complex_imports.wasm +0 -0
  40. package/test/debug/http_server_e2e.js +0 -31
  41. package/test/debug/minwasm.js +0 -52
  42. package/test/debug/mupdf_debug.js +0 -86
  43. package/test/debug/wasm.js +0 -122
  44. package/test/debug/wasm_export_debug.js +0 -54
  45. package/test/debug/wasm_names.js +0 -36
  46. package/test/example.pdf +0 -0
  47. package/test/global_imports.wasm +0 -0
  48. package/test/import_func.wasm +0 -0
  49. package/test/imports.wasm +0 -0
  50. package/test/mupdf-cdn.js +0 -40
  51. package/test/mupdf-cdn.ts +0 -43
  52. package/test/run.js +0 -111
  53. package/test/run.ts +0 -116
  54. package/test/sjlj.wasm +0 -0
  55. package/test/test_basic.js +0 -7
  56. package/test/test_basic.ts +0 -9
  57. package/test/test_basic_fetch.js +0 -63
  58. package/test/test_basic_fetch.ts +0 -59
  59. package/test/test_brotli.js +0 -48
  60. package/test/test_brotli.ts +0 -52
  61. package/test/test_fetch_cache.js +0 -169
  62. package/test/test_fetch_cache.ts +0 -187
  63. package/test/test_ffi.js +0 -157
  64. package/test/test_ffi.ts +0 -170
  65. package/test/test_ffi_abi.js +0 -290
  66. package/test/test_ffi_abi.ts +0 -274
  67. package/test/test_ffi_array.js +0 -116
  68. package/test/test_ffi_array.ts +0 -141
  69. package/test/test_ffi_bind.js +0 -656
  70. package/test/test_ffi_bind.ts +0 -670
  71. package/test/test_ffi_struct.js +0 -779
  72. package/test/test_ffi_struct.ts +0 -828
  73. package/test/test_ffi_struct_layout.js +0 -495
  74. package/test/test_ffi_struct_layout.ts +0 -543
  75. package/test/test_ffi_user32.js +0 -103
  76. package/test/test_ffi_user32.ts +0 -113
  77. package/test/test_ffi_windows.js +0 -172
  78. package/test/test_ffi_windows.ts +0 -187
  79. package/test/test_files.js +0 -102
  80. package/test/test_files.ts +0 -121
  81. package/test/test_frame_encoding.js +0 -128
  82. package/test/test_frame_encoding.ts +0 -132
  83. package/test/test_gdi_draw.js +0 -681
  84. package/test/test_gdi_draw.ts +0 -725
  85. package/test/test_helper.js +0 -91
  86. package/test/test_helper.ts +0 -88
  87. package/test/test_http_import.js +0 -96
  88. package/test/test_http_import.ts +0 -93
  89. package/test/test_http_server.js +0 -214
  90. package/test/test_http_server.ts +0 -211
  91. package/test/test_import_dir.js +0 -4
  92. package/test/test_import_dir.ts +0 -5
  93. package/test/test_ipv6.js +0 -134
  94. package/test/test_ipv6.ts +0 -130
  95. package/test/test_jsx.js +0 -1314
  96. package/test/test_meta_url.js +0 -3
  97. package/test/test_meta_url.ts +0 -4
  98. package/test/test_mupdf_render.js +0 -51
  99. package/test/test_mupdf_render.ts +0 -55
  100. package/test/test_mupdf_twice.js +0 -62
  101. package/test/test_mupdf_twice.ts +0 -65
  102. package/test/test_mupdf_wasm.js +0 -39
  103. package/test/test_mupdf_wasm.ts +0 -32
  104. package/test/test_net_event.js +0 -57
  105. package/test/test_net_event.ts +0 -56
  106. package/test/test_net_fetch.js +0 -384
  107. package/test/test_net_fetch.ts +0 -373
  108. package/test/test_net_websocket.js +0 -180
  109. package/test/test_net_websocket.ts +0 -164
  110. package/test/test_polyfill.js +0 -144
  111. package/test/test_polyfill.ts +0 -159
  112. package/test/test_printer.js +0 -137
  113. package/test/test_printer.ts +0 -148
  114. package/test/test_proc.js +0 -141
  115. package/test/test_proc.ts +0 -163
  116. package/test/test_react_complex.js +0 -18678
  117. package/test/test_react_counter.js +0 -18555
  118. package/test/test_react_flex.js +0 -18871
  119. package/test/test_react_hidden.js +0 -18560
  120. package/test/test_react_listview_link.js +0 -18590
  121. package/test/test_react_notify.js +0 -18797
  122. package/test/test_react_render.js +0 -18550
  123. package/test/test_registry.js +0 -74
  124. package/test/test_registry.ts +0 -95
  125. package/test/test_sysinfo.js +0 -122
  126. package/test/test_sysinfo.ts +0 -141
  127. package/test/test_url.js +0 -173
  128. package/test/test_url.ts +0 -183
  129. package/test/test_wasm_basic.js +0 -85
  130. package/test/test_wasm_basic.ts +0 -73
  131. package/test/test_wasm_import_global.js +0 -41
  132. package/test/test_wasm_import_global.ts +0 -45
  133. package/test/test_wasm_sjlj.js +0 -145
  134. package/test/test_wasm_sjlj.ts +0 -125
  135. package/test/test_wasm_types.js +0 -97
  136. package/test/test_wasm_types.ts +0 -124
  137. package/test/test_wolfssl_read.js +0 -203
  138. package/test/test_wolfssl_read.ts +0 -184
  139. package/test/test_worker.js +0 -21
  140. package/test/test_worker.ts +0 -24
  141. package/test/test_worker_concurrent.js +0 -45
  142. package/test/test_worker_concurrent.ts +0 -56
  143. package/test/test_worker_data_url.js +0 -46
  144. package/test/test_worker_data_url.ts +0 -51
  145. package/test/test_worker_fetch.js +0 -26
  146. package/test/test_worker_fetch.ts +0 -27
  147. package/test/test_worker_net.js +0 -69
  148. package/test/test_worker_net.ts +0 -66
  149. package/test/test_worker_wasm_concurrent.js +0 -44
  150. package/test/test_worker_wasm_concurrent.ts +0 -45
  151. package/test/types.wasm +0 -0
  152. package/test/worker_fetch.js +0 -13
  153. package/test/worker_fetch.ts +0 -13
  154. package/test/worker_helper.js +0 -1
  155. package/test/worker_helper.ts +0 -1
  156. package/test/worker_http.js +0 -18
  157. package/test/worker_http.ts +0 -20
  158. package/test/worker_import_lib.js +0 -12
  159. package/test/worker_import_lib.ts +0 -13
  160. package/test/worker_module.js +0 -16
  161. package/test/worker_module.ts +0 -17
  162. package/test/worker_wasm_concurrent.js +0 -22
  163. package/test/worker_wasm_concurrent.ts +0 -22
package/test/test_url.ts DELETED
@@ -1,183 +0,0 @@
1
- import { Tester } from './test_helper.js'
2
- import '../lib/url.js'
3
-
4
- export const suite = {
5
- name: 'url',
6
- run: (t: Tester) => {
7
- t.section('http parse')
8
- const u = new URL('http://example.com')
9
- t.check('href', 'http://example.com/', u.href)
10
- t.check('protocol', 'http:', u.protocol)
11
- t.check('hostname', 'example.com', u.hostname)
12
- t.check('port', '', u.port)
13
- t.check('pathname', '/', u.pathname)
14
- t.check('host', 'example.com', u.host)
15
- t.check('origin', 'http://example.com', u.origin)
16
-
17
- t.section('full http')
18
- const u2 = new URL('https://user:pass@host.com:443/path/to?q=1&r=2#frag')
19
- t.check('protocol', 'https:', u2.protocol)
20
- t.check('username', 'user', u2.username)
21
- t.check('password', 'pass', u2.password)
22
- t.check('hostname', 'host.com', u2.hostname)
23
- t.check('port', '443', u2.port)
24
- t.check('pathname', '/path/to', u2.pathname)
25
- t.check('search', '?q=1&r=2', u2.search)
26
- t.check('hash', '#frag', u2.hash)
27
- t.check('host', 'host.com:443', u2.host)
28
-
29
- t.section('query string params')
30
- t.check('get q', '1', u2.searchParams.get('q'))
31
- t.check('get r', '2', u2.searchParams.get('r'))
32
- t.check('has q', true, u2.searchParams.has('q'))
33
- t.check('has x', false, u2.searchParams.has('x'))
34
-
35
- t.section('relative resolution')
36
- const b = new URL('./add.wasm', 'http://example.com/base/')
37
- t.check('relative path', 'http://example.com/base/add.wasm', b.href)
38
- const b2 = new URL('../other', 'http://example.com/base/')
39
- t.check('up one dir', 'http://example.com/other', b2.href)
40
- const b3 = new URL('/abs', 'http://example.com/base/')
41
- t.check('absolute path', 'http://example.com/abs', b3.href)
42
- const b4 = new URL('//other.com:8080/path', 'http://example.com/base/')
43
- t.check('protocol-relative', 'http://other.com:8080/path', b4.href)
44
-
45
- t.section('file URL')
46
- const f = new URL('file:///C:/Users/test/file.js')
47
- t.check('protocol', 'file:', f.protocol)
48
- t.check('hostname', '', f.hostname)
49
- t.check('pathname', '/C:/Users/test/file.js', f.pathname)
50
-
51
- t.section('file relative resolution')
52
- const f2 = new URL('./add.wasm', 'file:///C:/Users/test/helper.js')
53
- t.check('file relative', 'file:///C:/Users/test/add.wasm', f2.href)
54
- const f3 = new URL('../other.wasm', 'file:///C:/Users/test/sub/helper.js')
55
- t.check('file up dir', 'file:///C:/Users/test/other.wasm', f3.href)
56
-
57
- t.section('URLSearchParams')
58
- const p = new URLSearchParams('a=1&b=2&a=3')
59
- t.check('get a', '1', p.get('a'))
60
- t.check('getAll a', 2, p.getAll('a').length)
61
- t.check('get b', '2', p.get('b'))
62
- t.check('has c', false, p.has('c'))
63
- t.check('size', 3, p.size)
64
-
65
- t.section('URLSearchParams set/append/delete')
66
- const p2 = new URLSearchParams()
67
- p2.append('key', 'val1')
68
- p2.append('key', 'val2')
69
- t.check('append 2', 2, p2.getAll('key').length)
70
- p2.set('key', 'new')
71
- t.check('set replaces', 1, p2.getAll('key').length)
72
- t.check('set value', 'new', p2.get('key'))
73
- p2.append('x', 'y')
74
- p2.delete('x')
75
- t.check('delete', false, p2.has('x'))
76
-
77
- t.section('URLSearchParams toString')
78
- const p3 = new URLSearchParams('q=hello&r=world')
79
- t.check('toString', 'q=hello&r=world', p3.toString())
80
-
81
- t.section('URLSearchParams iterator')
82
- const p4 = new URLSearchParams('a=1&b=2')
83
- const keys: string[] = []
84
- for (const k of p4.keys()) keys.push(k)
85
- t.check('keys', 'a,b', keys.join(','))
86
-
87
- t.section('URL toJSON')
88
- const j = new URL('http://example.com/path')
89
- t.check('toJSON', 'http://example.com/path', j.toJSON())
90
-
91
- t.section('URL toString')
92
- t.check('toString', 'http://example.com/path', j.toString())
93
-
94
- t.section('IPv6')
95
- const v6 = new URL('http://[::1]:8080/path')
96
- t.check('hostname', '::1', v6.hostname)
97
- t.check('port', '8080', v6.port)
98
- t.check('host', '[::1]:8080', v6.host)
99
- t.check('pathname', '/path', v6.pathname)
100
- const v6b = new URL('http://[2001:db8::1]/')
101
- t.check('IPv6 no port', '2001:db8::1', v6b.hostname)
102
- t.check('IPv6 host', '[2001:db8::1]', v6b.host)
103
- const v6c = new URL('http://[::1]:8080')
104
- t.check('IPv6 origin', 'http://[::1]:8080', v6c.origin)
105
-
106
- t.section('ws/wss')
107
- const ws = new URL('ws://example.com/socket')
108
- t.check('ws protocol', 'ws:', ws.protocol)
109
- t.check('ws hostname', 'example.com', ws.hostname)
110
- t.check('ws pathname', '/socket', ws.pathname)
111
- const wss = new URL('wss://secure.com:9090/chat')
112
- t.check('wss port', '9090', wss.port)
113
-
114
- t.section('relative fragment/query')
115
- const rf = new URL('#top', 'http://example.com/path')
116
- t.check('fragment-only', 'http://example.com/path#top', rf.href)
117
- const rq = new URL('?q=1', 'http://example.com/path')
118
- t.check('query-only', 'http://example.com/path?q=1', rq.href)
119
- const rqf = new URL('?a=1#hash', 'http://example.com/path')
120
- t.check('query+frag', 'http://example.com/path?a=1#hash', rqf.href)
121
-
122
- t.section('path normalization')
123
- const np1 = new URL('a/../../other', 'http://example.com/base/')
124
- t.check('multi up', 'http://example.com/other', np1.href)
125
- const np2 = new URL('/../other', 'http://example.com/base/')
126
- t.check('root up', 'http://example.com/other', np2.href)
127
- const np3 = new URL('.', 'http://example.com/base/')
128
- t.check('dot only', 'http://example.com/base', np3.href)
129
- const np4 = new URL('', 'http://example.com/base/')
130
- t.check('empty relative', 'http://example.com/base/', np4.href)
131
-
132
- t.section('IP address')
133
- const ip = new URL('http://127.0.0.1:8080/path')
134
- t.check('ip hostname', '127.0.0.1', ip.hostname)
135
- t.check('ip port', '8080', ip.port)
136
-
137
- t.section('URLSearchParams values/entries/forEach')
138
- const pv = new URLSearchParams('a=1&b=2')
139
- const vals: string[] = []
140
- for (const v of pv.values()) vals.push(v)
141
- t.check('values', '1,2', vals.join(','))
142
- const entries: string[] = []
143
- for (const [k, v] of pv.entries()) entries.push(k + '=' + v)
144
- t.check('entries', 'a=1,b=2', entries.join(','))
145
- let forEachStr = ''
146
- pv.forEach((v, k) => { forEachStr += k + '=' + v + '|' })
147
- t.check('forEach', 'a=1|b=2|', forEachStr)
148
- const ps = new URLSearchParams('b=2&a=1&c=3')
149
- ps.sort()
150
- t.check('sort', 'a=1&b=2&c=3', ps.toString())
151
-
152
- t.section('URLSearchParams edge cases')
153
- const pe1 = new URLSearchParams('a=1&b')
154
- t.check('empty value', '', pe1.get('b'))
155
- const pe2 = new URLSearchParams('?a=1&b=2')
156
- t.check('leading ?', '1', pe2.get('a'))
157
- const pe3 = new URLSearchParams([['x', '10'], ['y', '20']] as any)
158
- t.check('array init', '10', pe3.get('x'))
159
- t.check('array init 2', '20', pe3.get('y'))
160
- t.check('array size', 2, pe3.size)
161
-
162
- t.section('encoded chars')
163
- const enc = new URL('http://example.com/hello%20world')
164
- t.check('encoded pathname', '/hello%20world', enc.pathname)
165
- const encq = new URL('http://example.com/path?q=a+b&r=%25')
166
- t.check('encoded query +→space', 'a b', encq.searchParams.get('q'))
167
- t.check('encoded query %25', '%', encq.searchParams.get('r'))
168
-
169
- t.section('null/undefined base')
170
- let threw = false
171
- try { new URL('/path', null as any) } catch { threw = true }
172
- t.check('null base throws', true, threw)
173
- threw = false
174
- try { new URL('relative') } catch { threw = true }
175
- t.check('no base throws', true, threw)
176
-
177
- t.section('data URL')
178
- const d = new URL('data:text/plain,hello')
179
- t.check('data protocol', 'data:', d.protocol)
180
- t.check('data hostname', '', d.hostname)
181
- t.check('data pathname', 'text/plain,hello', d.pathname)
182
- }
183
- }
@@ -1,85 +0,0 @@
1
- import { readWasmFile } from './test_helper.js';
2
- export const suite = {
3
- name: 'wasm-basic',
4
- run: (t) => {
5
- t.section('validate');
6
- t.check('empty buffer', false, WebAssembly.validate(new Uint8Array([]).buffer));
7
- t.check('invalid bytes', false, WebAssembly.validate(new Uint8Array([1, 2, 3]).buffer));
8
- const wasmBuf = readWasmFile('./add.wasm');
9
- if (!wasmBuf) {
10
- t.fail++;
11
- return;
12
- }
13
- t.check('valid add.wasm', true, WebAssembly.validate(wasmBuf));
14
- t.section('Module');
15
- var mod = null;
16
- try {
17
- mod = new WebAssembly.Module(wasmBuf);
18
- t.check('Module constructor', true, mod instanceof WebAssembly.Module);
19
- }
20
- catch (e) {
21
- t.fail++;
22
- }
23
- t.section('Module.exports');
24
- if (mod) {
25
- try {
26
- const exps = WebAssembly.Module.exports(mod);
27
- t.check('exports count', 1, exps.length);
28
- t.check('export name', 'add', exps[0].name);
29
- t.check('export kind', 'function', exps[0].kind);
30
- }
31
- catch (e) {
32
- t.fail++;
33
- }
34
- }
35
- t.section('Instance (add.wasm)');
36
- if (mod) {
37
- try {
38
- const inst = new WebAssembly.Instance(mod);
39
- const iExp = inst.exports;
40
- t.check('Instance created', true, inst instanceof WebAssembly.Instance);
41
- t.check('add(1, 2)', 3, iExp.add(1, 2));
42
- t.check('add(10, 20)', 30, iExp.add(10, 20));
43
- t.check('add(-5, 3)', -2, iExp.add(-5, 3));
44
- }
45
- catch (e) {
46
- t.fail++;
47
- }
48
- }
49
- t.section('complex.wasm');
50
- const complexBuf = readWasmFile('./complex.wasm');
51
- if (complexBuf) {
52
- try {
53
- const cmod = new WebAssembly.Module(complexBuf);
54
- const cinst = new WebAssembly.Instance(cmod);
55
- const cExp = cinst.exports;
56
- t.check('add(3, 4)', 7, cExp.add(3, 4));
57
- t.check('sub(10, 3)', 7, cExp.sub(10, 3));
58
- t.check('mul(6, 7)', 42, cExp.mul(6, 7));
59
- t.check('factorial(0)', 1, cExp.factorial(0));
60
- t.check('factorial(5)', 120, cExp.factorial(5));
61
- t.check('factorial(10)', 3628800, cExp.factorial(10));
62
- }
63
- catch (e) {
64
- t.fail++;
65
- }
66
- }
67
- t.section('import function');
68
- const importFuncBuf = readWasmFile('./import_func.wasm');
69
- if (importFuncBuf) {
70
- try {
71
- const ifmod = new WebAssembly.Module(importFuncBuf);
72
- const ifinst = new WebAssembly.Instance(ifmod, {
73
- env: { imported_add: (a, b) => a + b }
74
- });
75
- const ifExp = ifinst.exports;
76
- t.check('add_via_import(3, 4)', 7, ifExp.add_via_import(3, 4));
77
- t.check('add_via_import(10, 20)', 30, ifExp.add_via_import(10, 20));
78
- t.check('add_via_import(-5, 3)', -2, ifExp.add_via_import(-5, 3));
79
- }
80
- catch (e) {
81
- t.fail++;
82
- }
83
- }
84
- }
85
- };
@@ -1,73 +0,0 @@
1
- import { Tester, readWasmFile } from './test_helper.js'
2
-
3
- export const suite = {
4
- name: 'wasm-basic',
5
- run: (t: Tester) => {
6
- t.section('validate')
7
- t.check('empty buffer', false, WebAssembly.validate(new Uint8Array([]).buffer))
8
- t.check('invalid bytes', false, WebAssembly.validate(new Uint8Array([1, 2, 3]).buffer))
9
- const wasmBuf = readWasmFile('./add.wasm')
10
- if (!wasmBuf) { t.fail++; return }
11
- t.check('valid add.wasm', true, WebAssembly.validate(wasmBuf))
12
-
13
- t.section('Module')
14
- var mod: WebAssembly.Module | null = null
15
- try {
16
- mod = new WebAssembly.Module(wasmBuf)
17
- t.check('Module constructor', true, mod instanceof WebAssembly.Module)
18
- } catch (e) { t.fail++ }
19
-
20
- t.section('Module.exports')
21
- if (mod) {
22
- try {
23
- const exps = WebAssembly.Module.exports(mod)
24
- t.check('exports count', 1, exps.length)
25
- t.check('export name', 'add', exps[0]!.name)
26
- t.check('export kind', 'function', exps[0]!.kind)
27
- } catch (e) { t.fail++ }
28
- }
29
-
30
- t.section('Instance (add.wasm)')
31
- if (mod) {
32
- try {
33
- const inst = new WebAssembly.Instance<{ add: (a: number, b: number) => number }>(mod)
34
- const iExp = inst.exports
35
- t.check('Instance created', true, inst instanceof WebAssembly.Instance)
36
- t.check('add(1, 2)', 3, iExp.add(1, 2))
37
- t.check('add(10, 20)', 30, iExp.add(10, 20))
38
- t.check('add(-5, 3)', -2, iExp.add(-5, 3))
39
- } catch (e) { t.fail++ }
40
- }
41
-
42
- t.section('complex.wasm')
43
- const complexBuf = readWasmFile('./complex.wasm')
44
- if (complexBuf) {
45
- try {
46
- const cmod = new WebAssembly.Module(complexBuf)
47
- const cinst = new WebAssembly.Instance<{ add: (a: number, b: number) => number; sub: (a: number, b: number) => number; mul: (a: number, b: number) => number; factorial: (n: number) => number }>(cmod)
48
- const cExp = cinst.exports
49
- t.check('add(3, 4)', 7, cExp.add(3, 4))
50
- t.check('sub(10, 3)', 7, cExp.sub(10, 3))
51
- t.check('mul(6, 7)', 42, cExp.mul(6, 7))
52
- t.check('factorial(0)', 1, cExp.factorial(0))
53
- t.check('factorial(5)', 120, cExp.factorial(5))
54
- t.check('factorial(10)', 3628800, cExp.factorial(10))
55
- } catch (e) { t.fail++ }
56
- }
57
-
58
- t.section('import function')
59
- const importFuncBuf = readWasmFile('./import_func.wasm')
60
- if (importFuncBuf) {
61
- try {
62
- const ifmod = new WebAssembly.Module(importFuncBuf)
63
- const ifinst = new WebAssembly.Instance<{ add_via_import: (a: number, b: number) => number }>(ifmod, {
64
- env: { imported_add: (a: number, b: number) => a + b }
65
- })
66
- const ifExp = ifinst.exports
67
- t.check('add_via_import(3, 4)', 7, ifExp.add_via_import(3, 4))
68
- t.check('add_via_import(10, 20)', 30, ifExp.add_via_import(10, 20))
69
- t.check('add_via_import(-5, 3)', -2, ifExp.add_via_import(-5, 3))
70
- } catch (e) { t.fail++ }
71
- }
72
- }
73
- }
@@ -1,41 +0,0 @@
1
- import { readWasmFile } from './test_helper.js';
2
- export const suite = {
3
- name: 'wasm-import-global',
4
- run: (t) => {
5
- const giBuf = readWasmFile('./global_imports.wasm');
6
- if (!giBuf) {
7
- t.fail++;
8
- return;
9
- }
10
- const giMod = new WebAssembly.Module(giBuf);
11
- t.section('import globals');
12
- var giInst;
13
- try {
14
- giInst = new WebAssembly.Instance(giMod, {
15
- env: {
16
- offset: new WebAssembly.Global({ value: 'i32', mutable: false }, 42),
17
- factor: new WebAssembly.Global({ value: 'f64', mutable: false }, 3.14),
18
- log: function (_x) { }
19
- }
20
- });
21
- }
22
- catch (e) {
23
- t.fail++;
24
- return;
25
- }
26
- t.check('get_offset()', 42, giInst.exports.get_offset());
27
- t.check('compute(10)', 31.4, giInst.exports.compute(10));
28
- t.check('run(8)', 50, giInst.exports.run(8));
29
- t.section('second instance');
30
- var giInst2 = new WebAssembly.Instance(giMod, {
31
- env: {
32
- offset: new WebAssembly.Global({ value: 'i32', mutable: false }, 100),
33
- factor: new WebAssembly.Global({ value: 'f64', mutable: false }, 2.0),
34
- log: function (_x) { }
35
- }
36
- });
37
- t.check('instance2 get_offset()', 100, giInst2.exports.get_offset());
38
- t.check('instance2 compute(5)', 10, giInst2.exports.compute(5));
39
- t.check('instance1 still get_offset()', 42, giInst.exports.get_offset());
40
- }
41
- };
@@ -1,45 +0,0 @@
1
- import { Tester, readWasmFile } from './test_helper.js'
2
-
3
- type GlobalImportsExports = {
4
- get_offset: () => number
5
- compute: (x: number) => number
6
- run: (x: number) => number
7
- }
8
-
9
- export const suite = {
10
- name: 'wasm-import-global',
11
- run: (t: Tester) => {
12
- const giBuf = readWasmFile('./global_imports.wasm')
13
- if (!giBuf) { t.fail++; return }
14
- const giMod = new WebAssembly.Module(giBuf)
15
-
16
- t.section('import globals')
17
- var giInst: WebAssembly.Instance<GlobalImportsExports>
18
- try {
19
- giInst = new WebAssembly.Instance<GlobalImportsExports>(giMod, {
20
- env: {
21
- offset: new WebAssembly.Global({ value: 'i32', mutable: false }, 42),
22
- factor: new WebAssembly.Global({ value: 'f64', mutable: false }, 3.14),
23
- log: function (_x: number) { /* noop */ }
24
- }
25
- })
26
- } catch (e) {
27
- t.fail++; return
28
- }
29
- t.check('get_offset()', 42, giInst.exports.get_offset())
30
- t.check('compute(10)', 31.4, giInst.exports.compute(10))
31
- t.check('run(8)', 50, giInst.exports.run(8))
32
-
33
- t.section('second instance')
34
- var giInst2 = new WebAssembly.Instance<GlobalImportsExports>(giMod, {
35
- env: {
36
- offset: new WebAssembly.Global({ value: 'i32', mutable: false }, 100),
37
- factor: new WebAssembly.Global({ value: 'f64', mutable: false }, 2.0),
38
- log: function (_x: number) { /* noop */ }
39
- }
40
- })
41
- t.check('instance2 get_offset()', 100, giInst2.exports.get_offset())
42
- t.check('instance2 compute(5)', 10, giInst2.exports.compute(5))
43
- t.check('instance1 still get_offset()', 42, giInst.exports.get_offset())
44
- }
45
- }
@@ -1,145 +0,0 @@
1
- import { readWasmFile } from './test_helper.js';
2
- class EmscriptenEH {
3
- }
4
- class EmscriptenSjLj extends EmscriptenEH {
5
- }
6
- export const suite = {
7
- name: 'wasm-sjlj',
8
- run: (t) => {
9
- ;
10
- globalThis.EmscriptenEH = EmscriptenEH;
11
- globalThis.EmscriptenSjLj = EmscriptenSjLj;
12
- const buf = readWasmFile('./sjlj.wasm');
13
- if (!buf) {
14
- t.fail++;
15
- return;
16
- }
17
- t.section('Module');
18
- var mod = null;
19
- try {
20
- mod = new WebAssembly.Module(buf);
21
- t.check('Module created', true, mod instanceof WebAssembly.Module);
22
- }
23
- catch (e) {
24
- t.fail++;
25
- return;
26
- }
27
- t.section('Instance with SjLj imports');
28
- var inst = null;
29
- var threwBit = 0;
30
- function getWasmTableEntry(index) {
31
- const table = inst.exports['__indirect_function_table'];
32
- const fn = table.get(index);
33
- return fn;
34
- }
35
- function _setThrew(val, _v) {
36
- if (threwBit === 0) {
37
- threwBit = val;
38
- }
39
- }
40
- function invoke_ii(index, a1) {
41
- try {
42
- return getWasmTableEntry(index)(a1);
43
- }
44
- catch (e) {
45
- if (!(e instanceof EmscriptenEH))
46
- throw e;
47
- _setThrew(1, 0);
48
- return 0;
49
- }
50
- }
51
- try {
52
- inst = new WebAssembly.Instance(mod, {
53
- env: {
54
- throw_longjmp: () => { throw new EmscriptenSjLj; },
55
- invoke_ii: invoke_ii,
56
- }
57
- });
58
- t.check('Instance created', true, inst instanceof WebAssembly.Instance);
59
- }
60
- catch (e) {
61
- t.fail++;
62
- return;
63
- }
64
- t.section('identity (no throw)');
65
- try {
66
- threwBit = 0;
67
- const result = inst.exports.identity(42);
68
- t.check('identity(42) = 42', 42, result);
69
- }
70
- catch (e) {
71
- t.fail++;
72
- }
73
- t.section('invoke_ii with no-throw function');
74
- try {
75
- threwBit = 0;
76
- const result = inst.exports.test_no_throw();
77
- t.check('test_no_throw() returns 10', 10, result);
78
- t.check('threwBit is 0', 0, threwBit);
79
- }
80
- catch (e) {
81
- t.fail++;
82
- }
83
- t.section('invoke_ii with throwing function');
84
- try {
85
- threwBit = 0;
86
- const result = inst.exports.test_throw();
87
- t.check('test_throw() detects threwBit', true, result !== 0);
88
- t.check('threwBit is set', true, threwBit !== 0);
89
- }
90
- catch (e) {
91
- t.fail++;
92
- }
93
- t.section('nested invoke (invoke_ii calls invoke_ii)');
94
- try {
95
- threwBit = 0;
96
- const result = inst.exports.test_nested_invoke();
97
- t.check('test_nested_invoke() detects threwBit', true, result !== 0);
98
- t.check('threwBit is set', true, threwBit !== 0);
99
- }
100
- catch (e) {
101
- t.fail++;
102
- }
103
- t.section('setjmp_test pattern');
104
- try {
105
- threwBit = 0;
106
- const result = inst.exports.setjmp_test(0);
107
- t.check('setjmp_test detects throw', -1, result);
108
- t.check('threwBit is set', true, threwBit !== 0);
109
- }
110
- catch (e) {
111
- t.fail++;
112
- }
113
- t.section('setjmp/longjmp: a(x) normal path');
114
- try {
115
- threwBit = 0;
116
- const result = inst.exports.a(5);
117
- t.check('a(5) returns 10 (b returns x*2)', 10, result);
118
- t.check('threwBit is 0', 0, threwBit);
119
- }
120
- catch (e) {
121
- t.fail++;
122
- }
123
- t.section('setjmp/longjmp: a(x) longjmp path');
124
- try {
125
- threwBit = 0;
126
- const result = inst.exports.a(-1);
127
- t.check('a(-1) returns -1 (longjmp caught)', -1, result);
128
- t.check('threwBit is set', true, threwBit !== 0);
129
- }
130
- catch (e) {
131
- t.fail++;
132
- }
133
- t.section('EmscriptenSjLj instanceof check');
134
- try {
135
- const exc = new EmscriptenSjLj();
136
- t.check('instanceof EmscriptenEH', true, exc instanceof EmscriptenEH);
137
- t.check('instanceof EmscriptenSjLj', true, exc instanceof EmscriptenSjLj);
138
- const regularErr = new Error('test');
139
- t.check('Error not instanceof EmscriptenEH', false, regularErr instanceof EmscriptenEH);
140
- }
141
- catch (e) {
142
- t.fail++;
143
- }
144
- }
145
- };