From 78786f1bdb6847f5bd78fa069e7732af9440393e Mon Sep 17 00:00:00 2001 From: Steven Parkes Date: Sat, 6 Feb 2010 11:50:24 -0800 Subject: [PATCH] add mynyml's scope test (needs to be integrated) --- test/scope.rb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 test/scope.rb diff --git a/test/scope.rb b/test/scope.rb new file mode 100755 index 00000000..9086aaea --- /dev/null +++ b/test/scope.rb @@ -0,0 +1,25 @@ +#!/usr/bin/env ruby +require 'rubygems' +require 'johnson/tracemonkey' +require 'envjs/runtime' + +require 'nanotest' +include Nanotest + +rt = Johnson::Runtime.new +rt.extend(Envjs::Runtime) + +rt.evaluate('window.location = "http://example.com"') +assert { 'Example Web Page' == rt.evaluate('window.document.title') } +assert { 'Example Web Page' == rt.evaluate('this.document.title') } +assert { 'Example Web Page' == rt.evaluate('document.title') } + +rt.evaluate('window.location = "http://montrealrb.org"') +assert { 'Montreal.rb' == rt.evaluate('window.document.title') } + +# correct +# assert { 'Montreal.rb' == rt.evaluate('this.document.title') } +# buggy +assert { 'Example Web Page' == rt.evaluate('this.document.title') } + +assert { 'Example Web Page' == rt.evaluate('document.title') }