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>
40 #include <wtf/Assertions.h>
41 #include <wtf/MathExtras.h>
42 #include <wtf/OwnArrayPtr.h>
43 #include <wtf/RefPtr.h>
45 LayoutTestController::LayoutTestController(const std::string& testPathOrURL, const std::string& expectedPixelHash)
46 : m_dumpApplicationCacheDelegateCallbacks(false)
49 , m_dumpBackForwardList(false)
50 , m_dumpChildFrameScrollPositions(false)
51 , m_dumpChildFramesAsText(false)
52 , m_dumpDOMAsWebArchive(false)
53 , m_dumpDatabaseCallbacks(false)
54 , m_dumpEditingCallbacks(false)
55 , m_dumpFrameLoadCallbacks(false)
56 , m_dumpUserGestureInFrameLoadCallbacks(false)
57 , m_dumpHistoryDelegateCallbacks(false)
58 , m_dumpResourceLoadCallbacks(false)
59 , m_dumpResourceResponseMIMETypes(false)
60 , m_dumpSelectionRect(false)
61 , m_dumpSourceAsWebArchive(false)
62 , m_dumpStatusCallbacks(false)
63 , m_dumpTitleChanges(false)
64 , m_dumpIconChanges(false)
65 , m_dumpVisitedLinksCallback(false)
66 , m_dumpWillCacheResponse(false)
67 , m_generatePixelResults(true)
68 , m_callCloseOnWebViews(true)
69 , m_canOpenWindows(false)
70 , m_closeRemainingWindowsWhenComplete(true)
71 , m_newWindowsCopyBackForwardList(false)
72 , m_stopProvisionalFrameLoads(false)
73 , m_testOnscreen(false)
74 , m_testRepaint(false)
75 , m_testRepaintSweepHorizontally(false)
77 , m_willSendRequestReturnsNull(false)
78 , m_willSendRequestReturnsNullOnRedirect(false)
80 , m_alwaysAcceptCookies(false)
82 , m_isGeolocationPermissionSet(false)
83 , m_geolocationPermission(false)
84 , m_handlesAuthenticationChallenges(false)
86 , m_deferMainResourceDataLoad(true)
87 , m_shouldPaintBrokenImage(true)
88 , m_testPathOrURL(testPathOrURL)
89 , m_expectedPixelHash(expectedPixelHash)
93 PassRefPtr<LayoutTestController> LayoutTestController::create(const std::string& testPathOrURL, const std::string& expectedPixelHash)
95 return adoptRef(new LayoutTestController(testPathOrURL, expectedPixelHash));
100 static JSValueRef dumpApplicationCacheDelegateCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
102 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
103 controller->setDumpApplicationCacheDelegateCallbacks(true);
104 return JSValueMakeUndefined(context);
107 static JSValueRef dumpAsPDFCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
109 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
110 controller->setDumpAsPDF(true);
111 return JSValueMakeUndefined(context);
114 static JSValueRef dumpAsTextCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
116 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
117 controller->setDumpAsText(true);
119 // Optional paramater, describing whether it's allowed to dump pixel results in dumpAsText mode.
120 controller->setGeneratePixelResults(argumentCount > 0 ? JSValueToBoolean(context, arguments[0]) : false);
122 return JSValueMakeUndefined(context);
125 static JSValueRef dumpBackForwardListCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
127 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
128 controller->setDumpBackForwardList(true);
129 return JSValueMakeUndefined(context);
132 static JSValueRef dumpChildFramesAsTextCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
134 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
135 controller->setDumpChildFramesAsText(true);
136 return JSValueMakeUndefined(context);
139 static JSValueRef dumpChildFrameScrollPositionsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
141 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
142 controller->setDumpChildFrameScrollPositions(true);
143 return JSValueMakeUndefined(context);
146 static JSValueRef dumpConfigurationForViewportCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
148 if (argumentCount < 2)
149 return JSValueMakeUndefined(context);
152 double deviceDPI = JSValueToNumber(context, arguments[0], exception);
154 double deviceWidth = JSValueToNumber(context, arguments[1], exception);
156 double deviceHeight = JSValueToNumber(context, arguments[2], exception);
158 double availableWidth = JSValueToNumber(context, arguments[3], exception);
160 double availableHeight = JSValueToNumber(context, arguments[4], exception);
163 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
164 controller->dumpConfigurationForViewport(static_cast<int>(deviceDPI), static_cast<int>(deviceWidth), static_cast<int>(deviceHeight), static_cast<int>(availableWidth), static_cast<int>(availableHeight));
166 return JSValueMakeUndefined(context);
169 static JSValueRef dumpDatabaseCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
171 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
172 controller->setDumpDatabaseCallbacks(true);
173 return JSValueMakeUndefined(context);
176 static JSValueRef dumpDOMAsWebArchiveCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
178 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
179 controller->setDumpDOMAsWebArchive(true);
180 return JSValueMakeUndefined(context);
183 static JSValueRef dumpEditingCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
185 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
186 controller->setDumpEditingCallbacks(true);
187 return JSValueMakeUndefined(context);
190 static JSValueRef dumpFrameLoadCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
192 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
193 controller->setDumpFrameLoadCallbacks(true);
194 return JSValueMakeUndefined(context);
197 static JSValueRef dumpUserGestureInFrameLoadCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
199 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
200 controller->setDumpUserGestureInFrameLoadCallbacks(true);
201 return JSValueMakeUndefined(context);
204 static JSValueRef dumpResourceLoadCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
206 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
207 controller->setDumpResourceLoadCallbacks(true);
208 return JSValueMakeUndefined(context);
211 static JSValueRef dumpResourceResponseMIMETypesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
213 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
214 controller->setDumpResourceResponseMIMETypes(true);
215 return JSValueMakeUndefined(context);
218 static JSValueRef dumpSelectionRectCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
220 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
221 controller->setDumpSelectionRect(true);
222 return JSValueMakeUndefined(context);
225 static JSValueRef dumpSourceAsWebArchiveCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
227 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
228 controller->setDumpSourceAsWebArchive(true);
229 return JSValueMakeUndefined(context);
232 static JSValueRef dumpStatusCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
234 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
235 controller->setDumpStatusCallbacks(true);
236 return JSValueMakeUndefined(context);
239 static JSValueRef dumpTitleChangesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
241 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
242 controller->setDumpTitleChanges(true);
243 return JSValueMakeUndefined(context);
246 static JSValueRef dumpIconChangesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
248 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
249 controller->setDumpIconChanges(true);
250 return JSValueMakeUndefined(context);
253 static JSValueRef dumpWillCacheResponseCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
255 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
256 controller->setDumpWillCacheResponse(true);
257 return JSValueMakeUndefined(context);
260 static JSValueRef pathToLocalResourceCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
262 if (argumentCount < 1)
263 return JSValueMakeUndefined(context);
265 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
266 JSRetainPtr<JSStringRef> localPath(Adopt, JSValueToStringCopy(context, arguments[0], exception));
269 JSRetainPtr<JSStringRef> convertedPath(Adopt, controller->pathToLocalResource(context, localPath.get()));
271 return JSValueMakeUndefined(context);
273 return JSValueMakeString(context, convertedPath.get());
276 static JSValueRef removeAllVisitedLinksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
278 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
279 controller->setDumpVisitedLinksCallback(true);
280 controller->removeAllVisitedLinks();
281 return JSValueMakeUndefined(context);
284 static JSValueRef repaintSweepHorizontallyCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
286 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
287 controller->setTestRepaintSweepHorizontally(true);
288 return JSValueMakeUndefined(context);
291 static JSValueRef setCallCloseOnWebViewsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
293 if (argumentCount < 1)
294 return JSValueMakeUndefined(context);
296 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
297 controller->setCallCloseOnWebViews(JSValueToBoolean(context, arguments[0]));
298 return JSValueMakeUndefined(context);
301 static JSValueRef setCanOpenWindowsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
303 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
304 controller->setCanOpenWindows(true);
305 return JSValueMakeUndefined(context);
308 static JSValueRef setCloseRemainingWindowsWhenCompleteCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
310 if (argumentCount < 1)
311 return JSValueMakeUndefined(context);
313 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
314 controller->setCloseRemainingWindowsWhenComplete(JSValueToBoolean(context, arguments[0]));
315 return JSValueMakeUndefined(context);
318 static JSValueRef testOnscreenCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
320 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
321 controller->setTestOnscreen(true);
322 return JSValueMakeUndefined(context);
325 static JSValueRef testRepaintCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
327 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
328 controller->setTestRepaint(true);
329 return JSValueMakeUndefined(context);
332 static JSValueRef addDisallowedURLCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
334 // Has mac implementation
335 if (argumentCount < 1)
336 return JSValueMakeUndefined(context);
338 JSRetainPtr<JSStringRef> url(Adopt, JSValueToStringCopy(context, arguments[0], exception));
341 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
342 controller->addDisallowedURL(url.get());
344 return JSValueMakeUndefined(context);
347 static JSValueRef addURLToRedirectCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
349 if (argumentCount < 2)
350 return JSValueMakeUndefined(context);
352 JSRetainPtr<JSStringRef> origin(Adopt, JSValueToStringCopy(context, arguments[0], exception));
355 JSRetainPtr<JSStringRef> destination(Adopt, JSValueToStringCopy(context, arguments[1], exception));
358 size_t maxLength = JSStringGetMaximumUTF8CStringSize(origin.get());
359 OwnArrayPtr<char> originBuffer = adoptArrayPtr(new char[maxLength + 1]);
360 JSStringGetUTF8CString(origin.get(), originBuffer.get(), maxLength + 1);
362 maxLength = JSStringGetMaximumUTF8CStringSize(destination.get());
363 OwnArrayPtr<char> destinationBuffer = adoptArrayPtr(new char[maxLength + 1]);
364 JSStringGetUTF8CString(destination.get(), destinationBuffer.get(), maxLength + 1);
366 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
367 controller->addURLToRedirect(originBuffer.get(), destinationBuffer.get());
369 return JSValueMakeUndefined(context);
372 static JSValueRef callShouldCloseOnWebViewCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
374 // Has mac & windows implementation
375 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
377 return JSValueMakeBoolean(context, controller->callShouldCloseOnWebView());
380 static JSValueRef clearAllApplicationCachesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
382 // Has mac implementation
383 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
384 controller->clearAllApplicationCaches();
386 return JSValueMakeUndefined(context);
389 static JSValueRef clearApplicationCacheForOriginCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
391 if (argumentCount < 1)
392 return JSValueMakeUndefined(context);
394 JSRetainPtr<JSStringRef> originURL(Adopt, JSValueToStringCopy(context, arguments[0], exception));
397 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
398 controller->clearApplicationCacheForOrigin(originURL.get());
400 return JSValueMakeUndefined(context);
403 static JSValueRef originsWithApplicationCacheCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
405 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
406 return controller->originsWithApplicationCache(context);
409 static JSValueRef clearAllDatabasesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
411 // Has mac & windows implementation
412 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
413 controller->clearAllDatabases();
415 return JSValueMakeUndefined(context);
418 static JSValueRef syncLocalStorageCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
420 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
422 controller->syncLocalStorage();
424 return JSValueMakeUndefined(context);
427 static JSValueRef observeStorageTrackerNotificationsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
429 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
431 if (argumentCount < 1)
432 return JSValueMakeUndefined(context);
434 unsigned numNotifications = JSValueToNumber(context, arguments[0], exception);
438 controller->observeStorageTrackerNotifications(numNotifications);
440 return JSValueMakeUndefined(context);
443 static JSValueRef deleteAllLocalStorageCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
445 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
446 controller->deleteAllLocalStorage();
448 return JSValueMakeUndefined(context);
451 static JSValueRef deleteLocalStorageForOriginCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
453 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
455 if (argumentCount < 1)
456 return JSValueMakeUndefined(context);
458 JSRetainPtr<JSStringRef> url(Adopt, JSValueToStringCopy(context, arguments[0], exception));
461 controller->deleteLocalStorageForOrigin(url.get());
463 return JSValueMakeUndefined(context);
466 static JSValueRef originsWithLocalStorageCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
468 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
469 return controller->originsWithLocalStorage(context);
472 static JSValueRef clearBackForwardListCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
474 // Has mac & windows implementation
475 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
476 controller->clearBackForwardList();
478 return JSValueMakeUndefined(context);
481 static JSValueRef clearPersistentUserStyleSheetCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
483 // Has mac & windows implementation
484 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
485 controller->clearPersistentUserStyleSheet();
487 return JSValueMakeUndefined(context);
490 static JSValueRef decodeHostNameCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
492 // Has mac implementation
493 if (argumentCount < 1)
494 return JSValueMakeUndefined(context);
496 JSRetainPtr<JSStringRef> name(Adopt, JSValueToStringCopy(context, arguments[0], exception));
499 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
500 JSRetainPtr<JSStringRef> decodedHostName(Adopt, controller->copyDecodedHostName(name.get()));
501 return JSValueMakeString(context, decodedHostName.get());
504 static JSValueRef disableImageLoadingCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
506 // Has mac implementation, needs windows implementation
507 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
508 controller->disableImageLoading();
510 return JSValueMakeUndefined(context);
513 static JSValueRef dispatchPendingLoadRequestsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
515 // Has mac implementation, needs windows implementation
516 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
517 controller->dispatchPendingLoadRequests();
519 return JSValueMakeUndefined(context);
522 static JSValueRef displayCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
524 // Has mac & windows implementation
525 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
526 controller->display();
528 return JSValueMakeUndefined(context);
531 static JSValueRef displayInvalidatedRegionCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
533 // Has mac & windows implementation
534 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
535 // LayoutTestController::display() only renders the invalidated region so
536 // we can just use that.
537 controller->display();
539 return JSValueMakeUndefined(context);
542 static JSValueRef encodeHostNameCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
544 // Has mac implementation
545 if (argumentCount < 1)
546 return JSValueMakeUndefined(context);
548 JSRetainPtr<JSStringRef> name(Adopt, JSValueToStringCopy(context, arguments[0], exception));
551 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
552 JSRetainPtr<JSStringRef> encodedHostName(Adopt, controller->copyEncodedHostName(name.get()));
553 return JSValueMakeString(context, encodedHostName.get());
556 static JSValueRef execCommandCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
558 // Has Mac & Windows implementations.
559 if (argumentCount < 1)
560 return JSValueMakeUndefined(context);
562 JSRetainPtr<JSStringRef> name(Adopt, JSValueToStringCopy(context, arguments[0], exception));
565 // Ignoring the second parameter (userInterface), as this command emulates a manual action.
567 JSRetainPtr<JSStringRef> value;
568 if (argumentCount >= 3) {
569 value.adopt(JSValueToStringCopy(context, arguments[2], exception));
572 value.adopt(JSStringCreateWithUTF8CString(""));
575 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
576 controller->execCommand(name.get(), value.get());
578 return JSValueMakeUndefined(context);
581 static JSValueRef findStringCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
583 // Has Mac implementation.
584 if (argumentCount < 2)
585 return JSValueMakeUndefined(context);
587 JSRetainPtr<JSStringRef> target(Adopt, JSValueToStringCopy(context, arguments[0], exception));
590 JSObjectRef options = JSValueToObject(context, arguments[1], exception);
593 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
594 return JSValueMakeBoolean(context, controller->findString(context, target.get(), options));
597 static JSValueRef counterValueForElementByIdCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
599 if (argumentCount < 1)
600 return JSValueMakeUndefined(context);
602 JSRetainPtr<JSStringRef> elementId(Adopt, JSValueToStringCopy(context, arguments[0], exception));
604 return JSValueMakeUndefined(context);
606 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
607 JSRetainPtr<JSStringRef> counterValue(controller->counterValueForElementById(elementId.get()));
608 if (!counterValue.get())
609 return JSValueMakeUndefined(context);
610 return JSValueMakeString(context, counterValue.get());
613 static JSValueRef grantDesktopNotificationPermissionCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
615 // Has Windows implementation
616 if (argumentCount < 1)
617 return JSValueMakeUndefined(context);
619 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
621 controller->grantDesktopNotificationPermission(JSValueToStringCopy(context, arguments[0], NULL));
623 return JSValueMakeUndefined(context);
626 static JSValueRef isCommandEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
628 // Has Mac implementation.
630 if (argumentCount < 1)
631 return JSValueMakeUndefined(context);
633 JSRetainPtr<JSStringRef> name(Adopt, JSValueToStringCopy(context, arguments[0], exception));
636 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
638 return JSValueMakeBoolean(context, controller->isCommandEnabled(name.get()));
641 static JSValueRef overridePreferenceCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
643 if (argumentCount < 2)
644 return JSValueMakeUndefined(context);
646 JSRetainPtr<JSStringRef> key(Adopt, JSValueToStringCopy(context, arguments[0], exception));
648 JSRetainPtr<JSStringRef> value(Adopt, JSValueToStringCopy(context, arguments[1], exception));
651 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
652 controller->overridePreference(key.get(), value.get());
654 return JSValueMakeUndefined(context);
657 static JSValueRef keepWebHistoryCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
659 // Has mac implementation
660 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
661 controller->keepWebHistory();
663 return JSValueMakeUndefined(context);
666 static JSValueRef computedStyleIncludingVisitedInfoCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
668 if (argumentCount != 1)
669 return JSValueMakeUndefined(context);
671 // Has mac implementation
672 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
673 return controller->computedStyleIncludingVisitedInfo(context, arguments[0]);
676 static JSValueRef nodesFromRectCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
678 if (argumentCount != 8)
679 return JSValueMakeUndefined(context);
681 int x = JSValueToNumber(context, arguments[1], NULL);
682 int y = JSValueToNumber(context, arguments[2], NULL);
683 int top = static_cast<unsigned>(JSValueToNumber(context, arguments[3], NULL));
684 int right = static_cast<unsigned>(JSValueToNumber(context, arguments[4], NULL));
685 int bottom = static_cast<unsigned>(JSValueToNumber(context, arguments[5], NULL));
686 int left = static_cast<unsigned>(JSValueToNumber(context, arguments[6], NULL));
687 bool ignoreClipping = JSValueToBoolean(context, arguments[7]);
689 // Has mac implementation.
690 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
691 return controller->nodesFromRect(context, arguments[0], x, y, top, right, bottom, left, ignoreClipping);
694 static JSValueRef layerTreeAsTextCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
696 // Has mac & windows implementation
697 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
698 return JSValueMakeString(context, controller->layerTreeAsText().get());
701 static JSValueRef notifyDoneCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
703 // Has mac & windows implementation
704 // May be able to be made platform independant by using shared WorkQueue
705 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
706 controller->notifyDone();
707 return JSValueMakeUndefined(context);
710 static bool parsePageParameters(JSContextRef context, int argumentCount, const JSValueRef* arguments, JSValueRef* exception, float& pageWidthInPixels, float& pageHeightInPixels)
712 pageWidthInPixels = LayoutTestController::maxViewWidth;
713 pageHeightInPixels = LayoutTestController::maxViewHeight;
714 switch (argumentCount) {
716 pageWidthInPixels = static_cast<float>(JSValueToNumber(context, arguments[0], exception));
719 pageHeightInPixels = static_cast<float>(JSValueToNumber(context, arguments[1], exception));
722 case 0: // Fall through.
730 // Caller needs to delete[] propertyName.
731 static bool parsePagePropertyParameters(JSContextRef context, int argumentCount, const JSValueRef* arguments, JSValueRef* exception, char*& propertyName, int& pageNumber)
734 switch (argumentCount) {
736 pageNumber = static_cast<float>(JSValueToNumber(context, arguments[1], exception));
741 JSRetainPtr<JSStringRef> propertyNameString(Adopt, JSValueToStringCopy(context, arguments[0], exception));
745 size_t maxLength = JSStringGetMaximumUTF8CStringSize(propertyNameString.get());
746 propertyName = new char[maxLength + 1];
747 JSStringGetUTF8CString(propertyNameString.get(), propertyName, maxLength + 1);
756 static bool parsePageNumber(JSContextRef context, int argumentCount, const JSValueRef* arguments, JSValueRef* exception, int& pageNumber)
759 switch (argumentCount) {
761 pageNumber = static_cast<int>(JSValueToNumber(context, arguments[0], exception));
772 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)
776 marginTop = marginRight = marginBottom = marginLeft = 0;
778 switch (argumentCount) {
780 marginLeft = static_cast<int>(JSValueToNumber(context, arguments[6], exception));
785 marginBottom = static_cast<int>(JSValueToNumber(context, arguments[5], exception));
790 marginRight = static_cast<int>(JSValueToNumber(context, arguments[4], exception));
795 marginTop = static_cast<int>(JSValueToNumber(context, arguments[3], exception));
800 height = static_cast<int>(JSValueToNumber(context, arguments[2], exception));
805 width = static_cast<int>(JSValueToNumber(context, arguments[1], exception));
810 pageNumber = static_cast<int>(JSValueToNumber(context, arguments[0], exception));
820 static JSValueRef pageNumberForElementByIdCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
822 float pageWidthInPixels = 0;
823 float pageHeightInPixels = 0;
824 if (!parsePageParameters(context, argumentCount - 1, arguments + 1, exception, pageWidthInPixels, pageHeightInPixels))
825 return JSValueMakeUndefined(context);
827 JSRetainPtr<JSStringRef> elementId(Adopt, JSValueToStringCopy(context, arguments[0], exception));
829 return JSValueMakeUndefined(context);
831 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
832 int pageNumber = controller->pageNumberForElementById(elementId.get(), pageWidthInPixels, pageHeightInPixels);
833 return JSValueMakeNumber(context, pageNumber);
836 static JSValueRef numberOfPagesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
838 float pageWidthInPixels = 0;
839 float pageHeightInPixels = 0;
840 if (!parsePageParameters(context, argumentCount, arguments, exception, pageWidthInPixels, pageHeightInPixels))
841 return JSValueMakeUndefined(context);
843 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
844 return JSValueMakeNumber(context, controller->numberOfPages(pageWidthInPixels, pageHeightInPixels));
847 static JSValueRef numberOfPendingGeolocationPermissionRequestsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
849 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
850 return JSValueMakeNumber(context, controller->numberOfPendingGeolocationPermissionRequests());
853 static JSValueRef pagePropertyCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
855 char* propertyName = 0;
857 if (!parsePagePropertyParameters(context, argumentCount, arguments, exception, propertyName, pageNumber))
858 return JSValueMakeUndefined(context);
860 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
861 JSValueRef value = JSValueMakeString(context, controller->pageProperty(propertyName, pageNumber).get());
863 delete[] propertyName;
867 static JSValueRef isPageBoxVisibleCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
870 if (!parsePageNumber(context, argumentCount, arguments, exception, pageNumber))
871 return JSValueMakeUndefined(context);
873 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
874 return JSValueMakeBoolean(context, controller->isPageBoxVisible(pageNumber));
877 static JSValueRef pageSizeAndMarginsInPixelsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
880 int width = 0, height = 0;
881 int marginTop = 0, marginRight = 0, marginBottom = 0, marginLeft = 0;
882 if (!parsePageNumberSizeMarings(context, argumentCount, arguments, exception, pageNumber, width, height, marginTop, marginRight, marginBottom, marginLeft))
883 return JSValueMakeUndefined(context);
885 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
886 return JSValueMakeString(context, controller->pageSizeAndMarginsInPixels(pageNumber, width, height, marginTop, marginRight, marginBottom, marginLeft).get());
889 static JSValueRef queueBackNavigationCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
891 // Has mac & windows implementation
892 // May be able to be made platform independant by using shared WorkQueue
893 if (argumentCount < 1)
894 return JSValueMakeUndefined(context);
896 double howFarBackDouble = JSValueToNumber(context, arguments[0], exception);
899 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
900 controller->queueBackNavigation(static_cast<int>(howFarBackDouble));
902 return JSValueMakeUndefined(context);
905 static JSValueRef queueForwardNavigationCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
907 // Has mac & windows implementation
908 // May be able to be made platform independant by using shared WorkQueue
909 if (argumentCount < 1)
910 return JSValueMakeUndefined(context);
912 double howFarForwardDouble = JSValueToNumber(context, arguments[0], exception);
915 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
916 controller->queueForwardNavigation(static_cast<int>(howFarForwardDouble));
918 return JSValueMakeUndefined(context);
921 static JSValueRef queueLoadCallback(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 JSRetainPtr<JSStringRef> url(Adopt, JSValueToStringCopy(context, arguments[0], exception));
931 JSRetainPtr<JSStringRef> target;
932 if (argumentCount >= 2) {
933 target.adopt(JSValueToStringCopy(context, arguments[1], exception));
936 target.adopt(JSStringCreateWithUTF8CString(""));
938 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
939 controller->queueLoad(url.get(), target.get());
941 return JSValueMakeUndefined(context);
944 static JSValueRef queueLoadHTMLStringCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
946 // Has Mac & Windows implementation
947 if (argumentCount < 1)
948 return JSValueMakeUndefined(context);
950 JSRetainPtr<JSStringRef> content(Adopt, JSValueToStringCopy(context, arguments[0], exception));
953 JSRetainPtr<JSStringRef> baseURL;
954 if (argumentCount >= 2) {
955 baseURL.adopt(JSValueToStringCopy(context, arguments[1], exception));
958 baseURL.adopt(JSStringCreateWithUTF8CString(""));
960 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
962 if (argumentCount >= 3) {
963 JSRetainPtr<JSStringRef> unreachableURL;
964 unreachableURL.adopt(JSValueToStringCopy(context, arguments[2], exception));
966 controller->queueLoadAlternateHTMLString(content.get(), baseURL.get(), unreachableURL.get());
967 return JSValueMakeUndefined(context);
970 controller->queueLoadHTMLString(content.get(), baseURL.get());
971 return JSValueMakeUndefined(context);
974 static JSValueRef queueReloadCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
976 // Has mac & windows implementation
977 // May be able to be made platform independant by using shared WorkQueue
979 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
980 controller->queueReload();
982 return JSValueMakeUndefined(context);
985 static JSValueRef queueLoadingScriptCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
987 // Has mac & windows implementation
988 // May be able to be made platform independant by using shared WorkQueue
989 if (argumentCount < 1)
990 return JSValueMakeUndefined(context);
992 JSRetainPtr<JSStringRef> script(Adopt, JSValueToStringCopy(context, arguments[0], exception));
995 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
996 controller->queueLoadingScript(script.get());
998 return JSValueMakeUndefined(context);
1001 static JSValueRef queueNonLoadingScriptCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1003 // Has mac & windows implementation
1004 // May be able to be made platform independant by using shared WorkQueue
1005 if (argumentCount < 1)
1006 return JSValueMakeUndefined(context);
1008 JSRetainPtr<JSStringRef> script(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1009 ASSERT(!*exception);
1011 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1012 controller->queueNonLoadingScript(script.get());
1014 return JSValueMakeUndefined(context);
1017 static JSValueRef setAcceptsEditingCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1019 // Has mac & windows implementation
1020 if (argumentCount < 1)
1021 return JSValueMakeUndefined(context);
1023 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1024 controller->setAcceptsEditing(JSValueToBoolean(context, arguments[0]));
1026 return JSValueMakeUndefined(context);
1029 static JSValueRef setAlwaysAcceptCookiesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1031 // Has mac & windows implementation
1032 if (argumentCount < 1)
1033 return JSValueMakeUndefined(context);
1035 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1036 controller->setAlwaysAcceptCookies(JSValueToBoolean(context, arguments[0]));
1038 return JSValueMakeUndefined(context);
1041 static JSValueRef setAppCacheMaximumSizeCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1043 // Has mac implementation
1044 if (argumentCount < 1)
1045 return JSValueMakeUndefined(context);
1047 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1049 double size = JSValueToNumber(context, arguments[0], NULL);
1051 controller->setAppCacheMaximumSize(static_cast<unsigned long long>(size));
1053 return JSValueMakeUndefined(context);
1056 static JSValueRef setApplicationCacheOriginQuotaCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1058 // Has mac implementation
1059 if (argumentCount < 1)
1060 return JSValueMakeUndefined(context);
1062 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1064 double size = JSValueToNumber(context, arguments[0], NULL);
1066 controller->setApplicationCacheOriginQuota(static_cast<unsigned long long>(size));
1068 return JSValueMakeUndefined(context);
1071 static JSValueRef setAuthenticationPasswordCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1073 // Has mac & windows implementation
1074 if (argumentCount < 1)
1075 return JSValueMakeUndefined(context);
1077 JSRetainPtr<JSStringRef> password(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1078 ASSERT(!*exception);
1080 size_t maxLength = JSStringGetMaximumUTF8CStringSize(password.get());
1081 char* passwordBuffer = new char[maxLength + 1];
1082 JSStringGetUTF8CString(password.get(), passwordBuffer, maxLength + 1);
1084 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1085 controller->setAuthenticationPassword(passwordBuffer);
1086 delete[] passwordBuffer;
1088 return JSValueMakeUndefined(context);
1091 static JSValueRef setAuthenticationUsernameCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1093 // Has mac & windows implementation
1094 if (argumentCount < 1)
1095 return JSValueMakeUndefined(context);
1097 JSRetainPtr<JSStringRef> username(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1098 ASSERT(!*exception);
1100 size_t maxLength = JSStringGetMaximumUTF8CStringSize(username.get());
1101 char* usernameBuffer = new char[maxLength + 1];
1102 JSStringGetUTF8CString(username.get(), usernameBuffer, maxLength + 1);
1104 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1105 controller->setAuthenticationUsername(usernameBuffer);
1106 delete[] usernameBuffer;
1108 return JSValueMakeUndefined(context);
1111 static JSValueRef setAuthorAndUserStylesEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1113 // Has mac & windows implementation
1114 if (argumentCount < 1)
1115 return JSValueMakeUndefined(context);
1117 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1118 controller->setAuthorAndUserStylesEnabled(JSValueToBoolean(context, arguments[0]));
1120 return JSValueMakeUndefined(context);
1123 static JSValueRef setAutofilledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1125 if (argumentCount != 2 || !arguments[0])
1126 return JSValueMakeUndefined(context);
1128 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1129 controller->setAutofilled(context, arguments[0], JSValueToBoolean(context, arguments[1]));
1131 return JSValueMakeUndefined(context);
1134 static JSValueRef setCacheModelCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1136 // Has Mac implementation.
1137 if (argumentCount < 1)
1138 return JSValueMakeUndefined(context);
1140 int cacheModel = JSValueToNumber(context, arguments[0], exception);
1141 ASSERT(!*exception);
1143 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1144 controller->setCacheModel(cacheModel);
1146 return JSValueMakeUndefined(context);
1149 static JSValueRef setCustomPolicyDelegateCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1151 // Has mac implementation
1152 if (argumentCount < 1)
1153 return JSValueMakeUndefined(context);
1155 bool permissive = false;
1156 if (argumentCount >= 2)
1157 permissive = JSValueToBoolean(context, arguments[1]);
1159 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1160 controller->setCustomPolicyDelegate(JSValueToBoolean(context, arguments[0]), permissive);
1162 return JSValueMakeUndefined(context);
1165 static JSValueRef setDatabaseQuotaCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1167 // Has mac implementation
1168 if (argumentCount < 1)
1169 return JSValueMakeUndefined(context);
1171 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1173 double quota = JSValueToNumber(context, arguments[0], NULL);
1175 controller->setDatabaseQuota(static_cast<unsigned long long>(quota));
1177 return JSValueMakeUndefined(context);
1180 static JSValueRef setDeferMainResourceDataLoadCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1182 // Has Mac and Windows implementation
1183 if (argumentCount < 1)
1184 return JSValueMakeUndefined(context);
1186 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1187 controller->setDeferMainResourceDataLoad(JSValueToBoolean(context, arguments[0]));
1189 return JSValueMakeUndefined(context);
1192 static JSValueRef setDomainRelaxationForbiddenForURLSchemeCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1194 // Has Mac and Windows implementation
1195 if (argumentCount < 2)
1196 return JSValueMakeUndefined(context);
1198 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1200 bool forbidden = JSValueToBoolean(context, arguments[0]);
1201 JSRetainPtr<JSStringRef> scheme(Adopt, JSValueToStringCopy(context, arguments[1], 0));
1202 controller->setDomainRelaxationForbiddenForURLScheme(forbidden, scheme.get());
1204 return JSValueMakeUndefined(context);
1207 static JSValueRef setMockDeviceOrientationCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1209 if (argumentCount < 6)
1210 return JSValueMakeUndefined(context);
1212 bool canProvideAlpha = JSValueToBoolean(context, arguments[0]);
1213 double alpha = JSValueToNumber(context, arguments[1], exception);
1214 ASSERT(!*exception);
1215 bool canProvideBeta = JSValueToBoolean(context, arguments[2]);
1216 double beta = JSValueToNumber(context, arguments[3], exception);
1217 ASSERT(!*exception);
1218 bool canProvideGamma = JSValueToBoolean(context, arguments[4]);
1219 double gamma = JSValueToNumber(context, arguments[5], exception);
1220 ASSERT(!*exception);
1222 LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1223 controller->setMockDeviceOrientation(canProvideAlpha, alpha, canProvideBeta, beta, canProvideGamma, gamma);
1225 return JSValueMakeUndefined(context);
1228 static JSValueRef setMockGeolocationPositionCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1230 if (argumentCount < 3)
1231 return JSValueMakeUndefined(context);
1233 LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1234 controller->setMockGeolocationPosition(JSValueToNumber(context, arguments[0], NULL), // latitude
1235 JSValueToNumber(context, arguments[1], NULL), // longitude
1236 JSValueToNumber(context, arguments[2], NULL)); // accuracy
1238 return JSValueMakeUndefined(context);
1241 static JSValueRef setMockGeolocationErrorCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1243 if (argumentCount < 2)
1244 return JSValueMakeUndefined(context);
1246 int code = JSValueToNumber(context, arguments[0], NULL);
1247 JSRetainPtr<JSStringRef> message(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1248 ASSERT(!*exception);
1250 LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1251 controller->setMockGeolocationError(code, message.get());
1253 return JSValueMakeUndefined(context);
1256 static JSValueRef addMockSpeechInputResultCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1258 if (argumentCount < 3)
1259 return JSValueMakeUndefined(context);
1261 JSRetainPtr<JSStringRef> result(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1262 ASSERT(!*exception);
1264 double confidence = JSValueToNumber(context, arguments[1], exception);
1266 JSRetainPtr<JSStringRef> language(Adopt, JSValueToStringCopy(context, arguments[2], exception));
1267 ASSERT(!*exception);
1269 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1270 controller->addMockSpeechInputResult(result.get(), confidence, language.get());
1272 return JSValueMakeUndefined(context);
1275 static JSValueRef setNewWindowsCopyBackForwardListCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1277 // Has mac implementation
1278 if (argumentCount < 1)
1279 return JSValueMakeUndefined(context);
1281 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1282 controller->setNewWindowsCopyBackForwardList(JSValueToBoolean(context, arguments[0]));
1284 return JSValueMakeUndefined(context);
1287 static JSValueRef setGeolocationPermissionCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1289 // Has mac implementation
1290 if (argumentCount < 1)
1291 return JSValueMakeUndefined(context);
1293 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1294 controller->setGeolocationPermission(JSValueToBoolean(context, arguments[0]));
1296 return JSValueMakeUndefined(context);
1299 static JSValueRef setHandlesAuthenticationChallengesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1301 // Has mac & windows implementation
1302 if (argumentCount < 1)
1303 return JSValueMakeUndefined(context);
1305 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1306 controller->setHandlesAuthenticationChallenges(JSValueToBoolean(context, arguments[0]));
1308 return JSValueMakeUndefined(context);
1311 static JSValueRef setPOSIXLocaleCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1313 if (argumentCount < 1)
1314 return JSValueMakeUndefined(context);
1316 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1317 JSRetainPtr<JSStringRef> locale(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1318 ASSERT(!*exception);
1319 controller->setPOSIXLocale(locale.get());
1321 return JSValueMakeUndefined(context);
1324 static JSValueRef setIconDatabaseEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1326 // Has mac & windows implementation
1327 if (argumentCount < 1)
1328 return JSValueMakeUndefined(context);
1330 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1331 controller->setIconDatabaseEnabled(JSValueToBoolean(context, arguments[0]));
1333 return JSValueMakeUndefined(context);
1336 static JSValueRef setJavaScriptProfilingEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1338 if (argumentCount < 1)
1339 return JSValueMakeUndefined(context);
1341 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1342 controller->setJavaScriptProfilingEnabled(JSValueToBoolean(context, arguments[0]));
1344 return JSValueMakeUndefined(context);
1347 static JSValueRef setMainFrameIsFirstResponderCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1349 // Has mac implementation
1350 if (argumentCount < 1)
1351 return JSValueMakeUndefined(context);
1353 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1354 controller->setMainFrameIsFirstResponder(JSValueToBoolean(context, arguments[0]));
1356 return JSValueMakeUndefined(context);
1359 static JSValueRef setPersistentUserStyleSheetLocationCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1361 // Has mac implementation
1362 if (argumentCount < 1)
1363 return JSValueMakeUndefined(context);
1365 JSRetainPtr<JSStringRef> path(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1366 ASSERT(!*exception);
1368 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1369 controller->setPersistentUserStyleSheetLocation(path.get());
1371 return JSValueMakeUndefined(context);
1374 static JSValueRef setPrivateBrowsingEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1376 // Has mac & windows implementation
1377 if (argumentCount < 1)
1378 return JSValueMakeUndefined(context);
1380 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1381 controller->setPrivateBrowsingEnabled(JSValueToBoolean(context, arguments[0]));
1383 return JSValueMakeUndefined(context);
1386 static JSValueRef setJavaScriptCanAccessClipboardCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1388 // Has mac & windows implementation
1389 if (argumentCount < 1)
1390 return JSValueMakeUndefined(context);
1392 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1393 controller->setJavaScriptCanAccessClipboard(JSValueToBoolean(context, arguments[0]));
1395 return JSValueMakeUndefined(context);
1398 static JSValueRef setXSSAuditorEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1400 // Has mac & windows implementation
1401 if (argumentCount < 1)
1402 return JSValueMakeUndefined(context);
1404 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1405 controller->setXSSAuditorEnabled(JSValueToBoolean(context, arguments[0]));
1407 return JSValueMakeUndefined(context);
1410 static JSValueRef setSpatialNavigationEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1412 // Has mac implementation.
1413 if (argumentCount < 1)
1414 return JSValueMakeUndefined(context);
1416 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1417 controller->setSpatialNavigationEnabled(JSValueToBoolean(context, arguments[0]));
1419 return JSValueMakeUndefined(context);
1422 static JSValueRef setPrintingCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1424 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1425 controller->setIsPrinting(true);
1426 return JSValueMakeUndefined(context);
1430 static JSValueRef setFrameFlatteningEnabledCallback(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->setFrameFlatteningEnabled(JSValueToBoolean(context, arguments[0]));
1439 return JSValueMakeUndefined(context);
1442 static JSValueRef setAllowUniversalAccessFromFileURLsCallback(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->setAllowUniversalAccessFromFileURLs(JSValueToBoolean(context, arguments[0]));
1451 return JSValueMakeUndefined(context);
1454 static JSValueRef setAllowFileAccessFromFileURLsCallback(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->setAllowFileAccessFromFileURLs(JSValueToBoolean(context, arguments[0]));
1463 return JSValueMakeUndefined(context);
1466 static JSValueRef setTabKeyCyclesThroughElementsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1468 // Has mac & windows implementation
1469 if (argumentCount < 1)
1470 return JSValueMakeUndefined(context);
1472 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1473 controller->setTabKeyCyclesThroughElements(JSValueToBoolean(context, arguments[0]));
1475 return JSValueMakeUndefined(context);
1478 static JSValueRef setTimelineProfilingEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1480 if (argumentCount < 1)
1481 return JSValueMakeUndefined(context);
1483 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1484 controller->setTimelineProfilingEnabled(JSValueToBoolean(context, arguments[0]));
1485 return JSValueMakeUndefined(context);
1488 static JSValueRef setUseDashboardCompatibilityModeCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1490 // Has mac implementation
1491 if (argumentCount < 1)
1492 return JSValueMakeUndefined(context);
1494 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1495 controller->setUseDashboardCompatibilityMode(JSValueToBoolean(context, arguments[0]));
1497 return JSValueMakeUndefined(context);
1500 static JSValueRef setUserStyleSheetEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1502 // Has mac implementation
1503 if (argumentCount < 1)
1504 return JSValueMakeUndefined(context);
1506 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1507 controller->setUserStyleSheetEnabled(JSValueToBoolean(context, arguments[0]));
1509 return JSValueMakeUndefined(context);
1512 static JSValueRef setUserStyleSheetLocationCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1514 // Has mac implementation
1515 if (argumentCount < 1)
1516 return JSValueMakeUndefined(context);
1518 JSRetainPtr<JSStringRef> path(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1519 ASSERT(!*exception);
1521 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1522 controller->setUserStyleSheetLocation(path.get());
1524 return JSValueMakeUndefined(context);
1527 static JSValueRef setValueForUserCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1529 // Has mac implementation
1530 if (argumentCount != 2)
1531 return JSValueMakeUndefined(context);
1533 JSRetainPtr<JSStringRef> value(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1534 ASSERT(!*exception);
1536 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1537 controller->setValueForUser(context, arguments[0], value.get());
1539 return JSValueMakeUndefined(context);
1542 static JSValueRef setViewModeMediaFeatureCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1544 // Has mac implementation
1545 if (argumentCount < 1)
1546 return JSValueMakeUndefined(context);
1548 JSRetainPtr<JSStringRef> mode(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1549 ASSERT(!*exception);
1551 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1552 controller->setViewModeMediaFeature(mode.get());
1554 return JSValueMakeUndefined(context);
1557 static JSValueRef setWillSendRequestClearHeaderCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1559 // Has mac & windows implementation
1560 if (argumentCount < 1)
1561 return JSValueMakeUndefined(context);
1563 JSRetainPtr<JSStringRef> header(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1564 ASSERT(!*exception);
1566 size_t maxLength = JSStringGetMaximumUTF8CStringSize(header.get());
1567 OwnArrayPtr<char> headerBuffer = adoptArrayPtr(new char[maxLength + 1]);
1568 JSStringGetUTF8CString(header.get(), headerBuffer.get(), maxLength + 1);
1570 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1571 controller->setWillSendRequestClearHeader(headerBuffer.get());
1573 return JSValueMakeUndefined(context);
1576 static JSValueRef setWillSendRequestReturnsNullCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1578 // Has cross-platform implementation
1579 if (argumentCount < 1)
1580 return JSValueMakeUndefined(context);
1582 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1583 controller->setWillSendRequestReturnsNull(JSValueToBoolean(context, arguments[0]));
1585 return JSValueMakeUndefined(context);
1588 static JSValueRef setWillSendRequestReturnsNullOnRedirectCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1590 // Has cross-platform implementation
1591 if (argumentCount < 1)
1592 return JSValueMakeUndefined(context);
1594 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1595 controller->setWillSendRequestReturnsNullOnRedirect(JSValueToBoolean(context, arguments[0]));
1597 return JSValueMakeUndefined(context);
1600 static JSValueRef setWindowIsKeyCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1602 // Has mac implementation
1603 if (argumentCount < 1)
1604 return JSValueMakeUndefined(context);
1606 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1607 controller->setWindowIsKey(JSValueToBoolean(context, arguments[0]));
1609 return JSValueMakeUndefined(context);
1612 static JSValueRef waitUntilDoneCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1614 // Has mac & windows implementation
1615 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1616 controller->setWaitToDump(true);
1618 return JSValueMakeUndefined(context);
1621 static JSValueRef windowCountCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1623 // Has mac implementation
1624 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1625 int windows = controller->windowCount();
1626 return JSValueMakeNumber(context, windows);
1629 static JSValueRef setPopupBlockingEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1631 // Has mac & windows implementation
1632 if (argumentCount < 1)
1633 return JSValueMakeUndefined(context);
1635 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1636 controller->setPopupBlockingEnabled(JSValueToBoolean(context, arguments[0]));
1638 return JSValueMakeUndefined(context);
1641 static JSValueRef setPluginsEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1643 // Has mac & windows implementation
1644 if (argumentCount < 1)
1645 return JSValueMakeUndefined(context);
1647 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1648 controller->setPluginsEnabled(JSValueToBoolean(context, arguments[0]));
1650 return JSValueMakeUndefined(context);
1653 static JSValueRef setSmartInsertDeleteEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1655 if (argumentCount < 1)
1656 return JSValueMakeUndefined(context);
1658 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1659 controller->setSmartInsertDeleteEnabled(JSValueToBoolean(context, arguments[0]));
1660 return JSValueMakeUndefined(context);
1663 static JSValueRef setSelectTrailingWhitespaceEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1665 if (argumentCount < 1)
1666 return JSValueMakeUndefined(context);
1668 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1669 controller->setSelectTrailingWhitespaceEnabled(JSValueToBoolean(context, arguments[0]));
1670 return JSValueMakeUndefined(context);
1673 static JSValueRef setStopProvisionalFrameLoadsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1675 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1676 controller->setStopProvisionalFrameLoads(true);
1677 return JSValueMakeUndefined(context);
1680 static JSValueRef setAsynchronousSpellCheckingEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1682 if (argumentCount < 1)
1683 return JSValueMakeUndefined(context);
1685 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1686 controller->setAsynchronousSpellCheckingEnabled(JSValueToBoolean(context, arguments[0]));
1687 return JSValueMakeUndefined(context);
1690 static JSValueRef showWebInspectorCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1692 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1693 controller->showWebInspector();
1694 return JSValueMakeUndefined(context);
1697 static JSValueRef closeWebInspectorCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1699 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1700 controller->setTimelineProfilingEnabled(false);
1701 controller->closeWebInspector();
1702 return JSValueMakeUndefined(context);
1705 static JSValueRef evaluateInWebInspectorCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1707 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1708 double callId = JSValueToNumber(context, arguments[0], exception);
1709 ASSERT(!*exception);
1710 JSRetainPtr<JSStringRef> script(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1711 ASSERT(!*exception);
1713 controller->evaluateInWebInspector(static_cast<long>(callId), script.get());
1714 return JSValueMakeUndefined(context);
1717 static JSValueRef evaluateScriptInIsolatedWorldCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1719 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1720 double worldID = JSValueToNumber(context, arguments[0], exception);
1721 ASSERT(!*exception);
1722 JSRetainPtr<JSStringRef> script(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1723 ASSERT(!*exception);
1725 controller->evaluateScriptInIsolatedWorld(static_cast<unsigned>(worldID), JSContextGetGlobalObject(context), script.get());
1726 return JSValueMakeUndefined(context);
1729 static JSValueRef elementDoesAutoCompleteForElementWithIdCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1731 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1732 JSRetainPtr<JSStringRef> elementId(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1733 ASSERT(!*exception);
1735 bool autoCompletes = controller->elementDoesAutoCompleteForElementWithId(elementId.get());
1737 return JSValueMakeBoolean(context, autoCompletes);
1740 static JSValueRef pauseAnimationAtTimeOnElementWithIdCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1742 if (argumentCount != 3)
1743 return JSValueMakeUndefined(context);
1745 JSRetainPtr<JSStringRef> animationName(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1746 ASSERT(!*exception);
1747 double time = JSValueToNumber(context, arguments[1], exception);
1748 ASSERT(!*exception);
1749 JSRetainPtr<JSStringRef> elementId(Adopt, JSValueToStringCopy(context, arguments[2], exception));
1750 ASSERT(!*exception);
1752 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1753 return JSValueMakeBoolean(context, controller->pauseAnimationAtTimeOnElementWithId(animationName.get(), time, elementId.get()));
1756 static JSValueRef pauseTransitionAtTimeOnElementWithIdCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1758 if (argumentCount != 3)
1759 return JSValueMakeUndefined(context);
1761 JSRetainPtr<JSStringRef> propertyName(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1762 ASSERT(!*exception);
1763 double time = JSValueToNumber(context, arguments[1], exception);
1764 ASSERT(!*exception);
1765 JSRetainPtr<JSStringRef> elementId(Adopt, JSValueToStringCopy(context, arguments[2], exception));
1766 ASSERT(!*exception);
1768 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1769 return JSValueMakeBoolean(context, controller->pauseTransitionAtTimeOnElementWithId(propertyName.get(), time, elementId.get()));
1772 static JSValueRef sampleSVGAnimationForElementAtTimeCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1774 if (argumentCount != 3)
1775 return JSValueMakeUndefined(context);
1777 JSRetainPtr<JSStringRef> animationId(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1778 ASSERT(!*exception);
1779 double time = JSValueToNumber(context, arguments[1], exception);
1780 ASSERT(!*exception);
1781 JSRetainPtr<JSStringRef> elementId(Adopt, JSValueToStringCopy(context, arguments[2], exception));
1782 ASSERT(!*exception);
1784 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1785 return JSValueMakeBoolean(context, controller->sampleSVGAnimationForElementAtTime(animationId.get(), time, elementId.get()));
1788 static JSValueRef numberOfActiveAnimationsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1790 if (argumentCount != 0)
1791 return JSValueMakeUndefined(context);
1793 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1794 return JSValueMakeNumber(context, controller->numberOfActiveAnimations());
1797 static JSValueRef suspendAnimationsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1799 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1800 controller->suspendAnimations();
1801 return JSValueMakeUndefined(context);
1804 static JSValueRef resumeAnimationsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1806 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1807 controller->resumeAnimations();
1808 return JSValueMakeUndefined(context);
1811 static JSValueRef waitForPolicyDelegateCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t, const JSValueRef[], JSValueRef*)
1813 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1814 controller->waitForPolicyDelegate();
1815 return JSValueMakeUndefined(context);
1818 static JSValueRef addOriginAccessWhitelistEntryCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1820 if (argumentCount != 4)
1821 return JSValueMakeUndefined(context);
1823 JSRetainPtr<JSStringRef> sourceOrigin(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1824 ASSERT(!*exception);
1825 JSRetainPtr<JSStringRef> destinationProtocol(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1826 ASSERT(!*exception);
1827 JSRetainPtr<JSStringRef> destinationHost(Adopt, JSValueToStringCopy(context, arguments[2], exception));
1828 ASSERT(!*exception);
1829 bool allowDestinationSubdomains = JSValueToBoolean(context, arguments[3]);
1831 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1832 controller->addOriginAccessWhitelistEntry(sourceOrigin.get(), destinationProtocol.get(), destinationHost.get(), allowDestinationSubdomains);
1833 return JSValueMakeUndefined(context);
1836 static JSValueRef removeOriginAccessWhitelistEntryCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1838 if (argumentCount != 4)
1839 return JSValueMakeUndefined(context);
1841 JSRetainPtr<JSStringRef> sourceOrigin(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1842 ASSERT(!*exception);
1843 JSRetainPtr<JSStringRef> destinationProtocol(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1844 ASSERT(!*exception);
1845 JSRetainPtr<JSStringRef> destinationHost(Adopt, JSValueToStringCopy(context, arguments[2], exception));
1846 ASSERT(!*exception);
1847 bool allowDestinationSubdomains = JSValueToBoolean(context, arguments[3]);
1849 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1850 controller->removeOriginAccessWhitelistEntry(sourceOrigin.get(), destinationProtocol.get(), destinationHost.get(), allowDestinationSubdomains);
1851 return JSValueMakeUndefined(context);
1854 static JSValueRef setScrollbarPolicyCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1856 if (argumentCount != 2)
1857 return JSValueMakeUndefined(context);
1859 JSRetainPtr<JSStringRef> orientation(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1860 ASSERT(!*exception);
1861 JSRetainPtr<JSStringRef> policy(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1862 ASSERT(!*exception);
1864 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1865 controller->setScrollbarPolicy(orientation.get(), policy.get());
1866 return JSValueMakeUndefined(context);
1869 static JSValueRef addUserScriptCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1871 if (argumentCount != 3)
1872 return JSValueMakeUndefined(context);
1874 JSRetainPtr<JSStringRef> source(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1875 ASSERT(!*exception);
1876 bool runAtStart = JSValueToBoolean(context, arguments[1]);
1877 bool allFrames = JSValueToBoolean(context, arguments[2]);
1879 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1880 controller->addUserScript(source.get(), runAtStart, allFrames);
1881 return JSValueMakeUndefined(context);
1884 static JSValueRef addUserStyleSheetCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1886 if (argumentCount != 2)
1887 return JSValueMakeUndefined(context);
1889 JSRetainPtr<JSStringRef> source(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1890 ASSERT(!*exception);
1891 bool allFrames = JSValueToBoolean(context, arguments[1]);
1893 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1894 controller->addUserStyleSheet(source.get(), allFrames);
1895 return JSValueMakeUndefined(context);
1898 static JSValueRef setShouldPaintBrokenImageCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1900 // Has Mac implementation
1901 if (argumentCount < 1)
1902 return JSValueMakeUndefined(context);
1904 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1905 controller->setShouldPaintBrokenImage(JSValueToBoolean(context, arguments[0]));
1907 return JSValueMakeUndefined(context);
1910 static JSValueRef apiTestNewWindowDataLoadBaseURLCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1912 if (argumentCount != 2)
1913 return JSValueMakeUndefined(context);
1915 JSRetainPtr<JSStringRef> utf8Data(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1916 ASSERT(!*exception);
1918 JSRetainPtr<JSStringRef> baseURL(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1919 ASSERT(!*exception);
1921 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1922 controller->apiTestNewWindowDataLoadBaseURL(utf8Data.get(), baseURL.get());
1923 return JSValueMakeUndefined(context);
1926 static JSValueRef apiTestGoToCurrentBackForwardItemCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1928 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1929 controller->apiTestGoToCurrentBackForwardItem();
1930 return JSValueMakeUndefined(context);
1933 static JSValueRef setWebViewEditableCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1935 // Has Mac implementation
1936 if (argumentCount < 1)
1937 return JSValueMakeUndefined(context);
1939 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1940 controller->setWebViewEditable(JSValueToBoolean(context, arguments[0]));
1942 return JSValueMakeUndefined(context);
1946 static JSValueRef abortModalCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1948 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1949 controller->abortModal();
1950 return JSValueMakeUndefined(context);
1953 static JSValueRef hasSpellingMarkerCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1955 if (argumentCount != 2)
1956 return JSValueMakeUndefined(context);
1958 int from = JSValueToNumber(context, arguments[0], 0);
1959 int length = JSValueToNumber(context, arguments[1], 0);
1960 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1961 bool ok = controller->hasSpellingMarker(from, length);
1963 return JSValueMakeBoolean(context, ok);
1966 static JSValueRef hasGrammarMarkerCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1968 if (argumentCount != 2)
1969 return JSValueMakeUndefined(context);
1971 int from = JSValueToNumber(context, arguments[0], 0);
1972 int length = JSValueToNumber(context, arguments[1], 0);
1973 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1974 bool ok = controller->hasGrammarMarker(from, length);
1976 return JSValueMakeBoolean(context, ok);
1979 static JSValueRef markerTextForListItemCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1981 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1982 if (argumentCount < 1)
1983 return JSValueMakeUndefined(context);
1984 return JSValueMakeString(context, controller->markerTextForListItem(context, arguments[0]).get());
1987 static JSValueRef authenticateSessionCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1989 // authenticateSession(url, username, password)
1990 if (argumentCount != 3)
1991 return JSValueMakeUndefined(context);
1993 JSRetainPtr<JSStringRef> url(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1994 ASSERT(!*exception);
1995 JSRetainPtr<JSStringRef> username(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1996 ASSERT(!*exception);
1997 JSRetainPtr<JSStringRef> password(Adopt, JSValueToStringCopy(context, arguments[2], exception));
1998 ASSERT(!*exception);
2000 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2001 controller->authenticateSession(url.get(), username.get(), password.get());
2002 return JSValueMakeUndefined(context);
2005 static JSValueRef setEditingBehaviorCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
2007 // The editing behavior string.
2008 if (argumentCount < 1)
2009 return JSValueMakeUndefined(context);
2011 JSRetainPtr<JSStringRef> editingBehavior(Adopt, JSValueToStringCopy(context, arguments[0], exception));
2012 ASSERT(!*exception);
2014 size_t maxLength = JSStringGetMaximumUTF8CStringSize(editingBehavior.get());
2015 char* behaviorBuffer = new char[maxLength + 1];
2016 JSStringGetUTF8CString(editingBehavior.get(), behaviorBuffer, maxLength);
2018 if (strcmp(behaviorBuffer, "mac") && strcmp(behaviorBuffer, "win") && strcmp(behaviorBuffer, "unix")) {
2019 JSRetainPtr<JSStringRef> invalidArgument(JSStringCreateWithUTF8CString("Passed invalid editing behavior. Must be 'mac', 'win', or 'unix'."));
2020 *exception = JSValueMakeString(context, invalidArgument.get());
2021 return JSValueMakeUndefined(context);
2024 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2025 controller->setEditingBehavior(behaviorBuffer);
2027 delete [] behaviorBuffer;
2029 return JSValueMakeUndefined(context);
2032 static JSValueRef setSerializeHTTPLoadsCallback(JSContextRef context, JSObjectRef, JSObjectRef, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
2034 bool serialize = true;
2035 if (argumentCount == 1)
2036 serialize = JSValueToBoolean(context, arguments[0]);
2038 LayoutTestController::setSerializeHTTPLoads(serialize);
2039 return JSValueMakeUndefined(context);
2044 static JSValueRef getGlobalFlagCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
2046 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2047 return JSValueMakeBoolean(context, controller->globalFlag());
2050 static JSValueRef getWebHistoryItemCountCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
2052 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2053 return JSValueMakeNumber(context, controller->webHistoryItemCount());
2056 static JSValueRef getWorkerThreadCountCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
2058 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2059 return JSValueMakeNumber(context, controller->workerThreadCount());
2062 static bool setGlobalFlagCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef value, JSValueRef* exception)
2064 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2065 controller->setGlobalFlag(JSValueToBoolean(context, value));
2069 static JSValueRef setMinimumTimerIntervalCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
2071 if (argumentCount < 1)
2072 return JSValueMakeUndefined(context);
2074 double minimum = JSValueToNumber(context, arguments[0], exception);
2075 ASSERT(!*exception);
2077 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2078 controller->setMinimumTimerInterval(minimum);
2080 return JSValueMakeUndefined(context);
2083 static void layoutTestControllerObjectFinalize(JSObjectRef object)
2085 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(object));
2086 controller->deref();
2091 void LayoutTestController::makeWindowObject(JSContextRef context, JSObjectRef windowObject, JSValueRef* exception)
2093 JSRetainPtr<JSStringRef> layoutTestContollerStr(Adopt, JSStringCreateWithUTF8CString("layoutTestController"));
2096 JSClassRef classRef = getJSClass();
2097 JSValueRef layoutTestContollerObject = JSObjectMake(context, classRef, this);
2098 JSClassRelease(classRef);
2100 JSObjectSetProperty(context, windowObject, layoutTestContollerStr.get(), layoutTestContollerObject, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete, exception);
2103 JSClassRef LayoutTestController::getJSClass()
2105 static JSStaticValue* staticValues = LayoutTestController::staticValues();
2106 static JSStaticFunction* staticFunctions = LayoutTestController::staticFunctions();
2107 static JSClassDefinition classDefinition = {
2108 0, kJSClassAttributeNone, "LayoutTestController", 0, staticValues, staticFunctions,
2109 0, layoutTestControllerObjectFinalize, 0, 0, 0, 0, 0, 0, 0, 0, 0
2112 return JSClassCreate(&classDefinition);
2115 JSStaticValue* LayoutTestController::staticValues()
2117 static JSStaticValue staticValues[] = {
2118 { "globalFlag", getGlobalFlagCallback, setGlobalFlagCallback, kJSPropertyAttributeNone },
2119 { "webHistoryItemCount", getWebHistoryItemCountCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2120 { "workerThreadCount", getWorkerThreadCountCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2123 return staticValues;
2126 JSStaticFunction* LayoutTestController::staticFunctions()
2128 static JSStaticFunction staticFunctions[] = {
2129 { "abortModal", abortModalCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2130 { "addDisallowedURL", addDisallowedURLCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2131 { "addURLToRedirect", addURLToRedirectCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2132 { "addUserScript", addUserScriptCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2133 { "addUserStyleSheet", addUserStyleSheetCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2134 { "apiTestNewWindowDataLoadBaseURL", apiTestNewWindowDataLoadBaseURLCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2135 { "apiTestGoToCurrentBackForwardItem", apiTestGoToCurrentBackForwardItemCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2136 { "callShouldCloseOnWebView", callShouldCloseOnWebViewCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2137 { "clearAllApplicationCaches", clearAllApplicationCachesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2138 { "clearAllDatabases", clearAllDatabasesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2139 { "clearApplicationCacheForOrigin", clearApplicationCacheForOriginCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2140 { "clearBackForwardList", clearBackForwardListCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2141 { "clearPersistentUserStyleSheet", clearPersistentUserStyleSheetCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2142 { "closeWebInspector", closeWebInspectorCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2143 { "computedStyleIncludingVisitedInfo", computedStyleIncludingVisitedInfoCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2144 { "nodesFromRect", nodesFromRectCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2145 { "decodeHostName", decodeHostNameCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2146 { "disableImageLoading", disableImageLoadingCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2147 { "dispatchPendingLoadRequests", dispatchPendingLoadRequestsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2148 { "display", displayCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2149 { "displayInvalidatedRegion", displayInvalidatedRegionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2150 { "dumpApplicationCacheDelegateCallbacks", dumpApplicationCacheDelegateCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2151 { "dumpAsText", dumpAsTextCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2152 { "dumpBackForwardList", dumpBackForwardListCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2153 { "dumpChildFrameScrollPositions", dumpChildFrameScrollPositionsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2154 { "dumpChildFramesAsText", dumpChildFramesAsTextCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2155 { "dumpConfigurationForViewport", dumpConfigurationForViewportCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2156 { "dumpDOMAsWebArchive", dumpDOMAsWebArchiveCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2157 { "dumpDatabaseCallbacks", dumpDatabaseCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2158 { "dumpEditingCallbacks", dumpEditingCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2159 { "dumpFrameLoadCallbacks", dumpFrameLoadCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2160 { "dumpUserGestureInFrameLoadCallbacks", dumpUserGestureInFrameLoadCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2161 { "dumpResourceLoadCallbacks", dumpResourceLoadCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2162 { "dumpResourceResponseMIMETypes", dumpResourceResponseMIMETypesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2163 { "dumpSelectionRect", dumpSelectionRectCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2164 { "dumpSourceAsWebArchive", dumpSourceAsWebArchiveCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2165 { "dumpStatusCallbacks", dumpStatusCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2166 { "dumpTitleChanges", dumpTitleChangesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2167 { "dumpIconChanges", dumpIconChangesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2168 { "dumpWillCacheResponse", dumpWillCacheResponseCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2169 { "elementDoesAutoCompleteForElementWithId", elementDoesAutoCompleteForElementWithIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2170 { "encodeHostName", encodeHostNameCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2171 { "evaluateInWebInspector", evaluateInWebInspectorCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2172 { "evaluateScriptInIsolatedWorld", evaluateScriptInIsolatedWorldCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2173 { "execCommand", execCommandCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2174 { "findString", findStringCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2175 { "counterValueForElementById", counterValueForElementByIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2176 { "originsWithApplicationCache", originsWithApplicationCacheCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2177 { "grantDesktopNotificationPermission", grantDesktopNotificationPermissionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2178 { "hasSpellingMarker", hasSpellingMarkerCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2179 { "hasGrammarMarker", hasGrammarMarkerCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2180 { "isCommandEnabled", isCommandEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2181 { "isPageBoxVisible", isPageBoxVisibleCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2182 { "keepWebHistory", keepWebHistoryCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2183 { "layerTreeAsText", layerTreeAsTextCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2184 { "numberOfPages", numberOfPagesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2185 { "numberOfPendingGeolocationPermissionRequests", numberOfPendingGeolocationPermissionRequestsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2186 { "markerTextForListItem", markerTextForListItemCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2187 { "notifyDone", notifyDoneCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2188 { "numberOfActiveAnimations", numberOfActiveAnimationsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2189 { "suspendAnimations", suspendAnimationsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2190 { "resumeAnimations", resumeAnimationsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2191 { "overridePreference", overridePreferenceCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2192 { "pageNumberForElementById", pageNumberForElementByIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2193 { "pageSizeAndMarginsInPixels", pageSizeAndMarginsInPixelsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2194 { "pageProperty", pagePropertyCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2195 { "pathToLocalResource", pathToLocalResourceCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2196 { "pauseAnimationAtTimeOnElementWithId", pauseAnimationAtTimeOnElementWithIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2197 { "pauseTransitionAtTimeOnElementWithId", pauseTransitionAtTimeOnElementWithIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2198 { "sampleSVGAnimationForElementAtTime", sampleSVGAnimationForElementAtTimeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2199 { "printToPDF", dumpAsPDFCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2200 { "queueBackNavigation", queueBackNavigationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2201 { "queueForwardNavigation", queueForwardNavigationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2202 { "queueLoad", queueLoadCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2203 { "queueLoadHTMLString", queueLoadHTMLStringCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2204 { "queueLoadingScript", queueLoadingScriptCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2205 { "queueNonLoadingScript", queueNonLoadingScriptCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2206 { "queueReload", queueReloadCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2207 { "removeAllVisitedLinks", removeAllVisitedLinksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2208 { "removeOriginAccessWhitelistEntry", removeOriginAccessWhitelistEntryCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2209 { "repaintSweepHorizontally", repaintSweepHorizontallyCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2210 { "setAcceptsEditing", setAcceptsEditingCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2211 { "setAllowUniversalAccessFromFileURLs", setAllowUniversalAccessFromFileURLsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2212 { "setAllowFileAccessFromFileURLs", setAllowFileAccessFromFileURLsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2213 { "setAlwaysAcceptCookies", setAlwaysAcceptCookiesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2214 { "setAppCacheMaximumSize", setAppCacheMaximumSizeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2215 { "setApplicationCacheOriginQuota", setApplicationCacheOriginQuotaCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2216 { "setAuthenticationPassword", setAuthenticationPasswordCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2217 { "setAuthenticationUsername", setAuthenticationUsernameCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2218 { "setAuthorAndUserStylesEnabled", setAuthorAndUserStylesEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2219 { "setAutofilled", setAutofilledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2220 { "setCacheModel", setCacheModelCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2221 { "setCallCloseOnWebViews", setCallCloseOnWebViewsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2222 { "setCanOpenWindows", setCanOpenWindowsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2223 { "setCloseRemainingWindowsWhenComplete", setCloseRemainingWindowsWhenCompleteCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2224 { "setCustomPolicyDelegate", setCustomPolicyDelegateCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2225 { "setDatabaseQuota", setDatabaseQuotaCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2226 { "setDeferMainResourceDataLoad", setDeferMainResourceDataLoadCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2227 { "setDomainRelaxationForbiddenForURLScheme", setDomainRelaxationForbiddenForURLSchemeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2228 { "setEditingBehavior", setEditingBehaviorCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2229 { "setFrameFlatteningEnabled", setFrameFlatteningEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2230 { "setGeolocationPermission", setGeolocationPermissionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2231 { "setHandlesAuthenticationChallenges", setHandlesAuthenticationChallengesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2232 { "setIconDatabaseEnabled", setIconDatabaseEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2233 { "setJavaScriptProfilingEnabled", setJavaScriptProfilingEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2234 { "setMainFrameIsFirstResponder", setMainFrameIsFirstResponderCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2235 { "setMinimumTimerInterval", setMinimumTimerIntervalCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2236 { "setMockDeviceOrientation", setMockDeviceOrientationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2237 { "setMockGeolocationError", setMockGeolocationErrorCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2238 { "setMockGeolocationPosition", setMockGeolocationPositionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2239 { "addMockSpeechInputResult", addMockSpeechInputResultCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2240 { "setNewWindowsCopyBackForwardList", setNewWindowsCopyBackForwardListCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2241 { "setPOSIXLocale", setPOSIXLocaleCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2242 { "setPersistentUserStyleSheetLocation", setPersistentUserStyleSheetLocationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2243 { "setPopupBlockingEnabled", setPopupBlockingEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2244 { "setPluginsEnabled", setPluginsEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2245 { "setPrinting", setPrintingCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2246 { "setPrivateBrowsingEnabled", setPrivateBrowsingEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2247 { "setSelectTrailingWhitespaceEnabled", setSelectTrailingWhitespaceEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2248 { "setSerializeHTTPLoads", setSerializeHTTPLoadsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2249 { "setSmartInsertDeleteEnabled", setSmartInsertDeleteEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2250 { "setSpatialNavigationEnabled", setSpatialNavigationEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2251 { "setStopProvisionalFrameLoads", setStopProvisionalFrameLoadsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2252 { "setTabKeyCyclesThroughElements", setTabKeyCyclesThroughElementsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2253 { "setTimelineProfilingEnabled", setTimelineProfilingEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2254 { "setUseDashboardCompatibilityMode", setUseDashboardCompatibilityModeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2255 { "setUserStyleSheetEnabled", setUserStyleSheetEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2256 { "setUserStyleSheetLocation", setUserStyleSheetLocationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2257 { "setValueForUser", setValueForUserCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2258 { "setViewModeMediaFeature", setViewModeMediaFeatureCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2259 { "setWebViewEditable", setWebViewEditableCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2260 { "setWillSendRequestClearHeader", setWillSendRequestClearHeaderCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2261 { "setWillSendRequestReturnsNull", setWillSendRequestReturnsNullCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2262 { "setWillSendRequestReturnsNullOnRedirect", setWillSendRequestReturnsNullOnRedirectCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2263 { "setWindowIsKey", setWindowIsKeyCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2264 { "setJavaScriptCanAccessClipboard", setJavaScriptCanAccessClipboardCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2265 { "setXSSAuditorEnabled", setXSSAuditorEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2266 { "setAsynchronousSpellCheckingEnabled", setAsynchronousSpellCheckingEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2267 { "showWebInspector", showWebInspectorCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2268 { "testOnscreen", testOnscreenCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2269 { "testRepaint", testRepaintCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2270 { "waitForPolicyDelegate", waitForPolicyDelegateCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2271 { "waitUntilDone", waitUntilDoneCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2272 { "windowCount", windowCountCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2273 { "addOriginAccessWhitelistEntry", addOriginAccessWhitelistEntryCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2274 { "setScrollbarPolicy", setScrollbarPolicyCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2275 { "authenticateSession", authenticateSessionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2276 { "deleteAllLocalStorage", deleteAllLocalStorageCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2277 { "syncLocalStorage", syncLocalStorageCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2278 { "observeStorageTrackerNotifications", observeStorageTrackerNotificationsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2279 { "deleteLocalStorageForOrigin", deleteLocalStorageForOriginCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2280 { "originsWithLocalStorage", originsWithLocalStorageCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2281 { "setShouldPaintBrokenImage", setShouldPaintBrokenImageCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2285 return staticFunctions;
2288 void LayoutTestController::queueLoadHTMLString(JSStringRef content, JSStringRef baseURL)
2290 WorkQueue::shared()->queue(new LoadHTMLStringItem(content, baseURL));
2293 void LayoutTestController::queueLoadAlternateHTMLString(JSStringRef content, JSStringRef baseURL, JSStringRef unreachableURL)
2295 WorkQueue::shared()->queue(new LoadHTMLStringItem(content, baseURL, unreachableURL));
2298 void LayoutTestController::queueBackNavigation(int howFarBack)
2300 WorkQueue::shared()->queue(new BackItem(howFarBack));
2303 void LayoutTestController::queueForwardNavigation(int howFarForward)
2305 WorkQueue::shared()->queue(new ForwardItem(howFarForward));
2308 void LayoutTestController::queueLoadingScript(JSStringRef script)
2310 WorkQueue::shared()->queue(new LoadingScriptItem(script));
2313 void LayoutTestController::queueNonLoadingScript(JSStringRef script)
2315 WorkQueue::shared()->queue(new NonLoadingScriptItem(script));
2318 void LayoutTestController::queueReload()
2320 WorkQueue::shared()->queue(new ReloadItem);
2323 void LayoutTestController::grantDesktopNotificationPermission(JSStringRef origin)
2325 m_desktopNotificationAllowedOrigins.push_back(JSStringRetain(origin));
2328 bool LayoutTestController::checkDesktopNotificationPermission(JSStringRef origin)
2330 std::vector<JSStringRef>::iterator i;
2331 for (i = m_desktopNotificationAllowedOrigins.begin();
2332 i != m_desktopNotificationAllowedOrigins.end();
2334 if (JSStringIsEqual(*i, origin))
2340 void LayoutTestController::waitToDumpWatchdogTimerFired()
2342 const char* message = "FAIL: Timed out waiting for notifyDone to be called\n";
2343 fprintf(stderr, "%s", message);
2344 fprintf(stdout, "%s", message);
2348 void LayoutTestController::setGeolocationPermissionCommon(bool allow)
2350 m_isGeolocationPermissionSet = true;
2351 m_geolocationPermission = allow;
2354 void LayoutTestController::setPOSIXLocale(JSStringRef locale)
2357 JSStringGetUTF8CString(locale, localeBuf, sizeof(localeBuf));
2358 setlocale(LC_ALL, localeBuf);
2361 void LayoutTestController::addURLToRedirect(std::string origin, std::string destination)
2363 m_URLsToRedirect[origin] = destination;
2366 const std::string& LayoutTestController::redirectionDestinationForURL(std::string origin)
2368 return m_URLsToRedirect[origin];
2371 void LayoutTestController::setShouldPaintBrokenImage(bool shouldPaintBrokenImage)
2373 m_shouldPaintBrokenImage = shouldPaintBrokenImage;
2376 const unsigned LayoutTestController::maxViewWidth = 800;
2377 const unsigned LayoutTestController::maxViewHeight = 600;