Title: [88065] trunk/Source/WebKit/qt
Revision
88065
Author
[email protected]
Date
2011-06-03 14:53:04 -0700 (Fri, 03 Jun 2011)

Log Message

2011-06-03  Rafael Brandao  <[email protected]>

        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):

Modified Paths

Diff

Modified: trunk/Source/WebKit/qt/ChangeLog (88064 => 88065)


--- trunk/Source/WebKit/qt/ChangeLog	2011-06-03 21:49:25 UTC (rev 88064)
+++ trunk/Source/WebKit/qt/ChangeLog	2011-06-03 21:53:04 UTC (rev 88065)
@@ -1,3 +1,19 @@
+2011-06-03  Rafael Brandao  <[email protected]>
+
+        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):
+
 2011-06-03  Alexis Menard  <[email protected]>
 
         Reviewed by Andreas Kling.

Modified: trunk/Source/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp (88064 => 88065)


--- trunk/Source/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp	2011-06-03 21:49:25 UTC (rev 88064)
+++ trunk/Source/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp	2011-06-03 21:53:04 UTC (rev 88065)
@@ -119,6 +119,7 @@
     void protectBindingsRuntimeObjectsFromCollector();
     void localURLSchemes();
     void testOptionalJSObjects();
+    void testLocalStorageVisibility();
     void testEnablePersistentStorage();
     void consoleOutput();
     void inputMethods_data();
@@ -2328,8 +2329,8 @@
     QWebPage webPage1;
     QWebPage webPage2;
 
-    webPage1.currentFrame()->setHtml(QString("<html><body>test</body></html>"), QUrl());
-    webPage2.currentFrame()->setHtml(QString("<html><body>test</body></html>"), QUrl());
+    webPage1.currentFrame()->setHtml(QString("<html><body>test</body></html>"), QUrl("http://www.example.com/"));
+    webPage2.currentFrame()->setHtml(QString("<html><body>test</body></html>"), QUrl("http://www.example.com/"));
 
     QEXPECT_FAIL("","Feature enabled/disabled checking problem. Look at bugs.webkit.org/show_bug.cgi?id=29867", Continue);
     QCOMPARE(testFlag(webPage1, QWebSettings::OfflineWebApplicationCacheEnabled, "applicationCache", false), false);
@@ -2339,13 +2340,83 @@
     QCOMPARE(testFlag(webPage2, QWebSettings::OfflineWebApplicationCacheEnabled, "applicationCache", false), true);
 
     QCOMPARE(testFlag(webPage1, QWebSettings::LocalStorageEnabled, "localStorage", false), false);
-    QEXPECT_FAIL("", "https://bugs.webkit.org/show_bug.cgi?id=61045", Continue);
     QCOMPARE(testFlag(webPage2, QWebSettings::LocalStorageEnabled, "localStorage", true),  true);
     QCOMPARE(testFlag(webPage1, QWebSettings::LocalStorageEnabled, "localStorage", false), false);
-    QEXPECT_FAIL("", "https://bugs.webkit.org/show_bug.cgi?id=61045", Continue);
     QCOMPARE(testFlag(webPage2, QWebSettings::LocalStorageEnabled, "localStorage", false), true);
 }
 
+static inline bool checkLocalStorageVisibility(QWebPage& webPage, bool localStorageEnabled)
+{
+    webPage.settings()->setAttribute(QWebSettings::LocalStorageEnabled, localStorageEnabled);
+    return webPage.mainFrame()->evaluateJavaScript(QString("(window.localStorage != undefined)")).toBool();
+}
+
+void tst_QWebPage::testLocalStorageVisibility()
+{
+    // Local storage's visibility depends on its security origin, which depends on base url.
+    // Initially, it will test it with base urls that get a globally unique origin, which may not
+    // be able to use local storage even if the feature is enabled. Then later the same test is
+    // done but with urls that would get a valid origin, so local storage could be used.
+    // Before every test case it checks if local storage is not already visible.
+
+    QWebPage webPage;
+
+    webPage.currentFrame()->setHtml(QString("<html><body>test</body></html>"), QUrl());
+
+    QCOMPARE(checkLocalStorageVisibility(webPage, false), false);
+    QCOMPARE(checkLocalStorageVisibility(webPage, true), false);
+
+    webPage.currentFrame()->setHtml(QString("<html><body>test</body></html>"), QUrl("invalid"));
+
+    QCOMPARE(checkLocalStorageVisibility(webPage, false), false);
+    QCOMPARE(checkLocalStorageVisibility(webPage, true), false);
+
+    webPage.currentFrame()->setHtml(QString("<html><body>test</body></html>"), QUrl("://misparsed.com"));
+
+    QCOMPARE(checkLocalStorageVisibility(webPage, false), false);
+    QCOMPARE(checkLocalStorageVisibility(webPage, true), false);
+
+    webPage.currentFrame()->setHtml(QString("<html><body>test</body></html>"), QUrl("http://"));
+
+    QCOMPARE(checkLocalStorageVisibility(webPage, false), false);
+    QCOMPARE(checkLocalStorageVisibility(webPage, true), false);
+
+    webPage.currentFrame()->setHtml(QString("<html><body>test</body></html>"), QUrl("about:blank"));
+
+    QCOMPARE(checkLocalStorageVisibility(webPage, false), false);
+    QCOMPARE(checkLocalStorageVisibility(webPage, true), false);
+
+    webPage.currentFrame()->setHtml(QString("<html><body>test</body></html>"), QUrl("data:text/html,test"));
+
+    QCOMPARE(checkLocalStorageVisibility(webPage, false), false);
+    QCOMPARE(checkLocalStorageVisibility(webPage, true), false);
+
+    webPage.currentFrame()->setHtml(QString("<html><body>test</body></html>"), QUrl("file:///"));
+
+    QCOMPARE(checkLocalStorageVisibility(webPage, false), false);
+    QCOMPARE(checkLocalStorageVisibility(webPage, true), false);
+
+    webPage.currentFrame()->setHtml(QString("<html><body>test</body></html>"), QUrl("http://www.example.com"));
+
+    QCOMPARE(checkLocalStorageVisibility(webPage, false), false);
+    QCOMPARE(checkLocalStorageVisibility(webPage, true), true);
+
+    webPage.currentFrame()->setHtml(QString("<html><body>test</body></html>"), QUrl("https://www.example.com"));
+
+    QCOMPARE(checkLocalStorageVisibility(webPage, false), false);
+    QCOMPARE(checkLocalStorageVisibility(webPage, true), true);
+
+    webPage.currentFrame()->setHtml(QString("<html><body>test</body></html>"), QUrl("ftp://files.example.com"));
+
+    QCOMPARE(checkLocalStorageVisibility(webPage, false), false);
+    QCOMPARE(checkLocalStorageVisibility(webPage, true), true);
+
+    webPage.currentFrame()->setHtml(QString("<html><body>test</body></html>"), QUrl("file:///path/to/index.html"));
+
+    QCOMPARE(checkLocalStorageVisibility(webPage, false), false);
+    QCOMPARE(checkLocalStorageVisibility(webPage, true), true);
+}
+
 void tst_QWebPage::testEnablePersistentStorage()
 {
     QWebPage webPage;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to