Title: [94906] trunk/Source
Revision
94906
Author
commit-qu...@webkit.org
Date
2011-09-10 06:15:49 -0700 (Sat, 10 Sep 2011)

Log Message

Source/WebCore: [Qt] QWebSettings::setUserStyleSheetUrl() does not work with windows paths that contain drive letters
https://bugs.webkit.org/show_bug.cgi?id=34884

KURL::path() alone does not handle removing the leading slash from a windows file path.
Using QUrl::toLocalFile() will turn file:///C:/path into C:/path appropriately.

Patch by Jarred Nicholls <jar...@sencha.com> on 2011-09-10
Reviewed by Andreas Kling.

* platform/qt/KURLQt.cpp:
(WebCore::KURL::fileSystemPath):

Source/WebKit/qt: [Qt] QWebSettings::setUserStyleSheetUrl() does not work with windows paths that contain drive letters
https://bugs.webkit.org/show_bug.cgi?id=34884

KURL::path() alone does not handle removing the leading slash from a windows file path.
Using QUrl::toLocalFile() will turn file:///C:/path into C:/path appropriately.

New test case that ensures a user stylesheet from the file system will load correctly
on all platforms.

Patch by Jarred Nicholls <jar...@sencha.com> on 2011-09-10
Reviewed by Andreas Kling.

* tests/qwebpage/resources/user.css: Added.
(p):
* tests/qwebpage/tst_qwebpage.cpp:
(tst_QWebPage::userStyleSheetFromFile):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (94905 => 94906)


--- trunk/Source/WebCore/ChangeLog	2011-09-10 11:25:03 UTC (rev 94905)
+++ trunk/Source/WebCore/ChangeLog	2011-09-10 13:15:49 UTC (rev 94906)
@@ -1,3 +1,16 @@
+2011-09-10  Jarred Nicholls  <jar...@sencha.com>
+
+        [Qt] QWebSettings::setUserStyleSheetUrl() does not work with windows paths that contain drive letters
+        https://bugs.webkit.org/show_bug.cgi?id=34884
+        
+        KURL::path() alone does not handle removing the leading slash from a windows file path.
+        Using QUrl::toLocalFile() will turn file:///C:/path into C:/path appropriately.
+
+        Reviewed by Andreas Kling.
+
+        * platform/qt/KURLQt.cpp:
+        (WebCore::KURL::fileSystemPath):
+
 2011-09-10  Ken Buchanan <ke...@chromium.org>
 
         Crash due to bad data in SVGDocumentExtensions m_pendingResources

Modified: trunk/Source/WebCore/platform/qt/KURLQt.cpp (94905 => 94906)


--- trunk/Source/WebCore/platform/qt/KURLQt.cpp	2011-09-10 11:25:03 UTC (rev 94905)
+++ trunk/Source/WebCore/platform/qt/KURLQt.cpp	2011-09-10 13:15:49 UTC (rev 94906)
@@ -46,7 +46,7 @@
     if (!isValid() || !protocolIs("file"))
         return String();
 
-    return String(path());
+    return static_cast<QUrl>(*this).toLocalFile();
 }
 
 }

Modified: trunk/Source/WebKit/qt/ChangeLog (94905 => 94906)


--- trunk/Source/WebKit/qt/ChangeLog	2011-09-10 11:25:03 UTC (rev 94905)
+++ trunk/Source/WebKit/qt/ChangeLog	2011-09-10 13:15:49 UTC (rev 94906)
@@ -1,3 +1,21 @@
+2011-09-10  Jarred Nicholls  <jar...@sencha.com>
+
+        [Qt] QWebSettings::setUserStyleSheetUrl() does not work with windows paths that contain drive letters
+        https://bugs.webkit.org/show_bug.cgi?id=34884
+        
+        KURL::path() alone does not handle removing the leading slash from a windows file path.
+        Using QUrl::toLocalFile() will turn file:///C:/path into C:/path appropriately.
+        
+        New test case that ensures a user stylesheet from the file system will load correctly
+        on all platforms.
+
+        Reviewed by Andreas Kling.
+
+        * tests/qwebpage/resources/user.css: Added.
+        (p):
+        * tests/qwebpage/tst_qwebpage.cpp:
+        (tst_QWebPage::userStyleSheetFromFile):
+
 2011-09-09  Fady Samuel  <fsam...@chromium.org>
 
         Move pageScaleFactor code from Frame.{h|cpp} to Page.{h|cpp}

Added: trunk/Source/WebKit/qt/tests/qwebpage/resources/user.css (0 => 94906)


--- trunk/Source/WebKit/qt/tests/qwebpage/resources/user.css	                        (rev 0)
+++ trunk/Source/WebKit/qt/tests/qwebpage/resources/user.css	2011-09-10 13:15:49 UTC (rev 94906)
@@ -0,0 +1,3 @@
+p {
+    background-image: url('http://does.not/exist.png');
+}
\ No newline at end of file

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


--- trunk/Source/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp	2011-09-10 11:25:03 UTC (rev 94905)
+++ trunk/Source/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp	2011-09-10 13:15:49 UTC (rev 94906)
@@ -101,6 +101,7 @@
     void popupFormSubmission();
     void acceptNavigationRequestWithNewWindow();
     void userStyleSheet();
+    void userStyleSheetFromLocalFileUrl();
     void loadHtml5Video();
     void modified();
     void contextMenuCrash();
@@ -465,7 +466,6 @@
 {
     TestNetworkManager* networkManager = new TestNetworkManager(m_page);
     m_page->setNetworkAccessManager(networkManager);
-    networkManager->requestedUrls.clear();
 
     m_page->settings()->setUserStyleSheetUrl(QUrl("data:text/css;charset=utf-8;base64,"
             + QByteArray("p { background-image: url('http://does.not/exist.png');}").toBase64()));
@@ -476,6 +476,20 @@
     QCOMPARE(networkManager->requestedUrls.at(0), QUrl("http://does.not/exist.png"));
 }
 
+void tst_QWebPage::userStyleSheetFromLocalFileUrl()
+{
+    TestNetworkManager* networkManager = new TestNetworkManager(m_page);
+    m_page->setNetworkAccessManager(networkManager);
+
+    QUrl styleSheetUrl = QUrl::fromLocalFile(TESTS_SOURCE_DIR + QLatin1String("qwebpage/resources/user.css"));
+    m_page->settings()->setUserStyleSheetUrl(styleSheetUrl);
+    m_view->setHtml("<p>hello world</p>");
+    QVERIFY(::waitForSignal(m_view, SIGNAL(loadFinished(bool))));
+
+    QVERIFY(networkManager->requestedUrls.count() >= 1);
+    QCOMPARE(networkManager->requestedUrls.at(0), QUrl("http://does.not/exist.png"));
+}
+
 void tst_QWebPage::loadHtml5Video()
 {
 #if defined(WTF_USE_QT_MULTIMEDIA) && WTF_USE_QT_MULTIMEDIA
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to