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 Collabora Ltd.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
18 * its contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
22 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
25 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
28 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 #include "LayoutTestController.h"
36 #include "../../../WebKit/gtk/WebCoreSupport/DumpRenderTreeSupportGtk.h"
37 #include "DumpRenderTree.h"
38 #include "WorkQueue.h"
39 #include "WorkQueueItem.h"
40 #include <JavaScriptCore/JSRetainPtr.h>
41 #include <JavaScriptCore/JSStringRef.h>
47 #include <libsoup/soup.h>
48 #include <webkit/webkit.h>
49 #include <wtf/gobject/GOwnPtr.h>
52 bool webkit_web_frame_pause_animation(WebKitWebFrame* frame, const gchar* name, double time, const gchar* element);
53 bool webkit_web_frame_pause_transition(WebKitWebFrame* frame, const gchar* name, double time, const gchar* element);
54 bool webkit_web_frame_pause_svg_animation(WebKitWebFrame* frame, const gchar* name, double time, const gchar* element);
55 unsigned int webkit_web_frame_number_of_active_animations(WebKitWebFrame* frame);
56 void webkit_web_frame_suspend_animations(WebKitWebFrame* frame);
57 void webkit_web_frame_resume_animations(WebKitWebFrame* frame);
58 void webkit_application_cache_set_maximum_size(unsigned long long size);
59 unsigned int webkit_worker_thread_count(void);
60 void webkit_white_list_access_from_origin(const gchar* sourceOrigin, const gchar* destinationProtocol, const gchar* destinationHost, bool allowDestinationSubdomains);
61 gchar* webkit_web_frame_counter_value_for_element_by_id(WebKitWebFrame* frame, const gchar* id);
62 int webkit_web_frame_page_number_for_element_by_id(WebKitWebFrame* frame, const gchar* id, float pageWidth, float pageHeight);
63 int webkit_web_frame_number_of_pages(WebKitWebFrame* frame, float pageWidth, float pageHeight);
64 void webkit_web_inspector_execute_script(WebKitWebInspector* inspector, long callId, const gchar* script);
65 gchar* webkit_web_frame_marker_text_for_list_item(WebKitWebFrame* frame, JSContextRef context, JSValueRef nodeObject);
66 void webkit_web_view_execute_core_command_by_name(WebKitWebView* webView, const gchar* name, const gchar* value);
67 gboolean webkit_web_view_is_command_enabled(WebKitWebView* webView, const gchar* name);
70 LayoutTestController::~LayoutTestController()
75 void LayoutTestController::addDisallowedURL(JSStringRef url)
80 void LayoutTestController::clearBackForwardList()
82 WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame);
83 WebKitWebBackForwardList* list = webkit_web_view_get_back_forward_list(webView);
84 WebKitWebHistoryItem* item = webkit_web_back_forward_list_get_current_item(list);
87 // We clear the history by setting the back/forward list's capacity to 0
88 // then restoring it back and adding back the current item.
89 gint limit = webkit_web_back_forward_list_get_limit(list);
90 webkit_web_back_forward_list_set_limit(list, 0);
91 webkit_web_back_forward_list_set_limit(list, limit);
92 webkit_web_back_forward_list_add_item(list, item);
93 webkit_web_back_forward_list_go_to_item(list, item);
97 JSStringRef LayoutTestController::copyDecodedHostName(JSStringRef name)
103 JSStringRef LayoutTestController::copyEncodedHostName(JSStringRef name)
109 void LayoutTestController::dispatchPendingLoadRequests()
111 // FIXME: Implement for testing fix for 6727495
114 void LayoutTestController::display()
119 JSRetainPtr<JSStringRef> LayoutTestController::counterValueForElementById(JSStringRef id)
121 gchar* idGChar = JSStringCopyUTF8CString(id);
122 gchar* counterValueGChar = webkit_web_frame_counter_value_for_element_by_id(mainFrame, idGChar);
124 if (!counterValueGChar)
126 JSRetainPtr<JSStringRef> counterValue(Adopt, JSStringCreateWithUTF8CString(counterValueGChar));
130 void LayoutTestController::keepWebHistory()
135 JSValueRef LayoutTestController::computedStyleIncludingVisitedInfo(JSContextRef context, JSValueRef value)
137 // FIXME: Implement this.
138 return JSValueMakeUndefined(context);
141 JSValueRef LayoutTestController::nodesFromRect(JSContextRef context, JSValueRef value, int x, int y, unsigned top, unsigned right, unsigned bottom, unsigned left, bool ignoreClipping)
143 // FIXME: Implement this.
144 return JSValueMakeUndefined(context);
147 JSRetainPtr<JSStringRef> LayoutTestController::layerTreeAsText() const
150 JSRetainPtr<JSStringRef> string(Adopt, JSStringCreateWithUTF8CString(""));
154 int LayoutTestController::pageNumberForElementById(JSStringRef id, float pageWidth, float pageHeight)
156 gchar* idGChar = JSStringCopyUTF8CString(id);
157 int pageNumber = webkit_web_frame_page_number_for_element_by_id(mainFrame, idGChar, pageWidth, pageHeight);
162 int LayoutTestController::numberOfPages(float pageWidth, float pageHeight)
164 return webkit_web_frame_number_of_pages(mainFrame, pageWidth, pageHeight);
167 JSRetainPtr<JSStringRef> LayoutTestController::pageProperty(const char* propertyName, int pageNumber) const
170 return JSRetainPtr<JSStringRef>();
173 bool LayoutTestController::isPageBoxVisible(int pageNumber) const
179 JSRetainPtr<JSStringRef> LayoutTestController::pageSizeAndMarginsInPixels(int pageNumber, int width, int height, int marginTop, int marginRight, int marginBottom, int marginLeft) const
182 return JSRetainPtr<JSStringRef>();
185 size_t LayoutTestController::webHistoryItemCount()
187 WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame);
188 WebKitWebBackForwardList* list = webkit_web_view_get_back_forward_list(webView);
193 // We do not add the current page to the total count as it's not
194 // considered in DRT tests
195 return webkit_web_back_forward_list_get_back_length(list) +
196 webkit_web_back_forward_list_get_forward_length(list);
199 unsigned LayoutTestController::workerThreadCount() const
201 return webkit_worker_thread_count();
204 void LayoutTestController::notifyDone()
206 if (m_waitToDump && !topLoadingFrame && !WorkQueue::shared()->count())
208 m_waitToDump = false;
209 waitForPolicy = false;
212 JSStringRef LayoutTestController::pathToLocalResource(JSContextRef context, JSStringRef url)
214 // Function introduced in r28690. This may need special-casing on Windows.
215 return JSStringRetain(url); // Do nothing on Unix.
218 void LayoutTestController::queueLoad(JSStringRef url, JSStringRef target)
220 gchar* relativeURL = JSStringCopyUTF8CString(url);
221 SoupURI* baseURI = soup_uri_new(webkit_web_frame_get_uri(mainFrame));
223 SoupURI* absoluteURI = soup_uri_new_with_base(baseURI, relativeURL);
224 soup_uri_free(baseURI);
227 gchar* absoluteCString;
229 absoluteCString = soup_uri_to_string(absoluteURI, FALSE);
230 soup_uri_free(absoluteURI);
232 absoluteCString = JSStringCopyUTF8CString(url);
234 JSRetainPtr<JSStringRef> absoluteURL(Adopt, JSStringCreateWithUTF8CString(absoluteCString));
235 g_free(absoluteCString);
237 WorkQueue::shared()->queue(new LoadItem(absoluteURL.get(), target));
240 void LayoutTestController::setAcceptsEditing(bool acceptsEditing)
242 WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame);
243 webkit_web_view_set_editable(webView, acceptsEditing);
246 void LayoutTestController::setAlwaysAcceptCookies(bool alwaysAcceptCookies)
248 #ifdef HAVE_LIBSOUP_2_29_90
249 SoupSession* session = webkit_get_default_session();
250 SoupCookieJar* jar = reinterpret_cast<SoupCookieJar*>(soup_session_get_feature(session, SOUP_TYPE_COOKIE_JAR));
252 /* If the jar was not created - we create it on demand, i.e, just
253 in case we have HTTP requests - then we must create it here in
254 order to set the proper accept policy */
256 jar = soup_cookie_jar_new();
257 soup_session_add_feature(session, SOUP_SESSION_FEATURE(jar));
261 SoupCookieJarAcceptPolicy policy;
263 if (alwaysAcceptCookies)
264 policy = SOUP_COOKIE_JAR_ACCEPT_ALWAYS;
266 policy = SOUP_COOKIE_JAR_ACCEPT_NO_THIRD_PARTY;
268 g_object_set(G_OBJECT(jar), SOUP_COOKIE_JAR_ACCEPT_POLICY, policy, NULL);
272 void LayoutTestController::setCustomPolicyDelegate(bool setDelegate, bool permissive)
277 void LayoutTestController::waitForPolicyDelegate()
279 waitForPolicy = true;
283 void LayoutTestController::setScrollbarPolicy(JSStringRef orientation, JSStringRef policy)
288 void LayoutTestController::addOriginAccessWhitelistEntry(JSStringRef sourceOrigin, JSStringRef protocol, JSStringRef host, bool includeSubdomains)
290 gchar* sourceOriginGChar = JSStringCopyUTF8CString(sourceOrigin);
291 gchar* protocolGChar = JSStringCopyUTF8CString(protocol);
292 gchar* hostGChar = JSStringCopyUTF8CString(host);
293 webkit_white_list_access_from_origin(sourceOriginGChar, protocolGChar, hostGChar, includeSubdomains);
294 g_free(sourceOriginGChar);
295 g_free(protocolGChar);
299 void LayoutTestController::removeOriginAccessWhitelistEntry(JSStringRef sourceOrigin, JSStringRef protocol, JSStringRef host, bool includeSubdomains)
304 void LayoutTestController::setMainFrameIsFirstResponder(bool flag)
309 void LayoutTestController::setTabKeyCyclesThroughElements(bool cycles)
311 WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame);
312 WebKitWebSettings* settings = webkit_web_view_get_settings(webView);
313 g_object_set(G_OBJECT(settings), "tab-key-cycles-through-elements", cycles, NULL);
316 void LayoutTestController::setTimelineProfilingEnabled(bool flag)
318 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
321 WebKitWebInspector* inspector = webkit_web_view_get_inspector(view);
322 g_object_set(G_OBJECT(inspector), "timeline-profiling-enabled", flag, NULL);
325 void LayoutTestController::setUseDashboardCompatibilityMode(bool flag)
330 static gchar* userStyleSheet = NULL;
331 static gboolean userStyleSheetEnabled = TRUE;
333 void LayoutTestController::setUserStyleSheetEnabled(bool flag)
335 userStyleSheetEnabled = flag;
337 WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame);
338 WebKitWebSettings* settings = webkit_web_view_get_settings(webView);
339 if (flag && userStyleSheet)
340 g_object_set(G_OBJECT(settings), "user-stylesheet-uri", userStyleSheet, NULL);
342 g_object_set(G_OBJECT(settings), "user-stylesheet-uri", "", NULL);
345 void LayoutTestController::setUserStyleSheetLocation(JSStringRef path)
347 g_free(userStyleSheet);
348 userStyleSheet = JSStringCopyUTF8CString(path);
349 if (userStyleSheetEnabled)
350 setUserStyleSheetEnabled(true);
353 void LayoutTestController::setViewModeMediaFeature(JSStringRef mode)
355 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
358 char* viewMode = JSStringCopyUTF8CString(mode);
360 if (!g_strcmp0(viewMode, "windowed"))
361 webkit_web_view_set_view_mode(view, WEBKIT_WEB_VIEW_VIEW_MODE_WINDOWED);
362 else if (!g_strcmp0(viewMode, "floating"))
363 webkit_web_view_set_view_mode(view, WEBKIT_WEB_VIEW_VIEW_MODE_FLOATING);
364 else if (!g_strcmp0(viewMode, "fullscreen"))
365 webkit_web_view_set_view_mode(view, WEBKIT_WEB_VIEW_VIEW_MODE_FULLSCREEN);
366 else if (!g_strcmp0(viewMode, "maximized"))
367 webkit_web_view_set_view_mode(view, WEBKIT_WEB_VIEW_VIEW_MODE_MAXIMIZED);
368 else if (!g_strcmp0(viewMode, "minimized"))
369 webkit_web_view_set_view_mode(view, WEBKIT_WEB_VIEW_VIEW_MODE_MINIMIZED);
374 void LayoutTestController::setWindowIsKey(bool windowIsKey)
379 void LayoutTestController::setSmartInsertDeleteEnabled(bool flag)
384 static gboolean waitToDumpWatchdogFired(void*)
386 waitToDumpWatchdog = 0;
387 gLayoutTestController->waitToDumpWatchdogTimerFired();
391 void LayoutTestController::setWaitToDump(bool waitUntilDone)
393 static const int timeoutSeconds = 30;
395 m_waitToDump = waitUntilDone;
396 if (m_waitToDump && !waitToDumpWatchdog)
397 waitToDumpWatchdog = g_timeout_add_seconds(timeoutSeconds, waitToDumpWatchdogFired, 0);
400 int LayoutTestController::windowCount()
402 // +1 -> including the main view
403 return g_slist_length(webViewList) + 1;
406 void LayoutTestController::setPrivateBrowsingEnabled(bool flag)
408 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
411 WebKitWebSettings* settings = webkit_web_view_get_settings(view);
412 g_object_set(G_OBJECT(settings), "enable-private-browsing", flag, NULL);
415 void LayoutTestController::setJavaScriptCanAccessClipboard(bool flag)
417 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
420 WebKitWebSettings* settings = webkit_web_view_get_settings(view);
421 g_object_set(G_OBJECT(settings), "javascript-can-access-clipboard", flag, NULL);
424 void LayoutTestController::setXSSAuditorEnabled(bool flag)
426 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
429 WebKitWebSettings* settings = webkit_web_view_get_settings(view);
430 g_object_set(G_OBJECT(settings), "enable-xss-auditor", flag, NULL);
433 void LayoutTestController::setFrameFlatteningEnabled(bool flag)
435 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
438 WebKitWebSettings* settings = webkit_web_view_get_settings(view);
439 g_object_set(G_OBJECT(settings), "enable-frame-flattening", flag, NULL);
442 void LayoutTestController::setSpatialNavigationEnabled(bool flag)
444 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
447 WebKitWebSettings* settings = webkit_web_view_get_settings(view);
448 g_object_set(G_OBJECT(settings), "enable-spatial-navigation", flag, NULL);
451 void LayoutTestController::setAllowUniversalAccessFromFileURLs(bool flag)
453 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
456 WebKitWebSettings* settings = webkit_web_view_get_settings(view);
457 g_object_set(G_OBJECT(settings), "enable-universal-access-from-file-uris", flag, NULL);
460 void LayoutTestController::setAllowFileAccessFromFileURLs(bool flag)
462 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
465 WebKitWebSettings* settings = webkit_web_view_get_settings(view);
466 g_object_set(G_OBJECT(settings), "enable-file-access-from-file-uris", flag, NULL);
469 void LayoutTestController::setAuthorAndUserStylesEnabled(bool flag)
474 void LayoutTestController::disableImageLoading()
476 // FIXME: Implement for testing fix for https://bugs.webkit.org/show_bug.cgi?id=27896
477 // Also need to make sure image loading is re-enabled for each new test.
480 void LayoutTestController::setMockDeviceOrientation(bool canProvideAlpha, double alpha, bool canProvideBeta, double beta, bool canProvideGamma, double gamma)
482 // FIXME: Implement for DeviceOrientation layout tests.
483 // See https://bugs.webkit.org/show_bug.cgi?id=30335.
486 void LayoutTestController::setMockGeolocationPosition(double latitude, double longitude, double accuracy)
488 // FIXME: Implement for Geolocation layout tests.
489 // See https://bugs.webkit.org/show_bug.cgi?id=28264.
492 void LayoutTestController::setMockGeolocationError(int code, JSStringRef message)
494 // FIXME: Implement for Geolocation layout tests.
495 // See https://bugs.webkit.org/show_bug.cgi?id=28264.
498 void LayoutTestController::setGeolocationPermission(bool allow)
500 // FIXME: Implement for Geolocation layout tests.
501 setGeolocationPermissionCommon(allow);
504 void LayoutTestController::setMockSpeechInputResult(JSStringRef result)
506 // FIXME: Implement for speech input layout tests.
507 // See https://bugs.webkit.org/show_bug.cgi?id=39485.
510 void LayoutTestController::setIconDatabaseEnabled(bool flag)
515 void LayoutTestController::setJavaScriptProfilingEnabled(bool flag)
517 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
520 setDeveloperExtrasEnabled(flag);
522 WebKitWebInspector* inspector = webkit_web_view_get_inspector(view);
523 g_object_set(G_OBJECT(inspector), "javascript-profiling-enabled", flag, NULL);
526 void LayoutTestController::setSelectTrailingWhitespaceEnabled(bool flag)
531 void LayoutTestController::setPopupBlockingEnabled(bool flag)
533 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
536 WebKitWebSettings* settings = webkit_web_view_get_settings(view);
537 g_object_set(G_OBJECT(settings), "javascript-can-open-windows-automatically", !flag, NULL);
541 void LayoutTestController::setPluginsEnabled(bool flag)
546 bool LayoutTestController::elementDoesAutoCompleteForElementWithId(JSStringRef id)
552 void LayoutTestController::execCommand(JSStringRef name, JSStringRef value)
554 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
557 gchar* cName = JSStringCopyUTF8CString(name);
558 gchar* cValue = JSStringCopyUTF8CString(value);
559 webkit_web_view_execute_core_command_by_name(view, cName, cValue);
564 bool LayoutTestController::isCommandEnabled(JSStringRef name)
566 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
569 gchar* cName = JSStringCopyUTF8CString(name);
570 gboolean result = webkit_web_view_is_command_enabled(view, cName);
575 void LayoutTestController::setCacheModel(int)
580 void LayoutTestController::setPersistentUserStyleSheetLocation(JSStringRef jsURL)
585 void LayoutTestController::clearPersistentUserStyleSheet()
590 void LayoutTestController::clearAllApplicationCaches()
592 // FIXME: implement to support Application Cache quotas.
595 void LayoutTestController::setApplicationCacheOriginQuota(unsigned long long quota)
597 // FIXME: implement to support Application Cache quotas.
600 void LayoutTestController::clearAllDatabases()
602 webkit_remove_all_web_databases();
605 void LayoutTestController::setDatabaseQuota(unsigned long long quota)
607 WebKitSecurityOrigin* origin = webkit_web_frame_get_security_origin(mainFrame);
608 webkit_security_origin_set_web_database_quota(origin, quota);
611 void LayoutTestController::setDomainRelaxationForbiddenForURLScheme(bool, JSStringRef)
616 void LayoutTestController::setAppCacheMaximumSize(unsigned long long size)
618 webkit_application_cache_set_maximum_size(size);
621 bool LayoutTestController::pauseAnimationAtTimeOnElementWithId(JSStringRef animationName, double time, JSStringRef elementId)
623 gchar* name = JSStringCopyUTF8CString(animationName);
624 gchar* element = JSStringCopyUTF8CString(elementId);
625 bool returnValue = webkit_web_frame_pause_animation(mainFrame, name, time, element);
631 bool LayoutTestController::pauseTransitionAtTimeOnElementWithId(JSStringRef propertyName, double time, JSStringRef elementId)
633 gchar* name = JSStringCopyUTF8CString(propertyName);
634 gchar* element = JSStringCopyUTF8CString(elementId);
635 bool returnValue = webkit_web_frame_pause_transition(mainFrame, name, time, element);
641 bool LayoutTestController::sampleSVGAnimationForElementAtTime(JSStringRef animationId, double time, JSStringRef elementId)
643 gchar* name = JSStringCopyUTF8CString(animationId);
644 gchar* element = JSStringCopyUTF8CString(elementId);
645 bool returnValue = webkit_web_frame_pause_svg_animation(mainFrame, name, time, element);
651 unsigned LayoutTestController::numberOfActiveAnimations() const
653 return webkit_web_frame_number_of_active_animations(mainFrame);
656 void LayoutTestController::suspendAnimations() const
658 webkit_web_frame_suspend_animations(mainFrame);
661 void LayoutTestController::resumeAnimations() const
663 webkit_web_frame_resume_animations(mainFrame);
666 void LayoutTestController::overridePreference(JSStringRef key, JSStringRef value)
668 GOwnPtr<gchar> originalName(JSStringCopyUTF8CString(key));
669 GOwnPtr<gchar> valueAsString(JSStringCopyUTF8CString(value));
671 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
674 // This transformation could be handled by a hash table (and it once was), but
675 // having it prominent, makes it easier for people from other ports to keep the
677 const gchar* propertyName = 0;
678 if (g_str_equal(originalName.get(), "WebKitJavaScriptEnabled"))
679 propertyName = "enable-scripts";
680 else if (g_str_equal(originalName.get(), "WebKitDefaultFontSize"))
681 propertyName = "default-font-size";
682 else if (g_str_equal(originalName.get(), "WebKitEnableCaretBrowsing"))
683 propertyName = "enable-caret-browsing";
684 else if (g_str_equal(originalName.get(), "WebKitUsesPageCachePreferenceKey"))
685 propertyName = "enable-page-cache";
686 else if (g_str_equal(originalName.get(), "WebKitPluginsEnabled"))
687 propertyName = "enable-plugins";
688 else if (g_str_equal(originalName.get(), "WebKitHyperlinkAuditingEnabled"))
689 propertyName = "enable-hyperlink-auditing";
690 else if (g_str_equal(originalName.get(), "WebKitTabToLinksPreferenceKey")) {
691 DumpRenderTreeSupportGtk::setLinksIncludedInFocusChain(!g_ascii_strcasecmp(valueAsString.get(), "true") || !g_ascii_strcasecmp(valueAsString.get(), "1"));
694 fprintf(stderr, "LayoutTestController::overridePreference tried to override "
695 "unknown preference '%s'.\n", originalName.get());
699 WebKitWebSettings* settings = webkit_web_view_get_settings(view);
700 GParamSpec* pspec = g_object_class_find_property(G_OBJECT_CLASS(
701 WEBKIT_WEB_SETTINGS_GET_CLASS(settings)), propertyName);
702 GValue currentPropertyValue = { 0, { { 0 } } };
703 g_value_init(¤tPropertyValue, pspec->value_type);
705 if (G_VALUE_HOLDS_STRING(¤tPropertyValue))
706 g_object_set(settings, propertyName, valueAsString.get(), NULL);
707 else if (G_VALUE_HOLDS_BOOLEAN(¤tPropertyValue))
708 g_object_set(G_OBJECT(settings), propertyName, !g_ascii_strcasecmp(valueAsString.get(), "true")
709 || !g_ascii_strcasecmp(valueAsString.get(), "1"), NULL);
710 else if (G_VALUE_HOLDS_INT(¤tPropertyValue))
711 g_object_set(G_OBJECT(settings), propertyName, atoi(valueAsString.get()), NULL);
712 else if (G_VALUE_HOLDS_FLOAT(¤tPropertyValue)) {
713 gfloat newValue = g_ascii_strtod(valueAsString.get(), 0);
714 g_object_set(G_OBJECT(settings), propertyName, newValue, NULL);
716 fprintf(stderr, "LayoutTestController::overridePreference failed to override "
717 "preference '%s'.\n", originalName.get());
720 void LayoutTestController::addUserScript(JSStringRef source, bool runAtStart, bool allFrames)
722 printf("LayoutTestController::addUserScript not implemented.\n");
725 void LayoutTestController::addUserStyleSheet(JSStringRef source, bool allFrames)
727 printf("LayoutTestController::addUserStyleSheet not implemented.\n");
730 void LayoutTestController::setDeveloperExtrasEnabled(bool enabled)
732 WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame);
733 WebKitWebSettings* webSettings = webkit_web_view_get_settings(webView);
735 g_object_set(webSettings, "enable-developer-extras", enabled, NULL);
738 void LayoutTestController::showWebInspector()
740 WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame);
741 WebKitWebInspector* inspector = webkit_web_view_get_inspector(webView);
743 webkit_web_inspector_show(inspector);
746 void LayoutTestController::closeWebInspector()
748 WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame);
749 WebKitWebInspector* inspector = webkit_web_view_get_inspector(webView);
751 webkit_web_inspector_close(inspector);
754 void LayoutTestController::evaluateInWebInspector(long callId, JSStringRef script)
756 WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame);
757 WebKitWebInspector* inspector = webkit_web_view_get_inspector(webView);
758 char* scriptString = JSStringCopyUTF8CString(script);
760 webkit_web_inspector_execute_script(inspector, callId, scriptString);
761 g_free(scriptString);
764 void LayoutTestController::evaluateScriptInIsolatedWorld(unsigned worldID, JSObjectRef globalObject, JSStringRef script)
766 // FIXME: Implement this.
769 void LayoutTestController::removeAllVisitedLinks()
771 // FIXME: Implement this.
774 bool LayoutTestController::callShouldCloseOnWebView()
776 // FIXME: Implement for testing fix for https://bugs.webkit.org/show_bug.cgi?id=27481
780 void LayoutTestController::apiTestNewWindowDataLoadBaseURL(JSStringRef utf8Data, JSStringRef baseURL)
785 void LayoutTestController::apiTestGoToCurrentBackForwardItem()
790 void LayoutTestController::setWebViewEditable(bool)
794 JSRetainPtr<JSStringRef> LayoutTestController::markerTextForListItem(JSContextRef context, JSValueRef nodeObject) const
796 gchar* markerTextGChar = webkit_web_frame_marker_text_for_list_item(mainFrame, context, nodeObject);
797 if (!markerTextGChar)
800 JSRetainPtr<JSStringRef> markerText(Adopt, JSStringCreateWithUTF8CString(markerTextGChar));
801 g_free(markerTextGChar);
805 void LayoutTestController::authenticateSession(JSStringRef, JSStringRef, JSStringRef)
809 void LayoutTestController::setEditingBehavior(const char* editingBehavior)
811 WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame);
812 WebKitWebSettings* settings = webkit_web_view_get_settings(webView);
814 if (!strcmp(editingBehavior, "win"))
815 g_object_set(G_OBJECT(settings), "editing-behavior", WEBKIT_EDITING_BEHAVIOR_WINDOWS, NULL);
816 if (!strcmp(editingBehavior, "mac"))
817 g_object_set(G_OBJECT(settings), "editing-behavior", WEBKIT_EDITING_BEHAVIOR_MAC, NULL);
820 void LayoutTestController::abortModal()
824 bool LayoutTestController::hasSpellingMarker(int, int)
826 // FIXME: Implement this.