 assert = require 'assert'
 path   = require 'path'
 http   = require 'http'
+url    = require 'url'
 
 describe '<webview> tag', ->
   @timeout 10000

    it 'emits when favicon urls are received', (done) ->
      webview.addEventListener 'page-favicon-updated', (e) ->
        assert.equal e.favicons.length, 2
        url =
          if process.platform is 'win32'
            'file:///C:/favicon.png'
          else
            'file:///favicon.png'
        assert.equal e.favicons[0], url
        done()
      webview.src = "file://#{fixtures}/pages/a.html"
      document.body.appendChild webview


  describe 'did-navigate-in-page event', ->
    it 'emits when an anchor link is clicked', (done) ->
      p = path.join fixtures, 'pages', 'webview-did-navigate-in-page.html'
      p = p.replace /\\/g, '/'
      pageUrl = url.format protocol: 'file', slashes: true, pathname: p

      webview.addEventListener 'did-navigate-in-page', (e) ->
        assert.equal e.url, "#{pageUrl}#test_content"
        done()
