Module: Harmony::Page::Window

Extended by:
Window
Included in:
Window
Defined in:
lib/harmony/page.rb

Overview

Window factory

Constant Summary collapse

BASE_RUNTIME =

Cache the initial runtime. Parsing env.js (done automatically when Envjs::Runtime is extended) takes a while, so we only want to do this once.

Johnson::Runtime.new

Instance Method Summary collapse

Instance Method Details

#blankObject



33
34
35
# File 'lib/harmony/page.rb', line 33

def blank
  from_uri('about:blank')
end

#from_document(document) ⇒ Object



28
29
30
31
# File 'lib/harmony/page.rb', line 28

def from_document(document)
  Tempfile.open('harmony') {|f| f << document; @path = f.path }
  from_uri("file://#{@path}")
end

#from_uri(uri) ⇒ Object



24
25
26
# File 'lib/harmony/page.rb', line 24

def from_uri(uri)
  BASE_RUNTIME.evaluate("window.open('#{uri}')")
end