test: more tests

This commit is contained in:
Vlad Stan
2026-07-07 18:32:54 +03:00
parent 4f072a6247
commit 120cf735c8
8 changed files with 426 additions and 10 deletions
+1 -4
View File
@@ -116,10 +116,7 @@
"policies": [
{
"id": "watchonly",
"access": [
"read",
"write"
]
"access": ["read", "write"]
}
]
},
+49
View File
@@ -1 +1,50 @@
window.__lnbitsWasmTestExtensionLoaded = true
;(function () {
const channel = new MessageChannel()
const pending = new Map()
let counter = 0
const ready = new Promise(resolve => {
channel.port1.addEventListener('message', event => {
const message = event.data || {}
if (message.type === 'lnbits-extension:connected') {
resolve(true)
return
}
if (message.type !== 'lnbits-extension:response') return
const callback = pending.get(message.id)
if (!callback) return
pending.delete(message.id)
callback(message)
})
channel.port1.start()
window.parent.postMessage(
{type: 'lnbits-extension:connect', id: 'wasm-test-extension'},
'*',
[channel.port2]
)
})
window.lnbitsWasmTestBridge = {
ready() {
return ready
},
request(message) {
return ready.then(() => {
return new Promise(resolve => {
const id = `wasm-test-${++counter}`
pending.set(id, resolve)
channel.port1.postMessage({
type: 'lnbits-extension:request',
id,
...message
})
})
})
}
}
})()
@@ -0,0 +1 @@
{"unsafe": true}
@@ -0,0 +1,4 @@
<!doctype html>
<html>
<body>This must not be served as JavaScript.</body>
</html>