sourcegraph / go-webkit2

WebKit API bindings (WebKitGTK+ v2) for Go
https://sourcegraph.com/github.com/sourcegraph/go-webkit2
Other
313 stars 61 forks source link

example_test.go fails while all other tests before succeed #19

Open qknight opened 9 years ago

qknight commented 9 years ago

problem

this test is coming with go-webkit2 already but was slightly modified to not output the same output twice: example_test.go

anyway, i don't understand what is the issue here as it does not print any specific error message. how can i debug this futher?

when i run it it fails, all other tests before this one return success, see:

these derivations will be built:
  /nix/store/m8dhbf9bdm8f7gzxq8h07as68944ijwp-go1.4-gowebkit2-22d8960.drv
building path(s) ‘/nix/store/hsp9krzghhjjhkfczdn8wh98bi7flxmk-go1.4-gowebkit2-22d8960’
unpacking sources
unpacking source archive /nix/store/414sdb4ksxvki9c1lkid1c439sbbjcji-go-webkit2-22d89604526bbeafa4492c7f5c07ac643dff6e45-src
source root is go-webkit2-22d89604526bbeafa4492c7f5c07ac643dff6e45-src
patching sources
configuring
building
Renaming github.com/crazy2be/gojs to github.com/sqs/gojs
Renaming github.com/crazy2be/gojs to github.com/sqs/gojs
github.com/sourcegraph/go-webkit2/webkit2
github.com/sourcegraph/go-webkit2/cmd/webkit-eval-js
running tests
libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast
=== RUN TestSettings_EnableWriteConsoleMessagesToStdout
--- PASS: TestSettings_EnableWriteConsoleMessagesToStdout (0.05s)
=== RUN TestSettings_AutoLoadImages
--- PASS: TestSettings_AutoLoadImages (0.00s)
=== RUN TestSettings_SetUserAgentWithApplicationDetails
--- PASS: TestSettings_SetUserAgentWithApplicationDetails (0.00s)
=== RUN TestDefaultWebContext
--- PASS: TestDefaultWebContext (0.00s)
=== RUN TestWebContext_CacheModel
--- PASS: TestWebContext_CacheModel (0.00s)
=== RUN TestWebContext_ClearCache
--- PASS: TestWebContext_ClearCache (0.00s)
=== RUN TestNewWebView
--- PASS: TestNewWebView (0.00s)
=== RUN TestNewWebViewWithContext
--- PASS: TestNewWebViewWithContext (0.00s)
=== RUN TestWebView_Context
--- PASS: TestWebView_Context (0.00s)
=== RUN TestWebView_LoadURI
--- PASS: TestWebView_LoadURI (0.83s)
=== RUN TestWebView_LoadURI_load_failed
--- PASS: TestWebView_LoadURI_load_failed (0.00s)
=== RUN TestWebView_LoadHTML
--- PASS: TestWebView_LoadHTML (0.01s)
=== RUN TestWebView_Title
--- PASS: TestWebView_Title (0.00s)
=== RUN TestWebView_URI
--- PASS: TestWebView_URI (0.00s)
=== RUN TestWebView_Settings
--- PASS: TestWebView_Settings (0.00s)
=== RUN TestWebView_JavaScriptGlobalContext
--- PASS: TestWebView_JavaScriptGlobalContext (0.00s)
=== RUN TestWebView_RunJavaScript
--- PASS: TestWebView_RunJavaScript (0.01s)
=== RUN TestWebView_RunJavaScript_exception
--- PASS: TestWebView_RunJavaScript_exception (0.01s)
=== RUN TestWebView_GetSnapshot
--- PASS: TestWebView_GetSnapshot (0.00s)
=== RUN: Example
--- FAIL: Example (0.15s)
got:
Load failed.
Load finished.
Title: ""
URI: https://www.google.com/
Hostname (from JavaScript): ""
want:
Load finished.
Title: "Google"
URI: https://www.google.com/
Hostname (from JavaScript): "www.google.com"
FAIL
exit status 1
FAIL    github.com/sourcegraph/go-webkit2/webkit2       1.520s
builder for ‘/nix/store/m8dhbf9bdm8f7gzxq8h07as68944ijwp-go1.4-gowebkit2-22d8960.drv’ failed with exit code 1
error: build of ‘/nix/store/m8dhbf9bdm8f7gzxq8h07as68944ijwp-go1.4-gowebkit2-22d8960.drv’ failed

source code

package main

import (
    "fmt"
    "github.com/conformal/gotk3/glib"
    "github.com/conformal/gotk3/gtk"
    "github.com/sourcegraph/go-webkit2/webkit2"
    "github.com/sqs/gojs"
    "runtime"
)

func main() {
    gtk.Init(nil)
    runtime.LockOSThread()

    webView := webkit2.NewWebView()
    defer webView.Destroy()

    webView.Connect("load-failed", func() {
        fmt.Println("Load failed.")
    })
    webView.Connect("load-changed", func(_ *glib.Object, loadEvent webkit2.LoadEvent) {
        switch loadEvent {
        case webkit2.LoadFinished:
            fmt.Println("Load finished.")
            fmt.Printf("Title: %q\n", webView.Title())
            fmt.Printf("URI: %s\n", webView.URI())
            webView.RunJavaScript("window.location.hostname", func(val *gojs.Value, err error) {
                if err != nil {
                    fmt.Println("JavaScript error.")
                } else {
                    fmt.Printf("Hostname (from JavaScript): %q\n", val)
                }
                gtk.MainQuit()
            })
        }
    })

    glib.IdleAdd(func() bool {
        webView.LoadURI("http://www.lastlog.de/")
        return false
    })

    gtk.Main()
}

expected output

    // output:
    // Load finished.
    // Title: "Google"
    // URI: https://www.google.com/
    // Hostname (from JavaScript): "www.google.com"

my output

 go run gowebkit2.go 

** (gowebkit2:26321): WARNING **: Error retrieving accessibility bus address: org.freedesktop.DBus.Error.ServiceUnknown: The name org.a11y.Bus was not provided by any .service files

** (WebKitWebProcess:26328): WARNING **: Error retrieving accessibility bus address: org.freedesktop.DBus.Error.ServiceUnknown: The name org.a11y.Bus was not provided by any .service files
Load failed.
Load finished.
Title: ""
URI: https://lastlog.de/
Hostname (from JavaScript): ""

the diff

diff gowebkit2.go go-webkit2/webkit2/example_test.go
1c1
< package main

---
> package webkit2_test
4a5,6
>       "runtime"
> 
9d10
<       "runtime"
12,13c13
< func main() {
<       gtk.Init(nil)

---
> func Example() {
14a15
>       gtk.Init(nil)
22c23,24
<       webView.Connect("load-changed", func(_ *glib.Object, loadEvent webkit2.LoadEvent) {

---
>       webView.Connect("load-changed", func(_ *glib.Object, i int) {
>               loadEvent := webkit2.LoadEvent(i)
40c42
<               webView.LoadURI("http://www.lastlog.de/")

---
>               webView.LoadURI("http://www.google.de/")