Changeset 39863 in webkit


Ignore:
Timestamp:
Jan 13, 2009 9:58:57 AM (15 years ago)
Author:
Simon Hausmann
Message:

2009-01-13 Simon Hausmann <simon.hausmann@nokia.com>

Reviewed by Tor Arne Vestbø.

https://bugs.webkit.org/show_bug.cgi?id=23171

Based on patch by Yael Aharon <yael.aharon@nokia.com>

Make the QWebSettings functions for setting the path for the local
storage database private QtWebkit API, including the ability to
associated a QWebPage with a named page group.

Location:
trunk/WebKit/qt
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit/qt/Api/qwebpage.cpp

    r39753 r39863  
    101101{
    102102    QWebPagePrivate::drtRun = b;
     103}
     104
     105void QWEBKIT_EXPORT qt_webpage_setGroupName(QWebPage* page, const QString& groupName)
     106{
     107    page->handle()->page->setGroupName(groupName);
     108}
     109
     110QString QWEBKIT_EXPORT qt_webpage_groupName(QWebPage* page)
     111{
     112    return page->handle()->page->groupName();
    103113}
    104114
     
    26522662*/
    26532663
     2664/*!
     2665  \fn QWebPagePrivate* QWebPage::handle() const
     2666  \internal
     2667*/
    26542668
    26552669#include "moc_qwebpage.cpp"
  • trunk/WebKit/qt/Api/qwebpage.h

    r39581 r39863  
    270270    virtual bool supportsExtension(Extension extension) const;
    271271
     272    inline QWebPagePrivate* handle() const { return d; }
     273
    272274Q_SIGNALS:
    273275    void loadStarted();
  • trunk/WebKit/qt/Api/qwebsettings.cpp

    r39706 r39863  
    730730}
    731731
    732 /*!
     732/*
    733733    \since 4.5
    734734
     
    741741    \sa localStorageDatabasePath()
    742742*/
    743 void QWebSettings::setLocalStorageDatabasePath(const QString& path)
    744 {
    745     QWebSettingsPrivate *global = QWebSettings::globalSettings()->d;
    746     global->localStorageDatabasePath = path;
     743
     744void QWEBKIT_EXPORT qt_websettings_setLocalStorageDatabasePath(QWebSettings* settings, const QString& path)
     745{
     746    QWebSettingsPrivate *d = settings->handle();
     747    d->localStorageDatabasePath = path;
    747748    d->apply();
    748749}
    749750
    750 /*!
     751/*
    751752    \since 4.5
    752753
     
    756757    \sa setLocalStorageDatabasePath()
    757758*/
    758 QString QWebSettings::localStorageDatabasePath() const
    759 {
    760     QWebSettingsPrivate *global = QWebSettings::globalSettings()->d;
    761     return global->localStorageDatabasePath;
    762 }
     759QString QWEBKIT_EXPORT qt_websettings_localStorageDatabasePath(QWebSettings* settings)
     760{
     761    return settings->handle()->localStorageDatabasePath;
     762}
     763
     764/*!
     765    \fn QWebSettingsPrivate* QWebSettings::handle() const
     766    \internal
     767*/
  • trunk/WebKit/qt/Api/qwebsettings.h

    r39173 r39863  
    116116    static QString offlineWebApplicationCachePath();
    117117
    118     void setLocalStorageDatabasePath(const QString& path);
    119     QString localStorageDatabasePath() const;
     118    inline QWebSettingsPrivate* handle() const { return d; }
    120119
    121120private:
  • trunk/WebKit/qt/ChangeLog

    r39826 r39863  
     12009-01-13  Simon Hausmann  <simon.hausmann@nokia.com>
     2
     3        Reviewed by Tor Arne Vestbø.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=23171
     6
     7        Based on patch by Yael Aharon  <yael.aharon@nokia.com>
     8
     9        Make the QWebSettings functions for setting the path for the local
     10        storage database private QtWebkit API, including the ability to
     11        associated a QWebPage with a named page group.
     12
     13        * Api/qwebpage.cpp:
     14        (qt_webpage_setGroupName): Added.
     15        (qt_webpage_groupName): Added.
     16        * Api/qwebpage.h:
     17        (ExtensionOption::handle): Added internal helper function.
     18        * Api/qwebsettings.cpp:
     19        (qt_websettings_setLocalStorageDatabasePath): Made private API.
     20        (qt_websettings_localStorageDatabasePath): Made private API.
     21        * Api/qwebsettings.h:
     22        * tests/qwebpage/tst_qwebpage.cpp:
     23        (tst_QWebPage::database): Small cleanup.
     24        (tst_QWebPage::multiplePageGroupsAndLocalStorage): New test for the
     25        page group handling, written by Yael.
     26
    1272009-01-12  Tor Arne Vestbø  <tavestbo@trolltech.com>
    228
  • trunk/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp

    r39678 r39863  
    101101    void destroyPlugin();
    102102    void createViewlessPlugin();
     103    void multiplePageGroupsAndLocalStorage();
    103104
    104105private:
     
    370371    QWebSettings::setOfflineStorageDefaultQuota(1024 * 1024);
    371372    QVERIFY(QWebSettings::offlineStorageDefaultQuota() == 1024 * 1024);
    372 
    373     m_page->settings()->setOfflineWebApplicationCachePath(path);
    374     QVERIFY(m_page->settings()->offlineWebApplicationCachePath() == path);
    375 
    376     m_page->settings()->setLocalStorageDatabasePath(path);
    377     QVERIFY(m_page->settings()->localStorageDatabasePath() == path);
    378373
    379374    QString dbFileName = path + "Databases.db";
     
    596591}
    597592
     593// import private API
     594void QWEBKIT_EXPORT qt_webpage_setGroupName(QWebPage* page, const QString& groupName);
     595QString QWEBKIT_EXPORT qt_webpage_groupName(QWebPage* page);
     596void QWEBKIT_EXPORT qt_websettings_setLocalStorageDatabasePath(QWebSettings* settings, const QString& path);
     597
     598void tst_QWebPage::multiplePageGroupsAndLocalStorage()
     599{
     600    QDir dir(QDir::currentPath());
     601    dir.mkdir("path1");
     602    dir.mkdir("path2");
     603
     604    QWebView view1;
     605    QWebView view2;
     606
     607    qt_websettings_setLocalStorageDatabasePath(view1.page()->settings(), QDir::toNativeSeparators(QDir::currentPath() + "/path1"));
     608    qt_webpage_setGroupName(view1.page(), "group1");
     609    qt_websettings_setLocalStorageDatabasePath(view2.page()->settings(), QDir::toNativeSeparators(QDir::currentPath() + "/path2"));
     610    qt_webpage_setGroupName(view2.page(), "group2");
     611    QCOMPARE(qt_webpage_groupName(view1.page()), QString("group1"));
     612    QCOMPARE(qt_webpage_groupName(view2.page()), QString("group2"));
     613
     614
     615    view1.setHtml(QString("<html><body> </body></html>"), QUrl("http://www.myexample.com"));
     616    view2.setHtml(QString("<html><body> </body></html>"), QUrl("http://www.myexample.com"));
     617
     618    view1.page()->mainFrame()->evaluateJavaScript("localStorage.test='value1';");
     619    view2.page()->mainFrame()->evaluateJavaScript("localStorage.test='value2';");
     620
     621    view1.setHtml(QString("<html><body> </body></html>"), QUrl("http://www.myexample.com"));
     622    view2.setHtml(QString("<html><body> </body></html>"), QUrl("http://www.myexample.com"));
     623
     624    QVariant s1 = view1.page()->mainFrame()->evaluateJavaScript("localStorage.test");
     625    QCOMPARE(s1.toString(), QString("value1"));
     626
     627    QVariant s2 = view2.page()->mainFrame()->evaluateJavaScript("localStorage.test");
     628    QCOMPARE(s2.toString(), QString("value2"));
     629
     630    QTest::qWait(1000);
     631
     632    QFile::remove(QDir::toNativeSeparators(QDir::currentPath() + "/path1/http_www.myexample.com_0.localstorage"));
     633    QFile::remove(QDir::toNativeSeparators(QDir::currentPath() + "/path2/http_www.myexample.com_0.localstorage"));
     634    dir.rmdir(QDir::toNativeSeparators("./path1"));
     635    dir.rmdir(QDir::toNativeSeparators("./path2"));
     636}
     637
    598638QTEST_MAIN(tst_QWebPage)
    599639#include "tst_qwebpage.moc"
Note: See TracChangeset for help on using the changeset viewer.