WebKitTestRunner needs testRunner.queueLoadingScript and testRunner.queueNonLoadingScript
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 22 Oct 2012 08:42:08 +0000 (08:42 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 22 Oct 2012 08:42:08 +0000 (08:42 +0000)
https://bugs.webkit.org/show_bug.cgi?id=42675

Patch by Mikhail Pozdnyakov <mikhail.pozdnyakov@intel.com> on 2012-10-22
Reviewed by Kenneth Rohde Christiansen.

Tools:

Added implementation of testRunner.queueLoadingScript and testRunner.queueNonLoadingScript.

* WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
* WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
(WTR::InjectedBundle::queueLoadingScript):
(WTR):
(WTR::InjectedBundle::queueNonLoadingScript):
* WebKitTestRunner/InjectedBundle/InjectedBundle.h:
(InjectedBundle):
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::queueLoadingScript):
(WTR):
(WTR::TestRunner::queueNonLoadingScript):
* WebKitTestRunner/InjectedBundle/TestRunner.h:
(TestRunner):
* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::didReceiveMessageFromInjectedBundle):
* WebKitTestRunner/WorkQueueManager.cpp:
(WTR):
(WTR::runJavaScriptFunction):
(ScriptItem):
(WTR::ScriptItem::ScriptItem):
(WTR::ScriptItem::invoke):
(WTR::WorkQueueManager::queueBackNavigation):
(WTR::WorkQueueManager::queueLoadingScript):
(WTR::WorkQueueManager::queueNonLoadingScript):
* WebKitTestRunner/WorkQueueManager.h:
(WorkQueueManager):

LayoutTests:

Unskipped corresponding test cases for WK2. Put those which still fail to appropriate
groups.

* platform/wk2/TestExpectations:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@132041 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/platform/wk2/TestExpectations
Tools/ChangeLog
Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl
Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp
Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h
Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
Tools/WebKitTestRunner/InjectedBundle/TestRunner.h
Tools/WebKitTestRunner/TestInvocation.cpp
Tools/WebKitTestRunner/WorkQueueManager.cpp
Tools/WebKitTestRunner/WorkQueueManager.h

index c7cf631..3d9fdb6 100644 (file)
@@ -1,3 +1,15 @@
+2012-10-22  Mikhail Pozdnyakov  <mikhail.pozdnyakov@intel.com>
+
+        WebKitTestRunner needs testRunner.queueLoadingScript and testRunner.queueNonLoadingScript
+        https://bugs.webkit.org/show_bug.cgi?id=42675
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Unskipped corresponding test cases for WK2. Put those which still fail to appropriate
+        groups.
+
+        * platform/wk2/TestExpectations:
+
 2012-10-22  Raphael Kubo da Costa  <raphael.kubo.da.costa@intel.com>
 
         [EFL] Rebaseline pixel expectations after r131941 and r131991, part 2.
index abaaecf..936263e 100644 (file)
@@ -293,34 +293,9 @@ svg/custom/manually-parsed-embedded-svg-allowed-in-dashboard.html
 svg/custom/manually-parsed-svg-allowed-in-dashboard.html
 svg/custom/svg-allowed-in-dashboard-object.html
 
-# WebKitTestRunner needs testRunner.queueNonLoadingScript
-# <https://bugs.webkit.org/show_bug.cgi?id=98141>
-http/tests/navigation/anchor-goback.html
-http/tests/navigation/error404-goback.html
-http/tests/navigation/javascriptlink-goback.html
-http/tests/navigation/metaredirect-goback.html
-http/tests/navigation/post-goback2.html
-http/tests/navigation/postredirect-basic.html
-http/tests/navigation/postredirect-frames.html
-http/tests/navigation/postredirect-goback1.html
-http/tests/navigation/postredirect-goback2.html
-http/tests/navigation/redirect302-goback.html
-http/tests/navigation/relativeanchor-basic.html
-http/tests/navigation/relativeanchor-frames.html
-http/tests/navigation/relativeanchor-goback.html
-http/tests/navigation/restore-form-state-https.html
-http/tests/navigation/success200-frames-loadsame.html
-http/tests/navigation/success200-goback.html
-http/tests/navigation/success200-loadsame.html
-http/tests/navigation/success200-reload.html
-http/tests/navigation/timerredirect-goback.html
-
-# WebKitTestRunner needs testRunner.queueLoadingScript
-# <https://bugs.webkit.org/show_bug.cgi?id=42675>
+# WebKitTestRunner needs testRunner.queueForwardNavigation
+# <https://bugs.webkit.org/show_bug.cgi?id=99700>
 http/tests/cache/subresource-failover-to-network.html
-http/tests/navigation/forward-and-cancel.html
-http/tests/navigation/post-goback-same-url.html
-http/tests/navigation/postredirect-reload.html
 
 # WebKitTestRunner needs layoutTestController.setCacheModel
 # <https://bugs.webkit.org/show_bug.cgi?id=42684>
@@ -749,6 +724,13 @@ http/tests/navigation/response204.html
 http/tests/navigation/success200-subframeload.html
 http/tests/navigation/timerredirect-subframeload.html
 
+# Redirected to unexpected page. Might be EFL port specific issue.
+http/tests/navigation/postredirect-basic.html
+http/tests/navigation/postredirect-goback1.html
+
+# Unexpected output from scrolling. Might be EFL port specific issue.
+http/tests/navigation/relativeanchor-frames.html
+
 ### END OF (2) Classified failures without bug reports (yet)
 ########################################
 
index e59e096..66f82c0 100644 (file)
@@ -1,3 +1,39 @@
+2012-10-22  Mikhail Pozdnyakov  <mikhail.pozdnyakov@intel.com>
+
+        WebKitTestRunner needs testRunner.queueLoadingScript and testRunner.queueNonLoadingScript
+        https://bugs.webkit.org/show_bug.cgi?id=42675
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Added implementation of testRunner.queueLoadingScript and testRunner.queueNonLoadingScript.
+
+        * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
+        * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
+        (WTR::InjectedBundle::queueLoadingScript):
+        (WTR):
+        (WTR::InjectedBundle::queueNonLoadingScript):
+        * WebKitTestRunner/InjectedBundle/InjectedBundle.h:
+        (InjectedBundle):
+        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
+        (WTR::TestRunner::queueLoadingScript):
+        (WTR):
+        (WTR::TestRunner::queueNonLoadingScript):
+        * WebKitTestRunner/InjectedBundle/TestRunner.h:
+        (TestRunner):
+        * WebKitTestRunner/TestInvocation.cpp:
+        (WTR::TestInvocation::didReceiveMessageFromInjectedBundle):
+        * WebKitTestRunner/WorkQueueManager.cpp:
+        (WTR):
+        (WTR::runJavaScriptFunction):
+        (ScriptItem):
+        (WTR::ScriptItem::ScriptItem):
+        (WTR::ScriptItem::invoke):
+        (WTR::WorkQueueManager::queueBackNavigation):
+        (WTR::WorkQueueManager::queueLoadingScript):
+        (WTR::WorkQueueManager::queueNonLoadingScript):
+        * WebKitTestRunner/WorkQueueManager.h:
+        (WorkQueueManager):
+
 2012-10-22  Zan Dobersek  <zandobersek@gmail.com>
 
         Unreviewed, a follow-up to r132034 where I forgot to address
index 81432da..f9f6199 100644 (file)
@@ -186,5 +186,7 @@ interface TestRunner {
     void queueBackNavigation(in unsigned long howFarBackward);
     void queueLoad(in DOMString url, in DOMString target);
     void queueReload();
+    void queueLoadingScript(in DOMString script);
+    void queueNonLoadingScript(in DOMString script);
 };
 
index 8ff713f..d64a734 100644 (file)
@@ -507,4 +507,20 @@ void InjectedBundle::queueReload()
     WKBundlePostMessage(m_bundle, messageName.get(), 0);
 }
 
+void InjectedBundle::queueLoadingScript(WKStringRef script)
+{
+    m_useWorkQueue = true;
+
+    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("QueueLoadingScript"));
+    WKBundlePostMessage(m_bundle, messageName.get(), script);
+}
+
+void InjectedBundle::queueNonLoadingScript(WKStringRef script)
+{
+    m_useWorkQueue = true;
+
+    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("QueueNonLoadingScript"));
+    WKBundlePostMessage(m_bundle, messageName.get(), script);
+}
+
 } // namespace WTR
index 0b89584..f3d2034 100644 (file)
@@ -104,6 +104,8 @@ public:
     void queueBackNavigation(unsigned howFarBackward);
     void queueLoad(WKStringRef url, WKStringRef target);
     void queueReload();
+    void queueLoadingScript(WKStringRef script);
+    void queueNonLoadingScript(WKStringRef script);
 
 private:
     InjectedBundle();
index 7400495..43a6c0e 100644 (file)
@@ -852,4 +852,16 @@ void TestRunner::queueReload()
     InjectedBundle::shared().queueReload();
 }
 
+void TestRunner::queueLoadingScript(JSStringRef script)
+{
+    WKRetainPtr<WKStringRef> scriptWK = toWK(script);
+    InjectedBundle::shared().queueLoadingScript(scriptWK.get());
+}
+
+void TestRunner::queueNonLoadingScript(JSStringRef script)
+{
+    WKRetainPtr<WKStringRef> scriptWK = toWK(script);
+    InjectedBundle::shared().queueNonLoadingScript(scriptWK.get());
+}
+
 } // namespace WTR
index 96d8220..f92e342 100644 (file)
@@ -265,6 +265,8 @@ public:
     void queueBackNavigation(unsigned howFarBackward);
     void queueLoad(JSStringRef url, JSStringRef target);
     void queueReload();
+    void queueLoadingScript(JSStringRef script);
+    void queueNonLoadingScript(JSStringRef script);
 
 private:
     static const double waitToDumpWatchdogTimerInterval;
index 040adb5..fd94232 100644 (file)
@@ -466,6 +466,20 @@ void TestInvocation::didReceiveMessageFromInjectedBundle(WKStringRef messageName
         return;
     }
 
+    if (WKStringIsEqualToUTF8CString(messageName, "QueueLoadingScript")) {
+        ASSERT(WKGetTypeID(messageBody) == WKStringGetTypeID());
+        WKStringRef script = static_cast<WKStringRef>(messageBody);
+        TestController::shared().workQueueManager().queueLoadingScript(toWTFString(script));
+        return;
+    }
+
+    if (WKStringIsEqualToUTF8CString(messageName, "QueueNonLoadingScript")) {
+        ASSERT(WKGetTypeID(messageBody) == WKStringGetTypeID());
+        WKStringRef script = static_cast<WKStringRef>(messageBody);
+        TestController::shared().workQueueManager().queueNonLoadingScript(toWTFString(script));
+        return;
+    }
+
     ASSERT_NOT_REACHED();
 }
 
index 1efa8ad..7383579 100644 (file)
@@ -29,6 +29,7 @@
 #include "PlatformWebView.h"
 #include "TestController.h"
 #include <WebKit2/WKPage.h>
+#include <WebKit2/WKRetainPtr.h>
 #include <wtf/PassOwnPtr.h>
 #include <wtf/text/CString.h>
 
@@ -53,11 +54,48 @@ static inline bool goToItemAtIndex(int index)
     return true;
 }
 
+class WorkQueueItem {
+public:
+    enum Type {
+        Loading,
+        NonLoading
+    };
+
+    virtual ~WorkQueueItem() { }
+    virtual Type invoke() const = 0;
+};
+
+// Required by WKPageRunJavaScriptInMainFrame().
+static void runJavaScriptFunction(WKSerializedScriptValueRef, WKErrorRef, void*)
+{
+}
+
+template <WorkQueueItem::Type type>
+class ScriptItem : public WorkQueueItem {
+public:
+    explicit ScriptItem(const String& script)
+        : m_script(AdoptWK, WKStringCreateWithUTF8CString(script.utf8().data()))
+    {
+    }
+
+    WorkQueueItem::Type invoke() const
+    {
+        WKPageRunJavaScriptInMainFrame(mainPage(), m_script.get(), 0, runJavaScriptFunction);
+        return type;
+    }
+
+    WKRetainPtr<WKStringRef> m_script;
+};
+
 WorkQueueManager::WorkQueueManager()
     : m_processing(false)
 {
 }
 
+WorkQueueManager::~WorkQueueManager()
+{
+}
+
 void WorkQueueManager::clearWorkQueue()
 {
     m_processing = false;
@@ -69,7 +107,7 @@ bool WorkQueueManager::processWorkQueue()
     m_processing = false;
     while (!m_processing && !m_workQueue.isEmpty()) {
         OwnPtr<WorkQueueItem> item(m_workQueue.takeFirst());
-        m_processing = item->invoke();
+        m_processing = (item->invoke() == WorkQueueItem::Loading);
     }
 
     return !m_processing;
@@ -85,15 +123,15 @@ void WorkQueueManager::queueLoad(const String& url, const String& target)
         {
         }
 
-        bool invoke() const
+        WorkQueueItem::Type invoke() const
         {
             if (!m_target.isEmpty()) {
                 // FIXME: Use target. Some layout tests cannot pass as they rely on this functionality.
                 fprintf(stderr, "queueLoad for a specific target is not implemented.\n");
-                return false;
+                return WorkQueueItem::NonLoading;
             }
             WKPageLoadURL(mainPage(), m_url.get());
-            return true;
+            return WorkQueueItem::Loading;
         }
 
         WKRetainPtr<WKURLRef> m_url;
@@ -107,9 +145,9 @@ void WorkQueueManager::queueBackNavigation(unsigned howFarBackward)
 {
     class BackNavigationItem : public WorkQueueItem {
     public:
-        BackNavigationItem(unsigned howFarBackward) : m_howFarBackward(howFarBackward) { }
+        explicit BackNavigationItem(unsigned howFarBackward) : m_howFarBackward(howFarBackward) { }
 
-        bool invoke() const { return goToItemAtIndex(-m_howFarBackward); }
+        WorkQueueItem::Type invoke() const { return goToItemAtIndex(-m_howFarBackward) ? WorkQueueItem::Loading : WorkQueueItem::NonLoading; }
 
         unsigned m_howFarBackward;
     };
@@ -121,16 +159,26 @@ void WorkQueueManager::queueReload()
 {
     class ReloadItem : public WorkQueueItem {
     public:
-        bool invoke() const
+        WorkQueueItem::Type invoke() const
         {
             WKPageReload(mainPage());
-            return true;
+            return WorkQueueItem::Loading;
         }
     };
 
     enqueue(new ReloadItem());
 }
 
+void WorkQueueManager::queueLoadingScript(const String& script)
+{
+    enqueue(new ScriptItem<WorkQueueItem::Loading>(script));
+}
+
+void WorkQueueManager::queueNonLoadingScript(const String& script)
+{
+    enqueue(new ScriptItem<WorkQueueItem::NonLoading>(script));
+}
+
 void WorkQueueManager::enqueue(WorkQueueItem* item)
 {
     ASSERT(item);
index 665c7ab..b9a22dd 100644 (file)
@@ -26,7 +26,6 @@
 #ifndef WorkQueueManager_h
 #define WorkQueueManager_h
 
-#include <WebKit2/WKRetainPtr.h>
 #include <wtf/Deque.h>
 #include <wtf/OwnPtr.h>
 #include <wtf/text/WTFString.h>
@@ -37,6 +36,7 @@ class WorkQueueManager {
     WTF_MAKE_NONCOPYABLE(WorkQueueManager);
 public:
     WorkQueueManager();
+    ~WorkQueueManager();
 
     bool isWorkQueueEmpty() const { return m_workQueue.isEmpty(); }
     void clearWorkQueue();
@@ -45,14 +45,11 @@ public:
     void queueLoad(const String& url, const String& target);
     void queueBackNavigation(unsigned howFarBackward);
     void queueReload();
+    void queueLoadingScript(const String& script);
+    void queueNonLoadingScript(const String& script);
 
-private:
-    class WorkQueueItem {
-    public:
-        virtual ~WorkQueueItem() { }
-        virtual bool invoke() const = 0; // Returns 'true' if this started a load.
-    };    
-    typedef Deque<OwnPtr<WorkQueueItem> > WorkQueue;
+private:    
+    typedef Deque<OwnPtr<class WorkQueueItem> > WorkQueue;
 
     void enqueue(WorkQueueItem*); // Adopts pointer.