2 * Copyright (C) 2007 Apple Inc. All rights reserved.
3 * Copyright (C) 2007 Eric Seidel <eric@webkit.org>
4 * Copyright (C) 2008 Nuanti Ltd.
5 * Copyright (C) 2009 Jan Michael Alonzo <jmalonzo@gmail.com>
6 * Copyright (C) 2009,2011 Collabora Ltd.
7 * Copyright (C) 2010 Joone Hur <joone@kldp.org>
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
19 * its contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
23 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
26 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
29 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 #include "LayoutTestController.h"
37 #include "DumpRenderTree.h"
38 #include "WebCoreSupport/DumpRenderTreeSupportGtk.h"
39 #include "WorkQueue.h"
40 #include "WorkQueueItem.h"
41 #include <JavaScriptCore/JSRetainPtr.h>
42 #include <JavaScriptCore/JSStringRef.h>
48 #include <libsoup/soup.h>
49 #include <webkit/webkit.h>
50 #include <wtf/gobject/GOwnPtr.h>
53 void webkit_web_inspector_execute_script(WebKitWebInspector* inspector, long callId, const gchar* script);
56 LayoutTestController::~LayoutTestController()
61 void LayoutTestController::addDisallowedURL(JSStringRef url)
66 void LayoutTestController::clearBackForwardList()
68 WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame);
69 WebKitWebBackForwardList* list = webkit_web_view_get_back_forward_list(webView);
70 WebKitWebHistoryItem* item = webkit_web_back_forward_list_get_current_item(list);
73 // We clear the history by setting the back/forward list's capacity to 0
74 // then restoring it back and adding back the current item.
75 gint limit = webkit_web_back_forward_list_get_limit(list);
76 webkit_web_back_forward_list_set_limit(list, 0);
77 webkit_web_back_forward_list_set_limit(list, limit);
78 webkit_web_back_forward_list_add_item(list, item);
79 webkit_web_back_forward_list_go_to_item(list, item);
83 JSStringRef LayoutTestController::copyDecodedHostName(JSStringRef name)
89 JSStringRef LayoutTestController::copyEncodedHostName(JSStringRef name)
95 void LayoutTestController::dispatchPendingLoadRequests()
97 // FIXME: Implement for testing fix for 6727495
100 void LayoutTestController::display()
105 JSRetainPtr<JSStringRef> LayoutTestController::counterValueForElementById(JSStringRef id)
107 gchar* idGChar = JSStringCopyUTF8CString(id);
108 CString counterValueGChar = DumpRenderTreeSupportGtk::counterValueForElementById(mainFrame, idGChar);
110 if (counterValueGChar.isNull())
112 JSRetainPtr<JSStringRef> counterValue(Adopt, JSStringCreateWithUTF8CString(counterValueGChar.data()));
116 void LayoutTestController::keepWebHistory()
121 JSValueRef LayoutTestController::computedStyleIncludingVisitedInfo(JSContextRef context, JSValueRef value)
123 // FIXME: Implement this.
124 return JSValueMakeUndefined(context);
127 JSValueRef LayoutTestController::nodesFromRect(JSContextRef context, JSValueRef value, int x, int y, unsigned top, unsigned right, unsigned bottom, unsigned left, bool ignoreClipping)
129 return DumpRenderTreeSupportGtk::nodesFromRect(context, value, x, y, top, right, bottom, left, ignoreClipping);
132 JSRetainPtr<JSStringRef> LayoutTestController::layerTreeAsText() const
135 JSRetainPtr<JSStringRef> string(Adopt, JSStringCreateWithUTF8CString(""));
139 int LayoutTestController::pageNumberForElementById(JSStringRef id, float pageWidth, float pageHeight)
141 gchar* idGChar = JSStringCopyUTF8CString(id);
142 int pageNumber = DumpRenderTreeSupportGtk::pageNumberForElementById(mainFrame, idGChar, pageWidth, pageHeight);
147 int LayoutTestController::numberOfPages(float pageWidth, float pageHeight)
149 return DumpRenderTreeSupportGtk::numberOfPagesForFrame(mainFrame, pageWidth, pageHeight);
152 JSRetainPtr<JSStringRef> LayoutTestController::pageProperty(const char* propertyName, int pageNumber) const
154 JSRetainPtr<JSStringRef> propertyValue(Adopt, JSStringCreateWithUTF8CString(DumpRenderTreeSupportGtk::pageProperty(mainFrame, propertyName, pageNumber).data()));
155 return propertyValue;
158 bool LayoutTestController::isPageBoxVisible(int pageNumber) const
160 return DumpRenderTreeSupportGtk::isPageBoxVisible(mainFrame, pageNumber);
163 JSRetainPtr<JSStringRef> LayoutTestController::pageSizeAndMarginsInPixels(int pageNumber, int width, int height, int marginTop, int marginRight, int marginBottom, int marginLeft) const
165 JSRetainPtr<JSStringRef> propertyValue(Adopt, JSStringCreateWithUTF8CString(DumpRenderTreeSupportGtk::pageSizeAndMarginsInPixels(mainFrame, pageNumber, width, height, marginTop, marginRight, marginBottom, marginLeft).data()));
166 return propertyValue;
169 size_t LayoutTestController::webHistoryItemCount()
171 WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame);
172 WebKitWebBackForwardList* list = webkit_web_view_get_back_forward_list(webView);
177 // We do not add the current page to the total count as it's not
178 // considered in DRT tests
179 return webkit_web_back_forward_list_get_back_length(list) +
180 webkit_web_back_forward_list_get_forward_length(list);
183 unsigned LayoutTestController::workerThreadCount() const
185 return DumpRenderTreeSupportGtk::workerThreadCount();
188 void LayoutTestController::notifyDone()
190 if (m_waitToDump && !topLoadingFrame && !WorkQueue::shared()->count())
192 m_waitToDump = false;
193 waitForPolicy = false;
196 JSStringRef LayoutTestController::pathToLocalResource(JSContextRef context, JSStringRef url)
198 // Function introduced in r28690. This may need special-casing on Windows.
199 return JSStringRetain(url); // Do nothing on Unix.
202 void LayoutTestController::queueLoad(JSStringRef url, JSStringRef target)
204 gchar* relativeURL = JSStringCopyUTF8CString(url);
205 SoupURI* baseURI = soup_uri_new(webkit_web_frame_get_uri(mainFrame));
207 SoupURI* absoluteURI = soup_uri_new_with_base(baseURI, relativeURL);
208 soup_uri_free(baseURI);
211 gchar* absoluteCString;
213 absoluteCString = soup_uri_to_string(absoluteURI, FALSE);
214 soup_uri_free(absoluteURI);
216 absoluteCString = JSStringCopyUTF8CString(url);
218 JSRetainPtr<JSStringRef> absoluteURL(Adopt, JSStringCreateWithUTF8CString(absoluteCString));
219 g_free(absoluteCString);
221 WorkQueue::shared()->queue(new LoadItem(absoluteURL.get(), target));
224 void LayoutTestController::setAcceptsEditing(bool acceptsEditing)
226 WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame);
227 webkit_web_view_set_editable(webView, acceptsEditing);
230 void LayoutTestController::setAlwaysAcceptCookies(bool alwaysAcceptCookies)
232 SoupSession* session = webkit_get_default_session();
233 SoupCookieJar* jar = reinterpret_cast<SoupCookieJar*>(soup_session_get_feature(session, SOUP_TYPE_COOKIE_JAR));
235 /* If the jar was not created - we create it on demand, i.e, just
236 in case we have HTTP requests - then we must create it here in
237 order to set the proper accept policy */
239 jar = soup_cookie_jar_new();
240 soup_session_add_feature(session, SOUP_SESSION_FEATURE(jar));
244 SoupCookieJarAcceptPolicy policy;
246 if (alwaysAcceptCookies)
247 policy = SOUP_COOKIE_JAR_ACCEPT_ALWAYS;
249 policy = SOUP_COOKIE_JAR_ACCEPT_NO_THIRD_PARTY;
251 g_object_set(G_OBJECT(jar), SOUP_COOKIE_JAR_ACCEPT_POLICY, policy, NULL);
254 void LayoutTestController::setCustomPolicyDelegate(bool setDelegate, bool permissive)
259 void LayoutTestController::waitForPolicyDelegate()
261 waitForPolicy = true;
265 void LayoutTestController::setScrollbarPolicy(JSStringRef orientation, JSStringRef policy)
270 void LayoutTestController::addOriginAccessWhitelistEntry(JSStringRef sourceOrigin, JSStringRef protocol, JSStringRef host, bool includeSubdomains)
272 gchar* sourceOriginGChar = JSStringCopyUTF8CString(sourceOrigin);
273 gchar* protocolGChar = JSStringCopyUTF8CString(protocol);
274 gchar* hostGChar = JSStringCopyUTF8CString(host);
275 DumpRenderTreeSupportGtk::whiteListAccessFromOrigin(sourceOriginGChar, protocolGChar, hostGChar, includeSubdomains);
276 g_free(sourceOriginGChar);
277 g_free(protocolGChar);
281 void LayoutTestController::removeOriginAccessWhitelistEntry(JSStringRef sourceOrigin, JSStringRef protocol, JSStringRef host, bool includeSubdomains)
286 void LayoutTestController::setMainFrameIsFirstResponder(bool flag)
291 void LayoutTestController::setTabKeyCyclesThroughElements(bool cycles)
293 WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame);
294 WebKitWebSettings* settings = webkit_web_view_get_settings(webView);
295 g_object_set(G_OBJECT(settings), "tab-key-cycles-through-elements", cycles, NULL);
298 void LayoutTestController::setTimelineProfilingEnabled(bool flag)
300 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
303 WebKitWebInspector* inspector = webkit_web_view_get_inspector(view);
304 g_object_set(G_OBJECT(inspector), "timeline-profiling-enabled", flag, NULL);
307 void LayoutTestController::setUseDashboardCompatibilityMode(bool flag)
312 static gchar* userStyleSheet = NULL;
313 static gboolean userStyleSheetEnabled = TRUE;
315 void LayoutTestController::setUserStyleSheetEnabled(bool flag)
317 userStyleSheetEnabled = flag;
319 WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame);
320 WebKitWebSettings* settings = webkit_web_view_get_settings(webView);
321 if (flag && userStyleSheet)
322 g_object_set(G_OBJECT(settings), "user-stylesheet-uri", userStyleSheet, NULL);
324 g_object_set(G_OBJECT(settings), "user-stylesheet-uri", "", NULL);
327 void LayoutTestController::setUserStyleSheetLocation(JSStringRef path)
329 g_free(userStyleSheet);
330 userStyleSheet = JSStringCopyUTF8CString(path);
331 if (userStyleSheetEnabled)
332 setUserStyleSheetEnabled(true);
335 void LayoutTestController::setValueForUser(JSContextRef context, JSValueRef nodeObject, JSStringRef value)
337 DumpRenderTreeSupportGtk::setValueForUser(context, nodeObject, value);
340 void LayoutTestController::setViewModeMediaFeature(JSStringRef mode)
342 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
345 char* viewMode = JSStringCopyUTF8CString(mode);
347 if (!g_strcmp0(viewMode, "windowed"))
348 webkit_web_view_set_view_mode(view, WEBKIT_WEB_VIEW_VIEW_MODE_WINDOWED);
349 else if (!g_strcmp0(viewMode, "floating"))
350 webkit_web_view_set_view_mode(view, WEBKIT_WEB_VIEW_VIEW_MODE_FLOATING);
351 else if (!g_strcmp0(viewMode, "fullscreen"))
352 webkit_web_view_set_view_mode(view, WEBKIT_WEB_VIEW_VIEW_MODE_FULLSCREEN);
353 else if (!g_strcmp0(viewMode, "maximized"))
354 webkit_web_view_set_view_mode(view, WEBKIT_WEB_VIEW_VIEW_MODE_MAXIMIZED);
355 else if (!g_strcmp0(viewMode, "minimized"))
356 webkit_web_view_set_view_mode(view, WEBKIT_WEB_VIEW_VIEW_MODE_MINIMIZED);
361 void LayoutTestController::setWindowIsKey(bool windowIsKey)
366 void LayoutTestController::setSmartInsertDeleteEnabled(bool flag)
371 static gboolean waitToDumpWatchdogFired(void*)
373 waitToDumpWatchdog = 0;
374 gLayoutTestController->waitToDumpWatchdogTimerFired();
378 void LayoutTestController::setWaitToDump(bool waitUntilDone)
380 static const int timeoutSeconds = 30;
382 m_waitToDump = waitUntilDone;
383 if (m_waitToDump && !waitToDumpWatchdog)
384 waitToDumpWatchdog = g_timeout_add_seconds(timeoutSeconds, waitToDumpWatchdogFired, 0);
387 int LayoutTestController::windowCount()
389 // +1 -> including the main view
390 return g_slist_length(webViewList) + 1;
393 void LayoutTestController::setPrivateBrowsingEnabled(bool flag)
395 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
398 WebKitWebSettings* settings = webkit_web_view_get_settings(view);
399 g_object_set(G_OBJECT(settings), "enable-private-browsing", flag, NULL);
402 void LayoutTestController::setJavaScriptCanAccessClipboard(bool flag)
404 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
407 WebKitWebSettings* settings = webkit_web_view_get_settings(view);
408 g_object_set(G_OBJECT(settings), "javascript-can-access-clipboard", flag, NULL);
411 void LayoutTestController::setXSSAuditorEnabled(bool flag)
413 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
416 WebKitWebSettings* settings = webkit_web_view_get_settings(view);
417 g_object_set(G_OBJECT(settings), "enable-xss-auditor", flag, NULL);
420 void LayoutTestController::setFrameFlatteningEnabled(bool flag)
422 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
425 WebKitWebSettings* settings = webkit_web_view_get_settings(view);
426 g_object_set(G_OBJECT(settings), "enable-frame-flattening", flag, NULL);
429 void LayoutTestController::setSpatialNavigationEnabled(bool flag)
431 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
434 WebKitWebSettings* settings = webkit_web_view_get_settings(view);
435 g_object_set(G_OBJECT(settings), "enable-spatial-navigation", flag, NULL);
438 void LayoutTestController::setAllowUniversalAccessFromFileURLs(bool flag)
440 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
443 WebKitWebSettings* settings = webkit_web_view_get_settings(view);
444 g_object_set(G_OBJECT(settings), "enable-universal-access-from-file-uris", flag, NULL);
447 void LayoutTestController::setAllowFileAccessFromFileURLs(bool flag)
449 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
452 WebKitWebSettings* settings = webkit_web_view_get_settings(view);
453 g_object_set(G_OBJECT(settings), "enable-file-access-from-file-uris", flag, NULL);
456 void LayoutTestController::setAuthorAndUserStylesEnabled(bool flag)
461 void LayoutTestController::setAutofilled(JSContextRef context, JSValueRef nodeObject, bool isAutofilled)
463 DumpRenderTreeSupportGtk::setAutofilled(context, nodeObject, isAutofilled);
466 void LayoutTestController::disableImageLoading()
468 // FIXME: Implement for testing fix for https://bugs.webkit.org/show_bug.cgi?id=27896
469 // Also need to make sure image loading is re-enabled for each new test.
472 void LayoutTestController::setMockDeviceOrientation(bool canProvideAlpha, double alpha, bool canProvideBeta, double beta, bool canProvideGamma, double gamma)
474 // FIXME: Implement for DeviceOrientation layout tests.
475 // See https://bugs.webkit.org/show_bug.cgi?id=30335.
478 void LayoutTestController::setMockGeolocationPosition(double latitude, double longitude, double accuracy)
480 // FIXME: Implement for Geolocation layout tests.
481 // See https://bugs.webkit.org/show_bug.cgi?id=28264.
484 void LayoutTestController::setMockGeolocationError(int code, JSStringRef message)
486 // FIXME: Implement for Geolocation layout tests.
487 // See https://bugs.webkit.org/show_bug.cgi?id=28264.
490 void LayoutTestController::setGeolocationPermission(bool allow)
492 // FIXME: Implement for Geolocation layout tests.
493 setGeolocationPermissionCommon(allow);
496 int LayoutTestController::numberOfPendingGeolocationPermissionRequests()
498 // FIXME: Implement for Geolocation layout tests.
502 void LayoutTestController::addMockSpeechInputResult(JSStringRef result, double confidence, JSStringRef language)
504 // FIXME: Implement for speech input layout tests.
505 // See https://bugs.webkit.org/show_bug.cgi?id=39485.
508 void LayoutTestController::setIconDatabaseEnabled(bool enabled)
510 WebKitIconDatabase* database = webkit_get_icon_database();
512 GOwnPtr<gchar> iconDatabasePath(g_build_filename(g_get_tmp_dir(), "DumpRenderTree", "icondatabase", NULL));
513 webkit_icon_database_set_path(database, iconDatabasePath.get());
515 webkit_icon_database_set_path(database, 0);
518 void LayoutTestController::setJavaScriptProfilingEnabled(bool flag)
520 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
523 setDeveloperExtrasEnabled(flag);
525 WebKitWebInspector* inspector = webkit_web_view_get_inspector(view);
526 g_object_set(G_OBJECT(inspector), "javascript-profiling-enabled", flag, NULL);
529 void LayoutTestController::setSelectTrailingWhitespaceEnabled(bool flag)
531 DumpRenderTreeSupportGtk::setSelectTrailingWhitespaceEnabled(flag);
534 void LayoutTestController::setPopupBlockingEnabled(bool flag)
536 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
539 WebKitWebSettings* settings = webkit_web_view_get_settings(view);
540 g_object_set(G_OBJECT(settings), "javascript-can-open-windows-automatically", !flag, NULL);
544 void LayoutTestController::setPluginsEnabled(bool flag)
549 bool LayoutTestController::elementDoesAutoCompleteForElementWithId(JSStringRef id)
555 void LayoutTestController::execCommand(JSStringRef name, JSStringRef value)
557 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
560 gchar* cName = JSStringCopyUTF8CString(name);
561 gchar* cValue = JSStringCopyUTF8CString(value);
562 DumpRenderTreeSupportGtk::executeCoreCommandByName(view, cName, cValue);
567 bool LayoutTestController::findString(JSContextRef context, JSStringRef target, JSObjectRef optionsArray)
569 WebKitFindOptions findOptions = 0;
570 WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame);
573 JSRetainPtr<JSStringRef> lengthPropertyName(Adopt, JSStringCreateWithUTF8CString("length"));
574 JSValueRef lengthValue = JSObjectGetProperty(context, optionsArray, lengthPropertyName.get(), 0);
575 if (!JSValueIsNumber(context, lengthValue))
578 GOwnPtr<gchar> targetString(JSStringCopyUTF8CString(target));
580 size_t length = static_cast<size_t>(JSValueToNumber(context, lengthValue, 0));
581 for (size_t i = 0; i < length; ++i) {
582 JSValueRef value = JSObjectGetPropertyAtIndex(context, optionsArray, i, 0);
583 if (!JSValueIsString(context, value))
586 JSRetainPtr<JSStringRef> optionName(Adopt, JSValueToStringCopy(context, value, 0));
588 if (JSStringIsEqualToUTF8CString(optionName.get(), "CaseInsensitive"))
589 findOptions |= WebKit::WebFindOptionsCaseInsensitive;
590 else if (JSStringIsEqualToUTF8CString(optionName.get(), "AtWordStarts"))
591 findOptions |= WebKit::WebFindOptionsAtWordStarts;
592 else if (JSStringIsEqualToUTF8CString(optionName.get(), "TreatMedialCapitalAsWordStart"))
593 findOptions |= WebKit::WebFindOptionsTreatMedialCapitalAsWordStart;
594 else if (JSStringIsEqualToUTF8CString(optionName.get(), "Backwards"))
595 findOptions |= WebKit::WebFindOptionsBackwards;
596 else if (JSStringIsEqualToUTF8CString(optionName.get(), "WrapAround"))
597 findOptions |= WebKit::WebFindOptionsWrapAround;
598 else if (JSStringIsEqualToUTF8CString(optionName.get(), "StartInSelection"))
599 findOptions |= WebKit::WebFindOptionsStartInSelection;
602 return DumpRenderTreeSupportGtk::findString(webView, targetString.get(), findOptions);
605 bool LayoutTestController::isCommandEnabled(JSStringRef name)
607 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
610 gchar* cName = JSStringCopyUTF8CString(name);
611 bool result = DumpRenderTreeSupportGtk::isCommandEnabled(view, cName);
616 void LayoutTestController::setCacheModel(int cacheModel)
618 // These constants are derived from the Mac cache model enum in Source/WebKit/mac/WebView/WebPreferences.h.
619 switch (cacheModel) {
621 webkit_set_cache_model(WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER);
624 webkit_set_cache_model(WEBKIT_CACHE_MODEL_DOCUMENT_BROWSER);
627 webkit_set_cache_model(WEBKIT_CACHE_MODEL_DOCUMENT_BROWSER);
630 ASSERT_NOT_REACHED();
634 void LayoutTestController::setPersistentUserStyleSheetLocation(JSStringRef jsURL)
639 void LayoutTestController::clearPersistentUserStyleSheet()
644 void LayoutTestController::clearAllApplicationCaches()
646 // FIXME: Implement to support application cache quotas.
649 void LayoutTestController::setApplicationCacheOriginQuota(unsigned long long quota)
651 // FIXME: Implement to support application cache quotas.
654 void LayoutTestController::clearApplicationCacheForOrigin(OpaqueJSString*)
656 // FIXME: Implement to support deleting all application caches for an origin.
659 JSValueRef LayoutTestController::originsWithApplicationCache(JSContextRef context)
661 // FIXME: Implement to get origins that contain application caches.
662 return JSValueMakeUndefined(context);
665 void LayoutTestController::clearAllDatabases()
667 webkit_remove_all_web_databases();
670 void LayoutTestController::setDatabaseQuota(unsigned long long quota)
672 WebKitSecurityOrigin* origin = webkit_web_frame_get_security_origin(mainFrame);
673 webkit_security_origin_set_web_database_quota(origin, quota);
676 JSValueRef LayoutTestController::originsWithLocalStorage(JSContextRef context)
679 return JSValueMakeUndefined(context);
682 void LayoutTestController::deleteAllLocalStorage()
687 void LayoutTestController::deleteLocalStorageForOrigin(JSStringRef originIdentifier)
692 void LayoutTestController::observeStorageTrackerNotifications(unsigned number)
697 void LayoutTestController::syncLocalStorage()
702 void LayoutTestController::setDomainRelaxationForbiddenForURLScheme(bool, JSStringRef)
707 void LayoutTestController::setAppCacheMaximumSize(unsigned long long size)
709 webkit_application_cache_set_maximum_size(size);
712 bool LayoutTestController::pauseAnimationAtTimeOnElementWithId(JSStringRef animationName, double time, JSStringRef elementId)
714 gchar* name = JSStringCopyUTF8CString(animationName);
715 gchar* element = JSStringCopyUTF8CString(elementId);
716 bool returnValue = DumpRenderTreeSupportGtk::pauseAnimation(mainFrame, name, time, element);
722 bool LayoutTestController::pauseTransitionAtTimeOnElementWithId(JSStringRef propertyName, double time, JSStringRef elementId)
724 gchar* name = JSStringCopyUTF8CString(propertyName);
725 gchar* element = JSStringCopyUTF8CString(elementId);
726 bool returnValue = DumpRenderTreeSupportGtk::pauseTransition(mainFrame, name, time, element);
732 bool LayoutTestController::sampleSVGAnimationForElementAtTime(JSStringRef animationId, double time, JSStringRef elementId)
734 gchar* name = JSStringCopyUTF8CString(animationId);
735 gchar* element = JSStringCopyUTF8CString(elementId);
736 bool returnValue = DumpRenderTreeSupportGtk::pauseSVGAnimation(mainFrame, name, time, element);
742 unsigned LayoutTestController::numberOfActiveAnimations() const
744 return DumpRenderTreeSupportGtk::numberOfActiveAnimations(mainFrame);
747 void LayoutTestController::suspendAnimations() const
749 DumpRenderTreeSupportGtk::suspendAnimations(mainFrame);
752 void LayoutTestController::resumeAnimations() const
754 DumpRenderTreeSupportGtk::resumeAnimations(mainFrame);
757 void LayoutTestController::overridePreference(JSStringRef key, JSStringRef value)
759 GOwnPtr<gchar> originalName(JSStringCopyUTF8CString(key));
760 GOwnPtr<gchar> valueAsString(JSStringCopyUTF8CString(value));
762 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
765 // This transformation could be handled by a hash table (and it once was), but
766 // having it prominent, makes it easier for people from other ports to keep the
768 const gchar* propertyName = 0;
769 if (g_str_equal(originalName.get(), "WebKitJavaScriptEnabled"))
770 propertyName = "enable-scripts";
771 else if (g_str_equal(originalName.get(), "WebKitDefaultFontSize"))
772 propertyName = "default-font-size";
773 else if (g_str_equal(originalName.get(), "WebKitEnableCaretBrowsing"))
774 propertyName = "enable-caret-browsing";
775 else if (g_str_equal(originalName.get(), "WebKitUsesPageCachePreferenceKey"))
776 propertyName = "enable-page-cache";
777 else if (g_str_equal(originalName.get(), "WebKitPluginsEnabled"))
778 propertyName = "enable-plugins";
779 else if (g_str_equal(originalName.get(), "WebKitHyperlinkAuditingEnabled"))
780 propertyName = "enable-hyperlink-auditing";
781 else if (g_str_equal(originalName.get(), "WebKitTabToLinksPreferenceKey")) {
782 DumpRenderTreeSupportGtk::setLinksIncludedInFocusChain(!g_ascii_strcasecmp(valueAsString.get(), "true") || !g_ascii_strcasecmp(valueAsString.get(), "1"));
785 fprintf(stderr, "LayoutTestController::overridePreference tried to override "
786 "unknown preference '%s'.\n", originalName.get());
790 WebKitWebSettings* settings = webkit_web_view_get_settings(view);
791 GParamSpec* pspec = g_object_class_find_property(G_OBJECT_CLASS(
792 WEBKIT_WEB_SETTINGS_GET_CLASS(settings)), propertyName);
793 GValue currentPropertyValue = { 0, { { 0 } } };
794 g_value_init(¤tPropertyValue, pspec->value_type);
796 if (G_VALUE_HOLDS_STRING(¤tPropertyValue))
797 g_object_set(settings, propertyName, valueAsString.get(), NULL);
798 else if (G_VALUE_HOLDS_BOOLEAN(¤tPropertyValue))
799 g_object_set(G_OBJECT(settings), propertyName, !g_ascii_strcasecmp(valueAsString.get(), "true")
800 || !g_ascii_strcasecmp(valueAsString.get(), "1"), NULL);
801 else if (G_VALUE_HOLDS_INT(¤tPropertyValue))
802 g_object_set(G_OBJECT(settings), propertyName, atoi(valueAsString.get()), NULL);
803 else if (G_VALUE_HOLDS_FLOAT(¤tPropertyValue)) {
804 gfloat newValue = g_ascii_strtod(valueAsString.get(), 0);
805 g_object_set(G_OBJECT(settings), propertyName, newValue, NULL);
807 fprintf(stderr, "LayoutTestController::overridePreference failed to override "
808 "preference '%s'.\n", originalName.get());
811 void LayoutTestController::addUserScript(JSStringRef source, bool runAtStart, bool allFrames)
813 printf("LayoutTestController::addUserScript not implemented.\n");
816 void LayoutTestController::addUserStyleSheet(JSStringRef source, bool allFrames)
818 GOwnPtr<gchar> sourceCode(JSStringCopyUTF8CString(source));
819 DumpRenderTreeSupportGtk::addUserStyleSheet(mainFrame, sourceCode.get(), allFrames);
820 // FIXME: needs more investigation why userscripts/user-style-top-frame-only.html fails when allFrames is false.
824 void LayoutTestController::setDeveloperExtrasEnabled(bool enabled)
826 WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame);
827 WebKitWebSettings* webSettings = webkit_web_view_get_settings(webView);
829 g_object_set(webSettings, "enable-developer-extras", enabled, NULL);
832 void LayoutTestController::setAsynchronousSpellCheckingEnabled(bool)
834 // FIXME: Implement this.
837 void LayoutTestController::showWebInspector()
839 WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame);
840 WebKitWebInspector* inspector = webkit_web_view_get_inspector(webView);
842 webkit_web_inspector_show(inspector);
845 void LayoutTestController::closeWebInspector()
847 WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame);
848 WebKitWebInspector* inspector = webkit_web_view_get_inspector(webView);
850 webkit_web_inspector_close(inspector);
853 void LayoutTestController::evaluateInWebInspector(long callId, JSStringRef script)
855 WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame);
856 WebKitWebInspector* inspector = webkit_web_view_get_inspector(webView);
857 char* scriptString = JSStringCopyUTF8CString(script);
859 webkit_web_inspector_execute_script(inspector, callId, scriptString);
860 g_free(scriptString);
863 void LayoutTestController::evaluateScriptInIsolatedWorld(unsigned worldID, JSObjectRef globalObject, JSStringRef script)
865 // FIXME: Implement this.
868 void LayoutTestController::removeAllVisitedLinks()
870 // FIXME: Implement this.
873 bool LayoutTestController::callShouldCloseOnWebView()
875 // FIXME: Implement for testing fix for https://bugs.webkit.org/show_bug.cgi?id=27481
879 void LayoutTestController::apiTestNewWindowDataLoadBaseURL(JSStringRef utf8Data, JSStringRef baseURL)
884 void LayoutTestController::apiTestGoToCurrentBackForwardItem()
889 void LayoutTestController::setWebViewEditable(bool)
893 JSRetainPtr<JSStringRef> LayoutTestController::markerTextForListItem(JSContextRef context, JSValueRef nodeObject) const
895 CString markerTextGChar = DumpRenderTreeSupportGtk::markerTextForListItem(mainFrame, context, nodeObject);
896 if (markerTextGChar.isNull())
899 JSRetainPtr<JSStringRef> markerText(Adopt, JSStringCreateWithUTF8CString(markerTextGChar.data()));
903 void LayoutTestController::authenticateSession(JSStringRef, JSStringRef, JSStringRef)
907 void LayoutTestController::setEditingBehavior(const char* editingBehavior)
909 WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame);
910 WebKitWebSettings* settings = webkit_web_view_get_settings(webView);
912 if (!strcmp(editingBehavior, "win"))
913 g_object_set(G_OBJECT(settings), "editing-behavior", WEBKIT_EDITING_BEHAVIOR_WINDOWS, NULL);
914 else if (!strcmp(editingBehavior, "mac"))
915 g_object_set(G_OBJECT(settings), "editing-behavior", WEBKIT_EDITING_BEHAVIOR_MAC, NULL);
916 else if (!strcmp(editingBehavior, "unix"))
917 g_object_set(G_OBJECT(settings), "editing-behavior", WEBKIT_EDITING_BEHAVIOR_UNIX, NULL);
920 JSValueRef LayoutTestController::shadowRoot(JSContextRef context, JSValueRef jsElement)
922 // FIXME: Implement this.
923 return JSValueMakeUndefined(context);
926 void LayoutTestController::abortModal()
930 bool LayoutTestController::hasSpellingMarker(int from, int length)
932 return DumpRenderTreeSupportGtk::webkitWebFrameSelectionHasSpellingMarker(mainFrame, from, length);
935 bool LayoutTestController::hasGrammarMarker(int from, int length)
940 void LayoutTestController::dumpConfigurationForViewport(int deviceDPI, int deviceWidth, int deviceHeight, int availableWidth, int availableHeight)
942 WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame);
944 DumpRenderTreeSupportGtk::dumpConfigurationForViewport(webView, deviceDPI, deviceWidth, deviceHeight, availableWidth, availableHeight);
947 void LayoutTestController::setSerializeHTTPLoads(bool)
949 // FIXME: Implement if needed for https://bugs.webkit.org/show_bug.cgi?id=50758.
952 void LayoutTestController::setMinimumTimerInterval(double minimumTimerInterval)
954 WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame);
955 DumpRenderTreeSupportGtk::setMinimumTimerInterval(webView, minimumTimerInterval);