OLD | NEW |
| (Empty) |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 /* | |
6 * Copyright (C) 2010 Google Inc. All rights reserved. | |
7 * Copyright (C) 2010 Pawel Hajdan (phajdan.jr@chromium.org) | |
8 * Copyright (C) 2012 Apple Inc. All Rights Reserved. | |
9 * | |
10 * Redistribution and use in source and binary forms, with or without | |
11 * modification, are permitted provided that the following conditions are | |
12 * met: | |
13 * | |
14 * * Redistributions of source code must retain the above copyright | |
15 * notice, this list of conditions and the following disclaimer. | |
16 * * Redistributions in binary form must reproduce the above | |
17 * copyright notice, this list of conditions and the following disclaimer | |
18 * in the documentation and/or other materials provided with the | |
19 * distribution. | |
20 * * Neither the name of Google Inc. nor the names of its | |
21 * contributors may be used to endorse or promote products derived from | |
22 * this software without specific prior written permission. | |
23 * | |
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
25 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
26 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
27 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
28 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
29 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
30 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
31 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
35 */ | |
36 | |
37 #include "content/shell/renderer/test_runner/TestRunner.h" | |
38 | |
39 #include <limits> | |
40 | |
41 #include "content/shell/common/test_runner/WebPreferences.h" | |
42 #include "content/shell/renderer/test_runner/MockWebSpeechInputController.h" | |
43 #include "content/shell/renderer/test_runner/MockWebSpeechRecognizer.h" | |
44 #include "content/shell/renderer/test_runner/TestInterfaces.h" | |
45 #include "content/shell/renderer/test_runner/WebPermissions.h" | |
46 #include "content/shell/renderer/test_runner/WebTestDelegate.h" | |
47 #include "content/shell/renderer/test_runner/WebTestProxy.h" | |
48 #include "content/shell/renderer/test_runner/notification_presenter.h" | |
49 #include "third_party/WebKit/public/platform/WebData.h" | |
50 #include "third_party/WebKit/public/platform/WebDeviceMotionData.h" | |
51 #include "third_party/WebKit/public/platform/WebDeviceOrientationData.h" | |
52 #include "third_party/WebKit/public/platform/WebPoint.h" | |
53 #include "third_party/WebKit/public/platform/WebURLResponse.h" | |
54 #include "third_party/WebKit/public/web/WebBindings.h" | |
55 #include "third_party/WebKit/public/web/WebDataSource.h" | |
56 #include "third_party/WebKit/public/web/WebDocument.h" | |
57 #include "third_party/WebKit/public/web/WebElement.h" | |
58 #include "third_party/WebKit/public/web/WebFindOptions.h" | |
59 #include "third_party/WebKit/public/web/WebFrame.h" | |
60 #include "third_party/WebKit/public/web/WebInputElement.h" | |
61 #include "third_party/WebKit/public/web/WebMIDIClientMock.h" | |
62 #include "third_party/WebKit/public/web/WebScriptSource.h" | |
63 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" | |
64 #include "third_party/WebKit/public/web/WebSerializedScriptValue.h" | |
65 #include "third_party/WebKit/public/web/WebSettings.h" | |
66 #include "third_party/WebKit/public/web/WebSurroundingText.h" | |
67 #include "third_party/WebKit/public/web/WebView.h" | |
68 #include "v8/include/v8.h" | |
69 | |
70 #if defined(__linux__) || defined(ANDROID) | |
71 #include "third_party/WebKit/public/web/linux/WebFontRendering.h" | |
72 #endif | |
73 | |
74 using namespace blink; | |
75 using namespace std; | |
76 | |
77 namespace WebTestRunner { | |
78 | |
79 namespace { | |
80 | |
81 class InvokeCallbackTask : public WebMethodTask<TestRunner> { | |
82 public: | |
83 InvokeCallbackTask(TestRunner* object, scoped_ptr<CppVariant> callbackArgume
nts) | |
84 : WebMethodTask<TestRunner>(object) | |
85 , m_callbackArguments(callbackArguments.Pass()) | |
86 { | |
87 } | |
88 | |
89 virtual void runIfValid() OVERRIDE | |
90 { | |
91 CppVariant invokeResult; | |
92 m_callbackArguments->invokeDefault(m_callbackArguments.get(), 1, invokeR
esult); | |
93 } | |
94 | |
95 private: | |
96 scoped_ptr<CppVariant> m_callbackArguments; | |
97 }; | |
98 | |
99 } | |
100 | |
101 TestRunner::WorkQueue::WorkQueue(TestRunner* controller) | |
102 : m_frozen(false) | |
103 , m_controller(controller) | |
104 { | |
105 } | |
106 | |
107 TestRunner::WorkQueue::~WorkQueue() | |
108 { | |
109 reset(); | |
110 } | |
111 | |
112 void TestRunner::WorkQueue::processWorkSoon() | |
113 { | |
114 if (m_controller->topLoadingFrame()) | |
115 return; | |
116 | |
117 if (!m_queue.empty()) { | |
118 // We delay processing queued work to avoid recursion problems. | |
119 m_controller->m_delegate->postTask(new WorkQueueTask(this)); | |
120 } else if (!m_controller->m_waitUntilDone) | |
121 m_controller->m_delegate->testFinished(); | |
122 } | |
123 | |
124 void TestRunner::WorkQueue::processWork() | |
125 { | |
126 // Quit doing work once a load is in progress. | |
127 while (!m_queue.empty()) { | |
128 bool startedLoad = m_queue.front()->run(m_controller->m_delegate, m_cont
roller->m_webView); | |
129 delete m_queue.front(); | |
130 m_queue.pop_front(); | |
131 if (startedLoad) | |
132 return; | |
133 } | |
134 | |
135 if (!m_controller->m_waitUntilDone && !m_controller->topLoadingFrame()) | |
136 m_controller->m_delegate->testFinished(); | |
137 } | |
138 | |
139 void TestRunner::WorkQueue::reset() | |
140 { | |
141 m_frozen = false; | |
142 while (!m_queue.empty()) { | |
143 delete m_queue.front(); | |
144 m_queue.pop_front(); | |
145 } | |
146 } | |
147 | |
148 void TestRunner::WorkQueue::addWork(WorkItem* work) | |
149 { | |
150 if (m_frozen) { | |
151 delete work; | |
152 return; | |
153 } | |
154 m_queue.push_back(work); | |
155 } | |
156 | |
157 void TestRunner::WorkQueue::WorkQueueTask::runIfValid() | |
158 { | |
159 m_object->processWork(); | |
160 } | |
161 | |
162 TestRunner::HostMethodTask::HostMethodTask(TestRunner* object, TestRunner::HostM
ethodTask::CallbackMethodType callback) | |
163 : WebMethodTask<TestRunner>(object) | |
164 , m_callback(callback) | |
165 { | |
166 } | |
167 | |
168 void TestRunner::HostMethodTask::runIfValid() | |
169 { | |
170 (m_object->*m_callback)(); | |
171 } | |
172 | |
173 TestRunner::TestRunner(TestInterfaces* interfaces) | |
174 : m_testIsRunning(false) | |
175 , m_closeRemainingWindows(false) | |
176 , m_workQueue(this) | |
177 , m_testInterfaces(interfaces) | |
178 , m_delegate(0) | |
179 , m_webView(0) | |
180 , m_pageOverlay(0) | |
181 , m_webPermissions(new WebPermissions) | |
182 , notification_presenter_(new content::NotificationPresenter) | |
183 { | |
184 // Initialize the map that associates methods of this class with the names | |
185 // they will use when called by JavaScript. The actual binding of those | |
186 // names to their methods will be done by calling bindToJavaScript() (define
d | |
187 // by CppBoundClass, the parent to TestRunner). | |
188 | |
189 // Methods controlling test execution. | |
190 bindMethod("notifyDone", &TestRunner::notifyDone); | |
191 bindMethod("queueBackNavigation", &TestRunner::queueBackNavigation); | |
192 bindMethod("queueForwardNavigation", &TestRunner::queueForwardNavigation); | |
193 bindMethod("queueLoadingScript", &TestRunner::queueLoadingScript); | |
194 bindMethod("queueLoad", &TestRunner::queueLoad); | |
195 bindMethod("queueLoadHTMLString", &TestRunner::queueLoadHTMLString); | |
196 bindMethod("queueNonLoadingScript", &TestRunner::queueNonLoadingScript); | |
197 bindMethod("queueReload", &TestRunner::queueReload); | |
198 bindMethod("setCloseRemainingWindowsWhenComplete", &TestRunner::setCloseRema
iningWindowsWhenComplete); | |
199 bindMethod("resetTestHelperControllers", &TestRunner::resetTestHelperControl
lers); | |
200 bindMethod("setCustomPolicyDelegate", &TestRunner::setCustomPolicyDelegate); | |
201 bindMethod("waitForPolicyDelegate", &TestRunner::waitForPolicyDelegate); | |
202 bindMethod("waitUntilDone", &TestRunner::waitUntilDone); | |
203 bindMethod("windowCount", &TestRunner::windowCount); | |
204 // Methods implemented in terms of chromium's public WebKit API. | |
205 bindMethod("setTabKeyCyclesThroughElements", &TestRunner::setTabKeyCyclesThr
oughElements); | |
206 bindMethod("execCommand", &TestRunner::execCommand); | |
207 bindMethod("isCommandEnabled", &TestRunner::isCommandEnabled); | |
208 bindMethod("callShouldCloseOnWebView", &TestRunner::callShouldCloseOnWebView
); | |
209 bindMethod("setDomainRelaxationForbiddenForURLScheme", &TestRunner::setDomai
nRelaxationForbiddenForURLScheme); | |
210 bindMethod("evaluateScriptInIsolatedWorldAndReturnValue", &TestRunner::evalu
ateScriptInIsolatedWorldAndReturnValue); | |
211 bindMethod("evaluateScriptInIsolatedWorld", &TestRunner::evaluateScriptInIso
latedWorld); | |
212 bindMethod("setIsolatedWorldSecurityOrigin", &TestRunner::setIsolatedWorldSe
curityOrigin); | |
213 bindMethod("setIsolatedWorldContentSecurityPolicy", &TestRunner::setIsolated
WorldContentSecurityPolicy); | |
214 bindMethod("addOriginAccessWhitelistEntry", &TestRunner::addOriginAccessWhit
elistEntry); | |
215 bindMethod("removeOriginAccessWhitelistEntry", &TestRunner::removeOriginAcce
ssWhitelistEntry); | |
216 bindMethod("hasCustomPageSizeStyle", &TestRunner::hasCustomPageSizeStyle); | |
217 bindMethod("forceRedSelectionColors", &TestRunner::forceRedSelectionColors); | |
218 bindMethod("injectStyleSheet", &TestRunner::injectStyleSheet); | |
219 bindMethod("startSpeechInput", &TestRunner::startSpeechInput); | |
220 bindMethod("findString", &TestRunner::findString); | |
221 bindMethod("setValueForUser", &TestRunner::setValueForUser); | |
222 bindMethod("selectionAsMarkup", &TestRunner::selectionAsMarkup); | |
223 bindMethod("setTextSubpixelPositioning", &TestRunner::setTextSubpixelPositio
ning); | |
224 bindMethod("setPageVisibility", &TestRunner::setPageVisibility); | |
225 bindMethod("setTextDirection", &TestRunner::setTextDirection); | |
226 bindMethod("textSurroundingNode", &TestRunner::textSurroundingNode); | |
227 bindMethod("useUnfortunateSynchronousResizeMode", &TestRunner::useUnfortunat
eSynchronousResizeMode); | |
228 bindMethod("disableAutoResizeMode", &TestRunner::disableAutoResizeMode); | |
229 bindMethod("enableAutoResizeMode", &TestRunner::enableAutoResizeMode); | |
230 bindMethod("setMockDeviceMotion", &TestRunner::setMockDeviceMotion); | |
231 bindMethod("setMockDeviceOrientation", &TestRunner::setMockDeviceOrientation
); | |
232 bindMethod("didAcquirePointerLock", &TestRunner::didAcquirePointerLock); | |
233 bindMethod("didLosePointerLock", &TestRunner::didLosePointerLock); | |
234 bindMethod("didNotAcquirePointerLock", &TestRunner::didNotAcquirePointerLock
); | |
235 bindMethod("setPointerLockWillRespondAsynchronously", &TestRunner::setPointe
rLockWillRespondAsynchronously); | |
236 bindMethod("setPointerLockWillFailSynchronously", &TestRunner::setPointerLoc
kWillFailSynchronously); | |
237 | |
238 // The following modify WebPreferences. | |
239 bindMethod("setPopupBlockingEnabled", &TestRunner::setPopupBlockingEnabled); | |
240 bindMethod("setJavaScriptCanAccessClipboard", &TestRunner::setJavaScriptCanA
ccessClipboard); | |
241 bindMethod("setXSSAuditorEnabled", &TestRunner::setXSSAuditorEnabled); | |
242 bindMethod("setAllowUniversalAccessFromFileURLs", &TestRunner::setAllowUnive
rsalAccessFromFileURLs); | |
243 bindMethod("setAllowFileAccessFromFileURLs", &TestRunner::setAllowFileAccess
FromFileURLs); | |
244 bindMethod("overridePreference", &TestRunner::overridePreference); | |
245 bindMethod("setPluginsEnabled", &TestRunner::setPluginsEnabled); | |
246 | |
247 // The following modify the state of the TestRunner. | |
248 bindMethod("dumpEditingCallbacks", &TestRunner::dumpEditingCallbacks); | |
249 bindMethod("dumpAsText", &TestRunner::dumpAsText); | |
250 bindMethod("dumpAsTextWithPixelResults", &TestRunner::dumpAsTextWithPixelRes
ults); | |
251 bindMethod("dumpChildFramesAsText", &TestRunner::dumpChildFramesAsText); | |
252 bindMethod("dumpChildFrameScrollPositions", &TestRunner::dumpChildFrameScrol
lPositions); | |
253 bindMethod("dumpIconChanges", &TestRunner::dumpIconChanges); | |
254 bindMethod("setAudioData", &TestRunner::setAudioData); | |
255 bindMethod("dumpFrameLoadCallbacks", &TestRunner::dumpFrameLoadCallbacks); | |
256 bindMethod("dumpPingLoaderCallbacks", &TestRunner::dumpPingLoaderCallbacks); | |
257 bindMethod("dumpUserGestureInFrameLoadCallbacks", &TestRunner::dumpUserGestu
reInFrameLoadCallbacks); | |
258 bindMethod("dumpTitleChanges", &TestRunner::dumpTitleChanges); | |
259 bindMethod("dumpCreateView", &TestRunner::dumpCreateView); | |
260 bindMethod("setCanOpenWindows", &TestRunner::setCanOpenWindows); | |
261 bindMethod("dumpResourceLoadCallbacks", &TestRunner::dumpResourceLoadCallbac
ks); | |
262 bindMethod("dumpResourceRequestCallbacks", &TestRunner::dumpResourceRequestC
allbacks); | |
263 bindMethod("dumpResourceResponseMIMETypes", &TestRunner::dumpResourceRespons
eMIMETypes); | |
264 bindMethod("dumpPermissionClientCallbacks", &TestRunner::dumpPermissionClien
tCallbacks); | |
265 bindMethod("setImagesAllowed", &TestRunner::setImagesAllowed); | |
266 bindMethod("setScriptsAllowed", &TestRunner::setScriptsAllowed); | |
267 bindMethod("setStorageAllowed", &TestRunner::setStorageAllowed); | |
268 bindMethod("setPluginsAllowed", &TestRunner::setPluginsAllowed); | |
269 bindMethod("setAllowDisplayOfInsecureContent", &TestRunner::setAllowDisplayO
fInsecureContent); | |
270 bindMethod("setAllowRunningOfInsecureContent", &TestRunner::setAllowRunningO
fInsecureContent); | |
271 bindMethod("dumpStatusCallbacks", &TestRunner::dumpWindowStatusChanges); | |
272 bindMethod("dumpProgressFinishedCallback", &TestRunner::dumpProgressFinished
Callback); | |
273 bindMethod("dumpSpellCheckCallbacks", &TestRunner::dumpSpellCheckCallbacks); | |
274 bindMethod("dumpBackForwardList", &TestRunner::dumpBackForwardList); | |
275 bindMethod("dumpSelectionRect", &TestRunner::dumpSelectionRect); | |
276 bindMethod("testRepaint", &TestRunner::testRepaint); | |
277 bindMethod("repaintSweepHorizontally", &TestRunner::repaintSweepHorizontally
); | |
278 bindMethod("setPrinting", &TestRunner::setPrinting); | |
279 bindMethod("setShouldStayOnPageAfterHandlingBeforeUnload", &TestRunner::setS
houldStayOnPageAfterHandlingBeforeUnload); | |
280 bindMethod("setWillSendRequestClearHeader", &TestRunner::setWillSendRequestC
learHeader); | |
281 bindMethod("dumpResourceRequestPriorities", &TestRunner::dumpResourceRequest
Priorities); | |
282 bindMethod("setUseMockTheme", &TestRunner::setUseMockTheme); | |
283 | |
284 // The following methods interact with the WebTestProxy. | |
285 // The following methods interact with the WebTestDelegate. | |
286 bindMethod("showWebInspector", &TestRunner::showWebInspector); | |
287 bindMethod("closeWebInspector", &TestRunner::closeWebInspector); | |
288 bindMethod("evaluateInWebInspector", &TestRunner::evaluateInWebInspector); | |
289 bindMethod("clearAllDatabases", &TestRunner::clearAllDatabases); | |
290 bindMethod("setDatabaseQuota", &TestRunner::setDatabaseQuota); | |
291 bindMethod("setAlwaysAcceptCookies", &TestRunner::setAlwaysAcceptCookies); | |
292 bindMethod("setWindowIsKey", &TestRunner::setWindowIsKey); | |
293 bindMethod("pathToLocalResource", &TestRunner::pathToLocalResource); | |
294 bindMethod("setBackingScaleFactor", &TestRunner::setBackingScaleFactor); | |
295 bindMethod("setPOSIXLocale", &TestRunner::setPOSIXLocale); | |
296 bindMethod("setMIDIAccessorResult", &TestRunner::setMIDIAccessorResult); | |
297 bindMethod("setMIDISysExPermission", &TestRunner::setMIDISysExPermission); | |
298 bindMethod("grantWebNotificationPermission", &TestRunner::grantWebNotificati
onPermission); | |
299 bindMethod("simulateWebNotificationClick", &TestRunner::simulateWebNotificat
ionClick); | |
300 bindMethod("addMockSpeechInputResult", &TestRunner::addMockSpeechInputResult
); | |
301 bindMethod("setMockSpeechInputDumpRect", &TestRunner::setMockSpeechInputDump
Rect); | |
302 bindMethod("addMockSpeechRecognitionResult", &TestRunner::addMockSpeechRecog
nitionResult); | |
303 bindMethod("setMockSpeechRecognitionError", &TestRunner::setMockSpeechRecogn
itionError); | |
304 bindMethod("wasMockSpeechRecognitionAborted", &TestRunner::wasMockSpeechReco
gnitionAborted); | |
305 bindMethod("display", &TestRunner::display); | |
306 bindMethod("displayInvalidatedRegion", &TestRunner::displayInvalidatedRegion
); | |
307 bindMethod("isChooserShown", &TestRunner::isChooserShown); | |
308 | |
309 // The following modify WebPageOverlays. | |
310 bindMethod("addWebPageOverlay", &TestRunner::addWebPageOverlay); | |
311 bindMethod("removeWebPageOverlay", &TestRunner::removeWebPageOverlay); | |
312 | |
313 // Properties. | |
314 bindProperty("globalFlag", &m_globalFlag); | |
315 bindProperty("platformName", &m_platformName); | |
316 bindProperty("tooltipText", &m_tooltipText); | |
317 bindProperty("disableNotifyDone", &m_disableNotifyDone); | |
318 | |
319 // webHistoryItemCount is used by tests in LayoutTests\http\tests\history | |
320 bindProperty("webHistoryItemCount", &m_webHistoryItemCount); | |
321 bindProperty("interceptPostMessage", &m_interceptPostMessage); | |
322 | |
323 // The following are stubs. | |
324 bindMethod("dumpDatabaseCallbacks", &TestRunner::notImplemented); | |
325 bindMethod("setIconDatabaseEnabled", &TestRunner::notImplemented); | |
326 bindMethod("setScrollbarPolicy", &TestRunner::notImplemented); | |
327 bindMethod("clearAllApplicationCaches", &TestRunner::notImplemented); | |
328 bindMethod("clearApplicationCacheForOrigin", &TestRunner::notImplemented); | |
329 bindMethod("clearBackForwardList", &TestRunner::notImplemented); | |
330 bindMethod("keepWebHistory", &TestRunner::notImplemented); | |
331 bindMethod("setApplicationCacheOriginQuota", &TestRunner::notImplemented); | |
332 bindMethod("setCallCloseOnWebViews", &TestRunner::notImplemented); | |
333 bindMethod("setMainFrameIsFirstResponder", &TestRunner::notImplemented); | |
334 bindMethod("setUseDashboardCompatibilityMode", &TestRunner::notImplemented); | |
335 bindMethod("deleteAllLocalStorage", &TestRunner::notImplemented); | |
336 bindMethod("localStorageDiskUsageForOrigin", &TestRunner::notImplemented); | |
337 bindMethod("originsWithLocalStorage", &TestRunner::notImplemented); | |
338 bindMethod("deleteLocalStorageForOrigin", &TestRunner::notImplemented); | |
339 bindMethod("observeStorageTrackerNotifications", &TestRunner::notImplemented
); | |
340 bindMethod("syncLocalStorage", &TestRunner::notImplemented); | |
341 bindMethod("addDisallowedURL", &TestRunner::notImplemented); | |
342 bindMethod("applicationCacheDiskUsageForOrigin", &TestRunner::notImplemented
); | |
343 bindMethod("abortModal", &TestRunner::notImplemented); | |
344 | |
345 // The fallback method is called when an unknown method is invoked. | |
346 bindFallbackMethod(&TestRunner::fallbackMethod); | |
347 } | |
348 | |
349 TestRunner::~TestRunner() | |
350 { | |
351 } | |
352 | |
353 void TestRunner::setDelegate(WebTestDelegate* delegate) | |
354 { | |
355 m_delegate = delegate; | |
356 m_webPermissions->setDelegate(delegate); | |
357 notification_presenter_->set_delegate(delegate); | |
358 } | |
359 | |
360 void TestRunner::setWebView(WebView* webView, WebTestProxyBase* proxy) | |
361 { | |
362 m_webView = webView; | |
363 m_proxy = proxy; | |
364 } | |
365 | |
366 void TestRunner::reset() | |
367 { | |
368 if (m_webView) { | |
369 m_webView->setZoomLevel(0); | |
370 m_webView->setTextZoomFactor(1); | |
371 m_webView->setTabKeyCyclesThroughElements(true); | |
372 #if !defined(__APPLE__) && !defined(WIN32) // Actually, TOOLKIT_GTK | |
373 // (Constants copied because we can't depend on the header that defined | |
374 // them from this file.) | |
375 m_webView->setSelectionColors(0xff1e90ff, 0xff000000, 0xffc8c8c8, 0xff32
3232); | |
376 #endif | |
377 m_webView->removeInjectedStyleSheets(); | |
378 m_webView->setVisibilityState(WebPageVisibilityStateVisible, true); | |
379 m_webView->mainFrame()->enableViewSourceMode(false); | |
380 | |
381 if (m_pageOverlay) { | |
382 m_webView->removePageOverlay(m_pageOverlay); | |
383 delete m_pageOverlay; | |
384 m_pageOverlay = 0; | |
385 } | |
386 } | |
387 | |
388 m_topLoadingFrame = 0; | |
389 m_waitUntilDone = false; | |
390 m_policyDelegateEnabled = false; | |
391 m_policyDelegateIsPermissive = false; | |
392 m_policyDelegateShouldNotifyDone = false; | |
393 | |
394 WebSecurityPolicy::resetOriginAccessWhitelists(); | |
395 #if defined(__linux__) || defined(ANDROID) | |
396 WebFontRendering::setSubpixelPositioning(false); | |
397 #endif | |
398 | |
399 if (m_delegate) { | |
400 // Reset the default quota for each origin to 5MB | |
401 m_delegate->setDatabaseQuota(5 * 1024 * 1024); | |
402 m_delegate->setDeviceScaleFactor(1); | |
403 m_delegate->setAcceptAllCookies(false); | |
404 m_delegate->setLocale(""); | |
405 m_delegate->useUnfortunateSynchronousResizeMode(false); | |
406 m_delegate->disableAutoResizeMode(WebSize()); | |
407 m_delegate->deleteAllCookies(); | |
408 } | |
409 | |
410 m_dumpEditingCallbacks = false; | |
411 m_dumpAsText = false; | |
412 m_dumpAsMarkup = false; | |
413 m_generatePixelResults = true; | |
414 m_dumpChildFrameScrollPositions = false; | |
415 m_dumpChildFramesAsText = false; | |
416 m_dumpIconChanges = false; | |
417 m_dumpAsAudio = false; | |
418 m_dumpFrameLoadCallbacks = false; | |
419 m_dumpPingLoaderCallbacks = false; | |
420 m_dumpUserGestureInFrameLoadCallbacks = false; | |
421 m_dumpTitleChanges = false; | |
422 m_dumpCreateView = false; | |
423 m_canOpenWindows = false; | |
424 m_dumpResourceLoadCallbacks = false; | |
425 m_dumpResourceRequestCallbacks = false; | |
426 m_dumpResourceResponseMIMETypes = false; | |
427 m_dumpWindowStatusChanges = false; | |
428 m_dumpProgressFinishedCallback = false; | |
429 m_dumpSpellCheckCallbacks = false; | |
430 m_dumpBackForwardList = false; | |
431 m_dumpSelectionRect = false; | |
432 m_testRepaint = false; | |
433 m_sweepHorizontally = false; | |
434 m_isPrinting = false; | |
435 m_midiAccessorResult = true; | |
436 m_shouldStayOnPageAfterHandlingBeforeUnload = false; | |
437 m_shouldDumpResourcePriorities = false; | |
438 | |
439 m_httpHeadersToClear.clear(); | |
440 | |
441 m_globalFlag.set(false); | |
442 m_webHistoryItemCount.set(0); | |
443 m_interceptPostMessage.set(false); | |
444 m_platformName.set("chromium"); | |
445 m_tooltipText.set(""); | |
446 m_disableNotifyDone.set(false); | |
447 | |
448 m_webPermissions->reset(); | |
449 | |
450 notification_presenter_->Reset(); | |
451 m_useMockTheme = true; | |
452 m_pointerLocked = false; | |
453 m_pointerLockPlannedResult = PointerLockWillSucceed; | |
454 | |
455 m_taskList.revokeAll(); | |
456 m_workQueue.reset(); | |
457 | |
458 if (m_closeRemainingWindows && m_delegate) | |
459 m_delegate->closeRemainingWindows(); | |
460 else | |
461 m_closeRemainingWindows = true; | |
462 } | |
463 | |
464 | |
465 void TestRunner::setTestIsRunning(bool running) | |
466 { | |
467 m_testIsRunning = running; | |
468 } | |
469 | |
470 bool TestRunner::shouldDumpEditingCallbacks() const | |
471 { | |
472 return m_dumpEditingCallbacks; | |
473 } | |
474 | |
475 void TestRunner::checkResponseMimeType() | |
476 { | |
477 // Text output: the test page can request different types of output | |
478 // which we handle here. | |
479 if (!m_dumpAsText) { | |
480 string mimeType = m_webView->mainFrame()->dataSource()->response().mimeT
ype().utf8(); | |
481 if (mimeType == "text/plain") { | |
482 m_dumpAsText = true; | |
483 m_generatePixelResults = false; | |
484 } | |
485 } | |
486 } | |
487 | |
488 bool TestRunner::shouldDumpAsText() | |
489 { | |
490 checkResponseMimeType(); | |
491 return m_dumpAsText; | |
492 } | |
493 | |
494 void TestRunner::setShouldDumpAsText(bool value) | |
495 { | |
496 m_dumpAsText = value; | |
497 } | |
498 | |
499 bool TestRunner::shouldDumpAsMarkup() | |
500 { | |
501 return m_dumpAsMarkup; | |
502 } | |
503 | |
504 void TestRunner::setShouldDumpAsMarkup(bool value) | |
505 { | |
506 m_dumpAsMarkup = value; | |
507 } | |
508 | |
509 bool TestRunner::shouldGeneratePixelResults() | |
510 { | |
511 checkResponseMimeType(); | |
512 return m_generatePixelResults; | |
513 } | |
514 | |
515 void TestRunner::setShouldGeneratePixelResults(bool value) | |
516 { | |
517 m_generatePixelResults = value; | |
518 } | |
519 | |
520 bool TestRunner::shouldDumpChildFrameScrollPositions() const | |
521 { | |
522 return m_dumpChildFrameScrollPositions; | |
523 } | |
524 | |
525 bool TestRunner::shouldDumpChildFramesAsText() const | |
526 { | |
527 return m_dumpChildFramesAsText; | |
528 } | |
529 | |
530 bool TestRunner::shouldDumpAsAudio() const | |
531 { | |
532 return m_dumpAsAudio; | |
533 } | |
534 | |
535 const WebArrayBufferView* TestRunner::audioData() const | |
536 { | |
537 return &m_audioData; | |
538 } | |
539 | |
540 bool TestRunner::shouldDumpFrameLoadCallbacks() const | |
541 { | |
542 return m_testIsRunning && m_dumpFrameLoadCallbacks; | |
543 } | |
544 | |
545 void TestRunner::setShouldDumpFrameLoadCallbacks(bool value) | |
546 { | |
547 m_dumpFrameLoadCallbacks = value; | |
548 } | |
549 | |
550 bool TestRunner::shouldDumpPingLoaderCallbacks() const | |
551 { | |
552 return m_testIsRunning && m_dumpPingLoaderCallbacks; | |
553 } | |
554 | |
555 void TestRunner::setShouldDumpPingLoaderCallbacks(bool value) | |
556 { | |
557 m_dumpPingLoaderCallbacks = value; | |
558 } | |
559 | |
560 void TestRunner::setShouldEnableViewSource(bool value) | |
561 { | |
562 m_webView->mainFrame()->enableViewSourceMode(value); | |
563 } | |
564 | |
565 bool TestRunner::shouldDumpUserGestureInFrameLoadCallbacks() const | |
566 { | |
567 return m_testIsRunning && m_dumpUserGestureInFrameLoadCallbacks; | |
568 } | |
569 | |
570 bool TestRunner::shouldDumpTitleChanges() const | |
571 { | |
572 return m_dumpTitleChanges; | |
573 } | |
574 | |
575 bool TestRunner::shouldDumpIconChanges() const | |
576 { | |
577 return m_dumpIconChanges; | |
578 } | |
579 | |
580 bool TestRunner::shouldDumpCreateView() const | |
581 { | |
582 return m_dumpCreateView; | |
583 } | |
584 | |
585 bool TestRunner::canOpenWindows() const | |
586 { | |
587 return m_canOpenWindows; | |
588 } | |
589 | |
590 bool TestRunner::shouldDumpResourceLoadCallbacks() const | |
591 { | |
592 return m_testIsRunning && m_dumpResourceLoadCallbacks; | |
593 } | |
594 | |
595 bool TestRunner::shouldDumpResourceRequestCallbacks() const | |
596 { | |
597 return m_testIsRunning && m_dumpResourceRequestCallbacks; | |
598 } | |
599 | |
600 bool TestRunner::shouldDumpResourceResponseMIMETypes() const | |
601 { | |
602 return m_testIsRunning && m_dumpResourceResponseMIMETypes; | |
603 } | |
604 | |
605 WebPermissionClient* TestRunner::webPermissions() const | |
606 { | |
607 return m_webPermissions.get(); | |
608 } | |
609 | |
610 bool TestRunner::shouldDumpStatusCallbacks() const | |
611 { | |
612 return m_dumpWindowStatusChanges; | |
613 } | |
614 | |
615 bool TestRunner::shouldDumpProgressFinishedCallback() const | |
616 { | |
617 return m_dumpProgressFinishedCallback; | |
618 } | |
619 | |
620 bool TestRunner::shouldDumpSpellCheckCallbacks() const | |
621 { | |
622 return m_dumpSpellCheckCallbacks; | |
623 } | |
624 | |
625 bool TestRunner::shouldDumpBackForwardList() const | |
626 { | |
627 return m_dumpBackForwardList; | |
628 } | |
629 | |
630 bool TestRunner::shouldDumpSelectionRect() const | |
631 { | |
632 return m_dumpSelectionRect; | |
633 } | |
634 | |
635 bool TestRunner::testRepaint() const | |
636 { | |
637 return m_testRepaint; | |
638 } | |
639 | |
640 bool TestRunner::sweepHorizontally() const | |
641 { | |
642 return m_sweepHorizontally; | |
643 } | |
644 | |
645 bool TestRunner::isPrinting() const | |
646 { | |
647 return m_isPrinting; | |
648 } | |
649 | |
650 bool TestRunner::shouldStayOnPageAfterHandlingBeforeUnload() const | |
651 { | |
652 return m_shouldStayOnPageAfterHandlingBeforeUnload; | |
653 } | |
654 | |
655 const std::set<std::string>* TestRunner::httpHeadersToClear() const | |
656 { | |
657 return &m_httpHeadersToClear; | |
658 } | |
659 | |
660 void TestRunner::setTopLoadingFrame(WebFrame* frame, bool clear) | |
661 { | |
662 if (frame->top()->view() != m_webView) | |
663 return; | |
664 if (!m_testIsRunning) | |
665 return; | |
666 if (clear) { | |
667 m_topLoadingFrame = 0; | |
668 locationChangeDone(); | |
669 } else if (!m_topLoadingFrame) | |
670 m_topLoadingFrame = frame; | |
671 } | |
672 | |
673 WebFrame* TestRunner::topLoadingFrame() const | |
674 { | |
675 return m_topLoadingFrame; | |
676 } | |
677 | |
678 void TestRunner::policyDelegateDone() | |
679 { | |
680 BLINK_ASSERT(m_waitUntilDone); | |
681 m_delegate->testFinished(); | |
682 m_waitUntilDone = false; | |
683 } | |
684 | |
685 bool TestRunner::policyDelegateEnabled() const | |
686 { | |
687 return m_policyDelegateEnabled; | |
688 } | |
689 | |
690 bool TestRunner::policyDelegateIsPermissive() const | |
691 { | |
692 return m_policyDelegateIsPermissive; | |
693 } | |
694 | |
695 bool TestRunner::policyDelegateShouldNotifyDone() const | |
696 { | |
697 return m_policyDelegateShouldNotifyDone; | |
698 } | |
699 | |
700 bool TestRunner::shouldInterceptPostMessage() const | |
701 { | |
702 return m_interceptPostMessage.isBool() && m_interceptPostMessage.toBoolean()
; | |
703 } | |
704 | |
705 bool TestRunner::shouldDumpResourcePriorities() const | |
706 { | |
707 return m_shouldDumpResourcePriorities; | |
708 } | |
709 | |
710 WebNotificationPresenter* TestRunner::notification_presenter() const | |
711 { | |
712 return notification_presenter_.get(); | |
713 } | |
714 | |
715 bool TestRunner::requestPointerLock() | |
716 { | |
717 switch (m_pointerLockPlannedResult) { | |
718 case PointerLockWillSucceed: | |
719 m_delegate->postDelayedTask(new HostMethodTask(this, &TestRunner::didAcq
uirePointerLockInternal), 0); | |
720 return true; | |
721 case PointerLockWillRespondAsync: | |
722 BLINK_ASSERT(!m_pointerLocked); | |
723 return true; | |
724 case PointerLockWillFailSync: | |
725 BLINK_ASSERT(!m_pointerLocked); | |
726 return false; | |
727 default: | |
728 BLINK_ASSERT_NOT_REACHED(); | |
729 return false; | |
730 } | |
731 } | |
732 | |
733 void TestRunner::requestPointerUnlock() | |
734 { | |
735 m_delegate->postDelayedTask(new HostMethodTask(this, &TestRunner::didLosePoi
nterLockInternal), 0); | |
736 } | |
737 | |
738 bool TestRunner::isPointerLocked() | |
739 { | |
740 return m_pointerLocked; | |
741 } | |
742 | |
743 void TestRunner::setToolTipText(const blink::WebString& text) | |
744 { | |
745 m_tooltipText.set(text.utf8()); | |
746 } | |
747 | |
748 bool TestRunner::midiAccessorResult() | |
749 { | |
750 return m_midiAccessorResult; | |
751 } | |
752 | |
753 TestRunner::TestPageOverlay::TestPageOverlay(blink::WebView* webView) : m_webVie
w(webView) | |
754 { | |
755 } | |
756 | |
757 TestRunner::TestPageOverlay::~TestPageOverlay() | |
758 { | |
759 } | |
760 | |
761 void TestRunner::TestPageOverlay::paintPageOverlay(blink::WebCanvas* canvas) | |
762 { | |
763 SkRect rect = SkRect::MakeWH(m_webView->size().width, m_webView->size().heig
ht); | |
764 SkPaint paint; | |
765 paint.setColor(SK_ColorCYAN); | |
766 paint.setStyle(SkPaint::kFill_Style); | |
767 canvas->drawRect(rect, paint); | |
768 } | |
769 | |
770 void TestRunner::didAcquirePointerLockInternal() | |
771 { | |
772 m_pointerLocked = true; | |
773 m_webView->didAcquirePointerLock(); | |
774 | |
775 // Reset planned result to default. | |
776 m_pointerLockPlannedResult = PointerLockWillSucceed; | |
777 } | |
778 | |
779 void TestRunner::didNotAcquirePointerLockInternal() | |
780 { | |
781 BLINK_ASSERT(!m_pointerLocked); | |
782 m_pointerLocked = false; | |
783 m_webView->didNotAcquirePointerLock(); | |
784 | |
785 // Reset planned result to default. | |
786 m_pointerLockPlannedResult = PointerLockWillSucceed; | |
787 } | |
788 | |
789 void TestRunner::didLosePointerLockInternal() | |
790 { | |
791 bool wasLocked = m_pointerLocked; | |
792 m_pointerLocked = false; | |
793 if (wasLocked) | |
794 m_webView->didLosePointerLock(); | |
795 } | |
796 | |
797 void TestRunner::clearDevToolsLocalStorage() | |
798 { | |
799 m_delegate->clearDevToolsLocalStorage(); | |
800 } | |
801 | |
802 void TestRunner::showDevTools(const std::string& settings) | |
803 { | |
804 m_delegate->showDevTools(settings); | |
805 } | |
806 | |
807 void TestRunner::waitUntilDone(const CppArgumentList&, CppVariant* result) | |
808 { | |
809 m_waitUntilDone = true; | |
810 result->setNull(); | |
811 } | |
812 | |
813 void TestRunner::notifyDone(const CppArgumentList&, CppVariant* result) | |
814 { | |
815 if (m_disableNotifyDone.toBoolean()) | |
816 return; | |
817 | |
818 // Test didn't timeout. Kill the timeout timer. | |
819 taskList()->revokeAll(); | |
820 | |
821 completeNotifyDone(); | |
822 result->setNull(); | |
823 } | |
824 | |
825 void TestRunner::completeNotifyDone() | |
826 { | |
827 if (m_waitUntilDone && !topLoadingFrame() && m_workQueue.isEmpty()) | |
828 m_delegate->testFinished(); | |
829 m_waitUntilDone = false; | |
830 } | |
831 | |
832 class WorkItemBackForward : public TestRunner::WorkItem { | |
833 public: | |
834 WorkItemBackForward(int distance) : m_distance(distance) { } | |
835 virtual bool run(WebTestDelegate* delegate, WebView*) OVERRIDE | |
836 { | |
837 delegate->goToOffset(m_distance); | |
838 return true; // FIXME: Did it really start a navigation? | |
839 } | |
840 | |
841 private: | |
842 int m_distance; | |
843 }; | |
844 | |
845 void TestRunner::queueBackNavigation(const CppArgumentList& arguments, CppVarian
t* result) | |
846 { | |
847 if (arguments.size() > 0 && arguments[0].isNumber()) | |
848 m_workQueue.addWork(new WorkItemBackForward(-arguments[0].toInt32())); | |
849 result->setNull(); | |
850 } | |
851 | |
852 void TestRunner::queueForwardNavigation(const CppArgumentList& arguments, CppVar
iant* result) | |
853 { | |
854 if (arguments.size() > 0 && arguments[0].isNumber()) | |
855 m_workQueue.addWork(new WorkItemBackForward(arguments[0].toInt32())); | |
856 result->setNull(); | |
857 } | |
858 | |
859 class WorkItemReload : public TestRunner::WorkItem { | |
860 public: | |
861 virtual bool run(WebTestDelegate* delegate, WebView*) OVERRIDE | |
862 { | |
863 delegate->reload(); | |
864 return true; | |
865 } | |
866 }; | |
867 | |
868 void TestRunner::queueReload(const CppArgumentList&, CppVariant* result) | |
869 { | |
870 m_workQueue.addWork(new WorkItemReload); | |
871 result->setNull(); | |
872 } | |
873 | |
874 class WorkItemLoadingScript : public TestRunner::WorkItem { | |
875 public: | |
876 WorkItemLoadingScript(const string& script) : m_script(script) { } | |
877 virtual bool run(WebTestDelegate*, WebView* webView) OVERRIDE | |
878 { | |
879 webView->mainFrame()->executeScript(WebScriptSource(WebString::fromUTF8(
m_script))); | |
880 return true; // FIXME: Did it really start a navigation? | |
881 } | |
882 | |
883 private: | |
884 string m_script; | |
885 }; | |
886 | |
887 class WorkItemNonLoadingScript : public TestRunner::WorkItem { | |
888 public: | |
889 WorkItemNonLoadingScript(const string& script) : m_script(script) { } | |
890 virtual bool run(WebTestDelegate*, WebView* webView) OVERRIDE | |
891 { | |
892 webView->mainFrame()->executeScript(WebScriptSource(WebString::fromUTF8(
m_script))); | |
893 return false; | |
894 } | |
895 | |
896 private: | |
897 string m_script; | |
898 }; | |
899 | |
900 void TestRunner::queueLoadingScript(const CppArgumentList& arguments, CppVariant
* result) | |
901 { | |
902 if (arguments.size() > 0 && arguments[0].isString()) | |
903 m_workQueue.addWork(new WorkItemLoadingScript(arguments[0].toString())); | |
904 result->setNull(); | |
905 } | |
906 | |
907 void TestRunner::queueNonLoadingScript(const CppArgumentList& arguments, CppVari
ant* result) | |
908 { | |
909 if (arguments.size() > 0 && arguments[0].isString()) | |
910 m_workQueue.addWork(new WorkItemNonLoadingScript(arguments[0].toString()
)); | |
911 result->setNull(); | |
912 } | |
913 | |
914 class WorkItemLoad : public TestRunner::WorkItem { | |
915 public: | |
916 WorkItemLoad(const WebURL& url, const string& target) | |
917 : m_url(url) | |
918 , m_target(target) { } | |
919 virtual bool run(WebTestDelegate* delegate, WebView*) OVERRIDE | |
920 { | |
921 delegate->loadURLForFrame(m_url, m_target); | |
922 return true; // FIXME: Did it really start a navigation? | |
923 } | |
924 | |
925 private: | |
926 WebURL m_url; | |
927 string m_target; | |
928 }; | |
929 | |
930 void TestRunner::queueLoad(const CppArgumentList& arguments, CppVariant* result) | |
931 { | |
932 if (arguments.size() > 0 && arguments[0].isString()) { | |
933 // FIXME: Implement WebURL::resolve() and avoid GURL. | |
934 GURL currentURL = m_webView->mainFrame()->document().url(); | |
935 GURL fullURL = currentURL.Resolve(arguments[0].toString()); | |
936 | |
937 string target = ""; | |
938 if (arguments.size() > 1 && arguments[1].isString()) | |
939 target = arguments[1].toString(); | |
940 | |
941 m_workQueue.addWork(new WorkItemLoad(fullURL, target)); | |
942 } | |
943 result->setNull(); | |
944 } | |
945 | |
946 class WorkItemLoadHTMLString : public TestRunner::WorkItem { | |
947 public: | |
948 WorkItemLoadHTMLString(const std::string& html, const WebURL& baseURL) | |
949 : m_html(html) | |
950 , m_baseURL(baseURL) { } | |
951 WorkItemLoadHTMLString(const std::string& html, const WebURL& baseURL, const
WebURL& unreachableURL) | |
952 : m_html(html) | |
953 , m_baseURL(baseURL) | |
954 , m_unreachableURL(unreachableURL) { } | |
955 virtual bool run(WebTestDelegate*, WebView* webView) OVERRIDE | |
956 { | |
957 webView->mainFrame()->loadHTMLString( | |
958 blink::WebData(m_html.data(), m_html.length()), m_baseURL, m_unreach
ableURL); | |
959 return true; | |
960 } | |
961 | |
962 private: | |
963 std::string m_html; | |
964 WebURL m_baseURL; | |
965 WebURL m_unreachableURL; | |
966 }; | |
967 | |
968 void TestRunner::queueLoadHTMLString(const CppArgumentList& arguments, CppVarian
t* result) | |
969 { | |
970 if (arguments.size() > 0 && arguments[0].isString()) { | |
971 string html = arguments[0].toString(); | |
972 WebURL baseURL(GURL("")); | |
973 if (arguments.size() > 1 && arguments[1].isString()) | |
974 baseURL = WebURL(GURL(arguments[1].toString())); | |
975 if (arguments.size() > 2 && arguments[2].isString()) | |
976 m_workQueue.addWork(new WorkItemLoadHTMLString(html, baseURL, WebURL
(GURL(arguments[2].toString())))); | |
977 else | |
978 m_workQueue.addWork(new WorkItemLoadHTMLString(html, baseURL)); | |
979 } | |
980 result->setNull(); | |
981 } | |
982 | |
983 void TestRunner::locationChangeDone() | |
984 { | |
985 m_webHistoryItemCount.set(m_delegate->navigationEntryCount()); | |
986 | |
987 // No more new work after the first complete load. | |
988 m_workQueue.setFrozen(true); | |
989 | |
990 if (!m_waitUntilDone) | |
991 m_workQueue.processWorkSoon(); | |
992 } | |
993 | |
994 void TestRunner::windowCount(const CppArgumentList&, CppVariant* result) | |
995 { | |
996 result->set(static_cast<int>(m_testInterfaces->windowList().size())); | |
997 } | |
998 | |
999 void TestRunner::setCloseRemainingWindowsWhenComplete(const CppArgumentList& arg
uments, CppVariant* result) | |
1000 { | |
1001 if (arguments.size() > 0 && arguments[0].isBool()) | |
1002 m_closeRemainingWindows = arguments[0].value.boolValue; | |
1003 result->setNull(); | |
1004 } | |
1005 | |
1006 void TestRunner::resetTestHelperControllers(const CppArgumentList& arguments, Cp
pVariant* result) | |
1007 { | |
1008 m_testInterfaces->resetTestHelperControllers(); | |
1009 | |
1010 result->setNull(); | |
1011 } | |
1012 | |
1013 void TestRunner::setCustomPolicyDelegate(const CppArgumentList& arguments, CppVa
riant* result) | |
1014 { | |
1015 if (arguments.size() > 0 && arguments[0].isBool()) { | |
1016 m_policyDelegateEnabled = arguments[0].value.boolValue; | |
1017 m_policyDelegateIsPermissive = false; | |
1018 if (arguments.size() > 1 && arguments[1].isBool()) | |
1019 m_policyDelegateIsPermissive = arguments[1].value.boolValue; | |
1020 } | |
1021 result->setNull(); | |
1022 } | |
1023 | |
1024 void TestRunner::waitForPolicyDelegate(const CppArgumentList&, CppVariant* resul
t) | |
1025 { | |
1026 m_policyDelegateEnabled = true; | |
1027 m_policyDelegateShouldNotifyDone = true; | |
1028 m_waitUntilDone = true; | |
1029 result->setNull(); | |
1030 } | |
1031 | |
1032 void TestRunner::dumpPermissionClientCallbacks(const CppArgumentList&, CppVarian
t* result) | |
1033 { | |
1034 m_webPermissions->setDumpCallbacks(true); | |
1035 result->setNull(); | |
1036 } | |
1037 | |
1038 void TestRunner::setImagesAllowed(const CppArgumentList& arguments, CppVariant*
result) | |
1039 { | |
1040 if (arguments.size() > 0 && arguments[0].isBool()) | |
1041 m_webPermissions->setImagesAllowed(arguments[0].toBoolean()); | |
1042 result->setNull(); | |
1043 } | |
1044 | |
1045 void TestRunner::setScriptsAllowed(const CppArgumentList& arguments, CppVariant*
result) | |
1046 { | |
1047 if (arguments.size() > 0 && arguments[0].isBool()) | |
1048 m_webPermissions->setScriptsAllowed(arguments[0].toBoolean()); | |
1049 result->setNull(); | |
1050 } | |
1051 | |
1052 void TestRunner::setStorageAllowed(const CppArgumentList& arguments, CppVariant*
result) | |
1053 { | |
1054 if (arguments.size() > 0 && arguments[0].isBool()) | |
1055 m_webPermissions->setStorageAllowed(arguments[0].toBoolean()); | |
1056 result->setNull(); | |
1057 } | |
1058 | |
1059 void TestRunner::setPluginsAllowed(const CppArgumentList& arguments, CppVariant*
result) | |
1060 { | |
1061 if (arguments.size() > 0 && arguments[0].isBool()) | |
1062 m_webPermissions->setPluginsAllowed(arguments[0].toBoolean()); | |
1063 result->setNull(); | |
1064 } | |
1065 | |
1066 void TestRunner::setAllowDisplayOfInsecureContent(const CppArgumentList& argumen
ts, CppVariant* result) | |
1067 { | |
1068 if (arguments.size() > 0 && arguments[0].isBool()) | |
1069 m_webPermissions->setDisplayingInsecureContentAllowed(arguments[0].toBoo
lean()); | |
1070 | |
1071 result->setNull(); | |
1072 } | |
1073 | |
1074 void TestRunner::setAllowRunningOfInsecureContent(const CppArgumentList& argumen
ts, CppVariant* result) | |
1075 { | |
1076 if (arguments.size() > 0 && arguments[0].isBool()) | |
1077 m_webPermissions->setRunningInsecureContentAllowed(arguments[0].value.bo
olValue); | |
1078 | |
1079 result->setNull(); | |
1080 } | |
1081 | |
1082 void TestRunner::dumpWindowStatusChanges(const CppArgumentList&, CppVariant* res
ult) | |
1083 { | |
1084 m_dumpWindowStatusChanges = true; | |
1085 result->setNull(); | |
1086 } | |
1087 | |
1088 void TestRunner::dumpProgressFinishedCallback(const CppArgumentList&, CppVariant
* result) | |
1089 { | |
1090 m_dumpProgressFinishedCallback = true; | |
1091 result->setNull(); | |
1092 } | |
1093 | |
1094 void TestRunner::dumpSpellCheckCallbacks(const CppArgumentList&, CppVariant* res
ult) | |
1095 { | |
1096 m_dumpSpellCheckCallbacks = true; | |
1097 result->setNull(); | |
1098 } | |
1099 | |
1100 void TestRunner::dumpBackForwardList(const CppArgumentList&, CppVariant* result) | |
1101 { | |
1102 m_dumpBackForwardList = true; | |
1103 result->setNull(); | |
1104 } | |
1105 | |
1106 void TestRunner::dumpSelectionRect(const CppArgumentList& arguments, CppVariant*
result) | |
1107 { | |
1108 m_dumpSelectionRect = true; | |
1109 result->setNull(); | |
1110 } | |
1111 | |
1112 void TestRunner::testRepaint(const CppArgumentList&, CppVariant* result) | |
1113 { | |
1114 m_testRepaint = true; | |
1115 result->setNull(); | |
1116 } | |
1117 | |
1118 void TestRunner::repaintSweepHorizontally(const CppArgumentList&, CppVariant* re
sult) | |
1119 { | |
1120 m_sweepHorizontally = true; | |
1121 result->setNull(); | |
1122 } | |
1123 | |
1124 void TestRunner::setPrinting(const CppArgumentList& arguments, CppVariant* resul
t) | |
1125 { | |
1126 m_isPrinting = true; | |
1127 result->setNull(); | |
1128 } | |
1129 | |
1130 void TestRunner::setShouldStayOnPageAfterHandlingBeforeUnload(const CppArgumentL
ist& arguments, CppVariant* result) | |
1131 { | |
1132 if (arguments.size() == 1 && arguments[0].isBool()) | |
1133 m_shouldStayOnPageAfterHandlingBeforeUnload = arguments[0].toBoolean(); | |
1134 | |
1135 result->setNull(); | |
1136 } | |
1137 | |
1138 void TestRunner::setWillSendRequestClearHeader(const CppArgumentList& arguments,
CppVariant* result) | |
1139 { | |
1140 if (arguments.size() > 0 && arguments[0].isString()) { | |
1141 string header = arguments[0].toString(); | |
1142 if (!header.empty()) | |
1143 m_httpHeadersToClear.insert(header); | |
1144 } | |
1145 result->setNull(); | |
1146 } | |
1147 | |
1148 void TestRunner::setTabKeyCyclesThroughElements(const CppArgumentList& arguments
, CppVariant* result) | |
1149 { | |
1150 if (arguments.size() > 0 && arguments[0].isBool()) | |
1151 m_webView->setTabKeyCyclesThroughElements(arguments[0].toBoolean()); | |
1152 result->setNull(); | |
1153 } | |
1154 | |
1155 void TestRunner::execCommand(const CppArgumentList& arguments, CppVariant* resul
t) | |
1156 { | |
1157 result->setNull(); | |
1158 if (arguments.size() <= 0 || !arguments[0].isString()) | |
1159 return; | |
1160 | |
1161 std::string command = arguments[0].toString(); | |
1162 std::string value(""); | |
1163 // Ignore the second parameter (which is userInterface) | |
1164 // since this command emulates a manual action. | |
1165 if (arguments.size() >= 3 && arguments[2].isString()) | |
1166 value = arguments[2].toString(); | |
1167 | |
1168 // Note: webkit's version does not return the boolean, so neither do we. | |
1169 m_webView->focusedFrame()->executeCommand(WebString::fromUTF8(command), WebS
tring::fromUTF8(value)); | |
1170 } | |
1171 | |
1172 void TestRunner::isCommandEnabled(const CppArgumentList& arguments, CppVariant*
result) | |
1173 { | |
1174 if (arguments.size() <= 0 || !arguments[0].isString()) { | |
1175 result->setNull(); | |
1176 return; | |
1177 } | |
1178 | |
1179 std::string command = arguments[0].toString(); | |
1180 bool rv = m_webView->focusedFrame()->isCommandEnabled(WebString::fromUTF8(co
mmand)); | |
1181 result->set(rv); | |
1182 } | |
1183 | |
1184 void TestRunner::callShouldCloseOnWebView(const CppArgumentList&, CppVariant* re
sult) | |
1185 { | |
1186 result->set(m_webView->dispatchBeforeUnloadEvent()); | |
1187 } | |
1188 | |
1189 void TestRunner::setDomainRelaxationForbiddenForURLScheme(const CppArgumentList&
arguments, CppVariant* result) | |
1190 { | |
1191 if (arguments.size() != 2 || !arguments[0].isBool() || !arguments[1].isStrin
g()) | |
1192 return; | |
1193 m_webView->setDomainRelaxationForbidden(cppVariantToBool(arguments[0]), cppV
ariantToWebString(arguments[1])); | |
1194 } | |
1195 | |
1196 void TestRunner::evaluateScriptInIsolatedWorldAndReturnValue(const CppArgumentLi
st& arguments, CppVariant* result) | |
1197 { | |
1198 v8::HandleScope scope(v8::Isolate::GetCurrent()); | |
1199 WebVector<v8::Local<v8::Value> > values; | |
1200 if (arguments.size() >= 2 && arguments[0].isNumber() && arguments[1].isStrin
g()) { | |
1201 WebScriptSource source(cppVariantToWebString(arguments[1])); | |
1202 // This relies on the iframe focusing itself when it loads. This is a bi
t | |
1203 // sketchy, but it seems to be what other tests do. | |
1204 m_webView->focusedFrame()->executeScriptInIsolatedWorld(arguments[0].toI
nt32(), &source, 1, 1, &values); | |
1205 } | |
1206 result->setNull(); | |
1207 // Since only one script was added, only one result is expected | |
1208 if (values.size() == 1 && !values[0].IsEmpty()) { | |
1209 v8::Local<v8::Value> scriptValue = values[0]; | |
1210 // FIXME: There are many more types that can be handled. | |
1211 if (scriptValue->IsString()) { | |
1212 v8::String::Utf8Value utf8V8(scriptValue); | |
1213 result->set(std::string(*utf8V8)); | |
1214 } else if (scriptValue->IsBoolean()) | |
1215 result->set(scriptValue->ToBoolean()->Value()); | |
1216 else if (scriptValue->IsNumber()) { | |
1217 if (scriptValue->IsInt32()) | |
1218 result->set(scriptValue->ToInt32()->Value()); | |
1219 else | |
1220 result->set(scriptValue->ToNumber()->Value()); | |
1221 } else if (scriptValue->IsNull()) | |
1222 result->setNull(); | |
1223 } | |
1224 } | |
1225 | |
1226 void TestRunner::evaluateScriptInIsolatedWorld(const CppArgumentList& arguments,
CppVariant* result) | |
1227 { | |
1228 if (arguments.size() >= 2 && arguments[0].isNumber() && arguments[1].isStrin
g()) { | |
1229 WebScriptSource source(cppVariantToWebString(arguments[1])); | |
1230 // This relies on the iframe focusing itself when it loads. This is a bi
t | |
1231 // sketchy, but it seems to be what other tests do. | |
1232 m_webView->focusedFrame()->executeScriptInIsolatedWorld(arguments[0].toI
nt32(), &source, 1, 1); | |
1233 } | |
1234 result->setNull(); | |
1235 } | |
1236 | |
1237 void TestRunner::setIsolatedWorldSecurityOrigin(const CppArgumentList& arguments
, CppVariant* result) | |
1238 { | |
1239 result->setNull(); | |
1240 | |
1241 if (arguments.size() != 2 || !arguments[0].isNumber() || !(arguments[1].isSt
ring() || arguments[1].isNull())) | |
1242 return; | |
1243 | |
1244 WebSecurityOrigin origin; | |
1245 if (arguments[1].isString()) | |
1246 origin = WebSecurityOrigin::createFromString(cppVariantToWebString(argum
ents[1])); | |
1247 m_webView->focusedFrame()->setIsolatedWorldSecurityOrigin(arguments[0].toInt
32(), origin); | |
1248 } | |
1249 | |
1250 void TestRunner::setIsolatedWorldContentSecurityPolicy(const CppArgumentList& ar
guments, CppVariant* result) | |
1251 { | |
1252 result->setNull(); | |
1253 | |
1254 if (arguments.size() != 2 || !arguments[0].isNumber() || !arguments[1].isStr
ing()) | |
1255 return; | |
1256 | |
1257 m_webView->focusedFrame()->setIsolatedWorldContentSecurityPolicy(arguments[0
].toInt32(), cppVariantToWebString(arguments[1])); | |
1258 } | |
1259 | |
1260 void TestRunner::addOriginAccessWhitelistEntry(const CppArgumentList& arguments,
CppVariant* result) | |
1261 { | |
1262 result->setNull(); | |
1263 | |
1264 if (arguments.size() != 4 || !arguments[0].isString() || !arguments[1].isStr
ing() | |
1265 || !arguments[2].isString() || !arguments[3].isBool()) | |
1266 return; | |
1267 | |
1268 blink::WebURL url(GURL(arguments[0].toString())); | |
1269 if (!url.isValid()) | |
1270 return; | |
1271 | |
1272 WebSecurityPolicy::addOriginAccessWhitelistEntry( | |
1273 url, | |
1274 cppVariantToWebString(arguments[1]), | |
1275 cppVariantToWebString(arguments[2]), | |
1276 arguments[3].toBoolean()); | |
1277 } | |
1278 | |
1279 void TestRunner::removeOriginAccessWhitelistEntry(const CppArgumentList& argumen
ts, CppVariant* result) | |
1280 { | |
1281 result->setNull(); | |
1282 | |
1283 if (arguments.size() != 4 || !arguments[0].isString() || !arguments[1].isStr
ing() | |
1284 || !arguments[2].isString() || !arguments[3].isBool()) | |
1285 return; | |
1286 | |
1287 blink::WebURL url(GURL(arguments[0].toString())); | |
1288 if (!url.isValid()) | |
1289 return; | |
1290 | |
1291 WebSecurityPolicy::removeOriginAccessWhitelistEntry( | |
1292 url, | |
1293 cppVariantToWebString(arguments[1]), | |
1294 cppVariantToWebString(arguments[2]), | |
1295 arguments[3].toBoolean()); | |
1296 } | |
1297 | |
1298 void TestRunner::hasCustomPageSizeStyle(const CppArgumentList& arguments, CppVar
iant* result) | |
1299 { | |
1300 result->set(false); | |
1301 int pageIndex = 0; | |
1302 if (arguments.size() > 1) | |
1303 return; | |
1304 if (arguments.size() == 1) | |
1305 pageIndex = cppVariantToInt32(arguments[0]); | |
1306 WebFrame* frame = m_webView->mainFrame(); | |
1307 if (!frame) | |
1308 return; | |
1309 result->set(frame->hasCustomPageSizeStyle(pageIndex)); | |
1310 } | |
1311 | |
1312 void TestRunner::forceRedSelectionColors(const CppArgumentList& arguments, CppVa
riant* result) | |
1313 { | |
1314 result->setNull(); | |
1315 m_webView->setSelectionColors(0xffee0000, 0xff00ee00, 0xff000000, 0xffc0c0c0
); | |
1316 } | |
1317 | |
1318 void TestRunner::injectStyleSheet(const CppArgumentList& arguments, CppVariant*
result) | |
1319 { | |
1320 result->setNull(); | |
1321 if (arguments.size() < 2 || !arguments[0].isString() || !arguments[1].isBool
()) | |
1322 return; | |
1323 WebView::injectStyleSheet( | |
1324 cppVariantToWebString(arguments[0]), WebVector<WebString>(), | |
1325 arguments[1].toBoolean() ? WebView::InjectStyleInAllFrames : WebView::In
jectStyleInTopFrameOnly); | |
1326 } | |
1327 | |
1328 void TestRunner::startSpeechInput(const CppArgumentList& arguments, CppVariant*
result) | |
1329 { | |
1330 result->setNull(); | |
1331 if (arguments.size() != 1 || !arguments[0].isObject()) | |
1332 return; | |
1333 | |
1334 WebElement element; | |
1335 if (!WebBindings::getElement(arguments[0].value.objectValue, &element)) | |
1336 return; | |
1337 | |
1338 WebInputElement* input = toWebInputElement(&element); | |
1339 if (!input) | |
1340 return; | |
1341 | |
1342 if (!input->isSpeechInputEnabled()) | |
1343 return; | |
1344 | |
1345 input->startSpeechInput(); | |
1346 } | |
1347 | |
1348 void TestRunner::findString(const CppArgumentList& arguments, CppVariant* result
) | |
1349 { | |
1350 if (arguments.size() < 1 || !arguments[0].isString()) | |
1351 return; | |
1352 | |
1353 WebFindOptions findOptions; | |
1354 bool wrapAround = false; | |
1355 if (arguments.size() >= 2) { | |
1356 vector<string> optionsArray = arguments[1].toStringVector(); | |
1357 findOptions.matchCase = true; | |
1358 findOptions.findNext = true; | |
1359 | |
1360 for (size_t i = 0; i < optionsArray.size(); ++i) { | |
1361 const std::string& option = optionsArray[i]; | |
1362 if (option == "CaseInsensitive") | |
1363 findOptions.matchCase = false; | |
1364 else if (option == "Backwards") | |
1365 findOptions.forward = false; | |
1366 else if (option == "StartInSelection") | |
1367 findOptions.findNext = false; | |
1368 else if (option == "AtWordStarts") | |
1369 findOptions.wordStart = true; | |
1370 else if (option == "TreatMedialCapitalAsWordStart") | |
1371 findOptions.medialCapitalAsWordStart = true; | |
1372 else if (option == "WrapAround") | |
1373 wrapAround = true; | |
1374 } | |
1375 } | |
1376 | |
1377 WebFrame* frame = m_webView->mainFrame(); | |
1378 const bool findResult = frame->find(0, cppVariantToWebString(arguments[0]),
findOptions, wrapAround, 0); | |
1379 frame->stopFinding(false); | |
1380 result->set(findResult); | |
1381 } | |
1382 | |
1383 void TestRunner::setValueForUser(const CppArgumentList& arguments, CppVariant* r
esult) | |
1384 { | |
1385 result->setNull(); | |
1386 if (arguments.size() != 2 || !arguments[0].isObject() || !arguments[1].isStr
ing()) | |
1387 return; | |
1388 | |
1389 WebElement element; | |
1390 if (!WebBindings::getElement(arguments[0].value.objectValue, &element)) | |
1391 return; | |
1392 | |
1393 WebInputElement* input = toWebInputElement(&element); | |
1394 if (!input) | |
1395 return; | |
1396 | |
1397 input->setValue(cppVariantToWebString(arguments[1]), true); | |
1398 } | |
1399 | |
1400 void TestRunner::selectionAsMarkup(const CppArgumentList& arguments, CppVariant*
result) | |
1401 { | |
1402 result->set(m_webView->mainFrame()->selectionAsMarkup().utf8()); | |
1403 } | |
1404 | |
1405 void TestRunner::setTextSubpixelPositioning(const CppArgumentList& arguments, Cp
pVariant* result) | |
1406 { | |
1407 #if defined(__linux__) || defined(ANDROID) | |
1408 // Since FontConfig doesn't provide a variable to control subpixel positioni
ng, we'll fall back | |
1409 // to setting it globally for all fonts. | |
1410 if (arguments.size() > 0 && arguments[0].isBool()) | |
1411 WebFontRendering::setSubpixelPositioning(arguments[0].value.boolValue); | |
1412 #endif | |
1413 result->setNull(); | |
1414 } | |
1415 | |
1416 void TestRunner::setPageVisibility(const CppArgumentList& arguments, CppVariant*
result) | |
1417 { | |
1418 if (arguments.size() > 0 && arguments[0].isString()) { | |
1419 string newVisibility = arguments[0].toString(); | |
1420 if (newVisibility == "visible") | |
1421 m_webView->setVisibilityState(WebPageVisibilityStateVisible, false); | |
1422 else if (newVisibility == "hidden") | |
1423 m_webView->setVisibilityState(WebPageVisibilityStateHidden, false); | |
1424 else if (newVisibility == "prerender") | |
1425 m_webView->setVisibilityState(WebPageVisibilityStatePrerender, false
); | |
1426 } | |
1427 } | |
1428 | |
1429 void TestRunner::setTextDirection(const CppArgumentList& arguments, CppVariant*
result) | |
1430 { | |
1431 result->setNull(); | |
1432 if (arguments.size() != 1 || !arguments[0].isString()) | |
1433 return; | |
1434 | |
1435 // Map a direction name to a WebTextDirection value. | |
1436 std::string directionName = arguments[0].toString(); | |
1437 blink::WebTextDirection direction; | |
1438 if (directionName == "auto") | |
1439 direction = blink::WebTextDirectionDefault; | |
1440 else if (directionName == "rtl") | |
1441 direction = blink::WebTextDirectionRightToLeft; | |
1442 else if (directionName == "ltr") | |
1443 direction = blink::WebTextDirectionLeftToRight; | |
1444 else | |
1445 return; | |
1446 | |
1447 m_webView->setTextDirection(direction); | |
1448 } | |
1449 | |
1450 void TestRunner::textSurroundingNode(const CppArgumentList& arguments, CppVarian
t* result) | |
1451 { | |
1452 result->setNull(); | |
1453 if (arguments.size() < 4 || !arguments[0].isObject() || !arguments[1].isNumb
er() || !arguments[2].isNumber() || !arguments[3].isNumber()) | |
1454 return; | |
1455 | |
1456 WebNode node; | |
1457 if (!WebBindings::getNode(arguments[0].value.objectValue, &node)) | |
1458 return; | |
1459 | |
1460 if (node.isNull() || !node.isTextNode()) | |
1461 return; | |
1462 | |
1463 WebPoint point(arguments[1].toInt32(), arguments[2].toInt32()); | |
1464 unsigned maxLength = arguments[3].toInt32(); | |
1465 | |
1466 WebSurroundingText surroundingText; | |
1467 surroundingText.initialize(node, point, maxLength); | |
1468 if (surroundingText.isNull()) | |
1469 return; | |
1470 | |
1471 result->set(surroundingText.textContent().utf8()); | |
1472 } | |
1473 | |
1474 void TestRunner::dumpResourceRequestPriorities(const CppArgumentList& arguments,
CppVariant* result) | |
1475 { | |
1476 m_shouldDumpResourcePriorities = true; | |
1477 result->setNull(); | |
1478 } | |
1479 | |
1480 void TestRunner::setUseMockTheme(const CppArgumentList& arguments, CppVariant* r
esult) | |
1481 { | |
1482 result->setNull(); | |
1483 m_useMockTheme = arguments.size() < 1 || arguments[0].toBoolean(); | |
1484 } | |
1485 | |
1486 void TestRunner::useUnfortunateSynchronousResizeMode(const CppArgumentList& argu
ments, CppVariant* result) | |
1487 { | |
1488 result->setNull(); | |
1489 m_delegate->useUnfortunateSynchronousResizeMode(true); | |
1490 } | |
1491 | |
1492 void TestRunner::enableAutoResizeMode(const CppArgumentList& arguments, CppVaria
nt* result) | |
1493 { | |
1494 if (arguments.size() != 4) { | |
1495 result->set(false); | |
1496 return; | |
1497 } | |
1498 int minWidth = cppVariantToInt32(arguments[0]); | |
1499 int minHeight = cppVariantToInt32(arguments[1]); | |
1500 blink::WebSize minSize(minWidth, minHeight); | |
1501 | |
1502 int maxWidth = cppVariantToInt32(arguments[2]); | |
1503 int maxHeight = cppVariantToInt32(arguments[3]); | |
1504 blink::WebSize maxSize(maxWidth, maxHeight); | |
1505 | |
1506 m_delegate->enableAutoResizeMode(minSize, maxSize); | |
1507 result->set(true); | |
1508 } | |
1509 | |
1510 void TestRunner::disableAutoResizeMode(const CppArgumentList& arguments, CppVari
ant* result) | |
1511 { | |
1512 if (arguments.size() !=2) { | |
1513 result->set(false); | |
1514 return; | |
1515 } | |
1516 int newWidth = cppVariantToInt32(arguments[0]); | |
1517 int newHeight = cppVariantToInt32(arguments[1]); | |
1518 blink::WebSize newSize(newWidth, newHeight); | |
1519 | |
1520 m_delegate->disableAutoResizeMode(newSize); | |
1521 result->set(true); | |
1522 } | |
1523 | |
1524 void TestRunner::setMockDeviceMotion(const CppArgumentList& arguments, CppVarian
t* result) | |
1525 { | |
1526 result->setNull(); | |
1527 if (arguments.size() < 19 | |
1528 || !arguments[0].isBool() || !arguments[1].isNumber() // acceleration.x | |
1529 || !arguments[2].isBool() || !arguments[3].isNumber() // acceleration.y | |
1530 || !arguments[4].isBool() || !arguments[5].isNumber() // acceleration.z | |
1531 || !arguments[6].isBool() || !arguments[7].isNumber() // accelerationInc
ludingGravity.x | |
1532 || !arguments[8].isBool() || !arguments[9].isNumber() // accelerationInc
ludingGravity.y | |
1533 || !arguments[10].isBool() || !arguments[11].isNumber() // accelerationI
ncludingGravity.z | |
1534 || !arguments[12].isBool() || !arguments[13].isNumber() // rotationRate.
alpha | |
1535 || !arguments[14].isBool() || !arguments[15].isNumber() // rotationRate.
beta | |
1536 || !arguments[16].isBool() || !arguments[17].isNumber() // rotationRate.
gamma | |
1537 || !arguments[18].isNumber()) // interval | |
1538 return; | |
1539 | |
1540 WebDeviceMotionData motion; | |
1541 | |
1542 // acceleration | |
1543 motion.hasAccelerationX = arguments[0].toBoolean(); | |
1544 motion.accelerationX = arguments[1].toDouble(); | |
1545 motion.hasAccelerationY = arguments[2].toBoolean(); | |
1546 motion.accelerationY = arguments[3].toDouble(); | |
1547 motion.hasAccelerationZ = arguments[4].toBoolean(); | |
1548 motion.accelerationZ = arguments[5].toDouble(); | |
1549 | |
1550 // accelerationIncludingGravity | |
1551 motion.hasAccelerationIncludingGravityX = arguments[6].toBoolean(); | |
1552 motion.accelerationIncludingGravityX = arguments[7].toDouble(); | |
1553 motion.hasAccelerationIncludingGravityY = arguments[8].toBoolean(); | |
1554 motion.accelerationIncludingGravityY = arguments[9].toDouble(); | |
1555 motion.hasAccelerationIncludingGravityZ = arguments[10].toBoolean(); | |
1556 motion.accelerationIncludingGravityZ = arguments[11].toDouble(); | |
1557 | |
1558 // rotationRate | |
1559 motion.hasRotationRateAlpha = arguments[12].toBoolean(); | |
1560 motion.rotationRateAlpha = arguments[13].toDouble(); | |
1561 motion.hasRotationRateBeta = arguments[14].toBoolean(); | |
1562 motion.rotationRateBeta = arguments[15].toDouble(); | |
1563 motion.hasRotationRateGamma = arguments[16].toBoolean(); | |
1564 motion.rotationRateGamma = arguments[17].toDouble(); | |
1565 | |
1566 // interval | |
1567 motion.interval = arguments[18].toDouble(); | |
1568 | |
1569 m_delegate->setDeviceMotionData(motion); | |
1570 } | |
1571 | |
1572 void TestRunner::setMockDeviceOrientation(const CppArgumentList& arguments, CppV
ariant* result) | |
1573 { | |
1574 result->setNull(); | |
1575 if (arguments.size() < 8 | |
1576 || !arguments[0].isBool() || !arguments[1].isNumber() // alpha | |
1577 || !arguments[2].isBool() || !arguments[3].isNumber() // beta | |
1578 || !arguments[4].isBool() || !arguments[5].isNumber() // gamma | |
1579 || !arguments[6].isBool() || !arguments[7].isBool()) // absolute | |
1580 return; | |
1581 | |
1582 WebDeviceOrientationData orientation; | |
1583 | |
1584 // alpha | |
1585 orientation.hasAlpha = arguments[0].toBoolean(); | |
1586 orientation.alpha = arguments[1].toDouble(); | |
1587 | |
1588 // beta | |
1589 orientation.hasBeta = arguments[2].toBoolean(); | |
1590 orientation.beta = arguments[3].toDouble(); | |
1591 | |
1592 // gamma | |
1593 orientation.hasGamma = arguments[4].toBoolean(); | |
1594 orientation.gamma = arguments[5].toDouble(); | |
1595 | |
1596 // absolute | |
1597 orientation.hasAbsolute = arguments[6].toBoolean(); | |
1598 orientation.absolute = arguments[7].toBoolean(); | |
1599 | |
1600 m_delegate->setDeviceOrientationData(orientation); | |
1601 } | |
1602 | |
1603 void TestRunner::setPopupBlockingEnabled(const CppArgumentList& arguments, CppVa
riant* result) | |
1604 { | |
1605 if (arguments.size() > 0 && arguments[0].isBool()) { | |
1606 bool blockPopups = arguments[0].toBoolean(); | |
1607 m_delegate->preferences()->javaScriptCanOpenWindowsAutomatically = !bloc
kPopups; | |
1608 m_delegate->applyPreferences(); | |
1609 } | |
1610 result->setNull(); | |
1611 } | |
1612 | |
1613 void TestRunner::setJavaScriptCanAccessClipboard(const CppArgumentList& argument
s, CppVariant* result) | |
1614 { | |
1615 if (arguments.size() > 0 && arguments[0].isBool()) { | |
1616 m_delegate->preferences()->javaScriptCanAccessClipboard = arguments[0].v
alue.boolValue; | |
1617 m_delegate->applyPreferences(); | |
1618 } | |
1619 result->setNull(); | |
1620 } | |
1621 | |
1622 void TestRunner::setXSSAuditorEnabled(const CppArgumentList& arguments, CppVaria
nt* result) | |
1623 { | |
1624 if (arguments.size() > 0 && arguments[0].isBool()) { | |
1625 m_delegate->preferences()->XSSAuditorEnabled = arguments[0].value.boolVa
lue; | |
1626 m_delegate->applyPreferences(); | |
1627 } | |
1628 result->setNull(); | |
1629 } | |
1630 | |
1631 void TestRunner::setAllowUniversalAccessFromFileURLs(const CppArgumentList& argu
ments, CppVariant* result) | |
1632 { | |
1633 if (arguments.size() > 0 && arguments[0].isBool()) { | |
1634 m_delegate->preferences()->allowUniversalAccessFromFileURLs = arguments[
0].value.boolValue; | |
1635 m_delegate->applyPreferences(); | |
1636 } | |
1637 result->setNull(); | |
1638 } | |
1639 | |
1640 void TestRunner::setAllowFileAccessFromFileURLs(const CppArgumentList& arguments
, CppVariant* result) | |
1641 { | |
1642 if (arguments.size() > 0 && arguments[0].isBool()) { | |
1643 m_delegate->preferences()->allowFileAccessFromFileURLs = arguments[0].va
lue.boolValue; | |
1644 m_delegate->applyPreferences(); | |
1645 } | |
1646 result->setNull(); | |
1647 } | |
1648 | |
1649 void TestRunner::overridePreference(const CppArgumentList& arguments, CppVariant
* result) | |
1650 { | |
1651 result->setNull(); | |
1652 if (arguments.size() != 2 || !arguments[0].isString()) | |
1653 return; | |
1654 | |
1655 string key = arguments[0].toString(); | |
1656 CppVariant value = arguments[1]; | |
1657 WebPreferences* prefs = m_delegate->preferences(); | |
1658 if (key == "WebKitDefaultFontSize") | |
1659 prefs->defaultFontSize = cppVariantToInt32(value); | |
1660 else if (key == "WebKitMinimumFontSize") | |
1661 prefs->minimumFontSize = cppVariantToInt32(value); | |
1662 else if (key == "WebKitDefaultTextEncodingName") | |
1663 prefs->defaultTextEncodingName = cppVariantToWebString(value); | |
1664 else if (key == "WebKitJavaScriptEnabled") | |
1665 prefs->javaScriptEnabled = cppVariantToBool(value); | |
1666 else if (key == "WebKitSupportsMultipleWindows") | |
1667 prefs->supportsMultipleWindows = cppVariantToBool(value); | |
1668 else if (key == "WebKitDisplayImagesKey") | |
1669 prefs->loadsImagesAutomatically = cppVariantToBool(value); | |
1670 else if (key == "WebKitPluginsEnabled") | |
1671 prefs->pluginsEnabled = cppVariantToBool(value); | |
1672 else if (key == "WebKitJavaEnabled") | |
1673 prefs->javaEnabled = cppVariantToBool(value); | |
1674 else if (key == "WebKitOfflineWebApplicationCacheEnabled") | |
1675 prefs->offlineWebApplicationCacheEnabled = cppVariantToBool(value); | |
1676 else if (key == "WebKitTabToLinksPreferenceKey") | |
1677 prefs->tabsToLinks = cppVariantToBool(value); | |
1678 else if (key == "WebKitWebGLEnabled") | |
1679 prefs->experimentalWebGLEnabled = cppVariantToBool(value); | |
1680 else if (key == "WebKitCSSRegionsEnabled") | |
1681 prefs->experimentalCSSRegionsEnabled = cppVariantToBool(value); | |
1682 else if (key == "WebKitCSSGridLayoutEnabled") | |
1683 prefs->experimentalCSSGridLayoutEnabled = cppVariantToBool(value); | |
1684 else if (key == "WebKitHyperlinkAuditingEnabled") | |
1685 prefs->hyperlinkAuditingEnabled = cppVariantToBool(value); | |
1686 else if (key == "WebKitEnableCaretBrowsing") | |
1687 prefs->caretBrowsingEnabled = cppVariantToBool(value); | |
1688 else if (key == "WebKitAllowDisplayingInsecureContent") | |
1689 prefs->allowDisplayOfInsecureContent = cppVariantToBool(value); | |
1690 else if (key == "WebKitAllowRunningInsecureContent") | |
1691 prefs->allowRunningOfInsecureContent = cppVariantToBool(value); | |
1692 else if (key == "WebKitShouldRespectImageOrientation") | |
1693 prefs->shouldRespectImageOrientation = cppVariantToBool(value); | |
1694 else if (key == "WebKitWebAudioEnabled") | |
1695 BLINK_ASSERT(cppVariantToBool(value)); | |
1696 else { | |
1697 string message("Invalid name for preference: "); | |
1698 message.append(key); | |
1699 printErrorMessage(message); | |
1700 } | |
1701 m_delegate->applyPreferences(); | |
1702 } | |
1703 | |
1704 void TestRunner::setPluginsEnabled(const CppArgumentList& arguments, CppVariant*
result) | |
1705 { | |
1706 if (arguments.size() > 0 && arguments[0].isBool()) { | |
1707 m_delegate->preferences()->pluginsEnabled = arguments[0].toBoolean(); | |
1708 m_delegate->applyPreferences(); | |
1709 } | |
1710 result->setNull(); | |
1711 } | |
1712 | |
1713 void TestRunner::showWebInspector(const CppArgumentList& args, CppVariant* resul
t) | |
1714 { | |
1715 if (args.size() == 1 && args[0].isString()) | |
1716 showDevTools(args[0].toString()); | |
1717 else | |
1718 showDevTools(""); | |
1719 result->setNull(); | |
1720 } | |
1721 | |
1722 void TestRunner::closeWebInspector(const CppArgumentList& args, CppVariant* resu
lt) | |
1723 { | |
1724 m_delegate->closeDevTools(); | |
1725 result->setNull(); | |
1726 } | |
1727 | |
1728 void TestRunner::isChooserShown(const CppArgumentList&, CppVariant* result) | |
1729 { | |
1730 result->set(m_proxy->isChooserShown()); | |
1731 } | |
1732 | |
1733 void TestRunner::evaluateInWebInspector(const CppArgumentList& arguments, CppVar
iant* result) | |
1734 { | |
1735 result->setNull(); | |
1736 if (arguments.size() < 2 || !arguments[0].isNumber() || !arguments[1].isStri
ng()) | |
1737 return; | |
1738 m_delegate->evaluateInWebInspector(arguments[0].toInt32(), arguments[1].toSt
ring()); | |
1739 } | |
1740 | |
1741 void TestRunner::clearAllDatabases(const CppArgumentList& arguments, CppVariant*
result) | |
1742 { | |
1743 result->setNull(); | |
1744 m_delegate->clearAllDatabases(); | |
1745 } | |
1746 | |
1747 void TestRunner::setDatabaseQuota(const CppArgumentList& arguments, CppVariant*
result) | |
1748 { | |
1749 result->setNull(); | |
1750 if ((arguments.size() >= 1) && arguments[0].isNumber()) | |
1751 m_delegate->setDatabaseQuota(arguments[0].toInt32()); | |
1752 } | |
1753 | |
1754 void TestRunner::setAlwaysAcceptCookies(const CppArgumentList& arguments, CppVar
iant* result) | |
1755 { | |
1756 if (arguments.size() > 0) | |
1757 m_delegate->setAcceptAllCookies(cppVariantToBool(arguments[0])); | |
1758 result->setNull(); | |
1759 } | |
1760 | |
1761 void TestRunner::setWindowIsKey(const CppArgumentList& arguments, CppVariant* re
sult) | |
1762 { | |
1763 if (arguments.size() > 0 && arguments[0].isBool()) | |
1764 m_delegate->setFocus(m_proxy, arguments[0].value.boolValue); | |
1765 result->setNull(); | |
1766 } | |
1767 | |
1768 void TestRunner::pathToLocalResource(const CppArgumentList& arguments, CppVarian
t* result) | |
1769 { | |
1770 result->setNull(); | |
1771 if (arguments.size() <= 0 || !arguments[0].isString()) | |
1772 return; | |
1773 | |
1774 result->set(m_delegate->pathToLocalResource(arguments[0].toString())); | |
1775 } | |
1776 | |
1777 void TestRunner::setBackingScaleFactor(const CppArgumentList& arguments, CppVari
ant* result) | |
1778 { | |
1779 if (arguments.size() < 2 || !arguments[0].isNumber() || !arguments[1].isObje
ct()) | |
1780 return; | |
1781 | |
1782 float value = arguments[0].value.doubleValue; | |
1783 m_delegate->setDeviceScaleFactor(value); | |
1784 m_proxy->discardBackingStore(); | |
1785 | |
1786 scoped_ptr<CppVariant> callbackArguments(new CppVariant()); | |
1787 callbackArguments->set(arguments[1]); | |
1788 result->setNull(); | |
1789 m_delegate->postTask( | |
1790 new InvokeCallbackTask(this, callbackArguments.Pass())); | |
1791 } | |
1792 | |
1793 void TestRunner::setPOSIXLocale(const CppArgumentList& arguments, CppVariant* re
sult) | |
1794 { | |
1795 result->setNull(); | |
1796 if (arguments.size() == 1 && arguments[0].isString()) | |
1797 m_delegate->setLocale(arguments[0].toString()); | |
1798 } | |
1799 | |
1800 void TestRunner::setMIDIAccessorResult(const CppArgumentList& arguments, CppVari
ant* result) | |
1801 { | |
1802 result->setNull(); | |
1803 if (arguments.size() < 1 || !arguments[0].isBool()) | |
1804 return; | |
1805 m_midiAccessorResult = arguments[0].toBoolean(); | |
1806 } | |
1807 | |
1808 void TestRunner::setMIDISysExPermission(const CppArgumentList& arguments, CppVar
iant* result) | |
1809 { | |
1810 result->setNull(); | |
1811 if (arguments.size() < 1 || !arguments[0].isBool()) | |
1812 return; | |
1813 const vector<WebTestProxyBase*>& windowList = m_testInterfaces->windowList()
; | |
1814 for (unsigned i = 0; i < windowList.size(); ++i) | |
1815 windowList.at(i)->midiClientMock()->setSysExPermission(arguments[0].toBo
olean()); | |
1816 } | |
1817 | |
1818 void TestRunner::grantWebNotificationPermission(const CppArgumentList& arguments
, CppVariant* result) | |
1819 { | |
1820 result->setNull(); | |
1821 if (arguments.size() < 1 || !arguments[0].isString()) | |
1822 return; | |
1823 | |
1824 bool permissionGranted = true; | |
1825 if (arguments.size() == 2 && arguments[1].isBool()) | |
1826 permissionGranted = arguments[1].toBoolean(); | |
1827 | |
1828 notification_presenter_->GrantPermission(arguments[0].toString(), permission
Granted); | |
1829 } | |
1830 | |
1831 void TestRunner::simulateWebNotificationClick(const CppArgumentList& arguments,
CppVariant* result) | |
1832 { | |
1833 if (arguments.size() != 1 || !arguments[0].isString()) { | |
1834 result->set(false); | |
1835 return; | |
1836 } | |
1837 result->set(notification_presenter_->SimulateClick(arguments[0].toString()))
; | |
1838 } | |
1839 | |
1840 void TestRunner::addMockSpeechInputResult(const CppArgumentList& arguments, CppV
ariant* result) | |
1841 { | |
1842 result->setNull(); | |
1843 if (arguments.size() < 3 || !arguments[0].isString() || !arguments[1].isNumb
er() || !arguments[2].isString()) | |
1844 return; | |
1845 | |
1846 #if ENABLE_INPUT_SPEECH | |
1847 m_proxy->speechInputControllerMock()->addMockRecognitionResult(WebString::fr
omUTF8(arguments[0].toString()), arguments[1].toDouble(), WebString::fromUTF8(ar
guments[2].toString())); | |
1848 #endif | |
1849 } | |
1850 | |
1851 void TestRunner::setMockSpeechInputDumpRect(const CppArgumentList& arguments, Cp
pVariant* result) | |
1852 { | |
1853 result->setNull(); | |
1854 if (arguments.size() < 1 || !arguments[0].isBool()) | |
1855 return; | |
1856 | |
1857 #if ENABLE_INPUT_SPEECH | |
1858 m_proxy->speechInputControllerMock()->setDumpRect(arguments[0].toBoolean()); | |
1859 #endif | |
1860 } | |
1861 | |
1862 void TestRunner::addMockSpeechRecognitionResult(const CppArgumentList& arguments
, CppVariant* result) | |
1863 { | |
1864 result->setNull(); | |
1865 if (arguments.size() < 2 || !arguments[0].isString() || !arguments[1].isNumb
er()) | |
1866 return; | |
1867 | |
1868 m_proxy->speechRecognizerMock()->addMockResult(WebString::fromUTF8(arguments
[0].toString()), arguments[1].toDouble()); | |
1869 } | |
1870 | |
1871 void TestRunner::setMockSpeechRecognitionError(const CppArgumentList& arguments,
CppVariant* result) | |
1872 { | |
1873 result->setNull(); | |
1874 if (arguments.size() != 2 || !arguments[0].isString() || !arguments[1].isStr
ing()) | |
1875 return; | |
1876 | |
1877 m_proxy->speechRecognizerMock()->setError(WebString::fromUTF8(arguments[0].t
oString()), WebString::fromUTF8(arguments[1].toString())); | |
1878 } | |
1879 | |
1880 void TestRunner::wasMockSpeechRecognitionAborted(const CppArgumentList&, CppVari
ant* result) | |
1881 { | |
1882 result->set(m_proxy->speechRecognizerMock()->wasAborted()); | |
1883 } | |
1884 | |
1885 void TestRunner::addWebPageOverlay(const CppArgumentList&, CppVariant* result) | |
1886 { | |
1887 if (m_webView && !m_pageOverlay) { | |
1888 m_pageOverlay = new TestPageOverlay(m_webView); | |
1889 m_webView->addPageOverlay(m_pageOverlay, 0); | |
1890 } | |
1891 result->setNull(); | |
1892 } | |
1893 | |
1894 void TestRunner::removeWebPageOverlay(const CppArgumentList&, CppVariant* result
) | |
1895 { | |
1896 if (m_webView && m_pageOverlay) { | |
1897 m_webView->removePageOverlay(m_pageOverlay); | |
1898 delete m_pageOverlay; | |
1899 m_pageOverlay = 0; | |
1900 } | |
1901 | |
1902 result->setNull(); | |
1903 } | |
1904 | |
1905 void TestRunner::display(const CppArgumentList& arguments, CppVariant* result) | |
1906 { | |
1907 m_proxy->display(); | |
1908 result->setNull(); | |
1909 } | |
1910 | |
1911 void TestRunner::displayInvalidatedRegion(const CppArgumentList& arguments, CppV
ariant* result) | |
1912 { | |
1913 m_proxy->displayInvalidatedRegion(); | |
1914 result->setNull(); | |
1915 } | |
1916 | |
1917 void TestRunner::dumpEditingCallbacks(const CppArgumentList&, CppVariant* result
) | |
1918 { | |
1919 m_dumpEditingCallbacks = true; | |
1920 result->setNull(); | |
1921 } | |
1922 | |
1923 void TestRunner::dumpAsText(const CppArgumentList&, CppVariant* result) | |
1924 { | |
1925 m_dumpAsText = true; | |
1926 m_generatePixelResults = false; | |
1927 | |
1928 result->setNull(); | |
1929 } | |
1930 | |
1931 void TestRunner::dumpAsTextWithPixelResults(const CppArgumentList&, CppVariant*
result) | |
1932 { | |
1933 m_dumpAsText = true; | |
1934 m_generatePixelResults = true; | |
1935 | |
1936 result->setNull(); | |
1937 } | |
1938 | |
1939 void TestRunner::dumpChildFrameScrollPositions(const CppArgumentList&, CppVarian
t* result) | |
1940 { | |
1941 m_dumpChildFrameScrollPositions = true; | |
1942 result->setNull(); | |
1943 } | |
1944 | |
1945 void TestRunner::dumpChildFramesAsText(const CppArgumentList&, CppVariant* resul
t) | |
1946 { | |
1947 m_dumpChildFramesAsText = true; | |
1948 result->setNull(); | |
1949 } | |
1950 | |
1951 void TestRunner::dumpIconChanges(const CppArgumentList&, CppVariant* result) | |
1952 { | |
1953 m_dumpIconChanges = true; | |
1954 result->setNull(); | |
1955 } | |
1956 | |
1957 void TestRunner::setAudioData(const CppArgumentList& arguments, CppVariant* resu
lt) | |
1958 { | |
1959 result->setNull(); | |
1960 | |
1961 if (arguments.size() < 1 || !arguments[0].isObject()) | |
1962 return; | |
1963 | |
1964 // Check that passed-in object is, in fact, an ArrayBufferView. | |
1965 NPObject* npobject = NPVARIANT_TO_OBJECT(arguments[0]); | |
1966 if (!npobject) | |
1967 return; | |
1968 if (!WebBindings::getArrayBufferView(npobject, &m_audioData)) | |
1969 return; | |
1970 | |
1971 m_dumpAsAudio = true; | |
1972 } | |
1973 | |
1974 void TestRunner::dumpFrameLoadCallbacks(const CppArgumentList&, CppVariant* resu
lt) | |
1975 { | |
1976 m_dumpFrameLoadCallbacks = true; | |
1977 result->setNull(); | |
1978 } | |
1979 | |
1980 void TestRunner::dumpPingLoaderCallbacks(const CppArgumentList&, CppVariant* res
ult) | |
1981 { | |
1982 m_dumpPingLoaderCallbacks = true; | |
1983 result->setNull(); | |
1984 } | |
1985 | |
1986 void TestRunner::dumpUserGestureInFrameLoadCallbacks(const CppArgumentList&, Cpp
Variant* result) | |
1987 { | |
1988 m_dumpUserGestureInFrameLoadCallbacks = true; | |
1989 result->setNull(); | |
1990 } | |
1991 | |
1992 void TestRunner::dumpTitleChanges(const CppArgumentList&, CppVariant* result) | |
1993 { | |
1994 m_dumpTitleChanges = true; | |
1995 result->setNull(); | |
1996 } | |
1997 | |
1998 void TestRunner::dumpCreateView(const CppArgumentList&, CppVariant* result) | |
1999 { | |
2000 m_dumpCreateView = true; | |
2001 result->setNull(); | |
2002 } | |
2003 | |
2004 void TestRunner::setCanOpenWindows(const CppArgumentList&, CppVariant* result) | |
2005 { | |
2006 m_canOpenWindows = true; | |
2007 result->setNull(); | |
2008 } | |
2009 | |
2010 void TestRunner::dumpResourceLoadCallbacks(const CppArgumentList&, CppVariant* r
esult) | |
2011 { | |
2012 m_dumpResourceLoadCallbacks = true; | |
2013 result->setNull(); | |
2014 } | |
2015 | |
2016 void TestRunner::dumpResourceRequestCallbacks(const CppArgumentList&, CppVariant
* result) | |
2017 { | |
2018 m_dumpResourceRequestCallbacks = true; | |
2019 result->setNull(); | |
2020 } | |
2021 | |
2022 void TestRunner::dumpResourceResponseMIMETypes(const CppArgumentList&, CppVarian
t* result) | |
2023 { | |
2024 m_dumpResourceResponseMIMETypes = true; | |
2025 result->setNull(); | |
2026 } | |
2027 | |
2028 // Need these conversions because the format of the value for booleans | |
2029 // may vary - for example, on mac "1" and "0" are used for boolean. | |
2030 bool TestRunner::cppVariantToBool(const CppVariant& value) | |
2031 { | |
2032 if (value.isBool()) | |
2033 return value.toBoolean(); | |
2034 if (value.isNumber()) | |
2035 return value.toInt32() != 0; | |
2036 if (value.isString()) { | |
2037 string valueString = value.toString(); | |
2038 if (valueString == "true" || valueString == "1") | |
2039 return true; | |
2040 if (valueString == "false" || valueString == "0") | |
2041 return false; | |
2042 } | |
2043 printErrorMessage("Invalid value. Expected boolean value."); | |
2044 return false; | |
2045 } | |
2046 | |
2047 int32_t TestRunner::cppVariantToInt32(const CppVariant& value) | |
2048 { | |
2049 if (value.isNumber()) | |
2050 return value.toInt32(); | |
2051 if (value.isString()) { | |
2052 string stringSource = value.toString(); | |
2053 const char* source = stringSource.data(); | |
2054 char* end; | |
2055 long number = strtol(source, &end, 10); | |
2056 if (end == source + stringSource.length() && number >= numeric_limits<in
t32_t>::min() && number <= numeric_limits<int32_t>::max()) | |
2057 return static_cast<int32_t>(number); | |
2058 } | |
2059 printErrorMessage("Invalid value for preference. Expected integer value."); | |
2060 return 0; | |
2061 } | |
2062 | |
2063 WebString TestRunner::cppVariantToWebString(const CppVariant& value) | |
2064 { | |
2065 if (!value.isString()) { | |
2066 printErrorMessage("Invalid value for preference. Expected string value."
); | |
2067 return WebString(); | |
2068 } | |
2069 return WebString::fromUTF8(value.toString()); | |
2070 } | |
2071 | |
2072 void TestRunner::printErrorMessage(const string& text) | |
2073 { | |
2074 m_delegate->printMessage(string("CONSOLE MESSAGE: ") + text + "\n"); | |
2075 } | |
2076 | |
2077 void TestRunner::fallbackMethod(const CppArgumentList&, CppVariant* result) | |
2078 { | |
2079 printErrorMessage("JavaScript ERROR: unknown method called on TestRunner"); | |
2080 result->setNull(); | |
2081 } | |
2082 | |
2083 void TestRunner::notImplemented(const CppArgumentList&, CppVariant* result) | |
2084 { | |
2085 result->setNull(); | |
2086 } | |
2087 | |
2088 void TestRunner::didAcquirePointerLock(const CppArgumentList&, CppVariant* resul
t) | |
2089 { | |
2090 didAcquirePointerLockInternal(); | |
2091 result->setNull(); | |
2092 } | |
2093 | |
2094 void TestRunner::didNotAcquirePointerLock(const CppArgumentList&, CppVariant* re
sult) | |
2095 { | |
2096 didNotAcquirePointerLockInternal(); | |
2097 result->setNull(); | |
2098 } | |
2099 | |
2100 void TestRunner::didLosePointerLock(const CppArgumentList&, CppVariant* result) | |
2101 { | |
2102 didLosePointerLockInternal(); | |
2103 result->setNull(); | |
2104 } | |
2105 | |
2106 void TestRunner::setPointerLockWillRespondAsynchronously(const CppArgumentList&,
CppVariant* result) | |
2107 { | |
2108 m_pointerLockPlannedResult = PointerLockWillRespondAsync; | |
2109 result->setNull(); | |
2110 } | |
2111 | |
2112 void TestRunner::setPointerLockWillFailSynchronously(const CppArgumentList&, Cpp
Variant* result) | |
2113 { | |
2114 m_pointerLockPlannedResult = PointerLockWillFailSync; | |
2115 result->setNull(); | |
2116 } | |
2117 | |
2118 } | |
OLD | NEW |