2 * Copyright (C) 2007, 2008, 2009, 2011 Apple Inc. All rights reserved.
3 * Copyright (C) 2010 Joone Hur <joone@kldp.org>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
15 * its contributors may be used to endorse or promote products derived
16 * from this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
19 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #include "LayoutTestController.h"
33 #include "WorkQueue.h"
34 #include "WorkQueueItem.h"
36 #include <JavaScriptCore/JSContextRef.h>
37 #include <JavaScriptCore/JSObjectRef.h>
38 #include <JavaScriptCore/JSRetainPtr.h>
41 #include <wtf/Assertions.h>
42 #include <wtf/CurrentTime.h>
43 #include <wtf/MathExtras.h>
44 #include <wtf/OwnArrayPtr.h>
45 #include <wtf/RefPtr.h>
47 LayoutTestController::LayoutTestController(const std::string& testPathOrURL, const std::string& expectedPixelHash)
48 : m_disallowIncreaseForApplicationCacheQuota(false)
49 , m_dumpApplicationCacheDelegateCallbacks(false)
50 , m_dumpAsAudio(false)
53 , m_dumpBackForwardList(false)
54 , m_dumpChildFrameScrollPositions(false)
55 , m_dumpChildFramesAsText(false)
56 , m_dumpDOMAsWebArchive(false)
57 , m_dumpDatabaseCallbacks(false)
58 , m_dumpEditingCallbacks(false)
59 , m_dumpFrameLoadCallbacks(false)
60 , m_dumpProgressFinishedCallback(false)
61 , m_dumpUserGestureInFrameLoadCallbacks(false)
62 , m_dumpHistoryDelegateCallbacks(false)
63 , m_dumpResourceLoadCallbacks(false)
64 , m_dumpResourceResponseMIMETypes(false)
65 , m_dumpSelectionRect(false)
66 , m_dumpSourceAsWebArchive(false)
67 , m_dumpStatusCallbacks(false)
68 , m_dumpTitleChanges(false)
69 , m_dumpIconChanges(false)
70 , m_dumpVisitedLinksCallback(false)
71 , m_dumpWillCacheResponse(false)
72 , m_generatePixelResults(true)
73 , m_callCloseOnWebViews(true)
74 , m_canOpenWindows(false)
75 , m_closeRemainingWindowsWhenComplete(true)
76 , m_newWindowsCopyBackForwardList(false)
77 , m_stopProvisionalFrameLoads(false)
78 , m_testOnscreen(false)
79 , m_testRepaint(false)
80 , m_testRepaintSweepHorizontally(false)
82 , m_willSendRequestReturnsNull(false)
83 , m_willSendRequestReturnsNullOnRedirect(false)
85 , m_alwaysAcceptCookies(false)
87 , m_isGeolocationPermissionSet(false)
88 , m_geolocationPermission(false)
89 , m_handlesAuthenticationChallenges(false)
91 , m_deferMainResourceDataLoad(true)
92 , m_useDeferredFrameLoading(false)
93 , m_shouldPaintBrokenImage(true)
94 , m_shouldStayOnPageAfterHandlingBeforeUnload(false)
95 , m_areDesktopNotificationPermissionRequestsIgnored(false)
96 , m_customFullScreenBehavior(false)
97 , m_testPathOrURL(testPathOrURL)
98 , m_expectedPixelHash(expectedPixelHash)
99 , m_titleTextDirection("ltr")
103 PassRefPtr<LayoutTestController> LayoutTestController::create(const std::string& testPathOrURL, const std::string& expectedPixelHash)
105 return adoptRef(new LayoutTestController(testPathOrURL, expectedPixelHash));
110 static JSValueRef disallowIncreaseForApplicationCacheQuotaCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
112 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
113 controller->setDisallowIncreaseForApplicationCacheQuota(true);
114 return JSValueMakeUndefined(context);
117 static JSValueRef dumpApplicationCacheDelegateCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
119 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
120 controller->setDumpApplicationCacheDelegateCallbacks(true);
121 return JSValueMakeUndefined(context);
124 static JSValueRef dumpAsPDFCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
126 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
127 controller->setDumpAsPDF(true);
128 return JSValueMakeUndefined(context);
131 static JSValueRef dumpAsTextCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
133 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
134 controller->setDumpAsText(true);
136 // Optional paramater, describing whether it's allowed to dump pixel results in dumpAsText mode.
137 controller->setGeneratePixelResults(argumentCount > 0 ? JSValueToBoolean(context, arguments[0]) : false);
139 return JSValueMakeUndefined(context);
142 static JSValueRef dumpBackForwardListCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
144 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
145 controller->setDumpBackForwardList(true);
146 return JSValueMakeUndefined(context);
149 static JSValueRef dumpChildFramesAsTextCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
151 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
152 controller->setDumpChildFramesAsText(true);
153 return JSValueMakeUndefined(context);
156 static JSValueRef dumpChildFrameScrollPositionsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
158 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
159 controller->setDumpChildFrameScrollPositions(true);
160 return JSValueMakeUndefined(context);
163 static JSValueRef dumpDatabaseCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
165 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
166 controller->setDumpDatabaseCallbacks(true);
167 return JSValueMakeUndefined(context);
170 static JSValueRef dumpDOMAsWebArchiveCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
172 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
173 controller->setDumpDOMAsWebArchive(true);
174 return JSValueMakeUndefined(context);
177 static JSValueRef dumpEditingCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
179 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
180 controller->setDumpEditingCallbacks(true);
181 return JSValueMakeUndefined(context);
184 static JSValueRef dumpFrameLoadCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
186 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
187 controller->setDumpFrameLoadCallbacks(true);
188 return JSValueMakeUndefined(context);
191 static JSValueRef dumpProgressFinishedCallbackCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
193 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
194 controller->setDumpProgressFinishedCallback(true);
195 return JSValueMakeUndefined(context);
198 static JSValueRef dumpUserGestureInFrameLoadCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
200 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
201 controller->setDumpUserGestureInFrameLoadCallbacks(true);
202 return JSValueMakeUndefined(context);
205 static JSValueRef dumpResourceLoadCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
207 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
208 controller->setDumpResourceLoadCallbacks(true);
209 return JSValueMakeUndefined(context);
212 static JSValueRef dumpResourceResponseMIMETypesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
214 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
215 controller->setDumpResourceResponseMIMETypes(true);
216 return JSValueMakeUndefined(context);
219 static JSValueRef dumpSelectionRectCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
221 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
222 controller->setDumpSelectionRect(true);
223 return JSValueMakeUndefined(context);
226 static JSValueRef dumpSourceAsWebArchiveCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
228 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
229 controller->setDumpSourceAsWebArchive(true);
230 return JSValueMakeUndefined(context);
233 static JSValueRef dumpStatusCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
235 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
236 controller->setDumpStatusCallbacks(true);
237 return JSValueMakeUndefined(context);
240 static JSValueRef dumpTitleChangesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
242 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
243 controller->setDumpTitleChanges(true);
244 return JSValueMakeUndefined(context);
247 static JSValueRef dumpIconChangesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
249 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
250 controller->setDumpIconChanges(true);
251 return JSValueMakeUndefined(context);
254 static JSValueRef dumpWillCacheResponseCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
256 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
257 controller->setDumpWillCacheResponse(true);
258 return JSValueMakeUndefined(context);
261 static JSValueRef pathToLocalResourceCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
263 if (argumentCount < 1)
264 return JSValueMakeUndefined(context);
266 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
267 JSRetainPtr<JSStringRef> localPath(Adopt, JSValueToStringCopy(context, arguments[0], exception));
270 JSRetainPtr<JSStringRef> convertedPath(Adopt, controller->pathToLocalResource(context, localPath.get()));
272 return JSValueMakeUndefined(context);
274 return JSValueMakeString(context, convertedPath.get());
277 static JSValueRef removeAllVisitedLinksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
279 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
280 controller->setDumpVisitedLinksCallback(true);
281 controller->removeAllVisitedLinks();
282 return JSValueMakeUndefined(context);
285 static JSValueRef repaintSweepHorizontallyCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
287 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
288 controller->setTestRepaintSweepHorizontally(true);
289 return JSValueMakeUndefined(context);
292 static JSValueRef setCallCloseOnWebViewsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
294 if (argumentCount < 1)
295 return JSValueMakeUndefined(context);
297 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
298 controller->setCallCloseOnWebViews(JSValueToBoolean(context, arguments[0]));
299 return JSValueMakeUndefined(context);
302 static JSValueRef setCanOpenWindowsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
304 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
305 controller->setCanOpenWindows(true);
306 return JSValueMakeUndefined(context);
309 static JSValueRef setCloseRemainingWindowsWhenCompleteCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
311 if (argumentCount < 1)
312 return JSValueMakeUndefined(context);
314 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
315 controller->setCloseRemainingWindowsWhenComplete(JSValueToBoolean(context, arguments[0]));
316 return JSValueMakeUndefined(context);
319 static JSValueRef setEncodedAudioDataCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
321 if (argumentCount < 1)
322 return JSValueMakeUndefined(context);
324 JSRetainPtr<JSStringRef> encodedAudioData(Adopt, JSValueToStringCopy(context, arguments[0], exception));
327 size_t maxLength = JSStringGetMaximumUTF8CStringSize(encodedAudioData.get());
328 OwnArrayPtr<char> encodedAudioDataBuffer = adoptArrayPtr(new char[maxLength + 1]);
329 JSStringGetUTF8CString(encodedAudioData.get(), encodedAudioDataBuffer.get(), maxLength + 1);
331 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
332 controller->setEncodedAudioData(encodedAudioDataBuffer.get());
333 controller->setDumpAsAudio(true);
335 return JSValueMakeUndefined(context);
338 static JSValueRef testOnscreenCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
340 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
341 controller->setTestOnscreen(true);
342 return JSValueMakeUndefined(context);
345 static JSValueRef testRepaintCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
347 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
348 controller->setTestRepaint(true);
349 return JSValueMakeUndefined(context);
352 static JSValueRef addDisallowedURLCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
354 // Has mac implementation
355 if (argumentCount < 1)
356 return JSValueMakeUndefined(context);
358 JSRetainPtr<JSStringRef> url(Adopt, JSValueToStringCopy(context, arguments[0], exception));
361 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
362 controller->addDisallowedURL(url.get());
364 return JSValueMakeUndefined(context);
367 static JSValueRef addURLToRedirectCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
369 if (argumentCount < 2)
370 return JSValueMakeUndefined(context);
372 JSRetainPtr<JSStringRef> origin(Adopt, JSValueToStringCopy(context, arguments[0], exception));
375 JSRetainPtr<JSStringRef> destination(Adopt, JSValueToStringCopy(context, arguments[1], exception));
378 size_t maxLength = JSStringGetMaximumUTF8CStringSize(origin.get());
379 OwnArrayPtr<char> originBuffer = adoptArrayPtr(new char[maxLength + 1]);
380 JSStringGetUTF8CString(origin.get(), originBuffer.get(), maxLength + 1);
382 maxLength = JSStringGetMaximumUTF8CStringSize(destination.get());
383 OwnArrayPtr<char> destinationBuffer = adoptArrayPtr(new char[maxLength + 1]);
384 JSStringGetUTF8CString(destination.get(), destinationBuffer.get(), maxLength + 1);
386 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
387 controller->addURLToRedirect(originBuffer.get(), destinationBuffer.get());
389 return JSValueMakeUndefined(context);
392 static JSValueRef callShouldCloseOnWebViewCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
394 // Has mac & windows implementation
395 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
397 return JSValueMakeBoolean(context, controller->callShouldCloseOnWebView());
400 static JSValueRef clearAllApplicationCachesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
402 // Has mac implementation
403 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
404 controller->clearAllApplicationCaches();
406 return JSValueMakeUndefined(context);
409 static JSValueRef clearApplicationCacheForOriginCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
411 if (argumentCount < 1)
412 return JSValueMakeUndefined(context);
414 JSRetainPtr<JSStringRef> originURL(Adopt, JSValueToStringCopy(context, arguments[0], exception));
417 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
418 controller->clearApplicationCacheForOrigin(originURL.get());
420 return JSValueMakeUndefined(context);
423 static JSValueRef applicationCacheDiskUsageForOriginCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
425 if (argumentCount < 1)
426 return JSValueMakeUndefined(context);
428 JSRetainPtr<JSStringRef> originURL(Adopt, JSValueToStringCopy(context, arguments[0], exception));
431 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
433 return JSValueMakeNumber(context, controller->applicationCacheDiskUsageForOrigin(originURL.get()));
436 static JSValueRef originsWithApplicationCacheCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
438 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
439 return controller->originsWithApplicationCache(context);
442 static JSValueRef clearAllDatabasesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
444 // Has mac & windows implementation
445 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
446 controller->clearAllDatabases();
448 return JSValueMakeUndefined(context);
451 static JSValueRef syncLocalStorageCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
453 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
455 controller->syncLocalStorage();
457 return JSValueMakeUndefined(context);
460 static JSValueRef observeStorageTrackerNotificationsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
462 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
464 if (argumentCount < 1)
465 return JSValueMakeUndefined(context);
467 unsigned numNotifications = JSValueToNumber(context, arguments[0], exception);
471 controller->observeStorageTrackerNotifications(numNotifications);
473 return JSValueMakeUndefined(context);
476 static JSValueRef deleteAllLocalStorageCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
478 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
479 controller->deleteAllLocalStorage();
481 return JSValueMakeUndefined(context);
484 static JSValueRef deleteLocalStorageForOriginCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
486 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
488 if (argumentCount < 1)
489 return JSValueMakeUndefined(context);
491 JSRetainPtr<JSStringRef> url(Adopt, JSValueToStringCopy(context, arguments[0], exception));
494 controller->deleteLocalStorageForOrigin(url.get());
496 return JSValueMakeUndefined(context);
499 static JSValueRef localStorageDiskUsageForOriginCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
501 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
503 if (argumentCount < 1)
504 return JSValueMakeUndefined(context);
506 JSRetainPtr<JSStringRef> originURL(Adopt, JSValueToStringCopy(context, arguments[0], exception));
509 return JSValueMakeNumber(context, controller->localStorageDiskUsageForOrigin(originURL.get()));
512 static JSValueRef originsWithLocalStorageCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
514 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
515 return controller->originsWithLocalStorage(context);
518 static JSValueRef clearBackForwardListCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
520 // Has mac & windows implementation
521 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
522 controller->clearBackForwardList();
524 return JSValueMakeUndefined(context);
527 static JSValueRef clearPersistentUserStyleSheetCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
529 // Has mac & windows implementation
530 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
531 controller->clearPersistentUserStyleSheet();
533 return JSValueMakeUndefined(context);
536 static JSValueRef decodeHostNameCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
538 // Has mac implementation
539 if (argumentCount < 1)
540 return JSValueMakeUndefined(context);
542 JSRetainPtr<JSStringRef> name(Adopt, JSValueToStringCopy(context, arguments[0], exception));
545 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
546 JSRetainPtr<JSStringRef> decodedHostName(Adopt, controller->copyDecodedHostName(name.get()));
547 return JSValueMakeString(context, decodedHostName.get());
550 static JSValueRef disableImageLoadingCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
552 // Has mac implementation, needs windows implementation
553 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
554 controller->disableImageLoading();
556 return JSValueMakeUndefined(context);
559 static JSValueRef dispatchPendingLoadRequestsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
561 // Has mac implementation, needs windows implementation
562 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
563 controller->dispatchPendingLoadRequests();
565 return JSValueMakeUndefined(context);
568 static JSValueRef displayCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
570 // Has mac & windows implementation
571 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
572 controller->display();
574 return JSValueMakeUndefined(context);
577 static JSValueRef displayInvalidatedRegionCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
579 // Has mac & windows implementation
580 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
581 // LayoutTestController::display() only renders the invalidated region so
582 // we can just use that.
583 controller->display();
585 return JSValueMakeUndefined(context);
588 static JSValueRef encodeHostNameCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
590 // Has mac implementation
591 if (argumentCount < 1)
592 return JSValueMakeUndefined(context);
594 JSRetainPtr<JSStringRef> name(Adopt, JSValueToStringCopy(context, arguments[0], exception));
597 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
598 JSRetainPtr<JSStringRef> encodedHostName(Adopt, controller->copyEncodedHostName(name.get()));
599 return JSValueMakeString(context, encodedHostName.get());
602 static JSValueRef execCommandCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
604 // Has Mac & Windows implementations.
605 if (argumentCount < 1)
606 return JSValueMakeUndefined(context);
608 JSRetainPtr<JSStringRef> name(Adopt, JSValueToStringCopy(context, arguments[0], exception));
611 // Ignoring the second parameter (userInterface), as this command emulates a manual action.
613 JSRetainPtr<JSStringRef> value;
614 if (argumentCount >= 3) {
615 value.adopt(JSValueToStringCopy(context, arguments[2], exception));
618 value.adopt(JSStringCreateWithUTF8CString(""));
621 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
622 controller->execCommand(name.get(), value.get());
624 return JSValueMakeUndefined(context);
627 static JSValueRef findStringCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
629 // Has Mac implementation.
630 if (argumentCount < 2)
631 return JSValueMakeUndefined(context);
633 JSRetainPtr<JSStringRef> target(Adopt, JSValueToStringCopy(context, arguments[0], exception));
636 JSObjectRef options = JSValueToObject(context, arguments[1], exception);
639 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
640 return JSValueMakeBoolean(context, controller->findString(context, target.get(), options));
643 static JSValueRef goBackCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
645 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
646 controller->goBack();
648 return JSValueMakeUndefined(context);
651 static JSValueRef grantDesktopNotificationPermissionCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
653 // Has Windows implementation
654 if (argumentCount < 1)
655 return JSValueMakeUndefined(context);
657 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
659 controller->grantDesktopNotificationPermission(JSValueToStringCopy(context, arguments[0], NULL));
661 return JSValueMakeUndefined(context);
664 static JSValueRef isCommandEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
666 // Has Mac implementation.
668 if (argumentCount < 1)
669 return JSValueMakeUndefined(context);
671 JSRetainPtr<JSStringRef> name(Adopt, JSValueToStringCopy(context, arguments[0], exception));
674 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
676 return JSValueMakeBoolean(context, controller->isCommandEnabled(name.get()));
679 static JSValueRef overridePreferenceCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
681 if (argumentCount < 2)
682 return JSValueMakeUndefined(context);
684 JSRetainPtr<JSStringRef> key(Adopt, JSValueToStringCopy(context, arguments[0], exception));
686 JSRetainPtr<JSStringRef> value(Adopt, JSValueToStringCopy(context, arguments[1], exception));
689 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
690 controller->overridePreference(key.get(), value.get());
692 return JSValueMakeUndefined(context);
695 static JSValueRef keepWebHistoryCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
697 // Has mac implementation
698 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
699 controller->keepWebHistory();
701 return JSValueMakeUndefined(context);
704 static JSValueRef computedStyleIncludingVisitedInfoCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
706 if (argumentCount != 1)
707 return JSValueMakeUndefined(context);
709 // Has mac implementation
710 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
711 return controller->computedStyleIncludingVisitedInfo(context, arguments[0]);
714 static JSValueRef layerTreeAsTextCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
716 // Has mac & windows implementation
717 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
718 return JSValueMakeString(context, controller->layerTreeAsText().get());
721 static JSValueRef notifyDoneCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
723 // Has mac & windows implementation
724 // May be able to be made platform independant by using shared WorkQueue
725 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
726 controller->notifyDone();
727 return JSValueMakeUndefined(context);
730 static bool parsePageParameters(JSContextRef context, int argumentCount, const JSValueRef* arguments, JSValueRef* exception, float& pageWidthInPixels, float& pageHeightInPixels)
732 pageWidthInPixels = LayoutTestController::maxViewWidth;
733 pageHeightInPixels = LayoutTestController::maxViewHeight;
734 switch (argumentCount) {
736 pageWidthInPixels = static_cast<float>(JSValueToNumber(context, arguments[0], exception));
739 pageHeightInPixels = static_cast<float>(JSValueToNumber(context, arguments[1], exception));
742 case 0: // Fall through.
750 // Caller needs to delete[] propertyName.
751 static bool parsePagePropertyParameters(JSContextRef context, int argumentCount, const JSValueRef* arguments, JSValueRef* exception, char*& propertyName, int& pageNumber)
754 switch (argumentCount) {
756 pageNumber = static_cast<float>(JSValueToNumber(context, arguments[1], exception));
761 JSRetainPtr<JSStringRef> propertyNameString(Adopt, JSValueToStringCopy(context, arguments[0], exception));
765 size_t maxLength = JSStringGetMaximumUTF8CStringSize(propertyNameString.get());
766 propertyName = new char[maxLength + 1];
767 JSStringGetUTF8CString(propertyNameString.get(), propertyName, maxLength + 1);
776 static bool parsePageNumberSizeMarings(JSContextRef context, int argumentCount, const JSValueRef* arguments, JSValueRef* exception, int& pageNumber, int& width, int& height, int& marginTop, int& marginRight, int& marginBottom, int& marginLeft)
780 marginTop = marginRight = marginBottom = marginLeft = 0;
782 switch (argumentCount) {
784 marginLeft = static_cast<int>(JSValueToNumber(context, arguments[6], exception));
789 marginBottom = static_cast<int>(JSValueToNumber(context, arguments[5], exception));
794 marginRight = static_cast<int>(JSValueToNumber(context, arguments[4], exception));
799 marginTop = static_cast<int>(JSValueToNumber(context, arguments[3], exception));
804 height = static_cast<int>(JSValueToNumber(context, arguments[2], exception));
809 width = static_cast<int>(JSValueToNumber(context, arguments[1], exception));
814 pageNumber = static_cast<int>(JSValueToNumber(context, arguments[0], exception));
824 static JSValueRef numberOfPagesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
826 float pageWidthInPixels = 0;
827 float pageHeightInPixels = 0;
828 if (!parsePageParameters(context, argumentCount, arguments, exception, pageWidthInPixels, pageHeightInPixels))
829 return JSValueMakeUndefined(context);
831 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
832 return JSValueMakeNumber(context, controller->numberOfPages(pageWidthInPixels, pageHeightInPixels));
835 static JSValueRef numberOfPendingGeolocationPermissionRequestsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
837 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
838 return JSValueMakeNumber(context, controller->numberOfPendingGeolocationPermissionRequests());
841 static JSValueRef pagePropertyCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
843 char* propertyName = 0;
845 if (!parsePagePropertyParameters(context, argumentCount, arguments, exception, propertyName, pageNumber))
846 return JSValueMakeUndefined(context);
848 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
849 JSValueRef value = JSValueMakeString(context, controller->pageProperty(propertyName, pageNumber).get());
851 delete[] propertyName;
855 static JSValueRef pageSizeAndMarginsInPixelsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
858 int width = 0, height = 0;
859 int marginTop = 0, marginRight = 0, marginBottom = 0, marginLeft = 0;
860 if (!parsePageNumberSizeMarings(context, argumentCount, arguments, exception, pageNumber, width, height, marginTop, marginRight, marginBottom, marginLeft))
861 return JSValueMakeUndefined(context);
863 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
864 return JSValueMakeString(context, controller->pageSizeAndMarginsInPixels(pageNumber, width, height, marginTop, marginRight, marginBottom, marginLeft).get());
867 static JSValueRef queueBackNavigationCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
869 // Has mac & windows implementation
870 // May be able to be made platform independant by using shared WorkQueue
871 if (argumentCount < 1)
872 return JSValueMakeUndefined(context);
874 double howFarBackDouble = JSValueToNumber(context, arguments[0], exception);
877 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
878 controller->queueBackNavigation(static_cast<int>(howFarBackDouble));
880 return JSValueMakeUndefined(context);
883 static JSValueRef queueForwardNavigationCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
885 // Has mac & windows implementation
886 // May be able to be made platform independant by using shared WorkQueue
887 if (argumentCount < 1)
888 return JSValueMakeUndefined(context);
890 double howFarForwardDouble = JSValueToNumber(context, arguments[0], exception);
893 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
894 controller->queueForwardNavigation(static_cast<int>(howFarForwardDouble));
896 return JSValueMakeUndefined(context);
899 static JSValueRef queueLoadCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
901 // Has mac & windows implementation
902 // May be able to be made platform independant by using shared WorkQueue
903 if (argumentCount < 1)
904 return JSValueMakeUndefined(context);
906 JSRetainPtr<JSStringRef> url(Adopt, JSValueToStringCopy(context, arguments[0], exception));
909 JSRetainPtr<JSStringRef> target;
910 if (argumentCount >= 2) {
911 target.adopt(JSValueToStringCopy(context, arguments[1], exception));
914 target.adopt(JSStringCreateWithUTF8CString(""));
916 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
917 controller->queueLoad(url.get(), target.get());
919 return JSValueMakeUndefined(context);
922 static JSValueRef queueLoadHTMLStringCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
924 // Has Mac & Windows implementation
925 if (argumentCount < 1)
926 return JSValueMakeUndefined(context);
928 JSRetainPtr<JSStringRef> content(Adopt, JSValueToStringCopy(context, arguments[0], exception));
931 JSRetainPtr<JSStringRef> baseURL;
932 if (argumentCount >= 2) {
933 baseURL.adopt(JSValueToStringCopy(context, arguments[1], exception));
936 baseURL.adopt(JSStringCreateWithUTF8CString(""));
938 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
940 if (argumentCount >= 3) {
941 JSRetainPtr<JSStringRef> unreachableURL;
942 unreachableURL.adopt(JSValueToStringCopy(context, arguments[2], exception));
944 controller->queueLoadAlternateHTMLString(content.get(), baseURL.get(), unreachableURL.get());
945 return JSValueMakeUndefined(context);
948 controller->queueLoadHTMLString(content.get(), baseURL.get());
949 return JSValueMakeUndefined(context);
952 static JSValueRef queueReloadCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
954 // Has mac & windows implementation
955 // May be able to be made platform independant by using shared WorkQueue
957 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
958 controller->queueReload();
960 return JSValueMakeUndefined(context);
963 static JSValueRef queueLoadingScriptCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
965 // Has mac & windows implementation
966 // May be able to be made platform independant by using shared WorkQueue
967 if (argumentCount < 1)
968 return JSValueMakeUndefined(context);
970 JSRetainPtr<JSStringRef> script(Adopt, JSValueToStringCopy(context, arguments[0], exception));
973 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
974 controller->queueLoadingScript(script.get());
976 return JSValueMakeUndefined(context);
979 static JSValueRef queueNonLoadingScriptCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
981 // Has mac & windows implementation
982 // May be able to be made platform independant by using shared WorkQueue
983 if (argumentCount < 1)
984 return JSValueMakeUndefined(context);
986 JSRetainPtr<JSStringRef> script(Adopt, JSValueToStringCopy(context, arguments[0], exception));
989 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
990 controller->queueNonLoadingScript(script.get());
992 return JSValueMakeUndefined(context);
995 static JSValueRef setAcceptsEditingCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
997 // Has mac & windows implementation
998 if (argumentCount < 1)
999 return JSValueMakeUndefined(context);
1001 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1002 controller->setAcceptsEditing(JSValueToBoolean(context, arguments[0]));
1004 return JSValueMakeUndefined(context);
1007 static JSValueRef setAlwaysAcceptCookiesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1009 // Has mac & windows implementation
1010 if (argumentCount < 1)
1011 return JSValueMakeUndefined(context);
1013 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1014 controller->setAlwaysAcceptCookies(JSValueToBoolean(context, arguments[0]));
1016 return JSValueMakeUndefined(context);
1019 static JSValueRef setAppCacheMaximumSizeCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1021 // Has mac implementation
1022 if (argumentCount < 1)
1023 return JSValueMakeUndefined(context);
1025 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1027 double size = JSValueToNumber(context, arguments[0], NULL);
1029 controller->setAppCacheMaximumSize(static_cast<unsigned long long>(size));
1031 return JSValueMakeUndefined(context);
1034 static JSValueRef setApplicationCacheOriginQuotaCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1036 // Has mac implementation
1037 if (argumentCount < 1)
1038 return JSValueMakeUndefined(context);
1040 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1042 double size = JSValueToNumber(context, arguments[0], NULL);
1044 controller->setApplicationCacheOriginQuota(static_cast<unsigned long long>(size));
1046 return JSValueMakeUndefined(context);
1049 static JSValueRef setAuthenticationPasswordCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1051 // Has mac & windows implementation
1052 if (argumentCount < 1)
1053 return JSValueMakeUndefined(context);
1055 JSRetainPtr<JSStringRef> password(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1056 ASSERT(!*exception);
1058 size_t maxLength = JSStringGetMaximumUTF8CStringSize(password.get());
1059 char* passwordBuffer = new char[maxLength + 1];
1060 JSStringGetUTF8CString(password.get(), passwordBuffer, maxLength + 1);
1062 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1063 controller->setAuthenticationPassword(passwordBuffer);
1064 delete[] passwordBuffer;
1066 return JSValueMakeUndefined(context);
1069 static JSValueRef setAuthenticationUsernameCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1071 // Has mac & windows implementation
1072 if (argumentCount < 1)
1073 return JSValueMakeUndefined(context);
1075 JSRetainPtr<JSStringRef> username(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1076 ASSERT(!*exception);
1078 size_t maxLength = JSStringGetMaximumUTF8CStringSize(username.get());
1079 char* usernameBuffer = new char[maxLength + 1];
1080 JSStringGetUTF8CString(username.get(), usernameBuffer, maxLength + 1);
1082 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1083 controller->setAuthenticationUsername(usernameBuffer);
1084 delete[] usernameBuffer;
1086 return JSValueMakeUndefined(context);
1089 static JSValueRef setAuthorAndUserStylesEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1091 // Has mac & windows implementation
1092 if (argumentCount < 1)
1093 return JSValueMakeUndefined(context);
1095 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1096 controller->setAuthorAndUserStylesEnabled(JSValueToBoolean(context, arguments[0]));
1098 return JSValueMakeUndefined(context);
1101 static JSValueRef setAutofilledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1103 if (argumentCount != 2 || !arguments[0])
1104 return JSValueMakeUndefined(context);
1106 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1107 controller->setAutofilled(context, arguments[0], JSValueToBoolean(context, arguments[1]));
1109 return JSValueMakeUndefined(context);
1112 static JSValueRef setCacheModelCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1114 // Has Mac implementation.
1115 if (argumentCount < 1)
1116 return JSValueMakeUndefined(context);
1118 int cacheModel = JSValueToNumber(context, arguments[0], exception);
1119 ASSERT(!*exception);
1121 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1122 controller->setCacheModel(cacheModel);
1124 return JSValueMakeUndefined(context);
1127 static JSValueRef setCustomPolicyDelegateCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1129 // Has mac implementation
1130 if (argumentCount < 1)
1131 return JSValueMakeUndefined(context);
1133 bool permissive = false;
1134 if (argumentCount >= 2)
1135 permissive = JSValueToBoolean(context, arguments[1]);
1137 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1138 controller->setCustomPolicyDelegate(JSValueToBoolean(context, arguments[0]), permissive);
1140 return JSValueMakeUndefined(context);
1143 static JSValueRef setDatabaseQuotaCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1145 // Has mac implementation
1146 if (argumentCount < 1)
1147 return JSValueMakeUndefined(context);
1149 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1151 double quota = JSValueToNumber(context, arguments[0], NULL);
1153 controller->setDatabaseQuota(static_cast<unsigned long long>(quota));
1155 return JSValueMakeUndefined(context);
1158 static JSValueRef setDeferMainResourceDataLoadCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1160 // Has Mac and Windows implementation
1161 if (argumentCount < 1)
1162 return JSValueMakeUndefined(context);
1164 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1165 controller->setDeferMainResourceDataLoad(JSValueToBoolean(context, arguments[0]));
1167 return JSValueMakeUndefined(context);
1170 static JSValueRef setDefersLoadingCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1172 if (argumentCount < 1)
1173 return JSValueMakeUndefined(context);
1175 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1176 controller->setDefersLoading(JSValueToBoolean(context, arguments[0]));
1178 return JSValueMakeUndefined(context);
1181 static JSValueRef setUseDeferredFrameLoadingCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1183 if (argumentCount < 1)
1184 return JSValueMakeUndefined(context);
1186 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1187 controller->setUseDeferredFrameLoading(JSValueToBoolean(context, arguments[0]));
1189 return JSValueMakeUndefined(context);
1192 static JSValueRef setDomainRelaxationForbiddenForURLSchemeCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1194 // Has Mac and Windows implementation
1195 if (argumentCount < 2)
1196 return JSValueMakeUndefined(context);
1198 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1200 bool forbidden = JSValueToBoolean(context, arguments[0]);
1201 JSRetainPtr<JSStringRef> scheme(Adopt, JSValueToStringCopy(context, arguments[1], 0));
1202 controller->setDomainRelaxationForbiddenForURLScheme(forbidden, scheme.get());
1204 return JSValueMakeUndefined(context);
1207 static JSValueRef setMockDeviceOrientationCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1209 if (argumentCount < 6)
1210 return JSValueMakeUndefined(context);
1212 bool canProvideAlpha = JSValueToBoolean(context, arguments[0]);
1213 double alpha = JSValueToNumber(context, arguments[1], exception);
1214 ASSERT(!*exception);
1215 bool canProvideBeta = JSValueToBoolean(context, arguments[2]);
1216 double beta = JSValueToNumber(context, arguments[3], exception);
1217 ASSERT(!*exception);
1218 bool canProvideGamma = JSValueToBoolean(context, arguments[4]);
1219 double gamma = JSValueToNumber(context, arguments[5], exception);
1220 ASSERT(!*exception);
1222 LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1223 controller->setMockDeviceOrientation(canProvideAlpha, alpha, canProvideBeta, beta, canProvideGamma, gamma);
1225 return JSValueMakeUndefined(context);
1228 static JSValueRef setMockGeolocationPositionCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1230 if (argumentCount < 3)
1231 return JSValueMakeUndefined(context);
1233 LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1234 controller->setMockGeolocationPosition(JSValueToNumber(context, arguments[0], NULL), // latitude
1235 JSValueToNumber(context, arguments[1], NULL), // longitude
1236 JSValueToNumber(context, arguments[2], NULL)); // accuracy
1238 return JSValueMakeUndefined(context);
1241 static JSValueRef setMockGeolocationErrorCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1243 if (argumentCount < 2)
1244 return JSValueMakeUndefined(context);
1246 int code = JSValueToNumber(context, arguments[0], NULL);
1247 JSRetainPtr<JSStringRef> message(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1248 ASSERT(!*exception);
1250 LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1251 controller->setMockGeolocationError(code, message.get());
1253 return JSValueMakeUndefined(context);
1256 static JSValueRef addMockSpeechInputResultCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1258 if (argumentCount < 3)
1259 return JSValueMakeUndefined(context);
1261 JSRetainPtr<JSStringRef> result(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1262 ASSERT(!*exception);
1264 double confidence = JSValueToNumber(context, arguments[1], exception);
1266 JSRetainPtr<JSStringRef> language(Adopt, JSValueToStringCopy(context, arguments[2], exception));
1267 ASSERT(!*exception);
1269 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1270 controller->addMockSpeechInputResult(result.get(), confidence, language.get());
1272 return JSValueMakeUndefined(context);
1275 static JSValueRef setMockSpeechInputDumpRectCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1277 if (argumentCount < 1)
1278 return JSValueMakeUndefined(context);
1280 bool dumpRect = JSValueToBoolean(context, arguments[0]);
1282 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1283 controller->setMockSpeechInputDumpRect(dumpRect);
1285 return JSValueMakeUndefined(context);
1288 static JSValueRef setNewWindowsCopyBackForwardListCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1290 // Has mac implementation
1291 if (argumentCount < 1)
1292 return JSValueMakeUndefined(context);
1294 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1295 controller->setNewWindowsCopyBackForwardList(JSValueToBoolean(context, arguments[0]));
1297 return JSValueMakeUndefined(context);
1300 static JSValueRef setGeolocationPermissionCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1302 // Has mac implementation
1303 if (argumentCount < 1)
1304 return JSValueMakeUndefined(context);
1306 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1307 controller->setGeolocationPermission(JSValueToBoolean(context, arguments[0]));
1309 return JSValueMakeUndefined(context);
1312 static JSValueRef setHandlesAuthenticationChallengesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1314 // Has mac & windows implementation
1315 if (argumentCount < 1)
1316 return JSValueMakeUndefined(context);
1318 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1319 controller->setHandlesAuthenticationChallenges(JSValueToBoolean(context, arguments[0]));
1321 return JSValueMakeUndefined(context);
1324 static JSValueRef setPOSIXLocaleCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1326 if (argumentCount < 1)
1327 return JSValueMakeUndefined(context);
1329 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1330 JSRetainPtr<JSStringRef> locale(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1331 ASSERT(!*exception);
1332 controller->setPOSIXLocale(locale.get());
1334 return JSValueMakeUndefined(context);
1337 static JSValueRef setIconDatabaseEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1339 // Has mac & windows implementation
1340 if (argumentCount < 1)
1341 return JSValueMakeUndefined(context);
1343 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1344 controller->setIconDatabaseEnabled(JSValueToBoolean(context, arguments[0]));
1346 return JSValueMakeUndefined(context);
1349 static JSValueRef setMainFrameIsFirstResponderCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1351 // Has mac implementation
1352 if (argumentCount < 1)
1353 return JSValueMakeUndefined(context);
1355 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1356 controller->setMainFrameIsFirstResponder(JSValueToBoolean(context, arguments[0]));
1358 return JSValueMakeUndefined(context);
1361 static JSValueRef setPersistentUserStyleSheetLocationCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1363 // Has mac implementation
1364 if (argumentCount < 1)
1365 return JSValueMakeUndefined(context);
1367 JSRetainPtr<JSStringRef> path(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1368 ASSERT(!*exception);
1370 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1371 controller->setPersistentUserStyleSheetLocation(path.get());
1373 return JSValueMakeUndefined(context);
1376 static JSValueRef setPrivateBrowsingEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1378 // Has mac & windows implementation
1379 if (argumentCount < 1)
1380 return JSValueMakeUndefined(context);
1382 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1383 controller->setPrivateBrowsingEnabled(JSValueToBoolean(context, arguments[0]));
1385 return JSValueMakeUndefined(context);
1388 static JSValueRef setJavaScriptCanAccessClipboardCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1390 // Has mac & windows implementation
1391 if (argumentCount < 1)
1392 return JSValueMakeUndefined(context);
1394 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1395 controller->setJavaScriptCanAccessClipboard(JSValueToBoolean(context, arguments[0]));
1397 return JSValueMakeUndefined(context);
1400 static JSValueRef setXSSAuditorEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1402 // Has mac & windows implementation
1403 if (argumentCount < 1)
1404 return JSValueMakeUndefined(context);
1406 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1407 controller->setXSSAuditorEnabled(JSValueToBoolean(context, arguments[0]));
1409 return JSValueMakeUndefined(context);
1412 static JSValueRef setSpatialNavigationEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1414 // Has mac implementation.
1415 if (argumentCount < 1)
1416 return JSValueMakeUndefined(context);
1418 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1419 controller->setSpatialNavigationEnabled(JSValueToBoolean(context, arguments[0]));
1421 return JSValueMakeUndefined(context);
1424 static JSValueRef setPrintingCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1426 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1427 controller->setIsPrinting(true);
1428 return JSValueMakeUndefined(context);
1432 static JSValueRef setFrameFlatteningEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1434 // Has mac & windows implementation
1435 if (argumentCount < 1)
1436 return JSValueMakeUndefined(context);
1438 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1439 controller->setFrameFlatteningEnabled(JSValueToBoolean(context, arguments[0]));
1441 return JSValueMakeUndefined(context);
1444 static JSValueRef setAllowUniversalAccessFromFileURLsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1446 // Has mac & windows implementation
1447 if (argumentCount < 1)
1448 return JSValueMakeUndefined(context);
1450 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1451 controller->setAllowUniversalAccessFromFileURLs(JSValueToBoolean(context, arguments[0]));
1453 return JSValueMakeUndefined(context);
1456 static JSValueRef setAllowFileAccessFromFileURLsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1458 // Has mac & windows implementation
1459 if (argumentCount < 1)
1460 return JSValueMakeUndefined(context);
1462 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1463 controller->setAllowFileAccessFromFileURLs(JSValueToBoolean(context, arguments[0]));
1465 return JSValueMakeUndefined(context);
1468 static JSValueRef setTabKeyCyclesThroughElementsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1470 // Has mac & windows implementation
1471 if (argumentCount < 1)
1472 return JSValueMakeUndefined(context);
1474 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1475 controller->setTabKeyCyclesThroughElements(JSValueToBoolean(context, arguments[0]));
1477 return JSValueMakeUndefined(context);
1480 static JSValueRef setUseDashboardCompatibilityModeCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1482 // Has mac implementation
1483 if (argumentCount < 1)
1484 return JSValueMakeUndefined(context);
1486 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1487 controller->setUseDashboardCompatibilityMode(JSValueToBoolean(context, arguments[0]));
1489 return JSValueMakeUndefined(context);
1492 static JSValueRef setUserStyleSheetEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1494 // Has mac implementation
1495 if (argumentCount < 1)
1496 return JSValueMakeUndefined(context);
1498 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1499 controller->setUserStyleSheetEnabled(JSValueToBoolean(context, arguments[0]));
1501 return JSValueMakeUndefined(context);
1504 static JSValueRef setUserStyleSheetLocationCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1506 // Has mac implementation
1507 if (argumentCount < 1)
1508 return JSValueMakeUndefined(context);
1510 JSRetainPtr<JSStringRef> path(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1511 ASSERT(!*exception);
1513 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1514 controller->setUserStyleSheetLocation(path.get());
1516 return JSValueMakeUndefined(context);
1519 static JSValueRef setValueForUserCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1521 // Has mac implementation
1522 if (argumentCount != 2)
1523 return JSValueMakeUndefined(context);
1525 JSRetainPtr<JSStringRef> value(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1526 ASSERT(!*exception);
1528 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1529 controller->setValueForUser(context, arguments[0], value.get());
1531 return JSValueMakeUndefined(context);
1534 static JSValueRef setViewModeMediaFeatureCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1536 // Has mac implementation
1537 if (argumentCount < 1)
1538 return JSValueMakeUndefined(context);
1540 JSRetainPtr<JSStringRef> mode(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1541 ASSERT(!*exception);
1543 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1544 controller->setViewModeMediaFeature(mode.get());
1546 return JSValueMakeUndefined(context);
1549 static JSValueRef setWillSendRequestClearHeaderCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1551 // Has mac & windows implementation
1552 if (argumentCount < 1)
1553 return JSValueMakeUndefined(context);
1555 JSRetainPtr<JSStringRef> header(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1556 ASSERT(!*exception);
1558 size_t maxLength = JSStringGetMaximumUTF8CStringSize(header.get());
1559 OwnArrayPtr<char> headerBuffer = adoptArrayPtr(new char[maxLength + 1]);
1560 JSStringGetUTF8CString(header.get(), headerBuffer.get(), maxLength + 1);
1562 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1563 controller->setWillSendRequestClearHeader(headerBuffer.get());
1565 return JSValueMakeUndefined(context);
1568 static JSValueRef setWillSendRequestReturnsNullCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1570 // Has cross-platform implementation
1571 if (argumentCount < 1)
1572 return JSValueMakeUndefined(context);
1574 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1575 controller->setWillSendRequestReturnsNull(JSValueToBoolean(context, arguments[0]));
1577 return JSValueMakeUndefined(context);
1580 static JSValueRef setWillSendRequestReturnsNullOnRedirectCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1582 // Has cross-platform implementation
1583 if (argumentCount < 1)
1584 return JSValueMakeUndefined(context);
1586 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1587 controller->setWillSendRequestReturnsNullOnRedirect(JSValueToBoolean(context, arguments[0]));
1589 return JSValueMakeUndefined(context);
1592 static JSValueRef setWindowIsKeyCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1594 // Has mac implementation
1595 if (argumentCount < 1)
1596 return JSValueMakeUndefined(context);
1598 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1599 controller->setWindowIsKey(JSValueToBoolean(context, arguments[0]));
1601 return JSValueMakeUndefined(context);
1604 static JSValueRef waitUntilDoneCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1606 // Has mac & windows implementation
1607 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1608 controller->setWaitToDump(true);
1610 return JSValueMakeUndefined(context);
1613 static JSValueRef windowCountCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1615 // Has mac implementation
1616 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1617 int windows = controller->windowCount();
1618 return JSValueMakeNumber(context, windows);
1621 static JSValueRef setPopupBlockingEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1623 // Has mac & windows implementation
1624 if (argumentCount < 1)
1625 return JSValueMakeUndefined(context);
1627 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1628 controller->setPopupBlockingEnabled(JSValueToBoolean(context, arguments[0]));
1630 return JSValueMakeUndefined(context);
1633 static JSValueRef setPluginsEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1635 // Has mac & windows implementation
1636 if (argumentCount < 1)
1637 return JSValueMakeUndefined(context);
1639 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1640 controller->setPluginsEnabled(JSValueToBoolean(context, arguments[0]));
1642 return JSValueMakeUndefined(context);
1645 static JSValueRef setPageVisibilityCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1647 // Has mac & windows implementation
1648 if (argumentCount < 1)
1649 return JSValueMakeUndefined(context);
1651 JSRetainPtr<JSStringRef> visibility(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1652 ASSERT(!*exception);
1654 size_t maxLength = JSStringGetMaximumUTF8CStringSize(visibility.get());
1655 char* visibilityBuffer = new char[maxLength + 1];
1656 JSStringGetUTF8CString(visibility.get(), visibilityBuffer, maxLength + 1);
1658 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1659 controller->setPageVisibility(visibilityBuffer);
1660 delete[] visibilityBuffer;
1662 return JSValueMakeUndefined(context);
1665 static JSValueRef resetPageVisibilityCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1667 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1668 controller->resetPageVisibility();
1669 return JSValueMakeUndefined(context);
1672 static JSValueRef setSmartInsertDeleteEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1674 if (argumentCount < 1)
1675 return JSValueMakeUndefined(context);
1677 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1678 controller->setSmartInsertDeleteEnabled(JSValueToBoolean(context, arguments[0]));
1679 return JSValueMakeUndefined(context);
1682 static JSValueRef setAutomaticLinkDetectionEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1684 if (argumentCount < 1)
1685 return JSValueMakeUndefined(context);
1687 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1688 controller->setAutomaticLinkDetectionEnabled(JSValueToBoolean(context, arguments[0]));
1689 return JSValueMakeUndefined(context);
1692 static JSValueRef setSelectTrailingWhitespaceEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1694 if (argumentCount < 1)
1695 return JSValueMakeUndefined(context);
1697 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1698 controller->setSelectTrailingWhitespaceEnabled(JSValueToBoolean(context, arguments[0]));
1699 return JSValueMakeUndefined(context);
1702 static JSValueRef setStopProvisionalFrameLoadsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1704 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1705 controller->setStopProvisionalFrameLoads(true);
1706 return JSValueMakeUndefined(context);
1709 static JSValueRef setAsynchronousSpellCheckingEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1711 if (argumentCount < 1)
1712 return JSValueMakeUndefined(context);
1714 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1715 controller->setAsynchronousSpellCheckingEnabled(JSValueToBoolean(context, arguments[0]));
1716 return JSValueMakeUndefined(context);
1719 static JSValueRef showWebInspectorCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1721 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1722 controller->showWebInspector();
1723 return JSValueMakeUndefined(context);
1726 static JSValueRef closeWebInspectorCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1728 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1729 controller->closeWebInspector();
1730 return JSValueMakeUndefined(context);
1733 static JSValueRef evaluateInWebInspectorCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1735 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1736 double callId = JSValueToNumber(context, arguments[0], exception);
1737 ASSERT(!*exception);
1738 JSRetainPtr<JSStringRef> script(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1739 ASSERT(!*exception);
1741 controller->evaluateInWebInspector(static_cast<long>(callId), script.get());
1742 return JSValueMakeUndefined(context);
1745 static JSValueRef evaluateScriptInIsolatedWorldCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1747 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1748 double worldID = JSValueToNumber(context, arguments[0], exception);
1749 ASSERT(!*exception);
1750 JSRetainPtr<JSStringRef> script(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1751 ASSERT(!*exception);
1753 controller->evaluateScriptInIsolatedWorld(static_cast<unsigned>(worldID), JSContextGetGlobalObject(context), script.get());
1754 return JSValueMakeUndefined(context);
1757 static JSValueRef evaluateScriptInIsolatedWorldAndReturnValueCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1759 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1760 double worldID = JSValueToNumber(context, arguments[0], exception);
1761 ASSERT(!*exception);
1762 JSRetainPtr<JSStringRef> script(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1763 ASSERT(!*exception);
1765 controller->evaluateScriptInIsolatedWorldAndReturnValue(static_cast<unsigned>(worldID), JSContextGetGlobalObject(context), script.get());
1766 return JSValueMakeUndefined(context);
1769 static JSValueRef elementDoesAutoCompleteForElementWithIdCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1771 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1772 JSRetainPtr<JSStringRef> elementId(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1773 ASSERT(!*exception);
1775 bool autoCompletes = controller->elementDoesAutoCompleteForElementWithId(elementId.get());
1777 return JSValueMakeBoolean(context, autoCompletes);
1780 static JSValueRef pauseAnimationAtTimeOnElementWithIdCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1782 if (argumentCount != 3)
1783 return JSValueMakeUndefined(context);
1785 JSRetainPtr<JSStringRef> animationName(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1786 ASSERT(!*exception);
1787 double time = JSValueToNumber(context, arguments[1], exception);
1788 ASSERT(!*exception);
1789 JSRetainPtr<JSStringRef> elementId(Adopt, JSValueToStringCopy(context, arguments[2], exception));
1790 ASSERT(!*exception);
1792 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1793 return JSValueMakeBoolean(context, controller->pauseAnimationAtTimeOnElementWithId(animationName.get(), time, elementId.get()));
1796 static JSValueRef pauseTransitionAtTimeOnElementWithIdCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1798 if (argumentCount != 3)
1799 return JSValueMakeUndefined(context);
1801 JSRetainPtr<JSStringRef> propertyName(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1802 ASSERT(!*exception);
1803 double time = JSValueToNumber(context, arguments[1], exception);
1804 ASSERT(!*exception);
1805 JSRetainPtr<JSStringRef> elementId(Adopt, JSValueToStringCopy(context, arguments[2], exception));
1806 ASSERT(!*exception);
1808 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1809 return JSValueMakeBoolean(context, controller->pauseTransitionAtTimeOnElementWithId(propertyName.get(), time, elementId.get()));
1812 static JSValueRef numberOfActiveAnimationsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1814 if (argumentCount != 0)
1815 return JSValueMakeUndefined(context);
1817 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1818 return JSValueMakeNumber(context, controller->numberOfActiveAnimations());
1821 static JSValueRef waitForPolicyDelegateCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t, const JSValueRef[], JSValueRef*)
1823 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1824 controller->waitForPolicyDelegate();
1825 return JSValueMakeUndefined(context);
1828 static JSValueRef addOriginAccessWhitelistEntryCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1830 if (argumentCount != 4)
1831 return JSValueMakeUndefined(context);
1833 JSRetainPtr<JSStringRef> sourceOrigin(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1834 ASSERT(!*exception);
1835 JSRetainPtr<JSStringRef> destinationProtocol(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1836 ASSERT(!*exception);
1837 JSRetainPtr<JSStringRef> destinationHost(Adopt, JSValueToStringCopy(context, arguments[2], exception));
1838 ASSERT(!*exception);
1839 bool allowDestinationSubdomains = JSValueToBoolean(context, arguments[3]);
1841 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1842 controller->addOriginAccessWhitelistEntry(sourceOrigin.get(), destinationProtocol.get(), destinationHost.get(), allowDestinationSubdomains);
1843 return JSValueMakeUndefined(context);
1846 static JSValueRef removeOriginAccessWhitelistEntryCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1848 if (argumentCount != 4)
1849 return JSValueMakeUndefined(context);
1851 JSRetainPtr<JSStringRef> sourceOrigin(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1852 ASSERT(!*exception);
1853 JSRetainPtr<JSStringRef> destinationProtocol(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1854 ASSERT(!*exception);
1855 JSRetainPtr<JSStringRef> destinationHost(Adopt, JSValueToStringCopy(context, arguments[2], exception));
1856 ASSERT(!*exception);
1857 bool allowDestinationSubdomains = JSValueToBoolean(context, arguments[3]);
1859 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1860 controller->removeOriginAccessWhitelistEntry(sourceOrigin.get(), destinationProtocol.get(), destinationHost.get(), allowDestinationSubdomains);
1861 return JSValueMakeUndefined(context);
1864 static JSValueRef setScrollbarPolicyCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1866 if (argumentCount != 2)
1867 return JSValueMakeUndefined(context);
1869 JSRetainPtr<JSStringRef> orientation(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1870 ASSERT(!*exception);
1871 JSRetainPtr<JSStringRef> policy(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1872 ASSERT(!*exception);
1874 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1875 controller->setScrollbarPolicy(orientation.get(), policy.get());
1876 return JSValueMakeUndefined(context);
1879 static JSValueRef addUserScriptCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1881 if (argumentCount != 3)
1882 return JSValueMakeUndefined(context);
1884 JSRetainPtr<JSStringRef> source(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1885 ASSERT(!*exception);
1886 bool runAtStart = JSValueToBoolean(context, arguments[1]);
1887 bool allFrames = JSValueToBoolean(context, arguments[2]);
1889 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1890 controller->addUserScript(source.get(), runAtStart, allFrames);
1891 return JSValueMakeUndefined(context);
1894 static JSValueRef addUserStyleSheetCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1896 if (argumentCount != 2)
1897 return JSValueMakeUndefined(context);
1899 JSRetainPtr<JSStringRef> source(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1900 ASSERT(!*exception);
1901 bool allFrames = JSValueToBoolean(context, arguments[1]);
1903 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1904 controller->addUserStyleSheet(source.get(), allFrames);
1905 return JSValueMakeUndefined(context);
1908 static JSValueRef setShouldPaintBrokenImageCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1910 // Has Mac implementation
1911 if (argumentCount < 1)
1912 return JSValueMakeUndefined(context);
1914 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1915 controller->setShouldPaintBrokenImage(JSValueToBoolean(context, arguments[0]));
1917 return JSValueMakeUndefined(context);
1920 static JSValueRef apiTestNewWindowDataLoadBaseURLCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1922 if (argumentCount != 2)
1923 return JSValueMakeUndefined(context);
1925 JSRetainPtr<JSStringRef> utf8Data(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1926 ASSERT(!*exception);
1928 JSRetainPtr<JSStringRef> baseURL(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1929 ASSERT(!*exception);
1931 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1932 controller->apiTestNewWindowDataLoadBaseURL(utf8Data.get(), baseURL.get());
1933 return JSValueMakeUndefined(context);
1936 static JSValueRef apiTestGoToCurrentBackForwardItemCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1938 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1939 controller->apiTestGoToCurrentBackForwardItem();
1940 return JSValueMakeUndefined(context);
1943 static JSValueRef setWebViewEditableCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1945 // Has Mac implementation
1946 if (argumentCount < 1)
1947 return JSValueMakeUndefined(context);
1949 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1950 controller->setWebViewEditable(JSValueToBoolean(context, arguments[0]));
1952 return JSValueMakeUndefined(context);
1955 static JSValueRef sendWebIntentResponseCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1957 JSRetainPtr<JSStringRef> response;
1958 if (argumentCount == 1) {
1959 response.adopt(JSValueToStringCopy(context, arguments[0], exception));
1960 ASSERT(!*exception);
1962 response.adopt(JSStringCreateWithUTF8CString(0));
1964 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1965 controller->sendWebIntentResponse(response.get());
1967 return JSValueMakeUndefined(context);
1970 static JSValueRef deliverWebIntentCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1972 if (argumentCount < 3)
1973 return JSValueMakeUndefined(context);
1975 JSRetainPtr<JSStringRef> action(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1976 ASSERT(!*exception);
1977 JSRetainPtr<JSStringRef> type(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1978 ASSERT(!*exception);
1979 JSRetainPtr<JSStringRef> data(Adopt, JSValueToStringCopy(context, arguments[2], exception));
1980 ASSERT(!*exception);
1982 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1983 controller->deliverWebIntent(action.get(), type.get(), data.get());
1985 return JSValueMakeUndefined(context);
1988 static JSValueRef abortModalCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1990 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1991 controller->abortModal();
1992 return JSValueMakeUndefined(context);
1995 static JSValueRef markerTextForListItemCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1997 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1998 if (argumentCount < 1)
1999 return JSValueMakeUndefined(context);
2000 return JSValueMakeString(context, controller->markerTextForListItem(context, arguments[0]).get());
2003 static JSValueRef authenticateSessionCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
2005 // authenticateSession(url, username, password)
2006 if (argumentCount != 3)
2007 return JSValueMakeUndefined(context);
2009 JSRetainPtr<JSStringRef> url(Adopt, JSValueToStringCopy(context, arguments[0], exception));
2010 ASSERT(!*exception);
2011 JSRetainPtr<JSStringRef> username(Adopt, JSValueToStringCopy(context, arguments[1], exception));
2012 ASSERT(!*exception);
2013 JSRetainPtr<JSStringRef> password(Adopt, JSValueToStringCopy(context, arguments[2], exception));
2014 ASSERT(!*exception);
2016 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2017 controller->authenticateSession(url.get(), username.get(), password.get());
2018 return JSValueMakeUndefined(context);
2021 static JSValueRef setSerializeHTTPLoadsCallback(JSContextRef context, JSObjectRef, JSObjectRef, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
2023 bool serialize = true;
2024 if (argumentCount == 1)
2025 serialize = JSValueToBoolean(context, arguments[0]);
2027 LayoutTestController::setSerializeHTTPLoads(serialize);
2028 return JSValueMakeUndefined(context);
2031 static JSValueRef setShouldStayOnPageAfterHandlingBeforeUnloadCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
2033 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2035 if (argumentCount == 1)
2036 controller->setShouldStayOnPageAfterHandlingBeforeUnload(JSValueToBoolean(context, arguments[0]));
2038 return JSValueMakeUndefined(context);
2041 static JSValueRef addChromeInputFieldCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
2043 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2044 controller->addChromeInputField();
2045 // the first argument is a callback that is called once the input field has been added
2046 if (argumentCount == 1)
2047 JSObjectCallAsFunction(context, JSValueToObject(context, arguments[0], 0), thisObject, 0, 0, 0);
2048 return JSValueMakeUndefined(context);
2051 static JSValueRef removeChromeInputFieldCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
2053 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2054 controller->removeChromeInputField();
2055 // the first argument is a callback that is called once the input field has been added
2056 if (argumentCount == 1)
2057 JSObjectCallAsFunction(context, JSValueToObject(context, arguments[0], 0), thisObject, 0, 0, 0);
2058 return JSValueMakeUndefined(context);
2061 static JSValueRef focusWebViewCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
2063 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2064 controller->focusWebView();
2065 // the first argument is a callback that is called once the input field has been added
2066 if (argumentCount == 1)
2067 JSObjectCallAsFunction(context, JSValueToObject(context, arguments[0], 0), thisObject, 0, 0, 0);
2068 return JSValueMakeUndefined(context);
2071 static JSValueRef setBackingScaleFactorCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
2073 if (argumentCount != 2)
2074 return JSValueMakeUndefined(context);
2076 double backingScaleFactor = JSValueToNumber(context, arguments[0], exception);
2077 ASSERT(!*exception);
2079 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2080 controller->setBackingScaleFactor(backingScaleFactor);
2082 // The second argument is a callback that is called once the backing scale factor has been set.
2083 JSObjectCallAsFunction(context, JSValueToObject(context, arguments[1], 0), thisObject, 0, 0, 0);
2084 return JSValueMakeUndefined(context);
2087 static JSValueRef preciseTimeCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
2089 return JSValueMakeNumber(context, WTF::currentTime());
2094 static JSValueRef getGlobalFlagCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
2096 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2097 return JSValueMakeBoolean(context, controller->globalFlag());
2100 static JSValueRef getWebHistoryItemCountCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
2102 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2103 return JSValueMakeNumber(context, controller->webHistoryItemCount());
2106 static JSValueRef getWorkerThreadCountCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
2108 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2109 return JSValueMakeNumber(context, controller->workerThreadCount());
2112 #if PLATFORM(MAC) || PLATFORM(GTK) || PLATFORM(WIN)
2113 static JSValueRef getPlatformNameCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
2115 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2116 JSRetainPtr<JSStringRef> platformName(controller->platformName());
2117 if (!platformName.get())
2118 return JSValueMakeUndefined(context);
2119 return JSValueMakeString(context, platformName.get());
2123 static JSValueRef getTitleTextDirectionCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
2125 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2126 JSRetainPtr<JSStringRef> titleDirection(Adopt, JSStringCreateWithUTF8CString(controller->titleTextDirection().c_str()));
2127 return JSValueMakeString(context, titleDirection.get());
2130 static bool setGlobalFlagCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef value, JSValueRef* exception)
2132 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2133 controller->setGlobalFlag(JSValueToBoolean(context, value));
2137 static JSValueRef ignoreDesktopNotificationPermissionRequestsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
2139 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2140 controller->ignoreDesktopNotificationPermissionRequests();
2141 return JSValueMakeUndefined(context);
2144 static JSValueRef simulateDesktopNotificationClickCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
2146 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2147 JSRetainPtr<JSStringRef> title(Adopt, JSValueToStringCopy(context, arguments[0], exception));
2148 controller->simulateDesktopNotificationClick(title.get());
2149 return JSValueMakeUndefined(context);
2152 static JSValueRef setMinimumTimerIntervalCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
2154 if (argumentCount < 1)
2155 return JSValueMakeUndefined(context);
2157 double minimum = JSValueToNumber(context, arguments[0], exception);
2158 ASSERT(!*exception);
2160 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2161 controller->setMinimumTimerInterval(minimum);
2163 return JSValueMakeUndefined(context);
2166 static JSValueRef setTextDirectionCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
2168 if (argumentCount == 1) {
2169 JSRetainPtr<JSStringRef> direction(Adopt, JSValueToStringCopy(context, arguments[0], exception));
2170 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2171 controller->setTextDirection(direction.get());
2174 return JSValueMakeUndefined(context);
2178 static JSValueRef setHasCustomFullScreenBehaviorCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
2180 if (argumentCount == 1) {
2181 bool hasCustomBehavior = JSValueToBoolean(context, arguments[0]);
2182 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2183 controller->setHasCustomFullScreenBehavior(hasCustomBehavior);
2186 return JSValueMakeUndefined(context);
2189 static JSValueRef setStorageDatabaseIdleIntervalCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
2191 if (argumentCount != 1)
2192 return JSValueMakeUndefined(context);
2194 double interval = JSValueToNumber(context, arguments[0], exception);
2195 ASSERT(!*exception);
2197 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2198 controller->setStorageDatabaseIdleInterval(interval);
2200 return JSValueMakeUndefined(context);
2203 static void layoutTestControllerObjectFinalize(JSObjectRef object)
2205 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(object));
2206 controller->deref();
2211 void LayoutTestController::makeWindowObject(JSContextRef context, JSObjectRef windowObject, JSValueRef* exception)
2213 JSRetainPtr<JSStringRef> layoutTestContollerStr(Adopt, JSStringCreateWithUTF8CString("layoutTestController"));
2214 JSRetainPtr<JSStringRef> testRunnerStr(Adopt, JSStringCreateWithUTF8CString("testRunner"));
2218 JSClassRef classRef = getJSClass();
2219 JSValueRef layoutTestContollerObject = JSObjectMake(context, classRef, this);
2220 JSClassRelease(classRef);
2222 JSObjectSetProperty(context, windowObject, layoutTestContollerStr.get(), layoutTestContollerObject, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete, exception);
2223 JSObjectSetProperty(context, windowObject, testRunnerStr.get(), layoutTestContollerObject, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete, exception);
2226 JSClassRef LayoutTestController::getJSClass()
2228 static JSStaticValue* staticValues = LayoutTestController::staticValues();
2229 static JSStaticFunction* staticFunctions = LayoutTestController::staticFunctions();
2230 static JSClassDefinition classDefinition = {
2231 0, kJSClassAttributeNone, "LayoutTestController", 0, staticValues, staticFunctions,
2232 0, layoutTestControllerObjectFinalize, 0, 0, 0, 0, 0, 0, 0, 0, 0
2235 return JSClassCreate(&classDefinition);
2238 JSStaticValue* LayoutTestController::staticValues()
2240 static JSStaticValue staticValues[] = {
2241 { "globalFlag", getGlobalFlagCallback, setGlobalFlagCallback, kJSPropertyAttributeNone },
2242 { "webHistoryItemCount", getWebHistoryItemCountCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2243 { "workerThreadCount", getWorkerThreadCountCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2244 #if PLATFORM(MAC) || PLATFORM(GTK) || PLATFORM(WIN)
2245 { "platformName", getPlatformNameCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2247 { "titleTextDirection", getTitleTextDirectionCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2250 return staticValues;
2253 JSStaticFunction* LayoutTestController::staticFunctions()
2255 static JSStaticFunction staticFunctions[] = {
2256 { "abortModal", abortModalCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2257 { "addDisallowedURL", addDisallowedURLCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2258 { "addURLToRedirect", addURLToRedirectCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2259 { "addUserScript", addUserScriptCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2260 { "addUserStyleSheet", addUserStyleSheetCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2261 { "apiTestNewWindowDataLoadBaseURL", apiTestNewWindowDataLoadBaseURLCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2262 { "apiTestGoToCurrentBackForwardItem", apiTestGoToCurrentBackForwardItemCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2263 { "applicationCacheDiskUsageForOrigin", applicationCacheDiskUsageForOriginCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2264 { "callShouldCloseOnWebView", callShouldCloseOnWebViewCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2265 { "clearAllApplicationCaches", clearAllApplicationCachesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2266 { "clearAllDatabases", clearAllDatabasesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2267 { "clearApplicationCacheForOrigin", clearApplicationCacheForOriginCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2268 { "clearBackForwardList", clearBackForwardListCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2269 { "clearPersistentUserStyleSheet", clearPersistentUserStyleSheetCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2270 { "closeWebInspector", closeWebInspectorCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2271 { "computedStyleIncludingVisitedInfo", computedStyleIncludingVisitedInfoCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2272 { "decodeHostName", decodeHostNameCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2273 { "deliverWebIntent", deliverWebIntentCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2274 { "disableImageLoading", disableImageLoadingCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2275 { "disallowIncreaseForApplicationCacheQuota", disallowIncreaseForApplicationCacheQuotaCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2276 { "dispatchPendingLoadRequests", dispatchPendingLoadRequestsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2277 { "display", displayCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2278 { "displayInvalidatedRegion", displayInvalidatedRegionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2279 { "dumpApplicationCacheDelegateCallbacks", dumpApplicationCacheDelegateCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2280 { "dumpAsText", dumpAsTextCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2281 { "dumpBackForwardList", dumpBackForwardListCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2282 { "dumpChildFrameScrollPositions", dumpChildFrameScrollPositionsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2283 { "dumpChildFramesAsText", dumpChildFramesAsTextCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2284 { "dumpDOMAsWebArchive", dumpDOMAsWebArchiveCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2285 { "dumpDatabaseCallbacks", dumpDatabaseCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2286 { "dumpEditingCallbacks", dumpEditingCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2287 { "dumpFrameLoadCallbacks", dumpFrameLoadCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2288 { "dumpProgressFinishedCallback", dumpProgressFinishedCallbackCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2289 { "dumpUserGestureInFrameLoadCallbacks", dumpUserGestureInFrameLoadCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2290 { "dumpResourceLoadCallbacks", dumpResourceLoadCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2291 { "dumpResourceResponseMIMETypes", dumpResourceResponseMIMETypesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2292 { "dumpSelectionRect", dumpSelectionRectCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2293 { "dumpSourceAsWebArchive", dumpSourceAsWebArchiveCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2294 { "dumpStatusCallbacks", dumpStatusCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2295 { "dumpTitleChanges", dumpTitleChangesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2296 { "dumpIconChanges", dumpIconChangesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2297 { "dumpWillCacheResponse", dumpWillCacheResponseCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2298 { "elementDoesAutoCompleteForElementWithId", elementDoesAutoCompleteForElementWithIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2299 { "encodeHostName", encodeHostNameCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2300 { "evaluateInWebInspector", evaluateInWebInspectorCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2301 { "evaluateScriptInIsolatedWorldAndReturnValue", evaluateScriptInIsolatedWorldAndReturnValueCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2302 { "evaluateScriptInIsolatedWorld", evaluateScriptInIsolatedWorldCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2303 { "execCommand", execCommandCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2304 { "findString", findStringCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2305 { "originsWithApplicationCache", originsWithApplicationCacheCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2306 { "goBack", goBackCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2307 { "grantDesktopNotificationPermission", grantDesktopNotificationPermissionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2308 { "ignoreDesktopNotificationPermissionRequests", ignoreDesktopNotificationPermissionRequestsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2309 { "isCommandEnabled", isCommandEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2310 { "keepWebHistory", keepWebHistoryCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2311 { "layerTreeAsText", layerTreeAsTextCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2312 { "numberOfPages", numberOfPagesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2313 { "numberOfPendingGeolocationPermissionRequests", numberOfPendingGeolocationPermissionRequestsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2314 { "markerTextForListItem", markerTextForListItemCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2315 { "notifyDone", notifyDoneCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2316 { "numberOfActiveAnimations", numberOfActiveAnimationsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2317 { "overridePreference", overridePreferenceCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2318 { "pageSizeAndMarginsInPixels", pageSizeAndMarginsInPixelsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2319 { "pageProperty", pagePropertyCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2320 { "pathToLocalResource", pathToLocalResourceCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2321 { "pauseAnimationAtTimeOnElementWithId", pauseAnimationAtTimeOnElementWithIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2322 { "pauseTransitionAtTimeOnElementWithId", pauseTransitionAtTimeOnElementWithIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2323 { "printToPDF", dumpAsPDFCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2324 { "queueBackNavigation", queueBackNavigationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2325 { "queueForwardNavigation", queueForwardNavigationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2326 { "queueLoad", queueLoadCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2327 { "queueLoadHTMLString", queueLoadHTMLStringCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2328 { "queueLoadingScript", queueLoadingScriptCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2329 { "queueNonLoadingScript", queueNonLoadingScriptCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2330 { "queueReload", queueReloadCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2331 { "removeAllVisitedLinks", removeAllVisitedLinksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2332 { "removeOriginAccessWhitelistEntry", removeOriginAccessWhitelistEntryCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2333 { "repaintSweepHorizontally", repaintSweepHorizontallyCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2334 { "resetPageVisibility", resetPageVisibilityCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2335 { "sendWebIntentResponse", sendWebIntentResponseCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2336 { "setAcceptsEditing", setAcceptsEditingCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2337 { "setAllowUniversalAccessFromFileURLs", setAllowUniversalAccessFromFileURLsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2338 { "setAllowFileAccessFromFileURLs", setAllowFileAccessFromFileURLsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2339 { "setAlwaysAcceptCookies", setAlwaysAcceptCookiesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2340 { "setAppCacheMaximumSize", setAppCacheMaximumSizeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2341 { "setApplicationCacheOriginQuota", setApplicationCacheOriginQuotaCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2342 { "setEncodedAudioData", setEncodedAudioDataCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2343 { "setAuthenticationPassword", setAuthenticationPasswordCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2344 { "setAuthenticationUsername", setAuthenticationUsernameCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2345 { "setAuthorAndUserStylesEnabled", setAuthorAndUserStylesEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2346 { "setAutofilled", setAutofilledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2347 { "setCacheModel", setCacheModelCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2348 { "setCallCloseOnWebViews", setCallCloseOnWebViewsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2349 { "setCanOpenWindows", setCanOpenWindowsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2350 { "setCloseRemainingWindowsWhenComplete", setCloseRemainingWindowsWhenCompleteCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2351 { "setCustomPolicyDelegate", setCustomPolicyDelegateCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2352 { "setDatabaseQuota", setDatabaseQuotaCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2353 { "setDeferMainResourceDataLoad", setDeferMainResourceDataLoadCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2354 { "setDefersLoading", setDefersLoadingCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2355 { "setUseDeferredFrameLoading", setUseDeferredFrameLoadingCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2356 { "setDomainRelaxationForbiddenForURLScheme", setDomainRelaxationForbiddenForURLSchemeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2357 { "setFrameFlatteningEnabled", setFrameFlatteningEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2358 { "setGeolocationPermission", setGeolocationPermissionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2359 { "setHandlesAuthenticationChallenges", setHandlesAuthenticationChallengesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2360 { "setIconDatabaseEnabled", setIconDatabaseEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2361 { "setAutomaticLinkDetectionEnabled", setAutomaticLinkDetectionEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2362 { "setMainFrameIsFirstResponder", setMainFrameIsFirstResponderCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2363 { "setMinimumTimerInterval", setMinimumTimerIntervalCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2364 { "setMockDeviceOrientation", setMockDeviceOrientationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2365 { "setMockGeolocationError", setMockGeolocationErrorCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2366 { "setMockGeolocationPosition", setMockGeolocationPositionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2367 { "addMockSpeechInputResult", addMockSpeechInputResultCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2368 { "setMockSpeechInputDumpRect", setMockSpeechInputDumpRectCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2369 { "setNewWindowsCopyBackForwardList", setNewWindowsCopyBackForwardListCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2370 { "setPageVisibility", setPageVisibilityCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2371 { "setPOSIXLocale", setPOSIXLocaleCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2372 { "setPersistentUserStyleSheetLocation", setPersistentUserStyleSheetLocationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2373 { "setPopupBlockingEnabled", setPopupBlockingEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2374 { "setPluginsEnabled", setPluginsEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2375 { "setPrinting", setPrintingCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2376 { "setPrivateBrowsingEnabled", setPrivateBrowsingEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2377 { "setSelectTrailingWhitespaceEnabled", setSelectTrailingWhitespaceEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2378 { "setSerializeHTTPLoads", setSerializeHTTPLoadsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2379 { "setSmartInsertDeleteEnabled", setSmartInsertDeleteEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2380 { "setSpatialNavigationEnabled", setSpatialNavigationEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2381 { "setStopProvisionalFrameLoads", setStopProvisionalFrameLoadsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2382 { "setTabKeyCyclesThroughElements", setTabKeyCyclesThroughElementsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2383 { "setUseDashboardCompatibilityMode", setUseDashboardCompatibilityModeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2384 { "setUserStyleSheetEnabled", setUserStyleSheetEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2385 { "setUserStyleSheetLocation", setUserStyleSheetLocationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2386 { "setValueForUser", setValueForUserCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2387 { "setViewModeMediaFeature", setViewModeMediaFeatureCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2388 { "setWebViewEditable", setWebViewEditableCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2389 { "setWillSendRequestClearHeader", setWillSendRequestClearHeaderCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2390 { "setWillSendRequestReturnsNull", setWillSendRequestReturnsNullCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2391 { "setWillSendRequestReturnsNullOnRedirect", setWillSendRequestReturnsNullOnRedirectCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2392 { "setWindowIsKey", setWindowIsKeyCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2393 { "setJavaScriptCanAccessClipboard", setJavaScriptCanAccessClipboardCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2394 { "setXSSAuditorEnabled", setXSSAuditorEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2395 { "setAsynchronousSpellCheckingEnabled", setAsynchronousSpellCheckingEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2396 { "showWebInspector", showWebInspectorCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2397 { "simulateDesktopNotificationClick", simulateDesktopNotificationClickCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2398 { "testOnscreen", testOnscreenCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2399 { "testRepaint", testRepaintCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2400 { "waitForPolicyDelegate", waitForPolicyDelegateCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2401 { "waitUntilDone", waitUntilDoneCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2402 { "windowCount", windowCountCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2403 { "addOriginAccessWhitelistEntry", addOriginAccessWhitelistEntryCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2404 { "setScrollbarPolicy", setScrollbarPolicyCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2405 { "authenticateSession", authenticateSessionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2406 { "deleteAllLocalStorage", deleteAllLocalStorageCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2407 { "syncLocalStorage", syncLocalStorageCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2408 { "observeStorageTrackerNotifications", observeStorageTrackerNotificationsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2409 { "deleteLocalStorageForOrigin", deleteLocalStorageForOriginCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2410 { "localStorageDiskUsageForOrigin", localStorageDiskUsageForOriginCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2411 { "originsWithLocalStorage", originsWithLocalStorageCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2412 { "setShouldPaintBrokenImage", setShouldPaintBrokenImageCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2413 { "setTextDirection", setTextDirectionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2414 { "setShouldStayOnPageAfterHandlingBeforeUnload", setShouldStayOnPageAfterHandlingBeforeUnloadCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2415 { "addChromeInputField", addChromeInputFieldCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2416 { "removeChromeInputField", removeChromeInputFieldCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2417 { "focusWebView", focusWebViewCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2418 { "setBackingScaleFactor", setBackingScaleFactorCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2419 { "preciseTime", preciseTimeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2420 { "setHasCustomFullScreenBehavior", setHasCustomFullScreenBehaviorCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2421 { "setStorageDatabaseIdleInterval", setStorageDatabaseIdleIntervalCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2425 return staticFunctions;
2428 void LayoutTestController::queueLoadHTMLString(JSStringRef content, JSStringRef baseURL)
2430 WorkQueue::shared()->queue(new LoadHTMLStringItem(content, baseURL));
2433 void LayoutTestController::queueLoadAlternateHTMLString(JSStringRef content, JSStringRef baseURL, JSStringRef unreachableURL)
2435 WorkQueue::shared()->queue(new LoadHTMLStringItem(content, baseURL, unreachableURL));
2438 void LayoutTestController::queueBackNavigation(int howFarBack)
2440 WorkQueue::shared()->queue(new BackItem(howFarBack));
2443 void LayoutTestController::queueForwardNavigation(int howFarForward)
2445 WorkQueue::shared()->queue(new ForwardItem(howFarForward));
2448 void LayoutTestController::queueLoadingScript(JSStringRef script)
2450 WorkQueue::shared()->queue(new LoadingScriptItem(script));
2453 void LayoutTestController::queueNonLoadingScript(JSStringRef script)
2455 WorkQueue::shared()->queue(new NonLoadingScriptItem(script));
2458 void LayoutTestController::queueReload()
2460 WorkQueue::shared()->queue(new ReloadItem);
2463 void LayoutTestController::grantDesktopNotificationPermission(JSStringRef origin)
2465 m_desktopNotificationAllowedOrigins.push_back(JSStringRetain(origin));
2468 bool LayoutTestController::checkDesktopNotificationPermission(JSStringRef origin)
2470 std::vector<JSStringRef>::iterator i;
2471 for (i = m_desktopNotificationAllowedOrigins.begin();
2472 i != m_desktopNotificationAllowedOrigins.end();
2474 if (JSStringIsEqual(*i, origin))
2480 void LayoutTestController::ignoreDesktopNotificationPermissionRequests()
2482 m_areDesktopNotificationPermissionRequestsIgnored = false;
2485 void LayoutTestController::waitToDumpWatchdogTimerFired()
2487 const char* message = "FAIL: Timed out waiting for notifyDone to be called\n";
2488 fprintf(stderr, "%s", message);
2489 fprintf(stdout, "%s", message);
2493 void LayoutTestController::setGeolocationPermissionCommon(bool allow)
2495 m_isGeolocationPermissionSet = true;
2496 m_geolocationPermission = allow;
2499 void LayoutTestController::setPOSIXLocale(JSStringRef locale)
2502 JSStringGetUTF8CString(locale, localeBuf, sizeof(localeBuf));
2503 setlocale(LC_ALL, localeBuf);
2506 void LayoutTestController::addURLToRedirect(std::string origin, std::string destination)
2508 m_URLsToRedirect[origin] = destination;
2511 const std::string& LayoutTestController::redirectionDestinationForURL(std::string origin)
2513 return m_URLsToRedirect[origin];
2516 void LayoutTestController::setShouldPaintBrokenImage(bool shouldPaintBrokenImage)
2518 m_shouldPaintBrokenImage = shouldPaintBrokenImage;
2521 const unsigned LayoutTestController::maxViewWidth = 800;
2522 const unsigned LayoutTestController::maxViewHeight = 600;