 # opener    - Opening window (for window.open)
 module.exports = loadDocument = (options)->
   { browser } = options
+  { history } = options
   { url }     = options
   if url && browser.site
     site  = if /^(https?:|file:)/i.test(browser.site) then browser.site else "http://#{browser.site}"


        document.write(response.body)
        document.close()

        ###

        # Handle meta refresh.  Automatically reloads new location and counts
        # as a redirect.

          "content-type": options.encoding || "application/x-www-form-urlencoded"

      # Proceeed to load resource ...
      headers = options.headers || {}
      # HTTP header Referer, but Document property referrer
      headers.referer ||= options.referrer || history.url || ""
      # Tell the browser we're looking for an HTML document
      headers.accept  ||= "text/html,*/*"

      window._eventQueue.http method, options.url, headers: headers, params: options.params, target: document, (error, response)->
        if response
          history.updateLocation(window, response.url)
          window._response    = response
          document._URL       = response.url
          document._location  = history.location

        if error
          # 4xx/5xx we get an error with an HTTP response
