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') }