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 <stdint.h> | 5 #include <stdint.h> |
6 #include <utility> | 6 #include <utility> |
7 | 7 |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
398 controller().LoadURL( | 398 controller().LoadURL( |
399 kGURL, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 399 kGURL, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
400 | 400 |
401 NavigationEntry* entry = controller().GetVisibleEntry(); | 401 NavigationEntry* entry = controller().GetVisibleEntry(); |
402 ASSERT_EQ(kGURL, entry->GetURL()); | 402 ASSERT_EQ(kGURL, entry->GetURL()); |
403 entry->SetTitle(title); | 403 entry->SetTitle(title); |
404 | 404 |
405 EXPECT_EQ(title, contents()->GetTitle()); | 405 EXPECT_EQ(title, contents()->GetTitle()); |
406 } | 406 } |
407 | 407 |
408 // Test view source mode for a webui page. | 408 // A page shouldn't be able to open view-source for a webui page. |
409 TEST_F(WebContentsImplTest, NTPViewSource) { | 409 TEST_F(WebContentsImplTest, ContentInitiatedViewSource) { |
410 NavigationControllerImpl& cont = | 410 NavigationControllerImpl& cont = |
411 static_cast<NavigationControllerImpl&>(controller()); | 411 static_cast<NavigationControllerImpl&>(controller()); |
412 const char kUrl[] = "view-source:chrome://blah"; | 412 const char kUrl[] = "view-source:chrome://blah"; |
413 const GURL kGURL(kUrl); | 413 const GURL kGURL(kUrl); |
414 | 414 |
415 process()->sink().ClearMessages(); | 415 process()->sink().ClearMessages(); |
416 | 416 |
417 cont.LoadURL( | 417 cont.LoadURL(kGURL, Referrer(), ui::PAGE_TRANSITION_LINK, std::string()); |
Charlie Reis
2016/05/16 22:22:18
The transition type doesn't make this a renderer-i
meacer
2016/05/19 01:13:54
This test is problematic in that it uses LoadURL i
Charlie Reis
2016/05/23 22:32:16
I definitely think it's worth testing both the bro
meacer
2016/05/23 23:57:47
Added multiple browser tests and a layout test.
| |
418 kGURL, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | |
419 int entry_id = cont.GetPendingEntry()->GetUniqueID(); | 418 int entry_id = cont.GetPendingEntry()->GetUniqueID(); |
420 // Did we get the expected message? | 419 // Did we get the expected message? |
420 // TODO(meacer): This probably shouldn't be true if we can't navigate to the | |
421 // view-source URL. | |
Charlie Reis
2016/05/16 22:22:18
Yeah, this would be concerning if it happened for
meacer
2016/05/19 01:13:54
Now that the test is testing a browser initiated n
Charlie Reis
2016/05/23 22:32:16
I'm confused-- I thought you were making this a te
meacer
2016/05/23 23:57:47
Sorry for the confusion, I decided to only check b
| |
421 EXPECT_TRUE(process()->sink().GetFirstMessageMatching( | 422 EXPECT_TRUE(process()->sink().GetFirstMessageMatching( |
422 FrameMsg_EnableViewSourceMode::ID)); | 423 FrameMsg_EnableViewSourceMode::ID)); |
423 | 424 |
424 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 425 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
425 InitNavigateParams(¶ms, 0, entry_id, true, kGURL, | 426 InitNavigateParams(¶ms, 0, entry_id, true, kGURL, |
426 ui::PAGE_TRANSITION_TYPED); | 427 ui::PAGE_TRANSITION_TYPED); |
427 contents()->GetMainFrame()->PrepareForCommit(); | 428 contents()->GetMainFrame()->PrepareForCommit(); |
428 contents()->GetMainFrame()->SendNavigateWithParams(¶ms); | 429 contents()->GetMainFrame()->SendNavigateWithParams(¶ms); |
429 // Also check title and url. | 430 // Child processes shouldn't be able to load view-source URLs. |
430 EXPECT_EQ(base::ASCIIToUTF16(kUrl), contents()->GetTitle()); | 431 EXPECT_EQ(base::ASCIIToUTF16("about:blank"), contents()->GetTitle()); |
Charlie Reis
2016/05/16 22:22:18
I'm curious what happened here. Why did it get re
meacer
2016/05/19 01:13:54
As I mentioned in the comment above, view-source:c
| |
431 } | 432 } |
432 | 433 |
433 // Test to ensure UpdateMaxPageID is working properly. | 434 // Test to ensure UpdateMaxPageID is working properly. |
434 TEST_F(WebContentsImplTest, UpdateMaxPageID) { | 435 TEST_F(WebContentsImplTest, UpdateMaxPageID) { |
435 SiteInstance* instance1 = contents()->GetSiteInstance(); | 436 SiteInstance* instance1 = contents()->GetSiteInstance(); |
436 scoped_refptr<SiteInstance> instance2(SiteInstance::Create(nullptr)); | 437 scoped_refptr<SiteInstance> instance2(SiteInstance::Create(nullptr)); |
437 | 438 |
438 // Starts at -1. | 439 // Starts at -1. |
439 EXPECT_EQ(-1, contents()->GetMaxPageID()); | 440 EXPECT_EQ(-1, contents()->GetMaxPageID()); |
440 EXPECT_EQ(-1, contents()->GetMaxPageIDForSiteInstance(instance1)); | 441 EXPECT_EQ(-1, contents()->GetMaxPageIDForSiteInstance(instance1)); |
(...skipping 3012 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3453 // An automatic navigation. | 3454 // An automatic navigation. |
3454 contents()->GetMainFrame()->SendNavigateWithModificationCallback( | 3455 contents()->GetMainFrame()->SendNavigateWithModificationCallback( |
3455 2, 0, true, GURL(url::kAboutBlankURL), base::Bind(SetAsNonUserGesture)); | 3456 2, 0, true, GURL(url::kAboutBlankURL), base::Bind(SetAsNonUserGesture)); |
3456 | 3457 |
3457 EXPECT_EQ(1u, dialog_manager.reset_count()); | 3458 EXPECT_EQ(1u, dialog_manager.reset_count()); |
3458 | 3459 |
3459 contents()->SetJavaScriptDialogManagerForTesting(nullptr); | 3460 contents()->SetJavaScriptDialogManagerForTesting(nullptr); |
3460 } | 3461 } |
3461 | 3462 |
3462 } // namespace content | 3463 } // namespace content |
OLD | NEW |