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 JSRetainPtr<JSStringRef> LayoutTestController::platformName() const
190 JSRetainPtr<JSStringRef> platformName(Adopt, JSStringCreateWithUTF8CString("gtk"));
194 void LayoutTestController::notifyDone()
196 if (m_waitToDump && !topLoadingFrame && !WorkQueue::shared()->count())
198 m_waitToDump = false;
199 waitForPolicy = false;
202 JSStringRef LayoutTestController::pathToLocalResource(JSContextRef context, JSStringRef url)
204 // Function introduced in r28690. This may need special-casing on Windows.
205 return JSStringRetain(url); // Do nothing on Unix.
208 void LayoutTestController::queueLoad(JSStringRef url, JSStringRef target)
210 gchar* relativeURL = JSStringCopyUTF8CString(url);
211 SoupURI* baseURI = soup_uri_new(webkit_web_frame_get_uri(mainFrame));
213 SoupURI* absoluteURI = soup_uri_new_with_base(baseURI, relativeURL);
214 soup_uri_free(baseURI);
217 gchar* absoluteCString;
219 absoluteCString = soup_uri_to_string(absoluteURI, FALSE);
220 soup_uri_free(absoluteURI);
222 absoluteCString = JSStringCopyUTF8CString(url);
224 JSRetainPtr<JSStringRef> absoluteURL(Adopt, JSStringCreateWithUTF8CString(absoluteCString));
225 g_free(absoluteCString);
227 WorkQueue::shared()->queue(new LoadItem(absoluteURL.get(), target));
230 void LayoutTestController::setAcceptsEditing(bool acceptsEditing)
232 WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame);
233 webkit_web_view_set_editable(webView, acceptsEditing);
236 void LayoutTestController::setAlwaysAcceptCookies(bool alwaysAcceptCookies)
238 SoupSession* session = webkit_get_default_session();
239 SoupCookieJar* jar = reinterpret_cast<SoupCookieJar*>(soup_session_get_feature(session, SOUP_TYPE_COOKIE_JAR));
241 /* If the jar was not created - we create it on demand, i.e, just
242 in case we have HTTP requests - then we must create it here in
243 order to set the proper accept policy */
245 jar = soup_cookie_jar_new();
246 soup_session_add_feature(session, SOUP_SESSION_FEATURE(jar));
250 SoupCookieJarAcceptPolicy policy;
252 if (alwaysAcceptCookies)
253 policy = SOUP_COOKIE_JAR_ACCEPT_ALWAYS;
255 policy = SOUP_COOKIE_JAR_ACCEPT_NO_THIRD_PARTY;
257 g_object_set(G_OBJECT(jar), SOUP_COOKIE_JAR_ACCEPT_POLICY, policy, NULL);
260 void LayoutTestController::setCustomPolicyDelegate(bool setDelegate, bool permissive)
265 void LayoutTestController::waitForPolicyDelegate()
267 waitForPolicy = true;
271 void LayoutTestController::setScrollbarPolicy(JSStringRef orientation, JSStringRef policy)
276 void LayoutTestController::addOriginAccessWhitelistEntry(JSStringRef sourceOrigin, JSStringRef protocol, JSStringRef host, bool includeSubdomains)
278 gchar* sourceOriginGChar = JSStringCopyUTF8CString(sourceOrigin);
279 gchar* protocolGChar = JSStringCopyUTF8CString(protocol);
280 gchar* hostGChar = JSStringCopyUTF8CString(host);
281 DumpRenderTreeSupportGtk::whiteListAccessFromOrigin(sourceOriginGChar, protocolGChar, hostGChar, includeSubdomains);
282 g_free(sourceOriginGChar);
283 g_free(protocolGChar);
287 void LayoutTestController::removeOriginAccessWhitelistEntry(JSStringRef sourceOrigin, JSStringRef protocol, JSStringRef host, bool includeSubdomains)
292 void LayoutTestController::setMainFrameIsFirstResponder(bool flag)
297 void LayoutTestController::setTabKeyCyclesThroughElements(bool cycles)
299 WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame);
300 WebKitWebSettings* settings = webkit_web_view_get_settings(webView);
301 g_object_set(G_OBJECT(settings), "tab-key-cycles-through-elements", cycles, NULL);
304 void LayoutTestController::setUseDashboardCompatibilityMode(bool flag)
309 static gchar* userStyleSheet = NULL;
310 static gboolean userStyleSheetEnabled = TRUE;
312 void LayoutTestController::setUserStyleSheetEnabled(bool flag)
314 userStyleSheetEnabled = flag;
316 WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame);
317 WebKitWebSettings* settings = webkit_web_view_get_settings(webView);
318 if (flag && userStyleSheet)
319 g_object_set(G_OBJECT(settings), "user-stylesheet-uri", userStyleSheet, NULL);
321 g_object_set(G_OBJECT(settings), "user-stylesheet-uri", "", NULL);
324 void LayoutTestController::setUserStyleSheetLocation(JSStringRef path)
326 g_free(userStyleSheet);
327 userStyleSheet = JSStringCopyUTF8CString(path);
328 if (userStyleSheetEnabled)
329 setUserStyleSheetEnabled(true);
332 void LayoutTestController::setValueForUser(JSContextRef context, JSValueRef nodeObject, JSStringRef value)
334 DumpRenderTreeSupportGtk::setValueForUser(context, nodeObject, value);
337 void LayoutTestController::setViewModeMediaFeature(JSStringRef mode)
339 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
342 char* viewMode = JSStringCopyUTF8CString(mode);
344 if (!g_strcmp0(viewMode, "windowed"))
345 webkit_web_view_set_view_mode(view, WEBKIT_WEB_VIEW_VIEW_MODE_WINDOWED);
346 else if (!g_strcmp0(viewMode, "floating"))
347 webkit_web_view_set_view_mode(view, WEBKIT_WEB_VIEW_VIEW_MODE_FLOATING);
348 else if (!g_strcmp0(viewMode, "fullscreen"))
349 webkit_web_view_set_view_mode(view, WEBKIT_WEB_VIEW_VIEW_MODE_FULLSCREEN);
350 else if (!g_strcmp0(viewMode, "maximized"))
351 webkit_web_view_set_view_mode(view, WEBKIT_WEB_VIEW_VIEW_MODE_MAXIMIZED);
352 else if (!g_strcmp0(viewMode, "minimized"))
353 webkit_web_view_set_view_mode(view, WEBKIT_WEB_VIEW_VIEW_MODE_MINIMIZED);
358 void LayoutTestController::setWindowIsKey(bool windowIsKey)
363 void LayoutTestController::setSmartInsertDeleteEnabled(bool flag)
365 DumpRenderTreeSupportGtk::setSmartInsertDeleteEnabled(webkit_web_frame_get_web_view(mainFrame), flag);
368 static gboolean waitToDumpWatchdogFired(void*)
370 waitToDumpWatchdog = 0;
371 gLayoutTestController->waitToDumpWatchdogTimerFired();
375 void LayoutTestController::setWaitToDump(bool waitUntilDone)
377 static const int timeoutSeconds = 30;
379 m_waitToDump = waitUntilDone;
380 if (m_waitToDump && !waitToDumpWatchdog)
381 waitToDumpWatchdog = g_timeout_add_seconds(timeoutSeconds, waitToDumpWatchdogFired, 0);
384 int LayoutTestController::windowCount()
386 // +1 -> including the main view
387 return g_slist_length(webViewList) + 1;
390 void LayoutTestController::setPrivateBrowsingEnabled(bool flag)
392 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
395 WebKitWebSettings* settings = webkit_web_view_get_settings(view);
396 g_object_set(G_OBJECT(settings), "enable-private-browsing", flag, NULL);
399 void LayoutTestController::setJavaScriptCanAccessClipboard(bool flag)
401 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
404 WebKitWebSettings* settings = webkit_web_view_get_settings(view);
405 g_object_set(G_OBJECT(settings), "javascript-can-access-clipboard", flag, NULL);
408 void LayoutTestController::setXSSAuditorEnabled(bool flag)
410 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
413 WebKitWebSettings* settings = webkit_web_view_get_settings(view);
414 g_object_set(G_OBJECT(settings), "enable-xss-auditor", flag, NULL);
417 void LayoutTestController::setFrameFlatteningEnabled(bool flag)
419 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
422 WebKitWebSettings* settings = webkit_web_view_get_settings(view);
423 g_object_set(G_OBJECT(settings), "enable-frame-flattening", flag, NULL);
426 void LayoutTestController::setSpatialNavigationEnabled(bool flag)
428 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
431 WebKitWebSettings* settings = webkit_web_view_get_settings(view);
432 g_object_set(G_OBJECT(settings), "enable-spatial-navigation", flag, NULL);
435 void LayoutTestController::setAllowUniversalAccessFromFileURLs(bool flag)
437 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
440 WebKitWebSettings* settings = webkit_web_view_get_settings(view);
441 g_object_set(G_OBJECT(settings), "enable-universal-access-from-file-uris", flag, NULL);
444 void LayoutTestController::setAllowFileAccessFromFileURLs(bool flag)
446 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
449 WebKitWebSettings* settings = webkit_web_view_get_settings(view);
450 g_object_set(G_OBJECT(settings), "enable-file-access-from-file-uris", flag, NULL);
453 void LayoutTestController::setAuthorAndUserStylesEnabled(bool flag)
458 void LayoutTestController::setAutofilled(JSContextRef context, JSValueRef nodeObject, bool isAutofilled)
460 DumpRenderTreeSupportGtk::setAutofilled(context, nodeObject, isAutofilled);
463 void LayoutTestController::disableImageLoading()
465 // FIXME: Implement for testing fix for https://bugs.webkit.org/show_bug.cgi?id=27896
466 // Also need to make sure image loading is re-enabled for each new test.
469 void LayoutTestController::setMockDeviceOrientation(bool canProvideAlpha, double alpha, bool canProvideBeta, double beta, bool canProvideGamma, double gamma)
471 // FIXME: Implement for DeviceOrientation layout tests.
472 // See https://bugs.webkit.org/show_bug.cgi?id=30335.
475 void LayoutTestController::setMockGeolocationPosition(double latitude, double longitude, double accuracy)
477 // FIXME: Implement for Geolocation layout tests.
478 // See https://bugs.webkit.org/show_bug.cgi?id=28264.
481 void LayoutTestController::setMockGeolocationError(int code, JSStringRef message)
483 // FIXME: Implement for Geolocation layout tests.
484 // See https://bugs.webkit.org/show_bug.cgi?id=28264.
487 void LayoutTestController::setGeolocationPermission(bool allow)
489 // FIXME: Implement for Geolocation layout tests.
490 setGeolocationPermissionCommon(allow);
493 int LayoutTestController::numberOfPendingGeolocationPermissionRequests()
495 // FIXME: Implement for Geolocation layout tests.
499 void LayoutTestController::addMockSpeechInputResult(JSStringRef result, double confidence, JSStringRef language)
501 // FIXME: Implement for speech input layout tests.
502 // See https://bugs.webkit.org/show_bug.cgi?id=39485.
505 void LayoutTestController::startSpeechInput(JSContextRef inputElement)
507 // FIXME: Implement for speech input layout tests.
508 // See https://bugs.webkit.org/show_bug.cgi?id=39485.
511 void LayoutTestController::setIconDatabaseEnabled(bool enabled)
513 WebKitIconDatabase* database = webkit_get_icon_database();
515 GOwnPtr<gchar> iconDatabasePath(g_build_filename(g_get_tmp_dir(), "DumpRenderTree", "icondatabase", NULL));
516 webkit_icon_database_set_path(database, iconDatabasePath.get());
518 webkit_icon_database_set_path(database, 0);
521 void LayoutTestController::setJavaScriptProfilingEnabled(bool flag)
523 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
526 setDeveloperExtrasEnabled(flag);
528 WebKitWebInspector* inspector = webkit_web_view_get_inspector(view);
529 g_object_set(G_OBJECT(inspector), "javascript-profiling-enabled", flag, NULL);
532 void LayoutTestController::setSelectTrailingWhitespaceEnabled(bool flag)
534 DumpRenderTreeSupportGtk::setSelectTrailingWhitespaceEnabled(flag);
537 void LayoutTestController::setPopupBlockingEnabled(bool flag)
539 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
542 WebKitWebSettings* settings = webkit_web_view_get_settings(view);
543 g_object_set(G_OBJECT(settings), "javascript-can-open-windows-automatically", !flag, NULL);
547 void LayoutTestController::setPluginsEnabled(bool flag)
549 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
552 WebKitWebSettings* settings = webkit_web_view_get_settings(view);
553 g_object_set(G_OBJECT(settings), "enable-plugins", flag, NULL);
556 bool LayoutTestController::elementDoesAutoCompleteForElementWithId(JSStringRef id)
562 void LayoutTestController::execCommand(JSStringRef name, JSStringRef value)
564 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
567 gchar* cName = JSStringCopyUTF8CString(name);
568 gchar* cValue = JSStringCopyUTF8CString(value);
569 DumpRenderTreeSupportGtk::executeCoreCommandByName(view, cName, cValue);
574 bool LayoutTestController::findString(JSContextRef context, JSStringRef target, JSObjectRef optionsArray)
576 WebKitFindOptions findOptions = 0;
577 WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame);
580 JSRetainPtr<JSStringRef> lengthPropertyName(Adopt, JSStringCreateWithUTF8CString("length"));
581 JSValueRef lengthValue = JSObjectGetProperty(context, optionsArray, lengthPropertyName.get(), 0);
582 if (!JSValueIsNumber(context, lengthValue))
585 GOwnPtr<gchar> targetString(JSStringCopyUTF8CString(target));
587 size_t length = static_cast<size_t>(JSValueToNumber(context, lengthValue, 0));
588 for (size_t i = 0; i < length; ++i) {
589 JSValueRef value = JSObjectGetPropertyAtIndex(context, optionsArray, i, 0);
590 if (!JSValueIsString(context, value))
593 JSRetainPtr<JSStringRef> optionName(Adopt, JSValueToStringCopy(context, value, 0));
595 if (JSStringIsEqualToUTF8CString(optionName.get(), "CaseInsensitive"))
596 findOptions |= WebKit::WebFindOptionsCaseInsensitive;
597 else if (JSStringIsEqualToUTF8CString(optionName.get(), "AtWordStarts"))
598 findOptions |= WebKit::WebFindOptionsAtWordStarts;
599 else if (JSStringIsEqualToUTF8CString(optionName.get(), "TreatMedialCapitalAsWordStart"))
600 findOptions |= WebKit::WebFindOptionsTreatMedialCapitalAsWordStart;
601 else if (JSStringIsEqualToUTF8CString(optionName.get(), "Backwards"))
602 findOptions |= WebKit::WebFindOptionsBackwards;
603 else if (JSStringIsEqualToUTF8CString(optionName.get(), "WrapAround"))
604 findOptions |= WebKit::WebFindOptionsWrapAround;
605 else if (JSStringIsEqualToUTF8CString(optionName.get(), "StartInSelection"))
606 findOptions |= WebKit::WebFindOptionsStartInSelection;
609 return DumpRenderTreeSupportGtk::findString(webView, targetString.get(), findOptions);
612 bool LayoutTestController::isCommandEnabled(JSStringRef name)
614 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
617 gchar* cName = JSStringCopyUTF8CString(name);
618 bool result = DumpRenderTreeSupportGtk::isCommandEnabled(view, cName);
623 void LayoutTestController::setCacheModel(int cacheModel)
625 // These constants are derived from the Mac cache model enum in Source/WebKit/mac/WebView/WebPreferences.h.
626 switch (cacheModel) {
628 webkit_set_cache_model(WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER);
631 webkit_set_cache_model(WEBKIT_CACHE_MODEL_DOCUMENT_BROWSER);
634 webkit_set_cache_model(WEBKIT_CACHE_MODEL_DOCUMENT_BROWSER);
637 ASSERT_NOT_REACHED();
641 void LayoutTestController::setPersistentUserStyleSheetLocation(JSStringRef jsURL)
646 void LayoutTestController::clearPersistentUserStyleSheet()
651 void LayoutTestController::clearAllApplicationCaches()
653 // FIXME: Implement to support application cache quotas.
656 void LayoutTestController::setApplicationCacheOriginQuota(unsigned long long quota)
658 // FIXME: Implement to support application cache quotas.
661 void LayoutTestController::clearApplicationCacheForOrigin(OpaqueJSString*)
663 // FIXME: Implement to support deleting all application caches for an origin.
666 long long LayoutTestController::localStorageDiskUsageForOrigin(JSStringRef originIdentifier)
668 // FIXME: Implement to support getting disk usage in bytes for an origin.
672 JSValueRef LayoutTestController::originsWithApplicationCache(JSContextRef context)
674 // FIXME: Implement to get origins that contain application caches.
675 return JSValueMakeUndefined(context);
678 long long LayoutTestController::applicationCacheDiskUsageForOrigin(JSStringRef name)
684 void LayoutTestController::clearAllDatabases()
686 webkit_remove_all_web_databases();
689 void LayoutTestController::setDatabaseQuota(unsigned long long quota)
691 WebKitSecurityOrigin* origin = webkit_web_frame_get_security_origin(mainFrame);
692 webkit_security_origin_set_web_database_quota(origin, quota);
695 JSValueRef LayoutTestController::originsWithLocalStorage(JSContextRef context)
698 return JSValueMakeUndefined(context);
701 void LayoutTestController::deleteAllLocalStorage()
706 void LayoutTestController::deleteLocalStorageForOrigin(JSStringRef originIdentifier)
711 void LayoutTestController::observeStorageTrackerNotifications(unsigned number)
716 void LayoutTestController::syncLocalStorage()
721 void LayoutTestController::setDomainRelaxationForbiddenForURLScheme(bool, JSStringRef)
726 void LayoutTestController::goBack()
728 // FIXME: implement to enable loader/navigation-while-deferring-loads.html
731 void LayoutTestController::setDefersLoading(bool)
733 // FIXME: implement to enable loader/navigation-while-deferring-loads.html
736 void LayoutTestController::setAppCacheMaximumSize(unsigned long long size)
738 webkit_application_cache_set_maximum_size(size);
741 bool LayoutTestController::pauseAnimationAtTimeOnElementWithId(JSStringRef animationName, double time, JSStringRef elementId)
743 gchar* name = JSStringCopyUTF8CString(animationName);
744 gchar* element = JSStringCopyUTF8CString(elementId);
745 bool returnValue = DumpRenderTreeSupportGtk::pauseAnimation(mainFrame, name, time, element);
751 bool LayoutTestController::pauseTransitionAtTimeOnElementWithId(JSStringRef propertyName, double time, JSStringRef elementId)
753 gchar* name = JSStringCopyUTF8CString(propertyName);
754 gchar* element = JSStringCopyUTF8CString(elementId);
755 bool returnValue = DumpRenderTreeSupportGtk::pauseTransition(mainFrame, name, time, element);
761 bool LayoutTestController::sampleSVGAnimationForElementAtTime(JSStringRef animationId, double time, JSStringRef elementId)
763 gchar* name = JSStringCopyUTF8CString(animationId);
764 gchar* element = JSStringCopyUTF8CString(elementId);
765 bool returnValue = DumpRenderTreeSupportGtk::pauseSVGAnimation(mainFrame, name, time, element);
771 unsigned LayoutTestController::numberOfActiveAnimations() const
773 return DumpRenderTreeSupportGtk::numberOfActiveAnimations(mainFrame);
776 void LayoutTestController::suspendAnimations() const
778 DumpRenderTreeSupportGtk::suspendAnimations(mainFrame);
781 void LayoutTestController::resumeAnimations() const
783 DumpRenderTreeSupportGtk::resumeAnimations(mainFrame);
786 void LayoutTestController::overridePreference(JSStringRef key, JSStringRef value)
788 GOwnPtr<gchar> originalName(JSStringCopyUTF8CString(key));
789 GOwnPtr<gchar> valueAsString(JSStringCopyUTF8CString(value));
791 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
794 // This transformation could be handled by a hash table (and it once was), but
795 // having it prominent, makes it easier for people from other ports to keep the
797 const gchar* propertyName = 0;
798 if (g_str_equal(originalName.get(), "WebKitJavaScriptEnabled"))
799 propertyName = "enable-scripts";
800 else if (g_str_equal(originalName.get(), "WebKitDefaultFontSize"))
801 propertyName = "default-font-size";
802 else if (g_str_equal(originalName.get(), "WebKitEnableCaretBrowsing"))
803 propertyName = "enable-caret-browsing";
804 else if (g_str_equal(originalName.get(), "WebKitUsesPageCachePreferenceKey"))
805 propertyName = "enable-page-cache";
806 else if (g_str_equal(originalName.get(), "WebKitPluginsEnabled"))
807 propertyName = "enable-plugins";
808 else if (g_str_equal(originalName.get(), "WebKitHyperlinkAuditingEnabled"))
809 propertyName = "enable-hyperlink-auditing";
810 else if (g_str_equal(originalName.get(), "WebKitWebGLEnabled"))
811 propertyName = "enable-webgl";
812 else if (g_str_equal(originalName.get(), "WebKitTabToLinksPreferenceKey")) {
813 DumpRenderTreeSupportGtk::setLinksIncludedInFocusChain(!g_ascii_strcasecmp(valueAsString.get(), "true") || !g_ascii_strcasecmp(valueAsString.get(), "1"));
816 fprintf(stderr, "LayoutTestController::overridePreference tried to override "
817 "unknown preference '%s'.\n", originalName.get());
821 WebKitWebSettings* settings = webkit_web_view_get_settings(view);
822 GParamSpec* pspec = g_object_class_find_property(G_OBJECT_CLASS(
823 WEBKIT_WEB_SETTINGS_GET_CLASS(settings)), propertyName);
824 GValue currentPropertyValue = { 0, { { 0 } } };
825 g_value_init(¤tPropertyValue, pspec->value_type);
827 if (G_VALUE_HOLDS_STRING(¤tPropertyValue))
828 g_object_set(settings, propertyName, valueAsString.get(), NULL);
829 else if (G_VALUE_HOLDS_BOOLEAN(¤tPropertyValue))
830 g_object_set(G_OBJECT(settings), propertyName, !g_ascii_strcasecmp(valueAsString.get(), "true")
831 || !g_ascii_strcasecmp(valueAsString.get(), "1"), NULL);
832 else if (G_VALUE_HOLDS_INT(¤tPropertyValue))
833 g_object_set(G_OBJECT(settings), propertyName, atoi(valueAsString.get()), NULL);
834 else if (G_VALUE_HOLDS_FLOAT(¤tPropertyValue)) {
835 gfloat newValue = g_ascii_strtod(valueAsString.get(), 0);
836 g_object_set(G_OBJECT(settings), propertyName, newValue, NULL);
838 fprintf(stderr, "LayoutTestController::overridePreference failed to override "
839 "preference '%s'.\n", originalName.get());
842 void LayoutTestController::addUserScript(JSStringRef source, bool runAtStart, bool allFrames)
844 printf("LayoutTestController::addUserScript not implemented.\n");
847 void LayoutTestController::addUserStyleSheet(JSStringRef source, bool allFrames)
849 GOwnPtr<gchar> sourceCode(JSStringCopyUTF8CString(source));
850 DumpRenderTreeSupportGtk::addUserStyleSheet(mainFrame, sourceCode.get(), allFrames);
851 // FIXME: needs more investigation why userscripts/user-style-top-frame-only.html fails when allFrames is false.
855 void LayoutTestController::setDeveloperExtrasEnabled(bool enabled)
857 WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame);
858 WebKitWebSettings* webSettings = webkit_web_view_get_settings(webView);
860 g_object_set(webSettings, "enable-developer-extras", enabled, NULL);
863 void LayoutTestController::setAsynchronousSpellCheckingEnabled(bool)
865 // FIXME: Implement this.
868 void LayoutTestController::showWebInspector()
870 WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame);
871 WebKitWebInspector* inspector = webkit_web_view_get_inspector(webView);
873 webkit_web_inspector_show(inspector);
876 void LayoutTestController::closeWebInspector()
878 WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame);
879 WebKitWebInspector* inspector = webkit_web_view_get_inspector(webView);
881 webkit_web_inspector_close(inspector);
884 void LayoutTestController::evaluateInWebInspector(long callId, JSStringRef script)
886 WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame);
887 WebKitWebInspector* inspector = webkit_web_view_get_inspector(webView);
888 char* scriptString = JSStringCopyUTF8CString(script);
890 webkit_web_inspector_execute_script(inspector, callId, scriptString);
891 g_free(scriptString);
894 void LayoutTestController::evaluateScriptInIsolatedWorld(unsigned worldID, JSObjectRef globalObject, JSStringRef script)
896 // FIXME: Implement this.
899 void LayoutTestController::removeAllVisitedLinks()
901 // FIXME: Implement this.
904 bool LayoutTestController::callShouldCloseOnWebView()
906 return DumpRenderTreeSupportGtk::shouldClose(mainFrame);
909 void LayoutTestController::apiTestNewWindowDataLoadBaseURL(JSStringRef utf8Data, JSStringRef baseURL)
914 void LayoutTestController::apiTestGoToCurrentBackForwardItem()
919 void LayoutTestController::setWebViewEditable(bool)
923 JSRetainPtr<JSStringRef> LayoutTestController::markerTextForListItem(JSContextRef context, JSValueRef nodeObject) const
925 CString markerTextGChar = DumpRenderTreeSupportGtk::markerTextForListItem(mainFrame, context, nodeObject);
926 if (markerTextGChar.isNull())
929 JSRetainPtr<JSStringRef> markerText(Adopt, JSStringCreateWithUTF8CString(markerTextGChar.data()));
933 void LayoutTestController::authenticateSession(JSStringRef, JSStringRef, JSStringRef)
937 void LayoutTestController::setEditingBehavior(const char* editingBehavior)
939 WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame);
940 WebKitWebSettings* settings = webkit_web_view_get_settings(webView);
942 if (!strcmp(editingBehavior, "win"))
943 g_object_set(G_OBJECT(settings), "editing-behavior", WEBKIT_EDITING_BEHAVIOR_WINDOWS, NULL);
944 else if (!strcmp(editingBehavior, "mac"))
945 g_object_set(G_OBJECT(settings), "editing-behavior", WEBKIT_EDITING_BEHAVIOR_MAC, NULL);
946 else if (!strcmp(editingBehavior, "unix"))
947 g_object_set(G_OBJECT(settings), "editing-behavior", WEBKIT_EDITING_BEHAVIOR_UNIX, NULL);
950 void LayoutTestController::abortModal()
954 bool LayoutTestController::hasSpellingMarker(int from, int length)
956 return DumpRenderTreeSupportGtk::webkitWebFrameSelectionHasSpellingMarker(mainFrame, from, length);
959 bool LayoutTestController::hasGrammarMarker(int from, int length)
964 void LayoutTestController::dumpConfigurationForViewport(int deviceDPI, int deviceWidth, int deviceHeight, int availableWidth, int availableHeight)
966 WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame);
968 DumpRenderTreeSupportGtk::dumpConfigurationForViewport(webView, deviceDPI, deviceWidth, deviceHeight, availableWidth, availableHeight);
971 void LayoutTestController::setSerializeHTTPLoads(bool)
973 // FIXME: Implement if needed for https://bugs.webkit.org/show_bug.cgi?id=50758.
976 void LayoutTestController::setMinimumTimerInterval(double minimumTimerInterval)
978 WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame);
979 DumpRenderTreeSupportGtk::setMinimumTimerInterval(webView, minimumTimerInterval);
982 void LayoutTestController::setTextDirection(JSStringRef direction)
987 void LayoutTestController::allowRoundingHacks()