Commit 41e5cc3b authored by mario@webkit.org's avatar mario@webkit.org

[GTK] Add support for Page Visibility

https://bugs.webkit.org/show_bug.cgi?id=97324

Patch by Anton Obzhirov <a.obzhirov@samsung.com> on 2013-04-10
Reviewed by Sam Weinig.

.:

Page Visibility has been enabled for GTK port.
New GTK unittest has been added.

* Source/autotools/SetupWebKitFeatures.m4:

Source/WebKit/gtk:

Implemented access to page visibility API for GTK test runner.

* WebCoreSupport/DumpRenderTreeSupportGtk.cpp:
(DumpRenderTreeSupportGtk::setPageVisibility):
* WebCoreSupport/DumpRenderTreeSupportGtk.h:

Source/WebKit2:

Added new unittest to test page visibility using GTK Widget visibility API.

* UIProcess/API/gtk/tests/TestWebKitWebView.cpp:
(testWebViewPageVisibility):
(beforeAll):
* UIProcess/API/gtk/tests/WebViewTest.cpp:
(WebViewTest::showInWindow):
* UIProcess/API/gtk/tests/WebViewTest.h:

Tools:

Implemented test runner API for page visibility layout tests.

* DumpRenderTree/gtk/TestRunnerGtk.cpp:
(TestRunner::resetPageVisibility):
(TestRunner::setPageVisibility):
* Scripts/webkitperl/FeatureList.pm:

LayoutTests:

* platform/gtk/TestExpectations:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@148088 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 13fcde37
2013-04-10 Anton Obzhirov <a.obzhirov@samsung.com>
[GTK] Add support for Page Visibility
https://bugs.webkit.org/show_bug.cgi?id=97324
Reviewed by Sam Weinig.
Page Visibility has been enabled for GTK port.
New GTK unittest has been added.
* Source/autotools/SetupWebKitFeatures.m4:
2013-04-09 Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com>
[EFL] Declare TEST_THEME_DIR in a single place.
......
2013-04-10 Anton Obzhirov <a.obzhirov@samsung.com>
[GTK] Add support for Page Visibility
https://bugs.webkit.org/show_bug.cgi?id=97324
Reviewed by Sam Weinig.
* platform/gtk/TestExpectations:
2013-04-10 Zoltan Arvai <zarvai@inf.u-szeged.hu>
[Qt] Unreviewed gardening. Rebaselining after r148049.
......@@ -242,13 +242,6 @@ webkit.org/b/98942 storage/storagequota-request-quota.html [ Failure ]
webkit.org/b/98942 fast/workers/worker-storagequota-query-usage.html [ Failure ]
webkit.org/b/98942 fast/workers/shared-worker-storagequota-query-usage.html [ Failure ]
# This platform does not support the Page Visibility API.
webkit.org/b/97324 fast/events/page-visibility-iframe-delete-test.html [ Skip ]
webkit.org/b/97324 fast/events/page-visibility-iframe-move-test.html [ Skip ]
webkit.org/b/97324 fast/events/page-visibility-iframe-propagation-test.html [ Skip ]
webkit.org/b/97324 fast/events/page-visibility-null-view.html [ Skip ]
webkit.org/b/97324 fast/events/page-visibility-transition-test.html [ Skip ]
# GTK doesn't support smart replace.
webkit.org/b/61661 editing/pasteboard/drag-drop-list.html [ Failure ]
......
2013-04-10 Anton Obzhirov <a.obzhirov@samsung.com>
[GTK] Add support for Page Visibility
https://bugs.webkit.org/show_bug.cgi?id=97324
Reviewed by Sam Weinig.
Implemented access to page visibility API for GTK test runner.
* WebCoreSupport/DumpRenderTreeSupportGtk.cpp:
(DumpRenderTreeSupportGtk::setPageVisibility):
* WebCoreSupport/DumpRenderTreeSupportGtk.h:
2013-04-08 Carlos Garcia Campos <cgarcia@igalia.com>
[GTK] DOM objects created wrapping a base class have incorrect GObject type
......
......@@ -739,3 +739,14 @@ void DumpRenderTreeSupportGtk::setAuthenticationCallback(AuthenticationCallback
{
s_authenticationCallback = authenticationCallback;
}
void DumpRenderTreeSupportGtk::setPageVisibility(WebKitWebView* webView, WebCore::PageVisibilityState visibilityState, bool isInitialState)
{
#if ENABLE(PAGE_VISIBILITY_API)
Page* page = core(webView);
if (!page)
return;
page->setVisibilityState(visibilityState, isInitialState);
#endif
}
......@@ -21,6 +21,7 @@
#define DumpRenderTreeSupportGtk_h
#include "JSStringRef.h"
#include "PageVisibilityState.h"
#include <atk/atk.h>
#include <glib.h>
#include <webkit/webkitdefines.h>
......@@ -138,6 +139,7 @@ public:
typedef bool (*AuthenticationCallback) (CString& username, CString& password);
static void setAuthenticationCallback(AuthenticationCallback);
static AuthenticationCallback s_authenticationCallback;
static void setPageVisibility(WebKitWebView*, WebCore::PageVisibilityState, bool);
private:
static bool s_drtRun;
......
2013-04-10 Anton Obzhirov <a.obzhirov@samsung.com>
[GTK] Add support for Page Visibility
https://bugs.webkit.org/show_bug.cgi?id=97324
Reviewed by Sam Weinig.
Added new unittest to test page visibility using GTK Widget visibility API.
* UIProcess/API/gtk/tests/TestWebKitWebView.cpp:
(testWebViewPageVisibility):
(beforeAll):
* UIProcess/API/gtk/tests/WebViewTest.cpp:
(WebViewTest::showInWindow):
* UIProcess/API/gtk/tests/WebViewTest.h:
2013-04-10 Zan Dobersek <zdobersek@igalia.com>
REGRESSION (r146518): WebKit2APITests/TestInspector is failing
......@@ -1085,6 +1085,67 @@ static void testWebViewMode(WebViewTest* test, gconstpointer)
g_assert_cmpstr(valueString.get(), ==, indexHTML);
}
// To test page visibility API. Currently only 'visible' and 'hidden' states are implemented fully in WebCore.
// See also http://www.w3.org/TR/2011/WD-page-visibility-20110602/ and https://developers.google.com/chrome/whitepapers/pagevisibility
static void testWebViewPageVisibility(WebViewTest* test, gconstpointer)
{
test->loadHtml("<html><title></title>"
"<body><p>Test Web Page Visibility</p>"
"<script>"
"document.addEventListener(\"webkitvisibilitychange\", onVisibilityChange, false);"
"function onVisibilityChange() {"
" document.title = document.webkitVisibilityState;"
"}"
"</script>"
"</body></html>",
0);
// Wait untill the page is loaded. Initial visibility should be 'hidden'.
test->waitUntilLoadFinished();
GOwnPtr<GError> error;
WebKitJavascriptResult* javascriptResult = test->runJavaScriptAndWaitUntilFinished("document.webkitVisibilityState;", &error.outPtr());
g_assert(javascriptResult);
g_assert(!error.get());
GOwnPtr<char> valueString(WebViewTest::javascriptResultToCString(javascriptResult));
g_assert_cmpstr(valueString.get(), ==, "hidden");
javascriptResult = test->runJavaScriptAndWaitUntilFinished("document.webkitHidden;", &error.outPtr());
g_assert(javascriptResult);
g_assert(!error.get());
g_assert(WebViewTest::javascriptResultToBoolean(javascriptResult));
// Show the page. The visibility should be updated to 'visible'.
test->showInWindow();
test->waitUntilTitleChanged();
javascriptResult = test->runJavaScriptAndWaitUntilFinished("document.webkitVisibilityState;", &error.outPtr());
g_assert(javascriptResult);
g_assert(!error.get());
valueString.set(WebViewTest::javascriptResultToCString(javascriptResult));
g_assert_cmpstr(valueString.get(), ==, "visible");
javascriptResult = test->runJavaScriptAndWaitUntilFinished("document.webkitHidden;", &error.outPtr());
g_assert(javascriptResult);
g_assert(!error.get());
g_assert(!WebViewTest::javascriptResultToBoolean(javascriptResult));
// Hide the page. The visibility should be updated to 'hidden'.
gtk_widget_hide(GTK_WIDGET(test->m_webView));
test->waitUntilTitleChanged();
javascriptResult = test->runJavaScriptAndWaitUntilFinished("document.webkitVisibilityState;", &error.outPtr());
g_assert(javascriptResult);
g_assert(!error.get());
valueString.set(WebViewTest::javascriptResultToCString(javascriptResult));
g_assert_cmpstr(valueString.get(), ==, "hidden");
javascriptResult = test->runJavaScriptAndWaitUntilFinished("document.webkitHidden;", &error.outPtr());
g_assert(javascriptResult);
g_assert(!error.get());
g_assert(WebViewTest::javascriptResultToBoolean(javascriptResult));
}
void beforeAll()
{
WebViewTest::add("WebKitWebView", "default-context", testWebViewDefaultContext);
......@@ -1105,6 +1166,7 @@ void beforeAll()
FormClientTest::add("WebKitWebView", "submit-form", testWebViewSubmitForm);
SaveWebViewTest::add("WebKitWebView", "save", testWebViewSave);
WebViewTest::add("WebKitWebView", "view-mode", testWebViewMode);
WebViewTest::add("WebKitWebView", "page-visibility", testWebViewPageVisibility);
}
void afterAll()
......
......@@ -175,6 +175,15 @@ static gboolean parentWindowMapped(GtkWidget* widget, GdkEvent*, WebViewTest* te
return FALSE;
}
void WebViewTest::showInWindow(GtkWindowType windowType)
{
g_assert(!m_parentWindow);
m_parentWindow = gtk_window_new(windowType);
gtk_container_add(GTK_CONTAINER(m_parentWindow), GTK_WIDGET(m_webView));
gtk_widget_show(GTK_WIDGET(m_webView));
gtk_widget_show(m_parentWindow);
}
void WebViewTest::showInWindowAndWaitUntilMapped(GtkWindowType windowType)
{
g_assert(!m_parentWindow);
......
......@@ -46,6 +46,7 @@ public:
void waitUntilLoadFinished();
void waitUntilTitleChangedTo(const char* expectedTitle);
void waitUntilTitleChanged();
void showInWindow(GtkWindowType = GTK_WINDOW_POPUP);
void showInWindowAndWaitUntilMapped(GtkWindowType = GTK_WINDOW_POPUP);
void resizeView(int width, int height);
const char* mainResourceData(size_t& mainResourceDataSize);
......
......@@ -151,7 +151,7 @@ $srcdir/Tools/gtk/generate-feature-defines-files $CONFIGURABLE_FEATURE_DEFINES \
ENABLE_NETWORK_INFO=0 \
ENABLE_NOTIFICATIONS=0 \
ENABLE_ORIENTATION_EVENTS=0 \
ENABLE_PAGE_VISIBILITY_API=0 \
ENABLE_PAGE_VISIBILITY_API=1 \
ENABLE_PERFORMANCE_TIMELINE=0 \
ENABLE_PROGRESS_ELEMENT=1 \
ENABLE_PROXIMITY_EVENTS=0 \
......
2013-04-10 Anton Obzhirov <a.obzhirov@samsung.com>
[GTK] Add support for Page Visibility
https://bugs.webkit.org/show_bug.cgi?id=97324
Reviewed by Sam Weinig.
Implemented test runner API for page visibility layout tests.
* DumpRenderTree/gtk/TestRunnerGtk.cpp:
(TestRunner::resetPageVisibility):
(TestRunner::setPageVisibility):
* Scripts/webkitperl/FeatureList.pm:
2013-04-10 Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com>
[ATK] REGRESSION(r148033): Add a stub for AccessibilityUIElement::pathDescription().
......@@ -907,12 +907,24 @@ void TestRunner::simulateLegacyWebNotificationClick(JSStringRef title)
void TestRunner::resetPageVisibility()
{
// FIXME: Implement this.
WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame);
DumpRenderTreeSupportGtk::setPageVisibility(webView, WebCore::PageVisibilityStateVisible, true);
}
void TestRunner::setPageVisibility(const char*)
void TestRunner::setPageVisibility(const char* visibility)
{
// FIXME: Implement this.
WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame);
String visibilityString(visibility);
WebCore::PageVisibilityState visibilityState = WebCore::PageVisibilityStateVisible;
if (visibilityString == "visible")
visibilityState = WebCore::PageVisibilityStateVisible;
else if (visibilityString == "hidden")
visibilityState = WebCore::PageVisibilityStateHidden;
else
return;
DumpRenderTreeSupportGtk::setPageVisibility(webView, visibilityState, false);
}
void TestRunner::setAutomaticLinkDetectionEnabled(bool)
......
......@@ -379,7 +379,7 @@ my @features = (
define => "ENABLE_ORIENTATION_EVENTS", default => isBlackBerry(), value => \$orientationEventsSupport },
{ option => "page-visibility-api", desc => "Toggle Page Visibility API support",
define => "ENABLE_PAGE_VISIBILITY_API", default => (isBlackBerry() || isEfl()), value => \$pageVisibilityAPISupport },
define => "ENABLE_PAGE_VISIBILITY_API", default => (isBlackBerry() || isEfl() || isGtk()), value => \$pageVisibilityAPISupport },
{ option => "performance-timeline", desc => "Toggle Performance Timeline support",
define => "ENABLE_PERFORMANCE_TIMELINE", default => isGtk(), value => \$performanceTimelineSupport },
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment