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