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)
102 PassRefPtr<LayoutTestController> LayoutTestController::create(const std::string& testPathOrURL, const std::string& expectedPixelHash)
104 return adoptRef(new LayoutTestController(testPathOrURL, expectedPixelHash));
109 static JSValueRef disallowIncreaseForApplicationCacheQuotaCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
111 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
112 controller->setDisallowIncreaseForApplicationCacheQuota(true);
113 return JSValueMakeUndefined(context);
116 static JSValueRef dumpApplicationCacheDelegateCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
118 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
119 controller->setDumpApplicationCacheDelegateCallbacks(true);
120 return JSValueMakeUndefined(context);
123 static JSValueRef dumpAsPDFCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
125 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
126 controller->setDumpAsPDF(true);
127 return JSValueMakeUndefined(context);
130 static JSValueRef dumpAsTextCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
132 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
133 controller->setDumpAsText(true);
135 // Optional paramater, describing whether it's allowed to dump pixel results in dumpAsText mode.
136 controller->setGeneratePixelResults(argumentCount > 0 ? JSValueToBoolean(context, arguments[0]) : false);
138 return JSValueMakeUndefined(context);
141 static JSValueRef dumpBackForwardListCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
143 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
144 controller->setDumpBackForwardList(true);
145 return JSValueMakeUndefined(context);
148 static JSValueRef dumpChildFramesAsTextCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
150 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
151 controller->setDumpChildFramesAsText(true);
152 return JSValueMakeUndefined(context);
155 static JSValueRef dumpChildFrameScrollPositionsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
157 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
158 controller->setDumpChildFrameScrollPositions(true);
159 return JSValueMakeUndefined(context);
162 static JSValueRef dumpConfigurationForViewportCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
164 if (argumentCount < 2)
165 return JSValueMakeUndefined(context);
168 double deviceDPI = JSValueToNumber(context, arguments[0], exception);
170 double deviceWidth = JSValueToNumber(context, arguments[1], exception);
172 double deviceHeight = JSValueToNumber(context, arguments[2], exception);
174 double availableWidth = JSValueToNumber(context, arguments[3], exception);
176 double availableHeight = JSValueToNumber(context, arguments[4], exception);
179 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
180 controller->dumpConfigurationForViewport(static_cast<int>(deviceDPI), static_cast<int>(deviceWidth), static_cast<int>(deviceHeight), static_cast<int>(availableWidth), static_cast<int>(availableHeight));
182 return JSValueMakeUndefined(context);
185 static JSValueRef dumpDatabaseCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
187 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
188 controller->setDumpDatabaseCallbacks(true);
189 return JSValueMakeUndefined(context);
192 static JSValueRef dumpDOMAsWebArchiveCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
194 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
195 controller->setDumpDOMAsWebArchive(true);
196 return JSValueMakeUndefined(context);
199 static JSValueRef dumpEditingCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
201 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
202 controller->setDumpEditingCallbacks(true);
203 return JSValueMakeUndefined(context);
206 static JSValueRef dumpFrameLoadCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
208 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
209 controller->setDumpFrameLoadCallbacks(true);
210 return JSValueMakeUndefined(context);
213 static JSValueRef dumpProgressFinishedCallbackCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
215 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
216 controller->setDumpProgressFinishedCallback(true);
217 return JSValueMakeUndefined(context);
220 static JSValueRef dumpUserGestureInFrameLoadCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
222 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
223 controller->setDumpUserGestureInFrameLoadCallbacks(true);
224 return JSValueMakeUndefined(context);
227 static JSValueRef dumpResourceLoadCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
229 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
230 controller->setDumpResourceLoadCallbacks(true);
231 return JSValueMakeUndefined(context);
234 static JSValueRef dumpResourceResponseMIMETypesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
236 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
237 controller->setDumpResourceResponseMIMETypes(true);
238 return JSValueMakeUndefined(context);
241 static JSValueRef dumpSelectionRectCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
243 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
244 controller->setDumpSelectionRect(true);
245 return JSValueMakeUndefined(context);
248 static JSValueRef dumpSourceAsWebArchiveCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
250 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
251 controller->setDumpSourceAsWebArchive(true);
252 return JSValueMakeUndefined(context);
255 static JSValueRef dumpStatusCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
257 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
258 controller->setDumpStatusCallbacks(true);
259 return JSValueMakeUndefined(context);
262 static JSValueRef dumpTitleChangesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
264 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
265 controller->setDumpTitleChanges(true);
266 return JSValueMakeUndefined(context);
269 static JSValueRef dumpIconChangesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
271 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
272 controller->setDumpIconChanges(true);
273 return JSValueMakeUndefined(context);
276 static JSValueRef dumpWillCacheResponseCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
278 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
279 controller->setDumpWillCacheResponse(true);
280 return JSValueMakeUndefined(context);
283 static JSValueRef pathToLocalResourceCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
285 if (argumentCount < 1)
286 return JSValueMakeUndefined(context);
288 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
289 JSRetainPtr<JSStringRef> localPath(Adopt, JSValueToStringCopy(context, arguments[0], exception));
292 JSRetainPtr<JSStringRef> convertedPath(Adopt, controller->pathToLocalResource(context, localPath.get()));
294 return JSValueMakeUndefined(context);
296 return JSValueMakeString(context, convertedPath.get());
299 static JSValueRef removeAllVisitedLinksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
301 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
302 controller->setDumpVisitedLinksCallback(true);
303 controller->removeAllVisitedLinks();
304 return JSValueMakeUndefined(context);
307 static JSValueRef repaintSweepHorizontallyCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
309 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
310 controller->setTestRepaintSweepHorizontally(true);
311 return JSValueMakeUndefined(context);
314 static JSValueRef setCallCloseOnWebViewsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
316 if (argumentCount < 1)
317 return JSValueMakeUndefined(context);
319 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
320 controller->setCallCloseOnWebViews(JSValueToBoolean(context, arguments[0]));
321 return JSValueMakeUndefined(context);
324 static JSValueRef setCanOpenWindowsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
326 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
327 controller->setCanOpenWindows(true);
328 return JSValueMakeUndefined(context);
331 static JSValueRef setCloseRemainingWindowsWhenCompleteCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
333 if (argumentCount < 1)
334 return JSValueMakeUndefined(context);
336 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
337 controller->setCloseRemainingWindowsWhenComplete(JSValueToBoolean(context, arguments[0]));
338 return JSValueMakeUndefined(context);
341 static JSValueRef setEncodedAudioDataCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
343 if (argumentCount < 1)
344 return JSValueMakeUndefined(context);
346 JSRetainPtr<JSStringRef> encodedAudioData(Adopt, JSValueToStringCopy(context, arguments[0], exception));
349 size_t maxLength = JSStringGetMaximumUTF8CStringSize(encodedAudioData.get());
350 OwnArrayPtr<char> encodedAudioDataBuffer = adoptArrayPtr(new char[maxLength + 1]);
351 JSStringGetUTF8CString(encodedAudioData.get(), encodedAudioDataBuffer.get(), maxLength + 1);
353 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
354 controller->setEncodedAudioData(encodedAudioDataBuffer.get());
355 controller->setDumpAsAudio(true);
357 return JSValueMakeUndefined(context);
360 static JSValueRef testOnscreenCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
362 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
363 controller->setTestOnscreen(true);
364 return JSValueMakeUndefined(context);
367 static JSValueRef testRepaintCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
369 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
370 controller->setTestRepaint(true);
371 return JSValueMakeUndefined(context);
374 static JSValueRef addDisallowedURLCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
376 // Has mac implementation
377 if (argumentCount < 1)
378 return JSValueMakeUndefined(context);
380 JSRetainPtr<JSStringRef> url(Adopt, JSValueToStringCopy(context, arguments[0], exception));
383 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
384 controller->addDisallowedURL(url.get());
386 return JSValueMakeUndefined(context);
389 static JSValueRef addURLToRedirectCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
391 if (argumentCount < 2)
392 return JSValueMakeUndefined(context);
394 JSRetainPtr<JSStringRef> origin(Adopt, JSValueToStringCopy(context, arguments[0], exception));
397 JSRetainPtr<JSStringRef> destination(Adopt, JSValueToStringCopy(context, arguments[1], exception));
400 size_t maxLength = JSStringGetMaximumUTF8CStringSize(origin.get());
401 OwnArrayPtr<char> originBuffer = adoptArrayPtr(new char[maxLength + 1]);
402 JSStringGetUTF8CString(origin.get(), originBuffer.get(), maxLength + 1);
404 maxLength = JSStringGetMaximumUTF8CStringSize(destination.get());
405 OwnArrayPtr<char> destinationBuffer = adoptArrayPtr(new char[maxLength + 1]);
406 JSStringGetUTF8CString(destination.get(), destinationBuffer.get(), maxLength + 1);
408 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
409 controller->addURLToRedirect(originBuffer.get(), destinationBuffer.get());
411 return JSValueMakeUndefined(context);
414 static JSValueRef callShouldCloseOnWebViewCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
416 // Has mac & windows implementation
417 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
419 return JSValueMakeBoolean(context, controller->callShouldCloseOnWebView());
422 static JSValueRef clearAllApplicationCachesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
424 // Has mac implementation
425 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
426 controller->clearAllApplicationCaches();
428 return JSValueMakeUndefined(context);
431 static JSValueRef clearApplicationCacheForOriginCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
433 if (argumentCount < 1)
434 return JSValueMakeUndefined(context);
436 JSRetainPtr<JSStringRef> originURL(Adopt, JSValueToStringCopy(context, arguments[0], exception));
439 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
440 controller->clearApplicationCacheForOrigin(originURL.get());
442 return JSValueMakeUndefined(context);
445 static JSValueRef applicationCacheDiskUsageForOriginCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
447 if (argumentCount < 1)
448 return JSValueMakeUndefined(context);
450 JSRetainPtr<JSStringRef> originURL(Adopt, JSValueToStringCopy(context, arguments[0], exception));
453 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
455 return JSValueMakeNumber(context, controller->applicationCacheDiskUsageForOrigin(originURL.get()));
458 static JSValueRef originsWithApplicationCacheCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
460 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
461 return controller->originsWithApplicationCache(context);
464 static JSValueRef clearAllDatabasesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
466 // Has mac & windows implementation
467 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
468 controller->clearAllDatabases();
470 return JSValueMakeUndefined(context);
473 static JSValueRef syncLocalStorageCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
475 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
477 controller->syncLocalStorage();
479 return JSValueMakeUndefined(context);
482 static JSValueRef observeStorageTrackerNotificationsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
484 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
486 if (argumentCount < 1)
487 return JSValueMakeUndefined(context);
489 unsigned numNotifications = JSValueToNumber(context, arguments[0], exception);
493 controller->observeStorageTrackerNotifications(numNotifications);
495 return JSValueMakeUndefined(context);
498 static JSValueRef deleteAllLocalStorageCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
500 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
501 controller->deleteAllLocalStorage();
503 return JSValueMakeUndefined(context);
506 static JSValueRef deleteLocalStorageForOriginCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
508 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
510 if (argumentCount < 1)
511 return JSValueMakeUndefined(context);
513 JSRetainPtr<JSStringRef> url(Adopt, JSValueToStringCopy(context, arguments[0], exception));
516 controller->deleteLocalStorageForOrigin(url.get());
518 return JSValueMakeUndefined(context);
521 static JSValueRef localStorageDiskUsageForOriginCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
523 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
525 if (argumentCount < 1)
526 return JSValueMakeUndefined(context);
528 JSRetainPtr<JSStringRef> originURL(Adopt, JSValueToStringCopy(context, arguments[0], exception));
531 return JSValueMakeNumber(context, controller->localStorageDiskUsageForOrigin(originURL.get()));
534 static JSValueRef originsWithLocalStorageCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
536 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
537 return controller->originsWithLocalStorage(context);
540 static JSValueRef clearBackForwardListCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
542 // Has mac & windows implementation
543 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
544 controller->clearBackForwardList();
546 return JSValueMakeUndefined(context);
549 static JSValueRef clearPersistentUserStyleSheetCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
551 // Has mac & windows implementation
552 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
553 controller->clearPersistentUserStyleSheet();
555 return JSValueMakeUndefined(context);
558 static JSValueRef decodeHostNameCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
560 // Has mac implementation
561 if (argumentCount < 1)
562 return JSValueMakeUndefined(context);
564 JSRetainPtr<JSStringRef> name(Adopt, JSValueToStringCopy(context, arguments[0], exception));
567 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
568 JSRetainPtr<JSStringRef> decodedHostName(Adopt, controller->copyDecodedHostName(name.get()));
569 return JSValueMakeString(context, decodedHostName.get());
572 static JSValueRef disableImageLoadingCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
574 // Has mac implementation, needs windows implementation
575 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
576 controller->disableImageLoading();
578 return JSValueMakeUndefined(context);
581 static JSValueRef dispatchPendingLoadRequestsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
583 // Has mac implementation, needs windows implementation
584 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
585 controller->dispatchPendingLoadRequests();
587 return JSValueMakeUndefined(context);
590 static JSValueRef displayCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
592 // Has mac & windows implementation
593 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
594 controller->display();
596 return JSValueMakeUndefined(context);
599 static JSValueRef displayInvalidatedRegionCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
601 // Has mac & windows implementation
602 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
603 // LayoutTestController::display() only renders the invalidated region so
604 // we can just use that.
605 controller->display();
607 return JSValueMakeUndefined(context);
610 static JSValueRef encodeHostNameCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
612 // Has mac implementation
613 if (argumentCount < 1)
614 return JSValueMakeUndefined(context);
616 JSRetainPtr<JSStringRef> name(Adopt, JSValueToStringCopy(context, arguments[0], exception));
619 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
620 JSRetainPtr<JSStringRef> encodedHostName(Adopt, controller->copyEncodedHostName(name.get()));
621 return JSValueMakeString(context, encodedHostName.get());
624 static JSValueRef execCommandCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
626 // Has Mac & Windows implementations.
627 if (argumentCount < 1)
628 return JSValueMakeUndefined(context);
630 JSRetainPtr<JSStringRef> name(Adopt, JSValueToStringCopy(context, arguments[0], exception));
633 // Ignoring the second parameter (userInterface), as this command emulates a manual action.
635 JSRetainPtr<JSStringRef> value;
636 if (argumentCount >= 3) {
637 value.adopt(JSValueToStringCopy(context, arguments[2], exception));
640 value.adopt(JSStringCreateWithUTF8CString(""));
643 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
644 controller->execCommand(name.get(), value.get());
646 return JSValueMakeUndefined(context);
649 static JSValueRef findStringCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
651 // Has Mac implementation.
652 if (argumentCount < 2)
653 return JSValueMakeUndefined(context);
655 JSRetainPtr<JSStringRef> target(Adopt, JSValueToStringCopy(context, arguments[0], exception));
658 JSObjectRef options = JSValueToObject(context, arguments[1], exception);
661 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
662 return JSValueMakeBoolean(context, controller->findString(context, target.get(), options));
665 static JSValueRef counterValueForElementByIdCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
667 if (argumentCount < 1)
668 return JSValueMakeUndefined(context);
670 JSRetainPtr<JSStringRef> elementId(Adopt, JSValueToStringCopy(context, arguments[0], exception));
672 return JSValueMakeUndefined(context);
674 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
675 JSRetainPtr<JSStringRef> counterValue(controller->counterValueForElementById(elementId.get()));
676 if (!counterValue.get())
677 return JSValueMakeUndefined(context);
678 return JSValueMakeString(context, counterValue.get());
681 static JSValueRef goBackCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
683 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
684 controller->goBack();
686 return JSValueMakeUndefined(context);
689 static JSValueRef grantDesktopNotificationPermissionCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
691 // Has Windows implementation
692 if (argumentCount < 1)
693 return JSValueMakeUndefined(context);
695 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
697 controller->grantDesktopNotificationPermission(JSValueToStringCopy(context, arguments[0], NULL));
699 return JSValueMakeUndefined(context);
702 static JSValueRef isCommandEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
704 // Has Mac implementation.
706 if (argumentCount < 1)
707 return JSValueMakeUndefined(context);
709 JSRetainPtr<JSStringRef> name(Adopt, JSValueToStringCopy(context, arguments[0], exception));
712 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
714 return JSValueMakeBoolean(context, controller->isCommandEnabled(name.get()));
717 static JSValueRef overridePreferenceCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
719 if (argumentCount < 2)
720 return JSValueMakeUndefined(context);
722 JSRetainPtr<JSStringRef> key(Adopt, JSValueToStringCopy(context, arguments[0], exception));
724 JSRetainPtr<JSStringRef> value(Adopt, JSValueToStringCopy(context, arguments[1], exception));
727 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
728 controller->overridePreference(key.get(), value.get());
730 return JSValueMakeUndefined(context);
733 static JSValueRef keepWebHistoryCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
735 // Has mac implementation
736 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
737 controller->keepWebHistory();
739 return JSValueMakeUndefined(context);
742 static JSValueRef computedStyleIncludingVisitedInfoCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
744 if (argumentCount != 1)
745 return JSValueMakeUndefined(context);
747 // Has mac implementation
748 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
749 return controller->computedStyleIncludingVisitedInfo(context, arguments[0]);
752 static JSValueRef layerTreeAsTextCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
754 // Has mac & windows implementation
755 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
756 return JSValueMakeString(context, controller->layerTreeAsText().get());
759 static JSValueRef notifyDoneCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
761 // Has mac & windows implementation
762 // May be able to be made platform independant by using shared WorkQueue
763 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
764 controller->notifyDone();
765 return JSValueMakeUndefined(context);
768 static bool parsePageParameters(JSContextRef context, int argumentCount, const JSValueRef* arguments, JSValueRef* exception, float& pageWidthInPixels, float& pageHeightInPixels)
770 pageWidthInPixels = LayoutTestController::maxViewWidth;
771 pageHeightInPixels = LayoutTestController::maxViewHeight;
772 switch (argumentCount) {
774 pageWidthInPixels = static_cast<float>(JSValueToNumber(context, arguments[0], exception));
777 pageHeightInPixels = static_cast<float>(JSValueToNumber(context, arguments[1], exception));
780 case 0: // Fall through.
788 // Caller needs to delete[] propertyName.
789 static bool parsePagePropertyParameters(JSContextRef context, int argumentCount, const JSValueRef* arguments, JSValueRef* exception, char*& propertyName, int& pageNumber)
792 switch (argumentCount) {
794 pageNumber = static_cast<float>(JSValueToNumber(context, arguments[1], exception));
799 JSRetainPtr<JSStringRef> propertyNameString(Adopt, JSValueToStringCopy(context, arguments[0], exception));
803 size_t maxLength = JSStringGetMaximumUTF8CStringSize(propertyNameString.get());
804 propertyName = new char[maxLength + 1];
805 JSStringGetUTF8CString(propertyNameString.get(), propertyName, maxLength + 1);
814 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)
818 marginTop = marginRight = marginBottom = marginLeft = 0;
820 switch (argumentCount) {
822 marginLeft = static_cast<int>(JSValueToNumber(context, arguments[6], exception));
827 marginBottom = static_cast<int>(JSValueToNumber(context, arguments[5], exception));
832 marginRight = static_cast<int>(JSValueToNumber(context, arguments[4], exception));
837 marginTop = static_cast<int>(JSValueToNumber(context, arguments[3], exception));
842 height = static_cast<int>(JSValueToNumber(context, arguments[2], exception));
847 width = static_cast<int>(JSValueToNumber(context, arguments[1], exception));
852 pageNumber = static_cast<int>(JSValueToNumber(context, arguments[0], exception));
862 static JSValueRef pageNumberForElementByIdCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
864 float pageWidthInPixels = 0;
865 float pageHeightInPixels = 0;
866 if (!parsePageParameters(context, argumentCount - 1, arguments + 1, exception, pageWidthInPixels, pageHeightInPixels))
867 return JSValueMakeUndefined(context);
869 JSRetainPtr<JSStringRef> elementId(Adopt, JSValueToStringCopy(context, arguments[0], exception));
871 return JSValueMakeUndefined(context);
873 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
874 int pageNumber = controller->pageNumberForElementById(elementId.get(), pageWidthInPixels, pageHeightInPixels);
875 return JSValueMakeNumber(context, pageNumber);
878 static JSValueRef numberOfPagesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
880 float pageWidthInPixels = 0;
881 float pageHeightInPixels = 0;
882 if (!parsePageParameters(context, argumentCount, arguments, exception, pageWidthInPixels, pageHeightInPixels))
883 return JSValueMakeUndefined(context);
885 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
886 return JSValueMakeNumber(context, controller->numberOfPages(pageWidthInPixels, pageHeightInPixels));
889 static JSValueRef numberOfPendingGeolocationPermissionRequestsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
891 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
892 return JSValueMakeNumber(context, controller->numberOfPendingGeolocationPermissionRequests());
895 static JSValueRef pagePropertyCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
897 char* propertyName = 0;
899 if (!parsePagePropertyParameters(context, argumentCount, arguments, exception, propertyName, pageNumber))
900 return JSValueMakeUndefined(context);
902 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
903 JSValueRef value = JSValueMakeString(context, controller->pageProperty(propertyName, pageNumber).get());
905 delete[] propertyName;
909 static JSValueRef pageSizeAndMarginsInPixelsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
912 int width = 0, height = 0;
913 int marginTop = 0, marginRight = 0, marginBottom = 0, marginLeft = 0;
914 if (!parsePageNumberSizeMarings(context, argumentCount, arguments, exception, pageNumber, width, height, marginTop, marginRight, marginBottom, marginLeft))
915 return JSValueMakeUndefined(context);
917 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
918 return JSValueMakeString(context, controller->pageSizeAndMarginsInPixels(pageNumber, width, height, marginTop, marginRight, marginBottom, marginLeft).get());
921 static JSValueRef queueBackNavigationCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
923 // Has mac & windows implementation
924 // May be able to be made platform independant by using shared WorkQueue
925 if (argumentCount < 1)
926 return JSValueMakeUndefined(context);
928 double howFarBackDouble = JSValueToNumber(context, arguments[0], exception);
931 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
932 controller->queueBackNavigation(static_cast<int>(howFarBackDouble));
934 return JSValueMakeUndefined(context);
937 static JSValueRef queueForwardNavigationCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
939 // Has mac & windows implementation
940 // May be able to be made platform independant by using shared WorkQueue
941 if (argumentCount < 1)
942 return JSValueMakeUndefined(context);
944 double howFarForwardDouble = JSValueToNumber(context, arguments[0], exception);
947 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
948 controller->queueForwardNavigation(static_cast<int>(howFarForwardDouble));
950 return JSValueMakeUndefined(context);
953 static JSValueRef queueLoadCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
955 // Has mac & windows implementation
956 // May be able to be made platform independant by using shared WorkQueue
957 if (argumentCount < 1)
958 return JSValueMakeUndefined(context);
960 JSRetainPtr<JSStringRef> url(Adopt, JSValueToStringCopy(context, arguments[0], exception));
963 JSRetainPtr<JSStringRef> target;
964 if (argumentCount >= 2) {
965 target.adopt(JSValueToStringCopy(context, arguments[1], exception));
968 target.adopt(JSStringCreateWithUTF8CString(""));
970 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
971 controller->queueLoad(url.get(), target.get());
973 return JSValueMakeUndefined(context);
976 static JSValueRef queueLoadHTMLStringCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
978 // Has Mac & Windows implementation
979 if (argumentCount < 1)
980 return JSValueMakeUndefined(context);
982 JSRetainPtr<JSStringRef> content(Adopt, JSValueToStringCopy(context, arguments[0], exception));
985 JSRetainPtr<JSStringRef> baseURL;
986 if (argumentCount >= 2) {
987 baseURL.adopt(JSValueToStringCopy(context, arguments[1], exception));
990 baseURL.adopt(JSStringCreateWithUTF8CString(""));
992 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
994 if (argumentCount >= 3) {
995 JSRetainPtr<JSStringRef> unreachableURL;
996 unreachableURL.adopt(JSValueToStringCopy(context, arguments[2], exception));
998 controller->queueLoadAlternateHTMLString(content.get(), baseURL.get(), unreachableURL.get());
999 return JSValueMakeUndefined(context);
1002 controller->queueLoadHTMLString(content.get(), baseURL.get());
1003 return JSValueMakeUndefined(context);
1006 static JSValueRef queueReloadCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1008 // Has mac & windows implementation
1009 // May be able to be made platform independant by using shared WorkQueue
1011 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1012 controller->queueReload();
1014 return JSValueMakeUndefined(context);
1017 static JSValueRef queueLoadingScriptCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1019 // Has mac & windows implementation
1020 // May be able to be made platform independant by using shared WorkQueue
1021 if (argumentCount < 1)
1022 return JSValueMakeUndefined(context);
1024 JSRetainPtr<JSStringRef> script(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1025 ASSERT(!*exception);
1027 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1028 controller->queueLoadingScript(script.get());
1030 return JSValueMakeUndefined(context);
1033 static JSValueRef queueNonLoadingScriptCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1035 // Has mac & windows implementation
1036 // May be able to be made platform independant by using shared WorkQueue
1037 if (argumentCount < 1)
1038 return JSValueMakeUndefined(context);
1040 JSRetainPtr<JSStringRef> script(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1041 ASSERT(!*exception);
1043 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1044 controller->queueNonLoadingScript(script.get());
1046 return JSValueMakeUndefined(context);
1049 static JSValueRef setAcceptsEditingCallback(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 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1056 controller->setAcceptsEditing(JSValueToBoolean(context, arguments[0]));
1058 return JSValueMakeUndefined(context);
1061 static JSValueRef setAlwaysAcceptCookiesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1063 // Has mac & windows implementation
1064 if (argumentCount < 1)
1065 return JSValueMakeUndefined(context);
1067 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1068 controller->setAlwaysAcceptCookies(JSValueToBoolean(context, arguments[0]));
1070 return JSValueMakeUndefined(context);
1073 static JSValueRef setAppCacheMaximumSizeCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1075 // Has mac implementation
1076 if (argumentCount < 1)
1077 return JSValueMakeUndefined(context);
1079 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1081 double size = JSValueToNumber(context, arguments[0], NULL);
1083 controller->setAppCacheMaximumSize(static_cast<unsigned long long>(size));
1085 return JSValueMakeUndefined(context);
1088 static JSValueRef setApplicationCacheOriginQuotaCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1090 // Has mac implementation
1091 if (argumentCount < 1)
1092 return JSValueMakeUndefined(context);
1094 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1096 double size = JSValueToNumber(context, arguments[0], NULL);
1098 controller->setApplicationCacheOriginQuota(static_cast<unsigned long long>(size));
1100 return JSValueMakeUndefined(context);
1103 static JSValueRef setAuthenticationPasswordCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1105 // Has mac & windows implementation
1106 if (argumentCount < 1)
1107 return JSValueMakeUndefined(context);
1109 JSRetainPtr<JSStringRef> password(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1110 ASSERT(!*exception);
1112 size_t maxLength = JSStringGetMaximumUTF8CStringSize(password.get());
1113 char* passwordBuffer = new char[maxLength + 1];
1114 JSStringGetUTF8CString(password.get(), passwordBuffer, maxLength + 1);
1116 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1117 controller->setAuthenticationPassword(passwordBuffer);
1118 delete[] passwordBuffer;
1120 return JSValueMakeUndefined(context);
1123 static JSValueRef setAuthenticationUsernameCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1125 // Has mac & windows implementation
1126 if (argumentCount < 1)
1127 return JSValueMakeUndefined(context);
1129 JSRetainPtr<JSStringRef> username(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1130 ASSERT(!*exception);
1132 size_t maxLength = JSStringGetMaximumUTF8CStringSize(username.get());
1133 char* usernameBuffer = new char[maxLength + 1];
1134 JSStringGetUTF8CString(username.get(), usernameBuffer, maxLength + 1);
1136 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1137 controller->setAuthenticationUsername(usernameBuffer);
1138 delete[] usernameBuffer;
1140 return JSValueMakeUndefined(context);
1143 static JSValueRef setAuthorAndUserStylesEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1145 // Has mac & windows implementation
1146 if (argumentCount < 1)
1147 return JSValueMakeUndefined(context);
1149 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1150 controller->setAuthorAndUserStylesEnabled(JSValueToBoolean(context, arguments[0]));
1152 return JSValueMakeUndefined(context);
1155 static JSValueRef setAutofilledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1157 if (argumentCount != 2 || !arguments[0])
1158 return JSValueMakeUndefined(context);
1160 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1161 controller->setAutofilled(context, arguments[0], JSValueToBoolean(context, arguments[1]));
1163 return JSValueMakeUndefined(context);
1166 static JSValueRef setCacheModelCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1168 // Has Mac implementation.
1169 if (argumentCount < 1)
1170 return JSValueMakeUndefined(context);
1172 int cacheModel = JSValueToNumber(context, arguments[0], exception);
1173 ASSERT(!*exception);
1175 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1176 controller->setCacheModel(cacheModel);
1178 return JSValueMakeUndefined(context);
1181 static JSValueRef setCustomPolicyDelegateCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1183 // Has mac implementation
1184 if (argumentCount < 1)
1185 return JSValueMakeUndefined(context);
1187 bool permissive = false;
1188 if (argumentCount >= 2)
1189 permissive = JSValueToBoolean(context, arguments[1]);
1191 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1192 controller->setCustomPolicyDelegate(JSValueToBoolean(context, arguments[0]), permissive);
1194 return JSValueMakeUndefined(context);
1197 static JSValueRef setDatabaseQuotaCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1199 // Has mac implementation
1200 if (argumentCount < 1)
1201 return JSValueMakeUndefined(context);
1203 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1205 double quota = JSValueToNumber(context, arguments[0], NULL);
1207 controller->setDatabaseQuota(static_cast<unsigned long long>(quota));
1209 return JSValueMakeUndefined(context);
1212 static JSValueRef setDeferMainResourceDataLoadCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1214 // Has Mac and Windows implementation
1215 if (argumentCount < 1)
1216 return JSValueMakeUndefined(context);
1218 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1219 controller->setDeferMainResourceDataLoad(JSValueToBoolean(context, arguments[0]));
1221 return JSValueMakeUndefined(context);
1224 static JSValueRef setDefersLoadingCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1226 if (argumentCount < 1)
1227 return JSValueMakeUndefined(context);
1229 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1230 controller->setDefersLoading(JSValueToBoolean(context, arguments[0]));
1232 return JSValueMakeUndefined(context);
1235 static JSValueRef setUseDeferredFrameLoadingCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1237 if (argumentCount < 1)
1238 return JSValueMakeUndefined(context);
1240 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1241 controller->setUseDeferredFrameLoading(JSValueToBoolean(context, arguments[0]));
1243 return JSValueMakeUndefined(context);
1246 static JSValueRef setDomainRelaxationForbiddenForURLSchemeCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1248 // Has Mac and Windows implementation
1249 if (argumentCount < 2)
1250 return JSValueMakeUndefined(context);
1252 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1254 bool forbidden = JSValueToBoolean(context, arguments[0]);
1255 JSRetainPtr<JSStringRef> scheme(Adopt, JSValueToStringCopy(context, arguments[1], 0));
1256 controller->setDomainRelaxationForbiddenForURLScheme(forbidden, scheme.get());
1258 return JSValueMakeUndefined(context);
1261 static JSValueRef setMockDeviceOrientationCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1263 if (argumentCount < 6)
1264 return JSValueMakeUndefined(context);
1266 bool canProvideAlpha = JSValueToBoolean(context, arguments[0]);
1267 double alpha = JSValueToNumber(context, arguments[1], exception);
1268 ASSERT(!*exception);
1269 bool canProvideBeta = JSValueToBoolean(context, arguments[2]);
1270 double beta = JSValueToNumber(context, arguments[3], exception);
1271 ASSERT(!*exception);
1272 bool canProvideGamma = JSValueToBoolean(context, arguments[4]);
1273 double gamma = JSValueToNumber(context, arguments[5], exception);
1274 ASSERT(!*exception);
1276 LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1277 controller->setMockDeviceOrientation(canProvideAlpha, alpha, canProvideBeta, beta, canProvideGamma, gamma);
1279 return JSValueMakeUndefined(context);
1282 static JSValueRef setMockGeolocationPositionCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1284 if (argumentCount < 3)
1285 return JSValueMakeUndefined(context);
1287 LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1288 controller->setMockGeolocationPosition(JSValueToNumber(context, arguments[0], NULL), // latitude
1289 JSValueToNumber(context, arguments[1], NULL), // longitude
1290 JSValueToNumber(context, arguments[2], NULL)); // accuracy
1292 return JSValueMakeUndefined(context);
1295 static JSValueRef setMockGeolocationErrorCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1297 if (argumentCount < 2)
1298 return JSValueMakeUndefined(context);
1300 int code = JSValueToNumber(context, arguments[0], NULL);
1301 JSRetainPtr<JSStringRef> message(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1302 ASSERT(!*exception);
1304 LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1305 controller->setMockGeolocationError(code, message.get());
1307 return JSValueMakeUndefined(context);
1310 static JSValueRef addMockSpeechInputResultCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1312 if (argumentCount < 3)
1313 return JSValueMakeUndefined(context);
1315 JSRetainPtr<JSStringRef> result(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1316 ASSERT(!*exception);
1318 double confidence = JSValueToNumber(context, arguments[1], exception);
1320 JSRetainPtr<JSStringRef> language(Adopt, JSValueToStringCopy(context, arguments[2], exception));
1321 ASSERT(!*exception);
1323 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1324 controller->addMockSpeechInputResult(result.get(), confidence, language.get());
1326 return JSValueMakeUndefined(context);
1329 static JSValueRef setMockSpeechInputDumpRectCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1331 if (argumentCount < 1)
1332 return JSValueMakeUndefined(context);
1334 bool dumpRect = JSValueToBoolean(context, arguments[0]);
1336 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1337 controller->setMockSpeechInputDumpRect(dumpRect);
1339 return JSValueMakeUndefined(context);
1342 static JSValueRef setNewWindowsCopyBackForwardListCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1344 // Has mac implementation
1345 if (argumentCount < 1)
1346 return JSValueMakeUndefined(context);
1348 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1349 controller->setNewWindowsCopyBackForwardList(JSValueToBoolean(context, arguments[0]));
1351 return JSValueMakeUndefined(context);
1354 static JSValueRef setGeolocationPermissionCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1356 // Has mac implementation
1357 if (argumentCount < 1)
1358 return JSValueMakeUndefined(context);
1360 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1361 controller->setGeolocationPermission(JSValueToBoolean(context, arguments[0]));
1363 return JSValueMakeUndefined(context);
1366 static JSValueRef setHandlesAuthenticationChallengesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1368 // Has mac & windows implementation
1369 if (argumentCount < 1)
1370 return JSValueMakeUndefined(context);
1372 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1373 controller->setHandlesAuthenticationChallenges(JSValueToBoolean(context, arguments[0]));
1375 return JSValueMakeUndefined(context);
1378 static JSValueRef setPOSIXLocaleCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1380 if (argumentCount < 1)
1381 return JSValueMakeUndefined(context);
1383 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1384 JSRetainPtr<JSStringRef> locale(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1385 ASSERT(!*exception);
1386 controller->setPOSIXLocale(locale.get());
1388 return JSValueMakeUndefined(context);
1391 static JSValueRef setIconDatabaseEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1393 // Has mac & windows implementation
1394 if (argumentCount < 1)
1395 return JSValueMakeUndefined(context);
1397 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1398 controller->setIconDatabaseEnabled(JSValueToBoolean(context, arguments[0]));
1400 return JSValueMakeUndefined(context);
1403 static JSValueRef setMainFrameIsFirstResponderCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1405 // Has mac implementation
1406 if (argumentCount < 1)
1407 return JSValueMakeUndefined(context);
1409 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1410 controller->setMainFrameIsFirstResponder(JSValueToBoolean(context, arguments[0]));
1412 return JSValueMakeUndefined(context);
1415 static JSValueRef setPersistentUserStyleSheetLocationCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1417 // Has mac implementation
1418 if (argumentCount < 1)
1419 return JSValueMakeUndefined(context);
1421 JSRetainPtr<JSStringRef> path(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1422 ASSERT(!*exception);
1424 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1425 controller->setPersistentUserStyleSheetLocation(path.get());
1427 return JSValueMakeUndefined(context);
1430 static JSValueRef setPrivateBrowsingEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1432 // Has mac & windows implementation
1433 if (argumentCount < 1)
1434 return JSValueMakeUndefined(context);
1436 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1437 controller->setPrivateBrowsingEnabled(JSValueToBoolean(context, arguments[0]));
1439 return JSValueMakeUndefined(context);
1442 static JSValueRef setJavaScriptCanAccessClipboardCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1444 // Has mac & windows implementation
1445 if (argumentCount < 1)
1446 return JSValueMakeUndefined(context);
1448 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1449 controller->setJavaScriptCanAccessClipboard(JSValueToBoolean(context, arguments[0]));
1451 return JSValueMakeUndefined(context);
1454 static JSValueRef setXSSAuditorEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1456 // Has mac & windows implementation
1457 if (argumentCount < 1)
1458 return JSValueMakeUndefined(context);
1460 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1461 controller->setXSSAuditorEnabled(JSValueToBoolean(context, arguments[0]));
1463 return JSValueMakeUndefined(context);
1466 static JSValueRef setSpatialNavigationEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1468 // Has mac implementation.
1469 if (argumentCount < 1)
1470 return JSValueMakeUndefined(context);
1472 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1473 controller->setSpatialNavigationEnabled(JSValueToBoolean(context, arguments[0]));
1475 return JSValueMakeUndefined(context);
1478 static JSValueRef setPrintingCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1480 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1481 controller->setIsPrinting(true);
1482 return JSValueMakeUndefined(context);
1486 static JSValueRef setFrameFlatteningEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1488 // Has mac & windows implementation
1489 if (argumentCount < 1)
1490 return JSValueMakeUndefined(context);
1492 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1493 controller->setFrameFlatteningEnabled(JSValueToBoolean(context, arguments[0]));
1495 return JSValueMakeUndefined(context);
1498 static JSValueRef setAllowUniversalAccessFromFileURLsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1500 // Has mac & windows implementation
1501 if (argumentCount < 1)
1502 return JSValueMakeUndefined(context);
1504 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1505 controller->setAllowUniversalAccessFromFileURLs(JSValueToBoolean(context, arguments[0]));
1507 return JSValueMakeUndefined(context);
1510 static JSValueRef setAllowFileAccessFromFileURLsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1512 // Has mac & windows implementation
1513 if (argumentCount < 1)
1514 return JSValueMakeUndefined(context);
1516 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1517 controller->setAllowFileAccessFromFileURLs(JSValueToBoolean(context, arguments[0]));
1519 return JSValueMakeUndefined(context);
1522 static JSValueRef setTabKeyCyclesThroughElementsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1524 // Has mac & windows implementation
1525 if (argumentCount < 1)
1526 return JSValueMakeUndefined(context);
1528 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1529 controller->setTabKeyCyclesThroughElements(JSValueToBoolean(context, arguments[0]));
1531 return JSValueMakeUndefined(context);
1534 static JSValueRef setUseDashboardCompatibilityModeCallback(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 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1541 controller->setUseDashboardCompatibilityMode(JSValueToBoolean(context, arguments[0]));
1543 return JSValueMakeUndefined(context);
1546 static JSValueRef setUserStyleSheetEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1548 // Has mac implementation
1549 if (argumentCount < 1)
1550 return JSValueMakeUndefined(context);
1552 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1553 controller->setUserStyleSheetEnabled(JSValueToBoolean(context, arguments[0]));
1555 return JSValueMakeUndefined(context);
1558 static JSValueRef setUserStyleSheetLocationCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1560 // Has mac implementation
1561 if (argumentCount < 1)
1562 return JSValueMakeUndefined(context);
1564 JSRetainPtr<JSStringRef> path(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1565 ASSERT(!*exception);
1567 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1568 controller->setUserStyleSheetLocation(path.get());
1570 return JSValueMakeUndefined(context);
1573 static JSValueRef setValueForUserCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1575 // Has mac implementation
1576 if (argumentCount != 2)
1577 return JSValueMakeUndefined(context);
1579 JSRetainPtr<JSStringRef> value(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1580 ASSERT(!*exception);
1582 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1583 controller->setValueForUser(context, arguments[0], value.get());
1585 return JSValueMakeUndefined(context);
1588 static JSValueRef setViewModeMediaFeatureCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1590 // Has mac implementation
1591 if (argumentCount < 1)
1592 return JSValueMakeUndefined(context);
1594 JSRetainPtr<JSStringRef> mode(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1595 ASSERT(!*exception);
1597 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1598 controller->setViewModeMediaFeature(mode.get());
1600 return JSValueMakeUndefined(context);
1603 static JSValueRef setWillSendRequestClearHeaderCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1605 // Has mac & windows implementation
1606 if (argumentCount < 1)
1607 return JSValueMakeUndefined(context);
1609 JSRetainPtr<JSStringRef> header(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1610 ASSERT(!*exception);
1612 size_t maxLength = JSStringGetMaximumUTF8CStringSize(header.get());
1613 OwnArrayPtr<char> headerBuffer = adoptArrayPtr(new char[maxLength + 1]);
1614 JSStringGetUTF8CString(header.get(), headerBuffer.get(), maxLength + 1);
1616 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1617 controller->setWillSendRequestClearHeader(headerBuffer.get());
1619 return JSValueMakeUndefined(context);
1622 static JSValueRef setWillSendRequestReturnsNullCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1624 // Has cross-platform implementation
1625 if (argumentCount < 1)
1626 return JSValueMakeUndefined(context);
1628 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1629 controller->setWillSendRequestReturnsNull(JSValueToBoolean(context, arguments[0]));
1631 return JSValueMakeUndefined(context);
1634 static JSValueRef setWillSendRequestReturnsNullOnRedirectCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1636 // Has cross-platform implementation
1637 if (argumentCount < 1)
1638 return JSValueMakeUndefined(context);
1640 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1641 controller->setWillSendRequestReturnsNullOnRedirect(JSValueToBoolean(context, arguments[0]));
1643 return JSValueMakeUndefined(context);
1646 static JSValueRef setWindowIsKeyCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1648 // Has mac implementation
1649 if (argumentCount < 1)
1650 return JSValueMakeUndefined(context);
1652 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1653 controller->setWindowIsKey(JSValueToBoolean(context, arguments[0]));
1655 return JSValueMakeUndefined(context);
1658 static JSValueRef waitUntilDoneCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1660 // Has mac & windows implementation
1661 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1662 controller->setWaitToDump(true);
1664 return JSValueMakeUndefined(context);
1667 static JSValueRef windowCountCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1669 // Has mac implementation
1670 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1671 int windows = controller->windowCount();
1672 return JSValueMakeNumber(context, windows);
1675 static JSValueRef setPopupBlockingEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1677 // Has mac & windows implementation
1678 if (argumentCount < 1)
1679 return JSValueMakeUndefined(context);
1681 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1682 controller->setPopupBlockingEnabled(JSValueToBoolean(context, arguments[0]));
1684 return JSValueMakeUndefined(context);
1687 static JSValueRef setPluginsEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1689 // Has mac & windows implementation
1690 if (argumentCount < 1)
1691 return JSValueMakeUndefined(context);
1693 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1694 controller->setPluginsEnabled(JSValueToBoolean(context, arguments[0]));
1696 return JSValueMakeUndefined(context);
1699 static JSValueRef setPageVisibilityCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1701 // Has mac & windows implementation
1702 if (argumentCount < 1)
1703 return JSValueMakeUndefined(context);
1705 JSRetainPtr<JSStringRef> visibility(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1706 ASSERT(!*exception);
1708 size_t maxLength = JSStringGetMaximumUTF8CStringSize(visibility.get());
1709 char* visibilityBuffer = new char[maxLength + 1];
1710 JSStringGetUTF8CString(visibility.get(), visibilityBuffer, maxLength + 1);
1712 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1713 controller->setPageVisibility(visibilityBuffer);
1714 delete[] visibilityBuffer;
1716 return JSValueMakeUndefined(context);
1719 static JSValueRef resetPageVisibilityCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1721 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1722 controller->resetPageVisibility();
1723 return JSValueMakeUndefined(context);
1726 static JSValueRef setSmartInsertDeleteEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1728 if (argumentCount < 1)
1729 return JSValueMakeUndefined(context);
1731 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1732 controller->setSmartInsertDeleteEnabled(JSValueToBoolean(context, arguments[0]));
1733 return JSValueMakeUndefined(context);
1736 static JSValueRef setAutomaticLinkDetectionEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1738 if (argumentCount < 1)
1739 return JSValueMakeUndefined(context);
1741 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1742 controller->setAutomaticLinkDetectionEnabled(JSValueToBoolean(context, arguments[0]));
1743 return JSValueMakeUndefined(context);
1746 static JSValueRef setSelectTrailingWhitespaceEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1748 if (argumentCount < 1)
1749 return JSValueMakeUndefined(context);
1751 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1752 controller->setSelectTrailingWhitespaceEnabled(JSValueToBoolean(context, arguments[0]));
1753 return JSValueMakeUndefined(context);
1756 static JSValueRef setStopProvisionalFrameLoadsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1758 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1759 controller->setStopProvisionalFrameLoads(true);
1760 return JSValueMakeUndefined(context);
1763 static JSValueRef setAsynchronousSpellCheckingEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1765 if (argumentCount < 1)
1766 return JSValueMakeUndefined(context);
1768 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1769 controller->setAsynchronousSpellCheckingEnabled(JSValueToBoolean(context, arguments[0]));
1770 return JSValueMakeUndefined(context);
1773 static JSValueRef showWebInspectorCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1775 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1776 controller->showWebInspector();
1777 return JSValueMakeUndefined(context);
1780 static JSValueRef closeWebInspectorCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1782 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1783 controller->closeWebInspector();
1784 return JSValueMakeUndefined(context);
1787 static JSValueRef evaluateInWebInspectorCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1789 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1790 double callId = JSValueToNumber(context, arguments[0], exception);
1791 ASSERT(!*exception);
1792 JSRetainPtr<JSStringRef> script(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1793 ASSERT(!*exception);
1795 controller->evaluateInWebInspector(static_cast<long>(callId), script.get());
1796 return JSValueMakeUndefined(context);
1799 static JSValueRef evaluateScriptInIsolatedWorldCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1801 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1802 double worldID = JSValueToNumber(context, arguments[0], exception);
1803 ASSERT(!*exception);
1804 JSRetainPtr<JSStringRef> script(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1805 ASSERT(!*exception);
1807 controller->evaluateScriptInIsolatedWorld(static_cast<unsigned>(worldID), JSContextGetGlobalObject(context), script.get());
1808 return JSValueMakeUndefined(context);
1811 static JSValueRef evaluateScriptInIsolatedWorldAndReturnValueCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1813 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1814 double worldID = JSValueToNumber(context, arguments[0], exception);
1815 ASSERT(!*exception);
1816 JSRetainPtr<JSStringRef> script(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1817 ASSERT(!*exception);
1819 controller->evaluateScriptInIsolatedWorldAndReturnValue(static_cast<unsigned>(worldID), JSContextGetGlobalObject(context), script.get());
1820 return JSValueMakeUndefined(context);
1823 static JSValueRef elementDoesAutoCompleteForElementWithIdCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1825 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1826 JSRetainPtr<JSStringRef> elementId(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1827 ASSERT(!*exception);
1829 bool autoCompletes = controller->elementDoesAutoCompleteForElementWithId(elementId.get());
1831 return JSValueMakeBoolean(context, autoCompletes);
1834 static JSValueRef pauseAnimationAtTimeOnElementWithIdCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1836 if (argumentCount != 3)
1837 return JSValueMakeUndefined(context);
1839 JSRetainPtr<JSStringRef> animationName(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1840 ASSERT(!*exception);
1841 double time = JSValueToNumber(context, arguments[1], exception);
1842 ASSERT(!*exception);
1843 JSRetainPtr<JSStringRef> elementId(Adopt, JSValueToStringCopy(context, arguments[2], exception));
1844 ASSERT(!*exception);
1846 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1847 return JSValueMakeBoolean(context, controller->pauseAnimationAtTimeOnElementWithId(animationName.get(), time, elementId.get()));
1850 static JSValueRef pauseTransitionAtTimeOnElementWithIdCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1852 if (argumentCount != 3)
1853 return JSValueMakeUndefined(context);
1855 JSRetainPtr<JSStringRef> propertyName(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1856 ASSERT(!*exception);
1857 double time = JSValueToNumber(context, arguments[1], exception);
1858 ASSERT(!*exception);
1859 JSRetainPtr<JSStringRef> elementId(Adopt, JSValueToStringCopy(context, arguments[2], exception));
1860 ASSERT(!*exception);
1862 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1863 return JSValueMakeBoolean(context, controller->pauseTransitionAtTimeOnElementWithId(propertyName.get(), time, elementId.get()));
1866 static JSValueRef numberOfActiveAnimationsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1868 if (argumentCount != 0)
1869 return JSValueMakeUndefined(context);
1871 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1872 return JSValueMakeNumber(context, controller->numberOfActiveAnimations());
1875 static JSValueRef waitForPolicyDelegateCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t, const JSValueRef[], JSValueRef*)
1877 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1878 controller->waitForPolicyDelegate();
1879 return JSValueMakeUndefined(context);
1882 static JSValueRef addOriginAccessWhitelistEntryCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1884 if (argumentCount != 4)
1885 return JSValueMakeUndefined(context);
1887 JSRetainPtr<JSStringRef> sourceOrigin(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1888 ASSERT(!*exception);
1889 JSRetainPtr<JSStringRef> destinationProtocol(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1890 ASSERT(!*exception);
1891 JSRetainPtr<JSStringRef> destinationHost(Adopt, JSValueToStringCopy(context, arguments[2], exception));
1892 ASSERT(!*exception);
1893 bool allowDestinationSubdomains = JSValueToBoolean(context, arguments[3]);
1895 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1896 controller->addOriginAccessWhitelistEntry(sourceOrigin.get(), destinationProtocol.get(), destinationHost.get(), allowDestinationSubdomains);
1897 return JSValueMakeUndefined(context);
1900 static JSValueRef removeOriginAccessWhitelistEntryCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1902 if (argumentCount != 4)
1903 return JSValueMakeUndefined(context);
1905 JSRetainPtr<JSStringRef> sourceOrigin(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1906 ASSERT(!*exception);
1907 JSRetainPtr<JSStringRef> destinationProtocol(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1908 ASSERT(!*exception);
1909 JSRetainPtr<JSStringRef> destinationHost(Adopt, JSValueToStringCopy(context, arguments[2], exception));
1910 ASSERT(!*exception);
1911 bool allowDestinationSubdomains = JSValueToBoolean(context, arguments[3]);
1913 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1914 controller->removeOriginAccessWhitelistEntry(sourceOrigin.get(), destinationProtocol.get(), destinationHost.get(), allowDestinationSubdomains);
1915 return JSValueMakeUndefined(context);
1918 static JSValueRef setScrollbarPolicyCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1920 if (argumentCount != 2)
1921 return JSValueMakeUndefined(context);
1923 JSRetainPtr<JSStringRef> orientation(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1924 ASSERT(!*exception);
1925 JSRetainPtr<JSStringRef> policy(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1926 ASSERT(!*exception);
1928 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1929 controller->setScrollbarPolicy(orientation.get(), policy.get());
1930 return JSValueMakeUndefined(context);
1933 static JSValueRef addUserScriptCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1935 if (argumentCount != 3)
1936 return JSValueMakeUndefined(context);
1938 JSRetainPtr<JSStringRef> source(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1939 ASSERT(!*exception);
1940 bool runAtStart = JSValueToBoolean(context, arguments[1]);
1941 bool allFrames = JSValueToBoolean(context, arguments[2]);
1943 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1944 controller->addUserScript(source.get(), runAtStart, allFrames);
1945 return JSValueMakeUndefined(context);
1948 static JSValueRef addUserStyleSheetCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1950 if (argumentCount != 2)
1951 return JSValueMakeUndefined(context);
1953 JSRetainPtr<JSStringRef> source(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1954 ASSERT(!*exception);
1955 bool allFrames = JSValueToBoolean(context, arguments[1]);
1957 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1958 controller->addUserStyleSheet(source.get(), allFrames);
1959 return JSValueMakeUndefined(context);
1962 static JSValueRef setShouldPaintBrokenImageCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1964 // Has Mac implementation
1965 if (argumentCount < 1)
1966 return JSValueMakeUndefined(context);
1968 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1969 controller->setShouldPaintBrokenImage(JSValueToBoolean(context, arguments[0]));
1971 return JSValueMakeUndefined(context);
1974 static JSValueRef apiTestNewWindowDataLoadBaseURLCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1976 if (argumentCount != 2)
1977 return JSValueMakeUndefined(context);
1979 JSRetainPtr<JSStringRef> utf8Data(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1980 ASSERT(!*exception);
1982 JSRetainPtr<JSStringRef> baseURL(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1983 ASSERT(!*exception);
1985 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1986 controller->apiTestNewWindowDataLoadBaseURL(utf8Data.get(), baseURL.get());
1987 return JSValueMakeUndefined(context);
1990 static JSValueRef apiTestGoToCurrentBackForwardItemCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1992 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1993 controller->apiTestGoToCurrentBackForwardItem();
1994 return JSValueMakeUndefined(context);
1997 static JSValueRef setWebViewEditableCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1999 // Has Mac implementation
2000 if (argumentCount < 1)
2001 return JSValueMakeUndefined(context);
2003 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2004 controller->setWebViewEditable(JSValueToBoolean(context, arguments[0]));
2006 return JSValueMakeUndefined(context);
2009 static JSValueRef sendWebIntentResponseCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
2011 JSRetainPtr<JSStringRef> response;
2012 if (argumentCount == 1) {
2013 response.adopt(JSValueToStringCopy(context, arguments[0], exception));
2014 ASSERT(!*exception);
2016 response.adopt(JSStringCreateWithUTF8CString(0));
2018 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2019 controller->sendWebIntentResponse(response.get());
2021 return JSValueMakeUndefined(context);
2024 static JSValueRef abortModalCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
2026 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2027 controller->abortModal();
2028 return JSValueMakeUndefined(context);
2031 static JSValueRef markerTextForListItemCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
2033 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2034 if (argumentCount < 1)
2035 return JSValueMakeUndefined(context);
2036 return JSValueMakeString(context, controller->markerTextForListItem(context, arguments[0]).get());
2039 static JSValueRef authenticateSessionCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
2041 // authenticateSession(url, username, password)
2042 if (argumentCount != 3)
2043 return JSValueMakeUndefined(context);
2045 JSRetainPtr<JSStringRef> url(Adopt, JSValueToStringCopy(context, arguments[0], exception));
2046 ASSERT(!*exception);
2047 JSRetainPtr<JSStringRef> username(Adopt, JSValueToStringCopy(context, arguments[1], exception));
2048 ASSERT(!*exception);
2049 JSRetainPtr<JSStringRef> password(Adopt, JSValueToStringCopy(context, arguments[2], exception));
2050 ASSERT(!*exception);
2052 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2053 controller->authenticateSession(url.get(), username.get(), password.get());
2054 return JSValueMakeUndefined(context);
2057 static JSValueRef setSerializeHTTPLoadsCallback(JSContextRef context, JSObjectRef, JSObjectRef, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
2059 bool serialize = true;
2060 if (argumentCount == 1)
2061 serialize = JSValueToBoolean(context, arguments[0]);
2063 LayoutTestController::setSerializeHTTPLoads(serialize);
2064 return JSValueMakeUndefined(context);
2067 static JSValueRef setShouldStayOnPageAfterHandlingBeforeUnloadCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
2069 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2071 if (argumentCount == 1)
2072 controller->setShouldStayOnPageAfterHandlingBeforeUnload(JSValueToBoolean(context, arguments[0]));
2074 return JSValueMakeUndefined(context);
2077 static JSValueRef addChromeInputFieldCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
2079 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2080 controller->addChromeInputField();
2081 // the first argument is a callback that is called once the input field has been added
2082 if (argumentCount == 1)
2083 JSObjectCallAsFunction(context, JSValueToObject(context, arguments[0], 0), thisObject, 0, 0, 0);
2084 return JSValueMakeUndefined(context);
2087 static JSValueRef removeChromeInputFieldCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
2089 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2090 controller->removeChromeInputField();
2091 // the first argument is a callback that is called once the input field has been added
2092 if (argumentCount == 1)
2093 JSObjectCallAsFunction(context, JSValueToObject(context, arguments[0], 0), thisObject, 0, 0, 0);
2094 return JSValueMakeUndefined(context);
2097 static JSValueRef focusWebViewCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
2099 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2100 controller->focusWebView();
2101 // the first argument is a callback that is called once the input field has been added
2102 if (argumentCount == 1)
2103 JSObjectCallAsFunction(context, JSValueToObject(context, arguments[0], 0), thisObject, 0, 0, 0);
2104 return JSValueMakeUndefined(context);
2107 static JSValueRef setBackingScaleFactorCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
2109 if (argumentCount != 2)
2110 return JSValueMakeUndefined(context);
2112 double backingScaleFactor = JSValueToNumber(context, arguments[0], exception);
2113 ASSERT(!*exception);
2115 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2116 controller->setBackingScaleFactor(backingScaleFactor);
2118 // The second argument is a callback that is called once the backing scale factor has been set.
2119 JSObjectCallAsFunction(context, JSValueToObject(context, arguments[1], 0), thisObject, 0, 0, 0);
2120 return JSValueMakeUndefined(context);
2123 static JSValueRef preciseTimeCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
2125 return JSValueMakeNumber(context, WTF::currentTime());
2130 static JSValueRef getGlobalFlagCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
2132 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2133 return JSValueMakeBoolean(context, controller->globalFlag());
2136 static JSValueRef getWebHistoryItemCountCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
2138 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2139 return JSValueMakeNumber(context, controller->webHistoryItemCount());
2142 static JSValueRef getWorkerThreadCountCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
2144 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2145 return JSValueMakeNumber(context, controller->workerThreadCount());
2148 #if PLATFORM(MAC) || PLATFORM(GTK) || PLATFORM(WIN)
2149 static JSValueRef getPlatformNameCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
2151 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2152 JSRetainPtr<JSStringRef> platformName(controller->platformName());
2153 if (!platformName.get())
2154 return JSValueMakeUndefined(context);
2155 return JSValueMakeString(context, platformName.get());
2159 static bool setGlobalFlagCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef value, JSValueRef* exception)
2161 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2162 controller->setGlobalFlag(JSValueToBoolean(context, value));
2166 static JSValueRef ignoreDesktopNotificationPermissionRequestsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
2168 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2169 controller->ignoreDesktopNotificationPermissionRequests();
2170 return JSValueMakeUndefined(context);
2173 static JSValueRef simulateDesktopNotificationClickCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
2175 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2176 JSRetainPtr<JSStringRef> title(Adopt, JSValueToStringCopy(context, arguments[0], exception));
2177 controller->simulateDesktopNotificationClick(title.get());
2178 return JSValueMakeUndefined(context);
2181 static JSValueRef setMinimumTimerIntervalCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
2183 if (argumentCount < 1)
2184 return JSValueMakeUndefined(context);
2186 double minimum = JSValueToNumber(context, arguments[0], exception);
2187 ASSERT(!*exception);
2189 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2190 controller->setMinimumTimerInterval(minimum);
2192 return JSValueMakeUndefined(context);
2195 static JSValueRef setTextDirectionCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
2197 if (argumentCount == 1) {
2198 JSRetainPtr<JSStringRef> direction(Adopt, JSValueToStringCopy(context, arguments[0], exception));
2199 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2200 controller->setTextDirection(direction.get());
2203 return JSValueMakeUndefined(context);
2207 static JSValueRef setHasCustomFullScreenBehaviorCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
2209 if (argumentCount == 1) {
2210 bool hasCustomBehavior = JSValueToBoolean(context, arguments[0]);
2211 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2212 controller->setHasCustomFullScreenBehavior(hasCustomBehavior);
2215 return JSValueMakeUndefined(context);
2218 static void layoutTestControllerObjectFinalize(JSObjectRef object)
2220 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(object));
2221 controller->deref();
2226 void LayoutTestController::makeWindowObject(JSContextRef context, JSObjectRef windowObject, JSValueRef* exception)
2228 JSRetainPtr<JSStringRef> layoutTestContollerStr(Adopt, JSStringCreateWithUTF8CString("layoutTestController"));
2231 JSClassRef classRef = getJSClass();
2232 JSValueRef layoutTestContollerObject = JSObjectMake(context, classRef, this);
2233 JSClassRelease(classRef);
2235 JSObjectSetProperty(context, windowObject, layoutTestContollerStr.get(), layoutTestContollerObject, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete, exception);
2238 JSClassRef LayoutTestController::getJSClass()
2240 static JSStaticValue* staticValues = LayoutTestController::staticValues();
2241 static JSStaticFunction* staticFunctions = LayoutTestController::staticFunctions();
2242 static JSClassDefinition classDefinition = {
2243 0, kJSClassAttributeNone, "LayoutTestController", 0, staticValues, staticFunctions,
2244 0, layoutTestControllerObjectFinalize, 0, 0, 0, 0, 0, 0, 0, 0, 0
2247 return JSClassCreate(&classDefinition);
2250 JSStaticValue* LayoutTestController::staticValues()
2252 static JSStaticValue staticValues[] = {
2253 { "globalFlag", getGlobalFlagCallback, setGlobalFlagCallback, kJSPropertyAttributeNone },
2254 { "webHistoryItemCount", getWebHistoryItemCountCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2255 { "workerThreadCount", getWorkerThreadCountCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2256 #if PLATFORM(MAC) || PLATFORM(GTK) || PLATFORM(WIN)
2257 { "platformName", getPlatformNameCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2261 return staticValues;
2264 JSStaticFunction* LayoutTestController::staticFunctions()
2266 static JSStaticFunction staticFunctions[] = {
2267 { "abortModal", abortModalCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2268 { "addDisallowedURL", addDisallowedURLCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2269 { "addURLToRedirect", addURLToRedirectCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2270 { "addUserScript", addUserScriptCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2271 { "addUserStyleSheet", addUserStyleSheetCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2272 { "apiTestNewWindowDataLoadBaseURL", apiTestNewWindowDataLoadBaseURLCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2273 { "apiTestGoToCurrentBackForwardItem", apiTestGoToCurrentBackForwardItemCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2274 { "applicationCacheDiskUsageForOrigin", applicationCacheDiskUsageForOriginCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2275 { "callShouldCloseOnWebView", callShouldCloseOnWebViewCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2276 { "clearAllApplicationCaches", clearAllApplicationCachesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2277 { "clearAllDatabases", clearAllDatabasesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2278 { "clearApplicationCacheForOrigin", clearApplicationCacheForOriginCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2279 { "clearBackForwardList", clearBackForwardListCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2280 { "clearPersistentUserStyleSheet", clearPersistentUserStyleSheetCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2281 { "closeWebInspector", closeWebInspectorCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2282 { "computedStyleIncludingVisitedInfo", computedStyleIncludingVisitedInfoCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2283 { "decodeHostName", decodeHostNameCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2284 { "disableImageLoading", disableImageLoadingCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2285 { "disallowIncreaseForApplicationCacheQuota", disallowIncreaseForApplicationCacheQuotaCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2286 { "dispatchPendingLoadRequests", dispatchPendingLoadRequestsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2287 { "display", displayCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2288 { "displayInvalidatedRegion", displayInvalidatedRegionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2289 { "dumpApplicationCacheDelegateCallbacks", dumpApplicationCacheDelegateCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2290 { "dumpAsText", dumpAsTextCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2291 { "dumpBackForwardList", dumpBackForwardListCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2292 { "dumpChildFrameScrollPositions", dumpChildFrameScrollPositionsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2293 { "dumpChildFramesAsText", dumpChildFramesAsTextCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2294 { "dumpConfigurationForViewport", dumpConfigurationForViewportCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2295 { "dumpDOMAsWebArchive", dumpDOMAsWebArchiveCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2296 { "dumpDatabaseCallbacks", dumpDatabaseCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2297 { "dumpEditingCallbacks", dumpEditingCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2298 { "dumpFrameLoadCallbacks", dumpFrameLoadCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2299 { "dumpProgressFinishedCallback", dumpProgressFinishedCallbackCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2300 { "dumpUserGestureInFrameLoadCallbacks", dumpUserGestureInFrameLoadCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2301 { "dumpResourceLoadCallbacks", dumpResourceLoadCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2302 { "dumpResourceResponseMIMETypes", dumpResourceResponseMIMETypesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2303 { "dumpSelectionRect", dumpSelectionRectCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2304 { "dumpSourceAsWebArchive", dumpSourceAsWebArchiveCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2305 { "dumpStatusCallbacks", dumpStatusCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2306 { "dumpTitleChanges", dumpTitleChangesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2307 { "dumpIconChanges", dumpIconChangesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2308 { "dumpWillCacheResponse", dumpWillCacheResponseCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2309 { "elementDoesAutoCompleteForElementWithId", elementDoesAutoCompleteForElementWithIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2310 { "encodeHostName", encodeHostNameCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2311 { "evaluateInWebInspector", evaluateInWebInspectorCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2312 { "evaluateScriptInIsolatedWorldAndReturnValue", evaluateScriptInIsolatedWorldAndReturnValueCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2313 { "evaluateScriptInIsolatedWorld", evaluateScriptInIsolatedWorldCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2314 { "execCommand", execCommandCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2315 { "findString", findStringCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2316 { "counterValueForElementById", counterValueForElementByIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2317 { "originsWithApplicationCache", originsWithApplicationCacheCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2318 { "goBack", goBackCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2319 { "grantDesktopNotificationPermission", grantDesktopNotificationPermissionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2320 { "ignoreDesktopNotificationPermissionRequests", ignoreDesktopNotificationPermissionRequestsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2321 { "isCommandEnabled", isCommandEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2322 { "keepWebHistory", keepWebHistoryCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2323 { "layerTreeAsText", layerTreeAsTextCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2324 { "numberOfPages", numberOfPagesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2325 { "numberOfPendingGeolocationPermissionRequests", numberOfPendingGeolocationPermissionRequestsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2326 { "markerTextForListItem", markerTextForListItemCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2327 { "notifyDone", notifyDoneCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2328 { "numberOfActiveAnimations", numberOfActiveAnimationsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2329 { "overridePreference", overridePreferenceCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2330 { "pageNumberForElementById", pageNumberForElementByIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2331 { "pageSizeAndMarginsInPixels", pageSizeAndMarginsInPixelsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2332 { "pageProperty", pagePropertyCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2333 { "pathToLocalResource", pathToLocalResourceCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2334 { "pauseAnimationAtTimeOnElementWithId", pauseAnimationAtTimeOnElementWithIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2335 { "pauseTransitionAtTimeOnElementWithId", pauseTransitionAtTimeOnElementWithIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2336 { "printToPDF", dumpAsPDFCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2337 { "queueBackNavigation", queueBackNavigationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2338 { "queueForwardNavigation", queueForwardNavigationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2339 { "queueLoad", queueLoadCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2340 { "queueLoadHTMLString", queueLoadHTMLStringCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2341 { "queueLoadingScript", queueLoadingScriptCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2342 { "queueNonLoadingScript", queueNonLoadingScriptCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2343 { "queueReload", queueReloadCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2344 { "removeAllVisitedLinks", removeAllVisitedLinksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2345 { "removeOriginAccessWhitelistEntry", removeOriginAccessWhitelistEntryCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2346 { "repaintSweepHorizontally", repaintSweepHorizontallyCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2347 { "resetPageVisibility", resetPageVisibilityCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2348 { "sendWebIntentResponse", sendWebIntentResponseCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2349 { "setAcceptsEditing", setAcceptsEditingCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2350 { "setAllowUniversalAccessFromFileURLs", setAllowUniversalAccessFromFileURLsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2351 { "setAllowFileAccessFromFileURLs", setAllowFileAccessFromFileURLsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2352 { "setAlwaysAcceptCookies", setAlwaysAcceptCookiesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2353 { "setAppCacheMaximumSize", setAppCacheMaximumSizeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2354 { "setApplicationCacheOriginQuota", setApplicationCacheOriginQuotaCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2355 { "setEncodedAudioData", setEncodedAudioDataCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2356 { "setAuthenticationPassword", setAuthenticationPasswordCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2357 { "setAuthenticationUsername", setAuthenticationUsernameCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2358 { "setAuthorAndUserStylesEnabled", setAuthorAndUserStylesEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2359 { "setAutofilled", setAutofilledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2360 { "setCacheModel", setCacheModelCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2361 { "setCallCloseOnWebViews", setCallCloseOnWebViewsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2362 { "setCanOpenWindows", setCanOpenWindowsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2363 { "setCloseRemainingWindowsWhenComplete", setCloseRemainingWindowsWhenCompleteCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2364 { "setCustomPolicyDelegate", setCustomPolicyDelegateCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2365 { "setDatabaseQuota", setDatabaseQuotaCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2366 { "setDeferMainResourceDataLoad", setDeferMainResourceDataLoadCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2367 { "setDefersLoading", setDefersLoadingCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2368 { "setUseDeferredFrameLoading", setUseDeferredFrameLoadingCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2369 { "setDomainRelaxationForbiddenForURLScheme", setDomainRelaxationForbiddenForURLSchemeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2370 { "setFrameFlatteningEnabled", setFrameFlatteningEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2371 { "setGeolocationPermission", setGeolocationPermissionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2372 { "setHandlesAuthenticationChallenges", setHandlesAuthenticationChallengesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2373 { "setIconDatabaseEnabled", setIconDatabaseEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2374 { "setAutomaticLinkDetectionEnabled", setAutomaticLinkDetectionEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2375 { "setMainFrameIsFirstResponder", setMainFrameIsFirstResponderCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2376 { "setMinimumTimerInterval", setMinimumTimerIntervalCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2377 { "setMockDeviceOrientation", setMockDeviceOrientationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2378 { "setMockGeolocationError", setMockGeolocationErrorCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2379 { "setMockGeolocationPosition", setMockGeolocationPositionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2380 { "addMockSpeechInputResult", addMockSpeechInputResultCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2381 { "setMockSpeechInputDumpRect", setMockSpeechInputDumpRectCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2382 { "setNewWindowsCopyBackForwardList", setNewWindowsCopyBackForwardListCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2383 { "setPageVisibility", setPageVisibilityCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2384 { "setPOSIXLocale", setPOSIXLocaleCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2385 { "setPersistentUserStyleSheetLocation", setPersistentUserStyleSheetLocationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2386 { "setPopupBlockingEnabled", setPopupBlockingEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2387 { "setPluginsEnabled", setPluginsEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2388 { "setPrinting", setPrintingCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2389 { "setPrivateBrowsingEnabled", setPrivateBrowsingEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2390 { "setSelectTrailingWhitespaceEnabled", setSelectTrailingWhitespaceEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2391 { "setSerializeHTTPLoads", setSerializeHTTPLoadsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2392 { "setSmartInsertDeleteEnabled", setSmartInsertDeleteEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2393 { "setSpatialNavigationEnabled", setSpatialNavigationEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2394 { "setStopProvisionalFrameLoads", setStopProvisionalFrameLoadsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2395 { "setTabKeyCyclesThroughElements", setTabKeyCyclesThroughElementsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2396 { "setUseDashboardCompatibilityMode", setUseDashboardCompatibilityModeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2397 { "setUserStyleSheetEnabled", setUserStyleSheetEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2398 { "setUserStyleSheetLocation", setUserStyleSheetLocationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2399 { "setValueForUser", setValueForUserCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2400 { "setViewModeMediaFeature", setViewModeMediaFeatureCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2401 { "setWebViewEditable", setWebViewEditableCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2402 { "setWillSendRequestClearHeader", setWillSendRequestClearHeaderCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2403 { "setWillSendRequestReturnsNull", setWillSendRequestReturnsNullCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2404 { "setWillSendRequestReturnsNullOnRedirect", setWillSendRequestReturnsNullOnRedirectCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2405 { "setWindowIsKey", setWindowIsKeyCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2406 { "setJavaScriptCanAccessClipboard", setJavaScriptCanAccessClipboardCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2407 { "setXSSAuditorEnabled", setXSSAuditorEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2408 { "setAsynchronousSpellCheckingEnabled", setAsynchronousSpellCheckingEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2409 { "showWebInspector", showWebInspectorCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2410 { "simulateDesktopNotificationClick", simulateDesktopNotificationClickCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2411 { "testOnscreen", testOnscreenCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2412 { "testRepaint", testRepaintCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2413 { "waitForPolicyDelegate", waitForPolicyDelegateCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2414 { "waitUntilDone", waitUntilDoneCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2415 { "windowCount", windowCountCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2416 { "addOriginAccessWhitelistEntry", addOriginAccessWhitelistEntryCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2417 { "setScrollbarPolicy", setScrollbarPolicyCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2418 { "authenticateSession", authenticateSessionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2419 { "deleteAllLocalStorage", deleteAllLocalStorageCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2420 { "syncLocalStorage", syncLocalStorageCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2421 { "observeStorageTrackerNotifications", observeStorageTrackerNotificationsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2422 { "deleteLocalStorageForOrigin", deleteLocalStorageForOriginCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2423 { "localStorageDiskUsageForOrigin", localStorageDiskUsageForOriginCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2424 { "originsWithLocalStorage", originsWithLocalStorageCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2425 { "setShouldPaintBrokenImage", setShouldPaintBrokenImageCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2426 { "setTextDirection", setTextDirectionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2427 { "setShouldStayOnPageAfterHandlingBeforeUnload", setShouldStayOnPageAfterHandlingBeforeUnloadCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2428 { "addChromeInputField", addChromeInputFieldCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2429 { "removeChromeInputField", removeChromeInputFieldCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2430 { "focusWebView", focusWebViewCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2431 { "setBackingScaleFactor", setBackingScaleFactorCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2432 { "preciseTime", preciseTimeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2433 { "setHasCustomFullScreenBehavior", setHasCustomFullScreenBehaviorCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2437 return staticFunctions;
2440 void LayoutTestController::queueLoadHTMLString(JSStringRef content, JSStringRef baseURL)
2442 WorkQueue::shared()->queue(new LoadHTMLStringItem(content, baseURL));
2445 void LayoutTestController::queueLoadAlternateHTMLString(JSStringRef content, JSStringRef baseURL, JSStringRef unreachableURL)
2447 WorkQueue::shared()->queue(new LoadHTMLStringItem(content, baseURL, unreachableURL));
2450 void LayoutTestController::queueBackNavigation(int howFarBack)
2452 WorkQueue::shared()->queue(new BackItem(howFarBack));
2455 void LayoutTestController::queueForwardNavigation(int howFarForward)
2457 WorkQueue::shared()->queue(new ForwardItem(howFarForward));
2460 void LayoutTestController::queueLoadingScript(JSStringRef script)
2462 WorkQueue::shared()->queue(new LoadingScriptItem(script));
2465 void LayoutTestController::queueNonLoadingScript(JSStringRef script)
2467 WorkQueue::shared()->queue(new NonLoadingScriptItem(script));
2470 void LayoutTestController::queueReload()
2472 WorkQueue::shared()->queue(new ReloadItem);
2475 void LayoutTestController::grantDesktopNotificationPermission(JSStringRef origin)
2477 m_desktopNotificationAllowedOrigins.push_back(JSStringRetain(origin));
2480 bool LayoutTestController::checkDesktopNotificationPermission(JSStringRef origin)
2482 std::vector<JSStringRef>::iterator i;
2483 for (i = m_desktopNotificationAllowedOrigins.begin();
2484 i != m_desktopNotificationAllowedOrigins.end();
2486 if (JSStringIsEqual(*i, origin))
2492 void LayoutTestController::ignoreDesktopNotificationPermissionRequests()
2494 m_areDesktopNotificationPermissionRequestsIgnored = false;
2497 void LayoutTestController::waitToDumpWatchdogTimerFired()
2499 const char* message = "FAIL: Timed out waiting for notifyDone to be called\n";
2500 fprintf(stderr, "%s", message);
2501 fprintf(stdout, "%s", message);
2505 void LayoutTestController::setGeolocationPermissionCommon(bool allow)
2507 m_isGeolocationPermissionSet = true;
2508 m_geolocationPermission = allow;
2511 void LayoutTestController::setPOSIXLocale(JSStringRef locale)
2514 JSStringGetUTF8CString(locale, localeBuf, sizeof(localeBuf));
2515 setlocale(LC_ALL, localeBuf);
2518 void LayoutTestController::addURLToRedirect(std::string origin, std::string destination)
2520 m_URLsToRedirect[origin] = destination;
2523 const std::string& LayoutTestController::redirectionDestinationForURL(std::string origin)
2525 return m_URLsToRedirect[origin];
2528 void LayoutTestController::setShouldPaintBrokenImage(bool shouldPaintBrokenImage)
2530 m_shouldPaintBrokenImage = shouldPaintBrokenImage;
2533 const unsigned LayoutTestController::maxViewWidth = 800;
2534 const unsigned LayoutTestController::maxViewHeight = 600;