var bwTest = func() bool {
	jasmine.Describe("BrowserWindow", func() {
		var w electron.BrowserWindow
		jasmine.It("New", func() {
			w = electron.NewBrowserWindow(&map[string]interface{}{
				"title": "title1",
			})
			jasmine.Expect(w.GetTitle() == "title1").ToBeTruthy()
		})
		jasmine.ItAsync("LoadUrl", func(done func()) {

			w = electron.NewBrowserWindow(&map[string]interface{}{
				"title": "title2",
			})
			w.LoadURL("file:///"+js.Global.Get("process").Call("cwd").String()+"/spec/page1.html", nil)
			w.GetWebContents().OnDidStopLoading(func() {
				jasmine.Expect(w.GetTitle()).ToBe("Page1")
				done()
			})

		})
		jasmine.It("OnClose and OnClosed", func() {
			var w = electron.NewBrowserWindow(nil)
			var closec = make(chan bool)
			var first = true
			w.OnClose(func(event *js.Object) {
				if first {
					event.Call("preventDefault")
				}
				first = false
				go func() {
Ejemplo n.º 2
0
import (
	"time"

	"github.com/arvitaly/gopherjs-electron"
)
import jasmine "github.com/arvitaly/gopherjs-jasmine"
import "github.com/gopherjs/gopherjs/js"

var wsTests = func() bool {
	jasmine.Describe("WebContents", func() {
		jasmine.ItAsync("ExecuteJavascript", func(done func()) {
			var w = electron.NewBrowserWindow(nil)
			w.LoadURL("file:///"+js.Global.Get("process").Call("cwd").String()+"/spec/page1.html", nil)
			w.GetWebContents().OnWillNavigate(func(event *js.Object, url string) {
				jasmine.Expect(url).ToBe("file:///url2")
				w.Close()
				done()
			})
			w.GetWebContents().ExecuteJavaScript("location.href='file:///url2'", nil)
		})
		jasmine.It("UserAgent", func() {
			var w = electron.NewBrowserWindow(nil)
			w.GetWebContents().SetUserAgent("user1")
			jasmine.Expect(w.GetWebContents().GetUserAgent()).ToBe("user1")
			w.Close()
		})
		jasmine.It("OnCrashed", func() {
			var w = electron.NewBrowserWindow(&map[string]interface{}{
				"webSecurity": false,
			})
			var crashed = make(chan bool)