Skip to content Search Apps Documentation Source Content Run Reset Eval Playground File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

z_create_reply_16_filetest.gno

1.15 Kb · 40 lines
 1// PKGPATH: gno.land/r/gnoland/boards2/v0/filetests/z_create_reply_16_filetest
 2
 3// A reply may now contain a <gno-form>. The write-time blacklist used to
 4// reject it; now the reply body renders inside a <gno-foreign> sandbox
 5// whose inner renderer does not load forms (gnoweb safe-mode omits the
 6// raw HTML at render).
 7package z_create_reply_16_filetest
 8
 9import (
10	"strings"
11	"testing"
12
13	"gno.land/p/gnoland/boards/v0"
14
15	boards2 "gno.land/r/gnoland/boards2/v0"
16)
17
18const owner address = "g1skl80cuz8zq3lul9pgz5pc35l2pfzgxgfpsqkx"
19
20var bid, tid boards.ID
21
22func init(cur realm) {
23	testing.SetRealm(testing.NewUserRealm(owner))
24	bid = boards2.CreateBoard(cross(cur), "test-board", false, false)
25	tid = boards2.CreateThread(cross(cur), bid, "Foo", "bar")
26}
27
28func main(cur realm) {
29	testing.SetRealm(testing.NewUserRealm(owner))
30
31	// Previously rejected ("forms are not allowed in replies").
32	boards2.CreateReply(cross(cur), bid, tid, 0, "<gno-form><gno-select name=\"foo\" value=\"\" /></gno-form>")
33
34	// Accepted; the body is wrapped in a gno-foreign sandbox.
35	content := boards2.Render("test-board/1")
36	println(strings.Contains(content, "<gno-foreign>"))
37}
38
39// Output:
40// true