⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 233576 in webkit


Ignore:
Timestamp:
Jul 6, 2018, 3:51:33 AM (8 years ago)
Author:
Carlos Garcia Campos
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):

Location:
trunk/Tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r233563 r233576  
     12018-07-06  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK][WPE] REGRESSION(r233111): Test /webkit/WebKitUserContentManager/script-message-received fails
     4        https://bugs.webkit.org/show_bug.cgi?id=187383
     5
     6        Reviewed by Žan Doberšek.
     7
     8        This is actually a problem in the test itself. The problem is that we run js, connect to message-received and
     9        quite the main loop when the message is received, which happens before the run js operation has been
     10        completed. The test finishes early and since r233111 an IPC message is still pending (I guess the run js
     11        callback) and the web page is still protected. Just adding a run loop operation before finishing the test would
     12        fix it. We should wait for the js run to complete, instead of the message.
     13
     14        * TestWebKitAPI/Tests/WebKitGLib/TestWebKitUserContentManager.cpp:
     15        (UserScriptMessageTest::scriptMessageReceived):
     16        (UserScriptMessageTest::waitUntilMessageReceived):
     17        (UserScriptMessageTest::runJavaScriptFinished):
     18        (UserScriptMessageTest::postMessageAndWaitUntilReceived):
     19
    1202018-07-05  Youenn Fablet  <youenn@apple.com>
    221
  • trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitUserContentManager.cpp

    r225044 r233576  
    223223    {
    224224        g_signal_handlers_disconnect_by_func(userContentManager, reinterpret_cast<gpointer>(scriptMessageReceived), test);
    225         g_main_loop_quit(test->m_mainLoop);
     225        if (!test->m_waitForScriptRun)
     226            g_main_loop_quit(test->m_mainLoop);
    226227
    227228        g_assert(!test->m_userScriptMessage);
    … …  
    240241
    241242        g_main_loop_run(m_mainLoop);
     243        g_assert(!m_waitForScriptRun);
    242244        g_assert(m_userScriptMessage);
    243245        return m_userScriptMessage;
    244246    }
    245247
     248    static void runJavaScriptFinished(GObject*, GAsyncResult* result, UserScriptMessageTest* test)
     249    {
     250        g_assert(test->m_waitForScriptRun);
     251        test->m_waitForScriptRun = false;
     252        g_main_loop_quit(test->m_mainLoop);
     253    }
     254
    246255    WebKitJavascriptResult* postMessageAndWaitUntilReceived(const char* handlerName, const char* javascriptValueAsText)
    247256    {
    248257        GUniquePtr<char> javascriptSnippet(g_strdup_printf("window.webkit.messageHandlers.%s.postMessage(%s);", handlerName, javascriptValueAsText));
    249         webkit_web_view_run_javascript(m_webView, javascriptSnippet.get(), nullptr, nullptr, nullptr);
     258        m_waitForScriptRun = true;
     259        webkit_web_view_run_javascript(m_webView, javascriptSnippet.get(), nullptr, reinterpret_cast<GAsyncReadyCallback>(runJavaScriptFinished), this);
    250260        return waitUntilMessageReceived(handlerName);
    251261    }
    … …  
    253263private:
    254264    WebKitJavascriptResult* m_userScriptMessage;
     265    bool m_waitForScriptRun { false };
    255266};
    256267
Note: See TracChangeset for help on using the changeset viewer.