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 "DumpRenderTree.h"
37 #include "WorkQueue.h"
38 #include "WorkQueueItem.h"
39 #include <JavaScriptCore/JSRetainPtr.h>
40 #include <JavaScriptCore/JSStringRef.h>
46 #include <libsoup/soup.h>
47 #include <webkit/webkit.h>
48 #include <wtf/gobject/GOwnPtr.h>
51 bool webkit_web_frame_pause_animation(WebKitWebFrame* frame, const gchar* name, double time, const gchar* element);
52 bool webkit_web_frame_pause_transition(WebKitWebFrame* frame, const gchar* name, double time, const gchar* element);
53 bool webkit_web_frame_pause_svg_animation(WebKitWebFrame* frame, const gchar* name, double time, const gchar* element);
54 unsigned int webkit_web_frame_number_of_active_animations(WebKitWebFrame* frame);
55 void webkit_web_frame_suspend_animations(WebKitWebFrame* frame);
56 void webkit_web_frame_resume_animations(WebKitWebFrame* frame);
57 void webkit_application_cache_set_maximum_size(unsigned long long size);
58 unsigned int webkit_worker_thread_count(void);
59 void webkit_white_list_access_from_origin(const gchar* sourceOrigin, const gchar* destinationProtocol, const gchar* destinationHost, bool allowDestinationSubdomains);
60 gchar* webkit_web_frame_counter_value_for_element_by_id(WebKitWebFrame* frame, const gchar* id);
61 int webkit_web_frame_page_number_for_element_by_id(WebKitWebFrame* frame, const gchar* id, float pageWidth, float pageHeight);
62 int webkit_web_frame_number_of_pages(WebKitWebFrame* frame, float pageWidth, float pageHeight);
63 void webkit_web_inspector_execute_script(WebKitWebInspector* inspector, long callId, const gchar* script);
64 gchar* webkit_web_frame_marker_text_for_list_item(WebKitWebFrame* frame, JSContextRef context, JSValueRef nodeObject);
65 void webkit_web_view_execute_core_command_by_name(WebKitWebView* webView, const gchar* name, const gchar* value);
66 gboolean webkit_web_view_is_command_enabled(WebKitWebView* webView, const gchar* name);
69 LayoutTestController::~LayoutTestController()
74 void LayoutTestController::addDisallowedURL(JSStringRef url)
79 void LayoutTestController::clearBackForwardList()
81 WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame);
82 WebKitWebBackForwardList* list = webkit_web_view_get_back_forward_list(webView);
83 WebKitWebHistoryItem* item = webkit_web_back_forward_list_get_current_item(list);
86 // We clear the history by setting the back/forward list's capacity to 0
87 // then restoring it back and adding back the current item.
88 gint limit = webkit_web_back_forward_list_get_limit(list);
89 webkit_web_back_forward_list_set_limit(list, 0);
90 webkit_web_back_forward_list_set_limit(list, limit);
91 webkit_web_back_forward_list_add_item(list, item);
92 webkit_web_back_forward_list_go_to_item(list, item);
96 JSStringRef LayoutTestController::copyDecodedHostName(JSStringRef name)
102 JSStringRef LayoutTestController::copyEncodedHostName(JSStringRef name)
108 void LayoutTestController::dispatchPendingLoadRequests()
110 // FIXME: Implement for testing fix for 6727495
113 void LayoutTestController::display()
118 JSRetainPtr<JSStringRef> LayoutTestController::counterValueForElementById(JSStringRef id)
120 gchar* idGChar = JSStringCopyUTF8CString(id);
121 gchar* counterValueGChar = webkit_web_frame_counter_value_for_element_by_id(mainFrame, idGChar);
123 if (!counterValueGChar)
125 JSRetainPtr<JSStringRef> counterValue(Adopt, JSStringCreateWithUTF8CString(counterValueGChar));
129 void LayoutTestController::keepWebHistory()
134 JSValueRef LayoutTestController::computedStyleIncludingVisitedInfo(JSContextRef context, JSValueRef value)
136 // FIXME: Implement this.
137 return JSValueMakeUndefined(context);
140 JSValueRef LayoutTestController::nodesFromRect(JSContextRef context, JSValueRef value, int x, int y, unsigned top, unsigned right, unsigned bottom, unsigned left, bool ignoreClipping)
142 // FIXME: Implement this.
143 return JSValueMakeUndefined(context);
146 JSRetainPtr<JSStringRef> LayoutTestController::layerTreeAsText() const
149 JSRetainPtr<JSStringRef> string(Adopt, JSStringCreateWithUTF8CString(""));
153 int LayoutTestController::pageNumberForElementById(JSStringRef id, float pageWidth, float pageHeight)
155 gchar* idGChar = JSStringCopyUTF8CString(id);
156 int pageNumber = webkit_web_frame_page_number_for_element_by_id(mainFrame, idGChar, pageWidth, pageHeight);
161 int LayoutTestController::numberOfPages(float pageWidth, float pageHeight)
163 return webkit_web_frame_number_of_pages(mainFrame, pageWidth, pageHeight);
166 JSRetainPtr<JSStringRef> LayoutTestController::pageProperty(const char* propertyName, int pageNumber) const
169 return JSRetainPtr<JSStringRef>();
172 bool LayoutTestController::isPageBoxVisible(int pageNumber) const
178 JSRetainPtr<JSStringRef> LayoutTestController::pageSizeAndMarginsInPixels(int pageNumber, int width, int height, int marginTop, int marginRight, int marginBottom, int marginLeft) const
181 return JSRetainPtr<JSStringRef>();
184 size_t LayoutTestController::webHistoryItemCount()
186 WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame);
187 WebKitWebBackForwardList* list = webkit_web_view_get_back_forward_list(webView);
192 // We do not add the current page to the total count as it's not
193 // considered in DRT tests
194 return webkit_web_back_forward_list_get_back_length(list) +
195 webkit_web_back_forward_list_get_forward_length(list);
198 unsigned LayoutTestController::workerThreadCount() const
200 return webkit_worker_thread_count();
203 void LayoutTestController::notifyDone()
205 if (m_waitToDump && !topLoadingFrame && !WorkQueue::shared()->count())
207 m_waitToDump = false;
208 waitForPolicy = false;
211 JSStringRef LayoutTestController::pathToLocalResource(JSContextRef context, JSStringRef url)
213 // Function introduced in r28690. This may need special-casing on Windows.
214 return JSStringRetain(url); // Do nothing on Unix.
217 void LayoutTestController::queueLoad(JSStringRef url, JSStringRef target)
219 gchar* relativeURL = JSStringCopyUTF8CString(url);
220 SoupURI* baseURI = soup_uri_new(webkit_web_frame_get_uri(mainFrame));
222 SoupURI* absoluteURI = soup_uri_new_with_base(baseURI, relativeURL);
223 soup_uri_free(baseURI);
226 gchar* absoluteCString;
228 absoluteCString = soup_uri_to_string(absoluteURI, FALSE);
229 soup_uri_free(absoluteURI);
231 absoluteCString = JSStringCopyUTF8CString(url);
233 JSRetainPtr<JSStringRef> absoluteURL(Adopt, JSStringCreateWithUTF8CString(absoluteCString));
234 g_free(absoluteCString);
236 WorkQueue::shared()->queue(new LoadItem(absoluteURL.get(), target));
239 void LayoutTestController::setAcceptsEditing(bool acceptsEditing)
241 WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame);
242 webkit_web_view_set_editable(webView, acceptsEditing);
245 void LayoutTestController::setAlwaysAcceptCookies(bool alwaysAcceptCookies)
247 #ifdef HAVE_LIBSOUP_2_29_90
248 SoupSession* session = webkit_get_default_session();
249 SoupCookieJar* jar = reinterpret_cast<SoupCookieJar*>(soup_session_get_feature(session, SOUP_TYPE_COOKIE_JAR));
251 /* If the jar was not created - we create it on demand, i.e, just
252 in case we have HTTP requests - then we must create it here in
253 order to set the proper accept policy */
255 jar = soup_cookie_jar_new();
256 soup_session_add_feature(session, SOUP_SESSION_FEATURE(jar));
260 SoupCookieJarAcceptPolicy policy;
262 if (alwaysAcceptCookies)
263 policy = SOUP_COOKIE_JAR_ACCEPT_ALWAYS;
265 policy = SOUP_COOKIE_JAR_ACCEPT_NO_THIRD_PARTY;
267 g_object_set(G_OBJECT(jar), SOUP_COOKIE_JAR_ACCEPT_POLICY, policy, NULL);
271 void LayoutTestController::setCustomPolicyDelegate(bool setDelegate, bool permissive)
276 void LayoutTestController::waitForPolicyDelegate()
278 waitForPolicy = true;
282 void LayoutTestController::setScrollbarPolicy(JSStringRef orientation, JSStringRef policy)
287 void LayoutTestController::addOriginAccessWhitelistEntry(JSStringRef sourceOrigin, JSStringRef protocol, JSStringRef host, bool includeSubdomains)
289 gchar* sourceOriginGChar = JSStringCopyUTF8CString(sourceOrigin);
290 gchar* protocolGChar = JSStringCopyUTF8CString(protocol);
291 gchar* hostGChar = JSStringCopyUTF8CString(host);
292 webkit_white_list_access_from_origin(sourceOriginGChar, protocolGChar, hostGChar, includeSubdomains);
293 g_free(sourceOriginGChar);
294 g_free(protocolGChar);
298 void LayoutTestController::removeOriginAccessWhitelistEntry(JSStringRef sourceOrigin, JSStringRef protocol, JSStringRef host, bool includeSubdomains)
303 void LayoutTestController::setMainFrameIsFirstResponder(bool flag)
308 void LayoutTestController::setTabKeyCyclesThroughElements(bool cycles)
310 WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame);
311 WebKitWebSettings* settings = webkit_web_view_get_settings(webView);
312 g_object_set(G_OBJECT(settings), "tab-key-cycles-through-elements", cycles, NULL);
315 void LayoutTestController::setTimelineProfilingEnabled(bool flag)
317 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
320 WebKitWebInspector* inspector = webkit_web_view_get_inspector(view);
321 g_object_set(G_OBJECT(inspector), "timeline-profiling-enabled", flag, NULL);
324 void LayoutTestController::setUseDashboardCompatibilityMode(bool flag)
329 static gchar* userStyleSheet = NULL;
330 static gboolean userStyleSheetEnabled = TRUE;
332 void LayoutTestController::setUserStyleSheetEnabled(bool flag)
334 userStyleSheetEnabled = flag;
336 WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame);
337 WebKitWebSettings* settings = webkit_web_view_get_settings(webView);
338 if (flag && userStyleSheet)
339 g_object_set(G_OBJECT(settings), "user-stylesheet-uri", userStyleSheet, NULL);
341 g_object_set(G_OBJECT(settings), "user-stylesheet-uri", "", NULL);
344 void LayoutTestController::setUserStyleSheetLocation(JSStringRef path)
346 g_free(userStyleSheet);
347 userStyleSheet = JSStringCopyUTF8CString(path);
348 if (userStyleSheetEnabled)
349 setUserStyleSheetEnabled(true);
352 void LayoutTestController::setViewModeMediaFeature(JSStringRef mode)
354 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
357 char* viewMode = JSStringCopyUTF8CString(mode);
359 if (!g_strcmp0(viewMode, "windowed"))
360 webkit_web_view_set_view_mode(view, WEBKIT_WEB_VIEW_VIEW_MODE_WINDOWED);
361 else if (!g_strcmp0(viewMode, "floating"))
362 webkit_web_view_set_view_mode(view, WEBKIT_WEB_VIEW_VIEW_MODE_FLOATING);
363 else if (!g_strcmp0(viewMode, "fullscreen"))
364 webkit_web_view_set_view_mode(view, WEBKIT_WEB_VIEW_VIEW_MODE_FULLSCREEN);
365 else if (!g_strcmp0(viewMode, "maximized"))
366 webkit_web_view_set_view_mode(view, WEBKIT_WEB_VIEW_VIEW_MODE_MAXIMIZED);
367 else if (!g_strcmp0(viewMode, "minimized"))
368 webkit_web_view_set_view_mode(view, WEBKIT_WEB_VIEW_VIEW_MODE_MINIMIZED);
373 void LayoutTestController::setWindowIsKey(bool windowIsKey)
378 void LayoutTestController::setSmartInsertDeleteEnabled(bool flag)
383 static gboolean waitToDumpWatchdogFired(void*)
385 waitToDumpWatchdog = 0;
386 gLayoutTestController->waitToDumpWatchdogTimerFired();
390 void LayoutTestController::setWaitToDump(bool waitUntilDone)
392 static const int timeoutSeconds = 30;
394 m_waitToDump = waitUntilDone;
395 if (m_waitToDump && !waitToDumpWatchdog)
396 waitToDumpWatchdog = g_timeout_add_seconds(timeoutSeconds, waitToDumpWatchdogFired, 0);
399 int LayoutTestController::windowCount()
401 // +1 -> including the main view
402 return g_slist_length(webViewList) + 1;
405 void LayoutTestController::setPrivateBrowsingEnabled(bool flag)
407 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
410 WebKitWebSettings* settings = webkit_web_view_get_settings(view);
411 g_object_set(G_OBJECT(settings), "enable-private-browsing", flag, NULL);
414 void LayoutTestController::setJavaScriptCanAccessClipboard(bool flag)
416 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
419 WebKitWebSettings* settings = webkit_web_view_get_settings(view);
420 g_object_set(G_OBJECT(settings), "javascript-can-access-clipboard", flag, NULL);
423 void LayoutTestController::setXSSAuditorEnabled(bool flag)
425 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
428 WebKitWebSettings* settings = webkit_web_view_get_settings(view);
429 g_object_set(G_OBJECT(settings), "enable-xss-auditor", flag, NULL);
432 void LayoutTestController::setFrameFlatteningEnabled(bool flag)
434 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
437 WebKitWebSettings* settings = webkit_web_view_get_settings(view);
438 g_object_set(G_OBJECT(settings), "enable-frame-flattening", flag, NULL);
441 void LayoutTestController::setSpatialNavigationEnabled(bool flag)
443 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
446 WebKitWebSettings* settings = webkit_web_view_get_settings(view);
447 g_object_set(G_OBJECT(settings), "enable-spatial-navigation", flag, NULL);
450 void LayoutTestController::setAllowUniversalAccessFromFileURLs(bool flag)
452 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
455 WebKitWebSettings* settings = webkit_web_view_get_settings(view);
456 g_object_set(G_OBJECT(settings), "enable-universal-access-from-file-uris", flag, NULL);
459 void LayoutTestController::setAllowFileAccessFromFileURLs(bool flag)
461 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
464 WebKitWebSettings* settings = webkit_web_view_get_settings(view);
465 g_object_set(G_OBJECT(settings), "enable-file-access-from-file-uris", flag, NULL);
468 void LayoutTestController::setAuthorAndUserStylesEnabled(bool flag)
473 void LayoutTestController::disableImageLoading()
475 // FIXME: Implement for testing fix for https://bugs.webkit.org/show_bug.cgi?id=27896
476 // Also need to make sure image loading is re-enabled for each new test.
479 void LayoutTestController::setMockDeviceOrientation(bool canProvideAlpha, double alpha, bool canProvideBeta, double beta, bool canProvideGamma, double gamma)
481 // FIXME: Implement for DeviceOrientation layout tests.
482 // See https://bugs.webkit.org/show_bug.cgi?id=30335.
485 void LayoutTestController::setMockGeolocationPosition(double latitude, double longitude, double accuracy)
487 // FIXME: Implement for Geolocation layout tests.
488 // See https://bugs.webkit.org/show_bug.cgi?id=28264.
491 void LayoutTestController::setMockGeolocationError(int code, JSStringRef message)
493 // FIXME: Implement for Geolocation layout tests.
494 // See https://bugs.webkit.org/show_bug.cgi?id=28264.
497 void LayoutTestController::setGeolocationPermission(bool allow)
499 // FIXME: Implement for Geolocation layout tests.
500 setGeolocationPermissionCommon(allow);
503 void LayoutTestController::setMockSpeechInputResult(JSStringRef result)
505 // FIXME: Implement for speech input layout tests.
506 // See https://bugs.webkit.org/show_bug.cgi?id=39485.
509 void LayoutTestController::setIconDatabaseEnabled(bool flag)
514 void LayoutTestController::setJavaScriptProfilingEnabled(bool flag)
516 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
519 setDeveloperExtrasEnabled(flag);
521 WebKitWebInspector* inspector = webkit_web_view_get_inspector(view);
522 g_object_set(G_OBJECT(inspector), "javascript-profiling-enabled", flag, NULL);
525 void LayoutTestController::setSelectTrailingWhitespaceEnabled(bool flag)
530 void LayoutTestController::setPopupBlockingEnabled(bool flag)
532 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
535 WebKitWebSettings* settings = webkit_web_view_get_settings(view);
536 g_object_set(G_OBJECT(settings), "javascript-can-open-windows-automatically", !flag, NULL);
540 void LayoutTestController::setPluginsEnabled(bool flag)
545 bool LayoutTestController::elementDoesAutoCompleteForElementWithId(JSStringRef id)
551 void LayoutTestController::execCommand(JSStringRef name, JSStringRef value)
553 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
556 gchar* cName = JSStringCopyUTF8CString(name);
557 gchar* cValue = JSStringCopyUTF8CString(value);
558 webkit_web_view_execute_core_command_by_name(view, cName, cValue);
563 bool LayoutTestController::isCommandEnabled(JSStringRef name)
565 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
568 gchar* cName = JSStringCopyUTF8CString(name);
569 gboolean result = webkit_web_view_is_command_enabled(view, cName);
574 void LayoutTestController::setCacheModel(int)
579 void LayoutTestController::setPersistentUserStyleSheetLocation(JSStringRef jsURL)
584 void LayoutTestController::clearPersistentUserStyleSheet()
589 void LayoutTestController::clearAllApplicationCaches()
591 // FIXME: implement to support Application Cache quotas.
594 void LayoutTestController::setApplicationCacheOriginQuota(unsigned long long quota)
596 // FIXME: implement to support Application Cache quotas.
599 void LayoutTestController::clearAllDatabases()
601 webkit_remove_all_web_databases();
604 void LayoutTestController::setDatabaseQuota(unsigned long long quota)
606 WebKitSecurityOrigin* origin = webkit_web_frame_get_security_origin(mainFrame);
607 webkit_security_origin_set_web_database_quota(origin, quota);
610 void LayoutTestController::setDomainRelaxationForbiddenForURLScheme(bool, JSStringRef)
615 void LayoutTestController::setAppCacheMaximumSize(unsigned long long size)
617 webkit_application_cache_set_maximum_size(size);
620 bool LayoutTestController::pauseAnimationAtTimeOnElementWithId(JSStringRef animationName, double time, JSStringRef elementId)
622 gchar* name = JSStringCopyUTF8CString(animationName);
623 gchar* element = JSStringCopyUTF8CString(elementId);
624 bool returnValue = webkit_web_frame_pause_animation(mainFrame, name, time, element);
630 bool LayoutTestController::pauseTransitionAtTimeOnElementWithId(JSStringRef propertyName, double time, JSStringRef elementId)
632 gchar* name = JSStringCopyUTF8CString(propertyName);
633 gchar* element = JSStringCopyUTF8CString(elementId);
634 bool returnValue = webkit_web_frame_pause_transition(mainFrame, name, time, element);
640 bool LayoutTestController::sampleSVGAnimationForElementAtTime(JSStringRef animationId, double time, JSStringRef elementId)
642 gchar* name = JSStringCopyUTF8CString(animationId);
643 gchar* element = JSStringCopyUTF8CString(elementId);
644 bool returnValue = webkit_web_frame_pause_svg_animation(mainFrame, name, time, element);
650 unsigned LayoutTestController::numberOfActiveAnimations() const
652 return webkit_web_frame_number_of_active_animations(mainFrame);
655 void LayoutTestController::suspendAnimations() const
657 webkit_web_frame_suspend_animations(mainFrame);
660 void LayoutTestController::resumeAnimations() const
662 webkit_web_frame_resume_animations(mainFrame);
665 void LayoutTestController::overridePreference(JSStringRef key, JSStringRef value)
667 GOwnPtr<gchar> originalName(JSStringCopyUTF8CString(key));
668 GOwnPtr<gchar> valueAsString(JSStringCopyUTF8CString(value));
670 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
673 // This transformation could be handled by a hash table (and it once was), but
674 // having it prominent, makes it easier for people from other ports to keep the
676 const gchar* propertyName = 0;
677 if (g_str_equal(originalName.get(), "WebKitJavaScriptEnabled"))
678 propertyName = "enable-scripts";
679 else if (g_str_equal(originalName.get(), "WebKitDefaultFontSize"))
680 propertyName = "default-font-size";
681 else if (g_str_equal(originalName.get(), "WebKitEnableCaretBrowsing"))
682 propertyName = "enable-caret-browsing";
683 else if (g_str_equal(originalName.get(), "WebKitUsesPageCachePreferenceKey"))
684 propertyName = "enable-page-cache";
685 else if (g_str_equal(originalName.get(), "WebKitPluginsEnabled"))
686 propertyName = "enable-plugins";
687 else if (g_str_equal(originalName.get(), "WebKitHyperlinkAuditingEnabled"))
688 propertyName = "enable-hyperlink-auditing";
690 fprintf(stderr, "LayoutTestController::overridePreference tried to override "
691 "unknown preference '%s'.\n", originalName.get());
695 WebKitWebSettings* settings = webkit_web_view_get_settings(view);
696 GParamSpec* pspec = g_object_class_find_property(G_OBJECT_CLASS(
697 WEBKIT_WEB_SETTINGS_GET_CLASS(settings)), propertyName);
698 GValue currentPropertyValue = { 0, { { 0 } } };
699 g_value_init(¤tPropertyValue, pspec->value_type);
701 if (G_VALUE_HOLDS_STRING(¤tPropertyValue))
702 g_object_set(settings, propertyName, valueAsString.get(), NULL);
703 else if (G_VALUE_HOLDS_BOOLEAN(¤tPropertyValue))
704 g_object_set(G_OBJECT(settings), propertyName, !g_ascii_strcasecmp(valueAsString.get(), "true")
705 || !g_ascii_strcasecmp(valueAsString.get(), "1"), NULL);
706 else if (G_VALUE_HOLDS_INT(¤tPropertyValue))
707 g_object_set(G_OBJECT(settings), propertyName, atoi(valueAsString.get()), NULL);
708 else if (G_VALUE_HOLDS_FLOAT(¤tPropertyValue)) {
709 gfloat newValue = g_ascii_strtod(valueAsString.get(), 0);
710 g_object_set(G_OBJECT(settings), propertyName, newValue, NULL);
712 fprintf(stderr, "LayoutTestController::overridePreference failed to override "
713 "preference '%s'.\n", originalName.get());
716 void LayoutTestController::addUserScript(JSStringRef source, bool runAtStart, bool allFrames)
718 printf("LayoutTestController::addUserScript not implemented.\n");
721 void LayoutTestController::addUserStyleSheet(JSStringRef source, bool allFrames)
723 printf("LayoutTestController::addUserStyleSheet not implemented.\n");
726 void LayoutTestController::setDeveloperExtrasEnabled(bool enabled)
728 WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame);
729 WebKitWebSettings* webSettings = webkit_web_view_get_settings(webView);
731 g_object_set(webSettings, "enable-developer-extras", enabled, NULL);
734 void LayoutTestController::showWebInspector()
736 WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame);
737 WebKitWebInspector* inspector = webkit_web_view_get_inspector(webView);
739 webkit_web_inspector_show(inspector);
742 void LayoutTestController::closeWebInspector()
744 WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame);
745 WebKitWebInspector* inspector = webkit_web_view_get_inspector(webView);
747 webkit_web_inspector_close(inspector);
750 void LayoutTestController::evaluateInWebInspector(long callId, JSStringRef script)
752 WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame);
753 WebKitWebInspector* inspector = webkit_web_view_get_inspector(webView);
754 char* scriptString = JSStringCopyUTF8CString(script);
756 webkit_web_inspector_execute_script(inspector, callId, scriptString);
757 g_free(scriptString);
760 void LayoutTestController::evaluateScriptInIsolatedWorld(unsigned worldID, JSObjectRef globalObject, JSStringRef script)
762 // FIXME: Implement this.
765 void LayoutTestController::removeAllVisitedLinks()
767 // FIXME: Implement this.
770 bool LayoutTestController::callShouldCloseOnWebView()
772 // FIXME: Implement for testing fix for https://bugs.webkit.org/show_bug.cgi?id=27481
776 void LayoutTestController::apiTestNewWindowDataLoadBaseURL(JSStringRef utf8Data, JSStringRef baseURL)
781 void LayoutTestController::apiTestGoToCurrentBackForwardItem()
786 void LayoutTestController::setWebViewEditable(bool)
790 JSRetainPtr<JSStringRef> LayoutTestController::markerTextForListItem(JSContextRef context, JSValueRef nodeObject) const
792 gchar* markerTextGChar = webkit_web_frame_marker_text_for_list_item(mainFrame, context, nodeObject);
793 if (!markerTextGChar)
796 JSRetainPtr<JSStringRef> markerText(Adopt, JSStringCreateWithUTF8CString(markerTextGChar));
797 g_free(markerTextGChar);
801 void LayoutTestController::authenticateSession(JSStringRef, JSStringRef, JSStringRef)
805 void LayoutTestController::setEditingBehavior(const char* editingBehavior)
807 WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame);
808 WebKitWebSettings* settings = webkit_web_view_get_settings(webView);
810 if (!strcmp(editingBehavior, "win"))
811 g_object_set(G_OBJECT(settings), "editing-behavior", WEBKIT_EDITING_BEHAVIOR_WINDOWS, NULL);
812 if (!strcmp(editingBehavior, "mac"))
813 g_object_set(G_OBJECT(settings), "editing-behavior", WEBKIT_EDITING_BEHAVIOR_MAC, NULL);
816 void LayoutTestController::abortModal()
820 bool LayoutTestController::hasSpellingMarker(int, int)
822 // FIXME: Implement this.