|
1 /* |
|
2 * Copyright (C) 2007 Apple Inc. All rights reserved. |
|
3 * |
|
4 * Redistribution and use in source and binary forms, with or without |
|
5 * modification, are permitted provided that the following conditions |
|
6 * are met: |
|
7 * |
|
8 * 1. Redistributions of source code must retain the above copyright |
|
9 * notice, this list of conditions and the following disclaimer. |
|
10 * 2. Redistributions in binary form must reproduce the above copyright |
|
11 * notice, this list of conditions and the following disclaimer in the |
|
12 * documentation and/or other materials provided with the distribution. |
|
13 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of |
|
14 * its contributors may be used to endorse or promote products derived |
|
15 * from this software without specific prior written permission. |
|
16 * |
|
17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY |
|
18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
|
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
|
20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY |
|
21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
|
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
|
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
|
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
|
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
27 */ |
|
28 |
|
29 #include "DumpRenderTree.h" |
|
30 #include "LayoutTestController.h" |
|
31 |
|
32 #include <JavaScriptCore/Assertions.h> |
|
33 #include <JavaScriptCore/JSObjectRef.h> |
|
34 #include <JavaScriptCore/JSRetainPtr.h> |
|
35 |
|
36 LayoutTestController::LayoutTestController(bool testRepaintDefault, bool testRepaintSweepHorizontallyDefault) |
|
37 : m_dumpAsText(false) |
|
38 , m_dumpBackForwardList(false) |
|
39 , m_dumpChildFrameScrollPositions(false) |
|
40 , m_dumpChildFramesAsText(false) |
|
41 , m_dumpDOMAsWebArchive(false) |
|
42 , m_dumpSelectionRect(false) |
|
43 , m_dumpSourceAsWebArchive(false) |
|
44 , m_dumpTitleChanges(false) |
|
45 , m_dumpEditingCallbacks(false) |
|
46 , m_dumpResourceLoadCallbacks(false) |
|
47 , m_dumpFrameLoadCallbacks(false) |
|
48 , m_addFileToPasteboardOnDrag(false) |
|
49 , m_callCloseOnWebViews(true) |
|
50 , m_canOpenWindows(false) |
|
51 , m_closeRemainingWindowsWhenComplete(true) |
|
52 , m_testRepaint(testRepaintDefault) |
|
53 , m_testRepaintSweepHorizontally(testRepaintSweepHorizontallyDefault) |
|
54 , m_waitToDump(false) |
|
55 , m_windowIsKey(true) |
|
56 { |
|
57 } |
|
58 |
|
59 LayoutTestController::~LayoutTestController() |
|
60 { |
|
61 } |
|
62 |
|
63 // Static Functions |
|
64 |
|
65 static JSValueRef dumpAsTextCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
|
66 { |
|
67 LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); |
|
68 controller->setDumpAsText(true); |
|
69 return JSValueMakeUndefined(context); |
|
70 } |
|
71 |
|
72 static JSValueRef dumpBackForwardListCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
|
73 { |
|
74 LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); |
|
75 controller->setDumpBackForwardList(true); |
|
76 return JSValueMakeUndefined(context); |
|
77 } |
|
78 |
|
79 static JSValueRef dumpChildFramesAsTextCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
|
80 { |
|
81 LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); |
|
82 controller->setDumpChildFramesAsText(true); |
|
83 return JSValueMakeUndefined(context); |
|
84 } |
|
85 |
|
86 static JSValueRef dumpChildFrameScrollPositionsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
|
87 { |
|
88 LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); |
|
89 controller->setDumpChildFrameScrollPositions(true); |
|
90 return JSValueMakeUndefined(context); |
|
91 } |
|
92 |
|
93 static JSValueRef dumpDOMAsWebArchiveCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
|
94 { |
|
95 LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); |
|
96 controller->setDumpDOMAsWebArchive(true); |
|
97 return JSValueMakeUndefined(context); |
|
98 } |
|
99 |
|
100 static JSValueRef dumpEditingCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
|
101 { |
|
102 LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); |
|
103 controller->setDumpEditingCallbacks(true); |
|
104 return JSValueMakeUndefined(context); |
|
105 } |
|
106 |
|
107 static JSValueRef dumpFrameLoadCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
|
108 { |
|
109 LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); |
|
110 controller->setDumpFrameLoadCallbacks(true); |
|
111 return JSValueMakeUndefined(context); |
|
112 } |
|
113 |
|
114 static JSValueRef dumpResourceLoadCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
|
115 { |
|
116 LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); |
|
117 controller->setDumpResourceLoadCallbacks(true); |
|
118 return JSValueMakeUndefined(context); |
|
119 } |
|
120 |
|
121 static JSValueRef dumpSelectionRectCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
|
122 { |
|
123 LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); |
|
124 controller->setDumpSelectionRect(true); |
|
125 return JSValueMakeUndefined(context); |
|
126 } |
|
127 |
|
128 static JSValueRef dumpSourceAsWebArchiveCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
|
129 { |
|
130 LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); |
|
131 controller->setDumpSourceAsWebArchive(true); |
|
132 return JSValueMakeUndefined(context); |
|
133 } |
|
134 |
|
135 static JSValueRef dumpTitleChangesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
|
136 { |
|
137 LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); |
|
138 controller->setDumpTitleChanges(true); |
|
139 return JSValueMakeUndefined(context); |
|
140 } |
|
141 |
|
142 static JSValueRef repaintSweepHorizontallyCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
|
143 { |
|
144 LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); |
|
145 controller->setTestRepaintSweepHorizontally(true); |
|
146 return JSValueMakeUndefined(context); |
|
147 } |
|
148 |
|
149 static JSValueRef setCallCloseOnWebViewsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
|
150 { |
|
151 if (argumentCount < 1) |
|
152 return JSValueMakeUndefined(context); |
|
153 |
|
154 LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); |
|
155 controller->setCallCloseOnWebViews(JSValueToBoolean(context, arguments[0])); |
|
156 return JSValueMakeUndefined(context); |
|
157 } |
|
158 |
|
159 static JSValueRef setCanOpenWindowsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
|
160 { |
|
161 LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); |
|
162 controller->setCanOpenWindows(true); |
|
163 return JSValueMakeUndefined(context); |
|
164 } |
|
165 |
|
166 static JSValueRef setCloseRemainingWindowsWhenCompleteCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
|
167 { |
|
168 if (argumentCount < 1) |
|
169 return JSValueMakeUndefined(context); |
|
170 |
|
171 LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); |
|
172 controller->setCloseRemainingWindowsWhenComplete(JSValueToBoolean(context, arguments[0])); |
|
173 return JSValueMakeUndefined(context); |
|
174 } |
|
175 |
|
176 static JSValueRef testRepaintCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
|
177 { |
|
178 LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); |
|
179 controller->setTestRepaint(true); |
|
180 return JSValueMakeUndefined(context); |
|
181 } |
|
182 |
|
183 static JSValueRef addFileToPasteboardOnDragCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
|
184 { |
|
185 LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); |
|
186 controller->setAddFileToPasteboardOnDrag(true); |
|
187 return JSValueMakeUndefined(context); |
|
188 } |
|
189 |
|
190 static JSValueRef addDisallowedURLCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
|
191 { |
|
192 // Has mac implementation |
|
193 if (argumentCount < 1) |
|
194 return JSValueMakeUndefined(context); |
|
195 |
|
196 JSRetainPtr<JSStringRef> url(Adopt, JSValueToStringCopy(context, arguments[0], exception)); |
|
197 ASSERT(!*exception); |
|
198 |
|
199 LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); |
|
200 controller->addDisallowedURL(url.get()); |
|
201 |
|
202 return JSValueMakeUndefined(context); |
|
203 } |
|
204 |
|
205 static JSValueRef clearBackForwardListCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
|
206 { |
|
207 // Has mac & windows implementation |
|
208 LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); |
|
209 controller->clearBackForwardList(); |
|
210 |
|
211 return JSValueMakeUndefined(context); |
|
212 } |
|
213 |
|
214 static JSValueRef decodeHostNameCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
|
215 { |
|
216 // Has mac implementation |
|
217 if (argumentCount < 1) |
|
218 return JSValueMakeUndefined(context); |
|
219 |
|
220 JSRetainPtr<JSStringRef> name(Adopt, JSValueToStringCopy(context, arguments[0], exception)); |
|
221 ASSERT(!*exception); |
|
222 |
|
223 LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); |
|
224 JSRetainPtr<JSStringRef> decodedHostName(Adopt, controller->copyDecodedHostName(name.get())); |
|
225 return JSValueMakeString(context, decodedHostName.get()); |
|
226 } |
|
227 |
|
228 static JSValueRef displayCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
|
229 { |
|
230 // Has mac & windows implementation |
|
231 LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); |
|
232 controller->display(); |
|
233 |
|
234 return JSValueMakeUndefined(context); |
|
235 } |
|
236 |
|
237 static JSValueRef encodeHostNameCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
|
238 { |
|
239 // Has mac implementation |
|
240 if (argumentCount < 1) |
|
241 return JSValueMakeUndefined(context); |
|
242 |
|
243 JSRetainPtr<JSStringRef> name(Adopt, JSValueToStringCopy(context, arguments[0], exception)); |
|
244 ASSERT(!*exception); |
|
245 |
|
246 LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); |
|
247 JSRetainPtr<JSStringRef> encodedHostName(Adopt, controller->copyEncodedHostName(name.get())); |
|
248 return JSValueMakeString(context, encodedHostName.get()); |
|
249 } |
|
250 |
|
251 static JSValueRef keepWebHistoryCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
|
252 { |
|
253 // Has mac implementation |
|
254 LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); |
|
255 controller->keepWebHistory(); |
|
256 |
|
257 return JSValueMakeUndefined(context); |
|
258 } |
|
259 |
|
260 static JSValueRef notifyDoneCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
|
261 { |
|
262 // Has mac & windows implementation |
|
263 // May be able to be made platform independant by using shared WorkQueue |
|
264 LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); |
|
265 controller->notifyDone(); |
|
266 |
|
267 return JSValueMakeUndefined(context); |
|
268 } |
|
269 |
|
270 static JSValueRef queueBackNavigationCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
|
271 { |
|
272 // Has mac & windows implementation |
|
273 // May be able to be made platform independant by using shared WorkQueue |
|
274 if (argumentCount < 1) |
|
275 return JSValueMakeUndefined(context); |
|
276 |
|
277 double howFarBackDouble = JSValueToNumber(context, arguments[0], exception); |
|
278 ASSERT(!*exception); |
|
279 |
|
280 LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); |
|
281 controller->queueBackNavigation(static_cast<int>(howFarBackDouble)); |
|
282 |
|
283 return JSValueMakeUndefined(context); |
|
284 } |
|
285 |
|
286 static JSValueRef queueForwardNavigationCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
|
287 { |
|
288 // Has mac & windows implementation |
|
289 // May be able to be made platform independant by using shared WorkQueue |
|
290 if (argumentCount < 1) |
|
291 return JSValueMakeUndefined(context); |
|
292 |
|
293 double howFarForwardDouble = JSValueToNumber(context, arguments[0], exception); |
|
294 ASSERT(!*exception); |
|
295 |
|
296 LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); |
|
297 controller->queueForwardNavigation(static_cast<int>(howFarForwardDouble)); |
|
298 |
|
299 return JSValueMakeUndefined(context); |
|
300 } |
|
301 |
|
302 static JSValueRef queueLoadCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
|
303 { |
|
304 // Has mac & windows implementation |
|
305 // May be able to be made platform independant by using shared WorkQueue |
|
306 if (argumentCount < 1) |
|
307 return JSValueMakeUndefined(context); |
|
308 |
|
309 JSRetainPtr<JSStringRef> url(Adopt, JSValueToStringCopy(context, arguments[0], exception)); |
|
310 ASSERT(!*exception); |
|
311 |
|
312 JSRetainPtr<JSStringRef> target; |
|
313 if (argumentCount >= 2) { |
|
314 target.adopt(JSValueToStringCopy(context, arguments[1], exception)); |
|
315 ASSERT(!*exception); |
|
316 } else |
|
317 target.adopt(JSStringCreateWithUTF8CString("")); |
|
318 |
|
319 LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); |
|
320 controller->queueLoad(url.get(), target.get()); |
|
321 |
|
322 return JSValueMakeUndefined(context); |
|
323 } |
|
324 |
|
325 static JSValueRef queueReloadCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
|
326 { |
|
327 // Has mac & windows implementation |
|
328 // May be able to be made platform independant by using shared WorkQueue |
|
329 |
|
330 LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); |
|
331 controller->queueReload(); |
|
332 |
|
333 return JSValueMakeUndefined(context); |
|
334 } |
|
335 |
|
336 static JSValueRef queueScriptCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
|
337 { |
|
338 // Has mac & windows implementation |
|
339 // May be able to be made platform independant by using shared WorkQueue |
|
340 if (argumentCount < 1) |
|
341 return JSValueMakeUndefined(context); |
|
342 |
|
343 JSRetainPtr<JSStringRef> script(Adopt, JSValueToStringCopy(context, arguments[0], exception)); |
|
344 ASSERT(!*exception); |
|
345 |
|
346 LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); |
|
347 controller->queueScript(script.get()); |
|
348 |
|
349 return JSValueMakeUndefined(context); |
|
350 } |
|
351 |
|
352 static JSValueRef setAcceptsEditingCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
|
353 { |
|
354 // Has mac & windows implementation |
|
355 if (argumentCount < 1) |
|
356 return JSValueMakeUndefined(context); |
|
357 |
|
358 LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); |
|
359 controller->setAcceptsEditing(JSValueToBoolean(context, arguments[0])); |
|
360 |
|
361 return JSValueMakeUndefined(context); |
|
362 } |
|
363 |
|
364 static JSValueRef setCustomPolicyDelegateCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
|
365 { |
|
366 // Has mac implementation |
|
367 if (argumentCount < 1) |
|
368 return JSValueMakeUndefined(context); |
|
369 |
|
370 LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); |
|
371 controller->setCustomPolicyDelegate(JSValueToBoolean(context, arguments[0])); |
|
372 |
|
373 return JSValueMakeUndefined(context); |
|
374 } |
|
375 |
|
376 static JSValueRef setMainFrameIsFirstResponderCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
|
377 { |
|
378 // Has mac implementation |
|
379 if (argumentCount < 1) |
|
380 return JSValueMakeUndefined(context); |
|
381 |
|
382 LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); |
|
383 controller->setMainFrameIsFirstResponder(JSValueToBoolean(context, arguments[0])); |
|
384 |
|
385 return JSValueMakeUndefined(context); |
|
386 } |
|
387 |
|
388 static JSValueRef setTabKeyCyclesThroughElementsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
|
389 { |
|
390 // Has mac & windows implementation |
|
391 if (argumentCount < 1) |
|
392 return JSValueMakeUndefined(context); |
|
393 |
|
394 LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); |
|
395 controller->setTabKeyCyclesThroughElements(JSValueToBoolean(context, arguments[0])); |
|
396 |
|
397 return JSValueMakeUndefined(context); |
|
398 } |
|
399 |
|
400 static JSValueRef setUseDashboardCompatibilityModeCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
|
401 { |
|
402 // Has mac implementation |
|
403 if (argumentCount < 1) |
|
404 return JSValueMakeUndefined(context); |
|
405 |
|
406 LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); |
|
407 controller->setUseDashboardCompatibilityMode(JSValueToBoolean(context, arguments[0])); |
|
408 |
|
409 return JSValueMakeUndefined(context); |
|
410 } |
|
411 |
|
412 static JSValueRef setUserStyleSheetEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
|
413 { |
|
414 // Has mac implementation |
|
415 if (argumentCount < 1) |
|
416 return JSValueMakeUndefined(context); |
|
417 |
|
418 LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); |
|
419 controller->setUserStyleSheetEnabled(JSValueToBoolean(context, arguments[0])); |
|
420 |
|
421 return JSValueMakeUndefined(context); |
|
422 } |
|
423 |
|
424 static JSValueRef setUserStyleSheetLocationCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
|
425 { |
|
426 // Has mac implementation |
|
427 if (argumentCount < 1) |
|
428 return JSValueMakeUndefined(context); |
|
429 |
|
430 JSRetainPtr<JSStringRef> path(Adopt, JSValueToStringCopy(context, arguments[0], exception)); |
|
431 ASSERT(!*exception); |
|
432 |
|
433 LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); |
|
434 controller->setUserStyleSheetLocation(path.get()); |
|
435 |
|
436 return JSValueMakeUndefined(context); |
|
437 } |
|
438 |
|
439 static JSValueRef setWindowIsKeyCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
|
440 { |
|
441 // Has mac implementation |
|
442 if (argumentCount < 1) |
|
443 return JSValueMakeUndefined(context); |
|
444 |
|
445 LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); |
|
446 controller->setWindowIsKey(JSValueToBoolean(context, arguments[0])); |
|
447 |
|
448 return JSValueMakeUndefined(context); |
|
449 } |
|
450 |
|
451 static JSValueRef waitUntilDoneCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
|
452 { |
|
453 // Has mac & windows implementation |
|
454 LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); |
|
455 controller->setWaitToDump(true); |
|
456 |
|
457 return JSValueMakeUndefined(context); |
|
458 } |
|
459 |
|
460 static JSValueRef windowCountCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
|
461 { |
|
462 // Has mac implementation |
|
463 LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); |
|
464 int windows = controller->windowCount(); |
|
465 return JSValueMakeNumber(context, windows); |
|
466 } |
|
467 |
|
468 // Object Creation |
|
469 |
|
470 void LayoutTestController::makeWindowObject(JSContextRef context, JSObjectRef windowObject, JSValueRef* exception) |
|
471 { |
|
472 JSRetainPtr<JSStringRef> layoutTestContollerStr(Adopt, JSStringCreateWithUTF8CString("layoutTestController")); |
|
473 JSValueRef layoutTestContollerObject = JSObjectMake(context, getJSClass(), this); |
|
474 JSObjectSetProperty(context, windowObject, layoutTestContollerStr.get(), layoutTestContollerObject, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete, exception); |
|
475 } |
|
476 |
|
477 JSClassRef LayoutTestController::getJSClass() |
|
478 { |
|
479 static JSClassRef layoutTestControllerClass = 0; |
|
480 |
|
481 if (!layoutTestControllerClass) { |
|
482 JSStaticFunction* staticFunctions = LayoutTestController::staticFunctions(); |
|
483 JSClassDefinition classDefinition = { |
|
484 0, kJSClassAttributeNone, "LayoutTestController", 0, 0, staticFunctions, |
|
485 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 |
|
486 }; |
|
487 |
|
488 layoutTestControllerClass = JSClassCreate(&classDefinition); |
|
489 } |
|
490 |
|
491 return layoutTestControllerClass; |
|
492 } |
|
493 |
|
494 JSStaticFunction* LayoutTestController::staticFunctions() |
|
495 { |
|
496 static JSStaticFunction staticFunctions[] = { |
|
497 { "addDisallowedURL", addDisallowedURLCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, |
|
498 { "addFileToPasteboardOnDrag", addFileToPasteboardOnDragCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, |
|
499 { "clearBackForwardList", clearBackForwardListCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, |
|
500 { "decodeHostName", decodeHostNameCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, |
|
501 { "display", displayCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, |
|
502 { "dumpAsText", dumpAsTextCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, |
|
503 { "dumpBackForwardList", dumpBackForwardListCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, |
|
504 { "dumpChildFramesAsText", dumpChildFramesAsTextCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, |
|
505 { "dumpChildFrameScrollPositions", dumpChildFrameScrollPositionsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, |
|
506 { "dumpDOMAsWebArchive", dumpDOMAsWebArchiveCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, |
|
507 { "dumpEditingCallbacks", dumpEditingCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, |
|
508 { "dumpFrameLoadCallbacks", dumpFrameLoadCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, |
|
509 { "dumpResourceLoadCallbacks", dumpResourceLoadCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, |
|
510 { "dumpSelectionRect", dumpSelectionRectCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, |
|
511 { "dumpSourceAsWebArchive", dumpSourceAsWebArchiveCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, |
|
512 { "dumpTitleChanges", dumpTitleChangesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, |
|
513 { "encodeHostName", encodeHostNameCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, |
|
514 { "keepWebHistory", keepWebHistoryCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, |
|
515 { "notifyDone", notifyDoneCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, |
|
516 { "queueBackNavigation", queueBackNavigationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, |
|
517 { "queueForwardNavigation", queueForwardNavigationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, |
|
518 { "queueLoad", queueLoadCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, |
|
519 { "queueReload", queueReloadCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, |
|
520 { "queueScript", queueScriptCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, |
|
521 { "repaintSweepHorizontally", repaintSweepHorizontallyCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, |
|
522 { "setAcceptsEditing", setAcceptsEditingCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, |
|
523 { "setCallCloseOnWebViews", setCallCloseOnWebViewsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, |
|
524 { "setCanOpenWindows", setCanOpenWindowsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, |
|
525 { "setCloseRemainingWindowsWhenComplete", setCloseRemainingWindowsWhenCompleteCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, |
|
526 { "setCustomPolicyDelegate", setCustomPolicyDelegateCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, |
|
527 { "setMainFrameIsFirstResponder", setMainFrameIsFirstResponderCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, |
|
528 { "setTabKeyCyclesThroughElements", setTabKeyCyclesThroughElementsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, |
|
529 { "setUseDashboardCompatibilityMode", setUseDashboardCompatibilityModeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, |
|
530 { "setUserStyleSheetEnabled", setUserStyleSheetEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, |
|
531 { "setUserStyleSheetLocation", setUserStyleSheetLocationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, |
|
532 { "setWindowIsKey", setWindowIsKeyCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, |
|
533 { "testRepaint", testRepaintCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, |
|
534 { "waitUntilDone", waitUntilDoneCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, |
|
535 { "windowCount", windowCountCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, |
|
536 { 0, 0, 0 } |
|
537 }; |
|
538 |
|
539 return staticFunctions; |
|
540 } |