 describe 'cookies module', ->
   fixtures = path.resolve __dirname, 'fixtures'
   w = null
-  url = "http://127.0.0.1:9999"
+  url = "http://127.0.0.1"
 
   beforeEach -> w = new BrowserWindow(show: true)
   afterEach -> w.destroy()

  it 'should remove cookies', (done) ->
    w.loadUrl 'file://' + path.join(fixtures, 'page', 'a.html')
    w.webContents.on 'did-finish-load', ()->
      w.webContents.session.cookies.get {url:url}, (error, cookies_list) ->
        count = 0
        for cookie in cookies_list
          w.webContents.session.cookies.remove {url:url, name:cookie.name}, (error) ->
            throw error if error
            ++count
            if count == cookies_list.length
              w.webContents.session.cookies.get {url:url}, (error, cookies_list) ->
                throw error if error
                assert.equal 0, cookies_list.length
                done()

  it 'should overwrite the existent cookie', (done) ->
    w.loadUrl 'file://' + path.join(fixtures, 'page', 'a.html')
    w.webContents.on 'did-finish-load', ()->
      w.webContents.session.cookies.set {url: url, name: 'type', value: 'dummy2'}, (error) ->
        throw error if error
        w.webContents.session.cookies.get {url: url}, (error, cookies_list) ->
          throw error if error
          assert.equal 1, cookies_list.length
          assert.equal 'type', cookies_list[0].name
