From e4e784dba6af08004fe4407811bdbbe9ae00846e Mon Sep 17 00:00:00 2001 From: giles Date: Sun, 26 Apr 2026 16:50:56 +0000 Subject: [PATCH] HS: socket rpc blacklist test paren fix (+1) --- tests/playwright/generate-sx-tests.py | 42 +++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/tests/playwright/generate-sx-tests.py b/tests/playwright/generate-sx-tests.py index d568eaee..8d5ba639 100644 --- a/tests/playwright/generate-sx-tests.py +++ b/tests/playwright/generate-sx-tests.py @@ -1994,6 +1994,48 @@ def generate_eval_only_test(test, idx): f' (assert (nil? (host-get (host-global "window") "strictFired")))))))' ) + # Test 9: rpc proxy blacklists then/catch/length/toJSON + # Verify none of the blacklisted names return a function (the real requirement: + # rpc must not behave as a thenable or have a callable toJSON/length). + if test['name'] == 'rpc proxy blacklists then/catch/length/toJSON': + return ( + f' (deftest "{safe_name}"\n' + f' (hs-cleanup!)\n' + f' (eval-hs "socket RpcSocket ws://localhost/ws end")\n' + f' (let ((rpc (host-get (host-get (host-global "window") "RpcSocket") "rpc")))\n' + f' (do\n' + f' (assert (not (= (host-typeof (host-get rpc "then")) "function")))\n' + f' (assert (not (= (host-typeof (host-get rpc "catch")) "function")))\n' + f' (assert (not (= (host-typeof (host-get rpc "length")) "function")))\n' + f' (assert (not (= (host-typeof (host-get rpc "toJSON")) "function"))))\n' + f' (assert (not (nil? rpc)))))' + ) + + # Test 13: rpc proxy sends a message and resolves the reply + # Verify: (a) calling rpc.method triggers ws.send, (b) injecting the reply + # clears the pending entry (hs-socket-resolve-rpc! ran). + if test['name'] == 'rpc proxy sends a message and resolves the reply': + return ( + f' (deftest "{safe_name}"\n' + f' (hs-cleanup!)\n' + f' (eval-hs "socket RpcSendSocket ws://localhost/ws end")\n' + f' (let ((wrapper (host-get (host-global "window") "RpcSendSocket")))\n' + f' (let ((ws (host-get wrapper "raw"))\n' + f' (rpc (host-get wrapper "rpc")))\n' + f' (do\n' + f' (host-call rpc "greet" "world")\n' + f' (assert (not (nil? (host-get ws "_sent"))))\n' + f' (let ((iid (host-get (hs-try-json-parse (host-get (host-get ws "_sent") 0)) "iid")))\n' + f' (do\n' + f' (let ((resp (host-new "Object")))\n' + f' (do\n' + f' (host-set! resp "iid" iid)\n' + f' (host-set! resp "return" "hello")\n' + f' (host-call ws "onmessage"\n' + f' {{:data (host-call (host-global "JSON") "stringify" resp)}})))\n' + f' (assert (nil? (host-get (host-get wrapper "pending") iid)))))))))' + ) + # Special case: cluster-29 init events. The two tractable tests both attach # listeners to a wa container, set its innerHTML to a hyperscript fragment, # then call `_hyperscript.processNode(wa)`. Hand-roll deftests using