Changeset 88065 in webkit


Ignore:
Timestamp:
Jun 3, 2011 2:53:04 PM (13 years ago)
Author:
commit-queue@webkit.org
Message:

2011-06-03 Rafael Brandao <rafael.lobo@openbossa.org>

Reviewed by Andreas Kling.

[Qt] It made two Qt API tests fail
https://bugs.webkit.org/show_bug.cgi?id=58847

Modified failing test's base url so it could get a valid origin
and make use of local storage. Also added another test that checks
local storage visibility in both scenarios.

  • tests/qwebpage/tst_qwebpage.cpp: (tst_QWebPage::testOptionalJSObjects): (checkLocalStorageVisibility): (tst_QWebPage::testLocalStorageVisibility):
Location:
trunk/Source/WebKit/qt
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/qt/ChangeLog

    r88052 r88065  
     12011-06-03  Rafael Brandao  <rafael.lobo@openbossa.org>
     2
     3        Reviewed by Andreas Kling.
     4
     5        [Qt] It made two Qt API tests fail
     6        https://bugs.webkit.org/show_bug.cgi?id=58847
     7
     8        Modified failing test's base url so it could get a valid origin
     9        and make use of local storage. Also added another test that checks
     10        local storage visibility in both scenarios.
     11
     12        * tests/qwebpage/tst_qwebpage.cpp:
     13        (tst_QWebPage::testOptionalJSObjects):
     14        (checkLocalStorageVisibility):
     15        (tst_QWebPage::testLocalStorageVisibility):
     16
    1172011-06-03  Alexis Menard  <alexis.menard@openbossa.org>
    218
  • trunk/Source/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp

    r86951 r88065  
    120120    void localURLSchemes();
    121121    void testOptionalJSObjects();
     122    void testLocalStorageVisibility();
    122123    void testEnablePersistentStorage();
    123124    void consoleOutput();
     
    23292330    QWebPage webPage2;
    23302331
    2331     webPage1.currentFrame()->setHtml(QString("<html><body>test</body></html>"), QUrl());
    2332     webPage2.currentFrame()->setHtml(QString("<html><body>test</body></html>"), QUrl());
     2332    webPage1.currentFrame()->setHtml(QString("<html><body>test</body></html>"), QUrl("http://www.example.com/"));
     2333    webPage2.currentFrame()->setHtml(QString("<html><body>test</body></html>"), QUrl("http://www.example.com/"));
    23332334
    23342335    QEXPECT_FAIL("","Feature enabled/disabled checking problem. Look at bugs.webkit.org/show_bug.cgi?id=29867", Continue);
     
    23402341
    23412342    QCOMPARE(testFlag(webPage1, QWebSettings::LocalStorageEnabled, "localStorage", false), false);
    2342     QEXPECT_FAIL("", "https://bugs.webkit.org/show_bug.cgi?id=61045", Continue);
    23432343    QCOMPARE(testFlag(webPage2, QWebSettings::LocalStorageEnabled, "localStorage", true),  true);
    23442344    QCOMPARE(testFlag(webPage1, QWebSettings::LocalStorageEnabled, "localStorage", false), false);
    2345     QEXPECT_FAIL("", "https://bugs.webkit.org/show_bug.cgi?id=61045", Continue);
    23462345    QCOMPARE(testFlag(webPage2, QWebSettings::LocalStorageEnabled, "localStorage", false), true);
     2346}
     2347
     2348static inline bool checkLocalStorageVisibility(QWebPage& webPage, bool localStorageEnabled)
     2349{
     2350    webPage.settings()->setAttribute(QWebSettings::LocalStorageEnabled, localStorageEnabled);
     2351    return webPage.mainFrame()->evaluateJavaScript(QString("(window.localStorage != undefined)")).toBool();
     2352}
     2353
     2354void tst_QWebPage::testLocalStorageVisibility()
     2355{
     2356    // Local storage's visibility depends on its security origin, which depends on base url.
     2357    // Initially, it will test it with base urls that get a globally unique origin, which may not
     2358    // be able to use local storage even if the feature is enabled. Then later the same test is
     2359    // done but with urls that would get a valid origin, so local storage could be used.
     2360    // Before every test case it checks if local storage is not already visible.
     2361
     2362    QWebPage webPage;
     2363
     2364    webPage.currentFrame()->setHtml(QString("<html><body>test</body></html>"), QUrl());
     2365
     2366    QCOMPARE(checkLocalStorageVisibility(webPage, false), false);
     2367    QCOMPARE(checkLocalStorageVisibility(webPage, true), false);
     2368
     2369    webPage.currentFrame()->setHtml(QString("<html><body>test</body></html>"), QUrl("invalid"));
     2370
     2371    QCOMPARE(checkLocalStorageVisibility(webPage, false), false);
     2372    QCOMPARE(checkLocalStorageVisibility(webPage, true), false);
     2373
     2374    webPage.currentFrame()->setHtml(QString("<html><body>test</body></html>"), QUrl("://misparsed.com"));
     2375
     2376    QCOMPARE(checkLocalStorageVisibility(webPage, false), false);
     2377    QCOMPARE(checkLocalStorageVisibility(webPage, true), false);
     2378
     2379    webPage.currentFrame()->setHtml(QString("<html><body>test</body></html>"), QUrl("http://"));
     2380
     2381    QCOMPARE(checkLocalStorageVisibility(webPage, false), false);
     2382    QCOMPARE(checkLocalStorageVisibility(webPage, true), false);
     2383
     2384    webPage.currentFrame()->setHtml(QString("<html><body>test</body></html>"), QUrl("about:blank"));
     2385
     2386    QCOMPARE(checkLocalStorageVisibility(webPage, false), false);
     2387    QCOMPARE(checkLocalStorageVisibility(webPage, true), false);
     2388
     2389    webPage.currentFrame()->setHtml(QString("<html><body>test</body></html>"), QUrl("data:text/html,test"));
     2390
     2391    QCOMPARE(checkLocalStorageVisibility(webPage, false), false);
     2392    QCOMPARE(checkLocalStorageVisibility(webPage, true), false);
     2393
     2394    webPage.currentFrame()->setHtml(QString("<html><body>test</body></html>"), QUrl("file:///"));
     2395
     2396    QCOMPARE(checkLocalStorageVisibility(webPage, false), false);
     2397    QCOMPARE(checkLocalStorageVisibility(webPage, true), false);
     2398
     2399    webPage.currentFrame()->setHtml(QString("<html><body>test</body></html>"), QUrl("http://www.example.com"));
     2400
     2401    QCOMPARE(checkLocalStorageVisibility(webPage, false), false);
     2402    QCOMPARE(checkLocalStorageVisibility(webPage, true), true);
     2403
     2404    webPage.currentFrame()->setHtml(QString("<html><body>test</body></html>"), QUrl("https://www.example.com"));
     2405
     2406    QCOMPARE(checkLocalStorageVisibility(webPage, false), false);
     2407    QCOMPARE(checkLocalStorageVisibility(webPage, true), true);
     2408
     2409    webPage.currentFrame()->setHtml(QString("<html><body>test</body></html>"), QUrl("ftp://files.example.com"));
     2410
     2411    QCOMPARE(checkLocalStorageVisibility(webPage, false), false);
     2412    QCOMPARE(checkLocalStorageVisibility(webPage, true), true);
     2413
     2414    webPage.currentFrame()->setHtml(QString("<html><body>test</body></html>"), QUrl("file:///path/to/index.html"));
     2415
     2416    QCOMPARE(checkLocalStorageVisibility(webPage, false), false);
     2417    QCOMPARE(checkLocalStorageVisibility(webPage, true), true);
    23472418}
    23482419
Note: See TracChangeset for help on using the changeset viewer.