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)
47 , m_dumpAsAudio(false)
50 , m_dumpBackForwardList(false)
51 , m_dumpChildFrameScrollPositions(false)
52 , m_dumpChildFramesAsText(false)
53 , m_dumpDOMAsWebArchive(false)
54 , m_dumpDatabaseCallbacks(false)
55 , m_dumpEditingCallbacks(false)
56 , m_dumpFrameLoadCallbacks(false)
57 , m_dumpUserGestureInFrameLoadCallbacks(false)
58 , m_dumpHistoryDelegateCallbacks(false)
59 , m_dumpResourceLoadCallbacks(false)
60 , m_dumpResourceResponseMIMETypes(false)
61 , m_dumpSelectionRect(false)
62 , m_dumpSourceAsWebArchive(false)
63 , m_dumpStatusCallbacks(false)
64 , m_dumpTitleChanges(false)
65 , m_dumpIconChanges(false)
66 , m_dumpVisitedLinksCallback(false)
67 , m_dumpWillCacheResponse(false)
68 , m_generatePixelResults(true)
69 , m_callCloseOnWebViews(true)
70 , m_canOpenWindows(false)
71 , m_closeRemainingWindowsWhenComplete(true)
72 , m_newWindowsCopyBackForwardList(false)
73 , m_stopProvisionalFrameLoads(false)
74 , m_testOnscreen(false)
75 , m_testRepaint(false)
76 , m_testRepaintSweepHorizontally(false)
78 , m_willSendRequestReturnsNull(false)
79 , m_willSendRequestReturnsNullOnRedirect(false)
81 , m_alwaysAcceptCookies(false)
83 , m_isGeolocationPermissionSet(false)
84 , m_geolocationPermission(false)
85 , m_handlesAuthenticationChallenges(false)
87 , m_deferMainResourceDataLoad(true)
88 , m_shouldPaintBrokenImage(true)
89 , m_testPathOrURL(testPathOrURL)
90 , m_expectedPixelHash(expectedPixelHash)
94 PassRefPtr<LayoutTestController> LayoutTestController::create(const std::string& testPathOrURL, const std::string& expectedPixelHash)
96 return adoptRef(new LayoutTestController(testPathOrURL, expectedPixelHash));
101 static JSValueRef dumpApplicationCacheDelegateCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
103 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
104 controller->setDumpApplicationCacheDelegateCallbacks(true);
105 return JSValueMakeUndefined(context);
108 static JSValueRef dumpAsPDFCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
110 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
111 controller->setDumpAsPDF(true);
112 return JSValueMakeUndefined(context);
115 static JSValueRef dumpAsTextCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
117 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
118 controller->setDumpAsText(true);
120 // Optional paramater, describing whether it's allowed to dump pixel results in dumpAsText mode.
121 controller->setGeneratePixelResults(argumentCount > 0 ? JSValueToBoolean(context, arguments[0]) : false);
123 return JSValueMakeUndefined(context);
126 static JSValueRef dumpBackForwardListCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
128 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
129 controller->setDumpBackForwardList(true);
130 return JSValueMakeUndefined(context);
133 static JSValueRef dumpChildFramesAsTextCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
135 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
136 controller->setDumpChildFramesAsText(true);
137 return JSValueMakeUndefined(context);
140 static JSValueRef dumpChildFrameScrollPositionsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
142 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
143 controller->setDumpChildFrameScrollPositions(true);
144 return JSValueMakeUndefined(context);
147 static JSValueRef dumpConfigurationForViewportCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
149 if (argumentCount < 2)
150 return JSValueMakeUndefined(context);
153 double deviceDPI = JSValueToNumber(context, arguments[0], exception);
155 double deviceWidth = JSValueToNumber(context, arguments[1], exception);
157 double deviceHeight = JSValueToNumber(context, arguments[2], exception);
159 double availableWidth = JSValueToNumber(context, arguments[3], exception);
161 double availableHeight = JSValueToNumber(context, arguments[4], exception);
164 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
165 controller->dumpConfigurationForViewport(static_cast<int>(deviceDPI), static_cast<int>(deviceWidth), static_cast<int>(deviceHeight), static_cast<int>(availableWidth), static_cast<int>(availableHeight));
167 return JSValueMakeUndefined(context);
170 static JSValueRef dumpDatabaseCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
172 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
173 controller->setDumpDatabaseCallbacks(true);
174 return JSValueMakeUndefined(context);
177 static JSValueRef dumpDOMAsWebArchiveCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
179 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
180 controller->setDumpDOMAsWebArchive(true);
181 return JSValueMakeUndefined(context);
184 static JSValueRef dumpEditingCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
186 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
187 controller->setDumpEditingCallbacks(true);
188 return JSValueMakeUndefined(context);
191 static JSValueRef dumpFrameLoadCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
193 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
194 controller->setDumpFrameLoadCallbacks(true);
195 return JSValueMakeUndefined(context);
198 static JSValueRef dumpUserGestureInFrameLoadCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
200 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
201 controller->setDumpUserGestureInFrameLoadCallbacks(true);
202 return JSValueMakeUndefined(context);
205 static JSValueRef dumpResourceLoadCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
207 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
208 controller->setDumpResourceLoadCallbacks(true);
209 return JSValueMakeUndefined(context);
212 static JSValueRef dumpResourceResponseMIMETypesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
214 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
215 controller->setDumpResourceResponseMIMETypes(true);
216 return JSValueMakeUndefined(context);
219 static JSValueRef dumpSelectionRectCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
221 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
222 controller->setDumpSelectionRect(true);
223 return JSValueMakeUndefined(context);
226 static JSValueRef dumpSourceAsWebArchiveCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
228 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
229 controller->setDumpSourceAsWebArchive(true);
230 return JSValueMakeUndefined(context);
233 static JSValueRef dumpStatusCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
235 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
236 controller->setDumpStatusCallbacks(true);
237 return JSValueMakeUndefined(context);
240 static JSValueRef dumpTitleChangesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
242 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
243 controller->setDumpTitleChanges(true);
244 return JSValueMakeUndefined(context);
247 static JSValueRef dumpIconChangesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
249 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
250 controller->setDumpIconChanges(true);
251 return JSValueMakeUndefined(context);
254 static JSValueRef dumpWillCacheResponseCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
256 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
257 controller->setDumpWillCacheResponse(true);
258 return JSValueMakeUndefined(context);
261 static JSValueRef pathToLocalResourceCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
263 if (argumentCount < 1)
264 return JSValueMakeUndefined(context);
266 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
267 JSRetainPtr<JSStringRef> localPath(Adopt, JSValueToStringCopy(context, arguments[0], exception));
270 JSRetainPtr<JSStringRef> convertedPath(Adopt, controller->pathToLocalResource(context, localPath.get()));
272 return JSValueMakeUndefined(context);
274 return JSValueMakeString(context, convertedPath.get());
277 static JSValueRef removeAllVisitedLinksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
279 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
280 controller->setDumpVisitedLinksCallback(true);
281 controller->removeAllVisitedLinks();
282 return JSValueMakeUndefined(context);
285 static JSValueRef repaintSweepHorizontallyCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
287 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
288 controller->setTestRepaintSweepHorizontally(true);
289 return JSValueMakeUndefined(context);
292 static JSValueRef setCallCloseOnWebViewsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
294 if (argumentCount < 1)
295 return JSValueMakeUndefined(context);
297 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
298 controller->setCallCloseOnWebViews(JSValueToBoolean(context, arguments[0]));
299 return JSValueMakeUndefined(context);
302 static JSValueRef setCanOpenWindowsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
304 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
305 controller->setCanOpenWindows(true);
306 return JSValueMakeUndefined(context);
309 static JSValueRef setCloseRemainingWindowsWhenCompleteCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
311 if (argumentCount < 1)
312 return JSValueMakeUndefined(context);
314 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
315 controller->setCloseRemainingWindowsWhenComplete(JSValueToBoolean(context, arguments[0]));
316 return JSValueMakeUndefined(context);
319 static JSValueRef setEncodedAudioDataCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
321 if (argumentCount < 1)
322 return JSValueMakeUndefined(context);
324 JSRetainPtr<JSStringRef> encodedAudioData(Adopt, JSValueToStringCopy(context, arguments[0], exception));
327 size_t maxLength = JSStringGetMaximumUTF8CStringSize(encodedAudioData.get());
328 OwnArrayPtr<char> encodedAudioDataBuffer = adoptArrayPtr(new char[maxLength + 1]);
329 JSStringGetUTF8CString(encodedAudioData.get(), encodedAudioDataBuffer.get(), maxLength + 1);
331 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
332 controller->setEncodedAudioData(encodedAudioDataBuffer.get());
333 controller->setDumpAsAudio(true);
335 return JSValueMakeUndefined(context);
338 static JSValueRef testOnscreenCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
340 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
341 controller->setTestOnscreen(true);
342 return JSValueMakeUndefined(context);
345 static JSValueRef testRepaintCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
347 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
348 controller->setTestRepaint(true);
349 return JSValueMakeUndefined(context);
352 static JSValueRef addDisallowedURLCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
354 // Has mac implementation
355 if (argumentCount < 1)
356 return JSValueMakeUndefined(context);
358 JSRetainPtr<JSStringRef> url(Adopt, JSValueToStringCopy(context, arguments[0], exception));
361 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
362 controller->addDisallowedURL(url.get());
364 return JSValueMakeUndefined(context);
367 static JSValueRef addURLToRedirectCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
369 if (argumentCount < 2)
370 return JSValueMakeUndefined(context);
372 JSRetainPtr<JSStringRef> origin(Adopt, JSValueToStringCopy(context, arguments[0], exception));
375 JSRetainPtr<JSStringRef> destination(Adopt, JSValueToStringCopy(context, arguments[1], exception));
378 size_t maxLength = JSStringGetMaximumUTF8CStringSize(origin.get());
379 OwnArrayPtr<char> originBuffer = adoptArrayPtr(new char[maxLength + 1]);
380 JSStringGetUTF8CString(origin.get(), originBuffer.get(), maxLength + 1);
382 maxLength = JSStringGetMaximumUTF8CStringSize(destination.get());
383 OwnArrayPtr<char> destinationBuffer = adoptArrayPtr(new char[maxLength + 1]);
384 JSStringGetUTF8CString(destination.get(), destinationBuffer.get(), maxLength + 1);
386 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
387 controller->addURLToRedirect(originBuffer.get(), destinationBuffer.get());
389 return JSValueMakeUndefined(context);
392 static JSValueRef callShouldCloseOnWebViewCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
394 // Has mac & windows implementation
395 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
397 return JSValueMakeBoolean(context, controller->callShouldCloseOnWebView());
400 static JSValueRef clearAllApplicationCachesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
402 // Has mac implementation
403 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
404 controller->clearAllApplicationCaches();
406 return JSValueMakeUndefined(context);
409 static JSValueRef clearApplicationCacheForOriginCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
411 if (argumentCount < 1)
412 return JSValueMakeUndefined(context);
414 JSRetainPtr<JSStringRef> originURL(Adopt, JSValueToStringCopy(context, arguments[0], exception));
417 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
418 controller->clearApplicationCacheForOrigin(originURL.get());
420 return JSValueMakeUndefined(context);
423 static JSValueRef originsWithApplicationCacheCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
425 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
426 return controller->originsWithApplicationCache(context);
429 static JSValueRef clearAllDatabasesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
431 // Has mac & windows implementation
432 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
433 controller->clearAllDatabases();
435 return JSValueMakeUndefined(context);
438 static JSValueRef syncLocalStorageCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
440 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
442 controller->syncLocalStorage();
444 return JSValueMakeUndefined(context);
447 static JSValueRef observeStorageTrackerNotificationsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
449 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
451 if (argumentCount < 1)
452 return JSValueMakeUndefined(context);
454 unsigned numNotifications = JSValueToNumber(context, arguments[0], exception);
458 controller->observeStorageTrackerNotifications(numNotifications);
460 return JSValueMakeUndefined(context);
463 static JSValueRef deleteAllLocalStorageCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
465 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
466 controller->deleteAllLocalStorage();
468 return JSValueMakeUndefined(context);
471 static JSValueRef deleteLocalStorageForOriginCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
473 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
475 if (argumentCount < 1)
476 return JSValueMakeUndefined(context);
478 JSRetainPtr<JSStringRef> url(Adopt, JSValueToStringCopy(context, arguments[0], exception));
481 controller->deleteLocalStorageForOrigin(url.get());
483 return JSValueMakeUndefined(context);
486 static JSValueRef originsWithLocalStorageCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
488 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
489 return controller->originsWithLocalStorage(context);
492 static JSValueRef clearBackForwardListCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
494 // Has mac & windows implementation
495 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
496 controller->clearBackForwardList();
498 return JSValueMakeUndefined(context);
501 static JSValueRef clearPersistentUserStyleSheetCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
503 // Has mac & windows implementation
504 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
505 controller->clearPersistentUserStyleSheet();
507 return JSValueMakeUndefined(context);
510 static JSValueRef decodeHostNameCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
512 // Has mac implementation
513 if (argumentCount < 1)
514 return JSValueMakeUndefined(context);
516 JSRetainPtr<JSStringRef> name(Adopt, JSValueToStringCopy(context, arguments[0], exception));
519 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
520 JSRetainPtr<JSStringRef> decodedHostName(Adopt, controller->copyDecodedHostName(name.get()));
521 return JSValueMakeString(context, decodedHostName.get());
524 static JSValueRef disableImageLoadingCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
526 // Has mac implementation, needs windows implementation
527 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
528 controller->disableImageLoading();
530 return JSValueMakeUndefined(context);
533 static JSValueRef dispatchPendingLoadRequestsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
535 // Has mac implementation, needs windows implementation
536 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
537 controller->dispatchPendingLoadRequests();
539 return JSValueMakeUndefined(context);
542 static JSValueRef displayCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
544 // Has mac & windows implementation
545 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
546 controller->display();
548 return JSValueMakeUndefined(context);
551 static JSValueRef displayInvalidatedRegionCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
553 // Has mac & windows implementation
554 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
555 // LayoutTestController::display() only renders the invalidated region so
556 // we can just use that.
557 controller->display();
559 return JSValueMakeUndefined(context);
562 static JSValueRef encodeHostNameCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
564 // Has mac implementation
565 if (argumentCount < 1)
566 return JSValueMakeUndefined(context);
568 JSRetainPtr<JSStringRef> name(Adopt, JSValueToStringCopy(context, arguments[0], exception));
571 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
572 JSRetainPtr<JSStringRef> encodedHostName(Adopt, controller->copyEncodedHostName(name.get()));
573 return JSValueMakeString(context, encodedHostName.get());
576 static JSValueRef execCommandCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
578 // Has Mac & Windows implementations.
579 if (argumentCount < 1)
580 return JSValueMakeUndefined(context);
582 JSRetainPtr<JSStringRef> name(Adopt, JSValueToStringCopy(context, arguments[0], exception));
585 // Ignoring the second parameter (userInterface), as this command emulates a manual action.
587 JSRetainPtr<JSStringRef> value;
588 if (argumentCount >= 3) {
589 value.adopt(JSValueToStringCopy(context, arguments[2], exception));
592 value.adopt(JSStringCreateWithUTF8CString(""));
595 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
596 controller->execCommand(name.get(), value.get());
598 return JSValueMakeUndefined(context);
601 static JSValueRef findStringCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
603 // Has Mac implementation.
604 if (argumentCount < 2)
605 return JSValueMakeUndefined(context);
607 JSRetainPtr<JSStringRef> target(Adopt, JSValueToStringCopy(context, arguments[0], exception));
610 JSObjectRef options = JSValueToObject(context, arguments[1], exception);
613 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
614 return JSValueMakeBoolean(context, controller->findString(context, target.get(), options));
617 static JSValueRef counterValueForElementByIdCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
619 if (argumentCount < 1)
620 return JSValueMakeUndefined(context);
622 JSRetainPtr<JSStringRef> elementId(Adopt, JSValueToStringCopy(context, arguments[0], exception));
624 return JSValueMakeUndefined(context);
626 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
627 JSRetainPtr<JSStringRef> counterValue(controller->counterValueForElementById(elementId.get()));
628 if (!counterValue.get())
629 return JSValueMakeUndefined(context);
630 return JSValueMakeString(context, counterValue.get());
633 static JSValueRef grantDesktopNotificationPermissionCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
635 // Has Windows implementation
636 if (argumentCount < 1)
637 return JSValueMakeUndefined(context);
639 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
641 controller->grantDesktopNotificationPermission(JSValueToStringCopy(context, arguments[0], NULL));
643 return JSValueMakeUndefined(context);
646 static JSValueRef isCommandEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
648 // Has Mac implementation.
650 if (argumentCount < 1)
651 return JSValueMakeUndefined(context);
653 JSRetainPtr<JSStringRef> name(Adopt, JSValueToStringCopy(context, arguments[0], exception));
656 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
658 return JSValueMakeBoolean(context, controller->isCommandEnabled(name.get()));
661 static JSValueRef overridePreferenceCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
663 if (argumentCount < 2)
664 return JSValueMakeUndefined(context);
666 JSRetainPtr<JSStringRef> key(Adopt, JSValueToStringCopy(context, arguments[0], exception));
668 JSRetainPtr<JSStringRef> value(Adopt, JSValueToStringCopy(context, arguments[1], exception));
671 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
672 controller->overridePreference(key.get(), value.get());
674 return JSValueMakeUndefined(context);
677 static JSValueRef keepWebHistoryCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
679 // Has mac implementation
680 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
681 controller->keepWebHistory();
683 return JSValueMakeUndefined(context);
686 static JSValueRef computedStyleIncludingVisitedInfoCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
688 if (argumentCount != 1)
689 return JSValueMakeUndefined(context);
691 // Has mac implementation
692 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
693 return controller->computedStyleIncludingVisitedInfo(context, arguments[0]);
696 static JSValueRef nodesFromRectCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
698 if (argumentCount != 8)
699 return JSValueMakeUndefined(context);
701 int x = JSValueToNumber(context, arguments[1], NULL);
702 int y = JSValueToNumber(context, arguments[2], NULL);
703 int top = static_cast<unsigned>(JSValueToNumber(context, arguments[3], NULL));
704 int right = static_cast<unsigned>(JSValueToNumber(context, arguments[4], NULL));
705 int bottom = static_cast<unsigned>(JSValueToNumber(context, arguments[5], NULL));
706 int left = static_cast<unsigned>(JSValueToNumber(context, arguments[6], NULL));
707 bool ignoreClipping = JSValueToBoolean(context, arguments[7]);
709 // Has mac implementation.
710 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
711 return controller->nodesFromRect(context, arguments[0], x, y, top, right, bottom, left, ignoreClipping);
714 static JSValueRef layerTreeAsTextCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
716 // Has mac & windows implementation
717 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
718 return JSValueMakeString(context, controller->layerTreeAsText().get());
721 static JSValueRef notifyDoneCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
723 // Has mac & windows implementation
724 // May be able to be made platform independant by using shared WorkQueue
725 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
726 controller->notifyDone();
727 return JSValueMakeUndefined(context);
730 static bool parsePageParameters(JSContextRef context, int argumentCount, const JSValueRef* arguments, JSValueRef* exception, float& pageWidthInPixels, float& pageHeightInPixels)
732 pageWidthInPixels = LayoutTestController::maxViewWidth;
733 pageHeightInPixels = LayoutTestController::maxViewHeight;
734 switch (argumentCount) {
736 pageWidthInPixels = static_cast<float>(JSValueToNumber(context, arguments[0], exception));
739 pageHeightInPixels = static_cast<float>(JSValueToNumber(context, arguments[1], exception));
742 case 0: // Fall through.
750 // Caller needs to delete[] propertyName.
751 static bool parsePagePropertyParameters(JSContextRef context, int argumentCount, const JSValueRef* arguments, JSValueRef* exception, char*& propertyName, int& pageNumber)
754 switch (argumentCount) {
756 pageNumber = static_cast<float>(JSValueToNumber(context, arguments[1], exception));
761 JSRetainPtr<JSStringRef> propertyNameString(Adopt, JSValueToStringCopy(context, arguments[0], exception));
765 size_t maxLength = JSStringGetMaximumUTF8CStringSize(propertyNameString.get());
766 propertyName = new char[maxLength + 1];
767 JSStringGetUTF8CString(propertyNameString.get(), propertyName, maxLength + 1);
776 static bool parsePageNumber(JSContextRef context, int argumentCount, const JSValueRef* arguments, JSValueRef* exception, int& pageNumber)
779 switch (argumentCount) {
781 pageNumber = static_cast<int>(JSValueToNumber(context, arguments[0], exception));
792 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)
796 marginTop = marginRight = marginBottom = marginLeft = 0;
798 switch (argumentCount) {
800 marginLeft = static_cast<int>(JSValueToNumber(context, arguments[6], exception));
805 marginBottom = static_cast<int>(JSValueToNumber(context, arguments[5], exception));
810 marginRight = static_cast<int>(JSValueToNumber(context, arguments[4], exception));
815 marginTop = static_cast<int>(JSValueToNumber(context, arguments[3], exception));
820 height = static_cast<int>(JSValueToNumber(context, arguments[2], exception));
825 width = static_cast<int>(JSValueToNumber(context, arguments[1], exception));
830 pageNumber = static_cast<int>(JSValueToNumber(context, arguments[0], exception));
840 static JSValueRef pageNumberForElementByIdCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
842 float pageWidthInPixels = 0;
843 float pageHeightInPixels = 0;
844 if (!parsePageParameters(context, argumentCount - 1, arguments + 1, exception, pageWidthInPixels, pageHeightInPixels))
845 return JSValueMakeUndefined(context);
847 JSRetainPtr<JSStringRef> elementId(Adopt, JSValueToStringCopy(context, arguments[0], exception));
849 return JSValueMakeUndefined(context);
851 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
852 int pageNumber = controller->pageNumberForElementById(elementId.get(), pageWidthInPixels, pageHeightInPixels);
853 return JSValueMakeNumber(context, pageNumber);
856 static JSValueRef numberOfPagesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
858 float pageWidthInPixels = 0;
859 float pageHeightInPixels = 0;
860 if (!parsePageParameters(context, argumentCount, arguments, exception, pageWidthInPixels, pageHeightInPixels))
861 return JSValueMakeUndefined(context);
863 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
864 return JSValueMakeNumber(context, controller->numberOfPages(pageWidthInPixels, pageHeightInPixels));
867 static JSValueRef numberOfPendingGeolocationPermissionRequestsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
869 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
870 return JSValueMakeNumber(context, controller->numberOfPendingGeolocationPermissionRequests());
873 static JSValueRef pagePropertyCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
875 char* propertyName = 0;
877 if (!parsePagePropertyParameters(context, argumentCount, arguments, exception, propertyName, pageNumber))
878 return JSValueMakeUndefined(context);
880 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
881 JSValueRef value = JSValueMakeString(context, controller->pageProperty(propertyName, pageNumber).get());
883 delete[] propertyName;
887 static JSValueRef isPageBoxVisibleCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
890 if (!parsePageNumber(context, argumentCount, arguments, exception, pageNumber))
891 return JSValueMakeUndefined(context);
893 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
894 return JSValueMakeBoolean(context, controller->isPageBoxVisible(pageNumber));
897 static JSValueRef pageSizeAndMarginsInPixelsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
900 int width = 0, height = 0;
901 int marginTop = 0, marginRight = 0, marginBottom = 0, marginLeft = 0;
902 if (!parsePageNumberSizeMarings(context, argumentCount, arguments, exception, pageNumber, width, height, marginTop, marginRight, marginBottom, marginLeft))
903 return JSValueMakeUndefined(context);
905 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
906 return JSValueMakeString(context, controller->pageSizeAndMarginsInPixels(pageNumber, width, height, marginTop, marginRight, marginBottom, marginLeft).get());
909 static JSValueRef queueBackNavigationCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
911 // Has mac & windows implementation
912 // May be able to be made platform independant by using shared WorkQueue
913 if (argumentCount < 1)
914 return JSValueMakeUndefined(context);
916 double howFarBackDouble = JSValueToNumber(context, arguments[0], exception);
919 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
920 controller->queueBackNavigation(static_cast<int>(howFarBackDouble));
922 return JSValueMakeUndefined(context);
925 static JSValueRef queueForwardNavigationCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
927 // Has mac & windows implementation
928 // May be able to be made platform independant by using shared WorkQueue
929 if (argumentCount < 1)
930 return JSValueMakeUndefined(context);
932 double howFarForwardDouble = JSValueToNumber(context, arguments[0], exception);
935 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
936 controller->queueForwardNavigation(static_cast<int>(howFarForwardDouble));
938 return JSValueMakeUndefined(context);
941 static JSValueRef queueLoadCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
943 // Has mac & windows implementation
944 // May be able to be made platform independant by using shared WorkQueue
945 if (argumentCount < 1)
946 return JSValueMakeUndefined(context);
948 JSRetainPtr<JSStringRef> url(Adopt, JSValueToStringCopy(context, arguments[0], exception));
951 JSRetainPtr<JSStringRef> target;
952 if (argumentCount >= 2) {
953 target.adopt(JSValueToStringCopy(context, arguments[1], exception));
956 target.adopt(JSStringCreateWithUTF8CString(""));
958 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
959 controller->queueLoad(url.get(), target.get());
961 return JSValueMakeUndefined(context);
964 static JSValueRef queueLoadHTMLStringCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
966 // Has Mac & Windows implementation
967 if (argumentCount < 1)
968 return JSValueMakeUndefined(context);
970 JSRetainPtr<JSStringRef> content(Adopt, JSValueToStringCopy(context, arguments[0], exception));
973 JSRetainPtr<JSStringRef> baseURL;
974 if (argumentCount >= 2) {
975 baseURL.adopt(JSValueToStringCopy(context, arguments[1], exception));
978 baseURL.adopt(JSStringCreateWithUTF8CString(""));
980 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
982 if (argumentCount >= 3) {
983 JSRetainPtr<JSStringRef> unreachableURL;
984 unreachableURL.adopt(JSValueToStringCopy(context, arguments[2], exception));
986 controller->queueLoadAlternateHTMLString(content.get(), baseURL.get(), unreachableURL.get());
987 return JSValueMakeUndefined(context);
990 controller->queueLoadHTMLString(content.get(), baseURL.get());
991 return JSValueMakeUndefined(context);
994 static JSValueRef queueReloadCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
996 // Has mac & windows implementation
997 // May be able to be made platform independant by using shared WorkQueue
999 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1000 controller->queueReload();
1002 return JSValueMakeUndefined(context);
1005 static JSValueRef queueLoadingScriptCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1007 // Has mac & windows implementation
1008 // May be able to be made platform independant by using shared WorkQueue
1009 if (argumentCount < 1)
1010 return JSValueMakeUndefined(context);
1012 JSRetainPtr<JSStringRef> script(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1013 ASSERT(!*exception);
1015 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1016 controller->queueLoadingScript(script.get());
1018 return JSValueMakeUndefined(context);
1021 static JSValueRef queueNonLoadingScriptCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1023 // Has mac & windows implementation
1024 // May be able to be made platform independant by using shared WorkQueue
1025 if (argumentCount < 1)
1026 return JSValueMakeUndefined(context);
1028 JSRetainPtr<JSStringRef> script(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1029 ASSERT(!*exception);
1031 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1032 controller->queueNonLoadingScript(script.get());
1034 return JSValueMakeUndefined(context);
1037 static JSValueRef setAcceptsEditingCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1039 // Has mac & windows implementation
1040 if (argumentCount < 1)
1041 return JSValueMakeUndefined(context);
1043 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1044 controller->setAcceptsEditing(JSValueToBoolean(context, arguments[0]));
1046 return JSValueMakeUndefined(context);
1049 static JSValueRef setAlwaysAcceptCookiesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1051 // Has mac & windows implementation
1052 if (argumentCount < 1)
1053 return JSValueMakeUndefined(context);
1055 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1056 controller->setAlwaysAcceptCookies(JSValueToBoolean(context, arguments[0]));
1058 return JSValueMakeUndefined(context);
1061 static JSValueRef setAppCacheMaximumSizeCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1063 // Has mac implementation
1064 if (argumentCount < 1)
1065 return JSValueMakeUndefined(context);
1067 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1069 double size = JSValueToNumber(context, arguments[0], NULL);
1071 controller->setAppCacheMaximumSize(static_cast<unsigned long long>(size));
1073 return JSValueMakeUndefined(context);
1076 static JSValueRef setApplicationCacheOriginQuotaCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1078 // Has mac implementation
1079 if (argumentCount < 1)
1080 return JSValueMakeUndefined(context);
1082 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1084 double size = JSValueToNumber(context, arguments[0], NULL);
1086 controller->setApplicationCacheOriginQuota(static_cast<unsigned long long>(size));
1088 return JSValueMakeUndefined(context);
1091 static JSValueRef setAuthenticationPasswordCallback(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> password(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1098 ASSERT(!*exception);
1100 size_t maxLength = JSStringGetMaximumUTF8CStringSize(password.get());
1101 char* passwordBuffer = new char[maxLength + 1];
1102 JSStringGetUTF8CString(password.get(), passwordBuffer, maxLength + 1);
1104 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1105 controller->setAuthenticationPassword(passwordBuffer);
1106 delete[] passwordBuffer;
1108 return JSValueMakeUndefined(context);
1111 static JSValueRef setAuthenticationUsernameCallback(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 JSRetainPtr<JSStringRef> username(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1118 ASSERT(!*exception);
1120 size_t maxLength = JSStringGetMaximumUTF8CStringSize(username.get());
1121 char* usernameBuffer = new char[maxLength + 1];
1122 JSStringGetUTF8CString(username.get(), usernameBuffer, maxLength + 1);
1124 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1125 controller->setAuthenticationUsername(usernameBuffer);
1126 delete[] usernameBuffer;
1128 return JSValueMakeUndefined(context);
1131 static JSValueRef setAuthorAndUserStylesEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1133 // Has mac & windows implementation
1134 if (argumentCount < 1)
1135 return JSValueMakeUndefined(context);
1137 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1138 controller->setAuthorAndUserStylesEnabled(JSValueToBoolean(context, arguments[0]));
1140 return JSValueMakeUndefined(context);
1143 static JSValueRef setAutofilledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1145 if (argumentCount != 2 || !arguments[0])
1146 return JSValueMakeUndefined(context);
1148 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1149 controller->setAutofilled(context, arguments[0], JSValueToBoolean(context, arguments[1]));
1151 return JSValueMakeUndefined(context);
1154 static JSValueRef setCacheModelCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1156 // Has Mac implementation.
1157 if (argumentCount < 1)
1158 return JSValueMakeUndefined(context);
1160 int cacheModel = JSValueToNumber(context, arguments[0], exception);
1161 ASSERT(!*exception);
1163 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1164 controller->setCacheModel(cacheModel);
1166 return JSValueMakeUndefined(context);
1169 static JSValueRef setCustomPolicyDelegateCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1171 // Has mac implementation
1172 if (argumentCount < 1)
1173 return JSValueMakeUndefined(context);
1175 bool permissive = false;
1176 if (argumentCount >= 2)
1177 permissive = JSValueToBoolean(context, arguments[1]);
1179 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1180 controller->setCustomPolicyDelegate(JSValueToBoolean(context, arguments[0]), permissive);
1182 return JSValueMakeUndefined(context);
1185 static JSValueRef setDatabaseQuotaCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1187 // Has mac implementation
1188 if (argumentCount < 1)
1189 return JSValueMakeUndefined(context);
1191 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1193 double quota = JSValueToNumber(context, arguments[0], NULL);
1195 controller->setDatabaseQuota(static_cast<unsigned long long>(quota));
1197 return JSValueMakeUndefined(context);
1200 static JSValueRef setDeferMainResourceDataLoadCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1202 // Has Mac and Windows implementation
1203 if (argumentCount < 1)
1204 return JSValueMakeUndefined(context);
1206 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1207 controller->setDeferMainResourceDataLoad(JSValueToBoolean(context, arguments[0]));
1209 return JSValueMakeUndefined(context);
1212 static JSValueRef setDomainRelaxationForbiddenForURLSchemeCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1214 // Has Mac and Windows implementation
1215 if (argumentCount < 2)
1216 return JSValueMakeUndefined(context);
1218 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1220 bool forbidden = JSValueToBoolean(context, arguments[0]);
1221 JSRetainPtr<JSStringRef> scheme(Adopt, JSValueToStringCopy(context, arguments[1], 0));
1222 controller->setDomainRelaxationForbiddenForURLScheme(forbidden, scheme.get());
1224 return JSValueMakeUndefined(context);
1227 static JSValueRef setMockDeviceOrientationCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1229 if (argumentCount < 6)
1230 return JSValueMakeUndefined(context);
1232 bool canProvideAlpha = JSValueToBoolean(context, arguments[0]);
1233 double alpha = JSValueToNumber(context, arguments[1], exception);
1234 ASSERT(!*exception);
1235 bool canProvideBeta = JSValueToBoolean(context, arguments[2]);
1236 double beta = JSValueToNumber(context, arguments[3], exception);
1237 ASSERT(!*exception);
1238 bool canProvideGamma = JSValueToBoolean(context, arguments[4]);
1239 double gamma = JSValueToNumber(context, arguments[5], exception);
1240 ASSERT(!*exception);
1242 LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1243 controller->setMockDeviceOrientation(canProvideAlpha, alpha, canProvideBeta, beta, canProvideGamma, gamma);
1245 return JSValueMakeUndefined(context);
1248 static JSValueRef setMockGeolocationPositionCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1250 if (argumentCount < 3)
1251 return JSValueMakeUndefined(context);
1253 LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1254 controller->setMockGeolocationPosition(JSValueToNumber(context, arguments[0], NULL), // latitude
1255 JSValueToNumber(context, arguments[1], NULL), // longitude
1256 JSValueToNumber(context, arguments[2], NULL)); // accuracy
1258 return JSValueMakeUndefined(context);
1261 static JSValueRef setMockGeolocationErrorCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1263 if (argumentCount < 2)
1264 return JSValueMakeUndefined(context);
1266 int code = JSValueToNumber(context, arguments[0], NULL);
1267 JSRetainPtr<JSStringRef> message(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1268 ASSERT(!*exception);
1270 LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1271 controller->setMockGeolocationError(code, message.get());
1273 return JSValueMakeUndefined(context);
1276 static JSValueRef addMockSpeechInputResultCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1278 if (argumentCount < 3)
1279 return JSValueMakeUndefined(context);
1281 JSRetainPtr<JSStringRef> result(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1282 ASSERT(!*exception);
1284 double confidence = JSValueToNumber(context, arguments[1], exception);
1286 JSRetainPtr<JSStringRef> language(Adopt, JSValueToStringCopy(context, arguments[2], exception));
1287 ASSERT(!*exception);
1289 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1290 controller->addMockSpeechInputResult(result.get(), confidence, language.get());
1292 return JSValueMakeUndefined(context);
1295 static JSValueRef setNewWindowsCopyBackForwardListCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1297 // Has mac implementation
1298 if (argumentCount < 1)
1299 return JSValueMakeUndefined(context);
1301 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1302 controller->setNewWindowsCopyBackForwardList(JSValueToBoolean(context, arguments[0]));
1304 return JSValueMakeUndefined(context);
1307 static JSValueRef setGeolocationPermissionCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1309 // Has mac implementation
1310 if (argumentCount < 1)
1311 return JSValueMakeUndefined(context);
1313 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1314 controller->setGeolocationPermission(JSValueToBoolean(context, arguments[0]));
1316 return JSValueMakeUndefined(context);
1319 static JSValueRef setHandlesAuthenticationChallengesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1321 // Has mac & windows implementation
1322 if (argumentCount < 1)
1323 return JSValueMakeUndefined(context);
1325 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1326 controller->setHandlesAuthenticationChallenges(JSValueToBoolean(context, arguments[0]));
1328 return JSValueMakeUndefined(context);
1331 static JSValueRef setPOSIXLocaleCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1333 if (argumentCount < 1)
1334 return JSValueMakeUndefined(context);
1336 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1337 JSRetainPtr<JSStringRef> locale(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1338 ASSERT(!*exception);
1339 controller->setPOSIXLocale(locale.get());
1341 return JSValueMakeUndefined(context);
1344 static JSValueRef setIconDatabaseEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1346 // Has mac & windows implementation
1347 if (argumentCount < 1)
1348 return JSValueMakeUndefined(context);
1350 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1351 controller->setIconDatabaseEnabled(JSValueToBoolean(context, arguments[0]));
1353 return JSValueMakeUndefined(context);
1356 static JSValueRef setJavaScriptProfilingEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1358 if (argumentCount < 1)
1359 return JSValueMakeUndefined(context);
1361 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1362 controller->setJavaScriptProfilingEnabled(JSValueToBoolean(context, arguments[0]));
1364 return JSValueMakeUndefined(context);
1367 static JSValueRef setMainFrameIsFirstResponderCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1369 // Has mac implementation
1370 if (argumentCount < 1)
1371 return JSValueMakeUndefined(context);
1373 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1374 controller->setMainFrameIsFirstResponder(JSValueToBoolean(context, arguments[0]));
1376 return JSValueMakeUndefined(context);
1379 static JSValueRef setPersistentUserStyleSheetLocationCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1381 // Has mac implementation
1382 if (argumentCount < 1)
1383 return JSValueMakeUndefined(context);
1385 JSRetainPtr<JSStringRef> path(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1386 ASSERT(!*exception);
1388 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1389 controller->setPersistentUserStyleSheetLocation(path.get());
1391 return JSValueMakeUndefined(context);
1394 static JSValueRef setPrivateBrowsingEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1396 // Has mac & windows implementation
1397 if (argumentCount < 1)
1398 return JSValueMakeUndefined(context);
1400 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1401 controller->setPrivateBrowsingEnabled(JSValueToBoolean(context, arguments[0]));
1403 return JSValueMakeUndefined(context);
1406 static JSValueRef setJavaScriptCanAccessClipboardCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1408 // Has mac & windows implementation
1409 if (argumentCount < 1)
1410 return JSValueMakeUndefined(context);
1412 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1413 controller->setJavaScriptCanAccessClipboard(JSValueToBoolean(context, arguments[0]));
1415 return JSValueMakeUndefined(context);
1418 static JSValueRef setXSSAuditorEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1420 // Has mac & windows implementation
1421 if (argumentCount < 1)
1422 return JSValueMakeUndefined(context);
1424 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1425 controller->setXSSAuditorEnabled(JSValueToBoolean(context, arguments[0]));
1427 return JSValueMakeUndefined(context);
1430 static JSValueRef setSpatialNavigationEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1432 // Has mac implementation.
1433 if (argumentCount < 1)
1434 return JSValueMakeUndefined(context);
1436 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1437 controller->setSpatialNavigationEnabled(JSValueToBoolean(context, arguments[0]));
1439 return JSValueMakeUndefined(context);
1442 static JSValueRef setPrintingCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1444 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1445 controller->setIsPrinting(true);
1446 return JSValueMakeUndefined(context);
1450 static JSValueRef setFrameFlatteningEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1452 // Has mac & windows implementation
1453 if (argumentCount < 1)
1454 return JSValueMakeUndefined(context);
1456 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1457 controller->setFrameFlatteningEnabled(JSValueToBoolean(context, arguments[0]));
1459 return JSValueMakeUndefined(context);
1462 static JSValueRef setAllowUniversalAccessFromFileURLsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1464 // Has mac & windows implementation
1465 if (argumentCount < 1)
1466 return JSValueMakeUndefined(context);
1468 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1469 controller->setAllowUniversalAccessFromFileURLs(JSValueToBoolean(context, arguments[0]));
1471 return JSValueMakeUndefined(context);
1474 static JSValueRef setAllowFileAccessFromFileURLsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1476 // Has mac & windows implementation
1477 if (argumentCount < 1)
1478 return JSValueMakeUndefined(context);
1480 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1481 controller->setAllowFileAccessFromFileURLs(JSValueToBoolean(context, arguments[0]));
1483 return JSValueMakeUndefined(context);
1486 static JSValueRef setTabKeyCyclesThroughElementsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1488 // Has mac & windows implementation
1489 if (argumentCount < 1)
1490 return JSValueMakeUndefined(context);
1492 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1493 controller->setTabKeyCyclesThroughElements(JSValueToBoolean(context, arguments[0]));
1495 return JSValueMakeUndefined(context);
1498 static JSValueRef setTimelineProfilingEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1500 if (argumentCount < 1)
1501 return JSValueMakeUndefined(context);
1503 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1504 controller->setTimelineProfilingEnabled(JSValueToBoolean(context, arguments[0]));
1505 return JSValueMakeUndefined(context);
1508 static JSValueRef setUseDashboardCompatibilityModeCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1510 // Has mac implementation
1511 if (argumentCount < 1)
1512 return JSValueMakeUndefined(context);
1514 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1515 controller->setUseDashboardCompatibilityMode(JSValueToBoolean(context, arguments[0]));
1517 return JSValueMakeUndefined(context);
1520 static JSValueRef setUserStyleSheetEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1522 // Has mac implementation
1523 if (argumentCount < 1)
1524 return JSValueMakeUndefined(context);
1526 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1527 controller->setUserStyleSheetEnabled(JSValueToBoolean(context, arguments[0]));
1529 return JSValueMakeUndefined(context);
1532 static JSValueRef setUserStyleSheetLocationCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1534 // Has mac implementation
1535 if (argumentCount < 1)
1536 return JSValueMakeUndefined(context);
1538 JSRetainPtr<JSStringRef> path(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1539 ASSERT(!*exception);
1541 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1542 controller->setUserStyleSheetLocation(path.get());
1544 return JSValueMakeUndefined(context);
1547 static JSValueRef setValueForUserCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1549 // Has mac implementation
1550 if (argumentCount != 2)
1551 return JSValueMakeUndefined(context);
1553 JSRetainPtr<JSStringRef> value(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1554 ASSERT(!*exception);
1556 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1557 controller->setValueForUser(context, arguments[0], value.get());
1559 return JSValueMakeUndefined(context);
1562 static JSValueRef setViewModeMediaFeatureCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1564 // Has mac implementation
1565 if (argumentCount < 1)
1566 return JSValueMakeUndefined(context);
1568 JSRetainPtr<JSStringRef> mode(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1569 ASSERT(!*exception);
1571 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1572 controller->setViewModeMediaFeature(mode.get());
1574 return JSValueMakeUndefined(context);
1577 static JSValueRef setWillSendRequestClearHeaderCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1579 // Has mac & windows implementation
1580 if (argumentCount < 1)
1581 return JSValueMakeUndefined(context);
1583 JSRetainPtr<JSStringRef> header(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1584 ASSERT(!*exception);
1586 size_t maxLength = JSStringGetMaximumUTF8CStringSize(header.get());
1587 OwnArrayPtr<char> headerBuffer = adoptArrayPtr(new char[maxLength + 1]);
1588 JSStringGetUTF8CString(header.get(), headerBuffer.get(), maxLength + 1);
1590 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1591 controller->setWillSendRequestClearHeader(headerBuffer.get());
1593 return JSValueMakeUndefined(context);
1596 static JSValueRef setWillSendRequestReturnsNullCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1598 // Has cross-platform implementation
1599 if (argumentCount < 1)
1600 return JSValueMakeUndefined(context);
1602 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1603 controller->setWillSendRequestReturnsNull(JSValueToBoolean(context, arguments[0]));
1605 return JSValueMakeUndefined(context);
1608 static JSValueRef setWillSendRequestReturnsNullOnRedirectCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1610 // Has cross-platform implementation
1611 if (argumentCount < 1)
1612 return JSValueMakeUndefined(context);
1614 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1615 controller->setWillSendRequestReturnsNullOnRedirect(JSValueToBoolean(context, arguments[0]));
1617 return JSValueMakeUndefined(context);
1620 static JSValueRef setWindowIsKeyCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1622 // Has mac implementation
1623 if (argumentCount < 1)
1624 return JSValueMakeUndefined(context);
1626 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1627 controller->setWindowIsKey(JSValueToBoolean(context, arguments[0]));
1629 return JSValueMakeUndefined(context);
1632 static JSValueRef waitUntilDoneCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1634 // Has mac & windows implementation
1635 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1636 controller->setWaitToDump(true);
1638 return JSValueMakeUndefined(context);
1641 static JSValueRef windowCountCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1643 // Has mac implementation
1644 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1645 int windows = controller->windowCount();
1646 return JSValueMakeNumber(context, windows);
1649 static JSValueRef setPopupBlockingEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1651 // Has mac & windows implementation
1652 if (argumentCount < 1)
1653 return JSValueMakeUndefined(context);
1655 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1656 controller->setPopupBlockingEnabled(JSValueToBoolean(context, arguments[0]));
1658 return JSValueMakeUndefined(context);
1661 static JSValueRef setPluginsEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1663 // Has mac & windows implementation
1664 if (argumentCount < 1)
1665 return JSValueMakeUndefined(context);
1667 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1668 controller->setPluginsEnabled(JSValueToBoolean(context, arguments[0]));
1670 return JSValueMakeUndefined(context);
1673 static JSValueRef setSmartInsertDeleteEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1675 if (argumentCount < 1)
1676 return JSValueMakeUndefined(context);
1678 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1679 controller->setSmartInsertDeleteEnabled(JSValueToBoolean(context, arguments[0]));
1680 return JSValueMakeUndefined(context);
1683 static JSValueRef setSelectTrailingWhitespaceEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1685 if (argumentCount < 1)
1686 return JSValueMakeUndefined(context);
1688 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1689 controller->setSelectTrailingWhitespaceEnabled(JSValueToBoolean(context, arguments[0]));
1690 return JSValueMakeUndefined(context);
1693 static JSValueRef setStopProvisionalFrameLoadsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1695 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1696 controller->setStopProvisionalFrameLoads(true);
1697 return JSValueMakeUndefined(context);
1700 static JSValueRef setAsynchronousSpellCheckingEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1702 if (argumentCount < 1)
1703 return JSValueMakeUndefined(context);
1705 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1706 controller->setAsynchronousSpellCheckingEnabled(JSValueToBoolean(context, arguments[0]));
1707 return JSValueMakeUndefined(context);
1710 static JSValueRef shadowRootCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1712 if (argumentCount != 1)
1713 return JSValueMakeUndefined(context);
1714 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1715 return controller->shadowRoot(context, arguments[0]);
1718 static JSValueRef ensureShadowRootCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1720 if (argumentCount != 1)
1721 return JSValueMakeUndefined(context);
1722 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1723 return controller->ensureShadowRoot(context, arguments[0]);
1726 static JSValueRef removeShadowRootCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1728 if (argumentCount != 1)
1729 return JSValueMakeUndefined(context);
1731 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1732 controller->removeShadowRoot(context, arguments[0]);
1734 return JSValueMakeUndefined(context);
1737 static JSValueRef showWebInspectorCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1739 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1740 controller->showWebInspector();
1741 return JSValueMakeUndefined(context);
1744 static JSValueRef closeWebInspectorCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1746 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1747 controller->setTimelineProfilingEnabled(false);
1748 controller->closeWebInspector();
1749 return JSValueMakeUndefined(context);
1752 static JSValueRef evaluateInWebInspectorCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1754 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1755 double callId = JSValueToNumber(context, arguments[0], exception);
1756 ASSERT(!*exception);
1757 JSRetainPtr<JSStringRef> script(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1758 ASSERT(!*exception);
1760 controller->evaluateInWebInspector(static_cast<long>(callId), script.get());
1761 return JSValueMakeUndefined(context);
1764 static JSValueRef evaluateScriptInIsolatedWorldCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1766 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1767 double worldID = JSValueToNumber(context, arguments[0], exception);
1768 ASSERT(!*exception);
1769 JSRetainPtr<JSStringRef> script(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1770 ASSERT(!*exception);
1772 controller->evaluateScriptInIsolatedWorld(static_cast<unsigned>(worldID), JSContextGetGlobalObject(context), script.get());
1773 return JSValueMakeUndefined(context);
1776 static JSValueRef elementDoesAutoCompleteForElementWithIdCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1778 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1779 JSRetainPtr<JSStringRef> elementId(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1780 ASSERT(!*exception);
1782 bool autoCompletes = controller->elementDoesAutoCompleteForElementWithId(elementId.get());
1784 return JSValueMakeBoolean(context, autoCompletes);
1787 static JSValueRef pauseAnimationAtTimeOnElementWithIdCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1789 if (argumentCount != 3)
1790 return JSValueMakeUndefined(context);
1792 JSRetainPtr<JSStringRef> animationName(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1793 ASSERT(!*exception);
1794 double time = JSValueToNumber(context, arguments[1], exception);
1795 ASSERT(!*exception);
1796 JSRetainPtr<JSStringRef> elementId(Adopt, JSValueToStringCopy(context, arguments[2], exception));
1797 ASSERT(!*exception);
1799 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1800 return JSValueMakeBoolean(context, controller->pauseAnimationAtTimeOnElementWithId(animationName.get(), time, elementId.get()));
1803 static JSValueRef pauseTransitionAtTimeOnElementWithIdCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1805 if (argumentCount != 3)
1806 return JSValueMakeUndefined(context);
1808 JSRetainPtr<JSStringRef> propertyName(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1809 ASSERT(!*exception);
1810 double time = JSValueToNumber(context, arguments[1], exception);
1811 ASSERT(!*exception);
1812 JSRetainPtr<JSStringRef> elementId(Adopt, JSValueToStringCopy(context, arguments[2], exception));
1813 ASSERT(!*exception);
1815 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1816 return JSValueMakeBoolean(context, controller->pauseTransitionAtTimeOnElementWithId(propertyName.get(), time, elementId.get()));
1819 static JSValueRef sampleSVGAnimationForElementAtTimeCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1821 if (argumentCount != 3)
1822 return JSValueMakeUndefined(context);
1824 JSRetainPtr<JSStringRef> animationId(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1825 ASSERT(!*exception);
1826 double time = JSValueToNumber(context, arguments[1], exception);
1827 ASSERT(!*exception);
1828 JSRetainPtr<JSStringRef> elementId(Adopt, JSValueToStringCopy(context, arguments[2], exception));
1829 ASSERT(!*exception);
1831 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1832 return JSValueMakeBoolean(context, controller->sampleSVGAnimationForElementAtTime(animationId.get(), time, elementId.get()));
1835 static JSValueRef numberOfActiveAnimationsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1837 if (argumentCount != 0)
1838 return JSValueMakeUndefined(context);
1840 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1841 return JSValueMakeNumber(context, controller->numberOfActiveAnimations());
1844 static JSValueRef suspendAnimationsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1846 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1847 controller->suspendAnimations();
1848 return JSValueMakeUndefined(context);
1851 static JSValueRef resumeAnimationsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1853 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1854 controller->resumeAnimations();
1855 return JSValueMakeUndefined(context);
1858 static JSValueRef waitForPolicyDelegateCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t, const JSValueRef[], JSValueRef*)
1860 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1861 controller->waitForPolicyDelegate();
1862 return JSValueMakeUndefined(context);
1865 static JSValueRef addOriginAccessWhitelistEntryCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1867 if (argumentCount != 4)
1868 return JSValueMakeUndefined(context);
1870 JSRetainPtr<JSStringRef> sourceOrigin(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1871 ASSERT(!*exception);
1872 JSRetainPtr<JSStringRef> destinationProtocol(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1873 ASSERT(!*exception);
1874 JSRetainPtr<JSStringRef> destinationHost(Adopt, JSValueToStringCopy(context, arguments[2], exception));
1875 ASSERT(!*exception);
1876 bool allowDestinationSubdomains = JSValueToBoolean(context, arguments[3]);
1878 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1879 controller->addOriginAccessWhitelistEntry(sourceOrigin.get(), destinationProtocol.get(), destinationHost.get(), allowDestinationSubdomains);
1880 return JSValueMakeUndefined(context);
1883 static JSValueRef removeOriginAccessWhitelistEntryCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1885 if (argumentCount != 4)
1886 return JSValueMakeUndefined(context);
1888 JSRetainPtr<JSStringRef> sourceOrigin(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1889 ASSERT(!*exception);
1890 JSRetainPtr<JSStringRef> destinationProtocol(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1891 ASSERT(!*exception);
1892 JSRetainPtr<JSStringRef> destinationHost(Adopt, JSValueToStringCopy(context, arguments[2], exception));
1893 ASSERT(!*exception);
1894 bool allowDestinationSubdomains = JSValueToBoolean(context, arguments[3]);
1896 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1897 controller->removeOriginAccessWhitelistEntry(sourceOrigin.get(), destinationProtocol.get(), destinationHost.get(), allowDestinationSubdomains);
1898 return JSValueMakeUndefined(context);
1901 static JSValueRef setScrollbarPolicyCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1903 if (argumentCount != 2)
1904 return JSValueMakeUndefined(context);
1906 JSRetainPtr<JSStringRef> orientation(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1907 ASSERT(!*exception);
1908 JSRetainPtr<JSStringRef> policy(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1909 ASSERT(!*exception);
1911 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1912 controller->setScrollbarPolicy(orientation.get(), policy.get());
1913 return JSValueMakeUndefined(context);
1916 static JSValueRef addUserScriptCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1918 if (argumentCount != 3)
1919 return JSValueMakeUndefined(context);
1921 JSRetainPtr<JSStringRef> source(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1922 ASSERT(!*exception);
1923 bool runAtStart = JSValueToBoolean(context, arguments[1]);
1924 bool allFrames = JSValueToBoolean(context, arguments[2]);
1926 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1927 controller->addUserScript(source.get(), runAtStart, allFrames);
1928 return JSValueMakeUndefined(context);
1931 static JSValueRef addUserStyleSheetCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1933 if (argumentCount != 2)
1934 return JSValueMakeUndefined(context);
1936 JSRetainPtr<JSStringRef> source(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1937 ASSERT(!*exception);
1938 bool allFrames = JSValueToBoolean(context, arguments[1]);
1940 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1941 controller->addUserStyleSheet(source.get(), allFrames);
1942 return JSValueMakeUndefined(context);
1945 static JSValueRef setShouldPaintBrokenImageCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1947 // Has Mac implementation
1948 if (argumentCount < 1)
1949 return JSValueMakeUndefined(context);
1951 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1952 controller->setShouldPaintBrokenImage(JSValueToBoolean(context, arguments[0]));
1954 return JSValueMakeUndefined(context);
1957 static JSValueRef apiTestNewWindowDataLoadBaseURLCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1959 if (argumentCount != 2)
1960 return JSValueMakeUndefined(context);
1962 JSRetainPtr<JSStringRef> utf8Data(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1963 ASSERT(!*exception);
1965 JSRetainPtr<JSStringRef> baseURL(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1966 ASSERT(!*exception);
1968 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1969 controller->apiTestNewWindowDataLoadBaseURL(utf8Data.get(), baseURL.get());
1970 return JSValueMakeUndefined(context);
1973 static JSValueRef apiTestGoToCurrentBackForwardItemCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1975 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1976 controller->apiTestGoToCurrentBackForwardItem();
1977 return JSValueMakeUndefined(context);
1980 static JSValueRef setWebViewEditableCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1982 // Has Mac implementation
1983 if (argumentCount < 1)
1984 return JSValueMakeUndefined(context);
1986 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1987 controller->setWebViewEditable(JSValueToBoolean(context, arguments[0]));
1989 return JSValueMakeUndefined(context);
1993 static JSValueRef abortModalCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1995 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1996 controller->abortModal();
1997 return JSValueMakeUndefined(context);
2000 static JSValueRef hasSpellingMarkerCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
2002 if (argumentCount != 2)
2003 return JSValueMakeUndefined(context);
2005 int from = JSValueToNumber(context, arguments[0], 0);
2006 int length = JSValueToNumber(context, arguments[1], 0);
2007 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2008 bool ok = controller->hasSpellingMarker(from, length);
2010 return JSValueMakeBoolean(context, ok);
2013 static JSValueRef hasGrammarMarkerCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
2015 if (argumentCount != 2)
2016 return JSValueMakeUndefined(context);
2018 int from = JSValueToNumber(context, arguments[0], 0);
2019 int length = JSValueToNumber(context, arguments[1], 0);
2020 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2021 bool ok = controller->hasGrammarMarker(from, length);
2023 return JSValueMakeBoolean(context, ok);
2026 static JSValueRef markerTextForListItemCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
2028 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2029 if (argumentCount < 1)
2030 return JSValueMakeUndefined(context);
2031 return JSValueMakeString(context, controller->markerTextForListItem(context, arguments[0]).get());
2034 static JSValueRef authenticateSessionCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
2036 // authenticateSession(url, username, password)
2037 if (argumentCount != 3)
2038 return JSValueMakeUndefined(context);
2040 JSRetainPtr<JSStringRef> url(Adopt, JSValueToStringCopy(context, arguments[0], exception));
2041 ASSERT(!*exception);
2042 JSRetainPtr<JSStringRef> username(Adopt, JSValueToStringCopy(context, arguments[1], exception));
2043 ASSERT(!*exception);
2044 JSRetainPtr<JSStringRef> password(Adopt, JSValueToStringCopy(context, arguments[2], exception));
2045 ASSERT(!*exception);
2047 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2048 controller->authenticateSession(url.get(), username.get(), password.get());
2049 return JSValueMakeUndefined(context);
2052 static JSValueRef setEditingBehaviorCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
2054 // The editing behavior string.
2055 if (argumentCount < 1)
2056 return JSValueMakeUndefined(context);
2058 JSRetainPtr<JSStringRef> editingBehavior(Adopt, JSValueToStringCopy(context, arguments[0], exception));
2059 ASSERT(!*exception);
2061 size_t maxLength = JSStringGetMaximumUTF8CStringSize(editingBehavior.get());
2062 char* behaviorBuffer = new char[maxLength + 1];
2063 JSStringGetUTF8CString(editingBehavior.get(), behaviorBuffer, maxLength);
2065 if (strcmp(behaviorBuffer, "mac") && strcmp(behaviorBuffer, "win") && strcmp(behaviorBuffer, "unix")) {
2066 JSRetainPtr<JSStringRef> invalidArgument(JSStringCreateWithUTF8CString("Passed invalid editing behavior. Must be 'mac', 'win', or 'unix'."));
2067 *exception = JSValueMakeString(context, invalidArgument.get());
2068 return JSValueMakeUndefined(context);
2071 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2072 controller->setEditingBehavior(behaviorBuffer);
2074 delete [] behaviorBuffer;
2076 return JSValueMakeUndefined(context);
2079 static JSValueRef setSerializeHTTPLoadsCallback(JSContextRef context, JSObjectRef, JSObjectRef, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
2081 bool serialize = true;
2082 if (argumentCount == 1)
2083 serialize = JSValueToBoolean(context, arguments[0]);
2085 LayoutTestController::setSerializeHTTPLoads(serialize);
2086 return JSValueMakeUndefined(context);
2089 static JSValueRef shadowPseudoIdCallback(JSContextRef context, JSObjectRef thisObject, JSObjectRef, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
2091 if (argumentCount < 1)
2092 return JSValueMakeUndefined(context);
2094 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2096 return JSValueMakeString(context, controller->shadowPseudoId(context, arguments[0]).get());
2101 static JSValueRef getGlobalFlagCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
2103 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2104 return JSValueMakeBoolean(context, controller->globalFlag());
2107 static JSValueRef getWebHistoryItemCountCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
2109 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2110 return JSValueMakeNumber(context, controller->webHistoryItemCount());
2113 static JSValueRef getWorkerThreadCountCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
2115 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2116 return JSValueMakeNumber(context, controller->workerThreadCount());
2119 static bool setGlobalFlagCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef value, JSValueRef* exception)
2121 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2122 controller->setGlobalFlag(JSValueToBoolean(context, value));
2126 static JSValueRef setMinimumTimerIntervalCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
2128 if (argumentCount < 1)
2129 return JSValueMakeUndefined(context);
2131 double minimum = JSValueToNumber(context, arguments[0], exception);
2132 ASSERT(!*exception);
2134 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2135 controller->setMinimumTimerInterval(minimum);
2137 return JSValueMakeUndefined(context);
2140 static void layoutTestControllerObjectFinalize(JSObjectRef object)
2142 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(object));
2143 controller->deref();
2148 void LayoutTestController::makeWindowObject(JSContextRef context, JSObjectRef windowObject, JSValueRef* exception)
2150 JSRetainPtr<JSStringRef> layoutTestContollerStr(Adopt, JSStringCreateWithUTF8CString("layoutTestController"));
2153 JSClassRef classRef = getJSClass();
2154 JSValueRef layoutTestContollerObject = JSObjectMake(context, classRef, this);
2155 JSClassRelease(classRef);
2157 JSObjectSetProperty(context, windowObject, layoutTestContollerStr.get(), layoutTestContollerObject, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete, exception);
2160 JSClassRef LayoutTestController::getJSClass()
2162 static JSStaticValue* staticValues = LayoutTestController::staticValues();
2163 static JSStaticFunction* staticFunctions = LayoutTestController::staticFunctions();
2164 static JSClassDefinition classDefinition = {
2165 0, kJSClassAttributeNone, "LayoutTestController", 0, staticValues, staticFunctions,
2166 0, layoutTestControllerObjectFinalize, 0, 0, 0, 0, 0, 0, 0, 0, 0
2169 return JSClassCreate(&classDefinition);
2172 JSStaticValue* LayoutTestController::staticValues()
2174 static JSStaticValue staticValues[] = {
2175 { "globalFlag", getGlobalFlagCallback, setGlobalFlagCallback, kJSPropertyAttributeNone },
2176 { "webHistoryItemCount", getWebHistoryItemCountCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2177 { "workerThreadCount", getWorkerThreadCountCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2180 return staticValues;
2183 JSStaticFunction* LayoutTestController::staticFunctions()
2185 static JSStaticFunction staticFunctions[] = {
2186 { "abortModal", abortModalCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2187 { "addDisallowedURL", addDisallowedURLCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2188 { "addURLToRedirect", addURLToRedirectCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2189 { "addUserScript", addUserScriptCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2190 { "addUserStyleSheet", addUserStyleSheetCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2191 { "apiTestNewWindowDataLoadBaseURL", apiTestNewWindowDataLoadBaseURLCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2192 { "apiTestGoToCurrentBackForwardItem", apiTestGoToCurrentBackForwardItemCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2193 { "callShouldCloseOnWebView", callShouldCloseOnWebViewCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2194 { "clearAllApplicationCaches", clearAllApplicationCachesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2195 { "clearAllDatabases", clearAllDatabasesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2196 { "clearApplicationCacheForOrigin", clearApplicationCacheForOriginCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2197 { "clearBackForwardList", clearBackForwardListCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2198 { "clearPersistentUserStyleSheet", clearPersistentUserStyleSheetCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2199 { "closeWebInspector", closeWebInspectorCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2200 { "computedStyleIncludingVisitedInfo", computedStyleIncludingVisitedInfoCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2201 { "nodesFromRect", nodesFromRectCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2202 { "decodeHostName", decodeHostNameCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2203 { "disableImageLoading", disableImageLoadingCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2204 { "dispatchPendingLoadRequests", dispatchPendingLoadRequestsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2205 { "display", displayCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2206 { "displayInvalidatedRegion", displayInvalidatedRegionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2207 { "dumpApplicationCacheDelegateCallbacks", dumpApplicationCacheDelegateCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2208 { "dumpAsText", dumpAsTextCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2209 { "dumpBackForwardList", dumpBackForwardListCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2210 { "dumpChildFrameScrollPositions", dumpChildFrameScrollPositionsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2211 { "dumpChildFramesAsText", dumpChildFramesAsTextCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2212 { "dumpConfigurationForViewport", dumpConfigurationForViewportCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2213 { "dumpDOMAsWebArchive", dumpDOMAsWebArchiveCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2214 { "dumpDatabaseCallbacks", dumpDatabaseCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2215 { "dumpEditingCallbacks", dumpEditingCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2216 { "dumpFrameLoadCallbacks", dumpFrameLoadCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2217 { "dumpUserGestureInFrameLoadCallbacks", dumpUserGestureInFrameLoadCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2218 { "dumpResourceLoadCallbacks", dumpResourceLoadCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2219 { "dumpResourceResponseMIMETypes", dumpResourceResponseMIMETypesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2220 { "dumpSelectionRect", dumpSelectionRectCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2221 { "dumpSourceAsWebArchive", dumpSourceAsWebArchiveCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2222 { "dumpStatusCallbacks", dumpStatusCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2223 { "dumpTitleChanges", dumpTitleChangesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2224 { "dumpIconChanges", dumpIconChangesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2225 { "dumpWillCacheResponse", dumpWillCacheResponseCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2226 { "elementDoesAutoCompleteForElementWithId", elementDoesAutoCompleteForElementWithIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2227 { "encodeHostName", encodeHostNameCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2228 { "ensureShadowRoot", ensureShadowRootCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2229 { "evaluateInWebInspector", evaluateInWebInspectorCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2230 { "evaluateScriptInIsolatedWorld", evaluateScriptInIsolatedWorldCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2231 { "execCommand", execCommandCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2232 { "findString", findStringCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2233 { "counterValueForElementById", counterValueForElementByIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2234 { "originsWithApplicationCache", originsWithApplicationCacheCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2235 { "grantDesktopNotificationPermission", grantDesktopNotificationPermissionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2236 { "hasSpellingMarker", hasSpellingMarkerCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2237 { "hasGrammarMarker", hasGrammarMarkerCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2238 { "isCommandEnabled", isCommandEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2239 { "isPageBoxVisible", isPageBoxVisibleCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2240 { "keepWebHistory", keepWebHistoryCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2241 { "layerTreeAsText", layerTreeAsTextCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2242 { "numberOfPages", numberOfPagesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2243 { "numberOfPendingGeolocationPermissionRequests", numberOfPendingGeolocationPermissionRequestsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2244 { "markerTextForListItem", markerTextForListItemCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2245 { "notifyDone", notifyDoneCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2246 { "numberOfActiveAnimations", numberOfActiveAnimationsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2247 { "suspendAnimations", suspendAnimationsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2248 { "resumeAnimations", resumeAnimationsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2249 { "removeShadowRoot", removeShadowRootCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2250 { "overridePreference", overridePreferenceCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2251 { "pageNumberForElementById", pageNumberForElementByIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2252 { "pageSizeAndMarginsInPixels", pageSizeAndMarginsInPixelsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2253 { "pageProperty", pagePropertyCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2254 { "pathToLocalResource", pathToLocalResourceCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2255 { "pauseAnimationAtTimeOnElementWithId", pauseAnimationAtTimeOnElementWithIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2256 { "pauseTransitionAtTimeOnElementWithId", pauseTransitionAtTimeOnElementWithIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2257 { "sampleSVGAnimationForElementAtTime", sampleSVGAnimationForElementAtTimeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2258 { "printToPDF", dumpAsPDFCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2259 { "queueBackNavigation", queueBackNavigationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2260 { "queueForwardNavigation", queueForwardNavigationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2261 { "queueLoad", queueLoadCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2262 { "queueLoadHTMLString", queueLoadHTMLStringCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2263 { "queueLoadingScript", queueLoadingScriptCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2264 { "queueNonLoadingScript", queueNonLoadingScriptCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2265 { "queueReload", queueReloadCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2266 { "removeAllVisitedLinks", removeAllVisitedLinksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2267 { "removeOriginAccessWhitelistEntry", removeOriginAccessWhitelistEntryCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2268 { "repaintSweepHorizontally", repaintSweepHorizontallyCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2269 { "setAcceptsEditing", setAcceptsEditingCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2270 { "setAllowUniversalAccessFromFileURLs", setAllowUniversalAccessFromFileURLsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2271 { "setAllowFileAccessFromFileURLs", setAllowFileAccessFromFileURLsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2272 { "setAlwaysAcceptCookies", setAlwaysAcceptCookiesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2273 { "setAppCacheMaximumSize", setAppCacheMaximumSizeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2274 { "setApplicationCacheOriginQuota", setApplicationCacheOriginQuotaCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2275 { "setEncodedAudioData", setEncodedAudioDataCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2276 { "setAuthenticationPassword", setAuthenticationPasswordCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2277 { "setAuthenticationUsername", setAuthenticationUsernameCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2278 { "setAuthorAndUserStylesEnabled", setAuthorAndUserStylesEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2279 { "setAutofilled", setAutofilledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2280 { "setCacheModel", setCacheModelCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2281 { "setCallCloseOnWebViews", setCallCloseOnWebViewsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2282 { "setCanOpenWindows", setCanOpenWindowsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2283 { "setCloseRemainingWindowsWhenComplete", setCloseRemainingWindowsWhenCompleteCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2284 { "setCustomPolicyDelegate", setCustomPolicyDelegateCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2285 { "setDatabaseQuota", setDatabaseQuotaCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2286 { "setDeferMainResourceDataLoad", setDeferMainResourceDataLoadCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2287 { "setDomainRelaxationForbiddenForURLScheme", setDomainRelaxationForbiddenForURLSchemeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2288 { "setEditingBehavior", setEditingBehaviorCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2289 { "setFrameFlatteningEnabled", setFrameFlatteningEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2290 { "setGeolocationPermission", setGeolocationPermissionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2291 { "setHandlesAuthenticationChallenges", setHandlesAuthenticationChallengesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2292 { "setIconDatabaseEnabled", setIconDatabaseEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2293 { "setJavaScriptProfilingEnabled", setJavaScriptProfilingEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2294 { "setMainFrameIsFirstResponder", setMainFrameIsFirstResponderCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2295 { "setMinimumTimerInterval", setMinimumTimerIntervalCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2296 { "setMockDeviceOrientation", setMockDeviceOrientationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2297 { "setMockGeolocationError", setMockGeolocationErrorCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2298 { "setMockGeolocationPosition", setMockGeolocationPositionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2299 { "addMockSpeechInputResult", addMockSpeechInputResultCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2300 { "setNewWindowsCopyBackForwardList", setNewWindowsCopyBackForwardListCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2301 { "setPOSIXLocale", setPOSIXLocaleCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2302 { "setPersistentUserStyleSheetLocation", setPersistentUserStyleSheetLocationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2303 { "setPopupBlockingEnabled", setPopupBlockingEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2304 { "setPluginsEnabled", setPluginsEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2305 { "setPrinting", setPrintingCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2306 { "setPrivateBrowsingEnabled", setPrivateBrowsingEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2307 { "setSelectTrailingWhitespaceEnabled", setSelectTrailingWhitespaceEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2308 { "setSerializeHTTPLoads", setSerializeHTTPLoadsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2309 { "setSmartInsertDeleteEnabled", setSmartInsertDeleteEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2310 { "setSpatialNavigationEnabled", setSpatialNavigationEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2311 { "setStopProvisionalFrameLoads", setStopProvisionalFrameLoadsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2312 { "setTabKeyCyclesThroughElements", setTabKeyCyclesThroughElementsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2313 { "setTimelineProfilingEnabled", setTimelineProfilingEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2314 { "setUseDashboardCompatibilityMode", setUseDashboardCompatibilityModeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2315 { "setUserStyleSheetEnabled", setUserStyleSheetEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2316 { "setUserStyleSheetLocation", setUserStyleSheetLocationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2317 { "setValueForUser", setValueForUserCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2318 { "setViewModeMediaFeature", setViewModeMediaFeatureCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2319 { "setWebViewEditable", setWebViewEditableCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2320 { "setWillSendRequestClearHeader", setWillSendRequestClearHeaderCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2321 { "setWillSendRequestReturnsNull", setWillSendRequestReturnsNullCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2322 { "setWillSendRequestReturnsNullOnRedirect", setWillSendRequestReturnsNullOnRedirectCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2323 { "setWindowIsKey", setWindowIsKeyCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2324 { "setJavaScriptCanAccessClipboard", setJavaScriptCanAccessClipboardCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2325 { "setXSSAuditorEnabled", setXSSAuditorEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2326 { "setAsynchronousSpellCheckingEnabled", setAsynchronousSpellCheckingEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2327 { "shadowRoot", shadowRootCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2328 { "showWebInspector", showWebInspectorCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2329 { "testOnscreen", testOnscreenCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2330 { "testRepaint", testRepaintCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2331 { "waitForPolicyDelegate", waitForPolicyDelegateCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2332 { "waitUntilDone", waitUntilDoneCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2333 { "windowCount", windowCountCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2334 { "addOriginAccessWhitelistEntry", addOriginAccessWhitelistEntryCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2335 { "setScrollbarPolicy", setScrollbarPolicyCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2336 { "authenticateSession", authenticateSessionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2337 { "deleteAllLocalStorage", deleteAllLocalStorageCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2338 { "syncLocalStorage", syncLocalStorageCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2339 { "observeStorageTrackerNotifications", observeStorageTrackerNotificationsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2340 { "deleteLocalStorageForOrigin", deleteLocalStorageForOriginCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2341 { "originsWithLocalStorage", originsWithLocalStorageCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2342 { "setShouldPaintBrokenImage", setShouldPaintBrokenImageCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2343 { "shadowPseudoId", shadowPseudoIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2347 return staticFunctions;
2350 void LayoutTestController::queueLoadHTMLString(JSStringRef content, JSStringRef baseURL)
2352 WorkQueue::shared()->queue(new LoadHTMLStringItem(content, baseURL));
2355 void LayoutTestController::queueLoadAlternateHTMLString(JSStringRef content, JSStringRef baseURL, JSStringRef unreachableURL)
2357 WorkQueue::shared()->queue(new LoadHTMLStringItem(content, baseURL, unreachableURL));
2360 void LayoutTestController::queueBackNavigation(int howFarBack)
2362 WorkQueue::shared()->queue(new BackItem(howFarBack));
2365 void LayoutTestController::queueForwardNavigation(int howFarForward)
2367 WorkQueue::shared()->queue(new ForwardItem(howFarForward));
2370 void LayoutTestController::queueLoadingScript(JSStringRef script)
2372 WorkQueue::shared()->queue(new LoadingScriptItem(script));
2375 void LayoutTestController::queueNonLoadingScript(JSStringRef script)
2377 WorkQueue::shared()->queue(new NonLoadingScriptItem(script));
2380 void LayoutTestController::queueReload()
2382 WorkQueue::shared()->queue(new ReloadItem);
2385 void LayoutTestController::grantDesktopNotificationPermission(JSStringRef origin)
2387 m_desktopNotificationAllowedOrigins.push_back(JSStringRetain(origin));
2390 bool LayoutTestController::checkDesktopNotificationPermission(JSStringRef origin)
2392 std::vector<JSStringRef>::iterator i;
2393 for (i = m_desktopNotificationAllowedOrigins.begin();
2394 i != m_desktopNotificationAllowedOrigins.end();
2396 if (JSStringIsEqual(*i, origin))
2402 void LayoutTestController::waitToDumpWatchdogTimerFired()
2404 const char* message = "FAIL: Timed out waiting for notifyDone to be called\n";
2405 fprintf(stderr, "%s", message);
2406 fprintf(stdout, "%s", message);
2410 void LayoutTestController::setGeolocationPermissionCommon(bool allow)
2412 m_isGeolocationPermissionSet = true;
2413 m_geolocationPermission = allow;
2416 void LayoutTestController::setPOSIXLocale(JSStringRef locale)
2419 JSStringGetUTF8CString(locale, localeBuf, sizeof(localeBuf));
2420 setlocale(LC_ALL, localeBuf);
2423 void LayoutTestController::addURLToRedirect(std::string origin, std::string destination)
2425 m_URLsToRedirect[origin] = destination;
2428 const std::string& LayoutTestController::redirectionDestinationForURL(std::string origin)
2430 return m_URLsToRedirect[origin];
2433 void LayoutTestController::setShouldPaintBrokenImage(bool shouldPaintBrokenImage)
2435 m_shouldPaintBrokenImage = shouldPaintBrokenImage;
2438 const unsigned LayoutTestController::maxViewWidth = 800;
2439 const unsigned LayoutTestController::maxViewHeight = 600;