From a0fb662773f14d9670dc9a02b7ee5ea932613a15 Mon Sep 17 00:00:00 2001 From: Chris Farber Date: Sun, 1 Apr 2012 12:53:40 -0400 Subject: [PATCH] Support for enabling/disabling localStorage --- spec/driver_spec.rb | 33 +++++++++++++++++++++++++++++++++ src/WebPage.cpp | 1 + 2 files changed, 34 insertions(+) diff --git a/spec/driver_spec.rb b/spec/driver_spec.rb index 854726d..12b9184 100644 --- a/spec/driver_spec.rb +++ b/spec/driver_spec.rb @@ -1277,6 +1277,39 @@ describe Capybara::Driver::Webkit do end end + context "localStorage works" do + before(:all) do + @app = lambda do |env| + body = <<-HTML + + + + + + + HTML + [200, + { 'Content-Type' => 'text/html', 'Content-Length' => body.length.to_s }, + [body]] + end + end + + it "displays the message on subsequent page loads" do + subject.find("//span[contains(.,'localStorage is enabled')]").should be_empty + subject.visit "/" + subject.find("//span[contains(.,'localStorage is enabled')]").should_not be_empty + end + end + context "app with a lot of HTML tags" do before(:all) do @app = lambda do |env| diff --git a/src/WebPage.cpp b/src/WebPage.cpp index 47fa420..62aa6ea 100644 --- a/src/WebPage.cpp +++ b/src/WebPage.cpp @@ -25,6 +25,7 @@ WebPage::WebPage(QObject *parent) : QWebPage(parent) { void WebPage::resetWindowSize() { this->setViewportSize(QSize(1680, 1050)); + this->settings()->setAttribute(QWebSettings::LocalStorageDatabaseEnabled, true); } void WebPage::setCustomNetworkAccessManager() {