public
Description: Johnson wraps JavaScript in a loving Ruby embrace.
Homepage: http://github.com/jbarnette/johnson/wikis
Clone URL: git://github.com/jbarnette/johnson.git
location = is supposed to be async
tenderlove (author)
Fri May 30 18:54:36 -0700 2008
commit  68c9c39f88088f96eed26922a141c0fbb8dc24e2
tree    57c32e7aa5d4061f3f96fa4ae64cc912ab78e5c3
parent  ae3584f2d4e47d82c063c89631bcd8b23acfd9db
...
29
30
31
32
33
34
35
...
652
653
654
655
656
657
658
...
29
30
31
 
32
33
34
...
651
652
653
 
654
655
656
0
@@ -29,7 +29,6 @@ print = function(txt) { Ruby.puts(txt); };
0
   
0
   window.__defineSetter__("location", function(url){
0
     var xhr = new XMLHttpRequest();
0
-    xhr.async = false;
0
     xhr.open("GET", url);
0
     xhr.onreadystatechange = function(){
0
       curLocation = curLocation.merge(url);
0
@@ -652,7 +651,6 @@ print = function(txt) { Ruby.puts(txt); };
0
       }
0
 
0
       if (this.async)
0
-        // FIXME: This is segfaulting
0
         new Ruby.Thread(function() { makeRequest(); });
0
       else
0
         makeRequest();
...
9
10
11
12
 
 
 
 
 
13
14
15
 
 
 
 
 
16
17
...
9
10
11
 
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
0
@@ -9,9 +9,18 @@ module Johnson
0
 
0
     def test_set_location_returns_location
0
       filename = "file://#{File.expand_path(__FILE__)}"
0
-      @runtime.evaluate("window.location = '#{filename}'")
0
+
0
+      may_thread {
0
+        @runtime.evaluate("window.location = '#{filename}'")
0
+      }
0
+
0
       uri = URI.parse(filename)
0
       assert_equal(uri.to_s, @runtime.evaluate('window.location').to_s)
0
     end
0
+
0
+    def may_thread(&block)
0
+      block.call
0
+      (Thread.list - [Thread.main]).each { |t| t.join }
0
+    end
0
   end
0
 end

Comments