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

Side by Side Diff: content/browser/web_contents/web_contents_impl_unittest.cc

Issue 2566583002: Change allowed bindings to be per RenderFrame instead of per RenderView. (Closed)
Patch Set: Created 4 years 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 <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 1122 matching lines...) Expand 10 before | Expand all | Expand 10 after
1133 contents()->TestDidNavigate(webui_rfh, entry_id, true, url1, 1133 contents()->TestDidNavigate(webui_rfh, entry_id, true, url1,
1134 ui::PAGE_TRANSITION_TYPED); 1134 ui::PAGE_TRANSITION_TYPED);
1135 NavigationEntry* entry1 = controller().GetLastCommittedEntry(); 1135 NavigationEntry* entry1 = controller().GetLastCommittedEntry();
1136 SiteInstance* instance1 = contents()->GetSiteInstance(); 1136 SiteInstance* instance1 = contents()->GetSiteInstance();
1137 1137
1138 EXPECT_FALSE(contents()->CrossProcessNavigationPending()); 1138 EXPECT_FALSE(contents()->CrossProcessNavigationPending());
1139 EXPECT_EQ(webui_rfh, main_test_rfh()); 1139 EXPECT_EQ(webui_rfh, main_test_rfh());
1140 EXPECT_EQ(url1, entry1->GetURL()); 1140 EXPECT_EQ(url1, entry1->GetURL());
1141 EXPECT_EQ(instance1, 1141 EXPECT_EQ(instance1,
1142 NavigationEntryImpl::FromNavigationEntry(entry1)->site_instance()); 1142 NavigationEntryImpl::FromNavigationEntry(entry1)->site_instance());
1143 EXPECT_TRUE(webui_rfh->GetRenderViewHost()->GetEnabledBindings() & 1143 EXPECT_TRUE(webui_rfh->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI);
1144 BINDINGS_POLICY_WEB_UI);
1145 1144
1146 // Navigate to new site. 1145 // Navigate to new site.
1147 const GURL url2("http://www.google.com"); 1146 const GURL url2("http://www.google.com");
1148 controller().LoadURL( 1147 controller().LoadURL(
1149 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); 1148 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
1150 entry_id = controller().GetPendingEntry()->GetUniqueID(); 1149 entry_id = controller().GetPendingEntry()->GetUniqueID();
1151 EXPECT_TRUE(contents()->CrossProcessNavigationPending()); 1150 EXPECT_TRUE(contents()->CrossProcessNavigationPending());
1152 TestRenderFrameHost* google_rfh = contents()->GetPendingMainFrame(); 1151 TestRenderFrameHost* google_rfh = contents()->GetPendingMainFrame();
1153 1152
1154 // Simulate beforeunload approval. 1153 // Simulate beforeunload approval.
1155 EXPECT_TRUE(webui_rfh->is_waiting_for_beforeunload_ack()); 1154 EXPECT_TRUE(webui_rfh->is_waiting_for_beforeunload_ack());
1156 webui_rfh->PrepareForCommit(); 1155 webui_rfh->PrepareForCommit();
1157 1156
1158 // DidNavigate from the pending page. 1157 // DidNavigate from the pending page.
1159 contents()->TestDidNavigate(google_rfh, entry_id, true, url2, 1158 contents()->TestDidNavigate(google_rfh, entry_id, true, url2,
1160 ui::PAGE_TRANSITION_TYPED); 1159 ui::PAGE_TRANSITION_TYPED);
1161 NavigationEntry* entry2 = controller().GetLastCommittedEntry(); 1160 NavigationEntry* entry2 = controller().GetLastCommittedEntry();
1162 SiteInstance* instance2 = contents()->GetSiteInstance(); 1161 SiteInstance* instance2 = contents()->GetSiteInstance();
1163 1162
1164 EXPECT_FALSE(contents()->CrossProcessNavigationPending()); 1163 EXPECT_FALSE(contents()->CrossProcessNavigationPending());
1165 EXPECT_EQ(google_rfh, main_test_rfh()); 1164 EXPECT_EQ(google_rfh, main_test_rfh());
1166 EXPECT_NE(instance1, instance2); 1165 EXPECT_NE(instance1, instance2);
1167 EXPECT_FALSE(contents()->GetPendingMainFrame()); 1166 EXPECT_FALSE(contents()->GetPendingMainFrame());
1168 EXPECT_EQ(url2, entry2->GetURL()); 1167 EXPECT_EQ(url2, entry2->GetURL());
1169 EXPECT_EQ(instance2, 1168 EXPECT_EQ(instance2,
1170 NavigationEntryImpl::FromNavigationEntry(entry2)->site_instance()); 1169 NavigationEntryImpl::FromNavigationEntry(entry2)->site_instance());
1171 EXPECT_FALSE(google_rfh->GetRenderViewHost()->GetEnabledBindings() & 1170 EXPECT_FALSE(google_rfh->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI);
1172 BINDINGS_POLICY_WEB_UI);
1173 1171
1174 // Navigate to third page on same site. 1172 // Navigate to third page on same site.
1175 const GURL url3("http://news.google.com"); 1173 const GURL url3("http://news.google.com");
1176 controller().LoadURL( 1174 controller().LoadURL(
1177 url3, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); 1175 url3, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
1178 entry_id = controller().GetPendingEntry()->GetUniqueID(); 1176 entry_id = controller().GetPendingEntry()->GetUniqueID();
1179 EXPECT_FALSE(contents()->CrossProcessNavigationPending()); 1177 EXPECT_FALSE(contents()->CrossProcessNavigationPending());
1180 main_test_rfh()->PrepareForCommit(); 1178 main_test_rfh()->PrepareForCommit();
1181 contents()->TestDidNavigate(google_rfh, entry_id, true, url3, 1179 contents()->TestDidNavigate(google_rfh, entry_id, true, url3,
1182 ui::PAGE_TRANSITION_TYPED); 1180 ui::PAGE_TRANSITION_TYPED);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1244 contents()->TestDidNavigate(webui_rfh, entry_id, true, url1, 1242 contents()->TestDidNavigate(webui_rfh, entry_id, true, url1,
1245 ui::PAGE_TRANSITION_TYPED); 1243 ui::PAGE_TRANSITION_TYPED);
1246 NavigationEntry* entry1 = controller().GetLastCommittedEntry(); 1244 NavigationEntry* entry1 = controller().GetLastCommittedEntry();
1247 SiteInstance* instance1 = contents()->GetSiteInstance(); 1245 SiteInstance* instance1 = contents()->GetSiteInstance();
1248 1246
1249 EXPECT_FALSE(contents()->CrossProcessNavigationPending()); 1247 EXPECT_FALSE(contents()->CrossProcessNavigationPending());
1250 EXPECT_EQ(webui_rfh, main_test_rfh()); 1248 EXPECT_EQ(webui_rfh, main_test_rfh());
1251 EXPECT_EQ(url1, entry1->GetURL()); 1249 EXPECT_EQ(url1, entry1->GetURL());
1252 EXPECT_EQ(instance1, 1250 EXPECT_EQ(instance1,
1253 NavigationEntryImpl::FromNavigationEntry(entry1)->site_instance()); 1251 NavigationEntryImpl::FromNavigationEntry(entry1)->site_instance());
1254 EXPECT_TRUE(webui_rfh->GetRenderViewHost()->GetEnabledBindings() & 1252 EXPECT_TRUE(webui_rfh->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI);
1255 BINDINGS_POLICY_WEB_UI);
1256 1253
1257 // Navigate to new site. 1254 // Navigate to new site.
1258 const GURL url2("http://www.google.com"); 1255 const GURL url2("http://www.google.com");
1259 controller().LoadURL(url2, Referrer(), ui::PAGE_TRANSITION_TYPED, 1256 controller().LoadURL(url2, Referrer(), ui::PAGE_TRANSITION_TYPED,
1260 std::string()); 1257 std::string());
1261 entry_id = controller().GetPendingEntry()->GetUniqueID(); 1258 entry_id = controller().GetPendingEntry()->GetUniqueID();
1262 EXPECT_TRUE(contents()->CrossProcessNavigationPending()); 1259 EXPECT_TRUE(contents()->CrossProcessNavigationPending());
1263 TestRenderFrameHost* google_rfh = contents()->GetPendingMainFrame(); 1260 TestRenderFrameHost* google_rfh = contents()->GetPendingMainFrame();
1264 1261
1265 // Simulate beforeunload approval. 1262 // Simulate beforeunload approval.
1266 EXPECT_TRUE(webui_rfh->is_waiting_for_beforeunload_ack()); 1263 EXPECT_TRUE(webui_rfh->is_waiting_for_beforeunload_ack());
1267 webui_rfh->PrepareForCommit(); 1264 webui_rfh->PrepareForCommit();
1268 1265
1269 // DidNavigate from the pending page. 1266 // DidNavigate from the pending page.
1270 contents()->TestDidNavigate(google_rfh, entry_id, true, url2, 1267 contents()->TestDidNavigate(google_rfh, entry_id, true, url2,
1271 ui::PAGE_TRANSITION_TYPED); 1268 ui::PAGE_TRANSITION_TYPED);
1272 NavigationEntry* entry2 = controller().GetLastCommittedEntry(); 1269 NavigationEntry* entry2 = controller().GetLastCommittedEntry();
1273 SiteInstance* instance2 = contents()->GetSiteInstance(); 1270 SiteInstance* instance2 = contents()->GetSiteInstance();
1274 1271
1275 EXPECT_FALSE(contents()->CrossProcessNavigationPending()); 1272 EXPECT_FALSE(contents()->CrossProcessNavigationPending());
1276 EXPECT_EQ(google_rfh, main_test_rfh()); 1273 EXPECT_EQ(google_rfh, main_test_rfh());
1277 EXPECT_NE(instance1, instance2); 1274 EXPECT_NE(instance1, instance2);
1278 EXPECT_FALSE(contents()->GetPendingMainFrame()); 1275 EXPECT_FALSE(contents()->GetPendingMainFrame());
1279 EXPECT_EQ(url2, entry2->GetURL()); 1276 EXPECT_EQ(url2, entry2->GetURL());
1280 EXPECT_EQ(instance2, 1277 EXPECT_EQ(instance2,
1281 NavigationEntryImpl::FromNavigationEntry(entry2)->site_instance()); 1278 NavigationEntryImpl::FromNavigationEntry(entry2)->site_instance());
1282 EXPECT_FALSE(google_rfh->GetRenderViewHost()->GetEnabledBindings() & 1279 EXPECT_FALSE(google_rfh->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI);
1283 BINDINGS_POLICY_WEB_UI);
1284 1280
1285 // Navigate to third page on same site. 1281 // Navigate to third page on same site.
1286 const GURL url3("http://news.google.com"); 1282 const GURL url3("http://news.google.com");
1287 controller().LoadURL(url3, Referrer(), ui::PAGE_TRANSITION_TYPED, 1283 controller().LoadURL(url3, Referrer(), ui::PAGE_TRANSITION_TYPED,
1288 std::string()); 1284 std::string());
1289 entry_id = controller().GetPendingEntry()->GetUniqueID(); 1285 entry_id = controller().GetPendingEntry()->GetUniqueID();
1290 EXPECT_FALSE(contents()->CrossProcessNavigationPending()); 1286 EXPECT_FALSE(contents()->CrossProcessNavigationPending());
1291 main_test_rfh()->PrepareForCommit(); 1287 main_test_rfh()->PrepareForCommit();
1292 contents()->TestDidNavigate(google_rfh, entry_id, true, url3, 1288 contents()->TestDidNavigate(google_rfh, entry_id, true, url3,
1293 ui::PAGE_TRANSITION_TYPED); 1289 ui::PAGE_TRANSITION_TYPED);
(...skipping 2120 matching lines...) Expand 10 before | Expand all | Expand 10 after
3414 // An automatic navigation. 3410 // An automatic navigation.
3415 main_test_rfh()->SendNavigateWithModificationCallback( 3411 main_test_rfh()->SendNavigateWithModificationCallback(
3416 0, true, GURL(url::kAboutBlankURL), base::Bind(SetAsNonUserGesture)); 3412 0, true, GURL(url::kAboutBlankURL), base::Bind(SetAsNonUserGesture));
3417 3413
3418 EXPECT_EQ(1u, dialog_manager.reset_count()); 3414 EXPECT_EQ(1u, dialog_manager.reset_count());
3419 3415
3420 contents()->SetJavaScriptDialogManagerForTesting(nullptr); 3416 contents()->SetJavaScriptDialogManagerForTesting(nullptr);
3421 } 3417 }
3422 3418
3423 } // namespace content 3419 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698