Title: [125352] trunk/Source/WebKit/qt
Revision
125352
Author
[email protected]
Date
2012-08-11 06:26:27 -0700 (Sat, 11 Aug 2012)

Log Message

[Qt] Add support for HTML5 state object history API in FrameLoaderClientQt
https://bugs.webkit.org/show_bug.cgi?id=93648

Reviewed by Kenneth Rohde Christiansen.

Add support for push/replace/pop by implementing dispatchDidNavigateWithinPage.

* WebCoreSupport/FrameLoaderClientQt.cpp:
(WebCore::FrameLoaderClientQt::dispatchDidNavigateWithinPage):
(WebCore::FrameLoaderClientQt::dispatchDidPushStateWithinPage):
(WebCore::FrameLoaderClientQt::dispatchDidReplaceStateWithinPage):
(WebCore::FrameLoaderClientQt::dispatchDidPopStateWithinPage):
* WebCoreSupport/FrameLoaderClientQt.h:
(FrameLoaderClientQt):
* tests/qwebframe/tst_qwebframe.cpp:
(tst_QWebFrame):
(tst_QWebFrame::setUrlUsingStateObject): Added. Tests that the urlChanged signal is fired.

Modified Paths

Diff

Modified: trunk/Source/WebKit/qt/ChangeLog (125351 => 125352)


--- trunk/Source/WebKit/qt/ChangeLog	2012-08-11 10:44:53 UTC (rev 125351)
+++ trunk/Source/WebKit/qt/ChangeLog	2012-08-11 13:26:27 UTC (rev 125352)
@@ -1,3 +1,23 @@
+2012-08-11  Pierre Rossi  <[email protected]>
+
+        [Qt] Add support for HTML5 state object history API in FrameLoaderClientQt
+        https://bugs.webkit.org/show_bug.cgi?id=93648
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Add support for push/replace/pop by implementing dispatchDidNavigateWithinPage.
+
+        * WebCoreSupport/FrameLoaderClientQt.cpp:
+        (WebCore::FrameLoaderClientQt::dispatchDidNavigateWithinPage):
+        (WebCore::FrameLoaderClientQt::dispatchDidPushStateWithinPage):
+        (WebCore::FrameLoaderClientQt::dispatchDidReplaceStateWithinPage):
+        (WebCore::FrameLoaderClientQt::dispatchDidPopStateWithinPage):
+        * WebCoreSupport/FrameLoaderClientQt.h:
+        (FrameLoaderClientQt):
+        * tests/qwebframe/tst_qwebframe.cpp:
+        (tst_QWebFrame):
+        (tst_QWebFrame::setUrlUsingStateObject): Added. Tests that the urlChanged signal is fired.
+
 2012-08-10  Simon Hausmann  <[email protected]>
 
         [Qt] Remove QRegExp <> JS RegExp conversion

Modified: trunk/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp (125351 => 125352)


--- trunk/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp	2012-08-11 10:44:53 UTC (rev 125351)
+++ trunk/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp	2012-08-11 13:26:27 UTC (rev 125352)
@@ -372,7 +372,21 @@
     notImplemented();
 }
 
+void FrameLoaderClientQt::dispatchDidNavigateWithinPage()
+{
+    if (!m_webFrame)
+        return;
 
+    FrameLoader* loader = m_frame->loader();
+    bool loaderCompleted = !(loader->activeDocumentLoader() && loader->activeDocumentLoader()->isLoadingInAPISense());
+
+    if (!loaderCompleted)
+        return;
+
+    dispatchDidCommitLoad();
+    dispatchDidFinishLoad();
+}
+
 void FrameLoaderClientQt::dispatchDidChangeLocationWithinPage()
 {
     if (dumpFrameLoaderCallbacks)
@@ -391,7 +405,7 @@
     if (dumpFrameLoaderCallbacks)
         printf("%s - dispatchDidPushStateWithinPage\n", qPrintable(drtDescriptionSuitableForTestResult(m_frame)));
 
-    notImplemented();
+    dispatchDidNavigateWithinPage();
 }
 
 void FrameLoaderClientQt::dispatchDidReplaceStateWithinPage()
@@ -399,7 +413,7 @@
     if (dumpFrameLoaderCallbacks)
         printf("%s - dispatchDidReplaceStateWithinPage\n", qPrintable(drtDescriptionSuitableForTestResult(m_frame)));
 
-    notImplemented();
+    dispatchDidNavigateWithinPage();
 }
 
 void FrameLoaderClientQt::dispatchDidPopStateWithinPage()
@@ -407,7 +421,7 @@
     if (dumpFrameLoaderCallbacks)
         printf("%s - dispatchDidPopStateWithinPage\n", qPrintable(drtDescriptionSuitableForTestResult(m_frame)));
 
-    notImplemented();
+    // No need to call dispatchDidNavigateWithinPage here, it's already been done in loadInSameDocument().
 }
 
 void FrameLoaderClientQt::dispatchWillClose()

Modified: trunk/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h (125351 => 125352)


--- trunk/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h	2012-08-11 10:44:53 UTC (rev 125351)
+++ trunk/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h	2012-08-11 13:26:27 UTC (rev 125352)
@@ -108,6 +108,7 @@
     virtual void dispatchDidReceiveServerRedirectForProvisionalLoad();
     virtual void dispatchDidCancelClientRedirect();
     virtual void dispatchWillPerformClientRedirect(const KURL&, double interval, double fireDate);
+    virtual void dispatchDidNavigateWithinPage() OVERRIDE;
     virtual void dispatchDidChangeLocationWithinPage();
     virtual void dispatchDidPushStateWithinPage();
     virtual void dispatchDidReplaceStateWithinPage();

Modified: trunk/Source/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp (125351 => 125352)


--- trunk/Source/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp	2012-08-11 10:44:53 UTC (rev 125351)
+++ trunk/Source/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp	2012-08-11 13:26:27 UTC (rev 125352)
@@ -90,6 +90,7 @@
     void setUrlToEmpty();
     void setUrlToInvalid();
     void setUrlHistory();
+    void setUrlUsingStateObject();
     void setUrlSameUrl();
     void setUrlThenLoads_data();
     void setUrlThenLoads();
@@ -1309,6 +1310,48 @@
     QCOMPARE(m_page->history()->count(), 2);
 }
 
+void tst_QWebFrame::setUrlUsingStateObject()
+{
+    const QUrl aboutBlank("about:blank");
+    QUrl url;
+    QWebFrame* frame = m_page->mainFrame();
+    QSignalSpy urlChangedSpy(frame, SIGNAL(urlChanged(QUrl)));
+    int expectedUrlChangeCount = 0;
+
+    QCOMPARE(m_page->history()->count(), 0);
+
+    url = ""
+    frame->setUrl(url);
+    waitForSignal(m_page, SIGNAL(loadFinished(bool)));
+    expectedUrlChangeCount++;
+    QCOMPARE(urlChangedSpy.count(), expectedUrlChangeCount);
+    QCOMPARE(frame->url(), url);
+    QCOMPARE(m_page->history()->count(), 1);
+
+    frame->evaluateJavaScript("window.history.pushState(null,'push', 'navigate/to/here')");
+    expectedUrlChangeCount++;
+    QCOMPARE(urlChangedSpy.count(), expectedUrlChangeCount);
+    QCOMPARE(frame->url(), QUrl("qrc:/navigate/to/here"));
+    QCOMPARE(m_page->history()->count(), 2);
+    QVERIFY(m_page->history()->canGoBack());
+
+    frame->evaluateJavaScript("window.history.replaceState(null,'replace', 'another/location')");
+    expectedUrlChangeCount++;
+    QCOMPARE(urlChangedSpy.count(), expectedUrlChangeCount);
+    QCOMPARE(frame->url(), QUrl("qrc:/navigate/to/another/location"));
+    QCOMPARE(m_page->history()->count(), 2);
+    QVERIFY(!m_page->history()->canGoForward());
+    QVERIFY(m_page->history()->canGoBack());
+
+    frame->evaluateJavaScript("window.history.back()");
+    QTest::qWait(100);
+    expectedUrlChangeCount++;
+    QCOMPARE(urlChangedSpy.count(), expectedUrlChangeCount);
+    QCOMPARE(frame->url(), QUrl("qrc:/test1.html"));
+    QVERIFY(m_page->history()->canGoForward());
+    QVERIFY(!m_page->history()->canGoBack());
+}
+
 void tst_QWebFrame::setUrlSameUrl()
 {
     const QUrl url1("qrc:/test1.html");
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to