TestRunnerEfl.cpp 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851
  1. /*
  2. * Copyright (C) 2007, 2012 Apple Inc. All rights reserved.
  3. * Copyright (C) 2007 Eric Seidel <eric@webkit.org>
  4. * Copyright (C) 2008 Nuanti Ltd.
  5. * Copyright (C) 2009 Jan Michael Alonzo <jmalonzo@gmail.com>
  6. * Copyright (C) 2009,2011 Collabora Ltd.
  7. * Copyright (C) 2010 Joone Hur <joone@kldp.org>
  8. * Copyright (C) 2011 ProFUSION Embedded Systems
  9. * Copyright (C) 2011 Samsung Electronics
  10. * Copyright (C) 2012 Intel Corporation
  11. *
  12. * Redistribution and use in source and binary forms, with or without
  13. * modification, are permitted provided that the following conditions
  14. * are met:
  15. *
  16. * 1. Redistributions of source code must retain the above copyright
  17. * notice, this list of conditions and the following disclaimer.
  18. * 2. Redistributions in binary form must reproduce the above copyright
  19. * notice, this list of conditions and the following disclaimer in the
  20. * documentation and/or other materials provided with the distribution.
  21. * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
  22. * its contributors may be used to endorse or promote products derived
  23. * from this software without specific prior written permission.
  24. *
  25. * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
  26. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  27. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  28. * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
  29. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  30. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  31. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  32. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  33. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  34. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  35. */
  36. #include "config.h"
  37. #include "TestRunner.h"
  38. #include "DumpRenderTree.h"
  39. #include "DumpRenderTreeChrome.h"
  40. #include "JSStringUtils.h"
  41. #include "NotImplemented.h"
  42. #include "WebCoreSupport/DumpRenderTreeSupportEfl.h"
  43. #include "WorkQueue.h"
  44. #include "WorkQueueItem.h"
  45. #include "ewk_private.h"
  46. #include <EWebKit.h>
  47. #include <Ecore_File.h>
  48. #include <JavaScriptCore/JSRetainPtr.h>
  49. #include <JavaScriptCore/JSStringRef.h>
  50. #include <JavaScriptCore/OpaqueJSString.h>
  51. #include <KURL.h>
  52. #include <editing/FindOptions.h>
  53. #include <stdio.h>
  54. #include <wtf/text/WTFString.h>
  55. // Same as Mac cache model enum in Source/WebKit/mac/WebView/WebPreferences.h.
  56. enum {
  57. WebCacheModelDocumentViewer = 0,
  58. WebCacheModelDocumentBrowser = 1,
  59. WebCacheModelPrimaryWebBrowser = 2
  60. };
  61. TestRunner::~TestRunner()
  62. {
  63. }
  64. void TestRunner::addDisallowedURL(JSStringRef)
  65. {
  66. notImplemented();
  67. }
  68. void TestRunner::clearBackForwardList()
  69. {
  70. Ewk_History* history = ewk_view_history_get(browser->mainView());
  71. if (!history)
  72. return;
  73. Ewk_History_Item* item = ewk_history_history_item_current_get(history);
  74. ewk_history_clear(history);
  75. ewk_history_history_item_add(history, item);
  76. ewk_history_history_item_set(history, item);
  77. ewk_history_item_free(item);
  78. }
  79. JSStringRef TestRunner::copyDecodedHostName(JSStringRef)
  80. {
  81. notImplemented();
  82. return 0;
  83. }
  84. JSStringRef TestRunner::copyEncodedHostName(JSStringRef)
  85. {
  86. notImplemented();
  87. return 0;
  88. }
  89. void TestRunner::dispatchPendingLoadRequests()
  90. {
  91. // FIXME: Implement for testing fix for 6727495
  92. notImplemented();
  93. }
  94. void TestRunner::display()
  95. {
  96. displayWebView();
  97. }
  98. void TestRunner::keepWebHistory()
  99. {
  100. DumpRenderTreeSupportEfl::setShouldTrackVisitedLinks(true);
  101. }
  102. size_t TestRunner::webHistoryItemCount()
  103. {
  104. const Ewk_History* history = ewk_view_history_get(browser->mainView());
  105. if (!history)
  106. return -1;
  107. return ewk_history_back_list_length(history) + ewk_history_forward_list_length(history);
  108. }
  109. void TestRunner::notifyDone()
  110. {
  111. if (m_waitToDump && !topLoadingFrame && !WorkQueue::shared()->count())
  112. dump();
  113. m_waitToDump = false;
  114. waitForPolicy = false;
  115. }
  116. JSStringRef TestRunner::pathToLocalResource(JSContextRef context, JSStringRef url)
  117. {
  118. String requestedUrl(url->characters(), url->length());
  119. String resourceRoot;
  120. String requestedRoot;
  121. if (requestedUrl.find("LayoutTests") != notFound) {
  122. // If the URL contains LayoutTests we need to remap that to
  123. // LOCAL_RESOURCE_ROOT which is the path of the LayoutTests directory
  124. // within the WebKit source tree.
  125. requestedRoot = "/tmp/LayoutTests";
  126. resourceRoot = getenv("LOCAL_RESOURCE_ROOT");
  127. } else if (requestedUrl.find("tmp") != notFound) {
  128. // If the URL is a child of /tmp we need to convert it to be a child
  129. // DUMPRENDERTREE_TEMP replace tmp with DUMPRENDERTREE_TEMP
  130. requestedRoot = "/tmp";
  131. resourceRoot = getenv("DUMPRENDERTREE_TEMP");
  132. }
  133. size_t indexOfRootStart = requestedUrl.reverseFind(requestedRoot);
  134. size_t indexOfSeparatorAfterRoot = indexOfRootStart + requestedRoot.length();
  135. String fullPathToUrl = "file://" + resourceRoot + requestedUrl.substring(indexOfSeparatorAfterRoot);
  136. return JSStringCreateWithUTF8CString(fullPathToUrl.utf8().data());
  137. }
  138. void TestRunner::queueLoad(JSStringRef url, JSStringRef target)
  139. {
  140. WebCore::KURL baseURL(WebCore::KURL(), String::fromUTF8(ewk_frame_uri_get(browser->mainFrame())));
  141. WebCore::KURL absoluteURL(baseURL, url->string());
  142. JSRetainPtr<JSStringRef> jsAbsoluteURL(
  143. Adopt, JSStringCreateWithUTF8CString(absoluteURL.string().utf8().data()));
  144. WorkQueue::shared()->queue(new LoadItem(jsAbsoluteURL.get(), target));
  145. }
  146. void TestRunner::setAcceptsEditing(bool acceptsEditing)
  147. {
  148. ewk_view_editable_set(browser->mainView(), acceptsEditing);
  149. }
  150. void TestRunner::setAlwaysAcceptCookies(bool alwaysAcceptCookies)
  151. {
  152. ewk_cookies_policy_set(alwaysAcceptCookies ? EWK_COOKIE_JAR_ACCEPT_ALWAYS : EWK_COOKIE_JAR_ACCEPT_NEVER);
  153. }
  154. void TestRunner::setCustomPolicyDelegate(bool enabled, bool permissive)
  155. {
  156. policyDelegateEnabled = enabled;
  157. policyDelegatePermissive = permissive;
  158. }
  159. void TestRunner::waitForPolicyDelegate()
  160. {
  161. setCustomPolicyDelegate(true, false);
  162. waitForPolicy = true;
  163. setWaitToDump(true);
  164. }
  165. void TestRunner::setScrollbarPolicy(JSStringRef, JSStringRef)
  166. {
  167. notImplemented();
  168. }
  169. void TestRunner::addOriginAccessWhitelistEntry(JSStringRef sourceOrigin, JSStringRef protocol, JSStringRef host, bool includeSubdomains)
  170. {
  171. WebCore::KURL kurl;
  172. kurl.setProtocol(String(protocol->characters(), protocol->length()));
  173. kurl.setHost(String(host->characters(), host->length()));
  174. ewk_security_policy_whitelist_origin_add(sourceOrigin->string().utf8().data(), kurl.string().utf8().data(), includeSubdomains);
  175. }
  176. void TestRunner::removeOriginAccessWhitelistEntry(JSStringRef sourceOrigin, JSStringRef protocol, JSStringRef host, bool includeSubdomains)
  177. {
  178. WebCore::KURL kurl;
  179. kurl.setProtocol(String(protocol->characters(), protocol->length()));
  180. kurl.setHost(String(host->characters(), host->length()));
  181. ewk_security_policy_whitelist_origin_del(sourceOrigin->string().utf8().data(), kurl.string().utf8().data(), includeSubdomains);
  182. }
  183. void TestRunner::setMainFrameIsFirstResponder(bool)
  184. {
  185. notImplemented();
  186. }
  187. void TestRunner::setTabKeyCyclesThroughElements(bool)
  188. {
  189. notImplemented();
  190. }
  191. void TestRunner::setUseDashboardCompatibilityMode(bool)
  192. {
  193. notImplemented();
  194. }
  195. static CString gUserStyleSheet;
  196. static bool gUserStyleSheetEnabled = true;
  197. void TestRunner::setUserStyleSheetEnabled(bool flag)
  198. {
  199. gUserStyleSheetEnabled = flag;
  200. ewk_view_setting_user_stylesheet_set(browser->mainView(), flag ? gUserStyleSheet.data() : 0);
  201. }
  202. void TestRunner::setUserStyleSheetLocation(JSStringRef path)
  203. {
  204. gUserStyleSheet = path->string().utf8();
  205. if (gUserStyleSheetEnabled)
  206. setUserStyleSheetEnabled(true);
  207. }
  208. void TestRunner::setValueForUser(JSContextRef context, JSValueRef nodeObject, JSStringRef value)
  209. {
  210. DumpRenderTreeSupportEfl::setValueForUser(context, nodeObject, value->string());
  211. }
  212. void TestRunner::setViewModeMediaFeature(JSStringRef mode)
  213. {
  214. #if ENABLE(VIEW_MODE_CSS_MEDIA)
  215. Evas_Object* view = browser->mainView();
  216. if (!view)
  217. return;
  218. if (equals(mode, "windowed"))
  219. ewk_view_mode_set(view, EWK_VIEW_MODE_WINDOWED);
  220. else if (equals(mode, "floating"))
  221. ewk_view_mode_set(view, EWK_VIEW_MODE_FLOATING);
  222. else if (equals(mode, "fullscreen"))
  223. ewk_view_mode_set(view, EWK_VIEW_MODE_FULLSCREEN);
  224. else if (equals(mode, "maximized"))
  225. ewk_view_mode_set(view, EWK_VIEW_MODE_MAXIMIZED);
  226. else if (equals(mode, "minimized"))
  227. ewk_view_mode_set(view, EWK_VIEW_MODE_MINIMIZED);
  228. #else
  229. UNUSED_PARAM(mode);
  230. #endif
  231. }
  232. void TestRunner::setWindowIsKey(bool)
  233. {
  234. notImplemented();
  235. }
  236. static Eina_Bool waitToDumpWatchdogFired(void*)
  237. {
  238. waitToDumpWatchdog = 0;
  239. gTestRunner->waitToDumpWatchdogTimerFired();
  240. return ECORE_CALLBACK_CANCEL;
  241. }
  242. void TestRunner::setWaitToDump(bool waitUntilDone)
  243. {
  244. static const double timeoutSeconds = 30;
  245. m_waitToDump = waitUntilDone;
  246. if (m_waitToDump && shouldSetWaitToDumpWatchdog())
  247. waitToDumpWatchdog = ecore_timer_add(timeoutSeconds, waitToDumpWatchdogFired, 0);
  248. }
  249. int TestRunner::windowCount()
  250. {
  251. return browser->extraViews().size() + 1; // + 1 for the main view.
  252. }
  253. void TestRunner::setPrivateBrowsingEnabled(bool flag)
  254. {
  255. ewk_view_setting_private_browsing_set(browser->mainView(), flag);
  256. }
  257. void TestRunner::setJavaScriptCanAccessClipboard(bool flag)
  258. {
  259. ewk_view_setting_scripts_can_access_clipboard_set(browser->mainView(), flag);
  260. }
  261. void TestRunner::setXSSAuditorEnabled(bool flag)
  262. {
  263. ewk_view_setting_enable_xss_auditor_set(browser->mainView(), flag);
  264. }
  265. void TestRunner::setSpatialNavigationEnabled(bool flag)
  266. {
  267. ewk_view_setting_spatial_navigation_set(browser->mainView(), flag);
  268. }
  269. void TestRunner::setAllowUniversalAccessFromFileURLs(bool flag)
  270. {
  271. ewk_view_setting_allow_universal_access_from_file_urls_set(browser->mainView(), flag);
  272. }
  273. void TestRunner::setAllowFileAccessFromFileURLs(bool flag)
  274. {
  275. ewk_view_setting_allow_file_access_from_file_urls_set(browser->mainView(), flag);
  276. }
  277. void TestRunner::setAuthorAndUserStylesEnabled(bool flag)
  278. {
  279. DumpRenderTreeSupportEfl::setAuthorAndUserStylesEnabled(browser->mainView(), flag);
  280. }
  281. void TestRunner::setMockDeviceOrientation(bool, double, bool, double, bool, double)
  282. {
  283. // FIXME: Implement for DeviceOrientation layout tests.
  284. // See https://bugs.webkit.org/show_bug.cgi?id=30335.
  285. notImplemented();
  286. }
  287. void TestRunner::setMockGeolocationPosition(double latitude, double longitude, double accuracy, bool canProvideAltitude, double altitude, bool canProvideAltitudeAccuracy, double altitudeAccuracy, bool canProvideHeading, double heading, bool canProvideSpeed, double speed)
  288. {
  289. Evas_Object* view = browser->mainView();
  290. if (browser->extraViews().size() > 0)
  291. view = browser->extraViews().last();
  292. DumpRenderTreeSupportEfl::setMockGeolocationPosition(view, latitude, longitude, accuracy, canProvideAltitude, altitude, canProvideAltitudeAccuracy, altitudeAccuracy, canProvideHeading, heading, canProvideSpeed, speed);
  293. }
  294. void TestRunner::setMockGeolocationPositionUnavailableError(JSStringRef message)
  295. {
  296. Evas_Object* view = browser->mainView();
  297. if (browser->extraViews().size() > 0)
  298. view = browser->extraViews().last();
  299. DumpRenderTreeSupportEfl::setMockGeolocationPositionUnavailableError(view, message->string().utf8().data());
  300. }
  301. void TestRunner::setGeolocationPermission(bool allow)
  302. {
  303. setGeolocationPermissionCommon(allow);
  304. Evas_Object* view = browser->mainView();
  305. if (browser->extraViews().size() > 0)
  306. view = browser->extraViews().last();
  307. DumpRenderTreeSupportEfl::setMockGeolocationPermission(view, allow);
  308. }
  309. int TestRunner::numberOfPendingGeolocationPermissionRequests()
  310. {
  311. Evas_Object* view = browser->mainView();
  312. if (browser->extraViews().size() > 0)
  313. view = browser->extraViews().last();
  314. return DumpRenderTreeSupportEfl::numberOfPendingGeolocationPermissionRequests(view);
  315. }
  316. void TestRunner::addMockSpeechInputResult(JSStringRef, double, JSStringRef)
  317. {
  318. // FIXME: Implement for speech input layout tests.
  319. // See https://bugs.webkit.org/show_bug.cgi?id=39485.
  320. notImplemented();
  321. }
  322. void TestRunner::setMockSpeechInputDumpRect(bool)
  323. {
  324. // FIXME: Implement for speech input layout tests.
  325. // See https://bugs.webkit.org/show_bug.cgi?id=39485.
  326. notImplemented();
  327. }
  328. void TestRunner::startSpeechInput(JSContextRef inputElement)
  329. {
  330. // FIXME: Implement for speech input layout tests.
  331. // See https://bugs.webkit.org/show_bug.cgi?id=39485.
  332. notImplemented();
  333. }
  334. void TestRunner::setIconDatabaseEnabled(bool enabled)
  335. {
  336. ewk_settings_icon_database_path_set(0);
  337. if (!enabled)
  338. return;
  339. String databasePath;
  340. const char* tempDir = getenv("TMPDIR");
  341. if (tempDir)
  342. databasePath = String::fromUTF8(tempDir);
  343. else if (tempDir = getenv("TEMP"))
  344. databasePath = String::fromUTF8(tempDir);
  345. else
  346. databasePath = String::fromUTF8("/tmp");
  347. databasePath.append("/DumpRenderTree/IconDatabase");
  348. if (ecore_file_mkpath(databasePath.utf8().data()))
  349. ewk_settings_icon_database_path_set(databasePath.utf8().data());
  350. }
  351. void TestRunner::setPopupBlockingEnabled(bool flag)
  352. {
  353. ewk_view_setting_scripts_can_open_windows_set(browser->mainView(), !flag);
  354. }
  355. void TestRunner::setPluginsEnabled(bool flag)
  356. {
  357. ewk_view_setting_enable_plugins_set(browser->mainView(), flag);
  358. }
  359. void TestRunner::execCommand(JSStringRef name, JSStringRef value)
  360. {
  361. DumpRenderTreeSupportEfl::executeCoreCommandByName(browser->mainView(), name->string().utf8().data(), value->string().utf8().data());
  362. }
  363. bool TestRunner::findString(JSContextRef context, JSStringRef target, JSObjectRef optionsArray)
  364. {
  365. JSRetainPtr<JSStringRef> lengthPropertyName(Adopt, JSStringCreateWithUTF8CString("length"));
  366. JSValueRef lengthValue = JSObjectGetProperty(context, optionsArray, lengthPropertyName.get(), 0);
  367. if (!JSValueIsNumber(context, lengthValue))
  368. return false;
  369. WebCore::FindOptions options = 0;
  370. const size_t length = static_cast<size_t>(JSValueToNumber(context, lengthValue, 0));
  371. for (size_t i = 0; i < length; ++i) {
  372. JSValueRef value = JSObjectGetPropertyAtIndex(context, optionsArray, i, 0);
  373. if (!JSValueIsString(context, value))
  374. continue;
  375. JSRetainPtr<JSStringRef> optionName(Adopt, JSValueToStringCopy(context, value, 0));
  376. if (equals(optionName, "CaseInsensitive"))
  377. options |= WebCore::CaseInsensitive;
  378. else if (equals(optionName, "AtWordStarts"))
  379. options |= WebCore::AtWordStarts;
  380. else if (equals(optionName, "TreatMedialCapitalAsWordStart"))
  381. options |= WebCore::TreatMedialCapitalAsWordStart;
  382. else if (equals(optionName, "Backwards"))
  383. options |= WebCore::Backwards;
  384. else if (equals(optionName, "WrapAround"))
  385. options |= WebCore::WrapAround;
  386. else if (equals(optionName, "StartInSelection"))
  387. options |= WebCore::StartInSelection;
  388. }
  389. return DumpRenderTreeSupportEfl::findString(browser->mainView(), target->string(), options);
  390. }
  391. bool TestRunner::isCommandEnabled(JSStringRef name)
  392. {
  393. return DumpRenderTreeSupportEfl::isCommandEnabled(browser->mainView(), name->string().utf8().data());
  394. }
  395. void TestRunner::setCacheModel(int cacheModel)
  396. {
  397. unsigned int cacheTotalCapacity;
  398. unsigned int cacheMinDeadCapacity;
  399. unsigned int cacheMaxDeadCapacity;
  400. double deadDecodedDataDeletionInterval;
  401. unsigned int pageCacheCapacity;
  402. // These constants are derived from the Mac cache model enum in Source/WebKit/mac/WebView/WebPreferences.h.
  403. switch (cacheModel) {
  404. case WebCacheModelDocumentViewer:
  405. pageCacheCapacity = 0;
  406. cacheTotalCapacity = 0;
  407. cacheMinDeadCapacity = 0;
  408. cacheMaxDeadCapacity = 0;
  409. deadDecodedDataDeletionInterval = 0;
  410. break;
  411. case WebCacheModelDocumentBrowser:
  412. pageCacheCapacity = 2;
  413. cacheTotalCapacity = 16 * 1024 * 1024;
  414. cacheMinDeadCapacity = cacheTotalCapacity / 8;
  415. cacheMaxDeadCapacity = cacheTotalCapacity / 4;
  416. deadDecodedDataDeletionInterval = 0;
  417. break;
  418. case WebCacheModelPrimaryWebBrowser:
  419. pageCacheCapacity = 3;
  420. cacheTotalCapacity = 32 * 1024 * 1024;
  421. cacheMinDeadCapacity = cacheTotalCapacity / 4;
  422. cacheMaxDeadCapacity = cacheTotalCapacity / 2;
  423. deadDecodedDataDeletionInterval = 60;
  424. break;
  425. default:
  426. fprintf(stderr, "trying to set an invalid value %d for the Cache model.", cacheModel);
  427. return;
  428. }
  429. ewk_settings_object_cache_capacity_set(cacheMinDeadCapacity, cacheMaxDeadCapacity, cacheTotalCapacity);
  430. DumpRenderTreeSupportEfl::setDeadDecodedDataDeletionInterval(deadDecodedDataDeletionInterval);
  431. ewk_settings_page_cache_capacity_set(pageCacheCapacity);
  432. }
  433. void TestRunner::setPersistentUserStyleSheetLocation(JSStringRef)
  434. {
  435. notImplemented();
  436. }
  437. void TestRunner::clearPersistentUserStyleSheet()
  438. {
  439. notImplemented();
  440. }
  441. void TestRunner::clearAllApplicationCaches()
  442. {
  443. ewk_settings_application_cache_clear();
  444. }
  445. void TestRunner::setApplicationCacheOriginQuota(unsigned long long quota)
  446. {
  447. Ewk_Security_Origin* origin = ewk_frame_security_origin_get(browser->mainFrame());
  448. ewk_security_origin_application_cache_quota_set(origin, quota);
  449. ewk_security_origin_free(origin);
  450. }
  451. void TestRunner::clearApplicationCacheForOrigin(OpaqueJSString* url)
  452. {
  453. Ewk_Security_Origin* origin = ewk_security_origin_new_from_string(url->string().utf8().data());
  454. ewk_security_origin_application_cache_clear(origin);
  455. ewk_security_origin_free(origin);
  456. }
  457. long long TestRunner::localStorageDiskUsageForOrigin(JSStringRef)
  458. {
  459. // FIXME: Implement to support getting disk usage in bytes for an origin.
  460. notImplemented();
  461. return 0;
  462. }
  463. JSValueRef TestRunner::originsWithApplicationCache(JSContextRef context)
  464. {
  465. // FIXME: Implement to get origins that contain application caches.
  466. notImplemented();
  467. return JSValueMakeUndefined(context);
  468. }
  469. long long TestRunner::applicationCacheDiskUsageForOrigin(JSStringRef)
  470. {
  471. notImplemented();
  472. return 0;
  473. }
  474. void TestRunner::clearAllDatabases()
  475. {
  476. ewk_web_database_remove_all();
  477. }
  478. void TestRunner::setDatabaseQuota(unsigned long long quota)
  479. {
  480. Ewk_Security_Origin* origin = ewk_frame_security_origin_get(browser->mainFrame());
  481. ewk_security_origin_web_database_quota_set(origin, quota);
  482. ewk_security_origin_free(origin);
  483. }
  484. JSValueRef TestRunner::originsWithLocalStorage(JSContextRef context)
  485. {
  486. notImplemented();
  487. return JSValueMakeUndefined(context);
  488. }
  489. void TestRunner::deleteAllLocalStorage()
  490. {
  491. notImplemented();
  492. }
  493. void TestRunner::deleteLocalStorageForOrigin(JSStringRef)
  494. {
  495. notImplemented();
  496. }
  497. void TestRunner::observeStorageTrackerNotifications(unsigned)
  498. {
  499. notImplemented();
  500. }
  501. void TestRunner::syncLocalStorage()
  502. {
  503. notImplemented();
  504. }
  505. void TestRunner::setDomainRelaxationForbiddenForURLScheme(bool forbidden, JSStringRef scheme)
  506. {
  507. DumpRenderTreeSupportEfl::setDomainRelaxationForbiddenForURLScheme(forbidden, scheme->string());
  508. }
  509. void TestRunner::goBack()
  510. {
  511. ewk_frame_back(browser->mainFrame());
  512. }
  513. void TestRunner::setDefersLoading(bool defers)
  514. {
  515. DumpRenderTreeSupportEfl::setDefersLoading(browser->mainView(), defers);
  516. }
  517. void TestRunner::setAppCacheMaximumSize(unsigned long long size)
  518. {
  519. ewk_settings_application_cache_max_quota_set(size);
  520. }
  521. static inline bool toBool(JSStringRef value)
  522. {
  523. return equals(value, "true") || equals(value, "1");
  524. }
  525. static inline int toInt(JSStringRef value)
  526. {
  527. return atoi(value->string().utf8().data());
  528. }
  529. void TestRunner::overridePreference(JSStringRef key, JSStringRef value)
  530. {
  531. if (equals(key, "WebKitJavaScriptEnabled"))
  532. ewk_view_setting_enable_scripts_set(browser->mainView(), toBool(value));
  533. else if (equals(key, "WebKitDefaultFontSize"))
  534. ewk_view_setting_font_default_size_set(browser->mainView(), toInt(value));
  535. else if (equals(key, "WebKitMinimumFontSize"))
  536. ewk_view_setting_font_minimum_size_set(browser->mainView(), toInt(value));
  537. else if (equals(key, "WebKitPluginsEnabled"))
  538. ewk_view_setting_enable_plugins_set(browser->mainView(), toBool(value));
  539. else if (equals(key, "WebKitWebGLEnabled"))
  540. ewk_view_setting_enable_webgl_set(browser->mainView(), toBool(value));
  541. else if (equals(key, "WebKitEnableCaretBrowsing"))
  542. ewk_view_setting_caret_browsing_set(browser->mainView(), toBool(value));
  543. else if (equals(key, "WebKitUsesPageCachePreferenceKey"))
  544. ewk_view_setting_page_cache_set(browser->mainView(), toBool(value));
  545. else if (equals(key, "WebKitHyperlinkAuditingEnabled"))
  546. ewk_view_setting_enable_hyperlink_auditing_set(browser->mainView(), toBool(value));
  547. else if (equals(key, "WebKitTabToLinksPreferenceKey"))
  548. ewk_view_setting_include_links_in_focus_chain_set(browser->mainView(), toBool(value));
  549. else if (equals(key, "WebKitOfflineWebApplicationCacheEnabled"))
  550. ewk_view_setting_application_cache_set(browser->mainView(), toBool(value));
  551. else if (equals(key, "WebKitLoadSiteIconsKey"))
  552. DumpRenderTreeSupportEfl::setLoadsSiteIconsIgnoringImageLoadingSetting(browser->mainView(), toBool(value));
  553. else if (equals(key, "WebKitCSSGridLayoutEnabled"))
  554. DumpRenderTreeSupportEfl::setCSSGridLayoutEnabled(browser->mainView(), toBool(value));
  555. else if (equals(key, "WebKitCSSRegionsEnabled"))
  556. DumpRenderTreeSupportEfl::setCSSRegionsEnabled(browser->mainView(), toBool(value));
  557. else if (equals(key, "WebKitWebAudioEnabled"))
  558. DumpRenderTreeSupportEfl::setWebAudioEnabled(browser->mainView(), toBool(value));
  559. else if (equals(key, "WebKitDisplayImagesKey"))
  560. ewk_view_setting_auto_load_images_set(browser->mainView(), toBool(value));
  561. else
  562. fprintf(stderr, "TestRunner::overridePreference tried to override unknown preference '%s'.\n", value->string().utf8().data());
  563. }
  564. void TestRunner::addUserScript(JSStringRef source, bool runAtStart, bool allFrames)
  565. {
  566. DumpRenderTreeSupportEfl::addUserScript(browser->mainView(), source->string(), runAtStart, allFrames);
  567. }
  568. void TestRunner::addUserStyleSheet(JSStringRef source, bool allFrames)
  569. {
  570. DumpRenderTreeSupportEfl::addUserStyleSheet(browser->mainView(), source->string(), allFrames);
  571. }
  572. void TestRunner::setDeveloperExtrasEnabled(bool enabled)
  573. {
  574. ewk_view_setting_enable_developer_extras_set(browser->mainView(), enabled);
  575. }
  576. void TestRunner::showWebInspector()
  577. {
  578. ewk_view_inspector_show(browser->mainView());
  579. browser->waitInspectorLoadFinished();
  580. }
  581. void TestRunner::closeWebInspector()
  582. {
  583. ewk_view_inspector_close(browser->mainView());
  584. }
  585. void TestRunner::evaluateInWebInspector(long callId, JSStringRef script)
  586. {
  587. DumpRenderTreeSupportEfl::evaluateInWebInspector(browser->mainView(), callId, script->string());
  588. }
  589. void TestRunner::evaluateScriptInIsolatedWorldAndReturnValue(unsigned, JSObjectRef, JSStringRef)
  590. {
  591. notImplemented();
  592. }
  593. void TestRunner::evaluateScriptInIsolatedWorld(unsigned worldID, JSObjectRef globalObject, JSStringRef script)
  594. {
  595. DumpRenderTreeSupportEfl::evaluateScriptInIsolatedWorld(browser->mainFrame(), worldID, globalObject, script->string());
  596. }
  597. void TestRunner::removeAllVisitedLinks()
  598. {
  599. Ewk_History* history = ewk_view_history_get(browser->mainView());
  600. if (!history)
  601. return;
  602. ewk_history_clear(history);
  603. }
  604. bool TestRunner::callShouldCloseOnWebView()
  605. {
  606. return DumpRenderTreeSupportEfl::callShouldCloseOnWebView(browser->mainFrame());
  607. }
  608. void TestRunner::apiTestNewWindowDataLoadBaseURL(JSStringRef, JSStringRef)
  609. {
  610. notImplemented();
  611. }
  612. void TestRunner::apiTestGoToCurrentBackForwardItem()
  613. {
  614. notImplemented();
  615. }
  616. void TestRunner::setWebViewEditable(bool)
  617. {
  618. ewk_frame_editable_set(browser->mainFrame(), EINA_TRUE);
  619. }
  620. void TestRunner::authenticateSession(JSStringRef, JSStringRef, JSStringRef)
  621. {
  622. notImplemented();
  623. }
  624. void TestRunner::abortModal()
  625. {
  626. notImplemented();
  627. }
  628. void TestRunner::setSerializeHTTPLoads(bool serialize)
  629. {
  630. DumpRenderTreeSupportEfl::setSerializeHTTPLoads(serialize);
  631. }
  632. void TestRunner::setTextDirection(JSStringRef direction)
  633. {
  634. Ewk_Text_Direction ewkDirection;
  635. if (JSStringIsEqualToUTF8CString(direction, "auto"))
  636. ewkDirection = EWK_TEXT_DIRECTION_DEFAULT;
  637. else if (JSStringIsEqualToUTF8CString(direction, "rtl"))
  638. ewkDirection = EWK_TEXT_DIRECTION_RIGHT_TO_LEFT;
  639. else if (JSStringIsEqualToUTF8CString(direction, "ltr"))
  640. ewkDirection = EWK_TEXT_DIRECTION_LEFT_TO_RIGHT;
  641. else {
  642. fprintf(stderr, "TestRunner::setTextDirection called with unknown direction: '%s'.\n", direction->string().utf8().data());
  643. return;
  644. }
  645. ewk_view_text_direction_set(browser->mainView(), ewkDirection);
  646. }
  647. void TestRunner::addChromeInputField()
  648. {
  649. notImplemented();
  650. }
  651. void TestRunner::removeChromeInputField()
  652. {
  653. notImplemented();
  654. }
  655. void TestRunner::focusWebView()
  656. {
  657. notImplemented();
  658. }
  659. void TestRunner::setBackingScaleFactor(double)
  660. {
  661. notImplemented();
  662. }
  663. void TestRunner::grantWebNotificationPermission(JSStringRef origin)
  664. {
  665. }
  666. void TestRunner::denyWebNotificationPermission(JSStringRef jsOrigin)
  667. {
  668. }
  669. void TestRunner::removeAllWebNotificationPermissions()
  670. {
  671. }
  672. void TestRunner::simulateWebNotificationClick(JSValueRef jsNotification)
  673. {
  674. }
  675. void TestRunner::simulateLegacyWebNotificationClick(JSStringRef title)
  676. {
  677. }
  678. void TestRunner::resetPageVisibility()
  679. {
  680. ewk_view_visibility_state_set(browser->mainView(), EWK_PAGE_VISIBILITY_STATE_VISIBLE, true);
  681. }
  682. void TestRunner::setPageVisibility(const char* visibility)
  683. {
  684. String newVisibility(visibility);
  685. if (newVisibility == "visible")
  686. ewk_view_visibility_state_set(browser->mainView(), EWK_PAGE_VISIBILITY_STATE_VISIBLE, false);
  687. else if (newVisibility == "hidden")
  688. ewk_view_visibility_state_set(browser->mainView(), EWK_PAGE_VISIBILITY_STATE_HIDDEN, false);
  689. else if (newVisibility == "prerender")
  690. ewk_view_visibility_state_set(browser->mainView(), EWK_PAGE_VISIBILITY_STATE_PRERENDER, false);
  691. else if (newVisibility == "unloaded")
  692. ewk_view_visibility_state_set(browser->mainView(), EWK_PAGE_VISIBILITY_STATE_UNLOADED, false);
  693. }
  694. void TestRunner::setAutomaticLinkDetectionEnabled(bool)
  695. {
  696. notImplemented();
  697. }
  698. void TestRunner::setStorageDatabaseIdleInterval(double)
  699. {
  700. notImplemented();
  701. }
  702. void TestRunner::closeIdleLocalStorageDatabases()
  703. {
  704. notImplemented();
  705. }
  706. JSRetainPtr<JSStringRef> TestRunner::platformName() const
  707. {
  708. JSRetainPtr<JSStringRef> platformName(Adopt, JSStringCreateWithUTF8CString("efl"));
  709. return platformName;
  710. }