2 * Copyright (C) 2007, 2008, 2009 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 callShouldCloseOnWebViewCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
340 // Has mac & windows implementation
341 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
343 return JSValueMakeBoolean(context, controller->callShouldCloseOnWebView());
346 static JSValueRef clearAllApplicationCachesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
348 // Has mac implementation
349 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
350 controller->clearAllApplicationCaches();
352 return JSValueMakeUndefined(context);
355 static JSValueRef clearAllDatabasesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
357 // Has mac & windows implementation
358 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
359 controller->clearAllDatabases();
361 return JSValueMakeUndefined(context);
364 static JSValueRef clearBackForwardListCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
366 // Has mac & windows implementation
367 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
368 controller->clearBackForwardList();
370 return JSValueMakeUndefined(context);
373 static JSValueRef clearPersistentUserStyleSheetCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
375 // Has mac & windows implementation
376 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
377 controller->clearPersistentUserStyleSheet();
379 return JSValueMakeUndefined(context);
382 static JSValueRef decodeHostNameCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
384 // Has mac implementation
385 if (argumentCount < 1)
386 return JSValueMakeUndefined(context);
388 JSRetainPtr<JSStringRef> name(Adopt, JSValueToStringCopy(context, arguments[0], exception));
391 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
392 JSRetainPtr<JSStringRef> decodedHostName(Adopt, controller->copyDecodedHostName(name.get()));
393 return JSValueMakeString(context, decodedHostName.get());
396 static JSValueRef disableImageLoadingCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
398 // Has mac implementation, needs windows implementation
399 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
400 controller->disableImageLoading();
402 return JSValueMakeUndefined(context);
405 static JSValueRef dispatchPendingLoadRequestsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
407 // Has mac implementation, needs windows implementation
408 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
409 controller->dispatchPendingLoadRequests();
411 return JSValueMakeUndefined(context);
414 static JSValueRef displayCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
416 // Has mac & windows implementation
417 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
418 controller->display();
420 return JSValueMakeUndefined(context);
423 static JSValueRef encodeHostNameCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
425 // Has mac implementation
426 if (argumentCount < 1)
427 return JSValueMakeUndefined(context);
429 JSRetainPtr<JSStringRef> name(Adopt, JSValueToStringCopy(context, arguments[0], exception));
432 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
433 JSRetainPtr<JSStringRef> encodedHostName(Adopt, controller->copyEncodedHostName(name.get()));
434 return JSValueMakeString(context, encodedHostName.get());
437 static JSValueRef execCommandCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
439 // Has Mac & Windows implementations.
440 if (argumentCount < 1)
441 return JSValueMakeUndefined(context);
443 JSRetainPtr<JSStringRef> name(Adopt, JSValueToStringCopy(context, arguments[0], exception));
446 // Ignoring the second parameter (userInterface), as this command emulates a manual action.
448 JSRetainPtr<JSStringRef> value;
449 if (argumentCount >= 3) {
450 value.adopt(JSValueToStringCopy(context, arguments[2], exception));
453 value.adopt(JSStringCreateWithUTF8CString(""));
456 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
457 controller->execCommand(name.get(), value.get());
459 return JSValueMakeUndefined(context);
462 static JSValueRef findStringCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
464 // Has Mac implementation.
465 if (argumentCount < 2)
466 return JSValueMakeUndefined(context);
468 JSRetainPtr<JSStringRef> target(Adopt, JSValueToStringCopy(context, arguments[0], exception));
471 JSObjectRef options = JSValueToObject(context, arguments[1], exception);
474 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
475 return JSValueMakeBoolean(context, controller->findString(context, target.get(), options));
478 static JSValueRef counterValueForElementByIdCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
480 if (argumentCount < 1)
481 return JSValueMakeUndefined(context);
483 JSRetainPtr<JSStringRef> elementId(Adopt, JSValueToStringCopy(context, arguments[0], exception));
485 return JSValueMakeUndefined(context);
487 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
488 JSRetainPtr<JSStringRef> counterValue(controller->counterValueForElementById(elementId.get()));
489 if (!counterValue.get())
490 return JSValueMakeUndefined(context);
491 return JSValueMakeString(context, counterValue.get());
494 static JSValueRef grantDesktopNotificationPermissionCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
496 // Has Windows implementation
497 if (argumentCount < 1)
498 return JSValueMakeUndefined(context);
500 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
502 controller->grantDesktopNotificationPermission(JSValueToStringCopy(context, arguments[0], NULL));
504 return JSValueMakeUndefined(context);
507 static JSValueRef isCommandEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
509 // Has Mac implementation.
511 if (argumentCount < 1)
512 return JSValueMakeUndefined(context);
514 JSRetainPtr<JSStringRef> name(Adopt, JSValueToStringCopy(context, arguments[0], exception));
517 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
519 return JSValueMakeBoolean(context, controller->isCommandEnabled(name.get()));
522 static JSValueRef overridePreferenceCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
524 if (argumentCount < 2)
525 return JSValueMakeUndefined(context);
527 JSRetainPtr<JSStringRef> key(Adopt, JSValueToStringCopy(context, arguments[0], exception));
529 JSRetainPtr<JSStringRef> value(Adopt, JSValueToStringCopy(context, arguments[1], exception));
532 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
533 controller->overridePreference(key.get(), value.get());
535 return JSValueMakeUndefined(context);
538 static JSValueRef keepWebHistoryCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
540 // Has mac implementation
541 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
542 controller->keepWebHistory();
544 return JSValueMakeUndefined(context);
547 static JSValueRef computedStyleIncludingVisitedInfoCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
549 if (argumentCount != 1)
550 return JSValueMakeUndefined(context);
552 // Has mac implementation
553 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
554 return controller->computedStyleIncludingVisitedInfo(context, arguments[0]);
557 static JSValueRef nodesFromRectCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
559 if (argumentCount != 8)
560 return JSValueMakeUndefined(context);
562 int x = JSValueToNumber(context, arguments[1], NULL);
563 int y = JSValueToNumber(context, arguments[2], NULL);
564 int top = static_cast<unsigned>(JSValueToNumber(context, arguments[3], NULL));
565 int right = static_cast<unsigned>(JSValueToNumber(context, arguments[4], NULL));
566 int bottom = static_cast<unsigned>(JSValueToNumber(context, arguments[5], NULL));
567 int left = static_cast<unsigned>(JSValueToNumber(context, arguments[6], NULL));
568 bool ignoreClipping = JSValueToBoolean(context, arguments[7]);
570 // Has mac implementation.
571 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
572 return controller->nodesFromRect(context, arguments[0], x, y, top, right, bottom, left, ignoreClipping);
575 static JSValueRef layerTreeAsTextCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
577 // Has mac & windows implementation
578 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
579 return JSValueMakeString(context, controller->layerTreeAsText().get());
582 static JSValueRef notifyDoneCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
584 // Has mac & windows implementation
585 // May be able to be made platform independant by using shared WorkQueue
586 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
587 controller->notifyDone();
588 return JSValueMakeUndefined(context);
591 static bool parsePageParameters(JSContextRef context, int argumentCount, const JSValueRef* arguments, JSValueRef* exception, float& pageWidthInPixels, float& pageHeightInPixels)
593 pageWidthInPixels = LayoutTestController::maxViewWidth;
594 pageHeightInPixels = LayoutTestController::maxViewHeight;
595 switch (argumentCount) {
597 pageWidthInPixels = static_cast<float>(JSValueToNumber(context, arguments[0], exception));
600 pageHeightInPixels = static_cast<float>(JSValueToNumber(context, arguments[1], exception));
603 case 0: // Fall through.
611 // Caller needs to delete[] propertyName.
612 static bool parsePagePropertyParameters(JSContextRef context, int argumentCount, const JSValueRef* arguments, JSValueRef* exception, char*& propertyName, int& pageNumber)
615 switch (argumentCount) {
617 pageNumber = static_cast<float>(JSValueToNumber(context, arguments[1], exception));
622 JSRetainPtr<JSStringRef> propertyNameString(Adopt, JSValueToStringCopy(context, arguments[0], exception));
626 size_t maxLength = JSStringGetMaximumUTF8CStringSize(propertyNameString.get());
627 propertyName = new char[maxLength + 1];
628 JSStringGetUTF8CString(propertyNameString.get(), propertyName, maxLength + 1);
637 static bool parsePageNumber(JSContextRef context, int argumentCount, const JSValueRef* arguments, JSValueRef* exception, int& pageNumber)
640 switch (argumentCount) {
642 pageNumber = static_cast<int>(JSValueToNumber(context, arguments[0], exception));
653 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)
657 marginTop = marginRight = marginBottom = marginLeft = 0;
659 switch (argumentCount) {
661 marginLeft = static_cast<int>(JSValueToNumber(context, arguments[6], exception));
666 marginBottom = static_cast<int>(JSValueToNumber(context, arguments[5], exception));
671 marginRight = static_cast<int>(JSValueToNumber(context, arguments[4], exception));
676 marginTop = static_cast<int>(JSValueToNumber(context, arguments[3], exception));
681 height = static_cast<int>(JSValueToNumber(context, arguments[2], exception));
686 width = static_cast<int>(JSValueToNumber(context, arguments[1], exception));
691 pageNumber = static_cast<int>(JSValueToNumber(context, arguments[0], exception));
701 static JSValueRef pageNumberForElementByIdCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
703 float pageWidthInPixels = 0;
704 float pageHeightInPixels = 0;
705 if (!parsePageParameters(context, argumentCount - 1, arguments + 1, exception, pageWidthInPixels, pageHeightInPixels))
706 return JSValueMakeUndefined(context);
708 JSRetainPtr<JSStringRef> elementId(Adopt, JSValueToStringCopy(context, arguments[0], exception));
710 return JSValueMakeUndefined(context);
712 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
713 int pageNumber = controller->pageNumberForElementById(elementId.get(), pageWidthInPixels, pageHeightInPixels);
714 return JSValueMakeNumber(context, pageNumber);
717 static JSValueRef numberOfPagesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
719 float pageWidthInPixels = 0;
720 float pageHeightInPixels = 0;
721 if (!parsePageParameters(context, argumentCount, arguments, exception, pageWidthInPixels, pageHeightInPixels))
722 return JSValueMakeUndefined(context);
724 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
725 return JSValueMakeNumber(context, controller->numberOfPages(pageWidthInPixels, pageHeightInPixels));
728 static JSValueRef pagePropertyCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
730 char* propertyName = 0;
732 if (!parsePagePropertyParameters(context, argumentCount, arguments, exception, propertyName, pageNumber))
733 return JSValueMakeUndefined(context);
735 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
736 JSValueRef value = JSValueMakeString(context, controller->pageProperty(propertyName, pageNumber).get());
738 delete[] propertyName;
742 static JSValueRef isPageBoxVisibleCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
745 if (!parsePageNumber(context, argumentCount, arguments, exception, pageNumber))
746 return JSValueMakeUndefined(context);
748 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
749 return JSValueMakeBoolean(context, controller->isPageBoxVisible(pageNumber));
752 static JSValueRef pageSizeAndMarginsInPixelsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
755 int width = 0, height = 0;
756 int marginTop = 0, marginRight = 0, marginBottom = 0, marginLeft = 0;
757 if (!parsePageNumberSizeMarings(context, argumentCount, arguments, exception, pageNumber, width, height, marginTop, marginRight, marginBottom, marginLeft))
758 return JSValueMakeUndefined(context);
760 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
761 return JSValueMakeString(context, controller->pageSizeAndMarginsInPixels(pageNumber, width, height, marginTop, marginRight, marginBottom, marginLeft).get());
764 static JSValueRef queueBackNavigationCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
766 // Has mac & windows implementation
767 // May be able to be made platform independant by using shared WorkQueue
768 if (argumentCount < 1)
769 return JSValueMakeUndefined(context);
771 double howFarBackDouble = JSValueToNumber(context, arguments[0], exception);
774 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
775 controller->queueBackNavigation(static_cast<int>(howFarBackDouble));
777 return JSValueMakeUndefined(context);
780 static JSValueRef queueForwardNavigationCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
782 // Has mac & windows implementation
783 // May be able to be made platform independant by using shared WorkQueue
784 if (argumentCount < 1)
785 return JSValueMakeUndefined(context);
787 double howFarForwardDouble = JSValueToNumber(context, arguments[0], exception);
790 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
791 controller->queueForwardNavigation(static_cast<int>(howFarForwardDouble));
793 return JSValueMakeUndefined(context);
796 static JSValueRef queueLoadCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
798 // Has mac & windows implementation
799 // May be able to be made platform independant by using shared WorkQueue
800 if (argumentCount < 1)
801 return JSValueMakeUndefined(context);
803 JSRetainPtr<JSStringRef> url(Adopt, JSValueToStringCopy(context, arguments[0], exception));
806 JSRetainPtr<JSStringRef> target;
807 if (argumentCount >= 2) {
808 target.adopt(JSValueToStringCopy(context, arguments[1], exception));
811 target.adopt(JSStringCreateWithUTF8CString(""));
813 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
814 controller->queueLoad(url.get(), target.get());
816 return JSValueMakeUndefined(context);
819 static JSValueRef queueLoadHTMLStringCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
821 // Has Mac & Windows implementation
822 if (argumentCount < 1)
823 return JSValueMakeUndefined(context);
825 JSRetainPtr<JSStringRef> content(Adopt, JSValueToStringCopy(context, arguments[0], exception));
828 JSRetainPtr<JSStringRef> baseURL;
829 if (argumentCount >= 2) {
830 baseURL.adopt(JSValueToStringCopy(context, arguments[1], exception));
833 baseURL.adopt(JSStringCreateWithUTF8CString(""));
835 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
836 controller->queueLoadHTMLString(content.get(), baseURL.get());
838 return JSValueMakeUndefined(context);
841 static JSValueRef queueReloadCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
843 // Has mac & windows implementation
844 // May be able to be made platform independant by using shared WorkQueue
846 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
847 controller->queueReload();
849 return JSValueMakeUndefined(context);
852 static JSValueRef queueLoadingScriptCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
854 // Has mac & windows implementation
855 // May be able to be made platform independant by using shared WorkQueue
856 if (argumentCount < 1)
857 return JSValueMakeUndefined(context);
859 JSRetainPtr<JSStringRef> script(Adopt, JSValueToStringCopy(context, arguments[0], exception));
862 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
863 controller->queueLoadingScript(script.get());
865 return JSValueMakeUndefined(context);
868 static JSValueRef queueNonLoadingScriptCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
870 // Has mac & windows implementation
871 // May be able to be made platform independant by using shared WorkQueue
872 if (argumentCount < 1)
873 return JSValueMakeUndefined(context);
875 JSRetainPtr<JSStringRef> script(Adopt, JSValueToStringCopy(context, arguments[0], exception));
878 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
879 controller->queueNonLoadingScript(script.get());
881 return JSValueMakeUndefined(context);
884 static JSValueRef setAcceptsEditingCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
886 // Has mac & windows implementation
887 if (argumentCount < 1)
888 return JSValueMakeUndefined(context);
890 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
891 controller->setAcceptsEditing(JSValueToBoolean(context, arguments[0]));
893 return JSValueMakeUndefined(context);
896 static JSValueRef setAlwaysAcceptCookiesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
898 // Has mac & windows implementation
899 if (argumentCount < 1)
900 return JSValueMakeUndefined(context);
902 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
903 controller->setAlwaysAcceptCookies(JSValueToBoolean(context, arguments[0]));
905 return JSValueMakeUndefined(context);
908 static JSValueRef setAppCacheMaximumSizeCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
910 // Has mac implementation
911 if (argumentCount < 1)
912 return JSValueMakeUndefined(context);
914 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
916 double size = JSValueToNumber(context, arguments[0], NULL);
918 controller->setAppCacheMaximumSize(static_cast<unsigned long long>(size));
920 return JSValueMakeUndefined(context);
923 static JSValueRef setApplicationCacheOriginQuotaCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
925 // Has mac implementation
926 if (argumentCount < 1)
927 return JSValueMakeUndefined(context);
929 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
931 double size = JSValueToNumber(context, arguments[0], NULL);
933 controller->setApplicationCacheOriginQuota(static_cast<unsigned long long>(size));
935 return JSValueMakeUndefined(context);
938 static JSValueRef setAuthenticationPasswordCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
940 // Has mac & windows implementation
941 if (argumentCount < 1)
942 return JSValueMakeUndefined(context);
944 JSRetainPtr<JSStringRef> password(Adopt, JSValueToStringCopy(context, arguments[0], exception));
947 size_t maxLength = JSStringGetMaximumUTF8CStringSize(password.get());
948 char* passwordBuffer = new char[maxLength + 1];
949 JSStringGetUTF8CString(password.get(), passwordBuffer, maxLength + 1);
951 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
952 controller->setAuthenticationPassword(passwordBuffer);
953 delete[] passwordBuffer;
955 return JSValueMakeUndefined(context);
958 static JSValueRef setAuthenticationUsernameCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
960 // Has mac & windows implementation
961 if (argumentCount < 1)
962 return JSValueMakeUndefined(context);
964 JSRetainPtr<JSStringRef> username(Adopt, JSValueToStringCopy(context, arguments[0], exception));
967 size_t maxLength = JSStringGetMaximumUTF8CStringSize(username.get());
968 char* usernameBuffer = new char[maxLength + 1];
969 JSStringGetUTF8CString(username.get(), usernameBuffer, maxLength + 1);
971 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
972 controller->setAuthenticationUsername(usernameBuffer);
973 delete[] usernameBuffer;
975 return JSValueMakeUndefined(context);
978 static JSValueRef setAuthorAndUserStylesEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
980 // Has mac & windows implementation
981 if (argumentCount < 1)
982 return JSValueMakeUndefined(context);
984 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
985 controller->setAuthorAndUserStylesEnabled(JSValueToBoolean(context, arguments[0]));
987 return JSValueMakeUndefined(context);
990 static JSValueRef setCacheModelCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
992 // Has Mac implementation.
993 if (argumentCount < 1)
994 return JSValueMakeUndefined(context);
996 int cacheModel = JSValueToNumber(context, arguments[0], exception);
999 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1000 controller->setCacheModel(cacheModel);
1002 return JSValueMakeUndefined(context);
1005 static JSValueRef setCustomPolicyDelegateCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1007 // Has mac implementation
1008 if (argumentCount < 1)
1009 return JSValueMakeUndefined(context);
1011 bool permissive = false;
1012 if (argumentCount >= 2)
1013 permissive = JSValueToBoolean(context, arguments[1]);
1015 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1016 controller->setCustomPolicyDelegate(JSValueToBoolean(context, arguments[0]), permissive);
1018 return JSValueMakeUndefined(context);
1021 static JSValueRef setDatabaseQuotaCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1023 // Has mac implementation
1024 if (argumentCount < 1)
1025 return JSValueMakeUndefined(context);
1027 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1029 double quota = JSValueToNumber(context, arguments[0], NULL);
1031 controller->setDatabaseQuota(static_cast<unsigned long long>(quota));
1033 return JSValueMakeUndefined(context);
1036 static JSValueRef setDeferMainResourceDataLoadCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1038 // Has Mac and Windows implementation
1039 if (argumentCount < 1)
1040 return JSValueMakeUndefined(context);
1042 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1043 controller->setDeferMainResourceDataLoad(JSValueToBoolean(context, arguments[0]));
1045 return JSValueMakeUndefined(context);
1048 static JSValueRef setDomainRelaxationForbiddenForURLSchemeCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1050 // Has Mac and Windows implementation
1051 if (argumentCount < 2)
1052 return JSValueMakeUndefined(context);
1054 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1056 bool forbidden = JSValueToBoolean(context, arguments[0]);
1057 JSRetainPtr<JSStringRef> scheme(Adopt, JSValueToStringCopy(context, arguments[1], 0));
1058 controller->setDomainRelaxationForbiddenForURLScheme(forbidden, scheme.get());
1060 return JSValueMakeUndefined(context);
1063 static JSValueRef setMockDeviceOrientationCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1065 if (argumentCount < 6)
1066 return JSValueMakeUndefined(context);
1068 bool canProvideAlpha = JSValueToBoolean(context, arguments[0]);
1069 double alpha = JSValueToNumber(context, arguments[1], exception);
1070 ASSERT(!*exception);
1071 bool canProvideBeta = JSValueToBoolean(context, arguments[2]);
1072 double beta = JSValueToNumber(context, arguments[3], exception);
1073 ASSERT(!*exception);
1074 bool canProvideGamma = JSValueToBoolean(context, arguments[4]);
1075 double gamma = JSValueToNumber(context, arguments[5], exception);
1076 ASSERT(!*exception);
1078 LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1079 controller->setMockDeviceOrientation(canProvideAlpha, alpha, canProvideBeta, beta, canProvideGamma, gamma);
1081 return JSValueMakeUndefined(context);
1084 static JSValueRef setMockGeolocationPositionCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1086 if (argumentCount < 3)
1087 return JSValueMakeUndefined(context);
1089 LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1090 controller->setMockGeolocationPosition(JSValueToNumber(context, arguments[0], NULL), // latitude
1091 JSValueToNumber(context, arguments[1], NULL), // longitude
1092 JSValueToNumber(context, arguments[2], NULL)); // accuracy
1094 return JSValueMakeUndefined(context);
1097 static JSValueRef setMockGeolocationErrorCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1099 if (argumentCount < 2)
1100 return JSValueMakeUndefined(context);
1102 int code = JSValueToNumber(context, arguments[0], NULL);
1103 JSRetainPtr<JSStringRef> message(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1104 ASSERT(!*exception);
1106 LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1107 controller->setMockGeolocationError(code, message.get());
1109 return JSValueMakeUndefined(context);
1112 static JSValueRef addMockSpeechInputResultCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1114 if (argumentCount < 3)
1115 return JSValueMakeUndefined(context);
1117 JSRetainPtr<JSStringRef> result(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1118 ASSERT(!*exception);
1120 double confidence = JSValueToNumber(context, arguments[1], exception);
1122 JSRetainPtr<JSStringRef> language(Adopt, JSValueToStringCopy(context, arguments[2], exception));
1123 ASSERT(!*exception);
1125 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1126 controller->addMockSpeechInputResult(result.get(), confidence, language.get());
1128 return JSValueMakeUndefined(context);
1131 static JSValueRef setNewWindowsCopyBackForwardListCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1133 // Has mac implementation
1134 if (argumentCount < 1)
1135 return JSValueMakeUndefined(context);
1137 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1138 controller->setNewWindowsCopyBackForwardList(JSValueToBoolean(context, arguments[0]));
1140 return JSValueMakeUndefined(context);
1143 static JSValueRef setGeolocationPermissionCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1145 // Has mac implementation
1146 if (argumentCount < 1)
1147 return JSValueMakeUndefined(context);
1149 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1150 controller->setGeolocationPermission(JSValueToBoolean(context, arguments[0]));
1152 return JSValueMakeUndefined(context);
1155 static JSValueRef setHandlesAuthenticationChallengesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1157 // Has mac & windows implementation
1158 if (argumentCount < 1)
1159 return JSValueMakeUndefined(context);
1161 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1162 controller->setHandlesAuthenticationChallenges(JSValueToBoolean(context, arguments[0]));
1164 return JSValueMakeUndefined(context);
1167 static JSValueRef setPOSIXLocaleCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1169 if (argumentCount < 1)
1170 return JSValueMakeUndefined(context);
1172 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1173 JSRetainPtr<JSStringRef> locale(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1174 ASSERT(!*exception);
1175 controller->setPOSIXLocale(locale.get());
1177 return JSValueMakeUndefined(context);
1180 static JSValueRef setIconDatabaseEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1182 // Has mac & windows implementation
1183 if (argumentCount < 1)
1184 return JSValueMakeUndefined(context);
1186 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1187 controller->setIconDatabaseEnabled(JSValueToBoolean(context, arguments[0]));
1189 return JSValueMakeUndefined(context);
1192 static JSValueRef setJavaScriptProfilingEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1194 if (argumentCount < 1)
1195 return JSValueMakeUndefined(context);
1197 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1198 controller->setJavaScriptProfilingEnabled(JSValueToBoolean(context, arguments[0]));
1200 return JSValueMakeUndefined(context);
1203 static JSValueRef setMainFrameIsFirstResponderCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1205 // Has mac implementation
1206 if (argumentCount < 1)
1207 return JSValueMakeUndefined(context);
1209 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1210 controller->setMainFrameIsFirstResponder(JSValueToBoolean(context, arguments[0]));
1212 return JSValueMakeUndefined(context);
1215 static JSValueRef setPersistentUserStyleSheetLocationCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1217 // Has mac implementation
1218 if (argumentCount < 1)
1219 return JSValueMakeUndefined(context);
1221 JSRetainPtr<JSStringRef> path(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1222 ASSERT(!*exception);
1224 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1225 controller->setPersistentUserStyleSheetLocation(path.get());
1227 return JSValueMakeUndefined(context);
1230 static JSValueRef setPrivateBrowsingEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1232 // Has mac & windows implementation
1233 if (argumentCount < 1)
1234 return JSValueMakeUndefined(context);
1236 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1237 controller->setPrivateBrowsingEnabled(JSValueToBoolean(context, arguments[0]));
1239 return JSValueMakeUndefined(context);
1242 static JSValueRef setJavaScriptCanAccessClipboardCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1244 // Has mac & windows implementation
1245 if (argumentCount < 1)
1246 return JSValueMakeUndefined(context);
1248 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1249 controller->setJavaScriptCanAccessClipboard(JSValueToBoolean(context, arguments[0]));
1251 return JSValueMakeUndefined(context);
1254 static JSValueRef setXSSAuditorEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1256 // Has mac & windows implementation
1257 if (argumentCount < 1)
1258 return JSValueMakeUndefined(context);
1260 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1261 controller->setXSSAuditorEnabled(JSValueToBoolean(context, arguments[0]));
1263 return JSValueMakeUndefined(context);
1266 static JSValueRef setSpatialNavigationEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1268 // Has mac implementation.
1269 if (argumentCount < 1)
1270 return JSValueMakeUndefined(context);
1272 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1273 controller->setSpatialNavigationEnabled(JSValueToBoolean(context, arguments[0]));
1275 return JSValueMakeUndefined(context);
1278 static JSValueRef setPrintingCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1280 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1281 controller->setIsPrinting(true);
1282 return JSValueMakeUndefined(context);
1286 static JSValueRef setFrameFlatteningEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1288 // Has mac & windows implementation
1289 if (argumentCount < 1)
1290 return JSValueMakeUndefined(context);
1292 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1293 controller->setFrameFlatteningEnabled(JSValueToBoolean(context, arguments[0]));
1295 return JSValueMakeUndefined(context);
1298 static JSValueRef setAllowUniversalAccessFromFileURLsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1300 // Has mac & windows implementation
1301 if (argumentCount < 1)
1302 return JSValueMakeUndefined(context);
1304 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1305 controller->setAllowUniversalAccessFromFileURLs(JSValueToBoolean(context, arguments[0]));
1307 return JSValueMakeUndefined(context);
1310 static JSValueRef setAllowFileAccessFromFileURLsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1312 // Has mac & windows implementation
1313 if (argumentCount < 1)
1314 return JSValueMakeUndefined(context);
1316 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1317 controller->setAllowFileAccessFromFileURLs(JSValueToBoolean(context, arguments[0]));
1319 return JSValueMakeUndefined(context);
1322 static JSValueRef setTabKeyCyclesThroughElementsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1324 // Has mac & windows implementation
1325 if (argumentCount < 1)
1326 return JSValueMakeUndefined(context);
1328 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1329 controller->setTabKeyCyclesThroughElements(JSValueToBoolean(context, arguments[0]));
1331 return JSValueMakeUndefined(context);
1334 static JSValueRef setTimelineProfilingEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1336 if (argumentCount < 1)
1337 return JSValueMakeUndefined(context);
1339 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1340 controller->setTimelineProfilingEnabled(JSValueToBoolean(context, arguments[0]));
1341 return JSValueMakeUndefined(context);
1344 static JSValueRef setUseDashboardCompatibilityModeCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1346 // Has mac implementation
1347 if (argumentCount < 1)
1348 return JSValueMakeUndefined(context);
1350 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1351 controller->setUseDashboardCompatibilityMode(JSValueToBoolean(context, arguments[0]));
1353 return JSValueMakeUndefined(context);
1356 static JSValueRef setUserStyleSheetEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1358 // Has mac implementation
1359 if (argumentCount < 1)
1360 return JSValueMakeUndefined(context);
1362 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1363 controller->setUserStyleSheetEnabled(JSValueToBoolean(context, arguments[0]));
1365 return JSValueMakeUndefined(context);
1368 static JSValueRef setUserStyleSheetLocationCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1370 // Has mac implementation
1371 if (argumentCount < 1)
1372 return JSValueMakeUndefined(context);
1374 JSRetainPtr<JSStringRef> path(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1375 ASSERT(!*exception);
1377 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1378 controller->setUserStyleSheetLocation(path.get());
1380 return JSValueMakeUndefined(context);
1383 static JSValueRef setViewModeMediaFeatureCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1385 // Has mac implementation
1386 if (argumentCount < 1)
1387 return JSValueMakeUndefined(context);
1389 JSRetainPtr<JSStringRef> mode(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1390 ASSERT(!*exception);
1392 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1393 controller->setViewModeMediaFeature(mode.get());
1395 return JSValueMakeUndefined(context);
1398 static JSValueRef setWillSendRequestClearHeaderCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1400 // Has mac & windows implementation
1401 if (argumentCount < 1)
1402 return JSValueMakeUndefined(context);
1404 JSRetainPtr<JSStringRef> header(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1405 ASSERT(!*exception);
1407 size_t maxLength = JSStringGetMaximumUTF8CStringSize(header.get());
1408 char* headerBuffer = new char[maxLength + 1];
1409 JSStringGetUTF8CString(header.get(), headerBuffer, maxLength + 1);
1411 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1412 controller->setWillSendRequestClearHeader(headerBuffer);
1414 return JSValueMakeUndefined(context);
1417 static JSValueRef setWillSendRequestReturnsNullCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1419 // Has cross-platform implementation
1420 if (argumentCount < 1)
1421 return JSValueMakeUndefined(context);
1423 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1424 controller->setWillSendRequestReturnsNull(JSValueToBoolean(context, arguments[0]));
1426 return JSValueMakeUndefined(context);
1429 static JSValueRef setWillSendRequestReturnsNullOnRedirectCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1431 // Has cross-platform implementation
1432 if (argumentCount < 1)
1433 return JSValueMakeUndefined(context);
1435 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1436 controller->setWillSendRequestReturnsNullOnRedirect(JSValueToBoolean(context, arguments[0]));
1438 return JSValueMakeUndefined(context);
1441 static JSValueRef setWindowIsKeyCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1443 // Has mac implementation
1444 if (argumentCount < 1)
1445 return JSValueMakeUndefined(context);
1447 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1448 controller->setWindowIsKey(JSValueToBoolean(context, arguments[0]));
1450 return JSValueMakeUndefined(context);
1453 static JSValueRef waitUntilDoneCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1455 // Has mac & windows implementation
1456 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1457 controller->setWaitToDump(true);
1459 return JSValueMakeUndefined(context);
1462 static JSValueRef windowCountCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1464 // Has mac implementation
1465 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1466 int windows = controller->windowCount();
1467 return JSValueMakeNumber(context, windows);
1470 static JSValueRef setPopupBlockingEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1472 // Has mac & windows implementation
1473 if (argumentCount < 1)
1474 return JSValueMakeUndefined(context);
1476 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1477 controller->setPopupBlockingEnabled(JSValueToBoolean(context, arguments[0]));
1479 return JSValueMakeUndefined(context);
1482 static JSValueRef setPluginsEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1484 // Has mac & windows implementation
1485 if (argumentCount < 1)
1486 return JSValueMakeUndefined(context);
1488 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1489 controller->setPluginsEnabled(JSValueToBoolean(context, arguments[0]));
1491 return JSValueMakeUndefined(context);
1494 static JSValueRef setSmartInsertDeleteEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1496 if (argumentCount < 1)
1497 return JSValueMakeUndefined(context);
1499 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1500 controller->setSmartInsertDeleteEnabled(JSValueToBoolean(context, arguments[0]));
1501 return JSValueMakeUndefined(context);
1504 static JSValueRef setSelectTrailingWhitespaceEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1506 if (argumentCount < 1)
1507 return JSValueMakeUndefined(context);
1509 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1510 controller->setSelectTrailingWhitespaceEnabled(JSValueToBoolean(context, arguments[0]));
1511 return JSValueMakeUndefined(context);
1514 static JSValueRef setStopProvisionalFrameLoadsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1516 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1517 controller->setStopProvisionalFrameLoads(true);
1518 return JSValueMakeUndefined(context);
1521 static JSValueRef setAsynchronousSpellCheckingEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1523 if (argumentCount < 1)
1524 return JSValueMakeUndefined(context);
1526 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1527 controller->setAsynchronousSpellCheckingEnabled(JSValueToBoolean(context, arguments[0]));
1528 return JSValueMakeUndefined(context);
1531 static JSValueRef showWebInspectorCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1533 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1534 controller->showWebInspector();
1535 return JSValueMakeUndefined(context);
1538 static JSValueRef closeWebInspectorCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1540 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1541 controller->setTimelineProfilingEnabled(false);
1542 controller->closeWebInspector();
1543 return JSValueMakeUndefined(context);
1546 static JSValueRef evaluateInWebInspectorCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1548 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1549 double callId = JSValueToNumber(context, arguments[0], exception);
1550 ASSERT(!*exception);
1551 JSRetainPtr<JSStringRef> script(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1552 ASSERT(!*exception);
1554 controller->evaluateInWebInspector(static_cast<long>(callId), script.get());
1555 return JSValueMakeUndefined(context);
1558 static JSValueRef evaluateScriptInIsolatedWorldCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1560 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1561 double worldID = JSValueToNumber(context, arguments[0], exception);
1562 ASSERT(!*exception);
1563 JSRetainPtr<JSStringRef> script(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1564 ASSERT(!*exception);
1566 controller->evaluateScriptInIsolatedWorld(static_cast<unsigned>(worldID), JSContextGetGlobalObject(context), script.get());
1567 return JSValueMakeUndefined(context);
1570 static JSValueRef elementDoesAutoCompleteForElementWithIdCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1572 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1573 JSRetainPtr<JSStringRef> elementId(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1574 ASSERT(!*exception);
1576 bool autoCompletes = controller->elementDoesAutoCompleteForElementWithId(elementId.get());
1578 return JSValueMakeBoolean(context, autoCompletes);
1581 static JSValueRef pauseAnimationAtTimeOnElementWithIdCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1583 if (argumentCount != 3)
1584 return JSValueMakeUndefined(context);
1586 JSRetainPtr<JSStringRef> animationName(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1587 ASSERT(!*exception);
1588 double time = JSValueToNumber(context, arguments[1], exception);
1589 ASSERT(!*exception);
1590 JSRetainPtr<JSStringRef> elementId(Adopt, JSValueToStringCopy(context, arguments[2], exception));
1591 ASSERT(!*exception);
1593 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1594 return JSValueMakeBoolean(context, controller->pauseAnimationAtTimeOnElementWithId(animationName.get(), time, elementId.get()));
1597 static JSValueRef pauseTransitionAtTimeOnElementWithIdCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1599 if (argumentCount != 3)
1600 return JSValueMakeUndefined(context);
1602 JSRetainPtr<JSStringRef> propertyName(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1603 ASSERT(!*exception);
1604 double time = JSValueToNumber(context, arguments[1], exception);
1605 ASSERT(!*exception);
1606 JSRetainPtr<JSStringRef> elementId(Adopt, JSValueToStringCopy(context, arguments[2], exception));
1607 ASSERT(!*exception);
1609 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1610 return JSValueMakeBoolean(context, controller->pauseTransitionAtTimeOnElementWithId(propertyName.get(), time, elementId.get()));
1613 static JSValueRef sampleSVGAnimationForElementAtTimeCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1615 if (argumentCount != 3)
1616 return JSValueMakeUndefined(context);
1618 JSRetainPtr<JSStringRef> animationId(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1619 ASSERT(!*exception);
1620 double time = JSValueToNumber(context, arguments[1], exception);
1621 ASSERT(!*exception);
1622 JSRetainPtr<JSStringRef> elementId(Adopt, JSValueToStringCopy(context, arguments[2], exception));
1623 ASSERT(!*exception);
1625 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1626 return JSValueMakeBoolean(context, controller->sampleSVGAnimationForElementAtTime(animationId.get(), time, elementId.get()));
1629 static JSValueRef numberOfActiveAnimationsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1631 if (argumentCount != 0)
1632 return JSValueMakeUndefined(context);
1634 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1635 return JSValueMakeNumber(context, controller->numberOfActiveAnimations());
1638 static JSValueRef suspendAnimationsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1640 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1641 controller->suspendAnimations();
1642 return JSValueMakeUndefined(context);
1645 static JSValueRef resumeAnimationsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1647 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1648 controller->resumeAnimations();
1649 return JSValueMakeUndefined(context);
1652 static JSValueRef waitForPolicyDelegateCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t, const JSValueRef[], JSValueRef*)
1654 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1655 controller->waitForPolicyDelegate();
1656 return JSValueMakeUndefined(context);
1659 static JSValueRef addOriginAccessWhitelistEntryCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1661 if (argumentCount != 4)
1662 return JSValueMakeUndefined(context);
1664 JSRetainPtr<JSStringRef> sourceOrigin(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1665 ASSERT(!*exception);
1666 JSRetainPtr<JSStringRef> destinationProtocol(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1667 ASSERT(!*exception);
1668 JSRetainPtr<JSStringRef> destinationHost(Adopt, JSValueToStringCopy(context, arguments[2], exception));
1669 ASSERT(!*exception);
1670 bool allowDestinationSubdomains = JSValueToBoolean(context, arguments[3]);
1672 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1673 controller->addOriginAccessWhitelistEntry(sourceOrigin.get(), destinationProtocol.get(), destinationHost.get(), allowDestinationSubdomains);
1674 return JSValueMakeUndefined(context);
1677 static JSValueRef removeOriginAccessWhitelistEntryCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1679 if (argumentCount != 4)
1680 return JSValueMakeUndefined(context);
1682 JSRetainPtr<JSStringRef> sourceOrigin(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1683 ASSERT(!*exception);
1684 JSRetainPtr<JSStringRef> destinationProtocol(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1685 ASSERT(!*exception);
1686 JSRetainPtr<JSStringRef> destinationHost(Adopt, JSValueToStringCopy(context, arguments[2], exception));
1687 ASSERT(!*exception);
1688 bool allowDestinationSubdomains = JSValueToBoolean(context, arguments[3]);
1690 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1691 controller->removeOriginAccessWhitelistEntry(sourceOrigin.get(), destinationProtocol.get(), destinationHost.get(), allowDestinationSubdomains);
1692 return JSValueMakeUndefined(context);
1695 static JSValueRef setScrollbarPolicyCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1697 if (argumentCount != 2)
1698 return JSValueMakeUndefined(context);
1700 JSRetainPtr<JSStringRef> orientation(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1701 ASSERT(!*exception);
1702 JSRetainPtr<JSStringRef> policy(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1703 ASSERT(!*exception);
1705 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1706 controller->setScrollbarPolicy(orientation.get(), policy.get());
1707 return JSValueMakeUndefined(context);
1710 static JSValueRef addUserScriptCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1712 if (argumentCount != 3)
1713 return JSValueMakeUndefined(context);
1715 JSRetainPtr<JSStringRef> source(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1716 ASSERT(!*exception);
1717 bool runAtStart = JSValueToBoolean(context, arguments[1]);
1718 bool allFrames = JSValueToBoolean(context, arguments[2]);
1720 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1721 controller->addUserScript(source.get(), runAtStart, allFrames);
1722 return JSValueMakeUndefined(context);
1725 static JSValueRef addUserStyleSheetCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1727 if (argumentCount != 2)
1728 return JSValueMakeUndefined(context);
1730 JSRetainPtr<JSStringRef> source(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1731 ASSERT(!*exception);
1732 bool allFrames = JSValueToBoolean(context, arguments[1]);
1734 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1735 controller->addUserStyleSheet(source.get(), allFrames);
1736 return JSValueMakeUndefined(context);
1739 static JSValueRef apiTestNewWindowDataLoadBaseURLCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1741 if (argumentCount != 2)
1742 return JSValueMakeUndefined(context);
1744 JSRetainPtr<JSStringRef> utf8Data(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1745 ASSERT(!*exception);
1747 JSRetainPtr<JSStringRef> baseURL(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1748 ASSERT(!*exception);
1750 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1751 controller->apiTestNewWindowDataLoadBaseURL(utf8Data.get(), baseURL.get());
1752 return JSValueMakeUndefined(context);
1755 static JSValueRef apiTestGoToCurrentBackForwardItemCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1757 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1758 controller->apiTestGoToCurrentBackForwardItem();
1759 return JSValueMakeUndefined(context);
1762 static JSValueRef setWebViewEditableCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1764 // Has Mac implementation
1765 if (argumentCount < 1)
1766 return JSValueMakeUndefined(context);
1768 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1769 controller->setWebViewEditable(JSValueToBoolean(context, arguments[0]));
1771 return JSValueMakeUndefined(context);
1775 static JSValueRef abortModalCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1777 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1778 controller->abortModal();
1779 return JSValueMakeUndefined(context);
1782 static JSValueRef hasSpellingMarkerCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1784 if (argumentCount != 2)
1785 return JSValueMakeUndefined(context);
1787 int from = JSValueToNumber(context, arguments[0], 0);
1788 int length = JSValueToNumber(context, arguments[1], 0);
1789 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1790 bool ok = controller->hasSpellingMarker(from, length);
1792 return JSValueMakeBoolean(context, ok);
1795 static JSValueRef markerTextForListItemCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1797 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1798 if (argumentCount < 1)
1799 return JSValueMakeUndefined(context);
1800 return JSValueMakeString(context, controller->markerTextForListItem(context, arguments[0]).get());
1803 static JSValueRef authenticateSessionCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1805 // authenticateSession(url, username, password)
1806 if (argumentCount != 3)
1807 return JSValueMakeUndefined(context);
1809 JSRetainPtr<JSStringRef> url(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1810 ASSERT(!*exception);
1811 JSRetainPtr<JSStringRef> username(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1812 ASSERT(!*exception);
1813 JSRetainPtr<JSStringRef> password(Adopt, JSValueToStringCopy(context, arguments[2], exception));
1814 ASSERT(!*exception);
1816 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1817 controller->authenticateSession(url.get(), username.get(), password.get());
1818 return JSValueMakeUndefined(context);
1821 static JSValueRef setEditingBehaviorCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1823 // The editing behavior string.
1824 if (argumentCount < 1)
1825 return JSValueMakeUndefined(context);
1827 JSRetainPtr<JSStringRef> editingBehavior(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1828 ASSERT(!*exception);
1830 size_t maxLength = JSStringGetMaximumUTF8CStringSize(editingBehavior.get());
1831 char* behaviorBuffer = new char[maxLength + 1];
1832 JSStringGetUTF8CString(editingBehavior.get(), behaviorBuffer, maxLength);
1834 if (strcmp(behaviorBuffer, "mac") && strcmp(behaviorBuffer, "win") && strcmp(behaviorBuffer, "unix")) {
1835 JSRetainPtr<JSStringRef> invalidArgument(JSStringCreateWithUTF8CString("Passed invalid editing behavior. Must be 'mac', 'win', or 'unix'."));
1836 *exception = JSValueMakeString(context, invalidArgument.get());
1837 return JSValueMakeUndefined(context);
1840 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1841 controller->setEditingBehavior(behaviorBuffer);
1843 delete [] behaviorBuffer;
1845 return JSValueMakeUndefined(context);
1848 static JSValueRef setSerializeHTTPLoadsCallback(JSContextRef context, JSObjectRef, JSObjectRef, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1850 bool serialize = true;
1851 if (argumentCount == 1)
1852 serialize = JSValueToBoolean(context, arguments[0]);
1854 LayoutTestController::setSerializeHTTPLoads(serialize);
1855 return JSValueMakeUndefined(context);
1860 static JSValueRef getGlobalFlagCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
1862 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1863 return JSValueMakeBoolean(context, controller->globalFlag());
1866 static JSValueRef getWebHistoryItemCountCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
1868 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1869 return JSValueMakeNumber(context, controller->webHistoryItemCount());
1872 static JSValueRef getWorkerThreadCountCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
1874 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1875 return JSValueMakeNumber(context, controller->workerThreadCount());
1878 static bool setGlobalFlagCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef value, JSValueRef* exception)
1880 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1881 controller->setGlobalFlag(JSValueToBoolean(context, value));
1885 static void layoutTestControllerObjectFinalize(JSObjectRef object)
1887 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(object));
1888 controller->deref();
1893 void LayoutTestController::makeWindowObject(JSContextRef context, JSObjectRef windowObject, JSValueRef* exception)
1895 JSRetainPtr<JSStringRef> layoutTestContollerStr(Adopt, JSStringCreateWithUTF8CString("layoutTestController"));
1898 JSClassRef classRef = getJSClass();
1899 JSValueRef layoutTestContollerObject = JSObjectMake(context, classRef, this);
1900 JSClassRelease(classRef);
1902 JSObjectSetProperty(context, windowObject, layoutTestContollerStr.get(), layoutTestContollerObject, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete, exception);
1905 JSClassRef LayoutTestController::getJSClass()
1907 static JSStaticValue* staticValues = LayoutTestController::staticValues();
1908 static JSStaticFunction* staticFunctions = LayoutTestController::staticFunctions();
1909 static JSClassDefinition classDefinition = {
1910 0, kJSClassAttributeNone, "LayoutTestController", 0, staticValues, staticFunctions,
1911 0, layoutTestControllerObjectFinalize, 0, 0, 0, 0, 0, 0, 0, 0, 0
1914 return JSClassCreate(&classDefinition);
1917 JSStaticValue* LayoutTestController::staticValues()
1919 static JSStaticValue staticValues[] = {
1920 { "globalFlag", getGlobalFlagCallback, setGlobalFlagCallback, kJSPropertyAttributeNone },
1921 { "webHistoryItemCount", getWebHistoryItemCountCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1922 { "workerThreadCount", getWorkerThreadCountCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1925 return staticValues;
1928 JSStaticFunction* LayoutTestController::staticFunctions()
1930 static JSStaticFunction staticFunctions[] = {
1931 { "abortModal", abortModalCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1932 { "addDisallowedURL", addDisallowedURLCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1933 { "addUserScript", addUserScriptCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1934 { "addUserStyleSheet", addUserStyleSheetCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1935 { "apiTestNewWindowDataLoadBaseURL", apiTestNewWindowDataLoadBaseURLCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1936 { "apiTestGoToCurrentBackForwardItem", apiTestGoToCurrentBackForwardItemCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1937 { "callShouldCloseOnWebView", callShouldCloseOnWebViewCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1938 { "clearAllApplicationCaches", clearAllApplicationCachesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1939 { "clearAllDatabases", clearAllDatabasesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1940 { "clearBackForwardList", clearBackForwardListCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1941 { "clearPersistentUserStyleSheet", clearPersistentUserStyleSheetCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1942 { "closeWebInspector", closeWebInspectorCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1943 { "computedStyleIncludingVisitedInfo", computedStyleIncludingVisitedInfoCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1944 { "nodesFromRect", nodesFromRectCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1945 { "decodeHostName", decodeHostNameCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1946 { "disableImageLoading", disableImageLoadingCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1947 { "dispatchPendingLoadRequests", dispatchPendingLoadRequestsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1948 { "display", displayCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1949 { "dumpApplicationCacheDelegateCallbacks", dumpApplicationCacheDelegateCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1950 { "dumpAsText", dumpAsTextCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1951 { "dumpBackForwardList", dumpBackForwardListCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1952 { "dumpChildFrameScrollPositions", dumpChildFrameScrollPositionsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1953 { "dumpChildFramesAsText", dumpChildFramesAsTextCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1954 { "dumpConfigurationForViewport", dumpConfigurationForViewportCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1955 { "dumpDOMAsWebArchive", dumpDOMAsWebArchiveCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1956 { "dumpDatabaseCallbacks", dumpDatabaseCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1957 { "dumpEditingCallbacks", dumpEditingCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1958 { "dumpFrameLoadCallbacks", dumpFrameLoadCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1959 { "dumpUserGestureInFrameLoadCallbacks", dumpUserGestureInFrameLoadCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1960 { "dumpResourceLoadCallbacks", dumpResourceLoadCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1961 { "dumpResourceResponseMIMETypes", dumpResourceResponseMIMETypesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1962 { "dumpSelectionRect", dumpSelectionRectCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1963 { "dumpSourceAsWebArchive", dumpSourceAsWebArchiveCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1964 { "dumpStatusCallbacks", dumpStatusCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1965 { "dumpTitleChanges", dumpTitleChangesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1966 { "dumpIconChanges", dumpIconChangesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1967 { "dumpWillCacheResponse", dumpWillCacheResponseCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1968 { "elementDoesAutoCompleteForElementWithId", elementDoesAutoCompleteForElementWithIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1969 { "encodeHostName", encodeHostNameCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1970 { "evaluateInWebInspector", evaluateInWebInspectorCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1971 { "evaluateScriptInIsolatedWorld", evaluateScriptInIsolatedWorldCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1972 { "execCommand", execCommandCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1973 { "findString", findStringCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1974 { "counterValueForElementById", counterValueForElementByIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1975 { "grantDesktopNotificationPermission", grantDesktopNotificationPermissionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1976 { "hasSpellingMarker", hasSpellingMarkerCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1977 { "isCommandEnabled", isCommandEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1978 { "isPageBoxVisible", isPageBoxVisibleCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1979 { "keepWebHistory", keepWebHistoryCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1980 { "layerTreeAsText", layerTreeAsTextCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1981 { "numberOfPages", numberOfPagesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1982 { "markerTextForListItem", markerTextForListItemCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1983 { "notifyDone", notifyDoneCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1984 { "numberOfActiveAnimations", numberOfActiveAnimationsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1985 { "suspendAnimations", suspendAnimationsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1986 { "resumeAnimations", resumeAnimationsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1987 { "overridePreference", overridePreferenceCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1988 { "pageNumberForElementById", pageNumberForElementByIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1989 { "pageSizeAndMarginsInPixels", pageSizeAndMarginsInPixelsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1990 { "pageProperty", pagePropertyCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1991 { "pathToLocalResource", pathToLocalResourceCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1992 { "pauseAnimationAtTimeOnElementWithId", pauseAnimationAtTimeOnElementWithIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1993 { "pauseTransitionAtTimeOnElementWithId", pauseTransitionAtTimeOnElementWithIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1994 { "sampleSVGAnimationForElementAtTime", sampleSVGAnimationForElementAtTimeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1995 { "printToPDF", dumpAsPDFCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1996 { "queueBackNavigation", queueBackNavigationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1997 { "queueForwardNavigation", queueForwardNavigationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1998 { "queueLoad", queueLoadCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1999 { "queueLoadHTMLString", queueLoadHTMLStringCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2000 { "queueLoadingScript", queueLoadingScriptCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2001 { "queueNonLoadingScript", queueNonLoadingScriptCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2002 { "queueReload", queueReloadCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2003 { "removeAllVisitedLinks", removeAllVisitedLinksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2004 { "removeOriginAccessWhitelistEntry", removeOriginAccessWhitelistEntryCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2005 { "repaintSweepHorizontally", repaintSweepHorizontallyCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2006 { "setAcceptsEditing", setAcceptsEditingCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2007 { "setAllowUniversalAccessFromFileURLs", setAllowUniversalAccessFromFileURLsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2008 { "setAllowFileAccessFromFileURLs", setAllowFileAccessFromFileURLsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2009 { "setAlwaysAcceptCookies", setAlwaysAcceptCookiesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2010 { "setAppCacheMaximumSize", setAppCacheMaximumSizeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2011 { "setApplicationCacheOriginQuota", setApplicationCacheOriginQuotaCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2012 { "setAuthenticationPassword", setAuthenticationPasswordCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2013 { "setAuthenticationUsername", setAuthenticationUsernameCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2014 { "setAuthorAndUserStylesEnabled", setAuthorAndUserStylesEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2015 { "setCacheModel", setCacheModelCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2016 { "setCallCloseOnWebViews", setCallCloseOnWebViewsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2017 { "setCanOpenWindows", setCanOpenWindowsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2018 { "setCloseRemainingWindowsWhenComplete", setCloseRemainingWindowsWhenCompleteCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2019 { "setCustomPolicyDelegate", setCustomPolicyDelegateCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2020 { "setDatabaseQuota", setDatabaseQuotaCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2021 { "setDeferMainResourceDataLoad", setDeferMainResourceDataLoadCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2022 { "setDomainRelaxationForbiddenForURLScheme", setDomainRelaxationForbiddenForURLSchemeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2023 { "setEditingBehavior", setEditingBehaviorCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2024 { "setFrameFlatteningEnabled", setFrameFlatteningEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2025 { "setGeolocationPermission", setGeolocationPermissionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2026 { "setHandlesAuthenticationChallenges", setHandlesAuthenticationChallengesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2027 { "setIconDatabaseEnabled", setIconDatabaseEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2028 { "setJavaScriptProfilingEnabled", setJavaScriptProfilingEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2029 { "setMainFrameIsFirstResponder", setMainFrameIsFirstResponderCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2030 { "setMockDeviceOrientation", setMockDeviceOrientationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2031 { "setMockGeolocationError", setMockGeolocationErrorCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2032 { "setMockGeolocationPosition", setMockGeolocationPositionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2033 { "addMockSpeechInputResult", addMockSpeechInputResultCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2034 { "setNewWindowsCopyBackForwardList", setNewWindowsCopyBackForwardListCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2035 { "setPOSIXLocale", setPOSIXLocaleCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2036 { "setPersistentUserStyleSheetLocation", setPersistentUserStyleSheetLocationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2037 { "setPopupBlockingEnabled", setPopupBlockingEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2038 { "setPluginsEnabled", setPluginsEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2039 { "setPrinting", setPrintingCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2040 { "setPrivateBrowsingEnabled", setPrivateBrowsingEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2041 { "setSelectTrailingWhitespaceEnabled", setSelectTrailingWhitespaceEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2042 { "setSerializeHTTPLoads", setSerializeHTTPLoadsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2043 { "setSmartInsertDeleteEnabled", setSmartInsertDeleteEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2044 { "setSpatialNavigationEnabled", setSpatialNavigationEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2045 { "setStopProvisionalFrameLoads", setStopProvisionalFrameLoadsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2046 { "setTabKeyCyclesThroughElements", setTabKeyCyclesThroughElementsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2047 { "setTimelineProfilingEnabled", setTimelineProfilingEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2048 { "setUseDashboardCompatibilityMode", setUseDashboardCompatibilityModeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2049 { "setUserStyleSheetEnabled", setUserStyleSheetEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2050 { "setUserStyleSheetLocation", setUserStyleSheetLocationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2051 { "setViewModeMediaFeature", setViewModeMediaFeatureCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2052 { "setWebViewEditable", setWebViewEditableCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2053 { "setWillSendRequestClearHeader", setWillSendRequestClearHeaderCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2054 { "setWillSendRequestReturnsNull", setWillSendRequestReturnsNullCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2055 { "setWillSendRequestReturnsNullOnRedirect", setWillSendRequestReturnsNullOnRedirectCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2056 { "setWindowIsKey", setWindowIsKeyCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2057 { "setJavaScriptCanAccessClipboard", setJavaScriptCanAccessClipboardCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2058 { "setXSSAuditorEnabled", setXSSAuditorEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2059 { "setAsynchronousSpellCheckingEnabled", setAsynchronousSpellCheckingEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2060 { "showWebInspector", showWebInspectorCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2061 { "testOnscreen", testOnscreenCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2062 { "testRepaint", testRepaintCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2063 { "waitForPolicyDelegate", waitForPolicyDelegateCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2064 { "waitUntilDone", waitUntilDoneCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2065 { "windowCount", windowCountCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2066 { "addOriginAccessWhitelistEntry", addOriginAccessWhitelistEntryCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2067 { "setScrollbarPolicy", setScrollbarPolicyCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2068 { "authenticateSession", authenticateSessionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2072 return staticFunctions;
2075 void LayoutTestController::queueLoadHTMLString(JSStringRef content, JSStringRef baseURL)
2077 WorkQueue::shared()->queue(new LoadHTMLStringItem(content, baseURL));
2080 void LayoutTestController::queueBackNavigation(int howFarBack)
2082 WorkQueue::shared()->queue(new BackItem(howFarBack));
2085 void LayoutTestController::queueForwardNavigation(int howFarForward)
2087 WorkQueue::shared()->queue(new ForwardItem(howFarForward));
2090 void LayoutTestController::queueLoadingScript(JSStringRef script)
2092 WorkQueue::shared()->queue(new LoadingScriptItem(script));
2095 void LayoutTestController::queueNonLoadingScript(JSStringRef script)
2097 WorkQueue::shared()->queue(new NonLoadingScriptItem(script));
2100 void LayoutTestController::queueReload()
2102 WorkQueue::shared()->queue(new ReloadItem);
2105 void LayoutTestController::grantDesktopNotificationPermission(JSStringRef origin)
2107 m_desktopNotificationAllowedOrigins.push_back(JSStringRetain(origin));
2110 bool LayoutTestController::checkDesktopNotificationPermission(JSStringRef origin)
2112 std::vector<JSStringRef>::iterator i;
2113 for (i = m_desktopNotificationAllowedOrigins.begin();
2114 i != m_desktopNotificationAllowedOrigins.end();
2116 if (JSStringIsEqual(*i, origin))
2122 void LayoutTestController::waitToDumpWatchdogTimerFired()
2124 const char* message = "FAIL: Timed out waiting for notifyDone to be called\n";
2125 fprintf(stderr, "%s", message);
2126 fprintf(stdout, "%s", message);
2130 void LayoutTestController::setGeolocationPermissionCommon(bool allow)
2132 m_isGeolocationPermissionSet = true;
2133 m_geolocationPermission = allow;
2136 void LayoutTestController::setPOSIXLocale(JSStringRef locale)
2139 JSStringGetUTF8CString(locale, localeBuf, sizeof(localeBuf));
2140 setlocale(LC_ALL, localeBuf);
2143 const unsigned LayoutTestController::maxViewWidth = 800;
2144 const unsigned LayoutTestController::maxViewHeight = 600;