Commit 9d9ec98b authored by jochen@chromium.org's avatar jochen@chromium.org

[content shell] hook up resource load callback printing

BUG=111316
R=marja@chromium.org


Review URL: https://chromiumcodereview.appspot.com/11821051

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@176119 0039d316-1c4b-4281-b951-d872f2087c98
parent cabca43b
......@@ -19,6 +19,7 @@
#include "content/shell/shell_messages.h"
#include "content/shell/shell_render_process_observer.h"
#include "content/shell/webkit_test_helpers.h"
#include "net/base/net_errors.h"
#include "net/base/net_util.h"
#include "skia/ext/platform_canvas.h"
#include "third_party/WebKit/Source/Platform/chromium/public/Platform.h"
......@@ -27,6 +28,7 @@
#include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebString.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebURLError.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebDevToolsAgent.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
......@@ -46,10 +48,12 @@ using WebKit::WebDevToolsAgent;
using WebKit::WebElement;
using WebKit::WebFrame;
using WebKit::WebGamepads;
using WebKit::WebIntentRequest;
using WebKit::WebRect;
using WebKit::WebSize;
using WebKit::WebString;
using WebKit::WebURL;
using WebKit::WebURLError;
using WebKit::WebVector;
using WebKit::WebView;
using WebTestRunner::WebPreferences;
......@@ -291,6 +295,46 @@ void WebKitTestRunner::applyPreferences() {
Send(new ShellViewHostMsg_OverridePreferences(routing_id(), prefs));
}
void WebKitTestRunner::setCurrentWebIntentRequest(
const WebIntentRequest& request) {
intent_request_ = request;
}
WebIntentRequest* WebKitTestRunner::currentWebIntentRequest() {
return &intent_request_;
}
std::string WebKitTestRunner::makeURLErrorDescription(
const WebURLError& error) {
std::string domain = error.domain.utf8();
int code = error.reason;
if (domain == net::kErrorDomain) {
domain = "NSURLErrorDomain";
switch (error.reason) {
case net::ERR_ABORTED:
code = -999; // NSURLErrorCancelled
break;
case net::ERR_UNSAFE_PORT:
// Our unsafe port checking happens at the network stack level, but we
// make this translation here to match the behavior of stock WebKit.
domain = "WebKitErrorDomain";
code = 103;
break;
case net::ERR_ADDRESS_INVALID:
case net::ERR_ADDRESS_UNREACHABLE:
case net::ERR_NETWORK_ACCESS_DENIED:
code = -1004; // NSURLErrorCannotConnectToHost
break;
}
} else {
DLOG(WARNING) << "Unknown error domain";
}
return base::StringPrintf("<NSError domain %s, code %d, failing URL \"%s\">",
domain.c_str(), code, error.unreachableURL.spec().data());
}
// WebTestRunner -------------------------------------------------------------
bool WebKitTestRunner::shouldDumpEditingCallbacks() const {
......@@ -313,6 +357,26 @@ bool WebKitTestRunner::shouldDumpTitleChanges() const {
return dump_title_changes_;
}
bool WebKitTestRunner::shouldDumpResourceLoadCallbacks() const {
return test_is_running_ && dump_resource_load_callbacks_;
}
bool WebKitTestRunner::shouldDumpResourceRequestCallbacks() const {
return test_is_running_ && dump_resource_request_callbacks_;
}
bool WebKitTestRunner::shouldDumpResourceResponseMIMETypes() const {
return test_is_running_ && dump_resource_response_mime_types_;
}
bool WebKitTestRunner::shouldDumpCreateView() const {
return dump_create_view_;
}
bool WebKitTestRunner::canOpenWindows() const {
return can_open_windows_;
}
// RenderViewObserver --------------------------------------------------------
void WebKitTestRunner::DidClearWindowObject(WebFrame* frame) {
......@@ -394,6 +458,7 @@ void WebKitTestRunner::WaitUntilDone() {
}
void WebKitTestRunner::CanOpenWindows() {
can_open_windows_ = true;
Send(new ShellViewHostMsg_CanOpenWindows(routing_id()));
}
......@@ -492,6 +557,22 @@ void WebKitTestRunner::DumpTitleChanges() {
dump_title_changes_ = true;
}
void WebKitTestRunner::DumpResourceLoadCallbacks() {
dump_resource_load_callbacks_ = true;
}
void WebKitTestRunner::DumpResourceRequestCallbacks() {
dump_resource_request_callbacks_ = true;
}
void WebKitTestRunner::DumpResourceResponseMIMETypes() {
dump_resource_response_mime_types_ = true;
}
void WebKitTestRunner::DumpCreateView() {
dump_create_view_ = true;
}
void WebKitTestRunner::NotImplemented(const std::string& object,
const std::string& method) {
Send(new ShellViewHostMsg_NotImplemented(routing_id(), object, method));
......@@ -507,6 +588,11 @@ void WebKitTestRunner::Reset() {
dump_user_gesture_in_frame_load_callbacks_ = false;
stop_provisional_frame_loads_ = false;
dump_title_changes_ = false;
dump_resource_load_callbacks_ = false;
dump_resource_request_callbacks_ = false;
dump_resource_response_mime_types_ = false;
dump_create_view_ = false;
can_open_windows_ = false;
test_is_running_ = true;
load_finished_ = false;
wait_until_done_ = false;
......
......@@ -8,6 +8,7 @@
#include "base/file_path.h"
#include "base/memory/scoped_ptr.h"
#include "content/public/renderer/render_view_observer.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebIntentRequest.h"
#include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/WebPreferences.h"
#include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestDelegate.h"
#include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestRunner.h"
......@@ -64,6 +65,9 @@ class WebKitTestRunner : public RenderViewObserver,
virtual WebKit::WebURL rewriteLayoutTestsURL(const std::string& utf8_url);
virtual ::WebTestRunner::WebPreferences* preferences();
virtual void applyPreferences();
virtual void setCurrentWebIntentRequest(const WebKit::WebIntentRequest&);
virtual WebKit::WebIntentRequest* currentWebIntentRequest();
virtual std::string makeURLErrorDescription(const WebKit::WebURLError& error);
// WebTestRunner implementation.
virtual bool shouldDumpEditingCallbacks() const;
......@@ -71,6 +75,11 @@ class WebKitTestRunner : public RenderViewObserver,
virtual bool shouldDumpUserGestureInFrameLoadCallbacks() const;
virtual bool stopProvisionalFrameLoads() const;
virtual bool shouldDumpTitleChanges() const;
virtual bool shouldDumpResourceLoadCallbacks() const;
virtual bool shouldDumpResourceRequestCallbacks() const;
virtual bool shouldDumpResourceResponseMIMETypes() const;
virtual bool shouldDumpCreateView() const;
virtual bool canOpenWindows() const;
void Reset();
void Display();
......@@ -92,6 +101,10 @@ class WebKitTestRunner : public RenderViewObserver,
void DumpUserGestureInFrameLoadCallbacks();
void StopProvisionalFrameLoads();
void DumpTitleChanges();
void DumpResourceLoadCallbacks();
void DumpResourceRequestCallbacks();
void DumpResourceResponseMIMETypes();
void DumpCreateView();
void NotImplemented(const std::string& object, const std::string& method);
......@@ -116,11 +129,18 @@ class WebKitTestRunner : public RenderViewObserver,
::WebTestRunner::WebPreferences prefs_;
WebKit::WebIntentRequest intent_request_;
bool dump_editing_callbacks_;
bool dump_frame_load_callbacks_;
bool dump_user_gesture_in_frame_load_callbacks_;
bool stop_provisional_frame_loads_;
bool dump_title_changes_;
bool dump_resource_load_callbacks_;
bool dump_resource_request_callbacks_;
bool dump_resource_response_mime_types_;
bool dump_create_view_;
bool can_open_windows_;
bool test_is_running_;
bool wait_until_done_;
......
......@@ -12,6 +12,10 @@ var testRunner = testRunner || {};
native function DumpUserGestureInFrameLoadCallbacks();
native function SetStopProvisionalFrameLoads();
native function DumpTitleChanges();
native function DumpResourceLoadCallbacks();
native function DumpResourceRequestCallbacks();
native function DumpResourceResponseMIMETypes();
native function DumpCreateView();
native function EvaluateInWebInspector();
native function ExecCommand();
native function GetWorkerThreadCount();
......@@ -98,6 +102,18 @@ var testRunner = testRunner || {};
Object.defineProperty(this,
"setStopProvisionalFrameLoads",
{value: SetStopProvisionalFrameLoads});
Object.defineProperty(this,
"dumpResourceLoadCallbacks",
{value: DumpResourceLoadCallbacks});
Object.defineProperty(this,
"dumpResourceRequestCallbacks",
{value: DumpResourceRequestCallbacks});
Object.defineProperty(this,
"dumpResourceResponseMIMETypes",
{value: DumpResourceResponseMIMETypes});
Object.defineProperty(this,
"dumpCreateView",
{value: DumpCreateView});
Object.defineProperty(this,
"dumpTitleChanges",
{value: DumpTitleChanges});
......
......@@ -247,6 +247,46 @@ v8::Handle<v8::Value> DumpTitleChanges(const v8::Arguments& args) {
return v8::Undefined();
}
v8::Handle<v8::Value> DumpResourceLoadCallbacks(const v8::Arguments& args) {
WebKitTestRunner* runner =
ShellRenderProcessObserver::GetInstance()->main_test_runner();
if (!runner)
return v8::Undefined();
runner->DumpResourceLoadCallbacks();
return v8::Undefined();
}
v8::Handle<v8::Value> DumpResourceRequestCallbacks(const v8::Arguments& args) {
WebKitTestRunner* runner =
ShellRenderProcessObserver::GetInstance()->main_test_runner();
if (!runner)
return v8::Undefined();
runner->DumpResourceRequestCallbacks();
return v8::Undefined();
}
v8::Handle<v8::Value> DumpResourceResponseMIMETypes(const v8::Arguments& args) {
WebKitTestRunner* runner =
ShellRenderProcessObserver::GetInstance()->main_test_runner();
if (!runner)
return v8::Undefined();
runner->DumpResourceResponseMIMETypes();
return v8::Undefined();
}
v8::Handle<v8::Value> DumpCreateView(const v8::Arguments& args) {
WebKitTestRunner* runner =
ShellRenderProcessObserver::GetInstance()->main_test_runner();
if (!runner)
return v8::Undefined();
runner->DumpCreateView();
return v8::Undefined();
}
v8::Handle<v8::Value> GetGlobalFlag(const v8::Arguments& args) {
return v8::Boolean::New(g_global_flag);
}
......@@ -340,6 +380,14 @@ WebKitTestRunnerBindings::GetNativeFunction(v8::Handle<v8::String> name) {
return v8::FunctionTemplate::New(SetStopProvisionalFrameLoads);
if (name->Equals(v8::String::New("DumpTitleChanges")))
return v8::FunctionTemplate::New(DumpTitleChanges);
if (name->Equals(v8::String::New("DumpResourceLoadCallbacks")))
return v8::FunctionTemplate::New(DumpResourceLoadCallbacks);
if (name->Equals(v8::String::New("DumpResourceRequestCallbacks")))
return v8::FunctionTemplate::New(DumpResourceRequestCallbacks);
if (name->Equals(v8::String::New("DumpResourceResponseMIMETypes")))
return v8::FunctionTemplate::New(DumpResourceResponseMIMETypes);
if (name->Equals(v8::String::New("DumpCreateView")))
return v8::FunctionTemplate::New(DumpCreateView);
if (name->Equals(v8::String::New("GetGlobalFlag")))
return v8::FunctionTemplate::New(GetGlobalFlag);
if (name->Equals(v8::String::New("SetGlobalFlag")))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment