From 49abe259813a505b0761e6d31dde671344b5bc87 Mon Sep 17 00:00:00 2001 From: Steven Parkes Date: Sat, 6 Feb 2010 13:53:57 -0800 Subject: [PATCH] add Window#evaluate(s) --- lib/envjs/runtime.rb | 9 +++++++++ src/intro.js | 3 +++ test/data.js | 9 +++++++++ 3 files changed, 21 insertions(+) diff --git a/lib/envjs/runtime.rb b/lib/envjs/runtime.rb index bbfa8d91..3d28e35e 100644 --- a/lib/envjs/runtime.rb +++ b/lib/envjs/runtime.rb @@ -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#!.*$/, '') @@ -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 @@ -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 @@ -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 diff --git a/src/intro.js b/src/intro.js index 2d9b1155..ab3cc9fe 100644 --- a/src/intro.js +++ b/src/intro.js @@ -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 ]; }; diff --git a/test/data.js b/test/data.js index 2abe7eeb..f2c3c836 100755 --- a/test/data.js +++ b/test/data.js @@ -34,3 +34,12 @@ inner = "Hello, World from a data uri!" 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); +*/ \ No newline at end of file