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/RefPtr.h>
44 LayoutTestController::LayoutTestController(const std::string& testPathOrURL, const std::string& expectedPixelHash)
45 : m_dumpApplicationCacheDelegateCallbacks(false)
48 , m_dumpBackForwardList(false)
49 , m_dumpChildFrameScrollPositions(false)
50 , m_dumpChildFramesAsText(false)
51 , m_dumpDOMAsWebArchive(false)
52 , m_dumpDatabaseCallbacks(false)
53 , m_dumpEditingCallbacks(false)
54 , m_dumpFrameLoadCallbacks(false)
55 , m_dumpUserGestureInFrameLoadCallbacks(false)
56 , m_dumpHistoryDelegateCallbacks(false)
57 , m_dumpResourceLoadCallbacks(false)
58 , m_dumpResourceResponseMIMETypes(false)
59 , m_dumpSelectionRect(false)
60 , m_dumpSourceAsWebArchive(false)
61 , m_dumpStatusCallbacks(false)
62 , m_dumpTitleChanges(false)
63 , m_dumpIconChanges(false)
64 , m_dumpVisitedLinksCallback(false)
65 , m_dumpWillCacheResponse(false)
66 , m_generatePixelResults(true)
67 , m_callCloseOnWebViews(true)
68 , m_canOpenWindows(false)
69 , m_closeRemainingWindowsWhenComplete(true)
70 , m_newWindowsCopyBackForwardList(false)
71 , m_stopProvisionalFrameLoads(false)
72 , m_testOnscreen(false)
73 , m_testRepaint(false)
74 , m_testRepaintSweepHorizontally(false)
76 , m_willSendRequestReturnsNull(false)
77 , m_willSendRequestReturnsNullOnRedirect(false)
79 , m_alwaysAcceptCookies(false)
81 , m_isGeolocationPermissionSet(false)
82 , m_geolocationPermission(false)
83 , m_handlesAuthenticationChallenges(false)
85 , m_deferMainResourceDataLoad(true)
86 , m_testPathOrURL(testPathOrURL)
87 , m_expectedPixelHash(expectedPixelHash)
91 PassRefPtr<LayoutTestController> LayoutTestController::create(const std::string& testPathOrURL, const std::string& expectedPixelHash)
93 return adoptRef(new LayoutTestController(testPathOrURL, expectedPixelHash));
98 static JSValueRef dumpApplicationCacheDelegateCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
100 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
101 controller->setDumpApplicationCacheDelegateCallbacks(true);
102 return JSValueMakeUndefined(context);
105 static JSValueRef dumpAsPDFCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
107 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
108 controller->setDumpAsPDF(true);
109 return JSValueMakeUndefined(context);
112 static JSValueRef dumpAsTextCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
114 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
115 controller->setDumpAsText(true);
117 // Optional paramater, describing whether it's allowed to dump pixel results in dumpAsText mode.
118 controller->setGeneratePixelResults(argumentCount > 0 ? JSValueToBoolean(context, arguments[0]) : false);
120 return JSValueMakeUndefined(context);
123 static JSValueRef dumpBackForwardListCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
125 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
126 controller->setDumpBackForwardList(true);
127 return JSValueMakeUndefined(context);
130 static JSValueRef dumpChildFramesAsTextCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
132 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
133 controller->setDumpChildFramesAsText(true);
134 return JSValueMakeUndefined(context);
137 static JSValueRef dumpChildFrameScrollPositionsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
139 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
140 controller->setDumpChildFrameScrollPositions(true);
141 return JSValueMakeUndefined(context);
144 static JSValueRef dumpConfigurationForViewportCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
146 if (argumentCount < 2)
147 return JSValueMakeUndefined(context);
149 double availableWidth = JSValueToNumber(context, arguments[0], exception);
151 double availableHeight = JSValueToNumber(context, arguments[1], exception);
154 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
155 controller->dumpConfigurationForViewport(static_cast<int>(availableWidth), static_cast<int>(availableHeight));
157 return JSValueMakeUndefined(context);
160 static JSValueRef dumpDatabaseCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
162 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
163 controller->setDumpDatabaseCallbacks(true);
164 return JSValueMakeUndefined(context);
167 static JSValueRef dumpDOMAsWebArchiveCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
169 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
170 controller->setDumpDOMAsWebArchive(true);
171 return JSValueMakeUndefined(context);
174 static JSValueRef dumpEditingCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
176 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
177 controller->setDumpEditingCallbacks(true);
178 return JSValueMakeUndefined(context);
181 static JSValueRef dumpFrameLoadCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
183 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
184 controller->setDumpFrameLoadCallbacks(true);
185 return JSValueMakeUndefined(context);
188 static JSValueRef dumpUserGestureInFrameLoadCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
190 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
191 controller->setDumpUserGestureInFrameLoadCallbacks(true);
192 return JSValueMakeUndefined(context);
195 static JSValueRef dumpResourceLoadCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
197 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
198 controller->setDumpResourceLoadCallbacks(true);
199 return JSValueMakeUndefined(context);
202 static JSValueRef dumpResourceResponseMIMETypesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
204 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
205 controller->setDumpResourceResponseMIMETypes(true);
206 return JSValueMakeUndefined(context);
209 static JSValueRef dumpSelectionRectCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
211 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
212 controller->setDumpSelectionRect(true);
213 return JSValueMakeUndefined(context);
216 static JSValueRef dumpSourceAsWebArchiveCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
218 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
219 controller->setDumpSourceAsWebArchive(true);
220 return JSValueMakeUndefined(context);
223 static JSValueRef dumpStatusCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
225 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
226 controller->setDumpStatusCallbacks(true);
227 return JSValueMakeUndefined(context);
230 static JSValueRef dumpTitleChangesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
232 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
233 controller->setDumpTitleChanges(true);
234 return JSValueMakeUndefined(context);
237 static JSValueRef dumpIconChangesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
239 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
240 controller->setDumpIconChanges(true);
241 return JSValueMakeUndefined(context);
244 static JSValueRef dumpWillCacheResponseCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
246 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
247 controller->setDumpWillCacheResponse(true);
248 return JSValueMakeUndefined(context);
251 static JSValueRef pathToLocalResourceCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
253 if (argumentCount < 1)
254 return JSValueMakeUndefined(context);
256 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
257 JSRetainPtr<JSStringRef> localPath(Adopt, JSValueToStringCopy(context, arguments[0], exception));
260 JSRetainPtr<JSStringRef> convertedPath(Adopt, controller->pathToLocalResource(context, localPath.get()));
262 return JSValueMakeUndefined(context);
264 return JSValueMakeString(context, convertedPath.get());
267 static JSValueRef removeAllVisitedLinksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
269 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
270 controller->setDumpVisitedLinksCallback(true);
271 controller->removeAllVisitedLinks();
272 return JSValueMakeUndefined(context);
275 static JSValueRef repaintSweepHorizontallyCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
277 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
278 controller->setTestRepaintSweepHorizontally(true);
279 return JSValueMakeUndefined(context);
282 static JSValueRef setCallCloseOnWebViewsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
284 if (argumentCount < 1)
285 return JSValueMakeUndefined(context);
287 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
288 controller->setCallCloseOnWebViews(JSValueToBoolean(context, arguments[0]));
289 return JSValueMakeUndefined(context);
292 static JSValueRef setCanOpenWindowsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
294 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
295 controller->setCanOpenWindows(true);
296 return JSValueMakeUndefined(context);
299 static JSValueRef setCloseRemainingWindowsWhenCompleteCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
301 if (argumentCount < 1)
302 return JSValueMakeUndefined(context);
304 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
305 controller->setCloseRemainingWindowsWhenComplete(JSValueToBoolean(context, arguments[0]));
306 return JSValueMakeUndefined(context);
309 static JSValueRef testOnscreenCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
311 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
312 controller->setTestOnscreen(true);
313 return JSValueMakeUndefined(context);
316 static JSValueRef testRepaintCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
318 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
319 controller->setTestRepaint(true);
320 return JSValueMakeUndefined(context);
323 static JSValueRef addDisallowedURLCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
325 // Has mac implementation
326 if (argumentCount < 1)
327 return JSValueMakeUndefined(context);
329 JSRetainPtr<JSStringRef> url(Adopt, JSValueToStringCopy(context, arguments[0], exception));
332 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
333 controller->addDisallowedURL(url.get());
335 return JSValueMakeUndefined(context);
338 static JSValueRef addURLToRedirectCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
340 if (argumentCount < 2)
341 return JSValueMakeUndefined(context);
343 JSRetainPtr<JSStringRef> origin(Adopt, JSValueToStringCopy(context, arguments[0], exception));
346 JSRetainPtr<JSStringRef> destination(Adopt, JSValueToStringCopy(context, arguments[1], exception));
349 size_t maxLength = JSStringGetMaximumUTF8CStringSize(origin.get());
350 char* originBuffer = new char[maxLength + 1];
351 JSStringGetUTF8CString(origin.get(), originBuffer, maxLength + 1);
353 maxLength = JSStringGetMaximumUTF8CStringSize(destination.get());
354 char* destinationBuffer = new char[maxLength + 1];
355 JSStringGetUTF8CString(destination.get(), destinationBuffer, maxLength + 1);
357 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
358 controller->addURLToRedirect(originBuffer, destinationBuffer);
360 return JSValueMakeUndefined(context);
363 static JSValueRef callShouldCloseOnWebViewCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
365 // Has mac & windows implementation
366 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
368 return JSValueMakeBoolean(context, controller->callShouldCloseOnWebView());
371 static JSValueRef clearAllApplicationCachesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
373 // Has mac implementation
374 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
375 controller->clearAllApplicationCaches();
377 return JSValueMakeUndefined(context);
380 static JSValueRef clearAllDatabasesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
382 // Has mac & windows implementation
383 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
384 controller->clearAllDatabases();
386 return JSValueMakeUndefined(context);
389 static JSValueRef clearBackForwardListCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
391 // Has mac & windows implementation
392 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
393 controller->clearBackForwardList();
395 return JSValueMakeUndefined(context);
398 static JSValueRef clearPersistentUserStyleSheetCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
400 // Has mac & windows implementation
401 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
402 controller->clearPersistentUserStyleSheet();
404 return JSValueMakeUndefined(context);
407 static JSValueRef decodeHostNameCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
409 // Has mac implementation
410 if (argumentCount < 1)
411 return JSValueMakeUndefined(context);
413 JSRetainPtr<JSStringRef> name(Adopt, JSValueToStringCopy(context, arguments[0], exception));
416 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
417 JSRetainPtr<JSStringRef> decodedHostName(Adopt, controller->copyDecodedHostName(name.get()));
418 return JSValueMakeString(context, decodedHostName.get());
421 static JSValueRef disableImageLoadingCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
423 // Has mac implementation, needs windows implementation
424 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
425 controller->disableImageLoading();
427 return JSValueMakeUndefined(context);
430 static JSValueRef dispatchPendingLoadRequestsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
432 // Has mac implementation, needs windows implementation
433 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
434 controller->dispatchPendingLoadRequests();
436 return JSValueMakeUndefined(context);
439 static JSValueRef displayCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
441 // Has mac & windows implementation
442 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
443 controller->display();
445 return JSValueMakeUndefined(context);
448 static JSValueRef displayInvalidatedRegionCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
450 // Has mac & windows implementation
451 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
452 // LayoutTestController::display() only renders the invalidated region so
453 // we can just use that.
454 controller->display();
456 return JSValueMakeUndefined(context);
459 static JSValueRef encodeHostNameCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
461 // Has mac implementation
462 if (argumentCount < 1)
463 return JSValueMakeUndefined(context);
465 JSRetainPtr<JSStringRef> name(Adopt, JSValueToStringCopy(context, arguments[0], exception));
468 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
469 JSRetainPtr<JSStringRef> encodedHostName(Adopt, controller->copyEncodedHostName(name.get()));
470 return JSValueMakeString(context, encodedHostName.get());
473 static JSValueRef execCommandCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
475 // Has Mac & Windows implementations.
476 if (argumentCount < 1)
477 return JSValueMakeUndefined(context);
479 JSRetainPtr<JSStringRef> name(Adopt, JSValueToStringCopy(context, arguments[0], exception));
482 // Ignoring the second parameter (userInterface), as this command emulates a manual action.
484 JSRetainPtr<JSStringRef> value;
485 if (argumentCount >= 3) {
486 value.adopt(JSValueToStringCopy(context, arguments[2], exception));
489 value.adopt(JSStringCreateWithUTF8CString(""));
492 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
493 controller->execCommand(name.get(), value.get());
495 return JSValueMakeUndefined(context);
498 static JSValueRef findStringCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
500 // Has Mac implementation.
501 if (argumentCount < 2)
502 return JSValueMakeUndefined(context);
504 JSRetainPtr<JSStringRef> target(Adopt, JSValueToStringCopy(context, arguments[0], exception));
507 JSObjectRef options = JSValueToObject(context, arguments[1], exception);
510 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
511 return JSValueMakeBoolean(context, controller->findString(context, target.get(), options));
514 static JSValueRef counterValueForElementByIdCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
516 if (argumentCount < 1)
517 return JSValueMakeUndefined(context);
519 JSRetainPtr<JSStringRef> elementId(Adopt, JSValueToStringCopy(context, arguments[0], exception));
521 return JSValueMakeUndefined(context);
523 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
524 JSRetainPtr<JSStringRef> counterValue(controller->counterValueForElementById(elementId.get()));
525 if (!counterValue.get())
526 return JSValueMakeUndefined(context);
527 return JSValueMakeString(context, counterValue.get());
530 static JSValueRef grantDesktopNotificationPermissionCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
532 // Has Windows implementation
533 if (argumentCount < 1)
534 return JSValueMakeUndefined(context);
536 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
538 controller->grantDesktopNotificationPermission(JSValueToStringCopy(context, arguments[0], NULL));
540 return JSValueMakeUndefined(context);
543 static JSValueRef isCommandEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
545 // Has Mac implementation.
547 if (argumentCount < 1)
548 return JSValueMakeUndefined(context);
550 JSRetainPtr<JSStringRef> name(Adopt, JSValueToStringCopy(context, arguments[0], exception));
553 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
555 return JSValueMakeBoolean(context, controller->isCommandEnabled(name.get()));
558 static JSValueRef overridePreferenceCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
560 if (argumentCount < 2)
561 return JSValueMakeUndefined(context);
563 JSRetainPtr<JSStringRef> key(Adopt, JSValueToStringCopy(context, arguments[0], exception));
565 JSRetainPtr<JSStringRef> value(Adopt, JSValueToStringCopy(context, arguments[1], exception));
568 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
569 controller->overridePreference(key.get(), value.get());
571 return JSValueMakeUndefined(context);
574 static JSValueRef keepWebHistoryCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
576 // Has mac implementation
577 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
578 controller->keepWebHistory();
580 return JSValueMakeUndefined(context);
583 static JSValueRef computedStyleIncludingVisitedInfoCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
585 if (argumentCount != 1)
586 return JSValueMakeUndefined(context);
588 // Has mac implementation
589 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
590 return controller->computedStyleIncludingVisitedInfo(context, arguments[0]);
593 static JSValueRef nodesFromRectCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
595 if (argumentCount != 8)
596 return JSValueMakeUndefined(context);
598 int x = JSValueToNumber(context, arguments[1], NULL);
599 int y = JSValueToNumber(context, arguments[2], NULL);
600 int top = static_cast<unsigned>(JSValueToNumber(context, arguments[3], NULL));
601 int right = static_cast<unsigned>(JSValueToNumber(context, arguments[4], NULL));
602 int bottom = static_cast<unsigned>(JSValueToNumber(context, arguments[5], NULL));
603 int left = static_cast<unsigned>(JSValueToNumber(context, arguments[6], NULL));
604 bool ignoreClipping = JSValueToBoolean(context, arguments[7]);
606 // Has mac implementation.
607 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
608 return controller->nodesFromRect(context, arguments[0], x, y, top, right, bottom, left, ignoreClipping);
611 static JSValueRef layerTreeAsTextCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
613 // Has mac & windows implementation
614 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
615 return JSValueMakeString(context, controller->layerTreeAsText().get());
618 static JSValueRef notifyDoneCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
620 // Has mac & windows implementation
621 // May be able to be made platform independant by using shared WorkQueue
622 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
623 controller->notifyDone();
624 return JSValueMakeUndefined(context);
627 static bool parsePageParameters(JSContextRef context, int argumentCount, const JSValueRef* arguments, JSValueRef* exception, float& pageWidthInPixels, float& pageHeightInPixels)
629 pageWidthInPixels = LayoutTestController::maxViewWidth;
630 pageHeightInPixels = LayoutTestController::maxViewHeight;
631 switch (argumentCount) {
633 pageWidthInPixels = static_cast<float>(JSValueToNumber(context, arguments[0], exception));
636 pageHeightInPixels = static_cast<float>(JSValueToNumber(context, arguments[1], exception));
639 case 0: // Fall through.
647 // Caller needs to delete[] propertyName.
648 static bool parsePagePropertyParameters(JSContextRef context, int argumentCount, const JSValueRef* arguments, JSValueRef* exception, char*& propertyName, int& pageNumber)
651 switch (argumentCount) {
653 pageNumber = static_cast<float>(JSValueToNumber(context, arguments[1], exception));
658 JSRetainPtr<JSStringRef> propertyNameString(Adopt, JSValueToStringCopy(context, arguments[0], exception));
662 size_t maxLength = JSStringGetMaximumUTF8CStringSize(propertyNameString.get());
663 propertyName = new char[maxLength + 1];
664 JSStringGetUTF8CString(propertyNameString.get(), propertyName, maxLength + 1);
673 static bool parsePageNumber(JSContextRef context, int argumentCount, const JSValueRef* arguments, JSValueRef* exception, int& pageNumber)
676 switch (argumentCount) {
678 pageNumber = static_cast<int>(JSValueToNumber(context, arguments[0], exception));
689 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)
693 marginTop = marginRight = marginBottom = marginLeft = 0;
695 switch (argumentCount) {
697 marginLeft = static_cast<int>(JSValueToNumber(context, arguments[6], exception));
702 marginBottom = static_cast<int>(JSValueToNumber(context, arguments[5], exception));
707 marginRight = static_cast<int>(JSValueToNumber(context, arguments[4], exception));
712 marginTop = static_cast<int>(JSValueToNumber(context, arguments[3], exception));
717 height = static_cast<int>(JSValueToNumber(context, arguments[2], exception));
722 width = static_cast<int>(JSValueToNumber(context, arguments[1], exception));
727 pageNumber = static_cast<int>(JSValueToNumber(context, arguments[0], exception));
737 static JSValueRef pageNumberForElementByIdCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
739 float pageWidthInPixels = 0;
740 float pageHeightInPixels = 0;
741 if (!parsePageParameters(context, argumentCount - 1, arguments + 1, exception, pageWidthInPixels, pageHeightInPixels))
742 return JSValueMakeUndefined(context);
744 JSRetainPtr<JSStringRef> elementId(Adopt, JSValueToStringCopy(context, arguments[0], exception));
746 return JSValueMakeUndefined(context);
748 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
749 int pageNumber = controller->pageNumberForElementById(elementId.get(), pageWidthInPixels, pageHeightInPixels);
750 return JSValueMakeNumber(context, pageNumber);
753 static JSValueRef numberOfPagesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
755 float pageWidthInPixels = 0;
756 float pageHeightInPixels = 0;
757 if (!parsePageParameters(context, argumentCount, arguments, exception, pageWidthInPixels, pageHeightInPixels))
758 return JSValueMakeUndefined(context);
760 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
761 return JSValueMakeNumber(context, controller->numberOfPages(pageWidthInPixels, pageHeightInPixels));
764 static JSValueRef pagePropertyCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
766 char* propertyName = 0;
768 if (!parsePagePropertyParameters(context, argumentCount, arguments, exception, propertyName, pageNumber))
769 return JSValueMakeUndefined(context);
771 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
772 JSValueRef value = JSValueMakeString(context, controller->pageProperty(propertyName, pageNumber).get());
774 delete[] propertyName;
778 static JSValueRef isPageBoxVisibleCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
781 if (!parsePageNumber(context, argumentCount, arguments, exception, pageNumber))
782 return JSValueMakeUndefined(context);
784 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
785 return JSValueMakeBoolean(context, controller->isPageBoxVisible(pageNumber));
788 static JSValueRef pageSizeAndMarginsInPixelsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
791 int width = 0, height = 0;
792 int marginTop = 0, marginRight = 0, marginBottom = 0, marginLeft = 0;
793 if (!parsePageNumberSizeMarings(context, argumentCount, arguments, exception, pageNumber, width, height, marginTop, marginRight, marginBottom, marginLeft))
794 return JSValueMakeUndefined(context);
796 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
797 return JSValueMakeString(context, controller->pageSizeAndMarginsInPixels(pageNumber, width, height, marginTop, marginRight, marginBottom, marginLeft).get());
800 static JSValueRef queueBackNavigationCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
802 // Has mac & windows implementation
803 // May be able to be made platform independant by using shared WorkQueue
804 if (argumentCount < 1)
805 return JSValueMakeUndefined(context);
807 double howFarBackDouble = JSValueToNumber(context, arguments[0], exception);
810 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
811 controller->queueBackNavigation(static_cast<int>(howFarBackDouble));
813 return JSValueMakeUndefined(context);
816 static JSValueRef queueForwardNavigationCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
818 // Has mac & windows implementation
819 // May be able to be made platform independant by using shared WorkQueue
820 if (argumentCount < 1)
821 return JSValueMakeUndefined(context);
823 double howFarForwardDouble = JSValueToNumber(context, arguments[0], exception);
826 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
827 controller->queueForwardNavigation(static_cast<int>(howFarForwardDouble));
829 return JSValueMakeUndefined(context);
832 static JSValueRef queueLoadCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
834 // Has mac & windows implementation
835 // May be able to be made platform independant by using shared WorkQueue
836 if (argumentCount < 1)
837 return JSValueMakeUndefined(context);
839 JSRetainPtr<JSStringRef> url(Adopt, JSValueToStringCopy(context, arguments[0], exception));
842 JSRetainPtr<JSStringRef> target;
843 if (argumentCount >= 2) {
844 target.adopt(JSValueToStringCopy(context, arguments[1], exception));
847 target.adopt(JSStringCreateWithUTF8CString(""));
849 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
850 controller->queueLoad(url.get(), target.get());
852 return JSValueMakeUndefined(context);
855 static JSValueRef queueLoadHTMLStringCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
857 // Has Mac & Windows implementation
858 if (argumentCount < 1)
859 return JSValueMakeUndefined(context);
861 JSRetainPtr<JSStringRef> content(Adopt, JSValueToStringCopy(context, arguments[0], exception));
864 JSRetainPtr<JSStringRef> baseURL;
865 if (argumentCount >= 2) {
866 baseURL.adopt(JSValueToStringCopy(context, arguments[1], exception));
869 baseURL.adopt(JSStringCreateWithUTF8CString(""));
871 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
873 if (argumentCount >= 3) {
874 JSRetainPtr<JSStringRef> unreachableURL;
875 unreachableURL.adopt(JSValueToStringCopy(context, arguments[2], exception));
877 controller->queueLoadAlternateHTMLString(content.get(), baseURL.get(), unreachableURL.get());
878 return JSValueMakeUndefined(context);
881 controller->queueLoadHTMLString(content.get(), baseURL.get());
882 return JSValueMakeUndefined(context);
885 static JSValueRef queueReloadCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
887 // Has mac & windows implementation
888 // May be able to be made platform independant by using shared WorkQueue
890 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
891 controller->queueReload();
893 return JSValueMakeUndefined(context);
896 static JSValueRef queueLoadingScriptCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
898 // Has mac & windows implementation
899 // May be able to be made platform independant by using shared WorkQueue
900 if (argumentCount < 1)
901 return JSValueMakeUndefined(context);
903 JSRetainPtr<JSStringRef> script(Adopt, JSValueToStringCopy(context, arguments[0], exception));
906 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
907 controller->queueLoadingScript(script.get());
909 return JSValueMakeUndefined(context);
912 static JSValueRef queueNonLoadingScriptCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
914 // Has mac & windows implementation
915 // May be able to be made platform independant by using shared WorkQueue
916 if (argumentCount < 1)
917 return JSValueMakeUndefined(context);
919 JSRetainPtr<JSStringRef> script(Adopt, JSValueToStringCopy(context, arguments[0], exception));
922 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
923 controller->queueNonLoadingScript(script.get());
925 return JSValueMakeUndefined(context);
928 static JSValueRef setAcceptsEditingCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
930 // Has mac & windows implementation
931 if (argumentCount < 1)
932 return JSValueMakeUndefined(context);
934 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
935 controller->setAcceptsEditing(JSValueToBoolean(context, arguments[0]));
937 return JSValueMakeUndefined(context);
940 static JSValueRef setAlwaysAcceptCookiesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
942 // Has mac & windows implementation
943 if (argumentCount < 1)
944 return JSValueMakeUndefined(context);
946 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
947 controller->setAlwaysAcceptCookies(JSValueToBoolean(context, arguments[0]));
949 return JSValueMakeUndefined(context);
952 static JSValueRef setAppCacheMaximumSizeCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
954 // Has mac implementation
955 if (argumentCount < 1)
956 return JSValueMakeUndefined(context);
958 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
960 double size = JSValueToNumber(context, arguments[0], NULL);
962 controller->setAppCacheMaximumSize(static_cast<unsigned long long>(size));
964 return JSValueMakeUndefined(context);
967 static JSValueRef setApplicationCacheOriginQuotaCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
969 // Has mac implementation
970 if (argumentCount < 1)
971 return JSValueMakeUndefined(context);
973 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
975 double size = JSValueToNumber(context, arguments[0], NULL);
977 controller->setApplicationCacheOriginQuota(static_cast<unsigned long long>(size));
979 return JSValueMakeUndefined(context);
982 static JSValueRef setAuthenticationPasswordCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
984 // Has mac & windows implementation
985 if (argumentCount < 1)
986 return JSValueMakeUndefined(context);
988 JSRetainPtr<JSStringRef> password(Adopt, JSValueToStringCopy(context, arguments[0], exception));
991 size_t maxLength = JSStringGetMaximumUTF8CStringSize(password.get());
992 char* passwordBuffer = new char[maxLength + 1];
993 JSStringGetUTF8CString(password.get(), passwordBuffer, maxLength + 1);
995 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
996 controller->setAuthenticationPassword(passwordBuffer);
997 delete[] passwordBuffer;
999 return JSValueMakeUndefined(context);
1002 static JSValueRef setAuthenticationUsernameCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1004 // Has mac & windows implementation
1005 if (argumentCount < 1)
1006 return JSValueMakeUndefined(context);
1008 JSRetainPtr<JSStringRef> username(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1009 ASSERT(!*exception);
1011 size_t maxLength = JSStringGetMaximumUTF8CStringSize(username.get());
1012 char* usernameBuffer = new char[maxLength + 1];
1013 JSStringGetUTF8CString(username.get(), usernameBuffer, maxLength + 1);
1015 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1016 controller->setAuthenticationUsername(usernameBuffer);
1017 delete[] usernameBuffer;
1019 return JSValueMakeUndefined(context);
1022 static JSValueRef setAuthorAndUserStylesEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1024 // Has mac & windows implementation
1025 if (argumentCount < 1)
1026 return JSValueMakeUndefined(context);
1028 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1029 controller->setAuthorAndUserStylesEnabled(JSValueToBoolean(context, arguments[0]));
1031 return JSValueMakeUndefined(context);
1034 static JSValueRef setCacheModelCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1036 // Has Mac implementation.
1037 if (argumentCount < 1)
1038 return JSValueMakeUndefined(context);
1040 int cacheModel = JSValueToNumber(context, arguments[0], exception);
1041 ASSERT(!*exception);
1043 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1044 controller->setCacheModel(cacheModel);
1046 return JSValueMakeUndefined(context);
1049 static JSValueRef setCustomPolicyDelegateCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1051 // Has mac implementation
1052 if (argumentCount < 1)
1053 return JSValueMakeUndefined(context);
1055 bool permissive = false;
1056 if (argumentCount >= 2)
1057 permissive = JSValueToBoolean(context, arguments[1]);
1059 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1060 controller->setCustomPolicyDelegate(JSValueToBoolean(context, arguments[0]), permissive);
1062 return JSValueMakeUndefined(context);
1065 static JSValueRef setDatabaseQuotaCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1067 // Has mac implementation
1068 if (argumentCount < 1)
1069 return JSValueMakeUndefined(context);
1071 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1073 double quota = JSValueToNumber(context, arguments[0], NULL);
1075 controller->setDatabaseQuota(static_cast<unsigned long long>(quota));
1077 return JSValueMakeUndefined(context);
1080 static JSValueRef setDeferMainResourceDataLoadCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1082 // Has Mac and Windows implementation
1083 if (argumentCount < 1)
1084 return JSValueMakeUndefined(context);
1086 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1087 controller->setDeferMainResourceDataLoad(JSValueToBoolean(context, arguments[0]));
1089 return JSValueMakeUndefined(context);
1092 static JSValueRef setDomainRelaxationForbiddenForURLSchemeCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1094 // Has Mac and Windows implementation
1095 if (argumentCount < 2)
1096 return JSValueMakeUndefined(context);
1098 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1100 bool forbidden = JSValueToBoolean(context, arguments[0]);
1101 JSRetainPtr<JSStringRef> scheme(Adopt, JSValueToStringCopy(context, arguments[1], 0));
1102 controller->setDomainRelaxationForbiddenForURLScheme(forbidden, scheme.get());
1104 return JSValueMakeUndefined(context);
1107 static JSValueRef setMockDeviceOrientationCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1109 if (argumentCount < 6)
1110 return JSValueMakeUndefined(context);
1112 bool canProvideAlpha = JSValueToBoolean(context, arguments[0]);
1113 double alpha = JSValueToNumber(context, arguments[1], exception);
1114 ASSERT(!*exception);
1115 bool canProvideBeta = JSValueToBoolean(context, arguments[2]);
1116 double beta = JSValueToNumber(context, arguments[3], exception);
1117 ASSERT(!*exception);
1118 bool canProvideGamma = JSValueToBoolean(context, arguments[4]);
1119 double gamma = JSValueToNumber(context, arguments[5], exception);
1120 ASSERT(!*exception);
1122 LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1123 controller->setMockDeviceOrientation(canProvideAlpha, alpha, canProvideBeta, beta, canProvideGamma, gamma);
1125 return JSValueMakeUndefined(context);
1128 static JSValueRef setMockGeolocationPositionCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1130 if (argumentCount < 3)
1131 return JSValueMakeUndefined(context);
1133 LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1134 controller->setMockGeolocationPosition(JSValueToNumber(context, arguments[0], NULL), // latitude
1135 JSValueToNumber(context, arguments[1], NULL), // longitude
1136 JSValueToNumber(context, arguments[2], NULL)); // accuracy
1138 return JSValueMakeUndefined(context);
1141 static JSValueRef setMockGeolocationErrorCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1143 if (argumentCount < 2)
1144 return JSValueMakeUndefined(context);
1146 int code = JSValueToNumber(context, arguments[0], NULL);
1147 JSRetainPtr<JSStringRef> message(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1148 ASSERT(!*exception);
1150 LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1151 controller->setMockGeolocationError(code, message.get());
1153 return JSValueMakeUndefined(context);
1156 static JSValueRef addMockSpeechInputResultCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1158 if (argumentCount < 3)
1159 return JSValueMakeUndefined(context);
1161 JSRetainPtr<JSStringRef> result(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1162 ASSERT(!*exception);
1164 double confidence = JSValueToNumber(context, arguments[1], exception);
1166 JSRetainPtr<JSStringRef> language(Adopt, JSValueToStringCopy(context, arguments[2], exception));
1167 ASSERT(!*exception);
1169 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1170 controller->addMockSpeechInputResult(result.get(), confidence, language.get());
1172 return JSValueMakeUndefined(context);
1175 static JSValueRef setNewWindowsCopyBackForwardListCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1177 // Has mac implementation
1178 if (argumentCount < 1)
1179 return JSValueMakeUndefined(context);
1181 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1182 controller->setNewWindowsCopyBackForwardList(JSValueToBoolean(context, arguments[0]));
1184 return JSValueMakeUndefined(context);
1187 static JSValueRef setGeolocationPermissionCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1189 // Has mac implementation
1190 if (argumentCount < 1)
1191 return JSValueMakeUndefined(context);
1193 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1194 controller->setGeolocationPermission(JSValueToBoolean(context, arguments[0]));
1196 return JSValueMakeUndefined(context);
1199 static JSValueRef setHandlesAuthenticationChallengesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1201 // Has mac & windows implementation
1202 if (argumentCount < 1)
1203 return JSValueMakeUndefined(context);
1205 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1206 controller->setHandlesAuthenticationChallenges(JSValueToBoolean(context, arguments[0]));
1208 return JSValueMakeUndefined(context);
1211 static JSValueRef setPOSIXLocaleCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1213 if (argumentCount < 1)
1214 return JSValueMakeUndefined(context);
1216 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1217 JSRetainPtr<JSStringRef> locale(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1218 ASSERT(!*exception);
1219 controller->setPOSIXLocale(locale.get());
1221 return JSValueMakeUndefined(context);
1224 static JSValueRef setIconDatabaseEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1226 // Has mac & windows implementation
1227 if (argumentCount < 1)
1228 return JSValueMakeUndefined(context);
1230 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1231 controller->setIconDatabaseEnabled(JSValueToBoolean(context, arguments[0]));
1233 return JSValueMakeUndefined(context);
1236 static JSValueRef setJavaScriptProfilingEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1238 if (argumentCount < 1)
1239 return JSValueMakeUndefined(context);
1241 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1242 controller->setJavaScriptProfilingEnabled(JSValueToBoolean(context, arguments[0]));
1244 return JSValueMakeUndefined(context);
1247 static JSValueRef setMainFrameIsFirstResponderCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1249 // Has mac implementation
1250 if (argumentCount < 1)
1251 return JSValueMakeUndefined(context);
1253 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1254 controller->setMainFrameIsFirstResponder(JSValueToBoolean(context, arguments[0]));
1256 return JSValueMakeUndefined(context);
1259 static JSValueRef setPersistentUserStyleSheetLocationCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1261 // Has mac implementation
1262 if (argumentCount < 1)
1263 return JSValueMakeUndefined(context);
1265 JSRetainPtr<JSStringRef> path(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1266 ASSERT(!*exception);
1268 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1269 controller->setPersistentUserStyleSheetLocation(path.get());
1271 return JSValueMakeUndefined(context);
1274 static JSValueRef setPrivateBrowsingEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1276 // Has mac & windows implementation
1277 if (argumentCount < 1)
1278 return JSValueMakeUndefined(context);
1280 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1281 controller->setPrivateBrowsingEnabled(JSValueToBoolean(context, arguments[0]));
1283 return JSValueMakeUndefined(context);
1286 static JSValueRef setJavaScriptCanAccessClipboardCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1288 // Has mac & windows implementation
1289 if (argumentCount < 1)
1290 return JSValueMakeUndefined(context);
1292 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1293 controller->setJavaScriptCanAccessClipboard(JSValueToBoolean(context, arguments[0]));
1295 return JSValueMakeUndefined(context);
1298 static JSValueRef setXSSAuditorEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1300 // Has mac & windows implementation
1301 if (argumentCount < 1)
1302 return JSValueMakeUndefined(context);
1304 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1305 controller->setXSSAuditorEnabled(JSValueToBoolean(context, arguments[0]));
1307 return JSValueMakeUndefined(context);
1310 static JSValueRef setSpatialNavigationEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1312 // Has mac implementation.
1313 if (argumentCount < 1)
1314 return JSValueMakeUndefined(context);
1316 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1317 controller->setSpatialNavigationEnabled(JSValueToBoolean(context, arguments[0]));
1319 return JSValueMakeUndefined(context);
1322 static JSValueRef setPrintingCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1324 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1325 controller->setIsPrinting(true);
1326 return JSValueMakeUndefined(context);
1330 static JSValueRef setFrameFlatteningEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1332 // Has mac & windows implementation
1333 if (argumentCount < 1)
1334 return JSValueMakeUndefined(context);
1336 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1337 controller->setFrameFlatteningEnabled(JSValueToBoolean(context, arguments[0]));
1339 return JSValueMakeUndefined(context);
1342 static JSValueRef setAllowUniversalAccessFromFileURLsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1344 // Has mac & windows implementation
1345 if (argumentCount < 1)
1346 return JSValueMakeUndefined(context);
1348 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1349 controller->setAllowUniversalAccessFromFileURLs(JSValueToBoolean(context, arguments[0]));
1351 return JSValueMakeUndefined(context);
1354 static JSValueRef setAllowFileAccessFromFileURLsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1356 // Has mac & windows implementation
1357 if (argumentCount < 1)
1358 return JSValueMakeUndefined(context);
1360 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1361 controller->setAllowFileAccessFromFileURLs(JSValueToBoolean(context, arguments[0]));
1363 return JSValueMakeUndefined(context);
1366 static JSValueRef setTabKeyCyclesThroughElementsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1368 // Has mac & windows implementation
1369 if (argumentCount < 1)
1370 return JSValueMakeUndefined(context);
1372 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1373 controller->setTabKeyCyclesThroughElements(JSValueToBoolean(context, arguments[0]));
1375 return JSValueMakeUndefined(context);
1378 static JSValueRef setTimelineProfilingEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1380 if (argumentCount < 1)
1381 return JSValueMakeUndefined(context);
1383 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1384 controller->setTimelineProfilingEnabled(JSValueToBoolean(context, arguments[0]));
1385 return JSValueMakeUndefined(context);
1388 static JSValueRef setUseDashboardCompatibilityModeCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1390 // Has mac implementation
1391 if (argumentCount < 1)
1392 return JSValueMakeUndefined(context);
1394 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1395 controller->setUseDashboardCompatibilityMode(JSValueToBoolean(context, arguments[0]));
1397 return JSValueMakeUndefined(context);
1400 static JSValueRef setUserStyleSheetEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1402 // Has mac implementation
1403 if (argumentCount < 1)
1404 return JSValueMakeUndefined(context);
1406 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1407 controller->setUserStyleSheetEnabled(JSValueToBoolean(context, arguments[0]));
1409 return JSValueMakeUndefined(context);
1412 static JSValueRef setUserStyleSheetLocationCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1414 // Has mac implementation
1415 if (argumentCount < 1)
1416 return JSValueMakeUndefined(context);
1418 JSRetainPtr<JSStringRef> path(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1419 ASSERT(!*exception);
1421 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1422 controller->setUserStyleSheetLocation(path.get());
1424 return JSValueMakeUndefined(context);
1427 static JSValueRef setViewModeMediaFeatureCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1429 // Has mac implementation
1430 if (argumentCount < 1)
1431 return JSValueMakeUndefined(context);
1433 JSRetainPtr<JSStringRef> mode(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1434 ASSERT(!*exception);
1436 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1437 controller->setViewModeMediaFeature(mode.get());
1439 return JSValueMakeUndefined(context);
1442 static JSValueRef setWillSendRequestClearHeaderCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1444 // Has mac & windows implementation
1445 if (argumentCount < 1)
1446 return JSValueMakeUndefined(context);
1448 JSRetainPtr<JSStringRef> header(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1449 ASSERT(!*exception);
1451 size_t maxLength = JSStringGetMaximumUTF8CStringSize(header.get());
1452 char* headerBuffer = new char[maxLength + 1];
1453 JSStringGetUTF8CString(header.get(), headerBuffer, maxLength + 1);
1455 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1456 controller->setWillSendRequestClearHeader(headerBuffer);
1458 return JSValueMakeUndefined(context);
1461 static JSValueRef setWillSendRequestReturnsNullCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1463 // Has cross-platform implementation
1464 if (argumentCount < 1)
1465 return JSValueMakeUndefined(context);
1467 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1468 controller->setWillSendRequestReturnsNull(JSValueToBoolean(context, arguments[0]));
1470 return JSValueMakeUndefined(context);
1473 static JSValueRef setWillSendRequestReturnsNullOnRedirectCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1475 // Has cross-platform implementation
1476 if (argumentCount < 1)
1477 return JSValueMakeUndefined(context);
1479 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1480 controller->setWillSendRequestReturnsNullOnRedirect(JSValueToBoolean(context, arguments[0]));
1482 return JSValueMakeUndefined(context);
1485 static JSValueRef setWindowIsKeyCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1487 // Has mac implementation
1488 if (argumentCount < 1)
1489 return JSValueMakeUndefined(context);
1491 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1492 controller->setWindowIsKey(JSValueToBoolean(context, arguments[0]));
1494 return JSValueMakeUndefined(context);
1497 static JSValueRef waitUntilDoneCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1499 // Has mac & windows implementation
1500 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1501 controller->setWaitToDump(true);
1503 return JSValueMakeUndefined(context);
1506 static JSValueRef windowCountCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1508 // Has mac implementation
1509 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1510 int windows = controller->windowCount();
1511 return JSValueMakeNumber(context, windows);
1514 static JSValueRef setPopupBlockingEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1516 // Has mac & windows implementation
1517 if (argumentCount < 1)
1518 return JSValueMakeUndefined(context);
1520 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1521 controller->setPopupBlockingEnabled(JSValueToBoolean(context, arguments[0]));
1523 return JSValueMakeUndefined(context);
1526 static JSValueRef setPluginsEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1528 // Has mac & windows implementation
1529 if (argumentCount < 1)
1530 return JSValueMakeUndefined(context);
1532 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1533 controller->setPluginsEnabled(JSValueToBoolean(context, arguments[0]));
1535 return JSValueMakeUndefined(context);
1538 static JSValueRef setSmartInsertDeleteEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1540 if (argumentCount < 1)
1541 return JSValueMakeUndefined(context);
1543 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1544 controller->setSmartInsertDeleteEnabled(JSValueToBoolean(context, arguments[0]));
1545 return JSValueMakeUndefined(context);
1548 static JSValueRef setSelectTrailingWhitespaceEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1550 if (argumentCount < 1)
1551 return JSValueMakeUndefined(context);
1553 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1554 controller->setSelectTrailingWhitespaceEnabled(JSValueToBoolean(context, arguments[0]));
1555 return JSValueMakeUndefined(context);
1558 static JSValueRef setStopProvisionalFrameLoadsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1560 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1561 controller->setStopProvisionalFrameLoads(true);
1562 return JSValueMakeUndefined(context);
1565 static JSValueRef setAsynchronousSpellCheckingEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1567 if (argumentCount < 1)
1568 return JSValueMakeUndefined(context);
1570 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1571 controller->setAsynchronousSpellCheckingEnabled(JSValueToBoolean(context, arguments[0]));
1572 return JSValueMakeUndefined(context);
1575 static JSValueRef showWebInspectorCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1577 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1578 controller->showWebInspector();
1579 return JSValueMakeUndefined(context);
1582 static JSValueRef closeWebInspectorCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1584 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1585 controller->setTimelineProfilingEnabled(false);
1586 controller->closeWebInspector();
1587 return JSValueMakeUndefined(context);
1590 static JSValueRef evaluateInWebInspectorCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1592 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1593 double callId = JSValueToNumber(context, arguments[0], exception);
1594 ASSERT(!*exception);
1595 JSRetainPtr<JSStringRef> script(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1596 ASSERT(!*exception);
1598 controller->evaluateInWebInspector(static_cast<long>(callId), script.get());
1599 return JSValueMakeUndefined(context);
1602 static JSValueRef evaluateScriptInIsolatedWorldCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1604 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1605 double worldID = JSValueToNumber(context, arguments[0], exception);
1606 ASSERT(!*exception);
1607 JSRetainPtr<JSStringRef> script(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1608 ASSERT(!*exception);
1610 controller->evaluateScriptInIsolatedWorld(static_cast<unsigned>(worldID), JSContextGetGlobalObject(context), script.get());
1611 return JSValueMakeUndefined(context);
1614 static JSValueRef elementDoesAutoCompleteForElementWithIdCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1616 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1617 JSRetainPtr<JSStringRef> elementId(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1618 ASSERT(!*exception);
1620 bool autoCompletes = controller->elementDoesAutoCompleteForElementWithId(elementId.get());
1622 return JSValueMakeBoolean(context, autoCompletes);
1625 static JSValueRef pauseAnimationAtTimeOnElementWithIdCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1627 if (argumentCount != 3)
1628 return JSValueMakeUndefined(context);
1630 JSRetainPtr<JSStringRef> animationName(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1631 ASSERT(!*exception);
1632 double time = JSValueToNumber(context, arguments[1], exception);
1633 ASSERT(!*exception);
1634 JSRetainPtr<JSStringRef> elementId(Adopt, JSValueToStringCopy(context, arguments[2], exception));
1635 ASSERT(!*exception);
1637 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1638 return JSValueMakeBoolean(context, controller->pauseAnimationAtTimeOnElementWithId(animationName.get(), time, elementId.get()));
1641 static JSValueRef pauseTransitionAtTimeOnElementWithIdCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1643 if (argumentCount != 3)
1644 return JSValueMakeUndefined(context);
1646 JSRetainPtr<JSStringRef> propertyName(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1647 ASSERT(!*exception);
1648 double time = JSValueToNumber(context, arguments[1], exception);
1649 ASSERT(!*exception);
1650 JSRetainPtr<JSStringRef> elementId(Adopt, JSValueToStringCopy(context, arguments[2], exception));
1651 ASSERT(!*exception);
1653 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1654 return JSValueMakeBoolean(context, controller->pauseTransitionAtTimeOnElementWithId(propertyName.get(), time, elementId.get()));
1657 static JSValueRef sampleSVGAnimationForElementAtTimeCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1659 if (argumentCount != 3)
1660 return JSValueMakeUndefined(context);
1662 JSRetainPtr<JSStringRef> animationId(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1663 ASSERT(!*exception);
1664 double time = JSValueToNumber(context, arguments[1], exception);
1665 ASSERT(!*exception);
1666 JSRetainPtr<JSStringRef> elementId(Adopt, JSValueToStringCopy(context, arguments[2], exception));
1667 ASSERT(!*exception);
1669 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1670 return JSValueMakeBoolean(context, controller->sampleSVGAnimationForElementAtTime(animationId.get(), time, elementId.get()));
1673 static JSValueRef numberOfActiveAnimationsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1675 if (argumentCount != 0)
1676 return JSValueMakeUndefined(context);
1678 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1679 return JSValueMakeNumber(context, controller->numberOfActiveAnimations());
1682 static JSValueRef suspendAnimationsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1684 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1685 controller->suspendAnimations();
1686 return JSValueMakeUndefined(context);
1689 static JSValueRef resumeAnimationsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1691 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1692 controller->resumeAnimations();
1693 return JSValueMakeUndefined(context);
1696 static JSValueRef waitForPolicyDelegateCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t, const JSValueRef[], JSValueRef*)
1698 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1699 controller->waitForPolicyDelegate();
1700 return JSValueMakeUndefined(context);
1703 static JSValueRef addOriginAccessWhitelistEntryCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1705 if (argumentCount != 4)
1706 return JSValueMakeUndefined(context);
1708 JSRetainPtr<JSStringRef> sourceOrigin(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1709 ASSERT(!*exception);
1710 JSRetainPtr<JSStringRef> destinationProtocol(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1711 ASSERT(!*exception);
1712 JSRetainPtr<JSStringRef> destinationHost(Adopt, JSValueToStringCopy(context, arguments[2], exception));
1713 ASSERT(!*exception);
1714 bool allowDestinationSubdomains = JSValueToBoolean(context, arguments[3]);
1716 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1717 controller->addOriginAccessWhitelistEntry(sourceOrigin.get(), destinationProtocol.get(), destinationHost.get(), allowDestinationSubdomains);
1718 return JSValueMakeUndefined(context);
1721 static JSValueRef removeOriginAccessWhitelistEntryCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1723 if (argumentCount != 4)
1724 return JSValueMakeUndefined(context);
1726 JSRetainPtr<JSStringRef> sourceOrigin(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1727 ASSERT(!*exception);
1728 JSRetainPtr<JSStringRef> destinationProtocol(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1729 ASSERT(!*exception);
1730 JSRetainPtr<JSStringRef> destinationHost(Adopt, JSValueToStringCopy(context, arguments[2], exception));
1731 ASSERT(!*exception);
1732 bool allowDestinationSubdomains = JSValueToBoolean(context, arguments[3]);
1734 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1735 controller->removeOriginAccessWhitelistEntry(sourceOrigin.get(), destinationProtocol.get(), destinationHost.get(), allowDestinationSubdomains);
1736 return JSValueMakeUndefined(context);
1739 static JSValueRef setScrollbarPolicyCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1741 if (argumentCount != 2)
1742 return JSValueMakeUndefined(context);
1744 JSRetainPtr<JSStringRef> orientation(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1745 ASSERT(!*exception);
1746 JSRetainPtr<JSStringRef> policy(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1747 ASSERT(!*exception);
1749 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1750 controller->setScrollbarPolicy(orientation.get(), policy.get());
1751 return JSValueMakeUndefined(context);
1754 static JSValueRef addUserScriptCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1756 if (argumentCount != 3)
1757 return JSValueMakeUndefined(context);
1759 JSRetainPtr<JSStringRef> source(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1760 ASSERT(!*exception);
1761 bool runAtStart = JSValueToBoolean(context, arguments[1]);
1762 bool allFrames = JSValueToBoolean(context, arguments[2]);
1764 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1765 controller->addUserScript(source.get(), runAtStart, allFrames);
1766 return JSValueMakeUndefined(context);
1769 static JSValueRef addUserStyleSheetCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1771 if (argumentCount != 2)
1772 return JSValueMakeUndefined(context);
1774 JSRetainPtr<JSStringRef> source(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1775 ASSERT(!*exception);
1776 bool allFrames = JSValueToBoolean(context, arguments[1]);
1778 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1779 controller->addUserStyleSheet(source.get(), allFrames);
1780 return JSValueMakeUndefined(context);
1783 static JSValueRef apiTestNewWindowDataLoadBaseURLCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1785 if (argumentCount != 2)
1786 return JSValueMakeUndefined(context);
1788 JSRetainPtr<JSStringRef> utf8Data(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1789 ASSERT(!*exception);
1791 JSRetainPtr<JSStringRef> baseURL(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1792 ASSERT(!*exception);
1794 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1795 controller->apiTestNewWindowDataLoadBaseURL(utf8Data.get(), baseURL.get());
1796 return JSValueMakeUndefined(context);
1799 static JSValueRef apiTestGoToCurrentBackForwardItemCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1801 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1802 controller->apiTestGoToCurrentBackForwardItem();
1803 return JSValueMakeUndefined(context);
1806 static JSValueRef setWebViewEditableCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1808 // Has Mac implementation
1809 if (argumentCount < 1)
1810 return JSValueMakeUndefined(context);
1812 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1813 controller->setWebViewEditable(JSValueToBoolean(context, arguments[0]));
1815 return JSValueMakeUndefined(context);
1819 static JSValueRef abortModalCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1821 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1822 controller->abortModal();
1823 return JSValueMakeUndefined(context);
1826 static JSValueRef hasSpellingMarkerCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1828 if (argumentCount != 2)
1829 return JSValueMakeUndefined(context);
1831 int from = JSValueToNumber(context, arguments[0], 0);
1832 int length = JSValueToNumber(context, arguments[1], 0);
1833 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1834 bool ok = controller->hasSpellingMarker(from, length);
1836 return JSValueMakeBoolean(context, ok);
1839 static JSValueRef markerTextForListItemCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1841 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1842 if (argumentCount < 1)
1843 return JSValueMakeUndefined(context);
1844 return JSValueMakeString(context, controller->markerTextForListItem(context, arguments[0]).get());
1847 static JSValueRef authenticateSessionCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1849 // authenticateSession(url, username, password)
1850 if (argumentCount != 3)
1851 return JSValueMakeUndefined(context);
1853 JSRetainPtr<JSStringRef> url(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1854 ASSERT(!*exception);
1855 JSRetainPtr<JSStringRef> username(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1856 ASSERT(!*exception);
1857 JSRetainPtr<JSStringRef> password(Adopt, JSValueToStringCopy(context, arguments[2], exception));
1858 ASSERT(!*exception);
1860 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1861 controller->authenticateSession(url.get(), username.get(), password.get());
1862 return JSValueMakeUndefined(context);
1865 static JSValueRef setEditingBehaviorCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1867 // The editing behavior string.
1868 if (argumentCount < 1)
1869 return JSValueMakeUndefined(context);
1871 JSRetainPtr<JSStringRef> editingBehavior(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1872 ASSERT(!*exception);
1874 size_t maxLength = JSStringGetMaximumUTF8CStringSize(editingBehavior.get());
1875 char* behaviorBuffer = new char[maxLength + 1];
1876 JSStringGetUTF8CString(editingBehavior.get(), behaviorBuffer, maxLength);
1878 if (strcmp(behaviorBuffer, "mac") && strcmp(behaviorBuffer, "win") && strcmp(behaviorBuffer, "unix")) {
1879 JSRetainPtr<JSStringRef> invalidArgument(JSStringCreateWithUTF8CString("Passed invalid editing behavior. Must be 'mac', 'win', or 'unix'."));
1880 *exception = JSValueMakeString(context, invalidArgument.get());
1881 return JSValueMakeUndefined(context);
1884 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1885 controller->setEditingBehavior(behaviorBuffer);
1887 delete [] behaviorBuffer;
1889 return JSValueMakeUndefined(context);
1892 static JSValueRef setSerializeHTTPLoadsCallback(JSContextRef context, JSObjectRef, JSObjectRef, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1894 bool serialize = true;
1895 if (argumentCount == 1)
1896 serialize = JSValueToBoolean(context, arguments[0]);
1898 LayoutTestController::setSerializeHTTPLoads(serialize);
1899 return JSValueMakeUndefined(context);
1904 static JSValueRef getGlobalFlagCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
1906 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1907 return JSValueMakeBoolean(context, controller->globalFlag());
1910 static JSValueRef getWebHistoryItemCountCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
1912 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1913 return JSValueMakeNumber(context, controller->webHistoryItemCount());
1916 static JSValueRef getWorkerThreadCountCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
1918 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1919 return JSValueMakeNumber(context, controller->workerThreadCount());
1922 static bool setGlobalFlagCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef value, JSValueRef* exception)
1924 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1925 controller->setGlobalFlag(JSValueToBoolean(context, value));
1929 static void layoutTestControllerObjectFinalize(JSObjectRef object)
1931 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(object));
1932 controller->deref();
1937 void LayoutTestController::makeWindowObject(JSContextRef context, JSObjectRef windowObject, JSValueRef* exception)
1939 JSRetainPtr<JSStringRef> layoutTestContollerStr(Adopt, JSStringCreateWithUTF8CString("layoutTestController"));
1942 JSClassRef classRef = getJSClass();
1943 JSValueRef layoutTestContollerObject = JSObjectMake(context, classRef, this);
1944 JSClassRelease(classRef);
1946 JSObjectSetProperty(context, windowObject, layoutTestContollerStr.get(), layoutTestContollerObject, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete, exception);
1949 JSClassRef LayoutTestController::getJSClass()
1951 static JSStaticValue* staticValues = LayoutTestController::staticValues();
1952 static JSStaticFunction* staticFunctions = LayoutTestController::staticFunctions();
1953 static JSClassDefinition classDefinition = {
1954 0, kJSClassAttributeNone, "LayoutTestController", 0, staticValues, staticFunctions,
1955 0, layoutTestControllerObjectFinalize, 0, 0, 0, 0, 0, 0, 0, 0, 0
1958 return JSClassCreate(&classDefinition);
1961 JSStaticValue* LayoutTestController::staticValues()
1963 static JSStaticValue staticValues[] = {
1964 { "globalFlag", getGlobalFlagCallback, setGlobalFlagCallback, kJSPropertyAttributeNone },
1965 { "webHistoryItemCount", getWebHistoryItemCountCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1966 { "workerThreadCount", getWorkerThreadCountCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1969 return staticValues;
1972 JSStaticFunction* LayoutTestController::staticFunctions()
1974 static JSStaticFunction staticFunctions[] = {
1975 { "abortModal", abortModalCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1976 { "addDisallowedURL", addDisallowedURLCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1977 { "addURLToRedirect", addURLToRedirectCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1978 { "addUserScript", addUserScriptCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1979 { "addUserStyleSheet", addUserStyleSheetCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1980 { "apiTestNewWindowDataLoadBaseURL", apiTestNewWindowDataLoadBaseURLCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1981 { "apiTestGoToCurrentBackForwardItem", apiTestGoToCurrentBackForwardItemCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1982 { "callShouldCloseOnWebView", callShouldCloseOnWebViewCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1983 { "clearAllApplicationCaches", clearAllApplicationCachesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1984 { "clearAllDatabases", clearAllDatabasesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1985 { "clearBackForwardList", clearBackForwardListCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1986 { "clearPersistentUserStyleSheet", clearPersistentUserStyleSheetCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1987 { "closeWebInspector", closeWebInspectorCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1988 { "computedStyleIncludingVisitedInfo", computedStyleIncludingVisitedInfoCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1989 { "nodesFromRect", nodesFromRectCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1990 { "decodeHostName", decodeHostNameCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1991 { "disableImageLoading", disableImageLoadingCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1992 { "dispatchPendingLoadRequests", dispatchPendingLoadRequestsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1993 { "display", displayCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1994 { "displayInvalidatedRegion", displayInvalidatedRegionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1995 { "dumpApplicationCacheDelegateCallbacks", dumpApplicationCacheDelegateCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1996 { "dumpAsText", dumpAsTextCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1997 { "dumpBackForwardList", dumpBackForwardListCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1998 { "dumpChildFrameScrollPositions", dumpChildFrameScrollPositionsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1999 { "dumpChildFramesAsText", dumpChildFramesAsTextCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2000 { "dumpConfigurationForViewport", dumpConfigurationForViewportCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2001 { "dumpDOMAsWebArchive", dumpDOMAsWebArchiveCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2002 { "dumpDatabaseCallbacks", dumpDatabaseCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2003 { "dumpEditingCallbacks", dumpEditingCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2004 { "dumpFrameLoadCallbacks", dumpFrameLoadCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2005 { "dumpUserGestureInFrameLoadCallbacks", dumpUserGestureInFrameLoadCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2006 { "dumpResourceLoadCallbacks", dumpResourceLoadCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2007 { "dumpResourceResponseMIMETypes", dumpResourceResponseMIMETypesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2008 { "dumpSelectionRect", dumpSelectionRectCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2009 { "dumpSourceAsWebArchive", dumpSourceAsWebArchiveCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2010 { "dumpStatusCallbacks", dumpStatusCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2011 { "dumpTitleChanges", dumpTitleChangesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2012 { "dumpIconChanges", dumpIconChangesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2013 { "dumpWillCacheResponse", dumpWillCacheResponseCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2014 { "elementDoesAutoCompleteForElementWithId", elementDoesAutoCompleteForElementWithIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2015 { "encodeHostName", encodeHostNameCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2016 { "evaluateInWebInspector", evaluateInWebInspectorCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2017 { "evaluateScriptInIsolatedWorld", evaluateScriptInIsolatedWorldCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2018 { "execCommand", execCommandCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2019 { "findString", findStringCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2020 { "counterValueForElementById", counterValueForElementByIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2021 { "grantDesktopNotificationPermission", grantDesktopNotificationPermissionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2022 { "hasSpellingMarker", hasSpellingMarkerCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2023 { "isCommandEnabled", isCommandEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2024 { "isPageBoxVisible", isPageBoxVisibleCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2025 { "keepWebHistory", keepWebHistoryCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2026 { "layerTreeAsText", layerTreeAsTextCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2027 { "numberOfPages", numberOfPagesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2028 { "markerTextForListItem", markerTextForListItemCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2029 { "notifyDone", notifyDoneCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2030 { "numberOfActiveAnimations", numberOfActiveAnimationsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2031 { "suspendAnimations", suspendAnimationsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2032 { "resumeAnimations", resumeAnimationsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2033 { "overridePreference", overridePreferenceCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2034 { "pageNumberForElementById", pageNumberForElementByIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2035 { "pageSizeAndMarginsInPixels", pageSizeAndMarginsInPixelsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2036 { "pageProperty", pagePropertyCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2037 { "pathToLocalResource", pathToLocalResourceCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2038 { "pauseAnimationAtTimeOnElementWithId", pauseAnimationAtTimeOnElementWithIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2039 { "pauseTransitionAtTimeOnElementWithId", pauseTransitionAtTimeOnElementWithIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2040 { "sampleSVGAnimationForElementAtTime", sampleSVGAnimationForElementAtTimeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2041 { "printToPDF", dumpAsPDFCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2042 { "queueBackNavigation", queueBackNavigationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2043 { "queueForwardNavigation", queueForwardNavigationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2044 { "queueLoad", queueLoadCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2045 { "queueLoadHTMLString", queueLoadHTMLStringCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2046 { "queueLoadingScript", queueLoadingScriptCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2047 { "queueNonLoadingScript", queueNonLoadingScriptCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2048 { "queueReload", queueReloadCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2049 { "removeAllVisitedLinks", removeAllVisitedLinksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2050 { "removeOriginAccessWhitelistEntry", removeOriginAccessWhitelistEntryCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2051 { "repaintSweepHorizontally", repaintSweepHorizontallyCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2052 { "setAcceptsEditing", setAcceptsEditingCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2053 { "setAllowUniversalAccessFromFileURLs", setAllowUniversalAccessFromFileURLsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2054 { "setAllowFileAccessFromFileURLs", setAllowFileAccessFromFileURLsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2055 { "setAlwaysAcceptCookies", setAlwaysAcceptCookiesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2056 { "setAppCacheMaximumSize", setAppCacheMaximumSizeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2057 { "setApplicationCacheOriginQuota", setApplicationCacheOriginQuotaCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2058 { "setAuthenticationPassword", setAuthenticationPasswordCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2059 { "setAuthenticationUsername", setAuthenticationUsernameCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2060 { "setAuthorAndUserStylesEnabled", setAuthorAndUserStylesEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2061 { "setCacheModel", setCacheModelCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2062 { "setCallCloseOnWebViews", setCallCloseOnWebViewsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2063 { "setCanOpenWindows", setCanOpenWindowsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2064 { "setCloseRemainingWindowsWhenComplete", setCloseRemainingWindowsWhenCompleteCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2065 { "setCustomPolicyDelegate", setCustomPolicyDelegateCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2066 { "setDatabaseQuota", setDatabaseQuotaCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2067 { "setDeferMainResourceDataLoad", setDeferMainResourceDataLoadCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2068 { "setDomainRelaxationForbiddenForURLScheme", setDomainRelaxationForbiddenForURLSchemeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2069 { "setEditingBehavior", setEditingBehaviorCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2070 { "setFrameFlatteningEnabled", setFrameFlatteningEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2071 { "setGeolocationPermission", setGeolocationPermissionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2072 { "setHandlesAuthenticationChallenges", setHandlesAuthenticationChallengesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2073 { "setIconDatabaseEnabled", setIconDatabaseEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2074 { "setJavaScriptProfilingEnabled", setJavaScriptProfilingEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2075 { "setMainFrameIsFirstResponder", setMainFrameIsFirstResponderCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2076 { "setMockDeviceOrientation", setMockDeviceOrientationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2077 { "setMockGeolocationError", setMockGeolocationErrorCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2078 { "setMockGeolocationPosition", setMockGeolocationPositionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2079 { "addMockSpeechInputResult", addMockSpeechInputResultCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2080 { "setNewWindowsCopyBackForwardList", setNewWindowsCopyBackForwardListCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2081 { "setPOSIXLocale", setPOSIXLocaleCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2082 { "setPersistentUserStyleSheetLocation", setPersistentUserStyleSheetLocationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2083 { "setPopupBlockingEnabled", setPopupBlockingEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2084 { "setPluginsEnabled", setPluginsEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2085 { "setPrinting", setPrintingCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2086 { "setPrivateBrowsingEnabled", setPrivateBrowsingEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2087 { "setSelectTrailingWhitespaceEnabled", setSelectTrailingWhitespaceEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2088 { "setSerializeHTTPLoads", setSerializeHTTPLoadsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2089 { "setSmartInsertDeleteEnabled", setSmartInsertDeleteEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2090 { "setSpatialNavigationEnabled", setSpatialNavigationEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2091 { "setStopProvisionalFrameLoads", setStopProvisionalFrameLoadsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2092 { "setTabKeyCyclesThroughElements", setTabKeyCyclesThroughElementsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2093 { "setTimelineProfilingEnabled", setTimelineProfilingEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2094 { "setUseDashboardCompatibilityMode", setUseDashboardCompatibilityModeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2095 { "setUserStyleSheetEnabled", setUserStyleSheetEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2096 { "setUserStyleSheetLocation", setUserStyleSheetLocationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2097 { "setViewModeMediaFeature", setViewModeMediaFeatureCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2098 { "setWebViewEditable", setWebViewEditableCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2099 { "setWillSendRequestClearHeader", setWillSendRequestClearHeaderCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2100 { "setWillSendRequestReturnsNull", setWillSendRequestReturnsNullCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2101 { "setWillSendRequestReturnsNullOnRedirect", setWillSendRequestReturnsNullOnRedirectCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2102 { "setWindowIsKey", setWindowIsKeyCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2103 { "setJavaScriptCanAccessClipboard", setJavaScriptCanAccessClipboardCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2104 { "setXSSAuditorEnabled", setXSSAuditorEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2105 { "setAsynchronousSpellCheckingEnabled", setAsynchronousSpellCheckingEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2106 { "showWebInspector", showWebInspectorCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2107 { "testOnscreen", testOnscreenCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2108 { "testRepaint", testRepaintCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2109 { "waitForPolicyDelegate", waitForPolicyDelegateCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2110 { "waitUntilDone", waitUntilDoneCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2111 { "windowCount", windowCountCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2112 { "addOriginAccessWhitelistEntry", addOriginAccessWhitelistEntryCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2113 { "setScrollbarPolicy", setScrollbarPolicyCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2114 { "authenticateSession", authenticateSessionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2118 return staticFunctions;
2121 void LayoutTestController::queueLoadHTMLString(JSStringRef content, JSStringRef baseURL)
2123 WorkQueue::shared()->queue(new LoadHTMLStringItem(content, baseURL));
2126 void LayoutTestController::queueLoadAlternateHTMLString(JSStringRef content, JSStringRef baseURL, JSStringRef unreachableURL)
2128 WorkQueue::shared()->queue(new LoadHTMLStringItem(content, baseURL, unreachableURL));
2131 void LayoutTestController::queueBackNavigation(int howFarBack)
2133 WorkQueue::shared()->queue(new BackItem(howFarBack));
2136 void LayoutTestController::queueForwardNavigation(int howFarForward)
2138 WorkQueue::shared()->queue(new ForwardItem(howFarForward));
2141 void LayoutTestController::queueLoadingScript(JSStringRef script)
2143 WorkQueue::shared()->queue(new LoadingScriptItem(script));
2146 void LayoutTestController::queueNonLoadingScript(JSStringRef script)
2148 WorkQueue::shared()->queue(new NonLoadingScriptItem(script));
2151 void LayoutTestController::queueReload()
2153 WorkQueue::shared()->queue(new ReloadItem);
2156 void LayoutTestController::grantDesktopNotificationPermission(JSStringRef origin)
2158 m_desktopNotificationAllowedOrigins.push_back(JSStringRetain(origin));
2161 bool LayoutTestController::checkDesktopNotificationPermission(JSStringRef origin)
2163 std::vector<JSStringRef>::iterator i;
2164 for (i = m_desktopNotificationAllowedOrigins.begin();
2165 i != m_desktopNotificationAllowedOrigins.end();
2167 if (JSStringIsEqual(*i, origin))
2173 void LayoutTestController::waitToDumpWatchdogTimerFired()
2175 const char* message = "FAIL: Timed out waiting for notifyDone to be called\n";
2176 fprintf(stderr, "%s", message);
2177 fprintf(stdout, "%s", message);
2181 void LayoutTestController::setGeolocationPermissionCommon(bool allow)
2183 m_isGeolocationPermissionSet = true;
2184 m_geolocationPermission = allow;
2187 void LayoutTestController::setPOSIXLocale(JSStringRef locale)
2190 JSStringGetUTF8CString(locale, localeBuf, sizeof(localeBuf));
2191 setlocale(LC_ALL, localeBuf);
2194 void LayoutTestController::addURLToRedirect(std::string origin, std::string destination)
2196 m_URLsToRedirect[origin] = destination;
2199 const std::string& LayoutTestController::redirectionDestinationForURL(std::string origin)
2201 return m_URLsToRedirect[origin];
2204 const unsigned LayoutTestController::maxViewWidth = 800;
2205 const unsigned LayoutTestController::maxViewHeight = 600;