Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Side by Side Diff: content/renderer/render_view_browsertest.cc

Issue 1978793002: RenderViewImpl::page_id_ isn't initialized for cross-process replacement navigations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 PageStateToHistoryEntry(base::get<0>(host_nav_params).page_state); 632 PageStateToHistoryEntry(base::get<0>(host_nav_params).page_state);
633 blink::WebHTTPBody body = entry->root().httpBody(); 633 blink::WebHTTPBody body = entry->root().httpBody();
634 blink::WebHTTPBody::Element element; 634 blink::WebHTTPBody::Element element;
635 bool successful = body.elementAt(0, element); 635 bool successful = body.elementAt(0, element);
636 EXPECT_TRUE(successful); 636 EXPECT_TRUE(successful);
637 EXPECT_EQ(blink::WebHTTPBody::Element::TypeData, element.type); 637 EXPECT_EQ(blink::WebHTTPBody::Element::TypeData, element.type);
638 EXPECT_EQ(length, element.data.size()); 638 EXPECT_EQ(length, element.data.size());
639 EXPECT_EQ(0, memcmp(raw_data, element.data.data(), length)); 639 EXPECT_EQ(0, memcmp(raw_data, element.data.data(), length));
640 } 640 }
641 641
642 // Check that page ID will be initialized in case of navigation
643 // that replaces current entry.
644 TEST_F(RenderViewImplTest, OnBrowserNavigationUpdatePageID) {
645 // An http url will trigger a resource load so cannot be used here.
646 CommonNavigationParams common_params;
647 StartNavigationParams start_params;
648 RequestNavigationParams request_params;
649 common_params.url = GURL("data:text/html,<div>Page</div>");
650 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
651 common_params.transition = ui::PAGE_TRANSITION_TYPED;
652
653 // Set up params to emulate a browser side navigation
654 // that should replace current entry.
655 common_params.should_replace_current_entry = true;
656 request_params.page_id = -1;
657 request_params.nav_entry_id = 1;
658 request_params.current_history_list_length = 1;
659
660 frame()->Navigate(common_params, start_params, request_params);
661 ProcessPendingMessages();
662
663 // Page ID should be initialized.
664 EXPECT_NE(view_page_id(), -1);
665
666 const IPC::Message* frame_navigate_msg =
667 render_thread_->sink().GetUniqueMessageMatching(
668 FrameHostMsg_DidCommitProvisionalLoad::ID);
669 EXPECT_TRUE(frame_navigate_msg);
670
671 FrameHostMsg_DidCommitProvisionalLoad::Param host_nav_params;
672 FrameHostMsg_DidCommitProvisionalLoad::Read(frame_navigate_msg,
673 &host_nav_params);
674 EXPECT_TRUE(base::get<0>(host_nav_params).page_state.IsValid());
675
676 const IPC::Message* frame_page_id_msg =
677 render_thread_->sink().GetUniqueMessageMatching(
678 FrameHostMsg_DidAssignPageId::ID);
679 EXPECT_TRUE(frame_page_id_msg);
680
681 FrameHostMsg_DidAssignPageId::Param host_page_id_params;
682 FrameHostMsg_DidAssignPageId::Read(frame_page_id_msg, &host_page_id_params);
683
684 EXPECT_EQ(base::get<0>(host_page_id_params), view_page_id());
685 }
686
642 #if defined(OS_ANDROID) 687 #if defined(OS_ANDROID)
643 TEST_F(RenderViewImplTest, OnNavigationLoadDataWithBaseURL) { 688 TEST_F(RenderViewImplTest, OnNavigationLoadDataWithBaseURL) {
644 CommonNavigationParams common_params; 689 CommonNavigationParams common_params;
645 common_params.url = GURL("data:text/html,"); 690 common_params.url = GURL("data:text/html,");
646 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; 691 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
647 common_params.transition = ui::PAGE_TRANSITION_TYPED; 692 common_params.transition = ui::PAGE_TRANSITION_TYPED;
648 common_params.base_url_for_data_url = GURL("about:blank"); 693 common_params.base_url_for_data_url = GURL("about:blank");
649 common_params.history_url_for_data_url = GURL("about:blank"); 694 common_params.history_url_for_data_url = GURL("about:blank");
650 RequestNavigationParams request_params; 695 RequestNavigationParams request_params;
651 request_params.data_url_as_string = 696 request_params.data_url_as_string =
(...skipping 1803 matching lines...) Expand 10 before | Expand all | Expand 10 after
2455 "," 2500 ","
2456 "\"functionDeclaration\":\"function foo(){ " 2501 "\"functionDeclaration\":\"function foo(){ "
2457 "Promise.resolve().then(() => " 2502 "Promise.resolve().then(() => "
2458 "console.log(239))}\"" 2503 "console.log(239))}\""
2459 "}" 2504 "}"
2460 "}"); 2505 "}");
2461 EXPECT_EQ(1, CountNotifications("Console.messageAdded")); 2506 EXPECT_EQ(1, CountNotifications("Console.messageAdded"));
2462 } 2507 }
2463 2508
2464 } // namespace content 2509 } // namespace content
OLDNEW
« content/renderer/render_frame_impl.cc ('K') | « content/renderer/render_frame_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698