|
1 /* |
|
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. |
|
7 * |
|
8 * Redistribution and use in source and binary forms, with or without |
|
9 * modification, are permitted provided that the following conditions |
|
10 * are met: |
|
11 * |
|
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. |
|
20 * |
|
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. |
|
31 */ |
|
32 |
|
33 #include "config.h" |
|
34 #include "LayoutTestController.h" |
|
35 |
|
36 #include "DumpRenderTree.h" |
|
37 #include "WorkQueue.h" |
|
38 #include "WorkQueueItem.h" |
|
39 #include <JavaScriptCore/JSRetainPtr.h> |
|
40 #include <JavaScriptCore/JSStringRef.h> |
|
41 |
|
42 #include <cstring> |
|
43 #include <iostream> |
|
44 #include <sstream> |
|
45 #include <stdio.h> |
|
46 #include <glib.h> |
|
47 #include <libsoup/soup.h> |
|
48 #include <webkit/webkit.h> |
|
49 |
|
50 extern "C" { |
|
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_application_cache_set_maximum_size(unsigned long long size); |
|
56 unsigned int webkit_worker_thread_count(void); |
|
57 void webkit_white_list_access_from_origin(const gchar* sourceOrigin, const gchar* destinationProtocol, const gchar* destinationHost, bool allowDestinationSubdomains); |
|
58 gchar* webkit_web_frame_counter_value_for_element_by_id(WebKitWebFrame* frame, const gchar* id); |
|
59 int webkit_web_frame_page_number_for_element_by_id(WebKitWebFrame* frame, const gchar* id, float pageWidth, float pageHeight); |
|
60 int webkit_web_frame_number_of_pages(WebKitWebFrame* frame, float pageWidth, float pageHeight); |
|
61 void webkit_web_inspector_execute_script(WebKitWebInspector* inspector, long callId, const gchar* script); |
|
62 gchar* webkit_web_frame_marker_text_for_list_item(WebKitWebFrame* frame, JSContextRef context, JSValueRef nodeObject); |
|
63 } |
|
64 |
|
65 static gchar* copyWebSettingKey(gchar* preferenceKey) |
|
66 { |
|
67 static GHashTable* keyTable; |
|
68 |
|
69 if (!keyTable) { |
|
70 // If you add a pref here, make sure you reset the value in |
|
71 // DumpRenderTree::resetDefaultsToConsistentValues. |
|
72 keyTable = g_hash_table_new(g_str_hash, g_str_equal); |
|
73 g_hash_table_insert(keyTable, g_strdup("WebKitJavaScriptEnabled"), g_strdup("enable-scripts")); |
|
74 g_hash_table_insert(keyTable, g_strdup("WebKitDefaultFontSize"), g_strdup("default-font-size")); |
|
75 g_hash_table_insert(keyTable, g_strdup("WebKitEnableCaretBrowsing"), g_strdup("enable-caret-browsing")); |
|
76 g_hash_table_insert(keyTable, g_strdup("WebKitUsesPageCachePreferenceKey"), g_strdup("enable-page-cache")); |
|
77 g_hash_table_insert(keyTable, g_strdup("WebKitPluginsEnabled"), g_strdup("enable-plugins")); |
|
78 } |
|
79 |
|
80 return g_strdup(static_cast<gchar*>(g_hash_table_lookup(keyTable, preferenceKey))); |
|
81 } |
|
82 |
|
83 LayoutTestController::~LayoutTestController() |
|
84 { |
|
85 // FIXME: implement |
|
86 } |
|
87 |
|
88 void LayoutTestController::addDisallowedURL(JSStringRef url) |
|
89 { |
|
90 // FIXME: implement |
|
91 } |
|
92 |
|
93 void LayoutTestController::clearBackForwardList() |
|
94 { |
|
95 WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame); |
|
96 WebKitWebBackForwardList* list = webkit_web_view_get_back_forward_list(webView); |
|
97 WebKitWebHistoryItem* item = webkit_web_back_forward_list_get_current_item(list); |
|
98 g_object_ref(item); |
|
99 |
|
100 // We clear the history by setting the back/forward list's capacity to 0 |
|
101 // then restoring it back and adding back the current item. |
|
102 gint limit = webkit_web_back_forward_list_get_limit(list); |
|
103 webkit_web_back_forward_list_set_limit(list, 0); |
|
104 webkit_web_back_forward_list_set_limit(list, limit); |
|
105 webkit_web_back_forward_list_add_item(list, item); |
|
106 webkit_web_back_forward_list_go_to_item(list, item); |
|
107 g_object_unref(item); |
|
108 } |
|
109 |
|
110 JSStringRef LayoutTestController::copyDecodedHostName(JSStringRef name) |
|
111 { |
|
112 // FIXME: implement |
|
113 return 0; |
|
114 } |
|
115 |
|
116 JSStringRef LayoutTestController::copyEncodedHostName(JSStringRef name) |
|
117 { |
|
118 // FIXME: implement |
|
119 return 0; |
|
120 } |
|
121 |
|
122 void LayoutTestController::dispatchPendingLoadRequests() |
|
123 { |
|
124 // FIXME: Implement for testing fix for 6727495 |
|
125 } |
|
126 |
|
127 void LayoutTestController::display() |
|
128 { |
|
129 displayWebView(); |
|
130 } |
|
131 |
|
132 JSRetainPtr<JSStringRef> LayoutTestController::counterValueForElementById(JSStringRef id) |
|
133 { |
|
134 gchar* idGChar = JSStringCopyUTF8CString(id); |
|
135 gchar* counterValueGChar = webkit_web_frame_counter_value_for_element_by_id(mainFrame, idGChar); |
|
136 g_free(idGChar); |
|
137 if (!counterValueGChar) |
|
138 return 0; |
|
139 JSRetainPtr<JSStringRef> counterValue(Adopt, JSStringCreateWithUTF8CString(counterValueGChar)); |
|
140 return counterValue; |
|
141 } |
|
142 |
|
143 void LayoutTestController::keepWebHistory() |
|
144 { |
|
145 // FIXME: implement |
|
146 } |
|
147 |
|
148 JSValueRef LayoutTestController::computedStyleIncludingVisitedInfo(JSContextRef context, JSValueRef value) |
|
149 { |
|
150 // FIXME: Implement this. |
|
151 return JSValueMakeUndefined(context); |
|
152 } |
|
153 |
|
154 JSRetainPtr<JSStringRef> LayoutTestController::layerTreeAsText() const |
|
155 { |
|
156 // FIXME: implement |
|
157 JSRetainPtr<JSStringRef> string(Adopt, JSStringCreateWithUTF8CString("")); |
|
158 return string; |
|
159 } |
|
160 |
|
161 int LayoutTestController::pageNumberForElementById(JSStringRef id, float pageWidth, float pageHeight) |
|
162 { |
|
163 gchar* idGChar = JSStringCopyUTF8CString(id); |
|
164 int pageNumber = webkit_web_frame_page_number_for_element_by_id(mainFrame, idGChar, pageWidth, pageHeight); |
|
165 g_free(idGChar); |
|
166 return pageNumber; |
|
167 } |
|
168 |
|
169 int LayoutTestController::numberOfPages(float pageWidth, float pageHeight) |
|
170 { |
|
171 return webkit_web_frame_number_of_pages(mainFrame, pageWidth, pageHeight); |
|
172 } |
|
173 |
|
174 JSRetainPtr<JSStringRef> LayoutTestController::pageProperty(const char* propertyName, int pageNumber) const |
|
175 { |
|
176 // FIXME: implement |
|
177 return JSRetainPtr<JSStringRef>(); |
|
178 } |
|
179 |
|
180 bool LayoutTestController::isPageBoxVisible(int pageNumber) const |
|
181 { |
|
182 // FIXME: implement |
|
183 return false; |
|
184 } |
|
185 |
|
186 JSRetainPtr<JSStringRef> LayoutTestController::pageSizeAndMarginsInPixels(int pageNumber, int width, int height, int marginTop, int marginRight, int marginBottom, int marginLeft) const |
|
187 { |
|
188 // FIXME: implement |
|
189 return JSRetainPtr<JSStringRef>(); |
|
190 } |
|
191 |
|
192 size_t LayoutTestController::webHistoryItemCount() |
|
193 { |
|
194 // FIXME: implement |
|
195 return 0; |
|
196 } |
|
197 |
|
198 unsigned LayoutTestController::workerThreadCount() const |
|
199 { |
|
200 return webkit_worker_thread_count(); |
|
201 } |
|
202 |
|
203 void LayoutTestController::notifyDone() |
|
204 { |
|
205 if (m_waitToDump && !topLoadingFrame && !WorkQueue::shared()->count()) |
|
206 dump(); |
|
207 m_waitToDump = false; |
|
208 waitForPolicy = false; |
|
209 } |
|
210 |
|
211 JSStringRef LayoutTestController::pathToLocalResource(JSContextRef context, JSStringRef url) |
|
212 { |
|
213 // Function introduced in r28690. This may need special-casing on Windows. |
|
214 return JSStringRetain(url); // Do nothing on Unix. |
|
215 } |
|
216 |
|
217 void LayoutTestController::queueLoad(JSStringRef url, JSStringRef target) |
|
218 { |
|
219 gchar* relativeURL = JSStringCopyUTF8CString(url); |
|
220 SoupURI* baseURI = soup_uri_new(webkit_web_frame_get_uri(mainFrame)); |
|
221 |
|
222 SoupURI* absoluteURI = soup_uri_new_with_base(baseURI, relativeURL); |
|
223 soup_uri_free(baseURI); |
|
224 g_free(relativeURL); |
|
225 |
|
226 gchar* absoluteCString; |
|
227 if (absoluteURI) { |
|
228 absoluteCString = soup_uri_to_string(absoluteURI, FALSE); |
|
229 soup_uri_free(absoluteURI); |
|
230 } else |
|
231 absoluteCString = JSStringCopyUTF8CString(url); |
|
232 |
|
233 JSRetainPtr<JSStringRef> absoluteURL(Adopt, JSStringCreateWithUTF8CString(absoluteCString)); |
|
234 g_free(absoluteCString); |
|
235 |
|
236 WorkQueue::shared()->queue(new LoadItem(absoluteURL.get(), target)); |
|
237 } |
|
238 |
|
239 void LayoutTestController::setAcceptsEditing(bool acceptsEditing) |
|
240 { |
|
241 WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame); |
|
242 webkit_web_view_set_editable(webView, acceptsEditing); |
|
243 } |
|
244 |
|
245 void LayoutTestController::setAlwaysAcceptCookies(bool alwaysAcceptCookies) |
|
246 { |
|
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)); |
|
250 |
|
251 SoupCookieJarAcceptPolicy policy; |
|
252 |
|
253 if (alwaysAcceptCookies) |
|
254 policy = SOUP_COOKIE_JAR_ACCEPT_ALWAYS; |
|
255 else |
|
256 policy = SOUP_COOKIE_JAR_ACCEPT_NO_THIRD_PARTY; |
|
257 |
|
258 g_object_set(G_OBJECT(jar), SOUP_COOKIE_JAR_ACCEPT_POLICY, policy, NULL); |
|
259 #endif |
|
260 } |
|
261 |
|
262 void LayoutTestController::setCustomPolicyDelegate(bool setDelegate, bool permissive) |
|
263 { |
|
264 // FIXME: implement |
|
265 } |
|
266 |
|
267 void LayoutTestController::waitForPolicyDelegate() |
|
268 { |
|
269 waitForPolicy = true; |
|
270 setWaitToDump(true); |
|
271 } |
|
272 |
|
273 void LayoutTestController::setScrollbarPolicy(JSStringRef orientation, JSStringRef policy) |
|
274 { |
|
275 // FIXME: implement |
|
276 } |
|
277 |
|
278 void LayoutTestController::addOriginAccessWhitelistEntry(JSStringRef sourceOrigin, JSStringRef protocol, JSStringRef host, bool includeSubdomains) |
|
279 { |
|
280 gchar* sourceOriginGChar = JSStringCopyUTF8CString(sourceOrigin); |
|
281 gchar* protocolGChar = JSStringCopyUTF8CString(protocol); |
|
282 gchar* hostGChar = JSStringCopyUTF8CString(host); |
|
283 webkit_white_list_access_from_origin(sourceOriginGChar, protocolGChar, hostGChar, includeSubdomains); |
|
284 g_free(sourceOriginGChar); |
|
285 g_free(protocolGChar); |
|
286 g_free(hostGChar); |
|
287 } |
|
288 |
|
289 void LayoutTestController::removeOriginAccessWhitelistEntry(JSStringRef sourceOrigin, JSStringRef protocol, JSStringRef host, bool includeSubdomains) |
|
290 { |
|
291 // FIXME: implement |
|
292 } |
|
293 |
|
294 void LayoutTestController::setMainFrameIsFirstResponder(bool flag) |
|
295 { |
|
296 // FIXME: implement |
|
297 } |
|
298 |
|
299 void LayoutTestController::setTabKeyCyclesThroughElements(bool cycles) |
|
300 { |
|
301 WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame); |
|
302 WebKitWebSettings* settings = webkit_web_view_get_settings(webView); |
|
303 g_object_set(G_OBJECT(settings), "tab-key-cycles-through-elements", cycles, NULL); |
|
304 } |
|
305 |
|
306 void LayoutTestController::setTimelineProfilingEnabled(bool flag) |
|
307 { |
|
308 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame); |
|
309 ASSERT(view); |
|
310 |
|
311 WebKitWebInspector* inspector = webkit_web_view_get_inspector(view); |
|
312 g_object_set(G_OBJECT(inspector), "timeline-profiling-enabled", flag, NULL); |
|
313 } |
|
314 |
|
315 void LayoutTestController::setUseDashboardCompatibilityMode(bool flag) |
|
316 { |
|
317 // FIXME: implement |
|
318 } |
|
319 |
|
320 static gchar* userStyleSheet = NULL; |
|
321 static gboolean userStyleSheetEnabled = TRUE; |
|
322 |
|
323 void LayoutTestController::setUserStyleSheetEnabled(bool flag) |
|
324 { |
|
325 userStyleSheetEnabled = flag; |
|
326 |
|
327 WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame); |
|
328 WebKitWebSettings* settings = webkit_web_view_get_settings(webView); |
|
329 if (flag && userStyleSheet) |
|
330 g_object_set(G_OBJECT(settings), "user-stylesheet-uri", userStyleSheet, NULL); |
|
331 else |
|
332 g_object_set(G_OBJECT(settings), "user-stylesheet-uri", "", NULL); |
|
333 } |
|
334 |
|
335 void LayoutTestController::setUserStyleSheetLocation(JSStringRef path) |
|
336 { |
|
337 g_free(userStyleSheet); |
|
338 userStyleSheet = JSStringCopyUTF8CString(path); |
|
339 if (userStyleSheetEnabled) |
|
340 setUserStyleSheetEnabled(true); |
|
341 } |
|
342 |
|
343 void LayoutTestController::setWindowIsKey(bool windowIsKey) |
|
344 { |
|
345 // FIXME: implement |
|
346 } |
|
347 |
|
348 void LayoutTestController::setSmartInsertDeleteEnabled(bool flag) |
|
349 { |
|
350 // FIXME: implement |
|
351 } |
|
352 |
|
353 static gboolean waitToDumpWatchdogFired(void*) |
|
354 { |
|
355 waitToDumpWatchdog = 0; |
|
356 gLayoutTestController->waitToDumpWatchdogTimerFired(); |
|
357 return FALSE; |
|
358 } |
|
359 |
|
360 void LayoutTestController::setWaitToDump(bool waitUntilDone) |
|
361 { |
|
362 static const int timeoutSeconds = 30; |
|
363 |
|
364 m_waitToDump = waitUntilDone; |
|
365 if (m_waitToDump && !waitToDumpWatchdog) |
|
366 waitToDumpWatchdog = g_timeout_add_seconds(timeoutSeconds, waitToDumpWatchdogFired, 0); |
|
367 } |
|
368 |
|
369 int LayoutTestController::windowCount() |
|
370 { |
|
371 // +1 -> including the main view |
|
372 return g_slist_length(webViewList) + 1; |
|
373 } |
|
374 |
|
375 void LayoutTestController::setPrivateBrowsingEnabled(bool flag) |
|
376 { |
|
377 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame); |
|
378 ASSERT(view); |
|
379 |
|
380 WebKitWebSettings* settings = webkit_web_view_get_settings(view); |
|
381 g_object_set(G_OBJECT(settings), "enable-private-browsing", flag, NULL); |
|
382 } |
|
383 |
|
384 void LayoutTestController::setJavaScriptCanAccessClipboard(bool flag) |
|
385 { |
|
386 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame); |
|
387 ASSERT(view); |
|
388 |
|
389 WebKitWebSettings* settings = webkit_web_view_get_settings(view); |
|
390 g_object_set(G_OBJECT(settings), "javascript-can-access-clipboard", flag, NULL); |
|
391 } |
|
392 |
|
393 void LayoutTestController::setXSSAuditorEnabled(bool flag) |
|
394 { |
|
395 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame); |
|
396 ASSERT(view); |
|
397 |
|
398 WebKitWebSettings* settings = webkit_web_view_get_settings(view); |
|
399 g_object_set(G_OBJECT(settings), "enable-xss-auditor", flag, NULL); |
|
400 } |
|
401 |
|
402 void LayoutTestController::setFrameFlatteningEnabled(bool flag) |
|
403 { |
|
404 // FIXME: implement |
|
405 } |
|
406 |
|
407 void LayoutTestController::setSpatialNavigationEnabled(bool flag) |
|
408 { |
|
409 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame); |
|
410 ASSERT(view); |
|
411 |
|
412 WebKitWebSettings* settings = webkit_web_view_get_settings(view); |
|
413 g_object_set(G_OBJECT(settings), "enable-spatial-navigation", flag, NULL); |
|
414 } |
|
415 |
|
416 void LayoutTestController::setAllowUniversalAccessFromFileURLs(bool flag) |
|
417 { |
|
418 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame); |
|
419 ASSERT(view); |
|
420 |
|
421 WebKitWebSettings* settings = webkit_web_view_get_settings(view); |
|
422 g_object_set(G_OBJECT(settings), "enable-universal-access-from-file-uris", flag, NULL); |
|
423 } |
|
424 |
|
425 void LayoutTestController::setAllowFileAccessFromFileURLs(bool flag) |
|
426 { |
|
427 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame); |
|
428 ASSERT(view); |
|
429 |
|
430 WebKitWebSettings* settings = webkit_web_view_get_settings(view); |
|
431 g_object_set(G_OBJECT(settings), "enable-file-access-from-file-uris", flag, NULL); |
|
432 } |
|
433 |
|
434 void LayoutTestController::setAuthorAndUserStylesEnabled(bool flag) |
|
435 { |
|
436 // FIXME: implement |
|
437 } |
|
438 |
|
439 void LayoutTestController::disableImageLoading() |
|
440 { |
|
441 // FIXME: Implement for testing fix for https://bugs.webkit.org/show_bug.cgi?id=27896 |
|
442 // Also need to make sure image loading is re-enabled for each new test. |
|
443 } |
|
444 |
|
445 void LayoutTestController::setMockGeolocationPosition(double latitude, double longitude, double accuracy) |
|
446 { |
|
447 // FIXME: Implement for Geolocation layout tests. |
|
448 // See https://bugs.webkit.org/show_bug.cgi?id=28264. |
|
449 } |
|
450 |
|
451 void LayoutTestController::setMockGeolocationError(int code, JSStringRef message) |
|
452 { |
|
453 // FIXME: Implement for Geolocation layout tests. |
|
454 // See https://bugs.webkit.org/show_bug.cgi?id=28264. |
|
455 } |
|
456 |
|
457 void LayoutTestController::setIconDatabaseEnabled(bool flag) |
|
458 { |
|
459 // FIXME: implement |
|
460 } |
|
461 |
|
462 void LayoutTestController::setJavaScriptProfilingEnabled(bool flag) |
|
463 { |
|
464 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame); |
|
465 ASSERT(view); |
|
466 |
|
467 setDeveloperExtrasEnabled(flag); |
|
468 |
|
469 WebKitWebInspector* inspector = webkit_web_view_get_inspector(view); |
|
470 g_object_set(G_OBJECT(inspector), "javascript-profiling-enabled", flag, NULL); |
|
471 } |
|
472 |
|
473 void LayoutTestController::setSelectTrailingWhitespaceEnabled(bool flag) |
|
474 { |
|
475 // FIXME: implement |
|
476 } |
|
477 |
|
478 void LayoutTestController::setPopupBlockingEnabled(bool flag) |
|
479 { |
|
480 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame); |
|
481 ASSERT(view); |
|
482 |
|
483 WebKitWebSettings* settings = webkit_web_view_get_settings(view); |
|
484 g_object_set(G_OBJECT(settings), "javascript-can-open-windows-automatically", !flag, NULL); |
|
485 |
|
486 } |
|
487 |
|
488 void LayoutTestController::setPluginsEnabled(bool flag) |
|
489 { |
|
490 // FIXME: Implement |
|
491 } |
|
492 |
|
493 bool LayoutTestController::elementDoesAutoCompleteForElementWithId(JSStringRef id) |
|
494 { |
|
495 // FIXME: implement |
|
496 return false; |
|
497 } |
|
498 |
|
499 void LayoutTestController::execCommand(JSStringRef name, JSStringRef value) |
|
500 { |
|
501 // FIXME: implement |
|
502 } |
|
503 |
|
504 void LayoutTestController::setCacheModel(int) |
|
505 { |
|
506 // FIXME: implement |
|
507 } |
|
508 |
|
509 bool LayoutTestController::isCommandEnabled(JSStringRef /*name*/) |
|
510 { |
|
511 // FIXME: implement |
|
512 return false; |
|
513 } |
|
514 |
|
515 void LayoutTestController::setPersistentUserStyleSheetLocation(JSStringRef jsURL) |
|
516 { |
|
517 // FIXME: implement |
|
518 } |
|
519 |
|
520 void LayoutTestController::clearPersistentUserStyleSheet() |
|
521 { |
|
522 // FIXME: implement |
|
523 } |
|
524 |
|
525 void LayoutTestController::clearAllDatabases() |
|
526 { |
|
527 webkit_remove_all_web_databases(); |
|
528 } |
|
529 |
|
530 void LayoutTestController::setDatabaseQuota(unsigned long long quota) |
|
531 { |
|
532 WebKitSecurityOrigin* origin = webkit_web_frame_get_security_origin(mainFrame); |
|
533 webkit_security_origin_set_web_database_quota(origin, quota); |
|
534 } |
|
535 |
|
536 void LayoutTestController::setDomainRelaxationForbiddenForURLScheme(bool, JSStringRef) |
|
537 { |
|
538 // FIXME: implement |
|
539 } |
|
540 |
|
541 void LayoutTestController::setAppCacheMaximumSize(unsigned long long size) |
|
542 { |
|
543 webkit_application_cache_set_maximum_size(size); |
|
544 } |
|
545 |
|
546 bool LayoutTestController::pauseAnimationAtTimeOnElementWithId(JSStringRef animationName, double time, JSStringRef elementId) |
|
547 { |
|
548 gchar* name = JSStringCopyUTF8CString(animationName); |
|
549 gchar* element = JSStringCopyUTF8CString(elementId); |
|
550 bool returnValue = webkit_web_frame_pause_animation(mainFrame, name, time, element); |
|
551 g_free(name); |
|
552 g_free(element); |
|
553 return returnValue; |
|
554 } |
|
555 |
|
556 bool LayoutTestController::pauseTransitionAtTimeOnElementWithId(JSStringRef propertyName, double time, JSStringRef elementId) |
|
557 { |
|
558 gchar* name = JSStringCopyUTF8CString(propertyName); |
|
559 gchar* element = JSStringCopyUTF8CString(elementId); |
|
560 bool returnValue = webkit_web_frame_pause_transition(mainFrame, name, time, element); |
|
561 g_free(name); |
|
562 g_free(element); |
|
563 return returnValue; |
|
564 } |
|
565 |
|
566 bool LayoutTestController::sampleSVGAnimationForElementAtTime(JSStringRef animationId, double time, JSStringRef elementId) |
|
567 { |
|
568 gchar* name = JSStringCopyUTF8CString(animationId); |
|
569 gchar* element = JSStringCopyUTF8CString(elementId); |
|
570 bool returnValue = webkit_web_frame_pause_svg_animation(mainFrame, name, time, element); |
|
571 g_free(name); |
|
572 g_free(element); |
|
573 return returnValue; |
|
574 } |
|
575 |
|
576 unsigned LayoutTestController::numberOfActiveAnimations() const |
|
577 { |
|
578 return webkit_web_frame_number_of_active_animations(mainFrame); |
|
579 } |
|
580 |
|
581 void LayoutTestController::overridePreference(JSStringRef key, JSStringRef value) |
|
582 { |
|
583 gchar* name = JSStringCopyUTF8CString(key); |
|
584 gchar* strValue = JSStringCopyUTF8CString(value); |
|
585 |
|
586 WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame); |
|
587 ASSERT(view); |
|
588 |
|
589 WebKitWebSettings* settings = webkit_web_view_get_settings(view); |
|
590 gchar* webSettingKey = copyWebSettingKey(name); |
|
591 |
|
592 if (webSettingKey) { |
|
593 GValue stringValue = { 0, { { 0 } } }; |
|
594 g_value_init(&stringValue, G_TYPE_STRING); |
|
595 g_value_set_string(&stringValue, const_cast<gchar*>(strValue)); |
|
596 |
|
597 WebKitWebSettingsClass* klass = WEBKIT_WEB_SETTINGS_GET_CLASS(settings); |
|
598 GParamSpec* pspec = g_object_class_find_property(G_OBJECT_CLASS(klass), webSettingKey); |
|
599 GValue propValue = { 0, { { 0 } } }; |
|
600 g_value_init(&propValue, pspec->value_type); |
|
601 |
|
602 if (g_value_type_transformable(G_TYPE_STRING, pspec->value_type)) { |
|
603 g_value_transform(const_cast<GValue*>(&stringValue), &propValue); |
|
604 g_object_set_property(G_OBJECT(settings), webSettingKey, const_cast<GValue*>(&propValue)); |
|
605 } else if (G_VALUE_HOLDS_BOOLEAN(&propValue)) { |
|
606 char* lowered = g_utf8_strdown(strValue, -1); |
|
607 g_object_set(G_OBJECT(settings), webSettingKey, |
|
608 g_str_equal(lowered, "true") |
|
609 || g_str_equal(strValue, "1"), |
|
610 NULL); |
|
611 g_free(lowered); |
|
612 } else if (G_VALUE_HOLDS_INT(&propValue)) { |
|
613 std::string str(strValue); |
|
614 std::stringstream ss(str); |
|
615 int val = 0; |
|
616 if (!(ss >> val).fail()) |
|
617 g_object_set(G_OBJECT(settings), webSettingKey, val, NULL); |
|
618 } else |
|
619 printf("LayoutTestController::overridePreference failed to override preference '%s'.\n", name); |
|
620 } |
|
621 |
|
622 g_free(webSettingKey); |
|
623 g_free(name); |
|
624 g_free(strValue); |
|
625 } |
|
626 |
|
627 void LayoutTestController::addUserScript(JSStringRef source, bool runAtStart, bool allFrames) |
|
628 { |
|
629 printf("LayoutTestController::addUserScript not implemented.\n"); |
|
630 } |
|
631 |
|
632 void LayoutTestController::addUserStyleSheet(JSStringRef source, bool allFrames) |
|
633 { |
|
634 printf("LayoutTestController::addUserStyleSheet not implemented.\n"); |
|
635 } |
|
636 |
|
637 void LayoutTestController::setDeveloperExtrasEnabled(bool enabled) |
|
638 { |
|
639 WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame); |
|
640 WebKitWebSettings* webSettings = webkit_web_view_get_settings(webView); |
|
641 |
|
642 g_object_set(webSettings, "enable-developer-extras", enabled, NULL); |
|
643 } |
|
644 |
|
645 void LayoutTestController::showWebInspector() |
|
646 { |
|
647 WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame); |
|
648 WebKitWebInspector* inspector = webkit_web_view_get_inspector(webView); |
|
649 |
|
650 webkit_web_inspector_show(inspector); |
|
651 } |
|
652 |
|
653 void LayoutTestController::closeWebInspector() |
|
654 { |
|
655 WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame); |
|
656 WebKitWebInspector* inspector = webkit_web_view_get_inspector(webView); |
|
657 |
|
658 webkit_web_inspector_close(inspector); |
|
659 } |
|
660 |
|
661 void LayoutTestController::evaluateInWebInspector(long callId, JSStringRef script) |
|
662 { |
|
663 WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame); |
|
664 WebKitWebInspector* inspector = webkit_web_view_get_inspector(webView); |
|
665 char* scriptString = JSStringCopyUTF8CString(script); |
|
666 |
|
667 webkit_web_inspector_execute_script(inspector, callId, scriptString); |
|
668 g_free(scriptString); |
|
669 } |
|
670 |
|
671 void LayoutTestController::evaluateScriptInIsolatedWorld(unsigned worldID, JSObjectRef globalObject, JSStringRef script) |
|
672 { |
|
673 // FIXME: Implement this. |
|
674 } |
|
675 |
|
676 void LayoutTestController::removeAllVisitedLinks() |
|
677 { |
|
678 // FIXME: Implement this. |
|
679 } |
|
680 |
|
681 bool LayoutTestController::callShouldCloseOnWebView() |
|
682 { |
|
683 // FIXME: Implement for testing fix for https://bugs.webkit.org/show_bug.cgi?id=27481 |
|
684 return false; |
|
685 } |
|
686 |
|
687 void LayoutTestController::apiTestNewWindowDataLoadBaseURL(JSStringRef utf8Data, JSStringRef baseURL) |
|
688 { |
|
689 |
|
690 } |
|
691 |
|
692 void LayoutTestController::apiTestGoToCurrentBackForwardItem() |
|
693 { |
|
694 |
|
695 } |
|
696 |
|
697 void LayoutTestController::setWebViewEditable(bool) |
|
698 { |
|
699 } |
|
700 |
|
701 JSRetainPtr<JSStringRef> LayoutTestController::markerTextForListItem(JSContextRef context, JSValueRef nodeObject) const |
|
702 { |
|
703 gchar* markerTextGChar = webkit_web_frame_marker_text_for_list_item(mainFrame, context, nodeObject); |
|
704 if (!markerTextGChar) |
|
705 return 0; |
|
706 |
|
707 JSRetainPtr<JSStringRef> markerText(Adopt, JSStringCreateWithUTF8CString(markerTextGChar)); |
|
708 g_free(markerTextGChar); |
|
709 return markerText; |
|
710 } |
|
711 |
|
712 void LayoutTestController::authenticateSession(JSStringRef, JSStringRef, JSStringRef) |
|
713 { |
|
714 } |
|
715 |
|
716 void LayoutTestController::setEditingBehavior(const char* editingBehavior) |
|
717 { |
|
718 WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame); |
|
719 WebKitWebSettings* settings = webkit_web_view_get_settings(webView); |
|
720 |
|
721 if (!strcmp(editingBehavior, "win")) |
|
722 g_object_set(G_OBJECT(settings), "editing-behavior", WEBKIT_EDITING_BEHAVIOR_WINDOWS, NULL); |
|
723 if (!strcmp(editingBehavior, "mac")) |
|
724 g_object_set(G_OBJECT(settings), "editing-behavior", WEBKIT_EDITING_BEHAVIOR_MAC, NULL); |
|
725 } |
|
726 |
|
727 void LayoutTestController::abortModal() |
|
728 { |
|
729 } |