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.
This commit is contained in:
Petteri Räty 2013-05-02 10:54:09 +03:00
parent 51b68f34d3
commit a9073703dd
2 changed files with 12 additions and 2 deletions

View File

@ -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
---------------------------

View File

@ -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();
}