From a9073703dd54e6902a2b1776722d0d177fcf50a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petteri=20R=C3=A4ty?= Date: Thu, 2 May 2013 10:54:09 +0300 Subject: [PATCH] Use offline app cache support when ./tmp/ exists In Rails projects it's a sure bet that tmp exists so this automatically covers most people. With the README addition other people know to create the directory. --- README.md | 7 +++++++ src/WebPage.cpp | 7 +++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b206dba..1d4984e 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,13 @@ If you're using capybara-webkit with Sinatra, don't forget to set Capybara.app = MySinatraApp.new ``` +Offline Application Cache +------------------------- + +The offline application cache needs a directory to write to for the cached files. Capybara-webkit +will look at if the working directory has a tmp directory and when it exists offline application +cache will be enabled. + Non-Standard Driver Methods --------------------------- diff --git a/src/WebPage.cpp b/src/WebPage.cpp index 7dd4e11..b506423 100644 --- a/src/WebPage.cpp +++ b/src/WebPage.cpp @@ -40,8 +40,11 @@ WebPage::WebPage(WebPageManager *manager, QObject *parent) : QWebPage(parent) { settings()->setAttribute(QWebSettings::JavascriptCanOpenWindows, true); settings()->setAttribute(QWebSettings::JavascriptCanCloseWindows, true); settings()->setAttribute(QWebSettings::LocalStorageDatabaseEnabled, true); - settings()->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, true); - settings()->setOfflineWebApplicationCachePath("tmp"); + + if(QFileInfo("tmp").isDir()) { + settings()->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, true); + settings()->setOfflineWebApplicationCachePath("tmp"); + } createWindow(); }