Diff
Modified: trunk/Tools/ChangeLog (178643 => 178644)
--- trunk/Tools/ChangeLog 2015-01-19 11:21:41 UTC (rev 178643)
+++ trunk/Tools/ChangeLog 2015-01-19 13:33:58 UTC (rev 178644)
@@ -1,3 +1,24 @@
+2015-01-19 Carlos Garcia Campos <cgar...@igalia.com>
+
+ [GTK] [WK2] TestWebKitWebView snapshot fails
+ https://bugs.webkit.org/show_bug.cgi?id=120404
+
+ Reviewed by Žan Doberšek.
+
+ Rework the test to make sure the snapshot is always created at the
+ desired size.
+
+ * Scripts/run-gtk-tests:
+ (TestRunner): Unskip /webkit2/WebKitWebView/snapshot.
+ * TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebView.cpp:
+ (testWebViewSnapshot): Use a fixed size for the document, and
+ disable scrollbars to make sure the visible area is always the
+ WebView size.
+ * TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.cpp:
+ (WebViewTest::showInWindowAndWaitUntilMapped): Add optional width
+ and height parameters to create the window with a given size.
+ * TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.h:
+
2015-01-18 David Kilzer <ddkil...@apple.com>
iOS EWS queue name should be consistent
Modified: trunk/Tools/Scripts/run-gtk-tests (178643 => 178644)
--- trunk/Tools/Scripts/run-gtk-tests 2015-01-19 11:21:41 UTC (rev 178643)
+++ trunk/Tools/Scripts/run-gtk-tests 2015-01-19 13:33:58 UTC (rev 178644)
@@ -64,7 +64,6 @@
SkippedTest("WebKit2Gtk/TestUIClient", "/webkit2/WebKitWebView/mouse-target", "Test times out after r150890", 117689),
SkippedTest("WebKit2Gtk/TestContextMenu", SkippedTest.ENTIRE_SUITE, "Test times out after r150890", 117689),
SkippedTest("WebKit2APITests/TestWebKitAccessibility", "/webkit2/WebKitAccessibility/atspi-basic-hierarchy", "Test is flaky", 132134),
- SkippedTest("WebKit2Gtk/TestWebKitWebView", "/webkit2/WebKitWebView/snapshot", "Test fails", 120404),
SkippedTest("WebKit2Gtk/TestWebKitWebView", "/webkit2/WebKitWebView/page-visibility", "Test fails or times out", 131731),
SkippedTest("WebKit2Gtk/TestCookieManager", "/webkit2/WebKitCookieManager/persistent-storage", "Test is flaky", 134580),
SkippedTest("WebKit2/TestWebKit2", "WebKit2.MouseMoveAfterCrash", "Test is flaky", 85066),
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebView.cpp (178643 => 178644)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebView.cpp 2015-01-19 11:21:41 UTC (rev 178643)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebView.cpp 2015-01-19 13:33:58 UTC (rev 178644)
@@ -546,59 +546,44 @@
static void testWebViewSnapshot(SnapshotWebViewTest* test, gconstpointer)
{
- test->loadHtml("<html><body><p>Whatever</p></body></html>", 0);
+ test->loadHtml("<html><head><style>html { width: 200px; height: 100px; } ::-webkit-scrollbar { display: none; }</style></head><body><p>Whatever</p></body></html>", nullptr);
test->waitUntilLoadFinished();
- // WebView not visible.
+ // WEBKIT_SNAPSHOT_REGION_VISIBLE returns a null surface when the view is not visible.
cairo_surface_t* surface1 = test->getSnapshotAndWaitUntilReady(WEBKIT_SNAPSHOT_REGION_VISIBLE, WEBKIT_SNAPSHOT_OPTIONS_NONE);
g_assert(!surface1);
- // Show surface, resize to 50x50, try again.
- test->showInWindowAndWaitUntilMapped();
- test->resizeView(50, 50);
- surface1 = test->getSnapshotAndWaitUntilReady(WEBKIT_SNAPSHOT_REGION_VISIBLE, WEBKIT_SNAPSHOT_OPTIONS_NONE);
+ // WEBKIT_SNAPSHOT_REGION_FULL_DOCUMENT works even if the window is not visible.
+ surface1 = test->getSnapshotAndWaitUntilReady(WEBKIT_SNAPSHOT_REGION_FULL_DOCUMENT, WEBKIT_SNAPSHOT_OPTIONS_NONE);
g_assert(surface1);
+ g_assert_cmpuint(cairo_surface_get_type(surface1), ==, CAIRO_SURFACE_TYPE_IMAGE);
+ g_assert_cmpint(cairo_image_surface_get_width(surface1), ==, 200);
+ g_assert_cmpint(cairo_image_surface_get_height(surface1), ==, 100);
- // obtained surface should be at the most 50x50. Store the size
- // for comparison later.
- int width = cairo_image_surface_get_width(surface1);
- int height = cairo_image_surface_get_height(surface1);
- g_assert_cmpint(width, <=, 50);
- g_assert_cmpint(height, <=, 50);
-
- // Select all text in the WebView, request a snapshot ignoring selection.
- test->selectAll();
+ // Show the WebView in a popup widow of 50x50 and try again with WEBKIT_SNAPSHOT_REGION_VISIBLE.
+ test->showInWindowAndWaitUntilMapped(GTK_WINDOW_POPUP, 50, 50);
surface1 = cairo_surface_reference(test->getSnapshotAndWaitUntilReady(WEBKIT_SNAPSHOT_REGION_VISIBLE, WEBKIT_SNAPSHOT_OPTIONS_NONE));
g_assert(surface1);
- g_assert_cmpint(cairo_image_surface_get_width(surface1), ==, width);
- g_assert_cmpint(cairo_image_surface_get_height(surface1), ==, height);
+ g_assert_cmpuint(cairo_surface_get_type(surface1), ==, CAIRO_SURFACE_TYPE_IMAGE);
+ g_assert_cmpint(cairo_image_surface_get_width(surface1), ==, 50);
+ g_assert_cmpint(cairo_image_surface_get_height(surface1), ==, 50);
- // Create identical surface.
+ // Select all text in the WebView, request a snapshot ignoring selection.
+ test->selectAll();
cairo_surface_t* surface2 = test->getSnapshotAndWaitUntilReady(WEBKIT_SNAPSHOT_REGION_VISIBLE, WEBKIT_SNAPSHOT_OPTIONS_NONE);
g_assert(surface2);
-
- // Compare these two, they should be identical.
g_assert(Test::cairoSurfacesEqual(surface1, surface2));
- // Request a new snapshot, including the selection this time. The
- // size should be the same but the result must be different to the
- // one previously obtained.
+ // Request a new snapshot, including the selection this time. The size should be the same but the result
+ // must be different to the one previously obtained.
surface2 = test->getSnapshotAndWaitUntilReady(WEBKIT_SNAPSHOT_REGION_VISIBLE, WEBKIT_SNAPSHOT_OPTIONS_INCLUDE_SELECTION_HIGHLIGHTING);
- g_assert(surface2);
- g_assert_cmpint(cairo_image_surface_get_width(surface2), ==, width);
- g_assert_cmpint(cairo_image_surface_get_height(surface2), ==, height);
+ g_assert_cmpuint(cairo_surface_get_type(surface2), ==, CAIRO_SURFACE_TYPE_IMAGE);
+ g_assert_cmpint(cairo_image_surface_get_width(surface1), ==, cairo_image_surface_get_width(surface2));
+ g_assert_cmpint(cairo_image_surface_get_height(surface1), ==, cairo_image_surface_get_height(surface2));
g_assert(!Test::cairoSurfacesEqual(surface1, surface2));
-
- // Request a snapshot of the whole document in the WebView. The
- // result should be different from the size obtained previously.
- surface2 = test->getSnapshotAndWaitUntilReady(WEBKIT_SNAPSHOT_REGION_FULL_DOCUMENT, WEBKIT_SNAPSHOT_OPTIONS_NONE);
- g_assert(surface2);
- g_assert_cmpint(cairo_image_surface_get_width(surface2), >, width);
- g_assert_cmpint(cairo_image_surface_get_height(surface2), >, height);
- g_assert(!Test::cairoSurfacesEqual(surface1, surface2));
-
cairo_surface_destroy(surface1);
+ // Test that cancellation works.
g_assert(test->getSnapshotAndCancel());
}
Modified: trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.cpp (178643 => 178644)
--- trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.cpp 2015-01-19 11:21:41 UTC (rev 178643)
+++ trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.cpp 2015-01-19 13:33:58 UTC (rev 178644)
@@ -232,10 +232,12 @@
gtk_widget_show(m_parentWindow);
}
-void WebViewTest::showInWindowAndWaitUntilMapped(GtkWindowType windowType)
+void WebViewTest::showInWindowAndWaitUntilMapped(GtkWindowType windowType, int width, int height)
{
g_assert(!m_parentWindow);
m_parentWindow = gtk_window_new(windowType);
+ if (width && height)
+ gtk_window_resize(GTK_WINDOW(m_parentWindow), width, height);
gtk_container_add(GTK_CONTAINER(m_parentWindow), GTK_WIDGET(m_webView));
gtk_widget_show(GTK_WIDGET(m_webView));
Modified: trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.h (178643 => 178644)
--- trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.h 2015-01-19 11:21:41 UTC (rev 178643)
+++ trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.h 2015-01-19 13:33:58 UTC (rev 178644)
@@ -48,7 +48,7 @@
void waitUntilTitleChangedTo(const char* expectedTitle);
void waitUntilTitleChanged();
void showInWindow(GtkWindowType = GTK_WINDOW_POPUP);
- void showInWindowAndWaitUntilMapped(GtkWindowType = GTK_WINDOW_POPUP);
+ void showInWindowAndWaitUntilMapped(GtkWindowType = GTK_WINDOW_POPUP, int width = 0, int height = 0);
void resizeView(int width, int height);
void selectAll();
const char* mainResourceData(size_t& mainResourceDataSize);