~ubuntu-branches/ubuntu/raring/qtwebkit-source/raring-proposed

« back to all changes in this revision

Viewing changes to Tools/DumpRenderTree/efl/TestRunnerEfl.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-02-18 14:24:18 UTC
  • Revision ID: package-import@ubuntu.com-20130218142418-eon0jmjg3nj438uy
Tags: upstream-2.3
ImportĀ upstreamĀ versionĀ 2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
37
#include "config.h"
 
38
#include "TestRunner.h"
 
39
 
 
40
#include "DumpRenderTree.h"
 
41
#include "DumpRenderTreeChrome.h"
 
42
#include "JSStringUtils.h"
 
43
#include "NotImplemented.h"
 
44
#include "WebCoreSupport/DumpRenderTreeSupportEfl.h"
 
45
#include "WorkQueue.h"
 
46
#include "WorkQueueItem.h"
 
47
#include "ewk_private.h"
 
48
#include <EWebKit.h>
 
49
#include <Ecore_File.h>
 
50
#include <JavaScriptCore/JSRetainPtr.h>
 
51
#include <JavaScriptCore/JSStringRef.h>
 
52
#include <JavaScriptCore/OpaqueJSString.h>
 
53
#include <KURL.h>
 
54
#include <editing/FindOptions.h>
 
55
#include <stdio.h>
 
56
#include <wtf/text/WTFString.h>
 
57
 
 
58
// Same as Mac cache model enum in Source/WebKit/mac/WebView/WebPreferences.h.
 
59
enum {
 
60
    WebCacheModelDocumentViewer = 0,
 
61
    WebCacheModelDocumentBrowser = 1,
 
62
    WebCacheModelPrimaryWebBrowser = 2
 
63
};
 
64
 
 
65
TestRunner::~TestRunner()
 
66
{
 
67
}
 
68
 
 
69
void TestRunner::addDisallowedURL(JSStringRef)
 
70
{
 
71
    notImplemented();
 
72
}
 
73
 
 
74
void TestRunner::clearBackForwardList()
 
75
{
 
76
    Ewk_History* history = ewk_view_history_get(browser->mainView());
 
77
    if (!history)
 
78
        return;
 
79
 
 
80
    Ewk_History_Item* item = ewk_history_history_item_current_get(history);
 
81
    ewk_history_clear(history);
 
82
    ewk_history_history_item_add(history, item);
 
83
    ewk_history_history_item_set(history, item);
 
84
    ewk_history_item_free(item);
 
85
}
 
86
 
 
87
JSStringRef TestRunner::copyDecodedHostName(JSStringRef)
 
88
{
 
89
    notImplemented();
 
90
    return 0;
 
91
}
 
92
 
 
93
JSStringRef TestRunner::copyEncodedHostName(JSStringRef)
 
94
{
 
95
    notImplemented();
 
96
    return 0;
 
97
}
 
98
 
 
99
void TestRunner::dispatchPendingLoadRequests()
 
100
{
 
101
    // FIXME: Implement for testing fix for 6727495
 
102
    notImplemented();
 
103
}
 
104
 
 
105
void TestRunner::display()
 
106
{
 
107
    displayWebView();
 
108
}
 
109
 
 
110
void TestRunner::keepWebHistory()
 
111
{
 
112
    DumpRenderTreeSupportEfl::setShouldTrackVisitedLinks(true);
 
113
}
 
114
 
 
115
JSValueRef TestRunner::computedStyleIncludingVisitedInfo(JSContextRef context, JSValueRef value)
 
116
{
 
117
    return DumpRenderTreeSupportEfl::computedStyleIncludingVisitedInfo(context, value);
 
118
}
 
119
 
 
120
size_t TestRunner::webHistoryItemCount()
 
121
{
 
122
    const Ewk_History* history = ewk_view_history_get(browser->mainView());
 
123
    if (!history)
 
124
        return -1;
 
125
 
 
126
    return ewk_history_back_list_length(history) + ewk_history_forward_list_length(history);
 
127
}
 
128
 
 
129
unsigned TestRunner::workerThreadCount() const
 
130
{
 
131
    return DumpRenderTreeSupportEfl::workerThreadCount();
 
132
}
 
133
 
 
134
void TestRunner::notifyDone()
 
135
{
 
136
    if (m_waitToDump && !topLoadingFrame && !WorkQueue::shared()->count())
 
137
        dump();
 
138
    m_waitToDump = false;
 
139
    waitForPolicy = false;
 
140
}
 
141
 
 
142
JSStringRef TestRunner::pathToLocalResource(JSContextRef context, JSStringRef url)
 
143
{
 
144
    String requestedUrl(url->characters(), url->length());
 
145
    String resourceRoot;
 
146
    String requestedRoot;
 
147
 
 
148
    if (requestedUrl.find("LayoutTests") != notFound) {
 
149
        // If the URL contains LayoutTests we need to remap that to
 
150
        // LOCAL_RESOURCE_ROOT which is the path of the LayoutTests directory
 
151
        // within the WebKit source tree.
 
152
        requestedRoot = "/tmp/LayoutTests";
 
153
        resourceRoot = getenv("LOCAL_RESOURCE_ROOT");
 
154
    } else if (requestedUrl.find("tmp") != notFound) {
 
155
        // If the URL is a child of /tmp we need to convert it to be a child
 
156
        // DUMPRENDERTREE_TEMP replace tmp with DUMPRENDERTREE_TEMP
 
157
        requestedRoot = "/tmp";
 
158
        resourceRoot = getenv("DUMPRENDERTREE_TEMP");
 
159
    }
 
160
 
 
161
    size_t indexOfRootStart = requestedUrl.reverseFind(requestedRoot);
 
162
    size_t indexOfSeparatorAfterRoot = indexOfRootStart + requestedRoot.length();
 
163
    String fullPathToUrl = "file://" + resourceRoot + requestedUrl.substring(indexOfSeparatorAfterRoot);
 
164
 
 
165
    return JSStringCreateWithUTF8CString(fullPathToUrl.utf8().data());
 
166
}
 
167
 
 
168
void TestRunner::queueLoad(JSStringRef url, JSStringRef target)
 
169
{
 
170
    WebCore::KURL baseURL(WebCore::KURL(), String::fromUTF8(ewk_frame_uri_get(browser->mainFrame())));
 
171
    WebCore::KURL absoluteURL(baseURL, url->string());
 
172
 
 
173
    JSRetainPtr<JSStringRef> jsAbsoluteURL(
 
174
        Adopt, JSStringCreateWithUTF8CString(absoluteURL.string().utf8().data()));
 
175
 
 
176
    WorkQueue::shared()->queue(new LoadItem(jsAbsoluteURL.get(), target));
 
177
}
 
178
 
 
179
void TestRunner::setAcceptsEditing(bool acceptsEditing)
 
180
{
 
181
    ewk_view_editable_set(browser->mainView(), acceptsEditing);
 
182
}
 
183
 
 
184
void TestRunner::setAlwaysAcceptCookies(bool alwaysAcceptCookies)
 
185
{
 
186
    ewk_cookies_policy_set(alwaysAcceptCookies ? EWK_COOKIE_JAR_ACCEPT_ALWAYS : EWK_COOKIE_JAR_ACCEPT_NEVER);
 
187
}
 
188
 
 
189
void TestRunner::setCustomPolicyDelegate(bool enabled, bool permissive)
 
190
{
 
191
    policyDelegateEnabled = enabled;
 
192
    policyDelegatePermissive = permissive;
 
193
}
 
194
 
 
195
void TestRunner::waitForPolicyDelegate()
 
196
{
 
197
    setCustomPolicyDelegate(true, false);
 
198
    waitForPolicy = true;
 
199
    setWaitToDump(true);
 
200
}
 
201
 
 
202
void TestRunner::setScrollbarPolicy(JSStringRef, JSStringRef)
 
203
{
 
204
    notImplemented();
 
205
}
 
206
 
 
207
void TestRunner::addOriginAccessWhitelistEntry(JSStringRef sourceOrigin, JSStringRef protocol, JSStringRef host, bool includeSubdomains)
 
208
{
 
209
    WebCore::KURL kurl;
 
210
    kurl.setProtocol(String(protocol->characters(), protocol->length()));
 
211
    kurl.setHost(String(host->characters(), host->length()));
 
212
 
 
213
    ewk_security_policy_whitelist_origin_add(sourceOrigin->string().utf8().data(), kurl.string().utf8().data(), includeSubdomains);
 
214
}
 
215
 
 
216
void TestRunner::removeOriginAccessWhitelistEntry(JSStringRef sourceOrigin, JSStringRef protocol, JSStringRef host, bool includeSubdomains)
 
217
{
 
218
    WebCore::KURL kurl;
 
219
    kurl.setProtocol(String(protocol->characters(), protocol->length()));
 
220
    kurl.setHost(String(host->characters(), host->length()));
 
221
 
 
222
    ewk_security_policy_whitelist_origin_del(sourceOrigin->string().utf8().data(), kurl.string().utf8().data(), includeSubdomains);
 
223
}
 
224
 
 
225
void TestRunner::setMainFrameIsFirstResponder(bool)
 
226
{
 
227
    notImplemented();
 
228
}
 
229
 
 
230
void TestRunner::setTabKeyCyclesThroughElements(bool)
 
231
{
 
232
    notImplemented();
 
233
}
 
234
 
 
235
void TestRunner::setUseDashboardCompatibilityMode(bool)
 
236
{
 
237
    notImplemented();
 
238
}
 
239
 
 
240
static CString gUserStyleSheet;
 
241
static bool gUserStyleSheetEnabled = true;
 
242
 
 
243
void TestRunner::setUserStyleSheetEnabled(bool flag)
 
244
{
 
245
    gUserStyleSheetEnabled = flag;
 
246
    ewk_view_setting_user_stylesheet_set(browser->mainView(), flag ? gUserStyleSheet.data() : 0);
 
247
}
 
248
 
 
249
void TestRunner::setUserStyleSheetLocation(JSStringRef path)
 
250
{
 
251
    gUserStyleSheet = path->string().utf8();
 
252
 
 
253
    if (gUserStyleSheetEnabled)
 
254
        setUserStyleSheetEnabled(true);
 
255
}
 
256
 
 
257
void TestRunner::setValueForUser(JSContextRef context, JSValueRef nodeObject, JSStringRef value)
 
258
{
 
259
    DumpRenderTreeSupportEfl::setValueForUser(context, nodeObject, value->string());
 
260
}
 
261
 
 
262
void TestRunner::setViewModeMediaFeature(JSStringRef mode)
 
263
{
 
264
    Evas_Object* view = browser->mainView();
 
265
    if (!view)
 
266
        return;
 
267
 
 
268
    if (equals(mode, "windowed"))
 
269
        ewk_view_mode_set(view, EWK_VIEW_MODE_WINDOWED);
 
270
    else if (equals(mode, "floating"))
 
271
        ewk_view_mode_set(view, EWK_VIEW_MODE_FLOATING);
 
272
    else if (equals(mode, "fullscreen"))
 
273
        ewk_view_mode_set(view, EWK_VIEW_MODE_FULLSCREEN);
 
274
    else if (equals(mode, "maximized"))
 
275
        ewk_view_mode_set(view, EWK_VIEW_MODE_MAXIMIZED);
 
276
    else if (equals(mode, "minimized"))
 
277
        ewk_view_mode_set(view, EWK_VIEW_MODE_MINIMIZED);
 
278
}
 
279
 
 
280
void TestRunner::setWindowIsKey(bool)
 
281
{
 
282
    notImplemented();
 
283
}
 
284
 
 
285
void TestRunner::setSmartInsertDeleteEnabled(bool flag)
 
286
{
 
287
    DumpRenderTreeSupportEfl::setSmartInsertDeleteEnabled(browser->mainView(), flag);
 
288
}
 
289
 
 
290
static Eina_Bool waitToDumpWatchdogFired(void*)
 
291
{
 
292
    waitToDumpWatchdog = 0;
 
293
    gTestRunner->waitToDumpWatchdogTimerFired();
 
294
    return ECORE_CALLBACK_CANCEL;
 
295
}
 
296
 
 
297
void TestRunner::setWaitToDump(bool waitUntilDone)
 
298
{
 
299
    static const double timeoutSeconds = 30;
 
300
 
 
301
    m_waitToDump = waitUntilDone;
 
302
    if (m_waitToDump && !waitToDumpWatchdog)
 
303
        waitToDumpWatchdog = ecore_timer_add(timeoutSeconds, waitToDumpWatchdogFired, 0);
 
304
}
 
305
 
 
306
int TestRunner::windowCount()
 
307
{
 
308
    return browser->extraViews().size() + 1; // + 1 for the main view.
 
309
}
 
310
 
 
311
void TestRunner::setPrivateBrowsingEnabled(bool flag)
 
312
{
 
313
    ewk_view_setting_private_browsing_set(browser->mainView(), flag);
 
314
}
 
315
 
 
316
void TestRunner::setJavaScriptCanAccessClipboard(bool flag)
 
317
{
 
318
    ewk_view_setting_scripts_can_access_clipboard_set(browser->mainView(), flag);
 
319
}
 
320
 
 
321
void TestRunner::setXSSAuditorEnabled(bool flag)
 
322
{
 
323
    ewk_view_setting_enable_xss_auditor_set(browser->mainView(), flag);
 
324
}
 
325
 
 
326
void TestRunner::setFrameFlatteningEnabled(bool flag)
 
327
{
 
328
    ewk_view_setting_enable_frame_flattening_set(browser->mainView(), flag);
 
329
}
 
330
 
 
331
void TestRunner::setSpatialNavigationEnabled(bool flag)
 
332
{
 
333
    ewk_view_setting_spatial_navigation_set(browser->mainView(), flag);
 
334
}
 
335
 
 
336
void TestRunner::setAllowUniversalAccessFromFileURLs(bool flag)
 
337
{
 
338
    ewk_view_setting_allow_universal_access_from_file_urls_set(browser->mainView(), flag);
 
339
}
 
340
 
 
341
void TestRunner::setAllowFileAccessFromFileURLs(bool flag)
 
342
{
 
343
    ewk_view_setting_allow_file_access_from_file_urls_set(browser->mainView(), flag);
 
344
}
 
345
 
 
346
void TestRunner::setAuthorAndUserStylesEnabled(bool flag)
 
347
{
 
348
    DumpRenderTreeSupportEfl::setAuthorAndUserStylesEnabled(browser->mainView(), flag);
 
349
}
 
350
 
 
351
void TestRunner::setAutofilled(JSContextRef context, JSValueRef nodeObject, bool autofilled)
 
352
{
 
353
    DumpRenderTreeSupportEfl::setAutofilled(context, nodeObject, autofilled);
 
354
}
 
355
 
 
356
void TestRunner::disableImageLoading()
 
357
{
 
358
    ewk_view_setting_auto_load_images_set(browser->mainView(), EINA_FALSE);
 
359
}
 
360
 
 
361
void TestRunner::setMockDeviceOrientation(bool, double, bool, double, bool, double)
 
362
{
 
363
    // FIXME: Implement for DeviceOrientation layout tests.
 
364
    // See https://bugs.webkit.org/show_bug.cgi?id=30335.
 
365
    notImplemented();
 
366
}
 
367
 
 
368
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)
 
369
{
 
370
    Evas_Object* view = browser->mainView();
 
371
    if (browser->extraViews().size() > 0)
 
372
        view = browser->extraViews().last();
 
373
 
 
374
    DumpRenderTreeSupportEfl::setMockGeolocationPosition(view, latitude, longitude, accuracy, canProvideAltitude, altitude, canProvideAltitudeAccuracy, altitudeAccuracy, canProvideHeading, heading, canProvideSpeed, speed);
 
375
}
 
376
 
 
377
void TestRunner::setMockGeolocationPositionUnavailableError(JSStringRef message)
 
378
{
 
379
    Evas_Object* view = browser->mainView();
 
380
    if (browser->extraViews().size() > 0)
 
381
        view = browser->extraViews().last();
 
382
 
 
383
    DumpRenderTreeSupportEfl::setMockGeolocationPositionUnavailableError(view, message->string().utf8().data());
 
384
}
 
385
 
 
386
void TestRunner::setGeolocationPermission(bool allow)
 
387
{
 
388
    setGeolocationPermissionCommon(allow);
 
389
    Evas_Object* view = browser->mainView();
 
390
    if (browser->extraViews().size() > 0)
 
391
        view = browser->extraViews().last();
 
392
 
 
393
    DumpRenderTreeSupportEfl::setMockGeolocationPermission(view, allow);
 
394
}
 
395
 
 
396
int TestRunner::numberOfPendingGeolocationPermissionRequests()
 
397
{
 
398
    Evas_Object* view = browser->mainView();
 
399
    if (browser->extraViews().size() > 0)
 
400
        view = browser->extraViews().last();
 
401
 
 
402
    return DumpRenderTreeSupportEfl::numberOfPendingGeolocationPermissionRequests(view);
 
403
}
 
404
 
 
405
void TestRunner::addMockSpeechInputResult(JSStringRef, double, JSStringRef)
 
406
{
 
407
    // FIXME: Implement for speech input layout tests.
 
408
    // See https://bugs.webkit.org/show_bug.cgi?id=39485.
 
409
    notImplemented();
 
410
}
 
411
 
 
412
void TestRunner::setMockSpeechInputDumpRect(bool)
 
413
{
 
414
    // FIXME: Implement for speech input layout tests.
 
415
    // See https://bugs.webkit.org/show_bug.cgi?id=39485.
 
416
    notImplemented();
 
417
}
 
418
 
 
419
void TestRunner::startSpeechInput(JSContextRef inputElement)
 
420
{
 
421
    // FIXME: Implement for speech input layout tests.
 
422
    // See https://bugs.webkit.org/show_bug.cgi?id=39485.
 
423
    notImplemented();
 
424
}
 
425
 
 
426
void TestRunner::setIconDatabaseEnabled(bool enabled)
 
427
{
 
428
    ewk_settings_icon_database_path_set(0);
 
429
 
 
430
    if (!enabled)
 
431
        return;
 
432
 
 
433
    String databasePath;
 
434
    const char* tempDir = getenv("TMPDIR");
 
435
 
 
436
    if (tempDir)
 
437
        databasePath = String::fromUTF8(tempDir);
 
438
    else if (tempDir = getenv("TEMP"))
 
439
        databasePath = String::fromUTF8(tempDir);
 
440
    else
 
441
        databasePath = String::fromUTF8("/tmp");
 
442
 
 
443
    databasePath.append("/DumpRenderTree/IconDatabase");
 
444
 
 
445
    if (ecore_file_mkpath(databasePath.utf8().data()))
 
446
        ewk_settings_icon_database_path_set(databasePath.utf8().data());
 
447
}
 
448
 
 
449
void TestRunner::setSelectTrailingWhitespaceEnabled(bool flag)
 
450
{
 
451
    DumpRenderTreeSupportEfl::setSelectTrailingWhitespaceEnabled(browser->mainView(), flag);
 
452
}
 
453
 
 
454
void TestRunner::setPopupBlockingEnabled(bool flag)
 
455
{
 
456
    ewk_view_setting_scripts_can_open_windows_set(browser->mainView(), !flag);
 
457
}
 
458
 
 
459
void TestRunner::setPluginsEnabled(bool flag)
 
460
{
 
461
    ewk_view_setting_enable_plugins_set(browser->mainView(), flag);
 
462
}
 
463
 
 
464
bool TestRunner::elementDoesAutoCompleteForElementWithId(JSStringRef id)
 
465
{
 
466
    const String elementId(id->string());
 
467
    const Evas_Object* mainFrame = browser->mainFrame();
 
468
    return DumpRenderTreeSupportEfl::elementDoesAutoCompleteForElementWithId(mainFrame, elementId);
 
469
}
 
470
 
 
471
void TestRunner::execCommand(JSStringRef name, JSStringRef value)
 
472
{
 
473
    DumpRenderTreeSupportEfl::executeCoreCommandByName(browser->mainView(), name->string().utf8().data(), value->string().utf8().data());
 
474
}
 
475
 
 
476
bool TestRunner::findString(JSContextRef context, JSStringRef target, JSObjectRef optionsArray)
 
477
{
 
478
    JSRetainPtr<JSStringRef> lengthPropertyName(Adopt, JSStringCreateWithUTF8CString("length"));
 
479
    JSValueRef lengthValue = JSObjectGetProperty(context, optionsArray, lengthPropertyName.get(), 0);
 
480
    if (!JSValueIsNumber(context, lengthValue))
 
481
        return false;
 
482
 
 
483
    WebCore::FindOptions options = 0;
 
484
 
 
485
    const size_t length = static_cast<size_t>(JSValueToNumber(context, lengthValue, 0));
 
486
    for (size_t i = 0; i < length; ++i) {
 
487
        JSValueRef value = JSObjectGetPropertyAtIndex(context, optionsArray, i, 0);
 
488
        if (!JSValueIsString(context, value))
 
489
            continue;
 
490
 
 
491
        JSRetainPtr<JSStringRef> optionName(Adopt, JSValueToStringCopy(context, value, 0));
 
492
 
 
493
        if (equals(optionName, "CaseInsensitive"))
 
494
            options |= WebCore::CaseInsensitive;
 
495
        else if (equals(optionName, "AtWordStarts"))
 
496
            options |= WebCore::AtWordStarts;
 
497
        else if (equals(optionName, "TreatMedialCapitalAsWordStart"))
 
498
            options |= WebCore::TreatMedialCapitalAsWordStart;
 
499
        else if (equals(optionName, "Backwards"))
 
500
            options |= WebCore::Backwards;
 
501
        else if (equals(optionName, "WrapAround"))
 
502
            options |= WebCore::WrapAround;
 
503
        else if (equals(optionName, "StartInSelection"))
 
504
            options |= WebCore::StartInSelection;
 
505
    }
 
506
 
 
507
    return DumpRenderTreeSupportEfl::findString(browser->mainView(), target->string(), options);
 
508
}
 
509
 
 
510
bool TestRunner::isCommandEnabled(JSStringRef name)
 
511
{
 
512
    return DumpRenderTreeSupportEfl::isCommandEnabled(browser->mainView(), name->string().utf8().data());
 
513
}
 
514
 
 
515
void TestRunner::setCacheModel(int cacheModel)
 
516
{
 
517
    unsigned int cacheTotalCapacity;
 
518
    unsigned int cacheMinDeadCapacity;
 
519
    unsigned int cacheMaxDeadCapacity;
 
520
    double deadDecodedDataDeletionInterval;
 
521
    unsigned int pageCacheCapacity;
 
522
 
 
523
    // These constants are derived from the Mac cache model enum in Source/WebKit/mac/WebView/WebPreferences.h.
 
524
    switch (cacheModel) {
 
525
    case WebCacheModelDocumentViewer:
 
526
        pageCacheCapacity = 0;
 
527
        cacheTotalCapacity = 0;
 
528
        cacheMinDeadCapacity = 0;
 
529
        cacheMaxDeadCapacity = 0;
 
530
        deadDecodedDataDeletionInterval = 0;
 
531
        break;
 
532
    case WebCacheModelDocumentBrowser:
 
533
        pageCacheCapacity = 2;
 
534
        cacheTotalCapacity = 16 * 1024 * 1024;
 
535
        cacheMinDeadCapacity = cacheTotalCapacity / 8;
 
536
        cacheMaxDeadCapacity = cacheTotalCapacity / 4;
 
537
        deadDecodedDataDeletionInterval = 0;
 
538
        break;
 
539
    case WebCacheModelPrimaryWebBrowser:
 
540
        pageCacheCapacity = 3;
 
541
        cacheTotalCapacity = 32 * 1024 * 1024;
 
542
        cacheMinDeadCapacity = cacheTotalCapacity / 4;
 
543
        cacheMaxDeadCapacity = cacheTotalCapacity / 2;
 
544
        deadDecodedDataDeletionInterval = 60;
 
545
        break;
 
546
    default:
 
547
        fprintf(stderr, "trying to set an invalid value %d for the Cache model.", cacheModel);
 
548
        return;
 
549
    }
 
550
 
 
551
    ewk_settings_object_cache_capacity_set(cacheMinDeadCapacity, cacheMaxDeadCapacity, cacheTotalCapacity);
 
552
    DumpRenderTreeSupportEfl::setDeadDecodedDataDeletionInterval(deadDecodedDataDeletionInterval);
 
553
    ewk_settings_page_cache_capacity_set(pageCacheCapacity);
 
554
}
 
555
 
 
556
void TestRunner::setPersistentUserStyleSheetLocation(JSStringRef)
 
557
{
 
558
    notImplemented();
 
559
}
 
560
 
 
561
void TestRunner::clearPersistentUserStyleSheet()
 
562
{
 
563
    notImplemented();
 
564
}
 
565
 
 
566
void TestRunner::clearAllApplicationCaches()
 
567
{
 
568
    ewk_settings_application_cache_clear();
 
569
}
 
570
 
 
571
void TestRunner::setApplicationCacheOriginQuota(unsigned long long quota)
 
572
{
 
573
    Ewk_Security_Origin* origin = ewk_frame_security_origin_get(browser->mainFrame());
 
574
    ewk_security_origin_application_cache_quota_set(origin, quota);
 
575
    ewk_security_origin_free(origin);
 
576
}
 
577
 
 
578
void TestRunner::clearApplicationCacheForOrigin(OpaqueJSString* url)
 
579
{
 
580
    Ewk_Security_Origin* origin = ewk_security_origin_new_from_string(url->string().utf8().data());
 
581
    ewk_security_origin_application_cache_clear(origin);
 
582
    ewk_security_origin_free(origin);
 
583
}
 
584
 
 
585
long long TestRunner::localStorageDiskUsageForOrigin(JSStringRef)
 
586
{
 
587
    // FIXME: Implement to support getting disk usage in bytes for an origin.
 
588
    notImplemented();
 
589
    return 0;
 
590
}
 
591
 
 
592
JSValueRef TestRunner::originsWithApplicationCache(JSContextRef context)
 
593
{
 
594
    // FIXME: Implement to get origins that contain application caches.
 
595
    notImplemented();
 
596
    return JSValueMakeUndefined(context);
 
597
}
 
598
 
 
599
long long TestRunner::applicationCacheDiskUsageForOrigin(JSStringRef)
 
600
{
 
601
    notImplemented();
 
602
    return 0;
 
603
}
 
604
 
 
605
void TestRunner::clearAllDatabases()
 
606
{
 
607
    ewk_web_database_remove_all();
 
608
}
 
609
 
 
610
void TestRunner::setDatabaseQuota(unsigned long long quota)
 
611
{
 
612
    Ewk_Security_Origin* origin = ewk_frame_security_origin_get(browser->mainFrame());
 
613
    ewk_security_origin_web_database_quota_set(origin, quota);
 
614
    ewk_security_origin_free(origin);
 
615
}
 
616
 
 
617
JSValueRef TestRunner::originsWithLocalStorage(JSContextRef context)
 
618
{
 
619
    notImplemented();
 
620
    return JSValueMakeUndefined(context);
 
621
}
 
622
 
 
623
void TestRunner::deleteAllLocalStorage()
 
624
{
 
625
    notImplemented();
 
626
}
 
627
 
 
628
void TestRunner::deleteLocalStorageForOrigin(JSStringRef)
 
629
{
 
630
    notImplemented();
 
631
}
 
632
 
 
633
void TestRunner::observeStorageTrackerNotifications(unsigned)
 
634
{
 
635
    notImplemented();
 
636
}
 
637
 
 
638
void TestRunner::syncLocalStorage()
 
639
{
 
640
    notImplemented();
 
641
}
 
642
 
 
643
void TestRunner::setDomainRelaxationForbiddenForURLScheme(bool forbidden, JSStringRef scheme)
 
644
{
 
645
    DumpRenderTreeSupportEfl::setDomainRelaxationForbiddenForURLScheme(forbidden, scheme->string());
 
646
}
 
647
 
 
648
void TestRunner::goBack()
 
649
{
 
650
    ewk_frame_back(browser->mainFrame());
 
651
}
 
652
 
 
653
void TestRunner::setDefersLoading(bool defers)
 
654
{
 
655
    DumpRenderTreeSupportEfl::setDefersLoading(browser->mainView(), defers);
 
656
}
 
657
 
 
658
void TestRunner::setAppCacheMaximumSize(unsigned long long size)
 
659
{
 
660
    ewk_settings_application_cache_max_quota_set(size);
 
661
}
 
662
 
 
663
bool TestRunner::pauseAnimationAtTimeOnElementWithId(JSStringRef animationName, double time, JSStringRef elementId)
 
664
{
 
665
    return DumpRenderTreeSupportEfl::pauseAnimation(browser->mainFrame(), animationName->string().utf8().data(), elementId->string().utf8().data(), time);
 
666
}
 
667
 
 
668
bool TestRunner::pauseTransitionAtTimeOnElementWithId(JSStringRef propertyName, double time, JSStringRef elementId)
 
669
{
 
670
    return DumpRenderTreeSupportEfl::pauseTransition(browser->mainFrame(), propertyName->string().utf8().data(), elementId->string().utf8().data(), time);
 
671
}
 
672
 
 
673
unsigned TestRunner::numberOfActiveAnimations() const
 
674
{
 
675
    return DumpRenderTreeSupportEfl::activeAnimationsCount(browser->mainFrame());
 
676
}
 
677
 
 
678
static inline bool toBool(JSStringRef value)
 
679
{
 
680
    return equals(value, "true") || equals(value, "1");
 
681
}
 
682
 
 
683
static inline int toInt(JSStringRef value)
 
684
{
 
685
    return atoi(value->string().utf8().data());
 
686
}
 
687
 
 
688
void TestRunner::overridePreference(JSStringRef key, JSStringRef value)
 
689
{
 
690
    if (equals(key, "WebKitJavaScriptEnabled"))
 
691
        ewk_view_setting_enable_scripts_set(browser->mainView(), toBool(value));
 
692
    else if (equals(key, "WebKitDefaultFontSize"))
 
693
        ewk_view_setting_font_default_size_set(browser->mainView(), toInt(value));
 
694
    else if (equals(key, "WebKitMinimumFontSize"))
 
695
        ewk_view_setting_font_minimum_size_set(browser->mainView(), toInt(value));
 
696
    else if (equals(key, "WebKitPluginsEnabled"))
 
697
        ewk_view_setting_enable_plugins_set(browser->mainView(), toBool(value));
 
698
    else if (equals(key, "WebKitWebGLEnabled"))
 
699
        ewk_view_setting_enable_webgl_set(browser->mainView(), toBool(value));
 
700
    else if (equals(key, "WebKitEnableCaretBrowsing"))
 
701
        ewk_view_setting_caret_browsing_set(browser->mainView(), toBool(value));
 
702
    else if (equals(key, "WebKitUsesPageCachePreferenceKey"))
 
703
        ewk_view_setting_page_cache_set(browser->mainView(), toBool(value));
 
704
    else if (equals(key, "WebKitHyperlinkAuditingEnabled"))
 
705
        ewk_view_setting_enable_hyperlink_auditing_set(browser->mainView(), toBool(value));
 
706
    else if (equals(key, "WebKitTabToLinksPreferenceKey"))
 
707
        ewk_view_setting_include_links_in_focus_chain_set(browser->mainView(), toBool(value));
 
708
    else if (equals(key, "WebKitOfflineWebApplicationCacheEnabled"))
 
709
        ewk_view_setting_application_cache_set(browser->mainView(), toBool(value));
 
710
    else if (equals(key, "WebKitLoadSiteIconsKey"))
 
711
        DumpRenderTreeSupportEfl::setLoadsSiteIconsIgnoringImageLoadingSetting(browser->mainView(), toBool(value));
 
712
    else if (equals(key, "WebKitCSSGridLayoutEnabled"))
 
713
        DumpRenderTreeSupportEfl::setCSSGridLayoutEnabled(browser->mainView(), toBool(value));
 
714
    else if (equals(key, "WebKitCSSRegionsEnabled"))
 
715
        DumpRenderTreeSupportEfl::setCSSRegionsEnabled(browser->mainView(), toBool(value));
 
716
    else if (equals(key, "WebKitWebAudioEnabled"))
 
717
        ewk_view_setting_web_audio_set(browser->mainView(), toBool(value));
 
718
    else if (equals(key, "WebKitDisplayImagesKey"))
 
719
        ewk_view_setting_auto_load_images_set(browser->mainView(), toBool(value));
 
720
    else
 
721
        fprintf(stderr, "TestRunner::overridePreference tried to override unknown preference '%s'.\n", value->string().utf8().data());
 
722
}
 
723
 
 
724
void TestRunner::addUserScript(JSStringRef source, bool runAtStart, bool allFrames)
 
725
{
 
726
    DumpRenderTreeSupportEfl::addUserScript(browser->mainView(), source->string(), runAtStart, allFrames);
 
727
}
 
728
 
 
729
void TestRunner::addUserStyleSheet(JSStringRef source, bool allFrames)
 
730
{
 
731
    DumpRenderTreeSupportEfl::addUserStyleSheet(browser->mainView(), source->string(), allFrames);
 
732
}
 
733
 
 
734
void TestRunner::setDeveloperExtrasEnabled(bool enabled)
 
735
{
 
736
    ewk_view_setting_enable_developer_extras_set(browser->mainView(), enabled);
 
737
}
 
738
 
 
739
void TestRunner::setAsynchronousSpellCheckingEnabled(bool)
 
740
{
 
741
    notImplemented();
 
742
}
 
743
 
 
744
void TestRunner::showWebInspector()
 
745
{
 
746
    ewk_view_inspector_show(browser->mainView());
 
747
    browser->waitInspectorLoadFinished();
 
748
}
 
749
 
 
750
void TestRunner::closeWebInspector()
 
751
{
 
752
    ewk_view_inspector_close(browser->mainView());
 
753
}
 
754
 
 
755
void TestRunner::evaluateInWebInspector(long callId, JSStringRef script)
 
756
{
 
757
    DumpRenderTreeSupportEfl::evaluateInWebInspector(browser->mainView(), callId, script->string());
 
758
}
 
759
 
 
760
void TestRunner::evaluateScriptInIsolatedWorldAndReturnValue(unsigned, JSObjectRef, JSStringRef)
 
761
{
 
762
    notImplemented();
 
763
}
 
764
 
 
765
void TestRunner::evaluateScriptInIsolatedWorld(unsigned worldID, JSObjectRef globalObject, JSStringRef script)
 
766
{
 
767
    DumpRenderTreeSupportEfl::evaluateScriptInIsolatedWorld(browser->mainFrame(), worldID, globalObject, script->string());
 
768
}
 
769
 
 
770
void TestRunner::removeAllVisitedLinks()
 
771
{
 
772
    Ewk_History* history = ewk_view_history_get(browser->mainView());
 
773
    if (!history)
 
774
        return;
 
775
 
 
776
    ewk_history_clear(history);
 
777
}
 
778
 
 
779
bool TestRunner::callShouldCloseOnWebView()
 
780
{
 
781
    return DumpRenderTreeSupportEfl::callShouldCloseOnWebView(browser->mainFrame());
 
782
}
 
783
 
 
784
void TestRunner::apiTestNewWindowDataLoadBaseURL(JSStringRef, JSStringRef)
 
785
{
 
786
    notImplemented();
 
787
}
 
788
 
 
789
void TestRunner::apiTestGoToCurrentBackForwardItem()
 
790
{
 
791
    notImplemented();
 
792
}
 
793
 
 
794
void TestRunner::setWebViewEditable(bool)
 
795
{
 
796
    ewk_frame_editable_set(browser->mainFrame(), EINA_TRUE);
 
797
}
 
798
 
 
799
JSRetainPtr<JSStringRef> TestRunner::markerTextForListItem(JSContextRef context, JSValueRef nodeObject) const
 
800
{
 
801
    String markerTextChar = DumpRenderTreeSupportEfl::markerTextForListItem(context, nodeObject);
 
802
    if (markerTextChar.isEmpty())
 
803
        return 0;
 
804
 
 
805
    JSRetainPtr<JSStringRef> markerText(Adopt, JSStringCreateWithUTF8CString(markerTextChar.utf8().data()));
 
806
    return markerText;
 
807
}
 
808
 
 
809
void TestRunner::authenticateSession(JSStringRef, JSStringRef, JSStringRef)
 
810
{
 
811
    notImplemented();
 
812
}
 
813
 
 
814
void TestRunner::abortModal()
 
815
{
 
816
    notImplemented();
 
817
}
 
818
 
 
819
void TestRunner::setSerializeHTTPLoads(bool serialize)
 
820
{
 
821
    DumpRenderTreeSupportEfl::setSerializeHTTPLoads(serialize);
 
822
}
 
823
 
 
824
void TestRunner::setMinimumTimerInterval(double minimumTimerInterval)
 
825
{
 
826
    ewk_view_setting_minimum_timer_interval_set(browser->mainView(), minimumTimerInterval);
 
827
}
 
828
 
 
829
void TestRunner::setTextDirection(JSStringRef direction)
 
830
{
 
831
    Ewk_Text_Direction ewkDirection;
 
832
    if (JSStringIsEqualToUTF8CString(direction, "auto"))
 
833
        ewkDirection = EWK_TEXT_DIRECTION_DEFAULT;
 
834
    else if (JSStringIsEqualToUTF8CString(direction, "rtl"))
 
835
        ewkDirection = EWK_TEXT_DIRECTION_RIGHT_TO_LEFT;
 
836
    else if (JSStringIsEqualToUTF8CString(direction, "ltr"))
 
837
        ewkDirection = EWK_TEXT_DIRECTION_LEFT_TO_RIGHT;
 
838
    else {
 
839
        fprintf(stderr, "TestRunner::setTextDirection called with unknown direction: '%s'.\n", direction->string().utf8().data());
 
840
        return;
 
841
    }
 
842
 
 
843
    ewk_view_text_direction_set(browser->mainView(), ewkDirection);
 
844
}
 
845
 
 
846
void TestRunner::addChromeInputField()
 
847
{
 
848
    notImplemented();
 
849
}
 
850
 
 
851
void TestRunner::removeChromeInputField()
 
852
{
 
853
    notImplemented();
 
854
}
 
855
 
 
856
void TestRunner::focusWebView()
 
857
{
 
858
    notImplemented();
 
859
}
 
860
 
 
861
void TestRunner::setBackingScaleFactor(double)
 
862
{
 
863
    notImplemented();
 
864
}
 
865
 
 
866
void TestRunner::grantWebNotificationPermission(JSStringRef origin)
 
867
{
 
868
}
 
869
 
 
870
void TestRunner::denyWebNotificationPermission(JSStringRef jsOrigin)
 
871
{
 
872
}
 
873
 
 
874
void TestRunner::removeAllWebNotificationPermissions()
 
875
{
 
876
}
 
877
 
 
878
void TestRunner::simulateWebNotificationClick(JSValueRef jsNotification)
 
879
{
 
880
}
 
881
 
 
882
void TestRunner::simulateLegacyWebNotificationClick(JSStringRef title)
 
883
{
 
884
}
 
885
 
 
886
void TestRunner::resetPageVisibility()
 
887
{
 
888
    ewk_view_visibility_state_set(browser->mainView(), EWK_PAGE_VISIBILITY_STATE_VISIBLE, true);
 
889
}
 
890
 
 
891
void TestRunner::setPageVisibility(const char* visibility)
 
892
{
 
893
    String newVisibility(visibility);
 
894
    if (newVisibility == "visible")
 
895
        ewk_view_visibility_state_set(browser->mainView(), EWK_PAGE_VISIBILITY_STATE_VISIBLE, false);
 
896
    else if (newVisibility == "hidden")
 
897
        ewk_view_visibility_state_set(browser->mainView(), EWK_PAGE_VISIBILITY_STATE_HIDDEN, false);
 
898
    else if (newVisibility == "prerender")
 
899
        ewk_view_visibility_state_set(browser->mainView(), EWK_PAGE_VISIBILITY_STATE_PRERENDER, false);
 
900
    else if (newVisibility == "preview")
 
901
        ewk_view_visibility_state_set(browser->mainView(), EWK_PAGE_VISIBILITY_STATE_PREVIEW, false);
 
902
}
 
903
 
 
904
void TestRunner::setAutomaticLinkDetectionEnabled(bool)
 
905
{
 
906
    notImplemented();
 
907
}
 
908
 
 
909
void TestRunner::sendWebIntentResponse(JSStringRef response)
 
910
{
 
911
    Ewk_Intent_Request* request = browser->currentIntentRequest();
 
912
    if (!request)
 
913
        return;
 
914
 
 
915
    DumpRenderTreeSupportEfl::sendWebIntentResponse(request, response);
 
916
}
 
917
 
 
918
void TestRunner::deliverWebIntent(JSStringRef action, JSStringRef type, JSStringRef data)
 
919
{
 
920
    DumpRenderTreeSupportEfl::deliverWebIntent(browser->mainFrame(), action, type, data);
 
921
}
 
922
 
 
923
void TestRunner::setStorageDatabaseIdleInterval(double)
 
924
{
 
925
    notImplemented();
 
926
}