[Release] Webkit-EFL Ver. 2.0_beta_118996_0.6.24
[framework/web/webkit-efl.git] / Tools / DumpRenderTree / LayoutTestController.cpp
1 /*
2  * Copyright (C) 2007, 2008, 2009, 2011 Apple Inc. All rights reserved.
3  * Copyright (C) 2010 Joone Hur <joone@kldp.org>
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
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. 
17  *
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.
28  */
29
30 #include "config.h"
31 #include "LayoutTestController.h"
32
33 #include "WorkQueue.h"
34 #include "WorkQueueItem.h"
35 #include <cstring>
36 #include <JavaScriptCore/JSContextRef.h>
37 #include <JavaScriptCore/JSObjectRef.h>
38 #include <JavaScriptCore/JSRetainPtr.h>
39 #include <locale.h>
40 #include <stdio.h>
41 #include <wtf/Assertions.h>
42 #include <wtf/CurrentTime.h>
43 #include <wtf/MathExtras.h>
44 #include <wtf/OwnArrayPtr.h>
45 #include <wtf/RefPtr.h>
46
47 LayoutTestController::LayoutTestController(const std::string& testPathOrURL, const std::string& expectedPixelHash)
48     : m_disallowIncreaseForApplicationCacheQuota(false)
49     , m_dumpApplicationCacheDelegateCallbacks(false)
50     , m_dumpAsAudio(false)
51     , m_dumpAsPDF(false)
52     , m_dumpAsText(false)
53     , m_dumpBackForwardList(false)
54     , m_dumpChildFrameScrollPositions(false)
55     , m_dumpChildFramesAsText(false)
56     , m_dumpDOMAsWebArchive(false)
57     , m_dumpDatabaseCallbacks(false)
58     , m_dumpEditingCallbacks(false)
59     , m_dumpFrameLoadCallbacks(false)
60     , m_dumpProgressFinishedCallback(false)
61     , m_dumpUserGestureInFrameLoadCallbacks(false)
62     , m_dumpHistoryDelegateCallbacks(false)
63     , m_dumpResourceLoadCallbacks(false)
64     , m_dumpResourceResponseMIMETypes(false)
65     , m_dumpSelectionRect(false)
66     , m_dumpSourceAsWebArchive(false)
67     , m_dumpStatusCallbacks(false)
68     , m_dumpTitleChanges(false)
69     , m_dumpIconChanges(false)
70     , m_dumpVisitedLinksCallback(false)
71     , m_dumpWillCacheResponse(false)
72     , m_generatePixelResults(true)
73     , m_callCloseOnWebViews(true)
74     , m_canOpenWindows(false)
75     , m_closeRemainingWindowsWhenComplete(true)
76     , m_newWindowsCopyBackForwardList(false)
77     , m_stopProvisionalFrameLoads(false)
78     , m_testOnscreen(false)
79     , m_testRepaint(false)
80     , m_testRepaintSweepHorizontally(false)
81     , m_waitToDump(false)
82     , m_willSendRequestReturnsNull(false)
83     , m_willSendRequestReturnsNullOnRedirect(false)
84     , m_windowIsKey(true)
85     , m_alwaysAcceptCookies(false)
86     , m_globalFlag(false)
87     , m_isGeolocationPermissionSet(false)
88     , m_geolocationPermission(false)
89     , m_handlesAuthenticationChallenges(false)
90     , m_isPrinting(false)
91     , m_deferMainResourceDataLoad(true)
92     , m_useDeferredFrameLoading(false)
93     , m_shouldPaintBrokenImage(true)
94     , m_shouldStayOnPageAfterHandlingBeforeUnload(false)
95     , m_areDesktopNotificationPermissionRequestsIgnored(false)
96     , m_customFullScreenBehavior(false) 
97     , m_testPathOrURL(testPathOrURL)
98     , m_expectedPixelHash(expectedPixelHash)
99 {
100 }
101
102 PassRefPtr<LayoutTestController> LayoutTestController::create(const std::string& testPathOrURL, const std::string& expectedPixelHash)
103 {
104     return adoptRef(new LayoutTestController(testPathOrURL, expectedPixelHash));
105 }
106
107 // Static Functions
108
109 static JSValueRef disallowIncreaseForApplicationCacheQuotaCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
110 {
111     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
112     controller->setDisallowIncreaseForApplicationCacheQuota(true);
113     return JSValueMakeUndefined(context);
114 }
115
116 static JSValueRef dumpApplicationCacheDelegateCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
117 {
118     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
119     controller->setDumpApplicationCacheDelegateCallbacks(true);
120     return JSValueMakeUndefined(context);
121 }
122
123 static JSValueRef dumpAsPDFCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
124 {
125     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
126     controller->setDumpAsPDF(true);
127     return JSValueMakeUndefined(context);
128 }
129
130 static JSValueRef dumpAsTextCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
131 {
132     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
133     controller->setDumpAsText(true);
134
135     // Optional paramater, describing whether it's allowed to dump pixel results in dumpAsText mode.
136     controller->setGeneratePixelResults(argumentCount > 0 ? JSValueToBoolean(context, arguments[0]) : false);
137
138     return JSValueMakeUndefined(context);
139 }
140
141 static JSValueRef dumpBackForwardListCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
142 {
143     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
144     controller->setDumpBackForwardList(true);
145     return JSValueMakeUndefined(context);
146 }
147
148 static JSValueRef dumpChildFramesAsTextCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
149 {
150     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
151     controller->setDumpChildFramesAsText(true);
152     return JSValueMakeUndefined(context);
153 }
154
155 static JSValueRef dumpChildFrameScrollPositionsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
156 {
157     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
158     controller->setDumpChildFrameScrollPositions(true);
159     return JSValueMakeUndefined(context);
160 }
161
162 static JSValueRef dumpConfigurationForViewportCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
163 {
164     if (argumentCount < 2)
165         return JSValueMakeUndefined(context);
166
167
168     double deviceDPI = JSValueToNumber(context, arguments[0], exception);
169     ASSERT(!*exception);
170     double deviceWidth = JSValueToNumber(context, arguments[1], exception);
171     ASSERT(!*exception);
172     double deviceHeight = JSValueToNumber(context, arguments[2], exception);
173     ASSERT(!*exception);
174     double availableWidth = JSValueToNumber(context, arguments[3], exception);
175     ASSERT(!*exception);
176     double availableHeight = JSValueToNumber(context, arguments[4], exception);
177     ASSERT(!*exception);
178
179     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
180     controller->dumpConfigurationForViewport(static_cast<int>(deviceDPI), static_cast<int>(deviceWidth), static_cast<int>(deviceHeight), static_cast<int>(availableWidth), static_cast<int>(availableHeight));
181
182     return JSValueMakeUndefined(context);
183 }
184
185 static JSValueRef dumpDatabaseCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
186 {
187     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
188     controller->setDumpDatabaseCallbacks(true);
189     return JSValueMakeUndefined(context);
190 }
191
192 static JSValueRef dumpDOMAsWebArchiveCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
193 {
194     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
195     controller->setDumpDOMAsWebArchive(true);
196     return JSValueMakeUndefined(context);
197 }
198
199 static JSValueRef dumpEditingCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
200 {
201     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
202     controller->setDumpEditingCallbacks(true);
203     return JSValueMakeUndefined(context);
204 }
205
206 static JSValueRef dumpFrameLoadCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
207 {
208     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
209     controller->setDumpFrameLoadCallbacks(true);
210     return JSValueMakeUndefined(context);
211 }
212
213 static JSValueRef dumpProgressFinishedCallbackCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
214 {
215     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
216     controller->setDumpProgressFinishedCallback(true);
217     return JSValueMakeUndefined(context);
218 }
219
220 static JSValueRef dumpUserGestureInFrameLoadCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
221 {
222     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
223     controller->setDumpUserGestureInFrameLoadCallbacks(true);
224     return JSValueMakeUndefined(context);
225 }
226
227 static JSValueRef dumpResourceLoadCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
228 {
229     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
230     controller->setDumpResourceLoadCallbacks(true);
231     return JSValueMakeUndefined(context);
232 }
233
234 static JSValueRef dumpResourceResponseMIMETypesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
235 {
236     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
237     controller->setDumpResourceResponseMIMETypes(true);
238     return JSValueMakeUndefined(context);
239 }
240
241 static JSValueRef dumpSelectionRectCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
242 {
243     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
244     controller->setDumpSelectionRect(true);
245     return JSValueMakeUndefined(context);
246 }
247
248 static JSValueRef dumpSourceAsWebArchiveCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
249 {
250     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
251     controller->setDumpSourceAsWebArchive(true);
252     return JSValueMakeUndefined(context);
253 }
254
255 static JSValueRef dumpStatusCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
256 {
257     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
258     controller->setDumpStatusCallbacks(true);
259     return JSValueMakeUndefined(context);
260 }
261
262 static JSValueRef dumpTitleChangesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
263 {
264     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
265     controller->setDumpTitleChanges(true);
266     return JSValueMakeUndefined(context);
267 }
268
269 static JSValueRef dumpIconChangesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
270 {
271     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
272     controller->setDumpIconChanges(true);
273     return JSValueMakeUndefined(context);
274 }
275
276 static JSValueRef dumpWillCacheResponseCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
277 {
278     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
279     controller->setDumpWillCacheResponse(true);
280     return JSValueMakeUndefined(context);
281 }
282
283 static JSValueRef pathToLocalResourceCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
284 {
285     if (argumentCount < 1)
286         return JSValueMakeUndefined(context);
287
288     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
289     JSRetainPtr<JSStringRef> localPath(Adopt, JSValueToStringCopy(context, arguments[0], exception));
290     ASSERT(!*exception);
291
292     JSRetainPtr<JSStringRef> convertedPath(Adopt, controller->pathToLocalResource(context, localPath.get()));
293     if (!convertedPath)
294         return JSValueMakeUndefined(context);
295
296     return JSValueMakeString(context, convertedPath.get());
297 }
298
299 static JSValueRef removeAllVisitedLinksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
300 {
301     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
302     controller->setDumpVisitedLinksCallback(true);
303     controller->removeAllVisitedLinks();
304     return JSValueMakeUndefined(context);
305 }
306
307 static JSValueRef repaintSweepHorizontallyCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
308 {
309     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
310     controller->setTestRepaintSweepHorizontally(true);
311     return JSValueMakeUndefined(context);
312 }
313
314 static JSValueRef setCallCloseOnWebViewsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
315 {
316     if (argumentCount < 1)
317         return JSValueMakeUndefined(context);
318
319     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
320     controller->setCallCloseOnWebViews(JSValueToBoolean(context, arguments[0]));
321     return JSValueMakeUndefined(context);
322 }
323
324 static JSValueRef setCanOpenWindowsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
325 {
326     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
327     controller->setCanOpenWindows(true);
328     return JSValueMakeUndefined(context);
329 }
330
331 static JSValueRef setCloseRemainingWindowsWhenCompleteCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
332 {
333     if (argumentCount < 1)
334         return JSValueMakeUndefined(context);
335
336     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
337     controller->setCloseRemainingWindowsWhenComplete(JSValueToBoolean(context, arguments[0]));
338     return JSValueMakeUndefined(context);
339 }
340
341 static JSValueRef setEncodedAudioDataCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
342 {
343     if (argumentCount < 1)
344         return JSValueMakeUndefined(context);
345
346     JSRetainPtr<JSStringRef> encodedAudioData(Adopt, JSValueToStringCopy(context, arguments[0], exception));
347     ASSERT(!*exception);
348     
349     size_t maxLength = JSStringGetMaximumUTF8CStringSize(encodedAudioData.get());
350     OwnArrayPtr<char> encodedAudioDataBuffer = adoptArrayPtr(new char[maxLength + 1]);
351     JSStringGetUTF8CString(encodedAudioData.get(), encodedAudioDataBuffer.get(), maxLength + 1);
352
353     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
354     controller->setEncodedAudioData(encodedAudioDataBuffer.get());
355     controller->setDumpAsAudio(true);
356     
357     return JSValueMakeUndefined(context);
358 }
359
360 static JSValueRef testOnscreenCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
361 {
362     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
363     controller->setTestOnscreen(true);
364     return JSValueMakeUndefined(context);
365 }
366
367 static JSValueRef testRepaintCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
368 {
369     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
370     controller->setTestRepaint(true);
371     return JSValueMakeUndefined(context);
372 }
373
374 static JSValueRef addDisallowedURLCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
375 {
376     // Has mac implementation
377     if (argumentCount < 1)
378         return JSValueMakeUndefined(context);
379
380     JSRetainPtr<JSStringRef> url(Adopt, JSValueToStringCopy(context, arguments[0], exception));
381     ASSERT(!*exception);
382
383     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
384     controller->addDisallowedURL(url.get());
385
386     return JSValueMakeUndefined(context);
387 }
388
389 static JSValueRef addURLToRedirectCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
390 {
391     if (argumentCount < 2)
392         return JSValueMakeUndefined(context);
393
394     JSRetainPtr<JSStringRef> origin(Adopt, JSValueToStringCopy(context, arguments[0], exception));
395     ASSERT(!*exception);
396
397     JSRetainPtr<JSStringRef> destination(Adopt, JSValueToStringCopy(context, arguments[1], exception));
398     ASSERT(!*exception);
399
400     size_t maxLength = JSStringGetMaximumUTF8CStringSize(origin.get());
401     OwnArrayPtr<char> originBuffer = adoptArrayPtr(new char[maxLength + 1]);
402     JSStringGetUTF8CString(origin.get(), originBuffer.get(), maxLength + 1);
403
404     maxLength = JSStringGetMaximumUTF8CStringSize(destination.get());
405     OwnArrayPtr<char> destinationBuffer = adoptArrayPtr(new char[maxLength + 1]);
406     JSStringGetUTF8CString(destination.get(), destinationBuffer.get(), maxLength + 1);
407
408     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
409     controller->addURLToRedirect(originBuffer.get(), destinationBuffer.get());
410
411     return JSValueMakeUndefined(context);
412 }
413
414 static JSValueRef callShouldCloseOnWebViewCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
415 {
416     // Has mac & windows implementation
417     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
418
419     return JSValueMakeBoolean(context, controller->callShouldCloseOnWebView());
420 }
421
422 static JSValueRef clearAllApplicationCachesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
423 {
424     // Has mac implementation
425     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
426     controller->clearAllApplicationCaches();
427
428     return JSValueMakeUndefined(context);
429 }
430
431 static JSValueRef clearApplicationCacheForOriginCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
432 {
433     if (argumentCount < 1)
434         return JSValueMakeUndefined(context);
435
436     JSRetainPtr<JSStringRef> originURL(Adopt, JSValueToStringCopy(context, arguments[0], exception));
437     ASSERT(!*exception);
438
439     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
440     controller->clearApplicationCacheForOrigin(originURL.get());
441     
442     return JSValueMakeUndefined(context);
443 }
444
445 static JSValueRef applicationCacheDiskUsageForOriginCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
446 {
447     if (argumentCount < 1)
448         return JSValueMakeUndefined(context);
449
450     JSRetainPtr<JSStringRef> originURL(Adopt, JSValueToStringCopy(context, arguments[0], exception));
451     ASSERT(!*exception);
452     
453     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
454
455     return JSValueMakeNumber(context, controller->applicationCacheDiskUsageForOrigin(originURL.get()));
456 }
457
458 static JSValueRef originsWithApplicationCacheCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
459 {
460     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
461     return controller->originsWithApplicationCache(context);
462 }
463
464 static JSValueRef clearAllDatabasesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
465 {
466     // Has mac & windows implementation
467     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
468     controller->clearAllDatabases();
469
470     return JSValueMakeUndefined(context);
471 }
472
473 static JSValueRef syncLocalStorageCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
474 {
475     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
476
477     controller->syncLocalStorage();
478
479     return JSValueMakeUndefined(context);
480 }
481
482 static JSValueRef observeStorageTrackerNotificationsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
483 {
484     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
485
486     if (argumentCount < 1)
487         return JSValueMakeUndefined(context);
488
489     unsigned numNotifications = JSValueToNumber(context, arguments[0], exception);
490
491     ASSERT(!*exception);
492
493     controller->observeStorageTrackerNotifications(numNotifications);
494
495     return JSValueMakeUndefined(context);
496 }
497
498 static JSValueRef deleteAllLocalStorageCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
499 {
500     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
501     controller->deleteAllLocalStorage();
502
503     return JSValueMakeUndefined(context);
504 }
505
506 static JSValueRef deleteLocalStorageForOriginCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
507 {
508     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
509
510     if (argumentCount < 1)
511         return JSValueMakeUndefined(context);
512
513     JSRetainPtr<JSStringRef> url(Adopt, JSValueToStringCopy(context, arguments[0], exception));
514     ASSERT(!*exception);
515
516     controller->deleteLocalStorageForOrigin(url.get());
517
518     return JSValueMakeUndefined(context);
519 }
520
521 static JSValueRef localStorageDiskUsageForOriginCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
522 {
523     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
524
525     if (argumentCount < 1)
526         return JSValueMakeUndefined(context);
527
528     JSRetainPtr<JSStringRef> originURL(Adopt, JSValueToStringCopy(context, arguments[0], exception));
529     ASSERT(!*exception);
530
531     return JSValueMakeNumber(context, controller->localStorageDiskUsageForOrigin(originURL.get()));
532 }
533
534 static JSValueRef originsWithLocalStorageCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
535 {
536     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
537     return controller->originsWithLocalStorage(context);
538 }
539
540 static JSValueRef clearBackForwardListCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
541 {
542     // Has mac & windows implementation
543     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
544     controller->clearBackForwardList();
545
546     return JSValueMakeUndefined(context);
547 }
548
549 static JSValueRef clearPersistentUserStyleSheetCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
550 {
551     // Has mac & windows implementation
552     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
553     controller->clearPersistentUserStyleSheet();
554
555     return JSValueMakeUndefined(context);
556 }
557
558 static JSValueRef decodeHostNameCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
559 {
560     // Has mac implementation
561     if (argumentCount < 1)
562         return JSValueMakeUndefined(context);
563
564     JSRetainPtr<JSStringRef> name(Adopt, JSValueToStringCopy(context, arguments[0], exception));
565     ASSERT(!*exception);
566
567     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
568     JSRetainPtr<JSStringRef> decodedHostName(Adopt, controller->copyDecodedHostName(name.get()));
569     return JSValueMakeString(context, decodedHostName.get());
570 }
571
572 static JSValueRef disableImageLoadingCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
573 {
574     // Has mac implementation, needs windows implementation
575     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
576     controller->disableImageLoading();
577     
578     return JSValueMakeUndefined(context);
579 }
580
581 static JSValueRef dispatchPendingLoadRequestsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
582 {
583     // Has mac implementation, needs windows implementation
584     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
585     controller->dispatchPendingLoadRequests();
586     
587     return JSValueMakeUndefined(context);
588 }
589
590 static JSValueRef displayCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
591 {
592     // Has mac & windows implementation
593     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
594     controller->display();
595
596     return JSValueMakeUndefined(context);
597 }
598
599 static JSValueRef displayInvalidatedRegionCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
600 {
601     // Has mac & windows implementation
602     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
603     // LayoutTestController::display() only renders the invalidated region so
604     // we can just use that.
605     controller->display();
606
607     return JSValueMakeUndefined(context);
608 }
609
610 static JSValueRef encodeHostNameCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
611 {
612     // Has mac implementation
613     if (argumentCount < 1)
614         return JSValueMakeUndefined(context);
615
616     JSRetainPtr<JSStringRef> name(Adopt, JSValueToStringCopy(context, arguments[0], exception));
617     ASSERT(!*exception);
618
619     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
620     JSRetainPtr<JSStringRef> encodedHostName(Adopt, controller->copyEncodedHostName(name.get()));
621     return JSValueMakeString(context, encodedHostName.get());
622 }
623
624 static JSValueRef execCommandCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
625 {
626     // Has Mac & Windows implementations.
627     if (argumentCount < 1)
628         return JSValueMakeUndefined(context);
629
630     JSRetainPtr<JSStringRef> name(Adopt, JSValueToStringCopy(context, arguments[0], exception));
631     ASSERT(!*exception);
632
633     // Ignoring the second parameter (userInterface), as this command emulates a manual action.
634
635     JSRetainPtr<JSStringRef> value;
636     if (argumentCount >= 3) {
637         value.adopt(JSValueToStringCopy(context, arguments[2], exception));
638         ASSERT(!*exception);
639     } else
640         value.adopt(JSStringCreateWithUTF8CString(""));
641
642
643     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
644     controller->execCommand(name.get(), value.get());
645
646     return JSValueMakeUndefined(context);
647 }
648
649 static JSValueRef findStringCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
650 {
651     // Has Mac implementation.
652     if (argumentCount < 2)
653         return JSValueMakeUndefined(context);
654
655     JSRetainPtr<JSStringRef> target(Adopt, JSValueToStringCopy(context, arguments[0], exception));
656     ASSERT(!*exception);
657
658     JSObjectRef options = JSValueToObject(context, arguments[1], exception);
659     ASSERT(!*exception);
660
661     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
662     return JSValueMakeBoolean(context, controller->findString(context, target.get(), options));
663 }
664
665 static JSValueRef counterValueForElementByIdCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
666 {
667     if (argumentCount < 1)
668         return JSValueMakeUndefined(context);
669
670     JSRetainPtr<JSStringRef> elementId(Adopt, JSValueToStringCopy(context, arguments[0], exception));
671     if (*exception)
672         return JSValueMakeUndefined(context);
673
674     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
675     JSRetainPtr<JSStringRef> counterValue(controller->counterValueForElementById(elementId.get()));
676     if (!counterValue.get())
677         return JSValueMakeUndefined(context);
678     return JSValueMakeString(context, counterValue.get());
679 }
680
681 static JSValueRef goBackCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
682 {
683     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
684     controller->goBack();
685     
686     return JSValueMakeUndefined(context);
687 }
688
689 static JSValueRef grantDesktopNotificationPermissionCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
690 {
691     // Has Windows implementation
692     if (argumentCount < 1)
693         return JSValueMakeUndefined(context);
694
695     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
696
697     controller->grantDesktopNotificationPermission(JSValueToStringCopy(context, arguments[0], NULL));
698         
699     return JSValueMakeUndefined(context);
700 }
701
702 static JSValueRef isCommandEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
703 {
704     // Has Mac implementation.
705
706     if (argumentCount < 1)
707         return JSValueMakeUndefined(context);
708
709     JSRetainPtr<JSStringRef> name(Adopt, JSValueToStringCopy(context, arguments[0], exception));
710     ASSERT(!*exception);
711
712     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
713
714     return JSValueMakeBoolean(context, controller->isCommandEnabled(name.get()));
715 }
716
717 static JSValueRef overridePreferenceCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
718 {
719     if (argumentCount < 2)
720         return JSValueMakeUndefined(context);
721
722     JSRetainPtr<JSStringRef> key(Adopt, JSValueToStringCopy(context, arguments[0], exception));
723     ASSERT(!*exception);
724     JSRetainPtr<JSStringRef> value(Adopt, JSValueToStringCopy(context, arguments[1], exception));
725     ASSERT(!*exception);
726
727     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
728     controller->overridePreference(key.get(), value.get());
729
730     return JSValueMakeUndefined(context);
731 }
732
733 static JSValueRef keepWebHistoryCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
734 {
735     // Has mac implementation
736     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
737     controller->keepWebHistory();
738
739     return JSValueMakeUndefined(context);
740 }
741
742 static JSValueRef computedStyleIncludingVisitedInfoCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
743 {
744     if (argumentCount != 1)
745         return JSValueMakeUndefined(context);
746     
747     // Has mac implementation
748     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
749     return controller->computedStyleIncludingVisitedInfo(context, arguments[0]);
750 }
751
752 static JSValueRef layerTreeAsTextCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
753 {
754     // Has mac & windows implementation
755     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
756     return JSValueMakeString(context, controller->layerTreeAsText().get());
757 }
758
759 static JSValueRef notifyDoneCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
760 {
761     // Has mac & windows implementation
762     // May be able to be made platform independant by using shared WorkQueue
763     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
764     controller->notifyDone();
765     return JSValueMakeUndefined(context);
766 }
767
768 static bool parsePageParameters(JSContextRef context, int argumentCount, const JSValueRef* arguments, JSValueRef* exception, float& pageWidthInPixels, float& pageHeightInPixels)
769 {
770     pageWidthInPixels = LayoutTestController::maxViewWidth;
771     pageHeightInPixels = LayoutTestController::maxViewHeight;
772     switch (argumentCount) {
773     case 2:
774         pageWidthInPixels = static_cast<float>(JSValueToNumber(context, arguments[0], exception));
775         if (*exception)
776             return false;
777         pageHeightInPixels = static_cast<float>(JSValueToNumber(context, arguments[1], exception));
778         if (*exception)
779             return false;
780     case 0: // Fall through.
781         break;
782     default:
783         return false;
784     }
785     return true;
786 }
787
788 // Caller needs to delete[] propertyName.
789 static bool parsePagePropertyParameters(JSContextRef context, int argumentCount, const JSValueRef* arguments, JSValueRef* exception, char*& propertyName, int& pageNumber)
790 {
791     pageNumber = 0;
792     switch (argumentCount) {
793     case 2:
794         pageNumber = static_cast<float>(JSValueToNumber(context, arguments[1], exception));
795         if (*exception)
796             return false;
797         // Fall through.
798     case 1: {
799         JSRetainPtr<JSStringRef> propertyNameString(Adopt, JSValueToStringCopy(context, arguments[0], exception));
800         if (*exception)
801             return false;
802
803         size_t maxLength = JSStringGetMaximumUTF8CStringSize(propertyNameString.get());
804         propertyName = new char[maxLength + 1];
805         JSStringGetUTF8CString(propertyNameString.get(), propertyName, maxLength + 1);
806         return true;
807     }
808     case 0:
809     default:
810         return false;
811     }
812 }
813
814 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)
815 {
816     pageNumber = 0;
817     width = height = 0;
818     marginTop = marginRight = marginBottom = marginLeft = 0;
819
820     switch (argumentCount) {
821     case 7:
822         marginLeft = static_cast<int>(JSValueToNumber(context, arguments[6], exception));
823         if (*exception)
824             return false;
825         // Fall through.
826     case 6:
827         marginBottom = static_cast<int>(JSValueToNumber(context, arguments[5], exception));
828         if (*exception)
829             return false;
830         // Fall through.
831     case 5:
832         marginRight = static_cast<int>(JSValueToNumber(context, arguments[4], exception));
833         if (*exception)
834             return false;
835         // Fall through.
836     case 4:
837         marginTop = static_cast<int>(JSValueToNumber(context, arguments[3], exception));
838         if (*exception)
839             return false;
840         // Fall through.
841     case 3:
842         height = static_cast<int>(JSValueToNumber(context, arguments[2], exception));
843         if (*exception)
844             return false;
845         // Fall through.
846     case 2:
847         width = static_cast<int>(JSValueToNumber(context, arguments[1], exception));
848         if (*exception)
849             return false;
850         // Fall through.
851     case 1:
852         pageNumber = static_cast<int>(JSValueToNumber(context, arguments[0], exception));
853         if (*exception)
854             return false;
855         // Fall through.
856         return true;
857     default:
858         return false;
859     }
860 }
861
862 static JSValueRef pageNumberForElementByIdCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
863 {
864     float pageWidthInPixels = 0;
865     float pageHeightInPixels = 0;
866     if (!parsePageParameters(context, argumentCount - 1, arguments + 1, exception, pageWidthInPixels, pageHeightInPixels))
867         return JSValueMakeUndefined(context);
868
869     JSRetainPtr<JSStringRef> elementId(Adopt, JSValueToStringCopy(context, arguments[0], exception));
870     if (*exception)
871         return JSValueMakeUndefined(context);
872
873     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
874     int pageNumber = controller->pageNumberForElementById(elementId.get(), pageWidthInPixels, pageHeightInPixels);
875     return JSValueMakeNumber(context, pageNumber);
876 }
877
878 static JSValueRef numberOfPagesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
879 {
880     float pageWidthInPixels = 0;
881     float pageHeightInPixels = 0;
882     if (!parsePageParameters(context, argumentCount, arguments, exception, pageWidthInPixels, pageHeightInPixels))
883         return JSValueMakeUndefined(context);
884
885     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
886     return JSValueMakeNumber(context, controller->numberOfPages(pageWidthInPixels, pageHeightInPixels));
887 }
888
889 static JSValueRef numberOfPendingGeolocationPermissionRequestsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
890 {
891     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
892     return JSValueMakeNumber(context, controller->numberOfPendingGeolocationPermissionRequests());
893 }
894
895 static JSValueRef pagePropertyCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
896 {
897     char* propertyName = 0;
898     int pageNumber = 0;
899     if (!parsePagePropertyParameters(context, argumentCount, arguments, exception, propertyName, pageNumber))
900         return JSValueMakeUndefined(context);
901
902     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
903     JSValueRef value = JSValueMakeString(context, controller->pageProperty(propertyName, pageNumber).get());
904
905     delete[] propertyName;
906     return value;
907 }
908
909 static JSValueRef pageSizeAndMarginsInPixelsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
910 {
911     int pageNumber = 0;
912     int width = 0, height = 0;
913     int marginTop = 0, marginRight = 0, marginBottom = 0, marginLeft = 0;
914     if (!parsePageNumberSizeMarings(context, argumentCount, arguments, exception, pageNumber, width, height, marginTop, marginRight, marginBottom, marginLeft))
915         return JSValueMakeUndefined(context);
916
917     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
918     return JSValueMakeString(context, controller->pageSizeAndMarginsInPixels(pageNumber, width, height, marginTop, marginRight, marginBottom, marginLeft).get());
919 }
920
921 static JSValueRef queueBackNavigationCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
922 {
923     // Has mac & windows implementation
924     // May be able to be made platform independant by using shared WorkQueue
925     if (argumentCount < 1)
926         return JSValueMakeUndefined(context);
927
928     double howFarBackDouble = JSValueToNumber(context, arguments[0], exception);
929     ASSERT(!*exception);
930
931     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
932     controller->queueBackNavigation(static_cast<int>(howFarBackDouble));
933
934     return JSValueMakeUndefined(context);
935 }
936
937 static JSValueRef queueForwardNavigationCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
938 {
939     // Has mac & windows implementation
940     // May be able to be made platform independant by using shared WorkQueue
941     if (argumentCount < 1)
942         return JSValueMakeUndefined(context);
943
944     double howFarForwardDouble = JSValueToNumber(context, arguments[0], exception);
945     ASSERT(!*exception);
946
947     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
948     controller->queueForwardNavigation(static_cast<int>(howFarForwardDouble));
949
950     return JSValueMakeUndefined(context);
951 }
952
953 static JSValueRef queueLoadCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
954 {
955     // Has mac & windows implementation
956     // May be able to be made platform independant by using shared WorkQueue
957     if (argumentCount < 1)
958         return JSValueMakeUndefined(context);
959
960     JSRetainPtr<JSStringRef> url(Adopt, JSValueToStringCopy(context, arguments[0], exception));
961     ASSERT(!*exception);
962
963     JSRetainPtr<JSStringRef> target;
964     if (argumentCount >= 2) {
965         target.adopt(JSValueToStringCopy(context, arguments[1], exception));
966         ASSERT(!*exception);
967     } else
968         target.adopt(JSStringCreateWithUTF8CString(""));
969
970     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
971     controller->queueLoad(url.get(), target.get());
972
973     return JSValueMakeUndefined(context);
974 }
975
976 static JSValueRef queueLoadHTMLStringCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
977 {
978     // Has Mac & Windows implementation
979     if (argumentCount < 1)
980         return JSValueMakeUndefined(context);
981
982     JSRetainPtr<JSStringRef> content(Adopt, JSValueToStringCopy(context, arguments[0], exception));
983     ASSERT(!*exception);
984
985     JSRetainPtr<JSStringRef> baseURL;
986     if (argumentCount >= 2) {
987         baseURL.adopt(JSValueToStringCopy(context, arguments[1], exception));
988         ASSERT(!*exception);
989     } else
990         baseURL.adopt(JSStringCreateWithUTF8CString(""));
991
992     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
993
994     if (argumentCount >= 3) {
995         JSRetainPtr<JSStringRef> unreachableURL;
996         unreachableURL.adopt(JSValueToStringCopy(context, arguments[2], exception));
997         ASSERT(!*exception);
998         controller->queueLoadAlternateHTMLString(content.get(), baseURL.get(), unreachableURL.get());
999         return JSValueMakeUndefined(context);
1000     }
1001
1002     controller->queueLoadHTMLString(content.get(), baseURL.get());
1003     return JSValueMakeUndefined(context);
1004 }
1005
1006 static JSValueRef queueReloadCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1007 {
1008     // Has mac & windows implementation
1009     // May be able to be made platform independant by using shared WorkQueue
1010
1011     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1012     controller->queueReload();
1013
1014     return JSValueMakeUndefined(context);
1015 }
1016
1017 static JSValueRef queueLoadingScriptCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1018 {
1019     // Has mac & windows implementation
1020     // May be able to be made platform independant by using shared WorkQueue
1021     if (argumentCount < 1)
1022         return JSValueMakeUndefined(context);
1023
1024     JSRetainPtr<JSStringRef> script(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1025     ASSERT(!*exception);
1026
1027     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1028     controller->queueLoadingScript(script.get());
1029
1030     return JSValueMakeUndefined(context);
1031 }
1032
1033 static JSValueRef queueNonLoadingScriptCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1034 {
1035     // Has mac & windows implementation
1036     // May be able to be made platform independant by using shared WorkQueue
1037     if (argumentCount < 1)
1038         return JSValueMakeUndefined(context);
1039
1040     JSRetainPtr<JSStringRef> script(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1041     ASSERT(!*exception);
1042
1043     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1044     controller->queueNonLoadingScript(script.get());
1045
1046     return JSValueMakeUndefined(context);
1047 }
1048
1049 static JSValueRef setAcceptsEditingCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1050 {
1051     // Has mac & windows implementation
1052     if (argumentCount < 1)
1053         return JSValueMakeUndefined(context);
1054
1055     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1056     controller->setAcceptsEditing(JSValueToBoolean(context, arguments[0]));
1057
1058     return JSValueMakeUndefined(context);
1059 }
1060
1061 static JSValueRef setAlwaysAcceptCookiesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1062 {
1063     // Has mac & windows implementation
1064     if (argumentCount < 1)
1065         return JSValueMakeUndefined(context);
1066
1067     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1068     controller->setAlwaysAcceptCookies(JSValueToBoolean(context, arguments[0]));
1069
1070     return JSValueMakeUndefined(context);
1071 }
1072
1073 static JSValueRef setAppCacheMaximumSizeCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1074 {
1075     // Has mac implementation
1076     if (argumentCount < 1)
1077         return JSValueMakeUndefined(context);
1078
1079     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1080
1081     double size = JSValueToNumber(context, arguments[0], NULL);
1082     if (!isnan(size))
1083         controller->setAppCacheMaximumSize(static_cast<unsigned long long>(size));
1084         
1085     return JSValueMakeUndefined(context);
1086 }
1087
1088 static JSValueRef setApplicationCacheOriginQuotaCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1089 {
1090     // Has mac implementation
1091     if (argumentCount < 1)
1092         return JSValueMakeUndefined(context);
1093
1094     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1095
1096     double size = JSValueToNumber(context, arguments[0], NULL);
1097     if (!isnan(size))
1098         controller->setApplicationCacheOriginQuota(static_cast<unsigned long long>(size));
1099
1100     return JSValueMakeUndefined(context);
1101 }
1102
1103 static JSValueRef setAuthenticationPasswordCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1104 {
1105     // Has mac & windows implementation
1106     if (argumentCount < 1)
1107         return JSValueMakeUndefined(context);
1108
1109     JSRetainPtr<JSStringRef> password(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1110     ASSERT(!*exception);
1111
1112     size_t maxLength = JSStringGetMaximumUTF8CStringSize(password.get());
1113     char* passwordBuffer = new char[maxLength + 1];
1114     JSStringGetUTF8CString(password.get(), passwordBuffer, maxLength + 1);
1115     
1116     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1117     controller->setAuthenticationPassword(passwordBuffer);
1118     delete[] passwordBuffer;
1119
1120     return JSValueMakeUndefined(context);
1121 }
1122
1123 static JSValueRef setAuthenticationUsernameCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1124 {
1125     // Has mac & windows implementation
1126     if (argumentCount < 1)
1127         return JSValueMakeUndefined(context);
1128
1129     JSRetainPtr<JSStringRef> username(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1130     ASSERT(!*exception);
1131
1132     size_t maxLength = JSStringGetMaximumUTF8CStringSize(username.get());
1133     char* usernameBuffer = new char[maxLength + 1];
1134     JSStringGetUTF8CString(username.get(), usernameBuffer, maxLength + 1);
1135     
1136     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1137     controller->setAuthenticationUsername(usernameBuffer);
1138     delete[] usernameBuffer;
1139
1140     return JSValueMakeUndefined(context);
1141 }
1142
1143 static JSValueRef setAuthorAndUserStylesEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1144 {
1145     // Has mac & windows implementation
1146     if (argumentCount < 1)
1147         return JSValueMakeUndefined(context);
1148
1149     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1150     controller->setAuthorAndUserStylesEnabled(JSValueToBoolean(context, arguments[0]));
1151
1152     return JSValueMakeUndefined(context);
1153 }
1154
1155 static JSValueRef setAutofilledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1156 {
1157     if (argumentCount != 2 || !arguments[0])
1158         return JSValueMakeUndefined(context);
1159
1160     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1161     controller->setAutofilled(context, arguments[0], JSValueToBoolean(context, arguments[1]));
1162
1163     return JSValueMakeUndefined(context);
1164 }
1165
1166 static JSValueRef setCacheModelCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1167 {
1168     // Has Mac implementation.
1169     if (argumentCount < 1)
1170         return JSValueMakeUndefined(context);
1171
1172     int cacheModel = JSValueToNumber(context, arguments[0], exception);
1173     ASSERT(!*exception);
1174
1175     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1176     controller->setCacheModel(cacheModel);
1177
1178     return JSValueMakeUndefined(context);
1179 }
1180
1181 static JSValueRef setCustomPolicyDelegateCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1182 {
1183     // Has mac implementation
1184     if (argumentCount < 1)
1185         return JSValueMakeUndefined(context);
1186     
1187     bool permissive = false;
1188     if (argumentCount >= 2)
1189         permissive = JSValueToBoolean(context, arguments[1]);
1190
1191     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1192     controller->setCustomPolicyDelegate(JSValueToBoolean(context, arguments[0]), permissive);
1193
1194     return JSValueMakeUndefined(context);
1195 }
1196
1197 static JSValueRef setDatabaseQuotaCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1198 {
1199     // Has mac implementation
1200     if (argumentCount < 1)
1201         return JSValueMakeUndefined(context);
1202
1203     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1204
1205     double quota = JSValueToNumber(context, arguments[0], NULL);
1206     if (!isnan(quota))
1207         controller->setDatabaseQuota(static_cast<unsigned long long>(quota));
1208         
1209     return JSValueMakeUndefined(context);
1210 }
1211
1212 static JSValueRef setDeferMainResourceDataLoadCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1213 {
1214     // Has Mac and Windows implementation
1215     if (argumentCount < 1)
1216         return JSValueMakeUndefined(context);
1217
1218     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1219     controller->setDeferMainResourceDataLoad(JSValueToBoolean(context, arguments[0]));
1220
1221     return JSValueMakeUndefined(context);
1222 }
1223
1224 static JSValueRef setDefersLoadingCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1225 {
1226     if (argumentCount < 1)
1227         return JSValueMakeUndefined(context);
1228
1229     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1230     controller->setDefersLoading(JSValueToBoolean(context, arguments[0]));
1231
1232     return JSValueMakeUndefined(context);
1233 }
1234
1235 static JSValueRef setUseDeferredFrameLoadingCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1236 {
1237     if (argumentCount < 1)
1238         return JSValueMakeUndefined(context);
1239
1240     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1241     controller->setUseDeferredFrameLoading(JSValueToBoolean(context, arguments[0]));
1242
1243     return JSValueMakeUndefined(context);
1244 }
1245
1246 static JSValueRef setDomainRelaxationForbiddenForURLSchemeCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1247 {
1248     // Has Mac and Windows implementation
1249     if (argumentCount < 2)
1250         return JSValueMakeUndefined(context);
1251
1252     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1253
1254     bool forbidden = JSValueToBoolean(context, arguments[0]);
1255     JSRetainPtr<JSStringRef> scheme(Adopt, JSValueToStringCopy(context, arguments[1], 0));
1256     controller->setDomainRelaxationForbiddenForURLScheme(forbidden, scheme.get());
1257
1258     return JSValueMakeUndefined(context);
1259 }
1260
1261 static JSValueRef setMockDeviceOrientationCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1262 {
1263     if (argumentCount < 6)
1264         return JSValueMakeUndefined(context);
1265
1266     bool canProvideAlpha = JSValueToBoolean(context, arguments[0]);
1267     double alpha = JSValueToNumber(context, arguments[1], exception);
1268     ASSERT(!*exception);
1269     bool canProvideBeta = JSValueToBoolean(context, arguments[2]);
1270     double beta = JSValueToNumber(context, arguments[3], exception);
1271     ASSERT(!*exception);
1272     bool canProvideGamma = JSValueToBoolean(context, arguments[4]);
1273     double gamma = JSValueToNumber(context, arguments[5], exception);
1274     ASSERT(!*exception);
1275
1276     LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1277     controller->setMockDeviceOrientation(canProvideAlpha, alpha, canProvideBeta, beta, canProvideGamma, gamma);
1278
1279     return JSValueMakeUndefined(context);
1280 }
1281
1282 static JSValueRef setMockGeolocationPositionCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1283 {
1284     if (argumentCount < 3)
1285         return JSValueMakeUndefined(context);
1286
1287     LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1288     controller->setMockGeolocationPosition(JSValueToNumber(context, arguments[0], NULL),  // latitude
1289                                            JSValueToNumber(context, arguments[1], NULL),  // longitude
1290                                            JSValueToNumber(context, arguments[2], NULL));  // accuracy
1291
1292     return JSValueMakeUndefined(context);
1293 }
1294
1295 static JSValueRef setMockGeolocationErrorCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1296 {
1297     if (argumentCount < 2)
1298         return JSValueMakeUndefined(context);
1299
1300     int code = JSValueToNumber(context, arguments[0], NULL);
1301     JSRetainPtr<JSStringRef> message(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1302     ASSERT(!*exception);
1303
1304     LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1305     controller->setMockGeolocationError(code, message.get());
1306
1307     return JSValueMakeUndefined(context);
1308 }
1309
1310 static JSValueRef addMockSpeechInputResultCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1311 {
1312     if (argumentCount < 3)
1313         return JSValueMakeUndefined(context);
1314
1315     JSRetainPtr<JSStringRef> result(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1316     ASSERT(!*exception);
1317
1318     double confidence = JSValueToNumber(context, arguments[1], exception);
1319
1320     JSRetainPtr<JSStringRef> language(Adopt, JSValueToStringCopy(context, arguments[2], exception));
1321     ASSERT(!*exception);
1322
1323     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1324     controller->addMockSpeechInputResult(result.get(), confidence, language.get());
1325
1326     return JSValueMakeUndefined(context);
1327 }
1328
1329 static JSValueRef setMockSpeechInputDumpRectCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1330 {
1331     if (argumentCount < 1)
1332         return JSValueMakeUndefined(context);
1333
1334     bool dumpRect = JSValueToBoolean(context, arguments[0]);
1335
1336     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1337     controller->setMockSpeechInputDumpRect(dumpRect);
1338
1339     return JSValueMakeUndefined(context);
1340 }
1341
1342 static JSValueRef setNewWindowsCopyBackForwardListCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1343 {
1344     // Has mac implementation
1345     if (argumentCount < 1)
1346         return JSValueMakeUndefined(context);
1347     
1348     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1349     controller->setNewWindowsCopyBackForwardList(JSValueToBoolean(context, arguments[0]));
1350
1351     return JSValueMakeUndefined(context);
1352 }
1353
1354 static JSValueRef setGeolocationPermissionCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1355 {
1356     // Has mac implementation
1357     if (argumentCount < 1)
1358         return JSValueMakeUndefined(context);
1359
1360     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1361     controller->setGeolocationPermission(JSValueToBoolean(context, arguments[0]));
1362
1363     return JSValueMakeUndefined(context);
1364 }
1365
1366 static JSValueRef setHandlesAuthenticationChallengesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1367 {
1368     // Has mac & windows implementation
1369     if (argumentCount < 1)
1370         return JSValueMakeUndefined(context);
1371
1372     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1373     controller->setHandlesAuthenticationChallenges(JSValueToBoolean(context, arguments[0]));
1374
1375     return JSValueMakeUndefined(context);
1376 }
1377
1378 static JSValueRef setPOSIXLocaleCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1379 {
1380     if (argumentCount < 1)
1381         return JSValueMakeUndefined(context);
1382
1383     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1384     JSRetainPtr<JSStringRef> locale(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1385     ASSERT(!*exception);
1386     controller->setPOSIXLocale(locale.get());
1387
1388     return JSValueMakeUndefined(context);
1389 }
1390
1391 static JSValueRef setIconDatabaseEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1392 {
1393     // Has mac & windows implementation
1394     if (argumentCount < 1)
1395         return JSValueMakeUndefined(context);
1396
1397     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1398     controller->setIconDatabaseEnabled(JSValueToBoolean(context, arguments[0]));
1399
1400     return JSValueMakeUndefined(context);
1401 }
1402
1403 static JSValueRef setMainFrameIsFirstResponderCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1404 {
1405     // Has mac implementation
1406     if (argumentCount < 1)
1407         return JSValueMakeUndefined(context);
1408
1409     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1410     controller->setMainFrameIsFirstResponder(JSValueToBoolean(context, arguments[0]));
1411
1412     return JSValueMakeUndefined(context);
1413 }
1414
1415 static JSValueRef setPersistentUserStyleSheetLocationCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1416 {
1417     // Has mac implementation
1418     if (argumentCount < 1)
1419         return JSValueMakeUndefined(context);
1420
1421     JSRetainPtr<JSStringRef> path(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1422     ASSERT(!*exception);
1423
1424     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1425     controller->setPersistentUserStyleSheetLocation(path.get());
1426
1427     return JSValueMakeUndefined(context);
1428 }
1429
1430 static JSValueRef setPrivateBrowsingEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1431 {
1432     // Has mac & windows implementation
1433     if (argumentCount < 1)
1434         return JSValueMakeUndefined(context);
1435
1436     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1437     controller->setPrivateBrowsingEnabled(JSValueToBoolean(context, arguments[0]));
1438
1439     return JSValueMakeUndefined(context);
1440 }
1441
1442 static JSValueRef setJavaScriptCanAccessClipboardCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1443 {
1444     // Has mac & windows implementation
1445     if (argumentCount < 1)
1446         return JSValueMakeUndefined(context);
1447
1448     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1449     controller->setJavaScriptCanAccessClipboard(JSValueToBoolean(context, arguments[0]));
1450
1451     return JSValueMakeUndefined(context);
1452 }
1453
1454 static JSValueRef setXSSAuditorEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1455 {
1456     // Has mac & windows implementation
1457     if (argumentCount < 1)
1458         return JSValueMakeUndefined(context);
1459
1460     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1461     controller->setXSSAuditorEnabled(JSValueToBoolean(context, arguments[0]));
1462
1463     return JSValueMakeUndefined(context);
1464 }
1465
1466 static JSValueRef setSpatialNavigationEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1467 {
1468     // Has mac implementation.
1469     if (argumentCount < 1)
1470         return JSValueMakeUndefined(context);
1471
1472     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1473     controller->setSpatialNavigationEnabled(JSValueToBoolean(context, arguments[0]));
1474
1475     return JSValueMakeUndefined(context);
1476 }
1477
1478 static JSValueRef setPrintingCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1479 {
1480     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1481     controller->setIsPrinting(true);
1482     return JSValueMakeUndefined(context);
1483 }
1484
1485
1486 static JSValueRef setFrameFlatteningEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1487 {
1488     // Has mac & windows implementation
1489     if (argumentCount < 1)
1490         return JSValueMakeUndefined(context);
1491
1492     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1493     controller->setFrameFlatteningEnabled(JSValueToBoolean(context, arguments[0]));
1494
1495     return JSValueMakeUndefined(context);
1496 }
1497
1498 static JSValueRef setAllowUniversalAccessFromFileURLsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1499 {
1500     // Has mac & windows implementation
1501     if (argumentCount < 1)
1502         return JSValueMakeUndefined(context);
1503
1504     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1505     controller->setAllowUniversalAccessFromFileURLs(JSValueToBoolean(context, arguments[0]));
1506
1507     return JSValueMakeUndefined(context);
1508 }
1509
1510 static JSValueRef setAllowFileAccessFromFileURLsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1511 {
1512     // Has mac & windows implementation
1513     if (argumentCount < 1)
1514         return JSValueMakeUndefined(context);
1515
1516     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1517     controller->setAllowFileAccessFromFileURLs(JSValueToBoolean(context, arguments[0]));
1518
1519     return JSValueMakeUndefined(context);
1520 }
1521
1522 static JSValueRef setTabKeyCyclesThroughElementsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1523 {
1524     // Has mac & windows implementation
1525     if (argumentCount < 1)
1526         return JSValueMakeUndefined(context);
1527
1528     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1529     controller->setTabKeyCyclesThroughElements(JSValueToBoolean(context, arguments[0]));
1530
1531     return JSValueMakeUndefined(context);
1532 }
1533
1534 static JSValueRef setUseDashboardCompatibilityModeCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1535 {
1536     // Has mac implementation
1537     if (argumentCount < 1)
1538         return JSValueMakeUndefined(context);
1539
1540     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1541     controller->setUseDashboardCompatibilityMode(JSValueToBoolean(context, arguments[0]));
1542
1543     return JSValueMakeUndefined(context);
1544 }
1545
1546 static JSValueRef setUserStyleSheetEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1547 {
1548     // Has mac implementation
1549     if (argumentCount < 1)
1550         return JSValueMakeUndefined(context);
1551
1552     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1553     controller->setUserStyleSheetEnabled(JSValueToBoolean(context, arguments[0]));
1554
1555     return JSValueMakeUndefined(context);
1556 }
1557
1558 static JSValueRef setUserStyleSheetLocationCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1559 {
1560     // Has mac implementation
1561     if (argumentCount < 1)
1562         return JSValueMakeUndefined(context);
1563
1564     JSRetainPtr<JSStringRef> path(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1565     ASSERT(!*exception);
1566
1567     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1568     controller->setUserStyleSheetLocation(path.get());
1569
1570     return JSValueMakeUndefined(context);
1571 }
1572
1573 static JSValueRef setValueForUserCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1574 {
1575     // Has mac implementation
1576     if (argumentCount != 2)
1577         return JSValueMakeUndefined(context);
1578
1579     JSRetainPtr<JSStringRef> value(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1580     ASSERT(!*exception);
1581
1582     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1583     controller->setValueForUser(context, arguments[0], value.get());
1584
1585     return JSValueMakeUndefined(context);
1586 }
1587
1588 static JSValueRef setViewModeMediaFeatureCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1589 {
1590     // Has mac implementation
1591     if (argumentCount < 1)
1592         return JSValueMakeUndefined(context);
1593
1594     JSRetainPtr<JSStringRef> mode(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1595     ASSERT(!*exception);
1596
1597     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1598     controller->setViewModeMediaFeature(mode.get());
1599
1600     return JSValueMakeUndefined(context);
1601 }
1602
1603 static JSValueRef setWillSendRequestClearHeaderCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1604 {
1605     // Has mac & windows implementation
1606     if (argumentCount < 1)
1607         return JSValueMakeUndefined(context);
1608
1609     JSRetainPtr<JSStringRef> header(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1610     ASSERT(!*exception);
1611
1612     size_t maxLength = JSStringGetMaximumUTF8CStringSize(header.get());
1613     OwnArrayPtr<char> headerBuffer = adoptArrayPtr(new char[maxLength + 1]);
1614     JSStringGetUTF8CString(header.get(), headerBuffer.get(), maxLength + 1);
1615
1616     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1617     controller->setWillSendRequestClearHeader(headerBuffer.get());
1618
1619     return JSValueMakeUndefined(context);
1620 }
1621
1622 static JSValueRef setWillSendRequestReturnsNullCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1623 {
1624     // Has cross-platform implementation
1625     if (argumentCount < 1)
1626         return JSValueMakeUndefined(context);
1627
1628     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1629     controller->setWillSendRequestReturnsNull(JSValueToBoolean(context, arguments[0]));
1630
1631     return JSValueMakeUndefined(context);
1632 }
1633
1634 static JSValueRef setWillSendRequestReturnsNullOnRedirectCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1635 {
1636     // Has cross-platform implementation
1637     if (argumentCount < 1)
1638         return JSValueMakeUndefined(context);
1639
1640     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1641     controller->setWillSendRequestReturnsNullOnRedirect(JSValueToBoolean(context, arguments[0]));
1642
1643     return JSValueMakeUndefined(context);
1644 }
1645
1646 static JSValueRef setWindowIsKeyCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1647 {
1648     // Has mac implementation
1649     if (argumentCount < 1)
1650         return JSValueMakeUndefined(context);
1651
1652     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1653     controller->setWindowIsKey(JSValueToBoolean(context, arguments[0]));
1654
1655     return JSValueMakeUndefined(context);
1656 }
1657
1658 static JSValueRef waitUntilDoneCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1659 {
1660     // Has mac & windows implementation
1661     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1662     controller->setWaitToDump(true);
1663
1664     return JSValueMakeUndefined(context);
1665 }
1666
1667 static JSValueRef windowCountCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1668 {
1669     // Has mac implementation
1670     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1671     int windows = controller->windowCount();
1672     return JSValueMakeNumber(context, windows);
1673 }
1674
1675 static JSValueRef setPopupBlockingEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1676 {
1677     // Has mac & windows implementation
1678     if (argumentCount < 1)
1679         return JSValueMakeUndefined(context);
1680
1681     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1682     controller->setPopupBlockingEnabled(JSValueToBoolean(context, arguments[0]));
1683
1684     return JSValueMakeUndefined(context);
1685 }
1686
1687 static JSValueRef setPluginsEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1688 {
1689     // Has mac & windows implementation
1690     if (argumentCount < 1)
1691         return JSValueMakeUndefined(context);
1692     
1693     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1694     controller->setPluginsEnabled(JSValueToBoolean(context, arguments[0]));
1695     
1696     return JSValueMakeUndefined(context);
1697 }    
1698
1699 static JSValueRef setPageVisibilityCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1700 {
1701     // Has mac & windows implementation
1702     if (argumentCount < 1)
1703         return JSValueMakeUndefined(context);
1704
1705     JSRetainPtr<JSStringRef> visibility(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1706     ASSERT(!*exception);
1707
1708     size_t maxLength = JSStringGetMaximumUTF8CStringSize(visibility.get());
1709     char* visibilityBuffer = new char[maxLength + 1];
1710     JSStringGetUTF8CString(visibility.get(), visibilityBuffer, maxLength + 1);
1711     
1712     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1713     controller->setPageVisibility(visibilityBuffer);
1714     delete[] visibilityBuffer;
1715     
1716     return JSValueMakeUndefined(context);
1717 }    
1718
1719 static JSValueRef resetPageVisibilityCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1720 {
1721     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1722     controller->resetPageVisibility();
1723     return JSValueMakeUndefined(context);
1724 }    
1725
1726 static JSValueRef setSmartInsertDeleteEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1727 {
1728     if (argumentCount < 1)
1729         return JSValueMakeUndefined(context);
1730
1731     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1732     controller->setSmartInsertDeleteEnabled(JSValueToBoolean(context, arguments[0]));
1733     return JSValueMakeUndefined(context);
1734 }
1735
1736 static JSValueRef setAutomaticLinkDetectionEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1737 {
1738     if (argumentCount < 1)
1739         return JSValueMakeUndefined(context);
1740
1741     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1742     controller->setAutomaticLinkDetectionEnabled(JSValueToBoolean(context, arguments[0]));
1743     return JSValueMakeUndefined(context);
1744 }
1745
1746 static JSValueRef setSelectTrailingWhitespaceEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1747 {
1748     if (argumentCount < 1)
1749         return JSValueMakeUndefined(context);
1750
1751     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1752     controller->setSelectTrailingWhitespaceEnabled(JSValueToBoolean(context, arguments[0]));
1753     return JSValueMakeUndefined(context);
1754 }
1755
1756 static JSValueRef setStopProvisionalFrameLoadsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1757 {
1758     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1759     controller->setStopProvisionalFrameLoads(true);
1760     return JSValueMakeUndefined(context);
1761 }
1762
1763 static JSValueRef setAsynchronousSpellCheckingEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1764 {
1765     if (argumentCount < 1)
1766         return JSValueMakeUndefined(context);
1767
1768     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1769     controller->setAsynchronousSpellCheckingEnabled(JSValueToBoolean(context, arguments[0]));
1770     return JSValueMakeUndefined(context);
1771 }
1772
1773 static JSValueRef showWebInspectorCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1774 {
1775     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1776     controller->showWebInspector();
1777     return JSValueMakeUndefined(context);
1778 }
1779
1780 static JSValueRef closeWebInspectorCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1781 {
1782     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1783     controller->closeWebInspector();
1784     return JSValueMakeUndefined(context);
1785 }
1786
1787 static JSValueRef evaluateInWebInspectorCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1788 {
1789     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1790     double callId = JSValueToNumber(context, arguments[0], exception);
1791     ASSERT(!*exception);
1792     JSRetainPtr<JSStringRef> script(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1793     ASSERT(!*exception);
1794
1795     controller->evaluateInWebInspector(static_cast<long>(callId), script.get());
1796     return JSValueMakeUndefined(context);
1797 }
1798
1799 static JSValueRef evaluateScriptInIsolatedWorldCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1800 {
1801     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1802     double worldID = JSValueToNumber(context, arguments[0], exception);
1803     ASSERT(!*exception);
1804     JSRetainPtr<JSStringRef> script(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1805     ASSERT(!*exception);
1806
1807     controller->evaluateScriptInIsolatedWorld(static_cast<unsigned>(worldID), JSContextGetGlobalObject(context), script.get());
1808     return JSValueMakeUndefined(context);
1809 }
1810
1811 static JSValueRef evaluateScriptInIsolatedWorldAndReturnValueCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1812 {
1813     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1814     double worldID = JSValueToNumber(context, arguments[0], exception);
1815     ASSERT(!*exception);
1816     JSRetainPtr<JSStringRef> script(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1817     ASSERT(!*exception);
1818
1819     controller->evaluateScriptInIsolatedWorldAndReturnValue(static_cast<unsigned>(worldID), JSContextGetGlobalObject(context), script.get());
1820     return JSValueMakeUndefined(context);
1821 }
1822
1823 static JSValueRef elementDoesAutoCompleteForElementWithIdCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1824 {
1825     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1826     JSRetainPtr<JSStringRef> elementId(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1827     ASSERT(!*exception);
1828
1829     bool autoCompletes = controller->elementDoesAutoCompleteForElementWithId(elementId.get());
1830
1831     return JSValueMakeBoolean(context, autoCompletes);
1832 }
1833
1834 static JSValueRef pauseAnimationAtTimeOnElementWithIdCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1835 {
1836     if (argumentCount != 3)
1837         return JSValueMakeUndefined(context);
1838
1839     JSRetainPtr<JSStringRef> animationName(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1840     ASSERT(!*exception);
1841     double time = JSValueToNumber(context, arguments[1], exception);
1842     ASSERT(!*exception);
1843     JSRetainPtr<JSStringRef> elementId(Adopt, JSValueToStringCopy(context, arguments[2], exception));
1844     ASSERT(!*exception);
1845
1846     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1847     return JSValueMakeBoolean(context, controller->pauseAnimationAtTimeOnElementWithId(animationName.get(), time, elementId.get()));
1848 }
1849
1850 static JSValueRef pauseTransitionAtTimeOnElementWithIdCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1851 {
1852     if (argumentCount != 3)
1853         return JSValueMakeUndefined(context);
1854
1855     JSRetainPtr<JSStringRef> propertyName(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1856     ASSERT(!*exception);
1857     double time = JSValueToNumber(context, arguments[1], exception);
1858     ASSERT(!*exception);
1859     JSRetainPtr<JSStringRef> elementId(Adopt, JSValueToStringCopy(context, arguments[2], exception));
1860     ASSERT(!*exception);
1861
1862     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1863     return JSValueMakeBoolean(context, controller->pauseTransitionAtTimeOnElementWithId(propertyName.get(), time, elementId.get()));
1864 }
1865
1866 static JSValueRef numberOfActiveAnimationsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1867 {
1868     if (argumentCount != 0)
1869         return JSValueMakeUndefined(context);
1870
1871     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1872     return JSValueMakeNumber(context, controller->numberOfActiveAnimations());
1873 }
1874
1875 static JSValueRef waitForPolicyDelegateCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t, const JSValueRef[], JSValueRef*)
1876 {
1877     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1878     controller->waitForPolicyDelegate();
1879     return JSValueMakeUndefined(context);
1880 }
1881
1882 static JSValueRef addOriginAccessWhitelistEntryCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1883 {
1884     if (argumentCount != 4)
1885         return JSValueMakeUndefined(context);
1886
1887     JSRetainPtr<JSStringRef> sourceOrigin(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1888     ASSERT(!*exception);
1889     JSRetainPtr<JSStringRef> destinationProtocol(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1890     ASSERT(!*exception);
1891     JSRetainPtr<JSStringRef> destinationHost(Adopt, JSValueToStringCopy(context, arguments[2], exception));
1892     ASSERT(!*exception);
1893     bool allowDestinationSubdomains = JSValueToBoolean(context, arguments[3]);
1894
1895     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1896     controller->addOriginAccessWhitelistEntry(sourceOrigin.get(), destinationProtocol.get(), destinationHost.get(), allowDestinationSubdomains);
1897     return JSValueMakeUndefined(context);
1898 }
1899
1900 static JSValueRef removeOriginAccessWhitelistEntryCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1901 {
1902     if (argumentCount != 4)
1903         return JSValueMakeUndefined(context);
1904
1905     JSRetainPtr<JSStringRef> sourceOrigin(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1906     ASSERT(!*exception);
1907     JSRetainPtr<JSStringRef> destinationProtocol(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1908     ASSERT(!*exception);
1909     JSRetainPtr<JSStringRef> destinationHost(Adopt, JSValueToStringCopy(context, arguments[2], exception));
1910     ASSERT(!*exception);
1911     bool allowDestinationSubdomains = JSValueToBoolean(context, arguments[3]);
1912
1913     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1914     controller->removeOriginAccessWhitelistEntry(sourceOrigin.get(), destinationProtocol.get(), destinationHost.get(), allowDestinationSubdomains);
1915     return JSValueMakeUndefined(context);
1916 }
1917
1918 static JSValueRef setScrollbarPolicyCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1919 {
1920     if (argumentCount != 2)
1921         return JSValueMakeUndefined(context);
1922
1923     JSRetainPtr<JSStringRef> orientation(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1924     ASSERT(!*exception);
1925     JSRetainPtr<JSStringRef> policy(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1926     ASSERT(!*exception);
1927
1928     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1929     controller->setScrollbarPolicy(orientation.get(), policy.get());
1930     return JSValueMakeUndefined(context);
1931 }
1932
1933 static JSValueRef addUserScriptCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1934 {
1935     if (argumentCount != 3)
1936         return JSValueMakeUndefined(context);
1937     
1938     JSRetainPtr<JSStringRef> source(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1939     ASSERT(!*exception);
1940     bool runAtStart = JSValueToBoolean(context, arguments[1]);
1941     bool allFrames = JSValueToBoolean(context, arguments[2]);
1942     
1943     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1944     controller->addUserScript(source.get(), runAtStart, allFrames);
1945     return JSValueMakeUndefined(context);
1946 }
1947  
1948 static JSValueRef addUserStyleSheetCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1949 {
1950     if (argumentCount != 2)
1951         return JSValueMakeUndefined(context);
1952     
1953     JSRetainPtr<JSStringRef> source(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1954     ASSERT(!*exception);
1955     bool allFrames = JSValueToBoolean(context, arguments[1]);
1956    
1957     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1958     controller->addUserStyleSheet(source.get(), allFrames);
1959     return JSValueMakeUndefined(context);
1960 }
1961
1962 static JSValueRef setShouldPaintBrokenImageCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1963 {
1964     // Has Mac implementation
1965     if (argumentCount < 1)
1966         return JSValueMakeUndefined(context);
1967
1968     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1969     controller->setShouldPaintBrokenImage(JSValueToBoolean(context, arguments[0]));
1970
1971     return JSValueMakeUndefined(context);
1972 }
1973
1974 static JSValueRef apiTestNewWindowDataLoadBaseURLCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1975 {
1976     if (argumentCount != 2)
1977         return JSValueMakeUndefined(context);
1978
1979     JSRetainPtr<JSStringRef> utf8Data(Adopt, JSValueToStringCopy(context, arguments[0], exception));
1980     ASSERT(!*exception);
1981
1982     JSRetainPtr<JSStringRef> baseURL(Adopt, JSValueToStringCopy(context, arguments[1], exception));
1983     ASSERT(!*exception);
1984         
1985     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1986     controller->apiTestNewWindowDataLoadBaseURL(utf8Data.get(), baseURL.get());
1987     return JSValueMakeUndefined(context);
1988 }
1989
1990 static JSValueRef apiTestGoToCurrentBackForwardItemCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1991 {
1992     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
1993     controller->apiTestGoToCurrentBackForwardItem();
1994     return JSValueMakeUndefined(context);
1995 }
1996
1997 static JSValueRef setWebViewEditableCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1998 {
1999     // Has Mac implementation
2000     if (argumentCount < 1)
2001         return JSValueMakeUndefined(context);
2002
2003     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2004     controller->setWebViewEditable(JSValueToBoolean(context, arguments[0]));
2005
2006     return JSValueMakeUndefined(context);
2007 }
2008
2009 static JSValueRef sendWebIntentResponseCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
2010 {
2011     JSRetainPtr<JSStringRef> response;
2012     if (argumentCount == 1) {
2013         response.adopt(JSValueToStringCopy(context, arguments[0], exception));
2014         ASSERT(!*exception);
2015     } else
2016         response.adopt(JSStringCreateWithUTF8CString(0));
2017
2018     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2019     controller->sendWebIntentResponse(response.get());
2020
2021     return JSValueMakeUndefined(context);
2022 }
2023
2024 static JSValueRef abortModalCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
2025 {
2026     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2027     controller->abortModal();
2028     return JSValueMakeUndefined(context);
2029 }
2030
2031 static JSValueRef markerTextForListItemCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
2032 {
2033     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2034     if (argumentCount < 1)
2035         return JSValueMakeUndefined(context);
2036     return JSValueMakeString(context, controller->markerTextForListItem(context, arguments[0]).get());
2037 }
2038
2039 static JSValueRef authenticateSessionCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
2040 {
2041     // authenticateSession(url, username, password)
2042     if (argumentCount != 3)
2043         return JSValueMakeUndefined(context);
2044
2045     JSRetainPtr<JSStringRef> url(Adopt, JSValueToStringCopy(context, arguments[0], exception));
2046     ASSERT(!*exception);
2047     JSRetainPtr<JSStringRef> username(Adopt, JSValueToStringCopy(context, arguments[1], exception));
2048     ASSERT(!*exception);
2049     JSRetainPtr<JSStringRef> password(Adopt, JSValueToStringCopy(context, arguments[2], exception));
2050     ASSERT(!*exception);
2051
2052     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2053     controller->authenticateSession(url.get(), username.get(), password.get());
2054     return JSValueMakeUndefined(context);
2055 }
2056
2057 static JSValueRef setSerializeHTTPLoadsCallback(JSContextRef context, JSObjectRef, JSObjectRef, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
2058 {
2059     bool serialize = true;
2060     if (argumentCount == 1)
2061         serialize = JSValueToBoolean(context, arguments[0]);
2062
2063     LayoutTestController::setSerializeHTTPLoads(serialize);
2064     return JSValueMakeUndefined(context);
2065 }
2066
2067 static JSValueRef setShouldStayOnPageAfterHandlingBeforeUnloadCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
2068 {
2069     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2070     
2071     if (argumentCount == 1)
2072         controller->setShouldStayOnPageAfterHandlingBeforeUnload(JSValueToBoolean(context, arguments[0]));
2073
2074     return JSValueMakeUndefined(context);
2075 }
2076
2077 static JSValueRef addChromeInputFieldCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
2078 {
2079     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2080     controller->addChromeInputField();
2081     // the first argument is a callback that is called once the input field has been added
2082     if (argumentCount == 1)
2083         JSObjectCallAsFunction(context, JSValueToObject(context, arguments[0], 0), thisObject, 0, 0, 0);
2084     return JSValueMakeUndefined(context);
2085 }
2086
2087 static JSValueRef removeChromeInputFieldCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
2088 {
2089     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2090     controller->removeChromeInputField();
2091     // the first argument is a callback that is called once the input field has been added
2092     if (argumentCount == 1)
2093         JSObjectCallAsFunction(context, JSValueToObject(context, arguments[0], 0), thisObject, 0, 0, 0);
2094     return JSValueMakeUndefined(context);
2095 }
2096
2097 static JSValueRef focusWebViewCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
2098 {
2099     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2100     controller->focusWebView();
2101     // the first argument is a callback that is called once the input field has been added
2102     if (argumentCount == 1)
2103         JSObjectCallAsFunction(context, JSValueToObject(context, arguments[0], 0), thisObject, 0, 0, 0);
2104     return JSValueMakeUndefined(context);
2105 }
2106
2107 static JSValueRef setBackingScaleFactorCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
2108 {
2109     if (argumentCount != 2)
2110         return JSValueMakeUndefined(context);
2111
2112     double backingScaleFactor = JSValueToNumber(context, arguments[0], exception);
2113     ASSERT(!*exception);
2114
2115     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2116     controller->setBackingScaleFactor(backingScaleFactor);
2117
2118     // The second argument is a callback that is called once the backing scale factor has been set.
2119     JSObjectCallAsFunction(context, JSValueToObject(context, arguments[1], 0), thisObject, 0, 0, 0);
2120     return JSValueMakeUndefined(context);
2121 }
2122
2123 static JSValueRef preciseTimeCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
2124 {
2125     return JSValueMakeNumber(context, WTF::currentTime());
2126 }
2127
2128 // Static Values
2129
2130 static JSValueRef getGlobalFlagCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
2131 {
2132     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2133     return JSValueMakeBoolean(context, controller->globalFlag());
2134 }
2135
2136 static JSValueRef getWebHistoryItemCountCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
2137 {
2138     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2139     return JSValueMakeNumber(context, controller->webHistoryItemCount());
2140 }
2141
2142 static JSValueRef getWorkerThreadCountCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
2143 {
2144     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2145     return JSValueMakeNumber(context, controller->workerThreadCount());
2146 }
2147
2148 #if PLATFORM(MAC) || PLATFORM(GTK) || PLATFORM(WIN)
2149 static JSValueRef getPlatformNameCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
2150 {
2151     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2152     JSRetainPtr<JSStringRef> platformName(controller->platformName());
2153     if (!platformName.get())
2154         return JSValueMakeUndefined(context);
2155     return JSValueMakeString(context, platformName.get());
2156 }
2157 #endif
2158
2159 static bool setGlobalFlagCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef value, JSValueRef* exception)
2160 {
2161     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2162     controller->setGlobalFlag(JSValueToBoolean(context, value));
2163     return true;
2164 }
2165
2166 static JSValueRef ignoreDesktopNotificationPermissionRequestsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
2167 {
2168     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2169     controller->ignoreDesktopNotificationPermissionRequests();
2170     return JSValueMakeUndefined(context);
2171 }
2172
2173 static JSValueRef simulateDesktopNotificationClickCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
2174 {
2175     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); 
2176     JSRetainPtr<JSStringRef> title(Adopt, JSValueToStringCopy(context, arguments[0], exception));
2177     controller->simulateDesktopNotificationClick(title.get());
2178     return JSValueMakeUndefined(context);
2179 }
2180
2181 static JSValueRef setMinimumTimerIntervalCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
2182 {
2183     if (argumentCount < 1)
2184         return JSValueMakeUndefined(context);
2185
2186     double minimum = JSValueToNumber(context, arguments[0], exception);
2187     ASSERT(!*exception);
2188
2189     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2190     controller->setMinimumTimerInterval(minimum);
2191
2192     return JSValueMakeUndefined(context);
2193 }
2194
2195 static JSValueRef setTextDirectionCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
2196 {
2197     if (argumentCount == 1) {
2198         JSRetainPtr<JSStringRef> direction(Adopt, JSValueToStringCopy(context, arguments[0], exception));
2199         LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2200         controller->setTextDirection(direction.get());
2201     }
2202
2203     return JSValueMakeUndefined(context);
2204
2205 }
2206
2207 static JSValueRef setHasCustomFullScreenBehaviorCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
2208 {
2209     if (argumentCount == 1) {
2210         bool hasCustomBehavior = JSValueToBoolean(context, arguments[0]);
2211         LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
2212         controller->setHasCustomFullScreenBehavior(hasCustomBehavior);
2213     }
2214
2215     return JSValueMakeUndefined(context);
2216 }
2217
2218 static void layoutTestControllerObjectFinalize(JSObjectRef object)
2219 {
2220     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(object));
2221     controller->deref();
2222 }
2223
2224 // Object Creation
2225
2226 void LayoutTestController::makeWindowObject(JSContextRef context, JSObjectRef windowObject, JSValueRef* exception)
2227 {
2228     JSRetainPtr<JSStringRef> layoutTestContollerStr(Adopt, JSStringCreateWithUTF8CString("layoutTestController"));
2229     ref();
2230
2231     JSClassRef classRef = getJSClass();
2232     JSValueRef layoutTestContollerObject = JSObjectMake(context, classRef, this);
2233     JSClassRelease(classRef);
2234
2235     JSObjectSetProperty(context, windowObject, layoutTestContollerStr.get(), layoutTestContollerObject, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete, exception);
2236 }
2237
2238 JSClassRef LayoutTestController::getJSClass()
2239 {
2240     static JSStaticValue* staticValues = LayoutTestController::staticValues();
2241     static JSStaticFunction* staticFunctions = LayoutTestController::staticFunctions();
2242     static JSClassDefinition classDefinition = {
2243         0, kJSClassAttributeNone, "LayoutTestController", 0, staticValues, staticFunctions,
2244         0, layoutTestControllerObjectFinalize, 0, 0, 0, 0, 0, 0, 0, 0, 0
2245     };
2246
2247     return JSClassCreate(&classDefinition);
2248 }
2249
2250 JSStaticValue* LayoutTestController::staticValues()
2251 {
2252     static JSStaticValue staticValues[] = {
2253         { "globalFlag", getGlobalFlagCallback, setGlobalFlagCallback, kJSPropertyAttributeNone },
2254         { "webHistoryItemCount", getWebHistoryItemCountCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2255         { "workerThreadCount", getWorkerThreadCountCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2256 #if PLATFORM(MAC) || PLATFORM(GTK) || PLATFORM(WIN)
2257         { "platformName", getPlatformNameCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2258 #endif
2259         { 0, 0, 0, 0 }
2260     };
2261     return staticValues;
2262 }
2263
2264 JSStaticFunction* LayoutTestController::staticFunctions()
2265 {
2266     static JSStaticFunction staticFunctions[] = {
2267         { "abortModal", abortModalCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2268         { "addDisallowedURL", addDisallowedURLCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2269         { "addURLToRedirect", addURLToRedirectCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2270         { "addUserScript", addUserScriptCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2271         { "addUserStyleSheet", addUserStyleSheetCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2272         { "apiTestNewWindowDataLoadBaseURL", apiTestNewWindowDataLoadBaseURLCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2273         { "apiTestGoToCurrentBackForwardItem", apiTestGoToCurrentBackForwardItemCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2274         { "applicationCacheDiskUsageForOrigin", applicationCacheDiskUsageForOriginCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2275         { "callShouldCloseOnWebView", callShouldCloseOnWebViewCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2276         { "clearAllApplicationCaches", clearAllApplicationCachesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2277         { "clearAllDatabases", clearAllDatabasesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2278         { "clearApplicationCacheForOrigin", clearApplicationCacheForOriginCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2279         { "clearBackForwardList", clearBackForwardListCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2280         { "clearPersistentUserStyleSheet", clearPersistentUserStyleSheetCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2281         { "closeWebInspector", closeWebInspectorCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2282         { "computedStyleIncludingVisitedInfo", computedStyleIncludingVisitedInfoCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2283         { "decodeHostName", decodeHostNameCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2284         { "disableImageLoading", disableImageLoadingCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2285         { "disallowIncreaseForApplicationCacheQuota", disallowIncreaseForApplicationCacheQuotaCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2286         { "dispatchPendingLoadRequests", dispatchPendingLoadRequestsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2287         { "display", displayCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2288         { "displayInvalidatedRegion", displayInvalidatedRegionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2289         { "dumpApplicationCacheDelegateCallbacks", dumpApplicationCacheDelegateCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2290         { "dumpAsText", dumpAsTextCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2291         { "dumpBackForwardList", dumpBackForwardListCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2292         { "dumpChildFrameScrollPositions", dumpChildFrameScrollPositionsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2293         { "dumpChildFramesAsText", dumpChildFramesAsTextCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2294         { "dumpConfigurationForViewport", dumpConfigurationForViewportCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2295         { "dumpDOMAsWebArchive", dumpDOMAsWebArchiveCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2296         { "dumpDatabaseCallbacks", dumpDatabaseCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2297         { "dumpEditingCallbacks", dumpEditingCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2298         { "dumpFrameLoadCallbacks", dumpFrameLoadCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2299         { "dumpProgressFinishedCallback", dumpProgressFinishedCallbackCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2300         { "dumpUserGestureInFrameLoadCallbacks", dumpUserGestureInFrameLoadCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },        
2301         { "dumpResourceLoadCallbacks", dumpResourceLoadCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2302         { "dumpResourceResponseMIMETypes", dumpResourceResponseMIMETypesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2303         { "dumpSelectionRect", dumpSelectionRectCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2304         { "dumpSourceAsWebArchive", dumpSourceAsWebArchiveCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2305         { "dumpStatusCallbacks", dumpStatusCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2306         { "dumpTitleChanges", dumpTitleChangesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2307         { "dumpIconChanges", dumpIconChangesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2308         { "dumpWillCacheResponse", dumpWillCacheResponseCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2309         { "elementDoesAutoCompleteForElementWithId", elementDoesAutoCompleteForElementWithIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2310         { "encodeHostName", encodeHostNameCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2311         { "evaluateInWebInspector", evaluateInWebInspectorCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2312         { "evaluateScriptInIsolatedWorldAndReturnValue", evaluateScriptInIsolatedWorldAndReturnValueCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2313         { "evaluateScriptInIsolatedWorld", evaluateScriptInIsolatedWorldCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2314         { "execCommand", execCommandCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2315         { "findString", findStringCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2316         { "counterValueForElementById", counterValueForElementByIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2317         { "originsWithApplicationCache", originsWithApplicationCacheCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2318         { "goBack", goBackCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, 
2319         { "grantDesktopNotificationPermission", grantDesktopNotificationPermissionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, 
2320         { "ignoreDesktopNotificationPermissionRequests", ignoreDesktopNotificationPermissionRequestsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2321         { "isCommandEnabled", isCommandEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2322         { "keepWebHistory", keepWebHistoryCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2323         { "layerTreeAsText", layerTreeAsTextCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2324         { "numberOfPages", numberOfPagesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2325         { "numberOfPendingGeolocationPermissionRequests", numberOfPendingGeolocationPermissionRequestsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2326         { "markerTextForListItem", markerTextForListItemCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2327         { "notifyDone", notifyDoneCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2328         { "numberOfActiveAnimations", numberOfActiveAnimationsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2329         { "overridePreference", overridePreferenceCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2330         { "pageNumberForElementById", pageNumberForElementByIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2331         { "pageSizeAndMarginsInPixels", pageSizeAndMarginsInPixelsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2332         { "pageProperty", pagePropertyCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2333         { "pathToLocalResource", pathToLocalResourceCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2334         { "pauseAnimationAtTimeOnElementWithId", pauseAnimationAtTimeOnElementWithIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2335         { "pauseTransitionAtTimeOnElementWithId", pauseTransitionAtTimeOnElementWithIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2336         { "printToPDF", dumpAsPDFCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2337         { "queueBackNavigation", queueBackNavigationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2338         { "queueForwardNavigation", queueForwardNavigationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2339         { "queueLoad", queueLoadCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2340         { "queueLoadHTMLString", queueLoadHTMLStringCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2341         { "queueLoadingScript", queueLoadingScriptCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2342         { "queueNonLoadingScript", queueNonLoadingScriptCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2343         { "queueReload", queueReloadCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2344         { "removeAllVisitedLinks", removeAllVisitedLinksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2345         { "removeOriginAccessWhitelistEntry", removeOriginAccessWhitelistEntryCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2346         { "repaintSweepHorizontally", repaintSweepHorizontallyCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2347         { "resetPageVisibility", resetPageVisibilityCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2348         { "sendWebIntentResponse", sendWebIntentResponseCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2349         { "setAcceptsEditing", setAcceptsEditingCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2350         { "setAllowUniversalAccessFromFileURLs", setAllowUniversalAccessFromFileURLsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2351         { "setAllowFileAccessFromFileURLs", setAllowFileAccessFromFileURLsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2352         { "setAlwaysAcceptCookies", setAlwaysAcceptCookiesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2353         { "setAppCacheMaximumSize", setAppCacheMaximumSizeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2354         { "setApplicationCacheOriginQuota", setApplicationCacheOriginQuotaCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2355         { "setEncodedAudioData", setEncodedAudioDataCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2356         { "setAuthenticationPassword", setAuthenticationPasswordCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2357         { "setAuthenticationUsername", setAuthenticationUsernameCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2358         { "setAuthorAndUserStylesEnabled", setAuthorAndUserStylesEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2359         { "setAutofilled", setAutofilledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2360         { "setCacheModel", setCacheModelCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2361         { "setCallCloseOnWebViews", setCallCloseOnWebViewsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2362         { "setCanOpenWindows", setCanOpenWindowsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2363         { "setCloseRemainingWindowsWhenComplete", setCloseRemainingWindowsWhenCompleteCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2364         { "setCustomPolicyDelegate", setCustomPolicyDelegateCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2365         { "setDatabaseQuota", setDatabaseQuotaCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, 
2366         { "setDeferMainResourceDataLoad", setDeferMainResourceDataLoadCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2367         { "setDefersLoading", setDefersLoadingCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2368         { "setUseDeferredFrameLoading", setUseDeferredFrameLoadingCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2369         { "setDomainRelaxationForbiddenForURLScheme", setDomainRelaxationForbiddenForURLSchemeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2370         { "setFrameFlatteningEnabled", setFrameFlatteningEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2371         { "setGeolocationPermission", setGeolocationPermissionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2372         { "setHandlesAuthenticationChallenges", setHandlesAuthenticationChallengesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2373         { "setIconDatabaseEnabled", setIconDatabaseEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2374         { "setAutomaticLinkDetectionEnabled", setAutomaticLinkDetectionEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2375         { "setMainFrameIsFirstResponder", setMainFrameIsFirstResponderCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2376         { "setMinimumTimerInterval", setMinimumTimerIntervalCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2377         { "setMockDeviceOrientation", setMockDeviceOrientationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2378         { "setMockGeolocationError", setMockGeolocationErrorCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2379         { "setMockGeolocationPosition", setMockGeolocationPositionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2380         { "addMockSpeechInputResult", addMockSpeechInputResultCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2381         { "setMockSpeechInputDumpRect", setMockSpeechInputDumpRectCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2382         { "setNewWindowsCopyBackForwardList", setNewWindowsCopyBackForwardListCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2383         { "setPageVisibility", setPageVisibilityCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2384         { "setPOSIXLocale", setPOSIXLocaleCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2385         { "setPersistentUserStyleSheetLocation", setPersistentUserStyleSheetLocationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2386         { "setPopupBlockingEnabled", setPopupBlockingEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2387         { "setPluginsEnabled", setPluginsEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2388         { "setPrinting", setPrintingCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2389         { "setPrivateBrowsingEnabled", setPrivateBrowsingEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2390         { "setSelectTrailingWhitespaceEnabled", setSelectTrailingWhitespaceEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2391         { "setSerializeHTTPLoads", setSerializeHTTPLoadsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2392         { "setSmartInsertDeleteEnabled", setSmartInsertDeleteEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2393         { "setSpatialNavigationEnabled", setSpatialNavigationEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2394         { "setStopProvisionalFrameLoads", setStopProvisionalFrameLoadsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2395         { "setTabKeyCyclesThroughElements", setTabKeyCyclesThroughElementsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2396         { "setUseDashboardCompatibilityMode", setUseDashboardCompatibilityModeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2397         { "setUserStyleSheetEnabled", setUserStyleSheetEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2398         { "setUserStyleSheetLocation", setUserStyleSheetLocationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2399         { "setValueForUser", setValueForUserCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2400         { "setViewModeMediaFeature", setViewModeMediaFeatureCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2401         { "setWebViewEditable", setWebViewEditableCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2402         { "setWillSendRequestClearHeader", setWillSendRequestClearHeaderCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2403         { "setWillSendRequestReturnsNull", setWillSendRequestReturnsNullCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2404         { "setWillSendRequestReturnsNullOnRedirect", setWillSendRequestReturnsNullOnRedirectCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2405         { "setWindowIsKey", setWindowIsKeyCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2406         { "setJavaScriptCanAccessClipboard", setJavaScriptCanAccessClipboardCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2407         { "setXSSAuditorEnabled", setXSSAuditorEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2408         { "setAsynchronousSpellCheckingEnabled", setAsynchronousSpellCheckingEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2409         { "showWebInspector", showWebInspectorCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2410         { "simulateDesktopNotificationClick", simulateDesktopNotificationClickCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2411         { "testOnscreen", testOnscreenCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2412         { "testRepaint", testRepaintCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2413         { "waitForPolicyDelegate", waitForPolicyDelegateCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2414         { "waitUntilDone", waitUntilDoneCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2415         { "windowCount", windowCountCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2416         { "addOriginAccessWhitelistEntry", addOriginAccessWhitelistEntryCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2417         { "setScrollbarPolicy", setScrollbarPolicyCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2418         { "authenticateSession", authenticateSessionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2419         { "deleteAllLocalStorage", deleteAllLocalStorageCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2420         { "syncLocalStorage", syncLocalStorageCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },                
2421         { "observeStorageTrackerNotifications", observeStorageTrackerNotificationsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },        
2422         { "deleteLocalStorageForOrigin", deleteLocalStorageForOriginCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2423         { "localStorageDiskUsageForOrigin", localStorageDiskUsageForOriginCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2424         { "originsWithLocalStorage", originsWithLocalStorageCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2425         { "setShouldPaintBrokenImage", setShouldPaintBrokenImageCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2426         { "setTextDirection", setTextDirectionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2427         { "setShouldStayOnPageAfterHandlingBeforeUnload", setShouldStayOnPageAfterHandlingBeforeUnloadCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2428         { "addChromeInputField", addChromeInputFieldCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2429         { "removeChromeInputField", removeChromeInputFieldCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2430         { "focusWebView", focusWebViewCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2431         { "setBackingScaleFactor", setBackingScaleFactorCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2432         { "preciseTime", preciseTimeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2433         { "setHasCustomFullScreenBehavior", setHasCustomFullScreenBehaviorCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
2434         { 0, 0, 0 }
2435     };
2436
2437     return staticFunctions;
2438 }
2439
2440 void LayoutTestController::queueLoadHTMLString(JSStringRef content, JSStringRef baseURL)
2441 {
2442     WorkQueue::shared()->queue(new LoadHTMLStringItem(content, baseURL));
2443 }
2444
2445 void LayoutTestController::queueLoadAlternateHTMLString(JSStringRef content, JSStringRef baseURL, JSStringRef unreachableURL)
2446 {
2447     WorkQueue::shared()->queue(new LoadHTMLStringItem(content, baseURL, unreachableURL));
2448 }
2449
2450 void LayoutTestController::queueBackNavigation(int howFarBack)
2451 {
2452     WorkQueue::shared()->queue(new BackItem(howFarBack));
2453 }
2454
2455 void LayoutTestController::queueForwardNavigation(int howFarForward)
2456 {
2457     WorkQueue::shared()->queue(new ForwardItem(howFarForward));
2458 }
2459
2460 void LayoutTestController::queueLoadingScript(JSStringRef script)
2461 {
2462     WorkQueue::shared()->queue(new LoadingScriptItem(script));
2463 }
2464
2465 void LayoutTestController::queueNonLoadingScript(JSStringRef script)
2466 {
2467     WorkQueue::shared()->queue(new NonLoadingScriptItem(script));
2468 }
2469
2470 void LayoutTestController::queueReload()
2471 {
2472     WorkQueue::shared()->queue(new ReloadItem);
2473 }
2474
2475 void LayoutTestController::grantDesktopNotificationPermission(JSStringRef origin)
2476 {
2477     m_desktopNotificationAllowedOrigins.push_back(JSStringRetain(origin));
2478 }
2479
2480 bool LayoutTestController::checkDesktopNotificationPermission(JSStringRef origin)
2481 {
2482     std::vector<JSStringRef>::iterator i;
2483     for (i = m_desktopNotificationAllowedOrigins.begin();
2484          i != m_desktopNotificationAllowedOrigins.end();
2485          ++i) {
2486         if (JSStringIsEqual(*i, origin))
2487             return true;
2488     }
2489     return false;
2490 }
2491
2492 void LayoutTestController::ignoreDesktopNotificationPermissionRequests()
2493 {
2494     m_areDesktopNotificationPermissionRequestsIgnored = false;
2495 }
2496
2497 void LayoutTestController::waitToDumpWatchdogTimerFired()
2498 {
2499     const char* message = "FAIL: Timed out waiting for notifyDone to be called\n";
2500     fprintf(stderr, "%s", message);
2501     fprintf(stdout, "%s", message);
2502     notifyDone();
2503 }
2504
2505 void LayoutTestController::setGeolocationPermissionCommon(bool allow)
2506 {
2507     m_isGeolocationPermissionSet = true;
2508     m_geolocationPermission = allow;
2509 }
2510
2511 void LayoutTestController::setPOSIXLocale(JSStringRef locale)
2512 {
2513     char localeBuf[32];
2514     JSStringGetUTF8CString(locale, localeBuf, sizeof(localeBuf));
2515     setlocale(LC_ALL, localeBuf);
2516 }
2517
2518 void LayoutTestController::addURLToRedirect(std::string origin, std::string destination)
2519 {
2520     m_URLsToRedirect[origin] = destination;
2521 }
2522
2523 const std::string& LayoutTestController::redirectionDestinationForURL(std::string origin)
2524 {
2525     return m_URLsToRedirect[origin];
2526 }
2527
2528 void LayoutTestController::setShouldPaintBrokenImage(bool shouldPaintBrokenImage)
2529 {
2530     m_shouldPaintBrokenImage = shouldPaintBrokenImage;
2531 }
2532
2533 const unsigned LayoutTestController::maxViewWidth = 800;
2534 const unsigned LayoutTestController::maxViewHeight = 600;