Search Apps Documentation Source Content File Folder Download Copy Actions Download

z_create_reply_16_filetest.gno

1.15 Kb · 40 lines
 1// PKGPATH: gno.land/r/gnoland/boards2/v1/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"
14
15	boards2 "gno.land/r/gnoland/boards2/v1"
16)
17
18const owner address = "g1rp7cmetn27eqlpjpc4vuusf8kaj746tysc0qgh"
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