[EFL][DRT] Implement TextInputController.
[WebKit-https.git] / Tools / DumpRenderTree / efl / DumpRenderTreeChrome.cpp
1 /*
2  * Copyright (C) 2011 ProFUSION Embedded Systems
3  * Copyright (C) 2011 Samsung Electronics
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1.  Redistributions of source code must retain the above copyright
9  *     notice, this list of conditions and the following disclaimer.
10  * 2.  Redistributions in binary form must reproduce the above copyright
11  *     notice, this list of conditions and the following disclaimer in the
12  *     documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND ITS CONTRIBUTORS
15  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
16  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
17  * PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT
18  * HOLDERS OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
19  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  */
26
27 #include "config.h"
28 #include "DumpRenderTreeChrome.h"
29
30 #include "DumpRenderTree.h"
31 #include "DumpRenderTreeView.h"
32 #include "EventSender.h"
33 #include "GCController.h"
34 #include "LayoutTestController.h"
35 #include "NotImplemented.h"
36 #include "TextInputController.h"
37 #include "WebCoreSupport/DumpRenderTreeSupportEfl.h"
38 #include "WebCoreTestSupport.h"
39 #include "WorkQueue.h"
40 #include "ewk_private.h" // FIXME: create some WebCoreSupport/DumpRenderTree.cpp instead
41
42 #include <EWebKit.h>
43 #include <Ecore.h>
44 #include <Eina.h>
45 #include <Evas.h>
46 #include <cstdio>
47 #include <wtf/NotFound.h>
48
49 using namespace WebCore;
50
51 HashMap<unsigned long, CString> DumpRenderTreeChrome::m_dumpAssignedUrls;
52
53 PassOwnPtr<DumpRenderTreeChrome> DumpRenderTreeChrome::create(Evas* evas)
54 {
55     OwnPtr<DumpRenderTreeChrome> chrome = adoptPtr(new DumpRenderTreeChrome(evas));
56
57     if (!chrome->initialize())
58         return nullptr;
59
60     return chrome.release();
61 }
62
63 DumpRenderTreeChrome::DumpRenderTreeChrome(Evas* evas)
64     : m_mainView(0)
65     , m_mainFrame(0)
66     , m_evas(evas)
67     , m_gcController(adoptPtr(new GCController))
68 {
69 }
70
71 DumpRenderTreeChrome::~DumpRenderTreeChrome()
72 {
73 }
74
75 Evas_Object* DumpRenderTreeChrome::createNewWindow()
76 {
77     Evas_Object* newView = createView();
78
79     ewk_view_setting_scripts_can_open_windows_set(newView, EINA_TRUE);
80     ewk_view_setting_scripts_can_close_windows_set(newView, EINA_TRUE);
81
82     m_extraViews.append(newView);
83
84     return newView;
85 }
86
87 Evas_Object* DumpRenderTreeChrome::createView() const
88 {
89     Evas_Object* view = drtViewAdd(m_evas);
90     if (!view)
91         return 0;
92
93     ewk_view_theme_set(view, DATA_DIR"/default.edj");
94
95     evas_object_smart_callback_add(view, "load,resource,failed", onResourceLoadFailed, 0);
96     evas_object_smart_callback_add(view, "load,resource,finished", onResourceLoadFinished, 0);
97     evas_object_smart_callback_add(view, "load,started", onLoadStarted, 0);
98     evas_object_smart_callback_add(view, "title,changed", onTitleChanged, 0);
99     evas_object_smart_callback_add(view, "window,object,cleared", onWindowObjectCleared, m_gcController.get());
100     evas_object_smart_callback_add(view, "statusbar,text,set", onStatusbarTextSet, 0);
101     evas_object_smart_callback_add(view, "load,document,finished", onDocumentLoadFinished, 0);
102     evas_object_smart_callback_add(view, "resource,request,new", onNewResourceRequest, 0);
103     evas_object_smart_callback_add(view, "resource,request,willsend", onWillSendRequest, 0);
104     evas_object_smart_callback_add(view, "resource,response,received", onResponseReceived, 0);
105     evas_object_smart_callback_add(view, "onload,event", onWebViewOnloadEvent, 0);
106     evas_object_smart_callback_add(view, "mixedcontent,run", onInsecureContentRun, 0);
107     evas_object_smart_callback_add(view, "mixedcontent,displayed", onInsecureContentDisplayed, 0);
108     evas_object_smart_callback_add(view, "frame,created", onFrameCreated, 0);
109
110     Evas_Object* mainFrame = ewk_view_frame_main_get(view);
111     evas_object_smart_callback_add(mainFrame, "load,provisional", onFrameProvisionalLoad, 0);
112     evas_object_smart_callback_add(mainFrame, "load,committed", onFrameLoadCommitted, 0);
113     evas_object_smart_callback_add(mainFrame, "load,finished", onFrameLoadFinished, 0);
114     evas_object_smart_callback_add(mainFrame, "load,error", onFrameLoadError, 0);
115     evas_object_smart_callback_add(mainFrame, "redirect,cancelled", onFrameRedirectCancelled, 0);
116     evas_object_smart_callback_add(mainFrame, "redirect,load,provisional", onFrameRedirectForProvisionalLoad, 0);
117     evas_object_smart_callback_add(mainFrame, "redirect,requested", onFrameRedirectRequested, 0);
118     evas_object_smart_callback_add(mainFrame, "xss,detected", onDidDetectXSS, 0);
119
120     return view;
121 }
122
123 void DumpRenderTreeChrome::removeWindow(Evas_Object* view)
124 {
125     const size_t pos = m_extraViews.find(view);
126
127     if (pos == notFound)
128         return;
129
130     m_extraViews.remove(pos);
131     evas_object_del(view);
132 }
133
134 bool DumpRenderTreeChrome::initialize()
135 {
136     DumpRenderTreeSupportEfl::setMockScrollbarsEnabled(true);
137
138     m_mainView = createView();
139     if (!m_mainView)
140         return false;
141
142     ewk_view_theme_set(m_mainView, DATA_DIR"/default.edj");
143
144     evas_object_name_set(m_mainView, "m_mainView");
145     evas_object_move(m_mainView, 0, 0);
146     evas_object_resize(m_mainView, 800, 600);
147     evas_object_layer_set(m_mainView, EVAS_LAYER_MAX);
148     evas_object_show(m_mainView);
149     evas_object_focus_set(m_mainView, EINA_TRUE);
150
151     m_mainFrame = ewk_view_frame_main_get(m_mainView);
152
153     char* drtTemp = getenv("DUMPRENDERTREE_TEMP");
154     if (drtTemp) {
155         char path[2048];
156         eina_str_join(path, sizeof(path), '/', drtTemp, "LocalStorage");
157         ewk_settings_local_storage_path_set(path);
158         eina_str_join(path, sizeof(path), '/', drtTemp, "Databases");
159         ewk_settings_web_database_path_set(path);
160     }
161
162     return true;
163 }
164
165 Vector<Evas_Object*> DumpRenderTreeChrome::extraViews() const
166 {
167     return m_extraViews;
168 }
169
170 void DumpRenderTreeChrome::clearExtraViews()
171 {
172     Vector<Evas_Object*>::iterator it = m_extraViews.begin();
173     for (; it != m_extraViews.end(); ++it)
174         evas_object_del(*it);
175     m_extraViews.clear();
176 }
177
178 Evas_Object* DumpRenderTreeChrome::mainFrame() const
179 {
180     return m_mainFrame;
181 }
182
183 Evas_Object* DumpRenderTreeChrome::mainView() const
184 {
185     return m_mainView;
186 }
187
188 static inline const char* defaultEditingBehavior()
189 {
190     return
191 #if OS(DARWIN)
192     "mac";
193 #elif OS(WINDOWS)
194     "win";
195 #elif OS(UNIX)
196     "unix";
197 #else
198     // Fallback
199     "mac";
200 #endif
201 }
202
203 void DumpRenderTreeChrome::resetDefaultsToConsistentValues()
204 {
205     ewk_settings_icon_database_clear();
206     ewk_settings_icon_database_path_set(0);
207
208     ewk_settings_web_database_clear();
209     ewk_settings_web_database_default_quota_set(5 * 1024 * 1024);
210
211     ewk_settings_memory_cache_clear();
212
213     ewk_view_setting_private_browsing_set(mainView(), EINA_FALSE);
214     ewk_view_setting_spatial_navigation_set(mainView(), EINA_FALSE);
215     ewk_view_setting_enable_frame_flattening_set(mainView(), EINA_FALSE);
216     ewk_view_setting_application_cache_set(mainView(), EINA_TRUE);
217     ewk_view_setting_enable_scripts_set(mainView(), EINA_TRUE);
218     ewk_view_font_family_name_set(mainView(), EWK_FONT_FAMILY_STANDARD, "Times");
219     ewk_view_font_family_name_set(mainView(), EWK_FONT_FAMILY_MONOSPACE, "Courier");
220     ewk_view_font_family_name_set(mainView(), EWK_FONT_FAMILY_SERIF, "Times");
221     ewk_view_font_family_name_set(mainView(), EWK_FONT_FAMILY_SANS_SERIF, "Helvetica");
222     ewk_view_font_family_name_set(mainView(), EWK_FONT_FAMILY_CURSIVE, "cursive");
223     ewk_view_font_family_name_set(mainView(), EWK_FONT_FAMILY_FANTASY, "fantasy");
224     ewk_view_setting_font_default_size_set(mainView(), 16);
225     ewk_view_setting_font_monospace_size_set(mainView(), 13);
226     ewk_view_setting_font_minimum_size_set(mainView(), 0);
227     ewk_view_setting_caret_browsing_set(mainView(), EINA_FALSE);
228     ewk_view_setting_page_cache_set(mainView(), EINA_FALSE);
229     ewk_view_setting_enable_auto_resize_window_set(mainView(), EINA_TRUE);
230     ewk_view_setting_enable_plugins_set(mainView(), EINA_TRUE);
231     ewk_view_setting_scripts_can_open_windows_set(mainView(), EINA_TRUE);
232     ewk_view_setting_scripts_can_close_windows_set(mainView(), EINA_TRUE);
233     ewk_view_setting_auto_load_images_set(mainView(), EINA_TRUE);
234     ewk_view_setting_user_stylesheet_set(mainView(), 0);
235     ewk_view_setting_enable_xss_auditor_set(browser->mainView(), EINA_TRUE);
236     ewk_view_setting_enable_developer_extras_set(browser->mainView(), EINA_FALSE);
237     ewk_view_setting_minimum_timer_interval_set(browser->mainView(), 0.010); // 10 milliseconds (DOMTimer::s_minDefaultTimerInterval)
238     ewk_view_setting_enable_webgl_set(mainView(), EINA_TRUE);
239     ewk_view_setting_enable_hyperlink_auditing_set(mainView(), EINA_FALSE);
240     ewk_view_setting_include_links_in_focus_chain_set(mainView(), EINA_TRUE);
241
242     ewk_view_zoom_set(mainView(), 1.0, 0, 0);
243     ewk_view_scale_set(mainView(), 1.0, 0, 0);
244     ewk_view_text_zoom_set(mainView(), 1.0);
245     ewk_view_visibility_state_set(mainView(), EWK_PAGE_VISIBILITY_STATE_VISIBLE, true);
246
247     ewk_history_clear(ewk_view_history_get(mainView()));
248
249     ewk_cookies_clear();
250     ewk_cookies_policy_set(EWK_COOKIE_JAR_ACCEPT_NO_THIRD_PARTY);
251
252     ewk_security_policy_whitelist_origin_reset();
253
254     DumpRenderTreeSupportEfl::clearFrameName(mainFrame());
255     DumpRenderTreeSupportEfl::clearOpener(mainFrame());
256     DumpRenderTreeSupportEfl::setInteractiveFormValidationEnabled(mainView(), true);
257     DumpRenderTreeSupportEfl::setAuthorAndUserStylesEnabled(mainView(), true);
258     DumpRenderTreeSupportEfl::setSmartInsertDeleteEnabled(mainView(), false);
259     DumpRenderTreeSupportEfl::setSelectTrailingWhitespaceEnabled(mainView(), false);
260     DumpRenderTreeSupportEfl::setDefersLoading(mainView(), false);
261     DumpRenderTreeSupportEfl::setEditingBehavior(mainView(), defaultEditingBehavior());
262     DumpRenderTreeSupportEfl::setJavaScriptProfilingEnabled(mainView(), false);
263     DumpRenderTreeSupportEfl::setLoadsSiteIconsIgnoringImageLoadingSetting(mainView(), false);
264 }
265
266 static CString pathSuitableForTestResult(const char* uriString)
267 {
268     if (!uriString)
269         return CString();
270
271     KURL uri = KURL(ParsedURLString, uriString);
272
273     if (!uri.isLocalFile())
274         return uri.string().utf8();
275
276     String pathString = uri.path();
277     size_t indexBaseName = pathString.reverseFind('/');
278     String baseName;
279     if (indexBaseName == notFound)
280         baseName = pathString;
281     else
282         baseName = pathString.substring(indexBaseName + 1);
283
284     String dirName;
285     if (indexBaseName != notFound) {
286         size_t indexDirName = pathString.reverseFind('/', indexBaseName - 1);
287         if (indexDirName != notFound)
288             dirName = pathString.substring(indexDirName + 1, indexBaseName - indexDirName - 1);
289     }
290
291     String ret = dirName + "/" + baseName;
292     return ret.utf8();
293 }
294
295 static CString urlSuitableForTestResult(const char* uriString)
296 {
297     KURL uri = KURL(ParsedURLString, uriString);
298     if (!uri.isLocalFile())
299         return CString(uriString);
300
301     unsigned startIndex = uri.pathAfterLastSlash();
302     return uri.string().substring(startIndex).utf8();
303 }
304
305 static CString descriptionSuitableForTestResult(Ewk_Frame_Resource_Request* request)
306 {
307     String ret = "<NSURLRequest URL ";
308     ret += pathSuitableForTestResult(request->url).data();
309     ret += ", main document URL ";
310     ret += urlSuitableForTestResult(request->first_party).data();
311     ret += ", http method ";
312     ret += request->http_method ? String(request->http_method) : "(none)";
313     ret += ">";
314
315     return ret.utf8();
316 }
317
318 static CString descriptionSuitableForTestResult(const Ewk_Frame_Resource_Response* response)
319 {
320     if (!response)
321         return CString("(null)");
322
323     String ret = "<NSURLResponse ";
324     ret += pathSuitableForTestResult(response->url).data();
325     ret += ", http status code ";
326     ret += String::number(response->status_code);
327     ret += ">";
328
329     return ret.utf8();
330 }
331
332 static CString descriptionSuitableForTestResult(Ewk_Frame_Load_Error* error)
333 {
334     String ret = "<NSError domain ";
335     ret += error->domain;
336     ret += ", code ";
337     ret += String::number(error->code);
338     if (error->failing_url && *error->failing_url != '\0') {
339         ret += ", failing URL \"";
340         ret += error->failing_url;
341         ret += "\"";
342     }
343     ret += ">";
344
345     return ret.utf8();
346 }
347
348 // Smart Callbacks
349 // ---------------
350
351 void DumpRenderTreeChrome::onWindowObjectCleared(void* userData, Evas_Object*, void* eventInfo)
352 {
353     Ewk_Window_Object_Cleared_Event* objectClearedInfo = static_cast<Ewk_Window_Object_Cleared_Event*>(eventInfo);
354     JSValueRef exception = 0;
355     ASSERT(gLayoutTestController);
356
357     GCController* gcController = static_cast<GCController*>(userData);
358     ASSERT(gcController);
359
360     gLayoutTestController->makeWindowObject(objectClearedInfo->context, objectClearedInfo->windowObject, &exception);
361     ASSERT(!exception);
362
363     gcController->makeWindowObject(objectClearedInfo->context, objectClearedInfo->windowObject, &exception);
364     ASSERT(!exception);
365
366     JSRetainPtr<JSStringRef> controllerName(JSStringCreateWithUTF8CString("eventSender"));
367     JSObjectSetProperty(objectClearedInfo->context, objectClearedInfo->windowObject,
368                         controllerName.get(),
369                         makeEventSender(objectClearedInfo->context, !DumpRenderTreeSupportEfl::frameParent(objectClearedInfo->frame)),
370                         kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete, 0);
371
372     JSRetainPtr<JSStringRef> textInputControllerName(JSStringCreateWithUTF8CString("textInputController"));
373     JSObjectSetProperty(objectClearedInfo->context, objectClearedInfo->windowObject,
374                         textInputControllerName.get(),
375                         makeTextInputController(objectClearedInfo->context),
376                         kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete, 0);
377
378     WebCoreTestSupport::injectInternalsObject(objectClearedInfo->context);
379 }
380
381 void DumpRenderTreeChrome::onLoadStarted(void*, Evas_Object* view, void* eventInfo)
382 {
383     Evas_Object* frame = static_cast<Evas_Object*>(eventInfo);
384
385     // Make sure we only set this once per test. If it gets cleared, and then set again, we might
386     // end up doing two dumps for one test.
387     if (!topLoadingFrame && !done)
388         topLoadingFrame = frame;
389 }
390
391 Eina_Bool DumpRenderTreeChrome::processWork(void*)
392 {
393     if (WorkQueue::shared()->processWork() && !gLayoutTestController->waitToDump())
394         dump();
395
396     return ECORE_CALLBACK_CANCEL;
397 }
398
399 void DumpRenderTreeChrome::topLoadingFrameLoadFinished()
400 {
401     topLoadingFrame = 0;
402
403     WorkQueue::shared()->setFrozen(true);
404     if (gLayoutTestController->waitToDump())
405         return;
406
407     if (WorkQueue::shared()->count())
408         ecore_idler_add(processWork, 0 /*frame*/);
409     else
410         dump();
411 }
412
413 void DumpRenderTreeChrome::onStatusbarTextSet(void*, Evas_Object*, void* eventInfo)
414 {
415     if (!gLayoutTestController->dumpStatusCallbacks())
416         return;
417
418     const char* statusbarText = static_cast<const char*>(eventInfo);
419     printf("UI DELEGATE STATUS CALLBACK: setStatusText:%s\n", statusbarText);
420 }
421
422 void DumpRenderTreeChrome::onTitleChanged(void*, Evas_Object*, void* eventInfo)
423 {
424     if (!gLayoutTestController->dumpTitleChanges())
425         return;
426
427     const char* titleText = static_cast<const char*>(eventInfo);
428     printf("TITLE CHANGED: %s\n", titleText);
429 }
430
431 void DumpRenderTreeChrome::onDocumentLoadFinished(void*, Evas_Object*, void* eventInfo)
432 {
433     const Evas_Object* frame = static_cast<Evas_Object*>(eventInfo);
434     const String frameName(DumpRenderTreeSupportEfl::suitableDRTFrameName(frame));
435
436     if (!done && gLayoutTestController->dumpFrameLoadCallbacks())
437         printf("%s - didFinishDocumentLoadForFrame\n", frameName.utf8().data());
438     else if (!done) {
439         const unsigned pendingFrameUnloadEvents = DumpRenderTreeSupportEfl::pendingUnloadEventCount(frame);
440         if (pendingFrameUnloadEvents)
441             printf("%s - has %u onunload handler(s)\n", frameName.utf8().data(), pendingFrameUnloadEvents);
442     }
443 }
444
445 void DumpRenderTreeChrome::onWillSendRequest(void*, Evas_Object*, void* eventInfo)
446 {
447     Ewk_Frame_Resource_Messages* messages = static_cast<Ewk_Frame_Resource_Messages*>(eventInfo);
448
449     if (!done && gLayoutTestController->dumpResourceLoadCallbacks())
450         printf("%s - willSendRequest %s redirectResponse %s\n",
451                m_dumpAssignedUrls.contains(messages->request->identifier) ? m_dumpAssignedUrls.get(messages->request->identifier).data() : "<unknown>",
452                descriptionSuitableForTestResult(messages->request).data(),
453                descriptionSuitableForTestResult(messages->redirect_response).data());
454
455     if (!done && gLayoutTestController->willSendRequestReturnsNull()) {
456         // As requested by the LayoutTestController, don't perform the request.
457         messages->request->url = 0;
458         return;
459     }
460
461     if (!done && gLayoutTestController->willSendRequestReturnsNullOnRedirect() && messages->redirect_response) {
462         printf("Returning null for this redirect\n");
463         messages->request->url = 0;
464         return;
465     }
466
467     KURL url = KURL(ParsedURLString, messages->request->url);
468
469     if (url.isValid()
470         && url.protocolIsInHTTPFamily()
471         && url.host() != "127.0.0.1"
472         && url.host() != "255.255.255.255"
473         && url.host().lower() != "localhost") {
474         printf("Blocked access to external URL %s\n", messages->request->url);
475         messages->request->url = 0;
476         return;
477     }
478
479     const std::string& destination = gLayoutTestController->redirectionDestinationForURL(url.string().utf8().data());
480     if (destination.length())
481         messages->request->url = strdup(destination.c_str());
482 }
483
484 void DumpRenderTreeChrome::onWebViewOnloadEvent(void*, Evas_Object*, void* eventInfo)
485 {
486     const Evas_Object* frame = static_cast<Evas_Object*>(eventInfo);
487
488     if (!done && gLayoutTestController->dumpFrameLoadCallbacks()) {
489         const String frameName(DumpRenderTreeSupportEfl::suitableDRTFrameName(frame));
490         printf("%s - didHandleOnloadEventsForFrame\n", frameName.utf8().data());
491     }
492 }
493
494 void DumpRenderTreeChrome::onInsecureContentRun(void*, Evas_Object*, void*)
495 {
496     if (!done && gLayoutTestController->dumpFrameLoadCallbacks())
497         printf("didRunInsecureContent\n");
498 }
499
500 void DumpRenderTreeChrome::onInsecureContentDisplayed(void*, Evas_Object*, void*)
501 {
502     if (!done && gLayoutTestController->dumpFrameLoadCallbacks())
503         printf("didDisplayInsecureContent\n");
504 }
505
506 void DumpRenderTreeChrome::onFrameCreated(void*, Evas_Object*, void* eventInfo)
507 {
508     Evas_Object* frame = static_cast<Evas_Object*>(eventInfo);
509
510     evas_object_smart_callback_add(frame, "load,provisional", onFrameProvisionalLoad, 0);
511     evas_object_smart_callback_add(frame, "load,committed", onFrameLoadCommitted, 0);
512     evas_object_smart_callback_add(frame, "load,finished", onFrameLoadFinished, 0);
513     evas_object_smart_callback_add(frame, "load,error", onFrameLoadError, 0);
514     evas_object_smart_callback_add(frame, "redirect,cancelled", onFrameRedirectCancelled, 0);
515     evas_object_smart_callback_add(frame, "redirect,load,provisional", onFrameRedirectForProvisionalLoad, 0);
516     evas_object_smart_callback_add(frame, "redirect,requested", onFrameRedirectRequested, 0);
517     evas_object_smart_callback_add(frame, "xss,detected", onDidDetectXSS, 0);
518 }
519
520 void DumpRenderTreeChrome::onFrameProvisionalLoad(void*, Evas_Object* frame, void*)
521 {
522     if (!done && gLayoutTestController->dumpFrameLoadCallbacks()) {
523         const String frameName(DumpRenderTreeSupportEfl::suitableDRTFrameName(frame));
524         printf("%s - didStartProvisionalLoadForFrame\n", frameName.utf8().data());
525     }
526 }
527
528 void DumpRenderTreeChrome::onFrameLoadCommitted(void*, Evas_Object* frame, void*)
529 {
530     if (!done && gLayoutTestController->dumpFrameLoadCallbacks()) {
531         const String frameName(DumpRenderTreeSupportEfl::suitableDRTFrameName(frame));
532         printf("%s - didCommitLoadForFrame\n", frameName.utf8().data());
533     }
534 }
535
536 void DumpRenderTreeChrome::onFrameLoadFinished(void*, Evas_Object* frame, void* eventInfo)
537 {
538     const Ewk_Frame_Load_Error* error = static_cast<Ewk_Frame_Load_Error*>(eventInfo);
539
540     // EFL port emits both "load,finished" and "load,error" signals in error case.
541     // Error case is therefore already handled in onFrameLoadError() and we don't need
542     // to handle it here.
543     if (error)
544         return;
545
546     if (!done && gLayoutTestController->dumpFrameLoadCallbacks()) {
547         const String frameName(DumpRenderTreeSupportEfl::suitableDRTFrameName(frame));
548         printf("%s - didFinishLoadForFrame\n", frameName.utf8().data());
549     }
550
551     if (frame == topLoadingFrame)
552         topLoadingFrameLoadFinished();
553 }
554
555 void DumpRenderTreeChrome::onFrameLoadError(void*, Evas_Object* frame, void*)
556 {
557     if (!done && gLayoutTestController->dumpFrameLoadCallbacks()) {
558         const String frameName(DumpRenderTreeSupportEfl::suitableDRTFrameName(frame));
559         printf("%s - didFailLoadWithError\n", frameName.utf8().data());
560     }
561
562     if (frame == topLoadingFrame)
563         topLoadingFrameLoadFinished();
564 }
565
566 void DumpRenderTreeChrome::onFrameRedirectCancelled(void*, Evas_Object* frame, void*)
567 {
568     if (!done && gLayoutTestController->dumpFrameLoadCallbacks()) {
569         const String frameName(DumpRenderTreeSupportEfl::suitableDRTFrameName(frame));
570         printf("%s - didCancelClientRedirectForFrame\n", frameName.utf8().data());
571     }
572 }
573
574 void DumpRenderTreeChrome::onFrameRedirectForProvisionalLoad(void*, Evas_Object* frame, void*)
575 {
576     if (!done && gLayoutTestController->dumpFrameLoadCallbacks()) {
577         const String frameName(DumpRenderTreeSupportEfl::suitableDRTFrameName(frame));
578         printf("%s - didReceiveServerRedirectForProvisionalLoadForFrame\n", frameName.utf8().data());
579     }
580 }
581
582 void DumpRenderTreeChrome::onFrameRedirectRequested(void*, Evas_Object* frame, void* eventInfo)
583 {
584     const char* url = static_cast<const char*>(eventInfo);
585
586     if (!done && gLayoutTestController->dumpFrameLoadCallbacks()) {
587         const String frameName(DumpRenderTreeSupportEfl::suitableDRTFrameName(frame));
588         printf("%s - willPerformClientRedirectToURL: %s \n", frameName.utf8().data(), pathSuitableForTestResult(url).data());
589     }
590 }
591
592 void DumpRenderTreeChrome::onDidDetectXSS(void*, Evas_Object* view, void*)
593 {
594     if (!done && gLayoutTestController->dumpFrameLoadCallbacks())
595         printf("didDetectXSS\n");
596 }
597
598 void DumpRenderTreeChrome::onResponseReceived(void*, Evas_Object*, void* eventInfo)
599 {
600     Ewk_Frame_Resource_Response* response = static_cast<Ewk_Frame_Resource_Response*>(eventInfo);
601
602     if (!done && gLayoutTestController->dumpResourceLoadCallbacks()) {
603         CString responseDescription(descriptionSuitableForTestResult(response));
604         printf("%s - didReceiveResponse %s\n",
605                m_dumpAssignedUrls.contains(response->identifier) ? m_dumpAssignedUrls.get(response->identifier).data() : "<unknown>",
606                responseDescription.data());
607     }
608
609     if (!done && gLayoutTestController->dumpResourceResponseMIMETypes()) {
610         printf("%s has MIME type %s\n",
611                KURL(ParsedURLString, response->url).lastPathComponent().utf8().data(),
612                response->mime_type);
613     }
614 }
615
616 void DumpRenderTreeChrome::onResourceLoadFinished(void*, Evas_Object*, void* eventInfo)
617 {
618     unsigned long identifier = *static_cast<unsigned long*>(eventInfo);
619
620     if (!done && gLayoutTestController->dumpResourceLoadCallbacks())
621         printf("%s - didFinishLoading\n",
622                (m_dumpAssignedUrls.contains(identifier) ? m_dumpAssignedUrls.take(identifier).data() : "<unknown>"));
623 }
624
625 void DumpRenderTreeChrome::onResourceLoadFailed(void*, Evas_Object*, void* eventInfo)
626 {
627     Ewk_Frame_Load_Error* error = static_cast<Ewk_Frame_Load_Error*>(eventInfo);
628
629     if (!done && gLayoutTestController->dumpResourceLoadCallbacks())
630         printf("%s - didFailLoadingWithError: %s\n",
631                (m_dumpAssignedUrls.contains(error->resource_identifier) ? m_dumpAssignedUrls.take(error->resource_identifier).data() : "<unknown>"),
632                descriptionSuitableForTestResult(error).data());
633 }
634
635 void DumpRenderTreeChrome::onNewResourceRequest(void*, Evas_Object*, void* eventInfo)
636 {
637     Ewk_Frame_Resource_Request* request = static_cast<Ewk_Frame_Resource_Request*>(eventInfo);
638
639     if (!done && gLayoutTestController->dumpResourceLoadCallbacks())
640         m_dumpAssignedUrls.add(request->identifier, pathSuitableForTestResult(request->url));
641 }