| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "v8_proxy.h" | 5 #include "v8_proxy.h" |
| 6 #undef LOG | 6 #undef LOG |
| 7 | 7 |
| 8 #include "webkit/tools/test_shell/test_shell.h" | 8 #include "webkit/tools/test_shell/test_shell.h" |
| 9 | 9 |
| 10 #include "base/base_paths.h" | 10 #include "base/base_paths.h" |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 // Reset state in the test webview delegate. | 487 // Reset state in the test webview delegate. |
| 488 delegate_ = new TestWebViewDelegate(this); | 488 delegate_ = new TestWebViewDelegate(this); |
| 489 webView()->SetDelegate(delegate_); | 489 webView()->SetDelegate(delegate_); |
| 490 } | 490 } |
| 491 | 491 |
| 492 void TestShell::LoadURL(const wchar_t* url) { | 492 void TestShell::LoadURL(const wchar_t* url) { |
| 493 LoadURLForFrame(url, NULL); | 493 LoadURLForFrame(url, NULL); |
| 494 } | 494 } |
| 495 | 495 |
| 496 bool TestShell::Navigate(const TestNavigationEntry& entry, bool reload) { | 496 bool TestShell::Navigate(const TestNavigationEntry& entry, bool reload) { |
| 497 // Get the right target frame for the entry. |
| 498 WebFrame* frame = webView()->GetMainFrame(); |
| 499 if (!entry.GetTargetFrame().empty()) |
| 500 frame = webView()->GetFrameWithName(entry.GetTargetFrame()); |
| 501 // TODO(mpcomplete): should we clear the target frame, or should |
| 502 // back/forward navigations maintain the target frame? |
| 503 |
| 504 // A navigation resulting from loading a javascript URL should not be |
| 505 // treated as a browser initiated event. Instead, we want it to look as if |
| 506 // the page initiated any load resulting from JS execution. |
| 507 if (!entry.GetURL().SchemeIs("javascript")) { |
| 508 delegate_->set_pending_extra_data( |
| 509 new TestShellExtraData(entry.GetPageID())); |
| 510 } |
| 511 |
| 512 // If we are reloading, then WebKit will use the state of the current page. |
| 513 // Otherwise, we give it the state to navigate to. |
| 514 if (!reload && !entry.GetContentState().empty()) { |
| 515 DCHECK(entry.GetPageID() != -1); |
| 516 frame->LoadHistoryState(entry.GetContentState()); |
| 517 } else { |
| 497 WebRequestCachePolicy cache_policy; | 518 WebRequestCachePolicy cache_policy; |
| 498 if (reload) { | 519 if (reload) { |
| 499 cache_policy = WebRequestReloadIgnoringCacheData; | 520 cache_policy = WebRequestReloadIgnoringCacheData; |
| 500 } else if (entry.GetPageID() != -1) { | |
| 501 cache_policy = WebRequestReturnCacheDataElseLoad; | |
| 502 } else { | 521 } else { |
| 522 DCHECK(entry.GetPageID() == -1); |
| 503 cache_policy = WebRequestUseProtocolCachePolicy; | 523 cache_policy = WebRequestUseProtocolCachePolicy; |
| 504 } | 524 } |
| 505 | 525 |
| 506 scoped_ptr<WebRequest> request(WebRequest::Create(entry.GetURL())); | 526 scoped_ptr<WebRequest> request(WebRequest::Create(entry.GetURL())); |
| 507 request->SetCachePolicy(cache_policy); | 527 request->SetCachePolicy(cache_policy); |
| 508 // If we are reloading, then WebKit will use the state of the current page. | |
| 509 // Otherwise, we give it the state to navigate to. | |
| 510 if (!reload) | |
| 511 request->SetHistoryState(entry.GetContentState()); | |
| 512 | |
| 513 // A navigation resulting from loading a javascript URL should not be | |
| 514 // treated as a browser initiated event. Instead, we want it to look as if | |
| 515 // the page initiated any load resulting from JS execution. | |
| 516 if (!entry.GetURL().SchemeIs("javascript")) { | |
| 517 delegate_->set_pending_extra_data( | |
| 518 new TestShellExtraData(entry.GetPageID())); | |
| 519 } | |
| 520 | |
| 521 // Get the right target frame for the entry. | |
| 522 WebFrame* frame = webView()->GetMainFrame(); | |
| 523 if (!entry.GetTargetFrame().empty()) | |
| 524 frame = webView()->GetFrameWithName(entry.GetTargetFrame()); | |
| 525 // TODO(mpcomplete): should we clear the target frame, or should | |
| 526 // back/forward navigations maintain the target frame? | |
| 527 | 528 |
| 528 frame->LoadRequest(request.get()); | 529 frame->LoadRequest(request.get()); |
| 530 } |
| 529 | 531 |
| 530 // In case LoadRequest failed before DidCreateDataSource was called. | 532 // In case LoadRequest failed before DidCreateDataSource was called. |
| 531 delegate_->set_pending_extra_data(NULL); | 533 delegate_->set_pending_extra_data(NULL); |
| 532 | 534 |
| 533 // Restore focus to the main frame prior to loading new request. | 535 // Restore focus to the main frame prior to loading new request. |
| 534 // This makes sure that we don't have a focused iframe. Otherwise, that | 536 // This makes sure that we don't have a focused iframe. Otherwise, that |
| 535 // iframe would keep focus when the SetFocus called immediately after | 537 // iframe would keep focus when the SetFocus called immediately after |
| 536 // LoadRequest, thus making some tests fail (see http://b/issue?id=845337 | 538 // LoadRequest, thus making some tests fail (see http://b/issue?id=845337 |
| 537 // for more details). | 539 // for more details). |
| 538 webView()->SetFocusedFrame(frame); | 540 webView()->SetFocusedFrame(frame); |
| 539 SetFocus(webViewHost(), true); | 541 SetFocus(webViewHost(), true); |
| 540 | 542 |
| 541 return true; | 543 return true; |
| 542 } | 544 } |
| 543 | 545 |
| 544 void TestShell::GoBackOrForward(int offset) { | 546 void TestShell::GoBackOrForward(int offset) { |
| 545 navigation_controller_->GoToOffset(offset); | 547 navigation_controller_->GoToOffset(offset); |
| 546 } | 548 } |
| 547 | 549 |
| 548 void TestShell::DumpDocumentText() { | 550 void TestShell::DumpDocumentText() { |
| 549 std::wstring file_path; | 551 std::wstring file_path; |
| 550 if (!PromptForSaveFile(L"Dump document text", &file_path)) | 552 if (!PromptForSaveFile(L"Dump document text", &file_path)) |
| 551 return; | 553 return; |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 651 } | 653 } |
| 652 #endif // OS_WIN | 654 #endif // OS_WIN |
| 653 return false; | 655 return false; |
| 654 } | 656 } |
| 655 | 657 |
| 656 std::wstring GetWebKitLocale() { | 658 std::wstring GetWebKitLocale() { |
| 657 return L"en-US"; | 659 return L"en-US"; |
| 658 } | 660 } |
| 659 | 661 |
| 660 } // namespace webkit_glue | 662 } // namespace webkit_glue |
| OLD | NEW |