diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-06-20 13:01:08 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-06-20 13:01:08 +0200 |
commit | 49233e234e5c787396cadb2cea33b31ae0cd65c1 (patch) | |
tree | 5410cb9a8fd53168bb60d62c54b654d86f03c38d /Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp | |
parent | b211c645d8ab690f713515dfdc84d80b11c27d2c (diff) | |
download | qtwebkit-49233e234e5c787396cadb2cea33b31ae0cd65c1.tar.gz |
Imported WebKit commit 3a8c29f35d00659d2ce7a0ccdfa8304f14e82327 (http://svn.webkit.org/repository/webkit/trunk@120813)
New snapshot with Windows build fixes
Diffstat (limited to 'Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp')
-rw-r--r-- | Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp index 6ede533d4..646752974 100644 --- a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp +++ b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp @@ -19,6 +19,8 @@ #include "config.h" #include "WebViewTest.h" +#include <JavaScriptCore/JSStringRef.h> +#include <JavaScriptCore/JSValueRef.h> #include <wtf/HashSet.h> #include <wtf/gobject/GRefPtr.h> #include <wtf/text/StringHash.h> @@ -278,15 +280,30 @@ public: g_main_loop_quit(test->m_mainLoop); } + static gboolean permissionRequested(WebKitWebView*, WebKitPermissionRequest* request, UIClientTest* test) + { + g_assert(WEBKIT_IS_PERMISSION_REQUEST(request)); + test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(request)); + + if (test->m_allowPermissionRequests) + webkit_permission_request_allow(request); + else + webkit_permission_request_deny(request); + + return TRUE; + } + UIClientTest() : m_scriptDialogType(WEBKIT_SCRIPT_DIALOG_ALERT) , m_scriptDialogConfirmed(true) + , m_allowPermissionRequests(false) , m_mouseTargetModifiers(0) { webkit_settings_set_javascript_can_open_windows_automatically(webkit_web_view_get_settings(m_webView), TRUE); g_signal_connect(m_webView, "create", G_CALLBACK(viewCreate), this); g_signal_connect(m_webView, "script-dialog", G_CALLBACK(scriptDialog), this); g_signal_connect(m_webView, "mouse-target-changed", G_CALLBACK(mouseTargetChanged), this); + g_signal_connect(m_webView, "permission-request", G_CALLBACK(permissionRequested), this); } ~UIClientTest() @@ -314,6 +331,7 @@ public: Vector<WebViewEvents> m_webViewEvents; WebKitScriptDialogType m_scriptDialogType; bool m_scriptDialogConfirmed; + bool m_allowPermissionRequests; WindowProperties m_windowProperties; HashSet<WTF::String> m_windowPropertiesChanged; GRefPtr<WebKitHitTestResult> m_mouseTargetHitTestResult; @@ -399,6 +417,7 @@ static void testWebViewMouseTarget(UIClientTest* test, gconstpointer) " <img style='position:absolute; left:1; top:10' src='0xdeadbeef' width=5 height=5></img>" " <a style='position:absolute; left:1; top:20' href='http://www.webkitgtk.org/logo' title='WebKitGTK+ Logo'><img src='0xdeadbeef' width=5 height=5></img></a>" " <video style='position:absolute; left:1; top:30' width=10 height=10 controls='controls'><source src='movie.ogg' type='video/ogg' /></video>" + " <input style='position:absolute; left:1; top:50' size='10'></input>" "</body></html>"; test->loadHtml(linksHoveredHTML, "file:///"); @@ -409,6 +428,7 @@ static void testWebViewMouseTarget(UIClientTest* test, gconstpointer) g_assert(webkit_hit_test_result_context_is_link(hitTestResult)); g_assert(!webkit_hit_test_result_context_is_image(hitTestResult)); g_assert(!webkit_hit_test_result_context_is_media(hitTestResult)); + g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult)); g_assert_cmpstr(webkit_hit_test_result_get_link_uri(hitTestResult), ==, "http://www.webkitgtk.org/"); g_assert_cmpstr(webkit_hit_test_result_get_link_title(hitTestResult), ==, "WebKitGTK+ Title"); g_assert_cmpstr(webkit_hit_test_result_get_link_label(hitTestResult), ==, "WebKitGTK+ Website"); @@ -419,6 +439,7 @@ static void testWebViewMouseTarget(UIClientTest* test, gconstpointer) g_assert(!webkit_hit_test_result_context_is_link(hitTestResult)); g_assert(!webkit_hit_test_result_context_is_image(hitTestResult)); g_assert(!webkit_hit_test_result_context_is_media(hitTestResult)); + g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult)); g_assert(!test->m_mouseTargetModifiers); // Move over image with GDK_CONTROL_MASK. @@ -426,6 +447,7 @@ static void testWebViewMouseTarget(UIClientTest* test, gconstpointer) g_assert(!webkit_hit_test_result_context_is_link(hitTestResult)); g_assert(webkit_hit_test_result_context_is_image(hitTestResult)); g_assert(!webkit_hit_test_result_context_is_media(hitTestResult)); + g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult)); g_assert_cmpstr(webkit_hit_test_result_get_image_uri(hitTestResult), ==, "file:///0xdeadbeef"); g_assert(test->m_mouseTargetModifiers & GDK_CONTROL_MASK); @@ -434,6 +456,7 @@ static void testWebViewMouseTarget(UIClientTest* test, gconstpointer) g_assert(webkit_hit_test_result_context_is_link(hitTestResult)); g_assert(webkit_hit_test_result_context_is_image(hitTestResult)); g_assert(!webkit_hit_test_result_context_is_media(hitTestResult)); + g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult)); g_assert_cmpstr(webkit_hit_test_result_get_link_uri(hitTestResult), ==, "http://www.webkitgtk.org/logo"); g_assert_cmpstr(webkit_hit_test_result_get_image_uri(hitTestResult), ==, "file:///0xdeadbeef"); g_assert_cmpstr(webkit_hit_test_result_get_link_title(hitTestResult), ==, "WebKitGTK+ Logo"); @@ -445,8 +468,53 @@ static void testWebViewMouseTarget(UIClientTest* test, gconstpointer) g_assert(!webkit_hit_test_result_context_is_link(hitTestResult)); g_assert(!webkit_hit_test_result_context_is_image(hitTestResult)); g_assert(webkit_hit_test_result_context_is_media(hitTestResult)); + g_assert(!webkit_hit_test_result_context_is_editable(hitTestResult)); g_assert_cmpstr(webkit_hit_test_result_get_media_uri(hitTestResult), ==, "file:///movie.ogg"); g_assert(!test->m_mouseTargetModifiers); + + // Mover over input. + hitTestResult = test->moveMouseAndWaitUntilMouseTargetChanged(5, 55); + g_assert(!webkit_hit_test_result_context_is_link(hitTestResult)); + g_assert(!webkit_hit_test_result_context_is_image(hitTestResult)); + g_assert(!webkit_hit_test_result_context_is_media(hitTestResult)); + g_assert(webkit_hit_test_result_context_is_editable(hitTestResult)); + g_assert(!test->m_mouseTargetModifiers); +} + +static void testWebViewPermissionRequests(UIClientTest* test, gconstpointer) +{ + test->showInWindowAndWaitUntilMapped(); + static const char* geolocationRequestHTML = + "<html>" + " <script>" + " function runTest()" + " {" + " navigator.geolocation.getCurrentPosition(function(p) { document.title = \"OK\" }," + " function(e) { document.title = e.code });" + " }" + " </script>" + " <body onload='runTest();'></body>" + "</html>"; + + // Test denying a permission request. + test->m_allowPermissionRequests = false; + test->loadHtml(geolocationRequestHTML, 0); + test->waitUntilTitleChanged(); + + // According to the Geolocation API specification, '1' is the + // error code returned for the PERMISSION_DENIED error. + // http://dev.w3.org/geo/api/spec-source.html#position_error_interface + const gchar* result = webkit_web_view_get_title(test->m_webView); + g_assert_cmpstr(result, ==, "1"); + + // Test allowing a permission request. + test->m_allowPermissionRequests = true; + test->loadHtml(geolocationRequestHTML, 0); + test->waitUntilTitleChanged(); + + // Check that we did not get the PERMISSION_DENIED error now. + result = webkit_web_view_get_title(test->m_webView); + g_assert_cmpstr(result, !=, "1"); } static void testWebViewZoomLevel(WebViewTest* test, gconstpointer) @@ -730,6 +798,7 @@ void beforeAll() UIClientTest::add("WebKitWebView", "javascript-dialogs", testWebViewJavaScriptDialogs); UIClientTest::add("WebKitWebView", "window-properties", testWebViewWindowProperties); UIClientTest::add("WebKitWebView", "mouse-target", testWebViewMouseTarget); + UIClientTest::add("WebKitWebView", "permission-requests", testWebViewPermissionRequests); WebViewTest::add("WebKitWebView", "zoom-level", testWebViewZoomLevel); WebViewTest::add("WebKitWebView", "run-javascript", testWebViewRunJavaScript); FileChooserTest::add("WebKitWebView", "file-chooser-request", testWebViewFileChooserRequest); |