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 encodeHostNameCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
450 // Has mac implementation
451 if (argumentCount < 1)
452 return JSValueMakeUndefined(context);
454 JSRetainPtr<JSStringRef> name(Adopt, JSValueToStringCopy(context, arguments[0], exception));
457 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
458 JSRetainPtr<JSStringRef> encodedHostName(Adopt, controller->copyEncodedHostName(name.get()));
459 return JSValueMakeString(context, encodedHostName.get());
462 static JSValueRef execCommandCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
464 // Has Mac & Windows implementations.
465 if (argumentCount < 1)
466 return JSValueMakeUndefined(context);
468 JSRetainPtr<JSStringRef> name(Adopt, JSValueToStringCopy(context, arguments[0], exception));
471 // Ignoring the second parameter (userInterface), as this command emulates a manual action.
473 JSRetainPtr<JSStringRef> value;
474 if (argumentCount >= 3) {
475 value.adopt(JSValueToStringCopy(context, arguments[2], exception));
478 value.adopt(JSStringCreateWithUTF8CString(""));
481 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
482 controller->execCommand(name.get(), value.get());
484 return JSValueMakeUndefined(context);
487 static JSValueRef findStringCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
489 // Has Mac implementation.
490 if (argumentCount < 2)
491 return JSValueMakeUndefined(context);
493 JSRetainPtr<JSStringRef> target(Adopt, JSValueToStringCopy(context, arguments[0], exception));
496 JSObjectRef options = JSValueToObject(context, arguments[1], exception);
499 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
500 return JSValueMakeBoolean(context, controller->findString(context, target.get(), options));
503 static JSValueRef counterValueForElementByIdCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
505 if (argumentCount < 1)
506 return JSValueMakeUndefined(context);
508 JSRetainPtr<JSStringRef> elementId(Adopt, JSValueToStringCopy(context, arguments[0], exception));
510 return JSValueMakeUndefined(context);
512 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
513 JSRetainPtr<JSStringRef> counterValue(controller->counterValueForElementById(elementId.get()));
514 if (!counterValue.get())
515 return JSValueMakeUndefined(context);
516 return JSValueMakeString(context, counterValue.get());
519 static JSValueRef grantDesktopNotificationPermissionCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
521 // Has Windows implementation
522 if (argumentCount < 1)
523 return JSValueMakeUndefined(context);
525 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
527 controller->grantDesktopNotificationPermission(JSValueToStringCopy(context, arguments[0], NULL));
529 return JSValueMakeUndefined(context);
532 static JSValueRef isCommandEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
534 // Has Mac implementation.
536 if (argumentCount < 1)
537 return JSValueMakeUndefined(context);
539 JSRetainPtr<JSStringRef> name(Adopt, JSValueToStringCopy(context, arguments[0], exception));
542 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
544 return JSValueMakeBoolean(context, controller->isCommandEnabled(name.get()));
547 static JSValueRef overridePreferenceCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
549 if (argumentCount < 2)
550 return JSValueMakeUndefined(context);
552 JSRetainPtr<JSStringRef> key(Adopt, JSValueToStringCopy(context, arguments[0], exception));
554 JSRetainPtr<JSStringRef> value(Adopt, JSValueToStringCopy(context, arguments[1], exception));
557 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
558 controller->overridePreference(key.get(), value.get());
560 return JSValueMakeUndefined(context);
563 static JSValueRef keepWebHistoryCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
565 // Has mac implementation
566 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
567 controller->keepWebHistory();
569 return JSValueMakeUndefined(context);
572 static JSValueRef computedStyleIncludingVisitedInfoCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
574 if (argumentCount != 1)
575 return JSValueMakeUndefined(context);
577 // Has mac implementation
578 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
579 return controller->computedStyleIncludingVisitedInfo(context, arguments[0]);
582 static JSValueRef nodesFromRectCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
584 if (argumentCount != 8)
585 return JSValueMakeUndefined(context);
587 int x = JSValueToNumber(context, arguments[1], NULL);
588 int y = JSValueToNumber(context, arguments[2], NULL);
589 int top = static_cast<unsigned>(JSValueToNumber(context, arguments[3], NULL));
590 int right = static_cast<unsigned>(JSValueToNumber(context, arguments[4], NULL));
591 int bottom = static_cast<unsigned>(JSValueToNumber(context, arguments[5], NULL));
592 int left = static_cast<unsigned>(JSValueToNumber(context, arguments[6], NULL));
593 bool ignoreClipping = JSValueToBoolean(context, arguments[7]);
595 // Has mac implementation.
596 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
597 return controller->nodesFromRect(context, arguments[0], x, y, top, right, bottom, left, ignoreClipping);
600 static JSValueRef layerTreeAsTextCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
602 // Has mac & windows implementation
603 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
604 return JSValueMakeString(context, controller->layerTreeAsText().get());
607 static JSValueRef notifyDoneCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
609 // Has mac & windows implementation
610 // May be able to be made platform independant by using shared WorkQueue
611 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
612 controller->notifyDone();
613 return JSValueMakeUndefined(context);
616 static bool parsePageParameters(JSContextRef context, int argumentCount, const JSValueRef* arguments, JSValueRef* exception, float& pageWidthInPixels, float& pageHeightInPixels)
618 pageWidthInPixels = LayoutTestController::maxViewWidth;
619 pageHeightInPixels = LayoutTestController::maxViewHeight;
620 switch (argumentCount) {
622 pageWidthInPixels = static_cast<float>(JSValueToNumber(context, arguments[0], exception));
625 pageHeightInPixels = static_cast<float>(JSValueToNumber(context, arguments[1], exception));
628 case 0: // Fall through.
636 // Caller needs to delete[] propertyName.
637 static bool parsePagePropertyParameters(JSContextRef context, int argumentCount, const JSValueRef* arguments, JSValueRef* exception, char*& propertyName, int& pageNumber)
640 switch (argumentCount) {
642 pageNumber = static_cast<float>(JSValueToNumber(context, arguments[1], exception));
647 JSRetainPtr<JSStringRef> propertyNameString(Adopt, JSValueToStringCopy(context, arguments[0], exception));
651 size_t maxLength = JSStringGetMaximumUTF8CStringSize(propertyNameString.get());
652 propertyName = new char[maxLength + 1];
653 JSStringGetUTF8CString(propertyNameString.get(), propertyName, maxLength + 1);
662 static bool parsePageNumber(JSContextRef context, int argumentCount, const JSValueRef* arguments, JSValueRef* exception, int& pageNumber)
665 switch (argumentCount) {
667 pageNumber = static_cast<int>(JSValueToNumber(context, arguments[0], exception));
678 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)
682 marginTop = marginRight = marginBottom = marginLeft = 0;
684 switch (argumentCount) {
686 marginLeft = static_cast<int>(JSValueToNumber(context, arguments[6], exception));
691 marginBottom = static_cast<int>(JSValueToNumber(context, arguments[5], exception));
696 marginRight = static_cast<int>(JSValueToNumber(context, arguments[4], exception));
701 marginTop = static_cast<int>(JSValueToNumber(context, arguments[3], exception));
706 height = static_cast<int>(JSValueToNumber(context, arguments[2], exception));
711 width = static_cast<int>(JSValueToNumber(context, arguments[1], exception));
716 pageNumber = static_cast<int>(JSValueToNumber(context, arguments[0], exception));
726 static JSValueRef pageNumberForElementByIdCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
728 float pageWidthInPixels = 0;
729 float pageHeightInPixels = 0;
730 if (!parsePageParameters(context, argumentCount - 1, arguments + 1, exception, pageWidthInPixels, pageHeightInPixels))
731 return JSValueMakeUndefined(context);
733 JSRetainPtr<JSStringRef> elementId(Adopt, JSValueToStringCopy(context, arguments[0], exception));
735 return JSValueMakeUndefined(context);
737 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
738 int pageNumber = controller->pageNumberForElementById(elementId.get(), pageWidthInPixels, pageHeightInPixels);
739 return JSValueMakeNumber(context, pageNumber);
742 static JSValueRef numberOfPagesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
744 float pageWidthInPixels = 0;
745 float pageHeightInPixels = 0;
746 if (!parsePageParameters(context, argumentCount, arguments, exception, pageWidthInPixels, pageHeightInPixels))
747 return JSValueMakeUndefined(context);
749 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
750 return JSValueMakeNumber(context, controller->numberOfPages(pageWidthInPixels, pageHeightInPixels));
753 static JSValueRef pagePropertyCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
755 char* propertyName = 0;
757 if (!parsePagePropertyParameters(context, argumentCount, arguments, exception, propertyName, pageNumber))
758 return JSValueMakeUndefined(context);
760 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
761 JSValueRef value = JSValueMakeString(context, controller->pageProperty(propertyName, pageNumber).get());
763 delete[] propertyName;
767 static JSValueRef isPageBoxVisibleCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
770 if (!parsePageNumber(context, argumentCount, arguments, exception, pageNumber))
771 return JSValueMakeUndefined(context);
773 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
774 return JSValueMakeBoolean(context, controller->isPageBoxVisible(pageNumber));
777 static JSValueRef pageSizeAndMarginsInPixelsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
780 int width = 0, height = 0;
781 int marginTop = 0, marginRight = 0, marginBottom = 0, marginLeft = 0;
782 if (!parsePageNumberSizeMarings(context, argumentCount, arguments, exception, pageNumber, width, height, marginTop, marginRight, marginBottom, marginLeft))
783 return JSValueMakeUndefined(context);
785 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
786 return JSValueMakeString(context, controller->pageSizeAndMarginsInPixels(pageNumber, width, height, marginTop, marginRight, marginBottom, marginLeft).get());
789 static JSValueRef queueBackNavigationCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
791 // Has mac & windows implementation
792 // May be able to be made platform independant by using shared WorkQueue
793 if (argumentCount < 1)
794 return JSValueMakeUndefined(context);
796 double howFarBackDouble = JSValueToNumber(context, arguments[0], exception);
799 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
800 controller->queueBackNavigation(static_cast<int>(howFarBackDouble));
802 return JSValueMakeUndefined(context);
805 static JSValueRef queueForwardNavigationCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
807 // Has mac & windows implementation
808 // May be able to be made platform independant by using shared WorkQueue
809 if (argumentCount < 1)
810 return JSValueMakeUndefined(context);
812 double howFarForwardDouble = JSValueToNumber(context, arguments[0], exception);
815 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
816 controller->queueForwardNavigation(static_cast<int>(howFarForwardDouble));
818 return JSValueMakeUndefined(context);
821 static JSValueRef queueLoadCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
823 // Has mac & windows implementation
824 // May be able to be made platform independant by using shared WorkQueue
825 if (argumentCount < 1)
826 return JSValueMakeUndefined(context);
828 JSRetainPtr<JSStringRef> url(Adopt, JSValueToStringCopy(context, arguments[0], exception));
831 JSRetainPtr<JSStringRef> target;
832 if (argumentCount >= 2) {
833 target.adopt(JSValueToStringCopy(context, arguments[1], exception));
836 target.adopt(JSStringCreateWithUTF8CString(""));
838 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
839 controller->queueLoad(url.get(), target.get());
841 return JSValueMakeUndefined(context);
844 static JSValueRef queueLoadHTMLStringCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
846 // Has Mac & Windows implementation
847 if (argumentCount < 1)
848 return JSValueMakeUndefined(context);
850 JSRetainPtr<JSStringRef> content(Adopt, JSValueToStringCopy(context, arguments[0], exception));
853 JSRetainPtr<JSStringRef> baseURL;
854 if (argumentCount >= 2) {
855 baseURL.adopt(JSValueToStringCopy(context, arguments[1], exception));
858 baseURL.adopt(JSStringCreateWithUTF8CString(""));
860 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
862 if (argumentCount >= 3) {
863 JSRetainPtr<JSStringRef> unreachableURL;
864 unreachableURL.adopt(JSValueToStringCopy(context, arguments[2], exception));
866 controller->queueLoadAlternateHTMLString(content.get(), baseURL.get(), unreachableURL.get());
867 return JSValueMakeUndefined(context);
870 controller->queueLoadHTMLString(content.get(), baseURL.get());
871 return JSValueMakeUndefined(context);
874 static JSValueRef queueReloadCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
876 // Has mac & windows implementation
877 // May be able to be made platform independant by using shared WorkQueue
879 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
880 controller->queueReload();
882 return JSValueMakeUndefined(context);
885 static JSValueRef queueLoadingScriptCallback(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
889 if (argumentCount < 1)
890 return JSValueMakeUndefined(context);
892 JSRetainPtr<JSStringRef> script(Adopt, JSValueToStringCopy(context, arguments[0], exception));
895 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
896 controller->queueLoadingScript(script.get());
898 return JSValueMakeUndefined(context);
901 static JSValueRef queueNonLoadingScriptCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
903 // Has mac & windows implementation
904 // May be able to be made platform independant by using shared WorkQueue
905 if (argumentCount < 1)
906 return JSValueMakeUndefined(context);
908 JSRetainPtr<JSStringRef> script(Adopt, JSValueToStringCopy(context, arguments[0], exception));
911 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
912 controller->queueNonLoadingScript(script.get());
914 return JSValueMakeUndefined(context);
917 static JSValueRef setAcceptsEditingCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
919 // Has mac & windows implementation
920 if (argumentCount < 1)
921 return JSValueMakeUndefined(context);
923 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
924 controller->setAcceptsEditing(JSValueToBoolean(context, arguments[0]));
926 return JSValueMakeUndefined(context);
929 static JSValueRef setAlwaysAcceptCookiesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
931 // Has mac & windows implementation
932 if (argumentCount < 1)
933 return JSValueMakeUndefined(context);
935 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
936 controller->setAlwaysAcceptCookies(JSValueToBoolean(context, arguments[0]));
938 return JSValueMakeUndefined(context);
941 static JSValueRef setAppCacheMaximumSizeCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
943 // Has mac implementation
944 if (argumentCount < 1)
945 return JSValueMakeUndefined(context);
947 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
949 double size = JSValueToNumber(context, arguments[0], NULL);
951 controller->setAppCacheMaximumSize(static_cast<unsigned long long>(size));
953 return JSValueMakeUndefined(context);
956 static JSValueRef setApplicationCacheOriginQuotaCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
958 // Has mac implementation
959 if (argumentCount < 1)
960 return JSValueMakeUndefined(context);
962 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
964 double size = JSValueToNumber(context, arguments[0], NULL);
966 controller->setApplicationCacheOriginQuota(static_cast<unsigned long long>(size));
968 return JSValueMakeUndefined(context);
971 static JSValueRef setAuthenticationPasswordCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
973 // Has mac & windows implementation
974 if (argumentCount < 1)
975 return JSValueMakeUndefined(context);
977 JSRetainPtr<JSStringRef> password(Adopt, JSValueToStringCopy(context, arguments[0], exception));
980 size_t maxLength = JSStringGetMaximumUTF8CStringSize(password.get());
981 char* passwordBuffer = new char[maxLength + 1];
982 JSStringGetUTF8CString(password.get(), passwordBuffer, maxLength + 1);
984 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
985 controller->setAuthenticationPassword(passwordBuffer);
986 delete[] passwordBuffer;
988 return JSValueMakeUndefined(context);
991 static JSValueRef setAuthenticationUsernameCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
993 // Has mac & windows implementation
994 if (argumentCount < 1)
995 return JSValueMakeUndefined(context);
997 JSRetainPtr<JSStringRef> username(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1000 size_t maxLength = JSStringGetMaximumUTF8CStringSize(username.get());
1001 char* usernameBuffer = new char[maxLength + 1];
1002 JSStringGetUTF8CString(username.get(), usernameBuffer, maxLength + 1);
1004 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1005 controller->setAuthenticationUsername(usernameBuffer);
1006 delete[] usernameBuffer;
1008 return JSValueMakeUndefined(context);
1011 static JSValueRef setAuthorAndUserStylesEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1013 // Has mac & windows implementation
1014 if (argumentCount < 1)
1015 return JSValueMakeUndefined(context);
1017 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1018 controller->setAuthorAndUserStylesEnabled(JSValueToBoolean(context, arguments[0]));
1020 return JSValueMakeUndefined(context);
1023 static JSValueRef setCacheModelCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1025 // Has Mac implementation.
1026 if (argumentCount < 1)
1027 return JSValueMakeUndefined(context);
1029 int cacheModel = JSValueToNumber(context, arguments[0], exception);
1030 ASSERT(!*exception);
1032 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1033 controller->setCacheModel(cacheModel);
1035 return JSValueMakeUndefined(context);
1038 static JSValueRef setCustomPolicyDelegateCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1040 // Has mac implementation
1041 if (argumentCount < 1)
1042 return JSValueMakeUndefined(context);
1044 bool permissive = false;
1045 if (argumentCount >= 2)
1046 permissive = JSValueToBoolean(context, arguments[1]);
1048 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1049 controller->setCustomPolicyDelegate(JSValueToBoolean(context, arguments[0]), permissive);
1051 return JSValueMakeUndefined(context);
1054 static JSValueRef setDatabaseQuotaCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1056 // Has mac implementation
1057 if (argumentCount < 1)
1058 return JSValueMakeUndefined(context);
1060 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1062 double quota = JSValueToNumber(context, arguments[0], NULL);
1064 controller->setDatabaseQuota(static_cast<unsigned long long>(quota));
1066 return JSValueMakeUndefined(context);
1069 static JSValueRef setDeferMainResourceDataLoadCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1071 // Has Mac and Windows implementation
1072 if (argumentCount < 1)
1073 return JSValueMakeUndefined(context);
1075 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1076 controller->setDeferMainResourceDataLoad(JSValueToBoolean(context, arguments[0]));
1078 return JSValueMakeUndefined(context);
1081 static JSValueRef setDomainRelaxationForbiddenForURLSchemeCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1083 // Has Mac and Windows implementation
1084 if (argumentCount < 2)
1085 return JSValueMakeUndefined(context);
1087 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1089 bool forbidden = JSValueToBoolean(context, arguments[0]);
1090 JSRetainPtr<JSStringRef> scheme(Adopt, JSValueToStringCopy(context, arguments[1], 0));
1091 controller->setDomainRelaxationForbiddenForURLScheme(forbidden, scheme.get());
1093 return JSValueMakeUndefined(context);
1096 static JSValueRef setMockDeviceOrientationCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1098 if (argumentCount < 6)
1099 return JSValueMakeUndefined(context);
1101 bool canProvideAlpha = JSValueToBoolean(context, arguments[0]);
1102 double alpha = JSValueToNumber(context, arguments[1], exception);
1103 ASSERT(!*exception);
1104 bool canProvideBeta = JSValueToBoolean(context, arguments[2]);
1105 double beta = JSValueToNumber(context, arguments[3], exception);
1106 ASSERT(!*exception);
1107 bool canProvideGamma = JSValueToBoolean(context, arguments[4]);
1108 double gamma = JSValueToNumber(context, arguments[5], exception);
1109 ASSERT(!*exception);
1111 LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1112 controller->setMockDeviceOrientation(canProvideAlpha, alpha, canProvideBeta, beta, canProvideGamma, gamma);
1114 return JSValueMakeUndefined(context);
1117 static JSValueRef setMockGeolocationPositionCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1119 if (argumentCount < 3)
1120 return JSValueMakeUndefined(context);
1122 LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1123 controller->setMockGeolocationPosition(JSValueToNumber(context, arguments[0], NULL), // latitude
1124 JSValueToNumber(context, arguments[1], NULL), // longitude
1125 JSValueToNumber(context, arguments[2], NULL)); // accuracy
1127 return JSValueMakeUndefined(context);
1130 static JSValueRef setMockGeolocationErrorCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1132 if (argumentCount < 2)
1133 return JSValueMakeUndefined(context);
1135 int code = JSValueToNumber(context, arguments[0], NULL);
1136 JSRetainPtr<JSStringRef> message(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1137 ASSERT(!*exception);
1139 LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1140 controller->setMockGeolocationError(code, message.get());
1142 return JSValueMakeUndefined(context);
1145 static JSValueRef addMockSpeechInputResultCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1147 if (argumentCount < 3)
1148 return JSValueMakeUndefined(context);
1150 JSRetainPtr<JSStringRef> result(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1151 ASSERT(!*exception);
1153 double confidence = JSValueToNumber(context, arguments[1], exception);
1155 JSRetainPtr<JSStringRef> language(Adopt, JSValueToStringCopy(context, arguments[2], exception));
1156 ASSERT(!*exception);
1158 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1159 controller->addMockSpeechInputResult(result.get(), confidence, language.get());
1161 return JSValueMakeUndefined(context);
1164 static JSValueRef setNewWindowsCopyBackForwardListCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1166 // Has mac implementation
1167 if (argumentCount < 1)
1168 return JSValueMakeUndefined(context);
1170 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1171 controller->setNewWindowsCopyBackForwardList(JSValueToBoolean(context, arguments[0]));
1173 return JSValueMakeUndefined(context);
1176 static JSValueRef setGeolocationPermissionCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1178 // Has mac implementation
1179 if (argumentCount < 1)
1180 return JSValueMakeUndefined(context);
1182 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1183 controller->setGeolocationPermission(JSValueToBoolean(context, arguments[0]));
1185 return JSValueMakeUndefined(context);
1188 static JSValueRef setHandlesAuthenticationChallengesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1190 // Has mac & windows implementation
1191 if (argumentCount < 1)
1192 return JSValueMakeUndefined(context);
1194 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1195 controller->setHandlesAuthenticationChallenges(JSValueToBoolean(context, arguments[0]));
1197 return JSValueMakeUndefined(context);
1200 static JSValueRef setPOSIXLocaleCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1202 if (argumentCount < 1)
1203 return JSValueMakeUndefined(context);
1205 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1206 JSRetainPtr<JSStringRef> locale(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1207 ASSERT(!*exception);
1208 controller->setPOSIXLocale(locale.get());
1210 return JSValueMakeUndefined(context);
1213 static JSValueRef setIconDatabaseEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1215 // Has mac & windows implementation
1216 if (argumentCount < 1)
1217 return JSValueMakeUndefined(context);
1219 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1220 controller->setIconDatabaseEnabled(JSValueToBoolean(context, arguments[0]));
1222 return JSValueMakeUndefined(context);
1225 static JSValueRef setJavaScriptProfilingEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1227 if (argumentCount < 1)
1228 return JSValueMakeUndefined(context);
1230 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1231 controller->setJavaScriptProfilingEnabled(JSValueToBoolean(context, arguments[0]));
1233 return JSValueMakeUndefined(context);
1236 static JSValueRef setMainFrameIsFirstResponderCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1238 // Has mac implementation
1239 if (argumentCount < 1)
1240 return JSValueMakeUndefined(context);
1242 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1243 controller->setMainFrameIsFirstResponder(JSValueToBoolean(context, arguments[0]));
1245 return JSValueMakeUndefined(context);
1248 static JSValueRef setPersistentUserStyleSheetLocationCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1250 // Has mac implementation
1251 if (argumentCount < 1)
1252 return JSValueMakeUndefined(context);
1254 JSRetainPtr<JSStringRef> path(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1255 ASSERT(!*exception);
1257 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1258 controller->setPersistentUserStyleSheetLocation(path.get());
1260 return JSValueMakeUndefined(context);
1263 static JSValueRef setPrivateBrowsingEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1265 // Has mac & windows implementation
1266 if (argumentCount < 1)
1267 return JSValueMakeUndefined(context);
1269 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1270 controller->setPrivateBrowsingEnabled(JSValueToBoolean(context, arguments[0]));
1272 return JSValueMakeUndefined(context);
1275 static JSValueRef setJavaScriptCanAccessClipboardCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1277 // Has mac & windows implementation
1278 if (argumentCount < 1)
1279 return JSValueMakeUndefined(context);
1281 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1282 controller->setJavaScriptCanAccessClipboard(JSValueToBoolean(context, arguments[0]));
1284 return JSValueMakeUndefined(context);
1287 static JSValueRef setXSSAuditorEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1289 // Has mac & windows implementation
1290 if (argumentCount < 1)
1291 return JSValueMakeUndefined(context);
1293 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1294 controller->setXSSAuditorEnabled(JSValueToBoolean(context, arguments[0]));
1296 return JSValueMakeUndefined(context);
1299 static JSValueRef setSpatialNavigationEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1301 // Has mac implementation.
1302 if (argumentCount < 1)
1303 return JSValueMakeUndefined(context);
1305 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1306 controller->setSpatialNavigationEnabled(JSValueToBoolean(context, arguments[0]));
1308 return JSValueMakeUndefined(context);
1311 static JSValueRef setPrintingCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1313 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1314 controller->setIsPrinting(true);
1315 return JSValueMakeUndefined(context);
1319 static JSValueRef setFrameFlatteningEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1321 // Has mac & windows implementation
1322 if (argumentCount < 1)
1323 return JSValueMakeUndefined(context);
1325 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1326 controller->setFrameFlatteningEnabled(JSValueToBoolean(context, arguments[0]));
1328 return JSValueMakeUndefined(context);
1331 static JSValueRef setAllowUniversalAccessFromFileURLsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1333 // Has mac & windows implementation
1334 if (argumentCount < 1)
1335 return JSValueMakeUndefined(context);
1337 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1338 controller->setAllowUniversalAccessFromFileURLs(JSValueToBoolean(context, arguments[0]));
1340 return JSValueMakeUndefined(context);
1343 static JSValueRef setAllowFileAccessFromFileURLsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1345 // Has mac & windows implementation
1346 if (argumentCount < 1)
1347 return JSValueMakeUndefined(context);
1349 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1350 controller->setAllowFileAccessFromFileURLs(JSValueToBoolean(context, arguments[0]));
1352 return JSValueMakeUndefined(context);
1355 static JSValueRef setTabKeyCyclesThroughElementsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1357 // Has mac & windows implementation
1358 if (argumentCount < 1)
1359 return JSValueMakeUndefined(context);
1361 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1362 controller->setTabKeyCyclesThroughElements(JSValueToBoolean(context, arguments[0]));
1364 return JSValueMakeUndefined(context);
1367 static JSValueRef setTimelineProfilingEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1369 if (argumentCount < 1)
1370 return JSValueMakeUndefined(context);
1372 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1373 controller->setTimelineProfilingEnabled(JSValueToBoolean(context, arguments[0]));
1374 return JSValueMakeUndefined(context);
1377 static JSValueRef setUseDashboardCompatibilityModeCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1379 // Has mac implementation
1380 if (argumentCount < 1)
1381 return JSValueMakeUndefined(context);
1383 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1384 controller->setUseDashboardCompatibilityMode(JSValueToBoolean(context, arguments[0]));
1386 return JSValueMakeUndefined(context);
1389 static JSValueRef setUserStyleSheetEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1391 // Has mac implementation
1392 if (argumentCount < 1)
1393 return JSValueMakeUndefined(context);
1395 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1396 controller->setUserStyleSheetEnabled(JSValueToBoolean(context, arguments[0]));
1398 return JSValueMakeUndefined(context);
1401 static JSValueRef setUserStyleSheetLocationCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1403 // Has mac implementation
1404 if (argumentCount < 1)
1405 return JSValueMakeUndefined(context);
1407 JSRetainPtr<JSStringRef> path(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1408 ASSERT(!*exception);
1410 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1411 controller->setUserStyleSheetLocation(path.get());
1413 return JSValueMakeUndefined(context);
1416 static JSValueRef setViewModeMediaFeatureCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1418 // Has mac implementation
1419 if (argumentCount < 1)
1420 return JSValueMakeUndefined(context);
1422 JSRetainPtr<JSStringRef> mode(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1423 ASSERT(!*exception);
1425 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1426 controller->setViewModeMediaFeature(mode.get());
1428 return JSValueMakeUndefined(context);
1431 static JSValueRef setWillSendRequestClearHeaderCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1433 // Has mac & windows implementation
1434 if (argumentCount < 1)
1435 return JSValueMakeUndefined(context);
1437 JSRetainPtr<JSStringRef> header(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1438 ASSERT(!*exception);
1440 size_t maxLength = JSStringGetMaximumUTF8CStringSize(header.get());
1441 char* headerBuffer = new char[maxLength + 1];
1442 JSStringGetUTF8CString(header.get(), headerBuffer, maxLength + 1);
1444 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1445 controller->setWillSendRequestClearHeader(headerBuffer);
1447 return JSValueMakeUndefined(context);
1450 static JSValueRef setWillSendRequestReturnsNullCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1452 // Has cross-platform implementation
1453 if (argumentCount < 1)
1454 return JSValueMakeUndefined(context);
1456 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1457 controller->setWillSendRequestReturnsNull(JSValueToBoolean(context, arguments[0]));
1459 return JSValueMakeUndefined(context);
1462 static JSValueRef setWillSendRequestReturnsNullOnRedirectCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1464 // Has cross-platform implementation
1465 if (argumentCount < 1)
1466 return JSValueMakeUndefined(context);
1468 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1469 controller->setWillSendRequestReturnsNullOnRedirect(JSValueToBoolean(context, arguments[0]));
1471 return JSValueMakeUndefined(context);
1474 static JSValueRef setWindowIsKeyCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1476 // Has mac implementation
1477 if (argumentCount < 1)
1478 return JSValueMakeUndefined(context);
1480 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1481 controller->setWindowIsKey(JSValueToBoolean(context, arguments[0]));
1483 return JSValueMakeUndefined(context);
1486 static JSValueRef waitUntilDoneCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1488 // Has mac & windows implementation
1489 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1490 controller->setWaitToDump(true);
1492 return JSValueMakeUndefined(context);
1495 static JSValueRef windowCountCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1497 // Has mac implementation
1498 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1499 int windows = controller->windowCount();
1500 return JSValueMakeNumber(context, windows);
1503 static JSValueRef setPopupBlockingEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1505 // Has mac & windows implementation
1506 if (argumentCount < 1)
1507 return JSValueMakeUndefined(context);
1509 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1510 controller->setPopupBlockingEnabled(JSValueToBoolean(context, arguments[0]));
1512 return JSValueMakeUndefined(context);
1515 static JSValueRef setPluginsEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1517 // Has mac & windows implementation
1518 if (argumentCount < 1)
1519 return JSValueMakeUndefined(context);
1521 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1522 controller->setPluginsEnabled(JSValueToBoolean(context, arguments[0]));
1524 return JSValueMakeUndefined(context);
1527 static JSValueRef setSmartInsertDeleteEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1529 if (argumentCount < 1)
1530 return JSValueMakeUndefined(context);
1532 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1533 controller->setSmartInsertDeleteEnabled(JSValueToBoolean(context, arguments[0]));
1534 return JSValueMakeUndefined(context);
1537 static JSValueRef setSelectTrailingWhitespaceEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1539 if (argumentCount < 1)
1540 return JSValueMakeUndefined(context);
1542 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1543 controller->setSelectTrailingWhitespaceEnabled(JSValueToBoolean(context, arguments[0]));
1544 return JSValueMakeUndefined(context);
1547 static JSValueRef setStopProvisionalFrameLoadsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1549 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1550 controller->setStopProvisionalFrameLoads(true);
1551 return JSValueMakeUndefined(context);
1554 static JSValueRef setAsynchronousSpellCheckingEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1556 if (argumentCount < 1)
1557 return JSValueMakeUndefined(context);
1559 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1560 controller->setAsynchronousSpellCheckingEnabled(JSValueToBoolean(context, arguments[0]));
1561 return JSValueMakeUndefined(context);
1564 static JSValueRef showWebInspectorCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1566 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1567 controller->showWebInspector();
1568 return JSValueMakeUndefined(context);
1571 static JSValueRef closeWebInspectorCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1573 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1574 controller->setTimelineProfilingEnabled(false);
1575 controller->closeWebInspector();
1576 return JSValueMakeUndefined(context);
1579 static JSValueRef evaluateInWebInspectorCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1581 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1582 double callId = JSValueToNumber(context, arguments[0], exception);
1583 ASSERT(!*exception);
1584 JSRetainPtr<JSStringRef> script(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1585 ASSERT(!*exception);
1587 controller->evaluateInWebInspector(static_cast<long>(callId), script.get());
1588 return JSValueMakeUndefined(context);
1591 static JSValueRef evaluateScriptInIsolatedWorldCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1593 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1594 double worldID = JSValueToNumber(context, arguments[0], exception);
1595 ASSERT(!*exception);
1596 JSRetainPtr<JSStringRef> script(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1597 ASSERT(!*exception);
1599 controller->evaluateScriptInIsolatedWorld(static_cast<unsigned>(worldID), JSContextGetGlobalObject(context), script.get());
1600 return JSValueMakeUndefined(context);
1603 static JSValueRef elementDoesAutoCompleteForElementWithIdCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1605 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1606 JSRetainPtr<JSStringRef> elementId(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1607 ASSERT(!*exception);
1609 bool autoCompletes = controller->elementDoesAutoCompleteForElementWithId(elementId.get());
1611 return JSValueMakeBoolean(context, autoCompletes);
1614 static JSValueRef pauseAnimationAtTimeOnElementWithIdCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1616 if (argumentCount != 3)
1617 return JSValueMakeUndefined(context);
1619 JSRetainPtr<JSStringRef> animationName(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1620 ASSERT(!*exception);
1621 double time = JSValueToNumber(context, arguments[1], exception);
1622 ASSERT(!*exception);
1623 JSRetainPtr<JSStringRef> elementId(Adopt, JSValueToStringCopy(context, arguments[2], exception));
1624 ASSERT(!*exception);
1626 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1627 return JSValueMakeBoolean(context, controller->pauseAnimationAtTimeOnElementWithId(animationName.get(), time, elementId.get()));
1630 static JSValueRef pauseTransitionAtTimeOnElementWithIdCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1632 if (argumentCount != 3)
1633 return JSValueMakeUndefined(context);
1635 JSRetainPtr<JSStringRef> propertyName(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1636 ASSERT(!*exception);
1637 double time = JSValueToNumber(context, arguments[1], exception);
1638 ASSERT(!*exception);
1639 JSRetainPtr<JSStringRef> elementId(Adopt, JSValueToStringCopy(context, arguments[2], exception));
1640 ASSERT(!*exception);
1642 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1643 return JSValueMakeBoolean(context, controller->pauseTransitionAtTimeOnElementWithId(propertyName.get(), time, elementId.get()));
1646 static JSValueRef sampleSVGAnimationForElementAtTimeCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1648 if (argumentCount != 3)
1649 return JSValueMakeUndefined(context);
1651 JSRetainPtr<JSStringRef> animationId(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1652 ASSERT(!*exception);
1653 double time = JSValueToNumber(context, arguments[1], exception);
1654 ASSERT(!*exception);
1655 JSRetainPtr<JSStringRef> elementId(Adopt, JSValueToStringCopy(context, arguments[2], exception));
1656 ASSERT(!*exception);
1658 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1659 return JSValueMakeBoolean(context, controller->sampleSVGAnimationForElementAtTime(animationId.get(), time, elementId.get()));
1662 static JSValueRef numberOfActiveAnimationsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1664 if (argumentCount != 0)
1665 return JSValueMakeUndefined(context);
1667 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1668 return JSValueMakeNumber(context, controller->numberOfActiveAnimations());
1671 static JSValueRef suspendAnimationsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1673 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1674 controller->suspendAnimations();
1675 return JSValueMakeUndefined(context);
1678 static JSValueRef resumeAnimationsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1680 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1681 controller->resumeAnimations();
1682 return JSValueMakeUndefined(context);
1685 static JSValueRef waitForPolicyDelegateCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t, const JSValueRef[], JSValueRef*)
1687 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1688 controller->waitForPolicyDelegate();
1689 return JSValueMakeUndefined(context);
1692 static JSValueRef addOriginAccessWhitelistEntryCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1694 if (argumentCount != 4)
1695 return JSValueMakeUndefined(context);
1697 JSRetainPtr<JSStringRef> sourceOrigin(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1698 ASSERT(!*exception);
1699 JSRetainPtr<JSStringRef> destinationProtocol(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1700 ASSERT(!*exception);
1701 JSRetainPtr<JSStringRef> destinationHost(Adopt, JSValueToStringCopy(context, arguments[2], exception));
1702 ASSERT(!*exception);
1703 bool allowDestinationSubdomains = JSValueToBoolean(context, arguments[3]);
1705 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1706 controller->addOriginAccessWhitelistEntry(sourceOrigin.get(), destinationProtocol.get(), destinationHost.get(), allowDestinationSubdomains);
1707 return JSValueMakeUndefined(context);
1710 static JSValueRef removeOriginAccessWhitelistEntryCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1712 if (argumentCount != 4)
1713 return JSValueMakeUndefined(context);
1715 JSRetainPtr<JSStringRef> sourceOrigin(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1716 ASSERT(!*exception);
1717 JSRetainPtr<JSStringRef> destinationProtocol(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1718 ASSERT(!*exception);
1719 JSRetainPtr<JSStringRef> destinationHost(Adopt, JSValueToStringCopy(context, arguments[2], exception));
1720 ASSERT(!*exception);
1721 bool allowDestinationSubdomains = JSValueToBoolean(context, arguments[3]);
1723 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1724 controller->removeOriginAccessWhitelistEntry(sourceOrigin.get(), destinationProtocol.get(), destinationHost.get(), allowDestinationSubdomains);
1725 return JSValueMakeUndefined(context);
1728 static JSValueRef setScrollbarPolicyCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1730 if (argumentCount != 2)
1731 return JSValueMakeUndefined(context);
1733 JSRetainPtr<JSStringRef> orientation(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1734 ASSERT(!*exception);
1735 JSRetainPtr<JSStringRef> policy(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1736 ASSERT(!*exception);
1738 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1739 controller->setScrollbarPolicy(orientation.get(), policy.get());
1740 return JSValueMakeUndefined(context);
1743 static JSValueRef addUserScriptCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1745 if (argumentCount != 3)
1746 return JSValueMakeUndefined(context);
1748 JSRetainPtr<JSStringRef> source(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1749 ASSERT(!*exception);
1750 bool runAtStart = JSValueToBoolean(context, arguments[1]);
1751 bool allFrames = JSValueToBoolean(context, arguments[2]);
1753 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1754 controller->addUserScript(source.get(), runAtStart, allFrames);
1755 return JSValueMakeUndefined(context);
1758 static JSValueRef addUserStyleSheetCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1760 if (argumentCount != 2)
1761 return JSValueMakeUndefined(context);
1763 JSRetainPtr<JSStringRef> source(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1764 ASSERT(!*exception);
1765 bool allFrames = JSValueToBoolean(context, arguments[1]);
1767 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1768 controller->addUserStyleSheet(source.get(), allFrames);
1769 return JSValueMakeUndefined(context);
1772 static JSValueRef apiTestNewWindowDataLoadBaseURLCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1774 if (argumentCount != 2)
1775 return JSValueMakeUndefined(context);
1777 JSRetainPtr<JSStringRef> utf8Data(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1778 ASSERT(!*exception);
1780 JSRetainPtr<JSStringRef> baseURL(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1781 ASSERT(!*exception);
1783 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1784 controller->apiTestNewWindowDataLoadBaseURL(utf8Data.get(), baseURL.get());
1785 return JSValueMakeUndefined(context);
1788 static JSValueRef apiTestGoToCurrentBackForwardItemCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1790 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1791 controller->apiTestGoToCurrentBackForwardItem();
1792 return JSValueMakeUndefined(context);
1795 static JSValueRef setWebViewEditableCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1797 // Has Mac implementation
1798 if (argumentCount < 1)
1799 return JSValueMakeUndefined(context);
1801 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1802 controller->setWebViewEditable(JSValueToBoolean(context, arguments[0]));
1804 return JSValueMakeUndefined(context);
1808 static JSValueRef abortModalCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1810 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1811 controller->abortModal();
1812 return JSValueMakeUndefined(context);
1815 static JSValueRef hasSpellingMarkerCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1817 if (argumentCount != 2)
1818 return JSValueMakeUndefined(context);
1820 int from = JSValueToNumber(context, arguments[0], 0);
1821 int length = JSValueToNumber(context, arguments[1], 0);
1822 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1823 bool ok = controller->hasSpellingMarker(from, length);
1825 return JSValueMakeBoolean(context, ok);
1828 static JSValueRef markerTextForListItemCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1830 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1831 if (argumentCount < 1)
1832 return JSValueMakeUndefined(context);
1833 return JSValueMakeString(context, controller->markerTextForListItem(context, arguments[0]).get());
1836 static JSValueRef authenticateSessionCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1838 // authenticateSession(url, username, password)
1839 if (argumentCount != 3)
1840 return JSValueMakeUndefined(context);
1842 JSRetainPtr<JSStringRef> url(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1843 ASSERT(!*exception);
1844 JSRetainPtr<JSStringRef> username(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1845 ASSERT(!*exception);
1846 JSRetainPtr<JSStringRef> password(Adopt, JSValueToStringCopy(context, arguments[2], exception));
1847 ASSERT(!*exception);
1849 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1850 controller->authenticateSession(url.get(), username.get(), password.get());
1851 return JSValueMakeUndefined(context);
1854 static JSValueRef setEditingBehaviorCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1856 // The editing behavior string.
1857 if (argumentCount < 1)
1858 return JSValueMakeUndefined(context);
1860 JSRetainPtr<JSStringRef> editingBehavior(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1861 ASSERT(!*exception);
1863 size_t maxLength = JSStringGetMaximumUTF8CStringSize(editingBehavior.get());
1864 char* behaviorBuffer = new char[maxLength + 1];
1865 JSStringGetUTF8CString(editingBehavior.get(), behaviorBuffer, maxLength);
1867 if (strcmp(behaviorBuffer, "mac") && strcmp(behaviorBuffer, "win") && strcmp(behaviorBuffer, "unix")) {
1868 JSRetainPtr<JSStringRef> invalidArgument(JSStringCreateWithUTF8CString("Passed invalid editing behavior. Must be 'mac', 'win', or 'unix'."));
1869 *exception = JSValueMakeString(context, invalidArgument.get());
1870 return JSValueMakeUndefined(context);
1873 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1874 controller->setEditingBehavior(behaviorBuffer);
1876 delete [] behaviorBuffer;
1878 return JSValueMakeUndefined(context);
1881 static JSValueRef setSerializeHTTPLoadsCallback(JSContextRef context, JSObjectRef, JSObjectRef, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1883 bool serialize = true;
1884 if (argumentCount == 1)
1885 serialize = JSValueToBoolean(context, arguments[0]);
1887 LayoutTestController::setSerializeHTTPLoads(serialize);
1888 return JSValueMakeUndefined(context);
1893 static JSValueRef getGlobalFlagCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
1895 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1896 return JSValueMakeBoolean(context, controller->globalFlag());
1899 static JSValueRef getWebHistoryItemCountCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
1901 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1902 return JSValueMakeNumber(context, controller->webHistoryItemCount());
1905 static JSValueRef getWorkerThreadCountCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
1907 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1908 return JSValueMakeNumber(context, controller->workerThreadCount());
1911 static bool setGlobalFlagCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef value, JSValueRef* exception)
1913 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1914 controller->setGlobalFlag(JSValueToBoolean(context, value));
1918 static void layoutTestControllerObjectFinalize(JSObjectRef object)
1920 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(object));
1921 controller->deref();
1926 void LayoutTestController::makeWindowObject(JSContextRef context, JSObjectRef windowObject, JSValueRef* exception)
1928 JSRetainPtr<JSStringRef> layoutTestContollerStr(Adopt, JSStringCreateWithUTF8CString("layoutTestController"));
1931 JSClassRef classRef = getJSClass();
1932 JSValueRef layoutTestContollerObject = JSObjectMake(context, classRef, this);
1933 JSClassRelease(classRef);
1935 JSObjectSetProperty(context, windowObject, layoutTestContollerStr.get(), layoutTestContollerObject, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete, exception);
1938 JSClassRef LayoutTestController::getJSClass()
1940 static JSStaticValue* staticValues = LayoutTestController::staticValues();
1941 static JSStaticFunction* staticFunctions = LayoutTestController::staticFunctions();
1942 static JSClassDefinition classDefinition = {
1943 0, kJSClassAttributeNone, "LayoutTestController", 0, staticValues, staticFunctions,
1944 0, layoutTestControllerObjectFinalize, 0, 0, 0, 0, 0, 0, 0, 0, 0
1947 return JSClassCreate(&classDefinition);
1950 JSStaticValue* LayoutTestController::staticValues()
1952 static JSStaticValue staticValues[] = {
1953 { "globalFlag", getGlobalFlagCallback, setGlobalFlagCallback, kJSPropertyAttributeNone },
1954 { "webHistoryItemCount", getWebHistoryItemCountCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1955 { "workerThreadCount", getWorkerThreadCountCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1958 return staticValues;
1961 JSStaticFunction* LayoutTestController::staticFunctions()
1963 static JSStaticFunction staticFunctions[] = {
1964 { "abortModal", abortModalCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1965 { "addDisallowedURL", addDisallowedURLCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1966 { "addURLToRedirect", addURLToRedirectCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1967 { "addUserScript", addUserScriptCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1968 { "addUserStyleSheet", addUserStyleSheetCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1969 { "apiTestNewWindowDataLoadBaseURL", apiTestNewWindowDataLoadBaseURLCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1970 { "apiTestGoToCurrentBackForwardItem", apiTestGoToCurrentBackForwardItemCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1971 { "callShouldCloseOnWebView", callShouldCloseOnWebViewCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1972 { "clearAllApplicationCaches", clearAllApplicationCachesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1973 { "clearAllDatabases", clearAllDatabasesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1974 { "clearBackForwardList", clearBackForwardListCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1975 { "clearPersistentUserStyleSheet", clearPersistentUserStyleSheetCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1976 { "closeWebInspector", closeWebInspectorCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1977 { "computedStyleIncludingVisitedInfo", computedStyleIncludingVisitedInfoCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1978 { "nodesFromRect", nodesFromRectCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1979 { "decodeHostName", decodeHostNameCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1980 { "disableImageLoading", disableImageLoadingCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1981 { "dispatchPendingLoadRequests", dispatchPendingLoadRequestsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1982 { "display", displayCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1983 { "dumpApplicationCacheDelegateCallbacks", dumpApplicationCacheDelegateCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1984 { "dumpAsText", dumpAsTextCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1985 { "dumpBackForwardList", dumpBackForwardListCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1986 { "dumpChildFrameScrollPositions", dumpChildFrameScrollPositionsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1987 { "dumpChildFramesAsText", dumpChildFramesAsTextCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1988 { "dumpConfigurationForViewport", dumpConfigurationForViewportCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1989 { "dumpDOMAsWebArchive", dumpDOMAsWebArchiveCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1990 { "dumpDatabaseCallbacks", dumpDatabaseCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1991 { "dumpEditingCallbacks", dumpEditingCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1992 { "dumpFrameLoadCallbacks", dumpFrameLoadCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1993 { "dumpUserGestureInFrameLoadCallbacks", dumpUserGestureInFrameLoadCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1994 { "dumpResourceLoadCallbacks", dumpResourceLoadCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1995 { "dumpResourceResponseMIMETypes", dumpResourceResponseMIMETypesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1996 { "dumpSelectionRect", dumpSelectionRectCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1997 { "dumpSourceAsWebArchive", dumpSourceAsWebArchiveCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1998 { "dumpStatusCallbacks", dumpStatusCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1999 { "dumpTitleChanges", dumpTitleChangesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2000 { "dumpIconChanges", dumpIconChangesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2001 { "dumpWillCacheResponse", dumpWillCacheResponseCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2002 { "elementDoesAutoCompleteForElementWithId", elementDoesAutoCompleteForElementWithIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2003 { "encodeHostName", encodeHostNameCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2004 { "evaluateInWebInspector", evaluateInWebInspectorCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2005 { "evaluateScriptInIsolatedWorld", evaluateScriptInIsolatedWorldCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2006 { "execCommand", execCommandCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2007 { "findString", findStringCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2008 { "counterValueForElementById", counterValueForElementByIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2009 { "grantDesktopNotificationPermission", grantDesktopNotificationPermissionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2010 { "hasSpellingMarker", hasSpellingMarkerCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2011 { "isCommandEnabled", isCommandEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2012 { "isPageBoxVisible", isPageBoxVisibleCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2013 { "keepWebHistory", keepWebHistoryCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2014 { "layerTreeAsText", layerTreeAsTextCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2015 { "numberOfPages", numberOfPagesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2016 { "markerTextForListItem", markerTextForListItemCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2017 { "notifyDone", notifyDoneCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2018 { "numberOfActiveAnimations", numberOfActiveAnimationsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2019 { "suspendAnimations", suspendAnimationsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2020 { "resumeAnimations", resumeAnimationsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2021 { "overridePreference", overridePreferenceCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2022 { "pageNumberForElementById", pageNumberForElementByIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2023 { "pageSizeAndMarginsInPixels", pageSizeAndMarginsInPixelsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2024 { "pageProperty", pagePropertyCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2025 { "pathToLocalResource", pathToLocalResourceCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2026 { "pauseAnimationAtTimeOnElementWithId", pauseAnimationAtTimeOnElementWithIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2027 { "pauseTransitionAtTimeOnElementWithId", pauseTransitionAtTimeOnElementWithIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2028 { "sampleSVGAnimationForElementAtTime", sampleSVGAnimationForElementAtTimeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2029 { "printToPDF", dumpAsPDFCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2030 { "queueBackNavigation", queueBackNavigationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2031 { "queueForwardNavigation", queueForwardNavigationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2032 { "queueLoad", queueLoadCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2033 { "queueLoadHTMLString", queueLoadHTMLStringCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2034 { "queueLoadingScript", queueLoadingScriptCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2035 { "queueNonLoadingScript", queueNonLoadingScriptCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2036 { "queueReload", queueReloadCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2037 { "removeAllVisitedLinks", removeAllVisitedLinksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2038 { "removeOriginAccessWhitelistEntry", removeOriginAccessWhitelistEntryCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2039 { "repaintSweepHorizontally", repaintSweepHorizontallyCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2040 { "setAcceptsEditing", setAcceptsEditingCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2041 { "setAllowUniversalAccessFromFileURLs", setAllowUniversalAccessFromFileURLsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2042 { "setAllowFileAccessFromFileURLs", setAllowFileAccessFromFileURLsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2043 { "setAlwaysAcceptCookies", setAlwaysAcceptCookiesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2044 { "setAppCacheMaximumSize", setAppCacheMaximumSizeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2045 { "setApplicationCacheOriginQuota", setApplicationCacheOriginQuotaCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2046 { "setAuthenticationPassword", setAuthenticationPasswordCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2047 { "setAuthenticationUsername", setAuthenticationUsernameCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2048 { "setAuthorAndUserStylesEnabled", setAuthorAndUserStylesEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2049 { "setCacheModel", setCacheModelCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2050 { "setCallCloseOnWebViews", setCallCloseOnWebViewsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2051 { "setCanOpenWindows", setCanOpenWindowsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2052 { "setCloseRemainingWindowsWhenComplete", setCloseRemainingWindowsWhenCompleteCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2053 { "setCustomPolicyDelegate", setCustomPolicyDelegateCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2054 { "setDatabaseQuota", setDatabaseQuotaCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2055 { "setDeferMainResourceDataLoad", setDeferMainResourceDataLoadCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2056 { "setDomainRelaxationForbiddenForURLScheme", setDomainRelaxationForbiddenForURLSchemeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2057 { "setEditingBehavior", setEditingBehaviorCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2058 { "setFrameFlatteningEnabled", setFrameFlatteningEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2059 { "setGeolocationPermission", setGeolocationPermissionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2060 { "setHandlesAuthenticationChallenges", setHandlesAuthenticationChallengesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2061 { "setIconDatabaseEnabled", setIconDatabaseEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2062 { "setJavaScriptProfilingEnabled", setJavaScriptProfilingEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2063 { "setMainFrameIsFirstResponder", setMainFrameIsFirstResponderCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2064 { "setMockDeviceOrientation", setMockDeviceOrientationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2065 { "setMockGeolocationError", setMockGeolocationErrorCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2066 { "setMockGeolocationPosition", setMockGeolocationPositionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2067 { "addMockSpeechInputResult", addMockSpeechInputResultCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2068 { "setNewWindowsCopyBackForwardList", setNewWindowsCopyBackForwardListCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2069 { "setPOSIXLocale", setPOSIXLocaleCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2070 { "setPersistentUserStyleSheetLocation", setPersistentUserStyleSheetLocationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2071 { "setPopupBlockingEnabled", setPopupBlockingEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2072 { "setPluginsEnabled", setPluginsEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2073 { "setPrinting", setPrintingCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2074 { "setPrivateBrowsingEnabled", setPrivateBrowsingEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2075 { "setSelectTrailingWhitespaceEnabled", setSelectTrailingWhitespaceEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2076 { "setSerializeHTTPLoads", setSerializeHTTPLoadsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2077 { "setSmartInsertDeleteEnabled", setSmartInsertDeleteEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2078 { "setSpatialNavigationEnabled", setSpatialNavigationEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2079 { "setStopProvisionalFrameLoads", setStopProvisionalFrameLoadsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2080 { "setTabKeyCyclesThroughElements", setTabKeyCyclesThroughElementsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2081 { "setTimelineProfilingEnabled", setTimelineProfilingEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2082 { "setUseDashboardCompatibilityMode", setUseDashboardCompatibilityModeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2083 { "setUserStyleSheetEnabled", setUserStyleSheetEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2084 { "setUserStyleSheetLocation", setUserStyleSheetLocationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2085 { "setViewModeMediaFeature", setViewModeMediaFeatureCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2086 { "setWebViewEditable", setWebViewEditableCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2087 { "setWillSendRequestClearHeader", setWillSendRequestClearHeaderCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2088 { "setWillSendRequestReturnsNull", setWillSendRequestReturnsNullCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2089 { "setWillSendRequestReturnsNullOnRedirect", setWillSendRequestReturnsNullOnRedirectCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2090 { "setWindowIsKey", setWindowIsKeyCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2091 { "setJavaScriptCanAccessClipboard", setJavaScriptCanAccessClipboardCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2092 { "setXSSAuditorEnabled", setXSSAuditorEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2093 { "setAsynchronousSpellCheckingEnabled", setAsynchronousSpellCheckingEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2094 { "showWebInspector", showWebInspectorCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2095 { "testOnscreen", testOnscreenCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2096 { "testRepaint", testRepaintCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2097 { "waitForPolicyDelegate", waitForPolicyDelegateCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2098 { "waitUntilDone", waitUntilDoneCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2099 { "windowCount", windowCountCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2100 { "addOriginAccessWhitelistEntry", addOriginAccessWhitelistEntryCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2101 { "setScrollbarPolicy", setScrollbarPolicyCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2102 { "authenticateSession", authenticateSessionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2106 return staticFunctions;
2109 void LayoutTestController::queueLoadHTMLString(JSStringRef content, JSStringRef baseURL)
2111 WorkQueue::shared()->queue(new LoadHTMLStringItem(content, baseURL));
2114 void LayoutTestController::queueLoadAlternateHTMLString(JSStringRef content, JSStringRef baseURL, JSStringRef unreachableURL)
2116 WorkQueue::shared()->queue(new LoadHTMLStringItem(content, baseURL, unreachableURL));
2119 void LayoutTestController::queueBackNavigation(int howFarBack)
2121 WorkQueue::shared()->queue(new BackItem(howFarBack));
2124 void LayoutTestController::queueForwardNavigation(int howFarForward)
2126 WorkQueue::shared()->queue(new ForwardItem(howFarForward));
2129 void LayoutTestController::queueLoadingScript(JSStringRef script)
2131 WorkQueue::shared()->queue(new LoadingScriptItem(script));
2134 void LayoutTestController::queueNonLoadingScript(JSStringRef script)
2136 WorkQueue::shared()->queue(new NonLoadingScriptItem(script));
2139 void LayoutTestController::queueReload()
2141 WorkQueue::shared()->queue(new ReloadItem);
2144 void LayoutTestController::grantDesktopNotificationPermission(JSStringRef origin)
2146 m_desktopNotificationAllowedOrigins.push_back(JSStringRetain(origin));
2149 bool LayoutTestController::checkDesktopNotificationPermission(JSStringRef origin)
2151 std::vector<JSStringRef>::iterator i;
2152 for (i = m_desktopNotificationAllowedOrigins.begin();
2153 i != m_desktopNotificationAllowedOrigins.end();
2155 if (JSStringIsEqual(*i, origin))
2161 void LayoutTestController::waitToDumpWatchdogTimerFired()
2163 const char* message = "FAIL: Timed out waiting for notifyDone to be called\n";
2164 fprintf(stderr, "%s", message);
2165 fprintf(stdout, "%s", message);
2169 void LayoutTestController::setGeolocationPermissionCommon(bool allow)
2171 m_isGeolocationPermissionSet = true;
2172 m_geolocationPermission = allow;
2175 void LayoutTestController::setPOSIXLocale(JSStringRef locale)
2178 JSStringGetUTF8CString(locale, localeBuf, sizeof(localeBuf));
2179 setlocale(LC_ALL, localeBuf);
2182 void LayoutTestController::addURLToRedirect(std::string origin, std::string destination)
2184 m_URLsToRedirect[origin] = destination;
2187 const std::string& LayoutTestController::redirectionDestinationForURL(std::string origin)
2189 return m_URLsToRedirect[origin];
2192 const unsigned LayoutTestController::maxViewWidth = 800;
2193 const unsigned LayoutTestController::maxViewHeight = 600;