Changeset 201505 in webkit
- Timestamp:
- May 31, 2016, 12:22:40 AM (9 years ago)
- Location:
- trunk/Tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r201489 r201505 1 2016-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 1 16 2016-05-28 Aakash Jain <aakash_jain@apple.com> 2 17 -
trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestUIClient.cpp
r199653 r201505 226 226 } 227 227 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 228 234 UIClientTest() 229 : m_scriptDialogType(WEBKIT_SCRIPT_DIALOG_ALERT) 235 : WebViewTest(webkit_user_content_manager_new()) 236 , m_scriptDialogType(WEBKIT_SCRIPT_DIALOG_ALERT) 230 237 , m_scriptDialogConfirmed(true) 231 238 , m_allowPermissionRequests(false) … … 240 247 g_signal_connect(m_webView, "mouse-target-changed", G_CALLBACK(mouseTargetChanged), this); 241 248 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); 242 252 } 243 253 … … 245 255 { 246 256 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"); 247 260 } 248 261 … … 268 281 { 269 282 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(); 270 290 } 271 291 … … 337 357 GRefPtr<WebKitHitTestResult> m_mouseTargetHitTestResult; 338 358 unsigned m_mouseTargetModifiers; 359 GUniquePtr<char> m_permissionResult; 339 360 }; 340 361 … … 723 744 " function runTest()" 724 745 " {" 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()); });" 727 748 " }" 728 749 " </script>" … … 730 751 "</html>"; 731 752 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. 733 756 test->m_allowPermissionRequests = false; 734 757 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(); 741 766 g_assert_cmpstr(result, ==, "1"); 742 767 743 // Test allowing a permission request. 768 // Test allowing a permission request. Result should be different 769 // to PERMISSION_DENIED ('1'). 744 770 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(); 750 773 g_assert_cmpstr(result, !=, "1"); 751 774 test->addLogFatalFlag(G_LOG_LEVEL_WARNING);
Note:
See TracChangeset
for help on using the changeset viewer.