Permalink
Browse files

Clean up browsers and pointers to ensure they are not the reason of t…

…he leakage.
  • Loading branch information...
1 parent dcbba13 commit a94e87adc7bfe1dc537b457a1b3bb14ab90abe91 @josevalim josevalim committed Mar 21, 2011
View
17 Gemfile.lock
@@ -18,13 +18,13 @@ GEM
rack-test (>= 0.5.4)
selenium-webdriver (>= 0.0.27)
xpath (~> 0.1.3)
- celerity (0.8.7)
- childprocess (0.1.7)
- ffi (~> 0.6.3)
+ celerity (0.8.8)
+ childprocess (0.1.8)
+ ffi (~> 1.0.6)
columnize (0.3.2)
culerity (0.2.15)
diff-lcs (1.1.2)
- ffi (0.6.3)
+ ffi (1.0.7)
rake (>= 0.8.7)
json_pure (1.5.1)
linecache (0.43)
@@ -49,9 +49,9 @@ GEM
ruby-debug-base (0.10.4)
linecache (>= 0.3)
rubyzip (0.9.4)
- selenium-webdriver (0.1.2)
- childprocess (~> 0.1.5)
- ffi (~> 0.6.3)
+ selenium-webdriver (0.1.4)
+ childprocess (>= 0.1.7)
+ ffi (>= 1.0.7)
json_pure
rubyzip
sinatra (1.1.2)
@@ -67,10 +67,7 @@ PLATFORMS
DEPENDENCIES
bundler (~> 1.0)
- capybara (~> 0.4.1)
capybara-zombie!
- childprocess (~> 0.1.7)
- multi_json (~> 0.0.5)
rspec (~> 2.0)
ruby-debug
sinatra (~> 1.0)
View
2 lib/capybara/driver/zombie_driver.rb
@@ -205,7 +205,7 @@ def find(selector, context=nil)
end
def reset!
- socket_write("browser.cookies(browser.window.location.hostname, '/').clear();")
+ socket_write("browser.cookies(browser.window.location.hostname, '/').clear(); browser = null;")
end
private
View
13 lib/capybara/zombie/executer.js
@@ -1,14 +1,10 @@
var net = require('net');
var sys = require('sys');
var zombie = require('zombie');
-var browser = new zombie.Browser;
+var browser = null;
var pointers = [];
var buffer = "";
-// Confirm all confirmation dialogs, expected behavior for
-// capybara
-browser.onconfirm(function() {return true;}, true);
-
net.createServer(function (stream) {
stream.setEncoding('utf8');
stream.allowHalfOpen = true;
@@ -18,6 +14,13 @@ net.createServer(function (stream) {
});
stream.on('end', function () {
+ if (browser == null) {
+ browser = new zombie.Browser();
+ // Confirm all confirmation dialogs, expected behavior for capybara
+ browser.onconfirm(function() {return true;}, true);
+ // Clean up old pointers
+ pointers = []
+ }
eval(buffer);
buffer = "";
});
View
5 spec/driver/zombie_driver_spec.rb
@@ -2,10 +2,15 @@
describe Capybara::Driver::Zombie do
driver = nil
+
before do
@driver = (driver ||= Capybara::Driver::Zombie.new(TestApp))
end
+ after do
+ @driver.reset!
+ end
+
it_should_behave_like "driver"
it_should_behave_like "driver with header support"
it_should_behave_like "driver with status code support"
View
4 spec/session/zombie_session_spec.rb
@@ -7,6 +7,10 @@
@session = (session ||= Capybara::Session.new(:zombie, TestApp))
end
+ after do
+ @session.driver.reset!
+ end
+
describe '#driver' do
it "should be an zombie driver" do
@session.driver.should be_an_instance_of(Capybara::Driver::Zombie)

0 comments on commit a94e87a

Please sign in to comment.