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

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 3 years, 11 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 <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 1123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1134 contents()->TestDidNavigate(webui_rfh, entry_id, true, url1, 1134 contents()->TestDidNavigate(webui_rfh, entry_id, true, url1,
1135 ui::PAGE_TRANSITION_TYPED); 1135 ui::PAGE_TRANSITION_TYPED);
1136 NavigationEntry* entry1 = controller().GetLastCommittedEntry(); 1136 NavigationEntry* entry1 = controller().GetLastCommittedEntry();
1137 SiteInstance* instance1 = contents()->GetSiteInstance(); 1137 SiteInstance* instance1 = contents()->GetSiteInstance();
1138 1138
1139 EXPECT_FALSE(contents()->CrossProcessNavigationPending()); 1139 EXPECT_FALSE(contents()->CrossProcessNavigationPending());
1140 EXPECT_EQ(webui_rfh, main_test_rfh()); 1140 EXPECT_EQ(webui_rfh, main_test_rfh());
1141 EXPECT_EQ(url1, entry1->GetURL()); 1141 EXPECT_EQ(url1, entry1->GetURL());
1142 EXPECT_EQ(instance1, 1142 EXPECT_EQ(instance1,
1143 NavigationEntryImpl::FromNavigationEntry(entry1)->site_instance()); 1143 NavigationEntryImpl::FromNavigationEntry(entry1)->site_instance());
1144 EXPECT_TRUE(webui_rfh->GetRenderViewHost()->GetEnabledBindings() & 1144 EXPECT_TRUE(webui_rfh->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI);
1145 BINDINGS_POLICY_WEB_UI);
1146 1145
1147 // Navigate to new site. 1146 // Navigate to new site.
1148 const GURL url2("http://www.google.com"); 1147 const GURL url2("http://www.google.com");
1149 controller().LoadURL( 1148 controller().LoadURL(
1150 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); 1149 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
1151 entry_id = controller().GetPendingEntry()->GetUniqueID(); 1150 entry_id = controller().GetPendingEntry()->GetUniqueID();
1152 EXPECT_TRUE(contents()->CrossProcessNavigationPending()); 1151 EXPECT_TRUE(contents()->CrossProcessNavigationPending());
1153 TestRenderFrameHost* google_rfh = contents()->GetPendingMainFrame(); 1152 TestRenderFrameHost* google_rfh = contents()->GetPendingMainFrame();
1154 1153
1155 // Simulate beforeunload approval. 1154 // Simulate beforeunload approval.
1156 EXPECT_TRUE(webui_rfh->is_waiting_for_beforeunload_ack()); 1155 EXPECT_TRUE(webui_rfh->is_waiting_for_beforeunload_ack());
1157 webui_rfh->PrepareForCommit(); 1156 webui_rfh->PrepareForCommit();
1158 1157
1159 // DidNavigate from the pending page. 1158 // DidNavigate from the pending page.
1160 contents()->TestDidNavigate(google_rfh, entry_id, true, url2, 1159 contents()->TestDidNavigate(google_rfh, entry_id, true, url2,
1161 ui::PAGE_TRANSITION_TYPED); 1160 ui::PAGE_TRANSITION_TYPED);
1162 NavigationEntry* entry2 = controller().GetLastCommittedEntry(); 1161 NavigationEntry* entry2 = controller().GetLastCommittedEntry();
1163 SiteInstance* instance2 = contents()->GetSiteInstance(); 1162 SiteInstance* instance2 = contents()->GetSiteInstance();
1164 1163
1165 EXPECT_FALSE(contents()->CrossProcessNavigationPending()); 1164 EXPECT_FALSE(contents()->CrossProcessNavigationPending());
1166 EXPECT_EQ(google_rfh, main_test_rfh()); 1165 EXPECT_EQ(google_rfh, main_test_rfh());
1167 EXPECT_NE(instance1, instance2); 1166 EXPECT_NE(instance1, instance2);
1168 EXPECT_FALSE(contents()->GetPendingMainFrame()); 1167 EXPECT_FALSE(contents()->GetPendingMainFrame());
1169 EXPECT_EQ(url2, entry2->GetURL()); 1168 EXPECT_EQ(url2, entry2->GetURL());
1170 EXPECT_EQ(instance2, 1169 EXPECT_EQ(instance2,
1171 NavigationEntryImpl::FromNavigationEntry(entry2)->site_instance()); 1170 NavigationEntryImpl::FromNavigationEntry(entry2)->site_instance());
1172 EXPECT_FALSE(google_rfh->GetRenderViewHost()->GetEnabledBindings() & 1171 EXPECT_FALSE(google_rfh->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI);
1173 BINDINGS_POLICY_WEB_UI);
1174 1172
1175 // Navigate to third page on same site. 1173 // Navigate to third page on same site.
1176 const GURL url3("http://news.google.com"); 1174 const GURL url3("http://news.google.com");
1177 controller().LoadURL( 1175 controller().LoadURL(
1178 url3, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); 1176 url3, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
1179 entry_id = controller().GetPendingEntry()->GetUniqueID(); 1177 entry_id = controller().GetPendingEntry()->GetUniqueID();
1180 EXPECT_FALSE(contents()->CrossProcessNavigationPending()); 1178 EXPECT_FALSE(contents()->CrossProcessNavigationPending());
1181 main_test_rfh()->PrepareForCommit(); 1179 main_test_rfh()->PrepareForCommit();
1182 contents()->TestDidNavigate(google_rfh, entry_id, true, url3, 1180 contents()->TestDidNavigate(google_rfh, entry_id, true, url3,
1183 ui::PAGE_TRANSITION_TYPED); 1181 ui::PAGE_TRANSITION_TYPED);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1245 contents()->TestDidNavigate(webui_rfh, entry_id, true, url1, 1243 contents()->TestDidNavigate(webui_rfh, entry_id, true, url1,
1246 ui::PAGE_TRANSITION_TYPED); 1244 ui::PAGE_TRANSITION_TYPED);
1247 NavigationEntry* entry1 = controller().GetLastCommittedEntry(); 1245 NavigationEntry* entry1 = controller().GetLastCommittedEntry();
1248 SiteInstance* instance1 = contents()->GetSiteInstance(); 1246 SiteInstance* instance1 = contents()->GetSiteInstance();
1249 1247
1250 EXPECT_FALSE(contents()->CrossProcessNavigationPending()); 1248 EXPECT_FALSE(contents()->CrossProcessNavigationPending());
1251 EXPECT_EQ(webui_rfh, main_test_rfh()); 1249 EXPECT_EQ(webui_rfh, main_test_rfh());
1252 EXPECT_EQ(url1, entry1->GetURL()); 1250 EXPECT_EQ(url1, entry1->GetURL());
1253 EXPECT_EQ(instance1, 1251 EXPECT_EQ(instance1,
1254 NavigationEntryImpl::FromNavigationEntry(entry1)->site_instance()); 1252 NavigationEntryImpl::FromNavigationEntry(entry1)->site_instance());
1255 EXPECT_TRUE(webui_rfh->GetRenderViewHost()->GetEnabledBindings() & 1253 EXPECT_TRUE(webui_rfh->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI);
1256 BINDINGS_POLICY_WEB_UI);
1257 1254
1258 // Navigate to new site. 1255 // Navigate to new site.
1259 const GURL url2("http://www.google.com"); 1256 const GURL url2("http://www.google.com");
1260 controller().LoadURL(url2, Referrer(), ui::PAGE_TRANSITION_TYPED, 1257 controller().LoadURL(url2, Referrer(), ui::PAGE_TRANSITION_TYPED,
1261 std::string()); 1258 std::string());
1262 entry_id = controller().GetPendingEntry()->GetUniqueID(); 1259 entry_id = controller().GetPendingEntry()->GetUniqueID();
1263 EXPECT_TRUE(contents()->CrossProcessNavigationPending()); 1260 EXPECT_TRUE(contents()->CrossProcessNavigationPending());
1264 TestRenderFrameHost* google_rfh = contents()->GetPendingMainFrame(); 1261 TestRenderFrameHost* google_rfh = contents()->GetPendingMainFrame();
1265 1262
1266 // Simulate beforeunload approval. 1263 // Simulate beforeunload approval.
1267 EXPECT_TRUE(webui_rfh->is_waiting_for_beforeunload_ack()); 1264 EXPECT_TRUE(webui_rfh->is_waiting_for_beforeunload_ack());
1268 webui_rfh->PrepareForCommit(); 1265 webui_rfh->PrepareForCommit();
1269 1266
1270 // DidNavigate from the pending page. 1267 // DidNavigate from the pending page.
1271 contents()->TestDidNavigate(google_rfh, entry_id, true, url2, 1268 contents()->TestDidNavigate(google_rfh, entry_id, true, url2,
1272 ui::PAGE_TRANSITION_TYPED); 1269 ui::PAGE_TRANSITION_TYPED);
1273 NavigationEntry* entry2 = controller().GetLastCommittedEntry(); 1270 NavigationEntry* entry2 = controller().GetLastCommittedEntry();
1274 SiteInstance* instance2 = contents()->GetSiteInstance(); 1271 SiteInstance* instance2 = contents()->GetSiteInstance();
1275 1272
1276 EXPECT_FALSE(contents()->CrossProcessNavigationPending()); 1273 EXPECT_FALSE(contents()->CrossProcessNavigationPending());
1277 EXPECT_EQ(google_rfh, main_test_rfh()); 1274 EXPECT_EQ(google_rfh, main_test_rfh());
1278 EXPECT_NE(instance1, instance2); 1275 EXPECT_NE(instance1, instance2);
1279 EXPECT_FALSE(contents()->GetPendingMainFrame()); 1276 EXPECT_FALSE(contents()->GetPendingMainFrame());
1280 EXPECT_EQ(url2, entry2->GetURL()); 1277 EXPECT_EQ(url2, entry2->GetURL());
1281 EXPECT_EQ(instance2, 1278 EXPECT_EQ(instance2,
1282 NavigationEntryImpl::FromNavigationEntry(entry2)->site_instance()); 1279 NavigationEntryImpl::FromNavigationEntry(entry2)->site_instance());
1283 EXPECT_FALSE(google_rfh->GetRenderViewHost()->GetEnabledBindings() & 1280 EXPECT_FALSE(google_rfh->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI);
1284 BINDINGS_POLICY_WEB_UI);
1285 1281
1286 // Navigate to third page on same site. 1282 // Navigate to third page on same site.
1287 const GURL url3("http://news.google.com"); 1283 const GURL url3("http://news.google.com");
1288 controller().LoadURL(url3, Referrer(), ui::PAGE_TRANSITION_TYPED, 1284 controller().LoadURL(url3, Referrer(), ui::PAGE_TRANSITION_TYPED,
1289 std::string()); 1285 std::string());
1290 entry_id = controller().GetPendingEntry()->GetUniqueID(); 1286 entry_id = controller().GetPendingEntry()->GetUniqueID();
1291 EXPECT_FALSE(contents()->CrossProcessNavigationPending()); 1287 EXPECT_FALSE(contents()->CrossProcessNavigationPending());
1292 main_test_rfh()->PrepareForCommit(); 1288 main_test_rfh()->PrepareForCommit();
1293 contents()->TestDidNavigate(google_rfh, entry_id, true, url3, 1289 contents()->TestDidNavigate(google_rfh, entry_id, true, url3,
1294 ui::PAGE_TRANSITION_TYPED); 1290 ui::PAGE_TRANSITION_TYPED);
(...skipping 2136 matching lines...) Expand 10 before | Expand all | Expand 10 after
3431 // An automatic navigation. 3427 // An automatic navigation.
3432 main_test_rfh()->SendNavigateWithModificationCallback( 3428 main_test_rfh()->SendNavigateWithModificationCallback(
3433 0, true, GURL(url::kAboutBlankURL), base::Bind(SetAsNonUserGesture)); 3429 0, true, GURL(url::kAboutBlankURL), base::Bind(SetAsNonUserGesture));
3434 3430
3435 EXPECT_EQ(1u, dialog_manager.reset_count()); 3431 EXPECT_EQ(1u, dialog_manager.reset_count());
3436 3432
3437 contents()->SetJavaScriptDialogManagerForTesting(nullptr); 3433 contents()->SetJavaScriptDialogManagerForTesting(nullptr);
3438 } 3434 }
3439 3435
3440 } // namespace content 3436 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698