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