 because it is special to the Javascript interpreter."
   (interactive "MJavascript to evaluate: ")
   (with-espresso-js
-   (let* ((context (espresso--get-js-context))
-          (content-window (ecase (car context)
-                            (window (cdr context))
-                            (browser (js< (cdr context)
-                                          "contentWindow" "wrappedJSObject"))))
+   (let* ((content-window (espresso--js-content-window
+                           (espresso--get-js-context)))
           (result (js-eval content-window js)))
 
      (when (interactive-p)

          else
          collect item)))

(defmacro with-espresso-js (&rest forms)
  "Runs FORMS with the Mozilla repl set up for espresso commands.
Inside the lexical scope of `with-espresso-js', `js?', `js!',
`js-new', `js-eval', `js-list', `js<', `js>', and are defined."

  `(progn
     (espresso--js-enter-repl)

          while (> time-left 0)
          do (accept-process-output process time-left nil t)
          do (goto-char (process-mark process))
          finally do (signal
                      'espresso-moz-bad-rpc
                      (list (format "Timed out waiting for output matching %S" regexp))))))

(defstruct espresso--js-handle
  ;; Integer, mirrors the value we see in JS
