| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/shell/renderer/webkit_test_runner.h" | 5 #include "content/shell/renderer/webkit_test_runner.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <clocale> | 8 #include <clocale> |
| 9 #include <cmath> | 9 #include <cmath> |
| 10 | 10 |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 is_main_window_(false), | 186 is_main_window_(false), |
| 187 focus_on_next_commit_(false), | 187 focus_on_next_commit_(false), |
| 188 leak_detector_(new LeakDetector(this)) { | 188 leak_detector_(new LeakDetector(this)) { |
| 189 } | 189 } |
| 190 | 190 |
| 191 WebKitTestRunner::~WebKitTestRunner() { | 191 WebKitTestRunner::~WebKitTestRunner() { |
| 192 } | 192 } |
| 193 | 193 |
| 194 // WebTestDelegate ----------------------------------------------------------- | 194 // WebTestDelegate ----------------------------------------------------------- |
| 195 | 195 |
| 196 void WebKitTestRunner::clearEditCommand() { | 196 void WebKitTestRunner::ClearEditCommand() { |
| 197 render_view()->ClearEditCommands(); | 197 render_view()->ClearEditCommands(); |
| 198 } | 198 } |
| 199 | 199 |
| 200 void WebKitTestRunner::setEditCommand(const std::string& name, | 200 void WebKitTestRunner::SetEditCommand(const std::string& name, |
| 201 const std::string& value) { | 201 const std::string& value) { |
| 202 render_view()->SetEditCommandForNextKeyEvent(name, value); | 202 render_view()->SetEditCommandForNextKeyEvent(name, value); |
| 203 } | 203 } |
| 204 | 204 |
| 205 void WebKitTestRunner::setGamepadProvider( | 205 void WebKitTestRunner::SetGamepadProvider( |
| 206 scoped_ptr<RendererGamepadProvider> provider) { | 206 scoped_ptr<RendererGamepadProvider> provider) { |
| 207 SetMockGamepadProvider(provider.Pass()); | 207 SetMockGamepadProvider(provider.Pass()); |
| 208 } | 208 } |
| 209 | 209 |
| 210 void WebKitTestRunner::setDeviceLightData(const double data) { | 210 void WebKitTestRunner::SetDeviceLightData(const double data) { |
| 211 SetMockDeviceLightData(data); | 211 SetMockDeviceLightData(data); |
| 212 } | 212 } |
| 213 | 213 |
| 214 void WebKitTestRunner::setDeviceMotionData(const WebDeviceMotionData& data) { | 214 void WebKitTestRunner::SetDeviceMotionData(const WebDeviceMotionData& data) { |
| 215 SetMockDeviceMotionData(data); | 215 SetMockDeviceMotionData(data); |
| 216 } | 216 } |
| 217 | 217 |
| 218 void WebKitTestRunner::setDeviceOrientationData( | 218 void WebKitTestRunner::SetDeviceOrientationData( |
| 219 const WebDeviceOrientationData& data) { | 219 const WebDeviceOrientationData& data) { |
| 220 SetMockDeviceOrientationData(data); | 220 SetMockDeviceOrientationData(data); |
| 221 } | 221 } |
| 222 | 222 |
| 223 void WebKitTestRunner::setScreenOrientation( | 223 void WebKitTestRunner::SetScreenOrientation( |
| 224 const WebScreenOrientationType& orientation) { | 224 const WebScreenOrientationType& orientation) { |
| 225 MockScreenOrientationClient* mock_client = | 225 MockScreenOrientationClient* mock_client = |
| 226 proxy()->GetScreenOrientationClientMock(); | 226 proxy()->GetScreenOrientationClientMock(); |
| 227 mock_client->UpdateDeviceOrientation(render_view()->GetWebView()->mainFrame(), | 227 mock_client->UpdateDeviceOrientation(render_view()->GetWebView()->mainFrame(), |
| 228 orientation); | 228 orientation); |
| 229 } | 229 } |
| 230 | 230 |
| 231 void WebKitTestRunner::resetScreenOrientation() { | 231 void WebKitTestRunner::ResetScreenOrientation() { |
| 232 MockScreenOrientationClient* mock_client = | 232 MockScreenOrientationClient* mock_client = |
| 233 proxy()->GetScreenOrientationClientMock(); | 233 proxy()->GetScreenOrientationClientMock(); |
| 234 mock_client->ResetData(); | 234 mock_client->ResetData(); |
| 235 } | 235 } |
| 236 | 236 |
| 237 void WebKitTestRunner::didChangeBatteryStatus( | 237 void WebKitTestRunner::DidChangeBatteryStatus( |
| 238 const blink::WebBatteryStatus& status) { | 238 const blink::WebBatteryStatus& status) { |
| 239 MockBatteryStatusChanged(status); | 239 MockBatteryStatusChanged(status); |
| 240 } | 240 } |
| 241 | 241 |
| 242 void WebKitTestRunner::printMessage(const std::string& message) { | 242 void WebKitTestRunner::PrintMessage(const std::string& message) { |
| 243 Send(new ShellViewHostMsg_PrintMessage(routing_id(), message)); | 243 Send(new ShellViewHostMsg_PrintMessage(routing_id(), message)); |
| 244 } | 244 } |
| 245 | 245 |
| 246 void WebKitTestRunner::postTask(WebTask* task) { | 246 void WebKitTestRunner::PostTask(WebTask* task) { |
| 247 Platform::current()->callOnMainThread(InvokeTaskHelper, task); | 247 Platform::current()->callOnMainThread(InvokeTaskHelper, task); |
| 248 } | 248 } |
| 249 | 249 |
| 250 void WebKitTestRunner::postDelayedTask(WebTask* task, long long ms) { | 250 void WebKitTestRunner::PostDelayedTask(WebTask* task, long long ms) { |
| 251 base::MessageLoop::current()->PostDelayedTask( | 251 base::MessageLoop::current()->PostDelayedTask( |
| 252 FROM_HERE, | 252 FROM_HERE, |
| 253 base::Bind(&WebTask::run, base::Owned(task)), | 253 base::Bind(&WebTask::run, base::Owned(task)), |
| 254 base::TimeDelta::FromMilliseconds(ms)); | 254 base::TimeDelta::FromMilliseconds(ms)); |
| 255 } | 255 } |
| 256 | 256 |
| 257 WebString WebKitTestRunner::registerIsolatedFileSystem( | 257 WebString WebKitTestRunner::RegisterIsolatedFileSystem( |
| 258 const blink::WebVector<blink::WebString>& absolute_filenames) { | 258 const blink::WebVector<blink::WebString>& absolute_filenames) { |
| 259 std::vector<base::FilePath> files; | 259 std::vector<base::FilePath> files; |
| 260 for (size_t i = 0; i < absolute_filenames.size(); ++i) | 260 for (size_t i = 0; i < absolute_filenames.size(); ++i) |
| 261 files.push_back(base::FilePath::FromUTF16Unsafe(absolute_filenames[i])); | 261 files.push_back(base::FilePath::FromUTF16Unsafe(absolute_filenames[i])); |
| 262 std::string filesystem_id; | 262 std::string filesystem_id; |
| 263 Send(new ShellViewHostMsg_RegisterIsolatedFileSystem( | 263 Send(new ShellViewHostMsg_RegisterIsolatedFileSystem( |
| 264 routing_id(), files, &filesystem_id)); | 264 routing_id(), files, &filesystem_id)); |
| 265 return WebString::fromUTF8(filesystem_id); | 265 return WebString::fromUTF8(filesystem_id); |
| 266 } | 266 } |
| 267 | 267 |
| 268 long long WebKitTestRunner::getCurrentTimeInMillisecond() { | 268 long long WebKitTestRunner::GetCurrentTimeInMillisecond() { |
| 269 return base::TimeDelta(base::Time::Now() - | 269 return base::TimeDelta(base::Time::Now() - |
| 270 base::Time::UnixEpoch()).ToInternalValue() / | 270 base::Time::UnixEpoch()).ToInternalValue() / |
| 271 base::Time::kMicrosecondsPerMillisecond; | 271 base::Time::kMicrosecondsPerMillisecond; |
| 272 } | 272 } |
| 273 | 273 |
| 274 WebString WebKitTestRunner::getAbsoluteWebStringFromUTF8Path( | 274 WebString WebKitTestRunner::GetAbsoluteWebStringFromUTF8Path( |
| 275 const std::string& utf8_path) { | 275 const std::string& utf8_path) { |
| 276 base::FilePath path = base::FilePath::FromUTF8Unsafe(utf8_path); | 276 base::FilePath path = base::FilePath::FromUTF8Unsafe(utf8_path); |
| 277 if (!path.IsAbsolute()) { | 277 if (!path.IsAbsolute()) { |
| 278 GURL base_url = | 278 GURL base_url = |
| 279 net::FilePathToFileURL(test_config_.current_working_directory.Append( | 279 net::FilePathToFileURL(test_config_.current_working_directory.Append( |
| 280 FILE_PATH_LITERAL("foo"))); | 280 FILE_PATH_LITERAL("foo"))); |
| 281 net::FileURLToFilePath(base_url.Resolve(utf8_path), &path); | 281 net::FileURLToFilePath(base_url.Resolve(utf8_path), &path); |
| 282 } | 282 } |
| 283 return path.AsUTF16Unsafe(); | 283 return path.AsUTF16Unsafe(); |
| 284 } | 284 } |
| 285 | 285 |
| 286 WebURL WebKitTestRunner::localFileToDataURL(const WebURL& file_url) { | 286 WebURL WebKitTestRunner::LocalFileToDataURL(const WebURL& file_url) { |
| 287 base::FilePath local_path; | 287 base::FilePath local_path; |
| 288 if (!net::FileURLToFilePath(file_url, &local_path)) | 288 if (!net::FileURLToFilePath(file_url, &local_path)) |
| 289 return WebURL(); | 289 return WebURL(); |
| 290 | 290 |
| 291 std::string contents; | 291 std::string contents; |
| 292 Send(new ShellViewHostMsg_ReadFileToString( | 292 Send(new ShellViewHostMsg_ReadFileToString( |
| 293 routing_id(), local_path, &contents)); | 293 routing_id(), local_path, &contents)); |
| 294 | 294 |
| 295 std::string contents_base64; | 295 std::string contents_base64; |
| 296 base::Base64Encode(contents, &contents_base64); | 296 base::Base64Encode(contents, &contents_base64); |
| 297 | 297 |
| 298 const char data_url_prefix[] = "data:text/css:charset=utf-8;base64,"; | 298 const char data_url_prefix[] = "data:text/css:charset=utf-8;base64,"; |
| 299 return WebURL(GURL(data_url_prefix + contents_base64)); | 299 return WebURL(GURL(data_url_prefix + contents_base64)); |
| 300 } | 300 } |
| 301 | 301 |
| 302 WebURL WebKitTestRunner::rewriteLayoutTestsURL(const std::string& utf8_url) { | 302 WebURL WebKitTestRunner::RewriteLayoutTestsURL(const std::string& utf8_url) { |
| 303 const char kPrefix[] = "file:///tmp/LayoutTests/"; | 303 const char kPrefix[] = "file:///tmp/LayoutTests/"; |
| 304 const int kPrefixLen = arraysize(kPrefix) - 1; | 304 const int kPrefixLen = arraysize(kPrefix) - 1; |
| 305 | 305 |
| 306 if (utf8_url.compare(0, kPrefixLen, kPrefix, kPrefixLen)) | 306 if (utf8_url.compare(0, kPrefixLen, kPrefix, kPrefixLen)) |
| 307 return WebURL(GURL(utf8_url)); | 307 return WebURL(GURL(utf8_url)); |
| 308 | 308 |
| 309 base::FilePath replace_path = | 309 base::FilePath replace_path = |
| 310 ShellRenderProcessObserver::GetInstance()->webkit_source_dir().Append( | 310 ShellRenderProcessObserver::GetInstance()->webkit_source_dir().Append( |
| 311 FILE_PATH_LITERAL("LayoutTests/")); | 311 FILE_PATH_LITERAL("LayoutTests/")); |
| 312 #if defined(OS_WIN) | 312 #if defined(OS_WIN) |
| 313 std::string utf8_path = base::WideToUTF8(replace_path.value()); | 313 std::string utf8_path = base::WideToUTF8(replace_path.value()); |
| 314 #else | 314 #else |
| 315 std::string utf8_path = | 315 std::string utf8_path = |
| 316 base::WideToUTF8(base::SysNativeMBToWide(replace_path.value())); | 316 base::WideToUTF8(base::SysNativeMBToWide(replace_path.value())); |
| 317 #endif | 317 #endif |
| 318 std::string new_url = | 318 std::string new_url = |
| 319 std::string("file://") + utf8_path + utf8_url.substr(kPrefixLen); | 319 std::string("file://") + utf8_path + utf8_url.substr(kPrefixLen); |
| 320 return WebURL(GURL(new_url)); | 320 return WebURL(GURL(new_url)); |
| 321 } | 321 } |
| 322 | 322 |
| 323 TestPreferences* WebKitTestRunner::preferences() { | 323 TestPreferences* WebKitTestRunner::Preferences() { |
| 324 return &prefs_; | 324 return &prefs_; |
| 325 } | 325 } |
| 326 | 326 |
| 327 void WebKitTestRunner::applyPreferences() { | 327 void WebKitTestRunner::ApplyPreferences() { |
| 328 WebPreferences prefs = render_view()->GetWebkitPreferences(); | 328 WebPreferences prefs = render_view()->GetWebkitPreferences(); |
| 329 ExportLayoutTestSpecificPreferences(prefs_, &prefs); | 329 ExportLayoutTestSpecificPreferences(prefs_, &prefs); |
| 330 render_view()->SetWebkitPreferences(prefs); | 330 render_view()->SetWebkitPreferences(prefs); |
| 331 Send(new ShellViewHostMsg_OverridePreferences(routing_id(), prefs)); | 331 Send(new ShellViewHostMsg_OverridePreferences(routing_id(), prefs)); |
| 332 } | 332 } |
| 333 | 333 |
| 334 std::string WebKitTestRunner::makeURLErrorDescription( | 334 std::string WebKitTestRunner::makeURLErrorDescription( |
| 335 const WebURLError& error) { | 335 const WebURLError& error) { |
| 336 std::string domain = error.domain.utf8(); | 336 std::string domain = error.domain.utf8(); |
| 337 int code = error.reason; | 337 int code = error.reason; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 355 break; | 355 break; |
| 356 } | 356 } |
| 357 } else { | 357 } else { |
| 358 DLOG(WARNING) << "Unknown error domain"; | 358 DLOG(WARNING) << "Unknown error domain"; |
| 359 } | 359 } |
| 360 | 360 |
| 361 return base::StringPrintf("<NSError domain %s, code %d, failing URL \"%s\">", | 361 return base::StringPrintf("<NSError domain %s, code %d, failing URL \"%s\">", |
| 362 domain.c_str(), code, error.unreachableURL.spec().data()); | 362 domain.c_str(), code, error.unreachableURL.spec().data()); |
| 363 } | 363 } |
| 364 | 364 |
| 365 void WebKitTestRunner::useUnfortunateSynchronousResizeMode(bool enable) { | 365 void WebKitTestRunner::UseUnfortunateSynchronousResizeMode(bool enable) { |
| 366 UseSynchronousResizeModeVisitor visitor(enable); | 366 UseSynchronousResizeModeVisitor visitor(enable); |
| 367 RenderView::ForEach(&visitor); | 367 RenderView::ForEach(&visitor); |
| 368 } | 368 } |
| 369 | 369 |
| 370 void WebKitTestRunner::enableAutoResizeMode(const WebSize& min_size, | 370 void WebKitTestRunner::EnableAutoResizeMode(const WebSize& min_size, |
| 371 const WebSize& max_size) { | 371 const WebSize& max_size) { |
| 372 EnableAutoResizeMode(render_view(), min_size, max_size); | 372 content::EnableAutoResizeMode(render_view(), min_size, max_size); |
| 373 } | 373 } |
| 374 | 374 |
| 375 void WebKitTestRunner::disableAutoResizeMode(const WebSize& new_size) { | 375 void WebKitTestRunner::DisableAutoResizeMode(const WebSize& new_size) { |
| 376 DisableAutoResizeMode(render_view(), new_size); | 376 content::DisableAutoResizeMode(render_view(), new_size); |
| 377 if (!new_size.isEmpty()) | 377 if (!new_size.isEmpty()) |
| 378 ForceResizeRenderView(render_view(), new_size); | 378 ForceResizeRenderView(render_view(), new_size); |
| 379 } | 379 } |
| 380 | 380 |
| 381 void WebKitTestRunner::clearDevToolsLocalStorage() { | 381 void WebKitTestRunner::ClearDevToolsLocalStorage() { |
| 382 Send(new ShellViewHostMsg_ClearDevToolsLocalStorage(routing_id())); | 382 Send(new ShellViewHostMsg_ClearDevToolsLocalStorage(routing_id())); |
| 383 } | 383 } |
| 384 | 384 |
| 385 void WebKitTestRunner::showDevTools(const std::string& settings, | 385 void WebKitTestRunner::ShowDevTools(const std::string& settings, |
| 386 const std::string& frontend_url) { | 386 const std::string& frontend_url) { |
| 387 Send(new ShellViewHostMsg_ShowDevTools( | 387 Send(new ShellViewHostMsg_ShowDevTools( |
| 388 routing_id(), settings, frontend_url)); | 388 routing_id(), settings, frontend_url)); |
| 389 } | 389 } |
| 390 | 390 |
| 391 void WebKitTestRunner::closeDevTools() { | 391 void WebKitTestRunner::CloseDevTools() { |
| 392 Send(new ShellViewHostMsg_CloseDevTools(routing_id())); | 392 Send(new ShellViewHostMsg_CloseDevTools(routing_id())); |
| 393 WebDevToolsAgent* agent = render_view()->GetWebView()->devToolsAgent(); | 393 WebDevToolsAgent* agent = render_view()->GetWebView()->devToolsAgent(); |
| 394 if (agent) | 394 if (agent) |
| 395 agent->detach(); | 395 agent->detach(); |
| 396 } | 396 } |
| 397 | 397 |
| 398 void WebKitTestRunner::evaluateInWebInspector(long call_id, | 398 void WebKitTestRunner::EvaluateInWebInspector(long call_id, |
| 399 const std::string& script) { | 399 const std::string& script) { |
| 400 WebDevToolsAgent* agent = render_view()->GetWebView()->devToolsAgent(); | 400 WebDevToolsAgent* agent = render_view()->GetWebView()->devToolsAgent(); |
| 401 if (agent) | 401 if (agent) |
| 402 agent->evaluateInWebInspector(call_id, WebString::fromUTF8(script)); | 402 agent->evaluateInWebInspector(call_id, WebString::fromUTF8(script)); |
| 403 } | 403 } |
| 404 | 404 |
| 405 void WebKitTestRunner::clearAllDatabases() { | 405 void WebKitTestRunner::ClearAllDatabases() { |
| 406 Send(new ShellViewHostMsg_ClearAllDatabases(routing_id())); | 406 Send(new ShellViewHostMsg_ClearAllDatabases(routing_id())); |
| 407 } | 407 } |
| 408 | 408 |
| 409 void WebKitTestRunner::setDatabaseQuota(int quota) { | 409 void WebKitTestRunner::SetDatabaseQuota(int quota) { |
| 410 Send(new ShellViewHostMsg_SetDatabaseQuota(routing_id(), quota)); | 410 Send(new ShellViewHostMsg_SetDatabaseQuota(routing_id(), quota)); |
| 411 } | 411 } |
| 412 | 412 |
| 413 blink::WebNotificationPresenter::Permission | 413 blink::WebNotificationPresenter::Permission |
| 414 WebKitTestRunner::checkWebNotificationPermission(const GURL& origin) { | 414 WebKitTestRunner::CheckWebNotificationPermission(const GURL& origin) { |
| 415 int permission = blink::WebNotificationPresenter::PermissionNotAllowed; | 415 int permission = blink::WebNotificationPresenter::PermissionNotAllowed; |
| 416 Send(new ShellViewHostMsg_CheckWebNotificationPermission( | 416 Send(new ShellViewHostMsg_CheckWebNotificationPermission( |
| 417 routing_id(), | 417 routing_id(), |
| 418 origin, | 418 origin, |
| 419 &permission)); | 419 &permission)); |
| 420 return static_cast<blink::WebNotificationPresenter::Permission>(permission); | 420 return static_cast<blink::WebNotificationPresenter::Permission>(permission); |
| 421 } | 421 } |
| 422 | 422 |
| 423 void WebKitTestRunner::grantWebNotificationPermission(const GURL& origin, | 423 void WebKitTestRunner::GrantWebNotificationPermission(const GURL& origin, |
| 424 bool permission_granted) { | 424 bool permission_granted) { |
| 425 Send(new ShellViewHostMsg_GrantWebNotificationPermission( | 425 Send(new ShellViewHostMsg_GrantWebNotificationPermission( |
| 426 routing_id(), origin, permission_granted)); | 426 routing_id(), origin, permission_granted)); |
| 427 } | 427 } |
| 428 | 428 |
| 429 void WebKitTestRunner::clearWebNotificationPermissions() { | 429 void WebKitTestRunner::ClearWebNotificationPermissions() { |
| 430 Send(new ShellViewHostMsg_ClearWebNotificationPermissions(routing_id())); | 430 Send(new ShellViewHostMsg_ClearWebNotificationPermissions(routing_id())); |
| 431 } | 431 } |
| 432 | 432 |
| 433 void WebKitTestRunner::setDeviceScaleFactor(float factor) { | 433 void WebKitTestRunner::SetDeviceScaleFactor(float factor) { |
| 434 SetDeviceScaleFactor(render_view(), factor); | 434 content::SetDeviceScaleFactor(render_view(), factor); |
| 435 } | 435 } |
| 436 | 436 |
| 437 void WebKitTestRunner::setDeviceColorProfile(const std::string& name) { | 437 void WebKitTestRunner::SetDeviceColorProfile(const std::string& name) { |
| 438 SetDeviceColorProfile(render_view(), name); | 438 content::SetDeviceColorProfile(render_view(), name); |
| 439 } | 439 } |
| 440 | 440 |
| 441 void WebKitTestRunner::setFocus(WebTestProxyBase* proxy, bool focus) { | 441 void WebKitTestRunner::SetFocus(WebTestProxyBase* proxy, bool focus) { |
| 442 ProxyToRenderViewVisitor visitor(proxy); | 442 ProxyToRenderViewVisitor visitor(proxy); |
| 443 RenderView::ForEach(&visitor); | 443 RenderView::ForEach(&visitor); |
| 444 if (!visitor.render_view()) { | 444 if (!visitor.render_view()) { |
| 445 NOTREACHED(); | 445 NOTREACHED(); |
| 446 return; | 446 return; |
| 447 } | 447 } |
| 448 | 448 |
| 449 // Check whether the focused view was closed meanwhile. | 449 // Check whether the focused view was closed meanwhile. |
| 450 if (!WebKitTestRunner::Get(focused_view_)) | 450 if (!WebKitTestRunner::Get(focused_view_)) |
| 451 focused_view_ = NULL; | 451 focused_view_ = NULL; |
| 452 | 452 |
| 453 if (focus) { | 453 if (focus) { |
| 454 if (focused_view_ != visitor.render_view()) { | 454 if (focused_view_ != visitor.render_view()) { |
| 455 if (focused_view_) | 455 if (focused_view_) |
| 456 SetFocusAndActivate(focused_view_, false); | 456 SetFocusAndActivate(focused_view_, false); |
| 457 SetFocusAndActivate(visitor.render_view(), true); | 457 SetFocusAndActivate(visitor.render_view(), true); |
| 458 focused_view_ = visitor.render_view(); | 458 focused_view_ = visitor.render_view(); |
| 459 } | 459 } |
| 460 } else { | 460 } else { |
| 461 if (focused_view_ == visitor.render_view()) { | 461 if (focused_view_ == visitor.render_view()) { |
| 462 SetFocusAndActivate(visitor.render_view(), false); | 462 SetFocusAndActivate(visitor.render_view(), false); |
| 463 focused_view_ = NULL; | 463 focused_view_ = NULL; |
| 464 } | 464 } |
| 465 } | 465 } |
| 466 } | 466 } |
| 467 | 467 |
| 468 void WebKitTestRunner::setAcceptAllCookies(bool accept) { | 468 void WebKitTestRunner::SetAcceptAllCookies(bool accept) { |
| 469 Send(new ShellViewHostMsg_AcceptAllCookies(routing_id(), accept)); | 469 Send(new ShellViewHostMsg_AcceptAllCookies(routing_id(), accept)); |
| 470 } | 470 } |
| 471 | 471 |
| 472 std::string WebKitTestRunner::pathToLocalResource(const std::string& resource) { | 472 std::string WebKitTestRunner::PathToLocalResource(const std::string& resource) { |
| 473 #if defined(OS_WIN) | 473 #if defined(OS_WIN) |
| 474 if (resource.find("/tmp/") == 0) { | 474 if (resource.find("/tmp/") == 0) { |
| 475 // We want a temp file. | 475 // We want a temp file. |
| 476 GURL base_url = net::FilePathToFileURL(test_config_.temp_path); | 476 GURL base_url = net::FilePathToFileURL(test_config_.temp_path); |
| 477 return base_url.Resolve(resource.substr(strlen("/tmp/"))).spec(); | 477 return base_url.Resolve(resource.substr(strlen("/tmp/"))).spec(); |
| 478 } | 478 } |
| 479 #endif | 479 #endif |
| 480 | 480 |
| 481 // Some layout tests use file://// which we resolve as a UNC path. Normalize | 481 // Some layout tests use file://// which we resolve as a UNC path. Normalize |
| 482 // them to just file:///. | 482 // them to just file:///. |
| 483 std::string result = resource; | 483 std::string result = resource; |
| 484 while (base::StringToLowerASCII(result).find("file:////") == 0) { | 484 while (base::StringToLowerASCII(result).find("file:////") == 0) { |
| 485 result = result.substr(0, strlen("file:///")) + | 485 result = result.substr(0, strlen("file:///")) + |
| 486 result.substr(strlen("file:////")); | 486 result.substr(strlen("file:////")); |
| 487 } | 487 } |
| 488 return rewriteLayoutTestsURL(result).spec(); | 488 return RewriteLayoutTestsURL(result).spec(); |
| 489 } | 489 } |
| 490 | 490 |
| 491 void WebKitTestRunner::setLocale(const std::string& locale) { | 491 void WebKitTestRunner::SetLocale(const std::string& locale) { |
| 492 setlocale(LC_ALL, locale.c_str()); | 492 setlocale(LC_ALL, locale.c_str()); |
| 493 } | 493 } |
| 494 | 494 |
| 495 void WebKitTestRunner::testFinished() { | 495 void WebKitTestRunner::TestFinished() { |
| 496 if (!is_main_window_) { | 496 if (!is_main_window_) { |
| 497 Send(new ShellViewHostMsg_TestFinishedInSecondaryWindow(routing_id())); | 497 Send(new ShellViewHostMsg_TestFinishedInSecondaryWindow(routing_id())); |
| 498 return; | 498 return; |
| 499 } | 499 } |
| 500 WebTestInterfaces* interfaces = | 500 WebTestInterfaces* interfaces = |
| 501 ShellRenderProcessObserver::GetInstance()->test_interfaces(); | 501 ShellRenderProcessObserver::GetInstance()->test_interfaces(); |
| 502 interfaces->setTestIsRunning(false); | 502 interfaces->setTestIsRunning(false); |
| 503 if (interfaces->testRunner()->ShouldDumpBackForwardList()) { | 503 if (interfaces->testRunner()->ShouldDumpBackForwardList()) { |
| 504 SyncNavigationStateVisitor visitor; | 504 SyncNavigationStateVisitor visitor; |
| 505 RenderView::ForEach(&visitor); | 505 RenderView::ForEach(&visitor); |
| 506 Send(new ShellViewHostMsg_CaptureSessionHistory(routing_id())); | 506 Send(new ShellViewHostMsg_CaptureSessionHistory(routing_id())); |
| 507 } else { | 507 } else { |
| 508 CaptureDump(); | 508 CaptureDump(); |
| 509 } | 509 } |
| 510 } | 510 } |
| 511 | 511 |
| 512 void WebKitTestRunner::closeRemainingWindows() { | 512 void WebKitTestRunner::CloseRemainingWindows() { |
| 513 NavigateAwayVisitor visitor(render_view()); | 513 NavigateAwayVisitor visitor(render_view()); |
| 514 RenderView::ForEach(&visitor); | 514 RenderView::ForEach(&visitor); |
| 515 Send(new ShellViewHostMsg_CloseRemainingWindows(routing_id())); | 515 Send(new ShellViewHostMsg_CloseRemainingWindows(routing_id())); |
| 516 } | 516 } |
| 517 | 517 |
| 518 void WebKitTestRunner::deleteAllCookies() { | 518 void WebKitTestRunner::DeleteAllCookies() { |
| 519 Send(new ShellViewHostMsg_DeleteAllCookies(routing_id())); | 519 Send(new ShellViewHostMsg_DeleteAllCookies(routing_id())); |
| 520 } | 520 } |
| 521 | 521 |
| 522 int WebKitTestRunner::navigationEntryCount() { | 522 int WebKitTestRunner::NavigationEntryCount() { |
| 523 return GetLocalSessionHistoryLength(render_view()); | 523 return GetLocalSessionHistoryLength(render_view()); |
| 524 } | 524 } |
| 525 | 525 |
| 526 void WebKitTestRunner::goToOffset(int offset) { | 526 void WebKitTestRunner::GoToOffset(int offset) { |
| 527 Send(new ShellViewHostMsg_GoToOffset(routing_id(), offset)); | 527 Send(new ShellViewHostMsg_GoToOffset(routing_id(), offset)); |
| 528 } | 528 } |
| 529 | 529 |
| 530 void WebKitTestRunner::reload() { | 530 void WebKitTestRunner::Reload() { |
| 531 Send(new ShellViewHostMsg_Reload(routing_id())); | 531 Send(new ShellViewHostMsg_Reload(routing_id())); |
| 532 } | 532 } |
| 533 | 533 |
| 534 void WebKitTestRunner::loadURLForFrame(const WebURL& url, | 534 void WebKitTestRunner::LoadURLForFrame(const WebURL& url, |
| 535 const std::string& frame_name) { | 535 const std::string& frame_name) { |
| 536 Send(new ShellViewHostMsg_LoadURLForFrame( | 536 Send(new ShellViewHostMsg_LoadURLForFrame( |
| 537 routing_id(), url, frame_name)); | 537 routing_id(), url, frame_name)); |
| 538 } | 538 } |
| 539 | 539 |
| 540 bool WebKitTestRunner::allowExternalPages() { | 540 bool WebKitTestRunner::AllowExternalPages() { |
| 541 return test_config_.allow_external_pages; | 541 return test_config_.allow_external_pages; |
| 542 } | 542 } |
| 543 | 543 |
| 544 std::string WebKitTestRunner::dumpHistoryForWindow(WebTestProxyBase* proxy) { | 544 std::string WebKitTestRunner::DumpHistoryForWindow(WebTestProxyBase* proxy) { |
| 545 size_t pos = 0; | 545 size_t pos = 0; |
| 546 std::vector<int>::iterator id; | 546 std::vector<int>::iterator id; |
| 547 for (id = routing_ids_.begin(); id != routing_ids_.end(); ++id, ++pos) { | 547 for (id = routing_ids_.begin(); id != routing_ids_.end(); ++id, ++pos) { |
| 548 RenderView* render_view = RenderView::FromRoutingID(*id); | 548 RenderView* render_view = RenderView::FromRoutingID(*id); |
| 549 if (!render_view) { | 549 if (!render_view) { |
| 550 NOTREACHED(); | 550 NOTREACHED(); |
| 551 continue; | 551 continue; |
| 552 } | 552 } |
| 553 if (WebKitTestRunner::Get(render_view)->proxy() == proxy) | 553 if (WebKitTestRunner::Get(render_view)->proxy() == proxy) |
| 554 break; | 554 break; |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 693 } | 693 } |
| 694 | 694 |
| 695 void WebKitTestRunner::OnSetTestConfiguration( | 695 void WebKitTestRunner::OnSetTestConfiguration( |
| 696 const ShellTestConfiguration& params) { | 696 const ShellTestConfiguration& params) { |
| 697 test_config_ = params; | 697 test_config_ = params; |
| 698 is_main_window_ = true; | 698 is_main_window_ = true; |
| 699 | 699 |
| 700 ForceResizeRenderView( | 700 ForceResizeRenderView( |
| 701 render_view(), | 701 render_view(), |
| 702 WebSize(params.initial_size.width(), params.initial_size.height())); | 702 WebSize(params.initial_size.width(), params.initial_size.height())); |
| 703 setFocus(proxy_, true); | 703 SetFocus(proxy_, true); |
| 704 | 704 |
| 705 WebTestInterfaces* interfaces = | 705 WebTestInterfaces* interfaces = |
| 706 ShellRenderProcessObserver::GetInstance()->test_interfaces(); | 706 ShellRenderProcessObserver::GetInstance()->test_interfaces(); |
| 707 interfaces->setTestIsRunning(true); | 707 interfaces->setTestIsRunning(true); |
| 708 interfaces->configureForTestWithURL(params.test_url, | 708 interfaces->configureForTestWithURL(params.test_url, |
| 709 params.enable_pixel_dumping); | 709 params.enable_pixel_dumping); |
| 710 } | 710 } |
| 711 | 711 |
| 712 void WebKitTestRunner::OnSessionHistory( | 712 void WebKitTestRunner::OnSessionHistory( |
| 713 const std::vector<int>& routing_ids, | 713 const std::vector<int>& routing_ids, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 742 | 742 |
| 743 leak_detector_->TryLeakDetection(main_frame); | 743 leak_detector_->TryLeakDetection(main_frame); |
| 744 } | 744 } |
| 745 | 745 |
| 746 void WebKitTestRunner::ReportLeakDetectionResult( | 746 void WebKitTestRunner::ReportLeakDetectionResult( |
| 747 const LeakDetectionResult& report) { | 747 const LeakDetectionResult& report) { |
| 748 Send(new ShellViewHostMsg_LeakDetectionDone(routing_id(), report)); | 748 Send(new ShellViewHostMsg_LeakDetectionDone(routing_id(), report)); |
| 749 } | 749 } |
| 750 | 750 |
| 751 } // namespace content | 751 } // namespace content |
| OLD | NEW |