Skip to content

Commit

Permalink
webgl test
Browse files Browse the repository at this point in the history
  • Loading branch information
agnivade committed Jun 28, 2024
1 parent 4a40c54 commit 1ecbc56
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ func run(ctx context.Context, args []string, errOutput io.Writer, flagSet *flag.
)
}

opts = append(opts, chromedp.Flag("single-process", true), chromedp.Flag("use-gl", "swiftshader"))

// create chrome instance
allocCtx, cancelAllocCtx := chromedp.NewExecAllocator(ctx, opts...)
defer cancelAllocCtx()
Expand Down
23 changes: 23 additions & 0 deletions tests/webgl_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package test

import (
"syscall/js"
"testing"
"time"
)

func TestWebGL(t *testing.T) {
window := js.Global().Get("window")
document := window.Get("document")
body := document.Get("body")
canvas := document.Call("createElement", "canvas")
body.Call("appendChild", canvas)
if context := canvas.Call("getContext", "2d"); !context.Truthy() {
t.Error("getContext('2d') failed")
}
if context := canvas.Call("getContext", "webgl"); !context.Truthy() {
t.Error("getContext('webgl') failed")
}

time.Sleep(30 * time.Second)
}

0 comments on commit 1ecbc56

Please sign in to comment.