Run WASM tests inside your browser

wasmbrowsertest Build Status

Run Go wasm tests easily in your browser.

If you have a codebase targeting the wasm platform, chances are you would want to test your code in a browser. Currently, that process is a bit cumbersome:

  • The test needs to be compiled to a wasm file.
  • Then loaded into an HTML file along with the wasm_exec.js.
  • And finally, this needs to be served with a static file server and then loaded in the browser.

This tool automates all of that. So you just have to type GOOS=js GOARCH=wasm go test, and it automatically executes the tests inside a browser !

Quickstart

  • go get github.com/agnivade/wasmbrowsertest. This will place the binary in $GOPATH/bin, or $GOBIN, if that has a different value.
  • Rename the binary to go_js_wasm_exec.
  • Add $GOBIN to $PATH if it is not already done.
  • Run tests as usual: GOOS=js GOARCH=wasm go test.
  • You can also take a cpu profile. Set the -cpuprofile flag for that.

Ok, but how does the magic work ?

go test allows invocation of a different binary to run a test. go help test has a line:

-exec xprog
	    Run the test binary using xprog. The behavior is the same as
	    in 'go run'. See 'go help run' for details.

And go help run says:

By default, 'go run' runs the compiled binary directly: 'a.out arguments...'.
If the -exec flag is given, 'go run' invokes the binary using xprog:
	'xprog a.out arguments...'.
If the -exec flag is not given, GOOS or GOARCH is different from the system
default, and a program named go_$GOOS_$GOARCH_exec can be found
on the current search path, 'go run' invokes the binary using that program,
for example 'go_nacl_386_exec a.out arguments...'. This allows execution of
cross-compiled programs when a simulator or other execution method is
available.

So essentially, there are 2 ways:

  • Either have a binary with the name of go_js_wasm_exec in your $PATH.
  • Or set the -exec flag in your tests.

Use whatever works for you.

How is a CPU profile taken ?

A CPU profile is run during the duration of the test, and then converted to the pprof format so that it can be natively analyzed with the Go toolchain.

Can I run something which is not a test ?

Yep. GOOS=js GOARCH=wasm go run main.go also works. If you want to actually see the application running in the browser, set the WASM_HEADLESS variable to off like so WASM_HEADLESS=off GOOS=js GOARCH=wasm go run main.go.

Can I use this inside Travis ?

Sure.

Add these lines to your .travis.yml

addons:
  chrome: stable

install:
- go get github.com/agnivade/wasmbrowsertest
- mv $GOPATH/bin/wasmbrowsertest $GOPATH/bin/go_js_wasm_exec
- export PATH=$GOPATH/bin:$PATH

Now, just setting GOOS=js GOARCH=wasm will run your tests using wasmbrowsertest. For other CI environments, you have to do something similar.

What sorts of browsers are supported ?

This tool uses the ChromeDP protocol to run the tests inside a Chrome browser. So Chrome or any blink-based browser will work.

Why not firefox ?

Great question. The initial idea was to use a Selenium API and drive any browser to run the tests. But unfortunately, geckodriver does not support the ability to capture console logs - https://github.com/mozilla/geckodriver/issues/284. Hence, the shift to use the ChromeDP protocol circumvents the need to have any external driver binary and just have a browser installed in the machine.

Comments
  • wasmbrowsertest taking too long and not printing any output

    wasmbrowsertest taking too long and not printing any output

    https://travis-ci.com/nhooyr/websocket/jobs/288703981

    --- FAIL: TestWasm (60.00s)
        conn_test.go:305: wasm test binary failed: signal: killed:
    

    This is indicating the go test -exec=wasmbrowsertest command failed as it was killed by the 60s timeout.

    travis config: https://github.com/nhooyr/websocket/blob/5afbe3c1d163117b5ff9df021aa4b14e6ab2e7b5/.travis.yml#L25-L31

    go test invocation: https://github.com/nhooyr/websocket/blob/wasm/conn_test.go#L300-L307

    wasm test: https://github.com/nhooyr/websocket/blob/5afbe3c1d163117b5ff9df021aa4b14e6ab2e7b5/ws_js_test.go

    As you can see, even with the t.Fatal in the wasm test, wasmbrowsertest is timing out after 60s and prints no output. Any ideas why?

  • Need GPU disabled in chromedp to run

    Need GPU disabled in chromedp to run

    Could you include some examples please?

    Background

    I'm trying to get this working here: https://gitlab.com/polyapp-open-source/build-wasm/-/merge_requests/1

    Steps to reproduce

    git clone https://gitlab.com/polyapp-open-source/build-wasm cd build-wasm git checkout -b "1-create-and-run-integration-tests-which-require-a-browser" "origin/1-create-and-run-integration-tests-which-require-a-browser" chmod +rwx ./test_integration.sh ./test_integration.sh

    And that last command hangs forever even if all tests in main_integration_test.go are commented out and I comment out everything in func main() in frontend/main.go

  • Add test coverage support

    Add test coverage support

    Fixes https://github.com/agnivade/wasmbrowsertest/issues/5

    I saw some discussion in #5 on the difficulty of collecting coverage without also changing upstream Go. I've managed to find a working solution with very minimal tweaks that works pretty well. I'm curious what you think.

    Personally, I'll definitely be using something like this while working on HackPad and related projects.

    How it works:

    This solution overrides three file system operations for the purposes of opening, writing, and closing only the coverage profile file. The file's contents are copied out of the JS runtime and written again to the real file.

    I also bumped to Go 1.16 to use embedded files, but I definitely can revert that if it's not desired. It was mostly so I could make use of native JS file editing in my IDE 😄

  • Run examples

    Run examples

    Is it possible to run examples?

    package js_test
    
    import "syscall/js"
    
    func ExampleConsole() {
    	console := js.Global().Get("console")
    	console.Call("log", "1")
    	// Output: 3
    }
    
    testing: open temp file: open /tmp/go-example-stdout-ExampleConsole-0.txt: not implemented on js
    exit status 1
    

    Can we make it not to redirect the output in a file? Or maybe make our own hack to check the stdout output?

  • using -- to signify end of options

    using -- to signify end of options

    I've found supporting -- as an end of options argument useful in getting the remaining arguments passed to the wasm binary.

    Perhaps you would consider implementing this too or looking at a PR I could provide. It is not quite as straight forward as letting the flag.Parse catch the --, but close.

  • enhancement: Add the ability to inject an

    enhancement: Add the ability to inject an "init file" at startup

    Background

    We are currently working on optimizing our browser client of 0x-mesh (repository here: https://github.com/0xProject/0x-mesh), and some of the optimizations that we have needed to consider consist of attaching Javascript code to the window object and using this Javascript in lieu of Go implementations.

    It was previously impossible for us to run our tests using wasmbrowsertest for these changes without setting up the window object in Go using the syscall/js package. This did not follow the DRY design methodology and was much more difficult than simply injecting Javascript into the web page.

    Description

    This pull request adds support for passing in a Javascript file to load in the index.html file that is used by wasmbrowsertest by using an environment variable called WASM_INIT_FILE.

  • Support collecting code coverage

    Support collecting code coverage

    This is a very useful tool and I'm using it in https://github.com/nhooyr/websocket

    It'd be nice to be able to collect coverage from via the -coverprofile flag to go test.

    Right now I get:

    $ env GOOS=js GOARCH=wasm go test   "-coverprofile=ci/out/coverage.prof"  "-coverpkg=./..." ./internal/wsjs
    PASS
    testing: open /var/folders/zd/5rls6whn363cpxvs_2h4fy6m0000gn/T/go-build284234120/b001/_cover_.out: not implemented on js
    
  • replace flag.Parse with gentleParse

    replace flag.Parse with gentleParse

    gentleParse does away with having to call out all the arguments that will be passed to the wasm image.

    Now the wasm image will be passed all the arguments that the tool doesn't recognize itself.

    Also there are unit test examples of the parsing.

  • Error: command line too long

    Error: command line too long

    Hi , Thanks for your project. I would like to migrate my test from travis to github actions and the test failed with "Error: command line too long" Any idea why this error happening? I sucessfull run test on a ubuntu:latest container , the problem is on the github actions (maybe the go install is not on the default location)

  • fix: handle wasm module loading failure and improve logging and perfo…

    fix: handle wasm module loading failure and improve logging and perfo…

    Problems

    Sorted from real problem to nice-to-have:

    1. Unhandled error path: If the webassembly module fails to instantiate via instantiateStreaming the Done button is never enabled because when the WASM file failed to instantiate it skipped setting the done button. That in turn leads to the program waiting on the chromedp.WaitEnabled command until the test times out.
    2. Logging & Debugging: When this happens, there is virtually no debugging information available.

    Solutions

    1. A console error is being logged but it is insufficient to stop the tests from running. In the event of such a failure, use logger.Fatal since it means wasmbrowsertest itself is failing.
    2. First, func handleEvent in main.go was using "fmt.Print" instead of logger.Printf, which caused problems for whatever reason. Second, in case *cdpruntime.EventConsoleAPICalled it was assumed the error would be a number. I can add a new case specifically for console.Error which helps with this.

    I also created a 'DEBUG' option which contained the information I needed to debug the problems I was running in to; presumably such a thing will be helpful for someone else in the future.

    What the changes look like on WSL, where the program seems to hang

    With DEBUG=on

     DEBUG=on ./wasmbrowsertest ./testdata/test.wasm
    2020/02/07 12:18:43 browser log: {"id":1,"method":"Target.setDiscoverTargets","params":{"discover":true}}
    
    2020/02/07 12:18:43 browser log: {"method":"Target.targetCreated","params":{"targetInfo":{"targetId":"755af249-070b-4a9f-b918-8daa8399581a","type":"browser","title":"","url":"","attached":false}}}
    
    2020/02/07 12:18:43 browser log: {"method":"Target.targetCreated","params":{"targetInfo":{"targetId":"A63CE0F5C34057F27BDCA988F2A7F6C7","type":"page","title":"","url":"about:blank","attached":false,"browserContextId":"C7E01B11619625966EC22D59BBA95FC0"}}}
    
    2020/02/07 12:18:43 browser log: {"method":"Target.targetCreated","params":{"targetInfo":{"targetId":"e1bb48d1-6ee2-45fc-958d-a4d9c020fda4","type":"browser","title":"","url":"","attached":true}}}
    
    2020/02/07 12:18:43 browser log: {"id":1,"result":{}}
    
    2020/02/07 12:18:43 browser log: {"id":2,"method":"Target.attachToTarget","params":{"targetId":"A63CE0F5C34057F27BDCA988F2A7F6C7"}}
    
    2020/02/07 12:18:43 browser log: {"method":"Target.targetInfoChanged","params":{"targetInfo":{"targetId":"A63CE0F5C34057F27BDCA988F2A7F6C7","type":"page","title":"","url":"about:blank","attached":true,"browserContextId":"C7E01B11619625966EC22D59BBA95FC0"}}}
    
    2020/02/07 12:18:43 browser log: {"method":"Target.attachedToTarget","params":{"sessionId":"2D0E92901307FDDD0989795EAD93A074","targetInfo":{"targetId":"A63CE0F5C34057F27BDCA988F2A7F6C7","type":"page","title":"","url":"about:blank","attached":true,"browserContextId"
    :"C7E01B11619625966EC22D59BBA95FC0"},"waitingForDebugger":false}}
    
    2020/02/07 12:18:43 browser log: {"id":2,"result":{"sessionId":"2D0E92901307FDDD0989795EAD93A074"}}
    
    2020/02/07 12:18:43 browser log: {"id":4,"method":"Target.sendMessageToTarget","params":{"message":"{\"id\":3,\"method\":\"Log.enable\"}","sessionId":"2D0E92901307FDDD0989795EAD93A074"}}
    
    2020/02/07 12:18:43 browser log: {"id":4,"result":{}}
    
    [the output continued...]
    

    With DEBUG=off it can seem to hang:

    greg@LAPTOP-AH6IAHBO:/mnt/c/Users/gledr/Polyapp_Apps/gocode/src/github.com/agnivade/wasmbrowsertest$ DEBUG=off ./wasmbrowsertest ./testdata/test.wasm
    ^C
    

    Running on Windows, where the program works

    DEBUG=off

    C:\Users\gledr\Polyapp_Apps\gocode\src\github.com\agnivade\wasmbrowsertest>wasmbrowsertest.exe ./testdata/test.wasm
    [wasmbrowsertest]: 2020/02/07 12:22:54 main.go:241: panic: syscall/js: Value.Call: property _makeFuncWrapper is not a function, got undefined
    [wasmbrowsertest]: 2020/02/07 12:22:54 main.go:241:
    [wasmbrowsertest]: 2020/02/07 12:22:54 main.go:241: goroutine 1 [running]:
    [wasmbrowsertest]: 2020/02/07 12:22:54 main.go:241: syscall/js.Value.Call(0x7ff8000000000007, 0x4e248, 0x10, 0xc063bc8, 0x1, 0x1, 0x10)
    [wasmbrowsertest]: 2020/02/07 12:22:54 main.go:241:     /usr/local/go/src/syscall/js/js.go:299 +0x87
    [wasmbrowsertest]: 2020/02/07 12:22:54 main.go:241: syscall/js.FuncOf(0xc00e480, 0xc00e480, 0xc03c1e0)
    [wasmbrowsertest]: 2020/02/07 12:22:54 main.go:241:     /usr/local/go/src/syscall/js/func.go:46 +0xa
    [wasmbrowsertest]: 2020/02/07 12:22:54 main.go:241: syscall.fsCall(0x4c22f, 0x5, 0xc063cf0, 0x5, 0x5, 0xc072040, 0x4bf93, 0x4)
    [wasmbrowsertest]: 2020/02/07 12:22:54 main.go:241:     /usr/local/go/src/syscall/fs_js.go:477 +0x6
    [wasmbrowsertest]: 2020/02/07 12:22:54 main.go:241: syscall.Write(0x1, 0xc01c0e8, 0x5, 0x8, 0x54ab0, 0xc000180, 0x14370004)
    [wasmbrowsertest]: 2020/02/07 12:22:54 main.go:241:     /usr/local/go/src/syscall/fs_js.go:397 +0xc
    [wasmbrowsertest]: 2020/02/07 12:22:54 main.go:241: internal/poll.(*FD).Write(0xc03c0c0, 0xc01c0e8, 0x5, 0x8, 0x0, 0x0, 0x0)
    [wasmbrowsertest]: 2020/02/07 12:22:54 main.go:241:     /usr/local/go/src/internal/poll/fd_unix.go:268 +0x21
    [wasmbrowsertest]: 2020/02/07 12:22:54 main.go:241: os.(*File).write(...)
    [wasmbrowsertest]: 2020/02/07 12:22:54 main.go:241:     /usr/local/go/src/os/file_unix.go:280
    [wasmbrowsertest]: 2020/02/07 12:22:54 main.go:241: os.(*File).Write(0xc00c020, 0xc01c0e8, 0x5, 0x8, 0x0, 0xc01a1e0, 0x10ac0004)
    [wasmbrowsertest]: 2020/02/07 12:22:54 main.go:241:     /usr/local/go/src/os/file.go:145 +0xf
    [wasmbrowsertest]: 2020/02/07 12:22:54 main.go:241: fmt.Fprintln(0x6da40, 0xc00c020, 0xc063ee8, 0x1, 0x1, 0x2, 0x1, 0xc06c000)
    [wasmbrowsertest]: 2020/02/07 12:22:54 main.go:241:     /usr/local/go/src/fmt/print.go:266 +0x8
    [wasmbrowsertest]: 2020/02/07 12:22:54 main.go:241: fmt.Println(...)
    [wasmbrowsertest]: 2020/02/07 12:22:54 main.go:241:     /usr/local/go/src/fmt/print.go:275
    [wasmbrowsertest]: 2020/02/07 12:22:54 main.go:241: testing.(*M).Run(0xc06c000, 0x0)
    [wasmbrowsertest]: 2020/02/07 12:22:54 main.go:241:     /usr/local/go/src/testing/testing.go:1083 +0x31
    [wasmbrowsertest]: 2020/02/07 12:22:54 main.go:241: main.main()
    [wasmbrowsertest]: 2020/02/07 12:22:54 main.go:241:     _testmain.go:50 +0xe
    [wasmbrowsertest]: 2020/02/07 12:22:59 main.go:178: context deadline exceeded
    
    C:\Users\gledr\Polyapp_Apps\gocode\src\github.com\agnivade\wasmbrowsertest>
    

    DEBUG=on

    C:\Users\gledr\Polyapp_Apps\gocode\src\github.com\agnivade\wasmbrowsertest>wasmbrowsertest.exe ./testdata/test.wasm
    2020/02/07 12:24:23 browser log: {"id":1,"method":"Target.setDiscoverTargets","params":{"discover":true}}
    
    2020/02/07 12:24:23 browser log: {"method":"Target.targetCreated","params":{"targetInfo":{"targetId":"1bbfbedc-9a89-4465-b1f4-83aa72889b7c","type":"browser","title":"","url":"","attached":true}}}
    
    2020/02/07 12:24:23 browser log: {"method":"Target.targetCreated","params":{"targetInfo":{"targetId":"50428D1AA16D99A04CBDD84E9D90B920","type":"page","title":"","url":"about:blank","attached":false,"browserContextId":"6F575330AD73032CD7862515A656A644"}}}
    
    2020/02/07 12:24:23 browser log: {"method":"Target.targetCreated","params":{"targetInfo":{"targetId":"58e2edef-7c49-4ed5-af05-a3f1b3213413","type":"browser","title":"","url":"","attached":false}}}
    
    2020/02/07 12:24:23 browser log: {"id":1,"result":{}}
    
    2020/02/07 12:24:23 browser log: {"id":2,"method":"Target.attachToTarget","params":{"targetId":"50428D1AA16D99A04CBDD84E9D90B920"}}
    
    2020/02/07 12:24:23 browser log: {"method":"Target.targetInfoChanged","params":{"targetInfo":{"targetId":"50428D1AA16D99A04CBDD84E9D90B920","type":"page","title":"","url":"about:blank","attached":true,"browserContextId":"6F575330AD73032CD7862515A656A644"}}}
    
    2020/02/07 12:24:23 browser log: {"method":"Target.attachedToTarget","params":{"sessionId":"635E07B8B2999ECD6436F96FA18AF099","targetInfo":{"targetId":"50428D1AA16D99A04CBDD84E9D90B920","type":"page","title":"","url":"about:blank","attached":true,"browserContextId":"6F575330AD73032CD7862515A656A644"},"waitingForDebugger":false}}
    
    2020/02/07 12:24:23 browser log: {"id":2,"result":{"sessionId":"635E07B8B2999ECD6436F96FA18AF099"}}
    
    2020/02/07 12:24:23 browser log: {"id":4,"method":"Target.sendMessageToTarget","params":{"message":"{\"id\":3,\"method\":\"Log.enable\"}","sessionId":"635E07B8B2999ECD6436F96FA18AF099"}}
    
    2020/02/07 12:24:23 browser log: {"id":4,"result":{}}
    

    output continued...

    [wasmbrowsertest]: 2020/02/07 12:24:24 main.go:241:     /usr/local/go/src/syscall/fs_js.go:477 +0x6
    2020/02/07 12:24:24 browser log: {"method":"Target.receivedMessageFromTarget","params":{"sessionId":"635E07B8B2999ECD6436F96FA18AF099","message":"{\"method\":\"Runtime.consoleAPICalled\",\"params\":{\"type\":\"log\",\"args\":[{\"type\":\"string\",\"value\":\"\\t_testmain.go:50 +0xe\"}],\"executionContextId\":2,\"timestamp\":1581099864049.165,\"stackTrace\":{\"callFrames\":[{\"functionName\":\"writeSync\",\"scriptId\":\"3\",\"url\":\"http://localhost:61758/wasm_exec.js\",\"lineNumber\":40,\"columnNumber\":13},{\"functionName\":\"runtime.wasmWrite\",\"scriptId\":\"3\",\"url\":\"http://localhost:61758/wasm_exec.js\",\"lineNumber\":247,\"columnNumber\":9},{\"functionName\":\"runtime.wasmWrite\",\"scriptId\":\"5\",\"url\":\"\",\"lineNumber\":940,\"columnNumber\":794847},{\"functionName\":\"runtime.write\",\"scriptId\":\"5\",\"url\":\"\",\"lineNumber\":449,\"columnNumber\":393933},{\"functionName\":\"runtime.writeErr\",\"scriptId\":\"5\",\"url\":\"\",\"lineNumber\":808,\"columnNumber\":754824},{\"functionName\":\"runtime.gwrite\",\"scriptId\":\"5\",\"url\":\"\",\"lineNumber\":484,\"columnNumber\":418290},{\"functionName\":\"runtime.printstring\",\"scriptId\":\"5\",\"url\":\"\",\"lineNumber\":494,\"columnNumber\":422490},{\"functionName\":\"runtime.printnl\",\"scriptId\":\"5\",\"url\":\"\",\"lineNumber\":486,\"columnNumber\":418914},{\"functionName\":\"runtime.gentraceback\",\"scriptId\":\"5\",\"url\":\"\",\"lineNumber\":773,\"columnNumber\":701854},{\"functionName\":\"runtime.traceback1\",\"scriptId\":\"5\",\"url\":\"\",\"lineNumber\":779,\"columnNumber\":714840},{\"functionName\":\"runtime.traceback\",\"scriptId\":\"5\",\"url\":\"\",\"lineNumber\":778,\"columnNumber\":714129},{\"functionName\":\"runtime.dopanic_m\",\"scriptId\":\"5\",\"url\":\"\",\"lineNumber\":479,\"columnNumber\":415364},{\"functionName\":\"runtime.fatalpanic.func1\",\"scriptId\":\"5\",\"url\":\"\",\"lineNumber\":856,\"columnNumber\":775565},{\"functionName\":\"runtime.systemstack\",\"scriptId\":\"5\",\"url\":\"\",\"lineNumber\":880,\"columnNumber\":783937},{\"functionName\":\"runtime.fatalpanic\",\"scriptId\":\"5\",\"url\":\"\",\"lineNumber\":477,\"columnNumber\":412556},{\"functionName\":\"runtime.gopanic\",\"scriptId\":\"5\",\"url\":\"\",\"lineNumber\":470,\"columnNumber\":408514},{\"functionName\":\"syscall_js.Value.Call\",\"scriptId\":\"5\",\"url\":\"\",\"lineNumber\":1122,\"columnNumber\":877261},{\"functionName\":\"syscall_js.FuncOf\",\"scriptId\":\"5\",\"url\":\"\",\"lineNumber\":1109,\"columnNumber\":863358},{\"functionName\":\"syscall.fsCall\",\"scriptId\":\"5\",\"url\":\"\",\"lineNumber\":1176,\"columnNumber\":911155},{\"functionName\":\"syscall.Write\",\"scriptId\":\"5\",\"url\":\"\",\"lineNumber\":1172,\"columnNumber\":907110},{\"functionName\":\"internal_poll.__FD_.Write\",\"scriptId\":\"5\",\"url\":\"\",\"lineNumber\":1257,\"columnNumber\":988940},{\"functionName\":\"os.__File_.Write\",\"scriptId\":\"5\",\"url\":\"\",\"lineNumber\":1271,\"columnNumber\":999354},{\"functionName\":\"fmt.Fprintln\",\"scriptId\":\"5\",\"url\":\"\",\"lineNumber\":1896,\"columnNumber\":1418366},{\"functionName\":\"testing.__M_.Run\",\"scriptId\":\"5\",\"url\":\"\",\"lineNumber\":2074,\"columnNumber\":1630924},{\"functionName\":\"wasm_pc_f_loop\",\"scriptId\":\"5\",\"url\":\"\",\"lineNumber\":925,\"columnNumber\":794310},{\"functionName\":\"wasm_export_run\",\"scriptId\":\"5\",\"url\":\"\",\"lineNumber\":923,\"columnNumber\":794277},{\"functionName\":\"run\",\"scriptId\":\"3\",\"url\":\"http://localhost:61758/wasm_exec.js\",\"lineNumber\":474,\"columnNumber\":22},{\"functionName\":\"\",\"scriptId\":\"4\",\"url\":\"http://localhost:61758/\",\"lineNumber\":93,\"columnNumber\":12}]}}}","targetId":"50428D1AA16D99A04CBDD84E9D90B920"}}
    
    [wasmbrowsertest]: 2020/02/07 12:24:24 main.go:241: syscall.Write(0x1, 0xc01a0f0, 0x5, 0x8, 0x54ab0, 0xc000180, 0x14370004)
    2020/02/07 12:24:24 browser log: {"method":"Target.receivedMessageFromTarget","params":{"sessionId":"635E07B8B2999ECD6436F96FA18AF099","message":"{\"method\":\"DOM.attributeRemoved\",\"params\":{\"nodeId\":14,\"name\":\"disabled\"}}","targetId":"50428D1AA16D99A04CBDD84E9D90B920"}}
    
    2020/02/07 12:24:24 browser log: {"method":"Target.receivedMessageFromTarget","params":{"sessionId":"635E07B8B2999ECD6436F96FA18AF099","message":"{\"id\":53,\"result\":{\"searchId\":\"29664.7\",\"resultCount\":1}}","targetId":"50428D1AA16D99A04CBDD84E9D90B920"}}
    
    [wasmbrowsertest]: 2020/02/07 12:24:24 main.go:241:     /usr/local/go/src/syscall/fs_js.go:397 +0xc
    [wasmbrowsertest]: 2020/02/07 12:24:24 main.go:241: internal/poll.(*FD).Write(0xc03c0c0, 0xc01a0f0, 0x5, 0x8, 0x0, 0x0, 0x0)
    [wasmbrowsertest]: 2020/02/07 12:24:24 main.go:241:     /usr/local/go/src/internal/poll/fd_unix.go:268 +0x21
    [wasmbrowsertest]: 2020/02/07 12:24:24 main.go:241: os.(*File).write(...)
    [wasmbrowsertest]: 2020/02/07 12:24:24 main.go:241:     /usr/local/go/src/os/file_unix.go:280
    [wasmbrowsertest]: 2020/02/07 12:24:24 main.go:241: os.(*File).Write(0xc00c020, 0xc01a0f0, 0x5, 0x8, 0x0, 0xc01c1e0, 0x10ac0004)
    [wasmbrowsertest]: 2020/02/07 12:24:24 main.go:241:     /usr/local/go/src/os/file.go:145 +0xf
    [wasmbrowsertest]: 2020/02/07 12:24:24 main.go:241: fmt.Fprintln(0x6da40, 0xc00c020, 0xc063ee8, 0x1, 0x1, 0x2, 0x1, 0xc06c000)
    [wasmbrowsertest]: 2020/02/07 12:24:24 main.go:241:     /usr/local/go/src/fmt/print.go:266 +0x8
    [wasmbrowsertest]: 2020/02/07 12:24:24 main.go:241: fmt.Println(...)
    [wasmbrowsertest]: 2020/02/07 12:24:24 main.go:241:     /usr/local/go/src/fmt/print.go:275
    [wasmbrowsertest]: 2020/02/07 12:24:24 main.go:241: testing.(*M).Run(0xc06c000, 0x0)
    [wasmbrowsertest]: 2020/02/07 12:24:24 main.go:241:     /usr/local/go/src/testing/testing.go:1083 +0x31
    [wasmbrowsertest]: 2020/02/07 12:24:24 main.go:241: main.main()
    [wasmbrowsertest]: 2020/02/07 12:24:24 main.go:241:     _testmain.go:50 +0xe
    2020/02/07 12:24:24 browser log: {"id":56,"method":"Target.sendMessageToTarget","params":{"message":"{\"id\":55,\"method\":\"DOM.getSearchResults\",\"params\":{\"searchId\":\"29664.7\",\"fromIndex\":0,\"toIndex\":1}}","sessionId":"635E07B8B2999ECD6436F96FA18AF099"}}
    
    2020/02/07 12:24:24 browser log: {"id":56,"result":{}}
    
    2020/02/07 12:24:24 browser log: {"method":"Target.receivedMessageFromTarget","params":{"sessionId":"635E07B8B2999ECD6436F96FA18AF099","message":"{\"id\":55,\"result\":{\"nodeIds\":[14]}}","targetId":"50428D1AA16D99A04CBDD84E9D90B920"}}
    
    2020/02/07 12:24:24 browser log: {"id":58,"method":"Target.sendMessageToTarget","params":{"message":"{\"id\":57,\"method\":\"Runtime.evaluate\",\"params\":{\"expression\":\"exitCode;\",\"returnByValue\":true}}","sessionId":"635E07B8B2999ECD6436F96FA18AF099"}}
    
    2020/02/07 12:24:24 browser log: {"id":58,"result":{}}
    
    2020/02/07 12:24:24 browser log: {"method":"Target.receivedMessageFromTarget","params":{"sessionId":"635E07B8B2999ECD6436F96FA18AF099","message":"{\"id\":57,\"result\":{\"result\":{\"type\":\"number\",\"value\":2,\"description\":\"2\"}}}","targetId":"50428D1AA16D99A04CBDD84E9D90B920"}}
    
    [wasmbrowsertest]: 2020/02/07 12:24:29 main.go:178: context deadline exceeded
    
    C:\Users\gledr\Polyapp_Apps\gocode\src\github.com\agnivade\wasmbrowsertest>
    
  • `could not dial` errors on the latest Chrome on GitHub Actions

    `could not dial` errors on the latest Chrome on GitHub Actions

    https://github.com/hajimehoshi/ebiten/runs/2203141403?check_suite_focus=true

    I saw a lot of [wasmbrowsertest]: 2021/03/26 15:45:06 main.go:158: could not dial "ws://127.0.0.1:32959/devtools/browser/***": EOF errors and sometimes the test failed. This didn't happen 1 or 2 days ago. Do you have any insights? Thanks.

  • `total length of command line and environment variables exceeds limit` in GitHub Actions

    `total length of command line and environment variables exceeds limit` in GitHub Actions

    Example: https://github.com/hajimehoshi/ebiten/actions/runs/3447009698/jobs/5752563468

    There is a limitation of total environment variable lengths in wasm_exec.js (https://github.com/golang/go/blob/fcd14bdcbdfbb5b0c79cfecff95291837836a76d/misc/wasm/wasm_exec.js#L523-L525) and apparently the limitation is exceeded in GitHub Actions.

    wasmbrowsertest is not to blame, but would it be possible to add a hack to suppress this error, or add a backdoor to pass an original wasm_exec.js?

  • Accept permission

    Accept permission

    Some API's needs a permission from the user, such as Notfication API, Credential Management API, Geolocation API. There's many APIs that need explicit permission from the user.

    In those case, the test "fails", because the user didn't accept the API permission. Of course, it should have a way to test this fail condition (when user doesn't accept).

    But, how I can test when the user accepts?

    The current test doesn't seems to accept any permission. :\

Go Wasm is a in-browser IDE for Go

Go Wasm Go Wasm is a Go development environment with the essentials to write and run code entirely within the browser, using the power of WebAssembly

Jan 8, 2023
DOM library for Go and WASM

Go DOM binding (and more) for WebAssembly This library provides a Go API for different Web APIs for WebAssembly target. It's in an active development,

Dec 23, 2022
Library to use HTML5 Canvas from Go-WASM, with all drawing within go code

go-canvas go-canvas is a pure go+webassembly Library for efficiently drawing on a html5 canvas element within the browser from go without requiring ca

Dec 11, 2022
An Experimental Wasm Virtual Machine for Gophers

gasm A minimal implementation of v1 WASM spec compatible virtual machine purely written in go. The vm can be embedded in your go program without any d

Dec 31, 2022
Golang-WASM provides a simple idiomatic, and comprehensive API and bindings for working with WebAssembly for Go and JavaScript developers
Golang-WASM provides a simple idiomatic, and comprehensive API and bindings for working with WebAssembly for Go and JavaScript developers

A bridge and bindings for JS DOM API with Go WebAssembly. Written by Team Ortix - Hamza Ali and Chan Wen Xu. GOOS=js GOARCH=wasm go get -u github.com/

Dec 22, 2022
A WASM Filter for Envoy Proxy written in Golang

envoy-proxy-wasm-filter-golang A WASM Filter for Envoy Proxy written in Golang Build tinygo build -o optimized.wasm -scheduler=none -target=wasi ./mai

Nov 6, 2022
Istio wasm api demo with golang

istio-wasm-api-demo 1. Setup the latest Istio Setup k8s cluster: e.g. kind create cluster --name test Download the latest Istioctl from the GitHub rel

Nov 1, 2022
Go compiler running entirely in your browser

wasm-go-playground This is the Go compiler ("gc") compiled for WASM, running in your browser! It can be used to run a simple playground, à la play.gol

Nov 10, 2022
The in-browser IDE for Go

Go Wasm Go Wasm is a Go development environment with the essentials to write and run code entirely within the browser, using the power of WebAssembly

Dec 19, 2022
Interact with browser from Go. Manually-crafted WebAPI interoperation library.

GWeb: golang + js + wasm gweb -- strictly typed WebAPI library on top of syscall/js. Like flow or TypeScript but for Go. You need it if you want to in

Sep 26, 2022
Running a Command line tool written in Go on browser with WebAssembly

Running a command line tool written in Go on browser with WebAssembly This repo contains code/assets from the article Files: . ├── article.md

Dec 30, 2022
A template project to demonstrate how to run WebAssembly functions as sidecar microservices in dapr
A template project to demonstrate how to run WebAssembly functions as sidecar microservices in dapr

Live Demo 1. Introduction DAPR is a portable, event-driven runtime that makes it easy for any developer to build resilient, stateless and stateful app

Jan 3, 2023
Write your front in Go!

Hogosuru Hogosuru is a part of a personel project and export to the community and provide a framework to easly provide write front end in go. He use a

Dec 14, 2022
Aes for go and java; build go fo wasm and use wasm parse java response.

aes_go_wasm_java aes for go and java; build go fo wasm and use wasm parse java response. vscode setting config settings.json { "go.toolsEnvVars":

Dec 14, 2021
Rename-pvc can rename PersistentVolumeClaims (PVCs) inside KubernetesRename-pvc can rename PersistentVolumeClaims (PVCs) inside Kubernetes

rename-pvc rename-pvc can rename PersistentVolumeClaims (PVCs) inside Kubernetes. ⚠️ Be sure to create a backup of your data in the PVC before using r

Oct 31, 2022
Go Wasm is a in-browser IDE for Go

Go Wasm Go Wasm is a Go development environment with the essentials to write and run code entirely within the browser, using the power of WebAssembly

Jan 8, 2023
A simple `fs.FS` implementation to be used inside tests.

testfs A simple fs.FS which is contained in a test (using testing.TB's TempDir()) and with a few helper methods. PS: This lib only works on Go 1.16+.

Mar 3, 2022
Extremely flexible golang deep comparison, extends the go testing package, tests HTTP APIs and provides tests suite
Extremely flexible golang deep comparison, extends the go testing package, tests HTTP APIs and provides tests suite

go-testdeep Extremely flexible golang deep comparison, extends the go testing package. Latest news Synopsis Description Installation Functions Availab

Jan 5, 2023
Rr-e2e-tests - Roadrunner end-to-end tests repository
Rr-e2e-tests - Roadrunner end-to-end tests repository

RoadRunner end-to-end plugins tests License: The MIT License (MIT). Please see L

Dec 15, 2022
Go testing in the browser. Integrates with `go test`. Write behavioral tests in Go.
Go testing in the browser. Integrates with `go test`. Write behavioral tests in Go.

GoConvey is awesome Go testing Welcome to GoConvey, a yummy Go testing tool for gophers. Works with go test. Use it in the terminal or browser accordi

Dec 30, 2022