Title: [233576] trunk/Tools
Revision
233576
Author
[email protected]
Date
2018-07-06 03:51:33 -0700 (Fri, 06 Jul 2018)

Log Message

[GTK][WPE] REGRESSION(r233111): Test /webkit/WebKitUserContentManager/script-message-received fails
https://bugs.webkit.org/show_bug.cgi?id=187383

Reviewed by Žan Doberšek.

This is actually a problem in the test itself. The problem is that we run js, connect to message-received and
quite the main loop when the message is received, which happens before the run js operation has been
completed. The test finishes early and since r233111 an IPC message is still pending (I guess the run js
callback) and the web page is still protected. Just adding a run loop operation before finishing the test would
fix it. We should wait for the js run to complete, instead of the message.

* TestWebKitAPI/Tests/WebKitGLib/TestWebKitUserContentManager.cpp:
(UserScriptMessageTest::scriptMessageReceived):
(UserScriptMessageTest::waitUntilMessageReceived):
(UserScriptMessageTest::runJavaScriptFinished):
(UserScriptMessageTest::postMessageAndWaitUntilReceived):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (233575 => 233576)


--- trunk/Tools/ChangeLog	2018-07-06 10:38:46 UTC (rev 233575)
+++ trunk/Tools/ChangeLog	2018-07-06 10:51:33 UTC (rev 233576)
@@ -1,3 +1,22 @@
+2018-07-06  Carlos Garcia Campos  <[email protected]>
+
+        [GTK][WPE] REGRESSION(r233111): Test /webkit/WebKitUserContentManager/script-message-received fails
+        https://bugs.webkit.org/show_bug.cgi?id=187383
+
+        Reviewed by Žan Doberšek.
+
+        This is actually a problem in the test itself. The problem is that we run js, connect to message-received and
+        quite the main loop when the message is received, which happens before the run js operation has been
+        completed. The test finishes early and since r233111 an IPC message is still pending (I guess the run js
+        callback) and the web page is still protected. Just adding a run loop operation before finishing the test would
+        fix it. We should wait for the js run to complete, instead of the message.
+
+        * TestWebKitAPI/Tests/WebKitGLib/TestWebKitUserContentManager.cpp:
+        (UserScriptMessageTest::scriptMessageReceived):
+        (UserScriptMessageTest::waitUntilMessageReceived):
+        (UserScriptMessageTest::runJavaScriptFinished):
+        (UserScriptMessageTest::postMessageAndWaitUntilReceived):
+
 2018-07-05  Youenn Fablet  <[email protected]>
 
         REGRESSION (r230843): Flash doesn't work; Produces blue box on page

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitUserContentManager.cpp (233575 => 233576)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitUserContentManager.cpp	2018-07-06 10:38:46 UTC (rev 233575)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitUserContentManager.cpp	2018-07-06 10:51:33 UTC (rev 233576)
@@ -222,7 +222,8 @@
     static void scriptMessageReceived(WebKitUserContentManager* userContentManager, WebKitJavascriptResult* jsResult, UserScriptMessageTest* test)
     {
         g_signal_handlers_disconnect_by_func(userContentManager, reinterpret_cast<gpointer>(scriptMessageReceived), test);
-        g_main_loop_quit(test->m_mainLoop);
+        if (!test->m_waitForScriptRun)
+            g_main_loop_quit(test->m_mainLoop);
 
         g_assert(!test->m_userScriptMessage);
         test->m_userScriptMessage = webkit_javascript_result_ref(jsResult);
@@ -239,19 +240,29 @@
         g_signal_connect(m_userContentManager.get(), signalName.get(), G_CALLBACK(scriptMessageReceived), this);
 
         g_main_loop_run(m_mainLoop);
+        g_assert(!m_waitForScriptRun);
         g_assert(m_userScriptMessage);
         return m_userScriptMessage;
     }
 
+    static void runJavaScriptFinished(GObject*, GAsyncResult* result, UserScriptMessageTest* test)
+    {
+        g_assert(test->m_waitForScriptRun);
+        test->m_waitForScriptRun = false;
+        g_main_loop_quit(test->m_mainLoop);
+    }
+
     WebKitJavascriptResult* postMessageAndWaitUntilReceived(const char* handlerName, const char* _javascript_ValueAsText)
     {
         GUniquePtr<char> _javascript_Snippet(g_strdup_printf("window.webkit.messageHandlers.%s.postMessage(%s);", handlerName, _javascript_ValueAsText));
-        webkit_web_view_run_javascript(m_webView, _javascript_Snippet.get(), nullptr, nullptr, nullptr);
+        m_waitForScriptRun = true;
+        webkit_web_view_run_javascript(m_webView, _javascript_Snippet.get(), nullptr, reinterpret_cast<GAsyncReadyCallback>(runJavaScriptFinished), this);
         return waitUntilMessageReceived(handlerName);
     }
 
 private:
     WebKitJavascriptResult* m_userScriptMessage;
+    bool m_waitForScriptRun { false };
 };
 
 static void testUserContentManagerScriptMessageReceived(UserScriptMessageTest* test, gconstpointer)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to