Changeset 201505 in webkit


Ignore:
Timestamp:
May 31, 2016, 12:22:40 AM (9 years ago)
Author:
Carlos Garcia Campos
Message:

[GTK] Test /webkit2/WebKitWebView/geolocation-permission-requests is failing since r201423
https://bugs.webkit.org/show_bug.cgi?id=158200

Reviewed by Philippe Normand.

This is because geolocation is no longer allowed for non secure sites, like HTTP. In that case
POSITION_UNAVAILABLE is returned without asking the API layer.

  • TestWebKitAPI/Tests/WebKit2Gtk/TestUIClient.cpp:

(testWebViewGeolocationPermissionRequests): Keep the HTTP case to check that it indeed returns
POSITION_UNAVAILABLE and use HTTPS URLs to check permission requests are allowed or denied. Also stop using the
document title, and use user script messages that are more reliable instead.

Location:
trunk/Tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r201489 r201505  
     12016-05-31  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Test /webkit2/WebKitWebView/geolocation-permission-requests is failing since r201423
     4        https://bugs.webkit.org/show_bug.cgi?id=158200
     5
     6        Reviewed by Philippe Normand.
     7
     8        This is because geolocation is no longer allowed for non secure sites, like HTTP. In that case
     9        POSITION_UNAVAILABLE is returned without asking the API layer.
     10
     11        * TestWebKitAPI/Tests/WebKit2Gtk/TestUIClient.cpp:
     12        (testWebViewGeolocationPermissionRequests): Keep the HTTP case to check that it indeed returns
     13        POSITION_UNAVAILABLE and use HTTPS URLs to check permission requests are allowed or denied. Also stop using the
     14        document title, and use user script messages that are more reliable instead.
     15
    1162016-05-28  Aakash Jain  <aakash_jain@apple.com>
    217
  • trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestUIClient.cpp

    r199653 r201505  
    226226    }
    227227
     228    static void permissionResultMessageReceivedCallback(WebKitUserContentManager* userContentManager, WebKitJavascriptResult* javascriptResult, UIClientTest* test)
     229    {
     230        test->m_permissionResult.reset(WebViewTest::javascriptResultToCString(javascriptResult));
     231        g_main_loop_quit(test->m_mainLoop);
     232    }
     233
    228234    UIClientTest()
    229         : m_scriptDialogType(WEBKIT_SCRIPT_DIALOG_ALERT)
     235        : WebViewTest(webkit_user_content_manager_new())
     236        , m_scriptDialogType(WEBKIT_SCRIPT_DIALOG_ALERT)
    230237        , m_scriptDialogConfirmed(true)
    231238        , m_allowPermissionRequests(false)
     
    240247        g_signal_connect(m_webView, "mouse-target-changed", G_CALLBACK(mouseTargetChanged), this);
    241248        g_signal_connect(m_webView, "permission-request", G_CALLBACK(permissionRequested), this);
     249        WebKitUserContentManager* manager = webkit_web_view_get_user_content_manager(m_webView);
     250        webkit_user_content_manager_register_script_message_handler(manager, "permission");
     251        g_signal_connect(manager, "script-message-received::permission", G_CALLBACK(permissionResultMessageReceivedCallback), this);
    242252    }
    243253
     
    245255    {
    246256        g_signal_handlers_disconnect_matched(m_webView, G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this);
     257        WebKitUserContentManager* manager = webkit_web_view_get_user_content_manager(m_webView);
     258        g_signal_handlers_disconnect_matched(manager, G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this);
     259        webkit_user_content_manager_unregister_script_message_handler(manager, "permission");
    247260    }
    248261
     
    268281    {
    269282        g_main_loop_run(m_mainLoop);
     283    }
     284
     285    const char* waitUntilPermissionResultMessageReceived()
     286    {
     287        m_permissionResult = nullptr;
     288        g_main_loop_run(m_mainLoop);
     289        return m_permissionResult.get();
    270290    }
    271291
     
    337357    GRefPtr<WebKitHitTestResult> m_mouseTargetHitTestResult;
    338358    unsigned m_mouseTargetModifiers;
     359    GUniquePtr<char> m_permissionResult;
    339360};
    340361
     
    723744        "  function runTest()"
    724745        "  {"
    725         "    navigator.geolocation.getCurrentPosition(function(p) { document.title = \"OK\" },"
    726         "                                             function(e) { document.title = e.code });"
     746        "    navigator.geolocation.getCurrentPosition(function(p) { window.webkit.messageHandlers.permission.postMessage('OK'); },"
     747        "                                             function(e) { window.webkit.messageHandlers.permission.postMessage(e.code.toString()); });"
    727748        "  }"
    728749        "  </script>"
     
    730751        "</html>";
    731752
    732     // Test denying a permission request.
     753    // Geolocation is not allowed from insecure connections like HTTP,
     754    // POSITION_UNAVAILABLE ('2') is returned in that case without even
     755    // asking the API layer.
    733756    test->m_allowPermissionRequests = false;
    734757    test->loadHtml(geolocationRequestHTML, "http://foo.com/bar");
    735     test->waitUntilTitleChanged();
    736 
    737     // According to the Geolocation API specification, '1' is the
    738     // error code returned for the PERMISSION_DENIED error.
    739     // http://dev.w3.org/geo/api/spec-source.html#position_error_interface
    740     const gchar* result = webkit_web_view_get_title(test->m_webView);
     758    const gchar* result = test->waitUntilPermissionResultMessageReceived();
     759    g_assert_cmpstr(result, ==, "2");
     760
     761    // Test denying a permission request. PERMISSION_DENIED ('1') is
     762    // returned in this case.
     763    test->m_allowPermissionRequests = false;
     764    test->loadHtml(geolocationRequestHTML, "https://foo.com/bar");
     765    result = test->waitUntilPermissionResultMessageReceived();
    741766    g_assert_cmpstr(result, ==, "1");
    742767
    743     // Test allowing a permission request.
     768    // Test allowing a permission request. Result should be different
     769    // to PERMISSION_DENIED ('1').
    744770    test->m_allowPermissionRequests = true;
    745     test->loadHtml(geolocationRequestHTML, 0);
    746     test->waitUntilTitleChanged();
    747 
    748     // Check that we did not get the PERMISSION_DENIED error now.
    749     result = webkit_web_view_get_title(test->m_webView);
     771    test->loadHtml(geolocationRequestHTML, "https://foo.com/bar");
     772    result = test->waitUntilPermissionResultMessageReceived();
    750773    g_assert_cmpstr(result, !=, "1");
    751774    test->addLogFatalFlag(G_LOG_LEVEL_WARNING);
Note: See TracChangeset for help on using the changeset viewer.