Skip to content

Commit

Permalink
add Window#evaluate(s)
Browse files Browse the repository at this point in the history
  • Loading branch information
smparkes committed Feb 6, 2010
1 parent 965db6e commit 49abe25
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/envjs/runtime.rb
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ def self.extended object

if uri.scheme == "file"
uri_s = uri.path
elsif uri.scheme == "data"
raise "implement 0"
end

v = open(uri_s).read.gsub(/\A#!.*$/, '')
Expand Down Expand Up @@ -224,6 +226,8 @@ def load *files

if uri.scheme == "file"
super uri.path
elsif uri.scheme == "data"
raise "implement 1"
else
raise "hell 1"
end
Expand Down Expand Up @@ -272,6 +276,10 @@ def load *files
window["$options"] = evaluate("new Object");
window["$options"].proxy = outer

window.evaluate = lambda { |s|
return master.evaluate.call(s,window);
}

window.load = lambda { |*files|
files.each do |f|
master.load.call f, window
Expand Down Expand Up @@ -309,6 +317,7 @@ def load *files
if fn && !scripts[fn]
scripts[fn] = compiled_script
end
# p "?", script
evaluate_compiled_script(compiled_script,scope)
end

Expand Down
3 changes: 3 additions & 0 deletions src/intro.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@
$master.load(f,new_window);
}
};
new_window.evaluate = function(string){
return $master.evaluate.call(string,new_window);
};
return [ proxy, new_window ];
};

Expand Down
9 changes: 9 additions & 0 deletions test/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,12 @@ inner = "<head><title></title></head><body>Hello, World from a data uri!</body>"
if(window.document.documentElement.innerHTML != inner){
throw new Error("c"+window.document.documentElement.innerHTML);
}

/* not implemented yet ...
w = open("about:blank");
w.foo = 10;
debug(w.foo);
uri = "data:text/javascript;base64,"+"foo = 20;";
w.load(uri);
debug(w.foo);
*/

0 comments on commit 49abe25

Please sign in to comment.