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

Side by Side Diff: content/browser/renderer_host/render_view_host_manager_browsertest.cc

Issue 14651029: content: Remove usage of NOTIFICATION_WEB_CONTENTS_DESTROYED from content (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
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 "base/file_util.h" 5 #include "base/file_util.h"
6 #include "base/json/json_reader.h" 6 #include "base/json/json_reader.h"
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 // Opens in same window. 307 // Opens in same window.
308 EXPECT_EQ(1u, Shell::windows().size()); 308 EXPECT_EQ(1u, Shell::windows().size());
309 EXPECT_EQ("/files/title2.html", shell()->web_contents()->GetURL().path()); 309 EXPECT_EQ("/files/title2.html", shell()->web_contents()->GetURL().path());
310 310
311 // Should have the same SiteInstance. 311 // Should have the same SiteInstance.
312 scoped_refptr<SiteInstance> noref_site_instance( 312 scoped_refptr<SiteInstance> noref_site_instance(
313 shell()->web_contents()->GetSiteInstance()); 313 shell()->web_contents()->GetSiteInstance());
314 EXPECT_EQ(orig_site_instance, noref_site_instance); 314 EXPECT_EQ(orig_site_instance, noref_site_instance);
315 } 315 }
316 316
317 namespace {
318
319 class WebContentsDestroyedObserver : public WebContentsObserver {
320 public:
321 WebContentsDestroyedObserver(WebContents* web_contents,
322 const base::Closure& callback)
323 : WebContentsObserver(web_contents),
324 callback_(callback) {
325 }
326
327 virtual void WebContentsDestroyed(WebContents* web_contents) OVERRIDE {
328 callback_.Run();
329 }
330
331 private:
332 base::Closure callback_;
333
334 DISALLOW_COPY_AND_ASSIGN(WebContentsDestroyedObserver);
335 };
336
337 } // namespace
338
317 // Test for crbug.com/116192. Targeted links should still work after the 339 // Test for crbug.com/116192. Targeted links should still work after the
318 // named target window has swapped processes. 340 // named target window has swapped processes.
319 IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, 341 IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest,
320 AllowTargetedNavigationsAfterSwap) { 342 AllowTargetedNavigationsAfterSwap) {
321 // Start two servers with different sites. 343 // Start two servers with different sites.
322 ASSERT_TRUE(test_server()->Start()); 344 ASSERT_TRUE(test_server()->Start());
323 net::SpawnedTestServer https_server( 345 net::SpawnedTestServer https_server(
324 net::SpawnedTestServer::TYPE_HTTPS, 346 net::SpawnedTestServer::TYPE_HTTPS,
325 net::SpawnedTestServer::kLocalhost, 347 net::SpawnedTestServer::kLocalhost,
326 base::FilePath(FILE_PATH_LITERAL("content/test/data"))); 348 base::FilePath(FILE_PATH_LITERAL("content/test/data")));
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 // Should have swapped back and shown the new window again. 402 // Should have swapped back and shown the new window again.
381 scoped_refptr<SiteInstance> revisit_site_instance( 403 scoped_refptr<SiteInstance> revisit_site_instance(
382 new_shell->web_contents()->GetSiteInstance()); 404 new_shell->web_contents()->GetSiteInstance());
383 EXPECT_EQ(orig_site_instance, revisit_site_instance); 405 EXPECT_EQ(orig_site_instance, revisit_site_instance);
384 406
385 // If it navigates away to another process, the original window should 407 // If it navigates away to another process, the original window should
386 // still be able to close it (using a cross-process close message). 408 // still be able to close it (using a cross-process close message).
387 NavigateToURL(new_shell, https_server.GetURL("files/title1.html")); 409 NavigateToURL(new_shell, https_server.GetURL("files/title1.html"));
388 EXPECT_EQ(new_site_instance, 410 EXPECT_EQ(new_site_instance,
389 new_shell->web_contents()->GetSiteInstance()); 411 new_shell->web_contents()->GetSiteInstance());
390 WindowedNotificationObserver close_observer( 412 scoped_refptr<MessageLoopRunner> loop_runner(new MessageLoopRunner);
391 NOTIFICATION_WEB_CONTENTS_DESTROYED, 413 WebContentsDestroyedObserver close_observer(new_shell->web_contents(),
392 Source<WebContents>(new_shell->web_contents())); 414 loop_runner->QuitClosure());
393 EXPECT_TRUE(ExecuteScriptAndExtractBool( 415 EXPECT_TRUE(ExecuteScriptAndExtractBool(
394 shell()->web_contents(), 416 shell()->web_contents(),
395 "window.domAutomationController.send(testCloseWindow());", 417 "window.domAutomationController.send(testCloseWindow());",
396 &success)); 418 &success));
397 EXPECT_TRUE(success); 419 EXPECT_TRUE(success);
398 close_observer.Wait(); 420 loop_runner->Run();
399 } 421 }
400 422
401 // Test that setting the opener to null in a window affects cross-process 423 // Test that setting the opener to null in a window affects cross-process
402 // navigations, including those to existing entries. http://crbug.com/156669. 424 // navigations, including those to existing entries. http://crbug.com/156669.
403 IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, DisownOpener) { 425 IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, DisownOpener) {
404 // Start two servers with different sites. 426 // Start two servers with different sites.
405 ASSERT_TRUE(test_server()->Start()); 427 ASSERT_TRUE(test_server()->Start());
406 net::SpawnedTestServer https_server( 428 net::SpawnedTestServer https_server(
407 net::SpawnedTestServer::TYPE_HTTPS, 429 net::SpawnedTestServer::TYPE_HTTPS,
408 net::SpawnedTestServer::kLocalhost, 430 net::SpawnedTestServer::kLocalhost,
(...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after
1200 NavigateToURL(shell(), https_server.GetURL("files/title1.html")); 1222 NavigateToURL(shell(), https_server.GetURL("files/title1.html"));
1201 1223
1202 // Make sure it ends up at the right page. 1224 // Make sure it ends up at the right page.
1203 WaitForLoadStop(shell()->web_contents()); 1225 WaitForLoadStop(shell()->web_contents());
1204 EXPECT_EQ(https_server.GetURL("files/title1.html"), 1226 EXPECT_EQ(https_server.GetURL("files/title1.html"),
1205 shell()->web_contents()->GetURL()); 1227 shell()->web_contents()->GetURL());
1206 EXPECT_EQ(new_site_instance, shell()->web_contents()->GetSiteInstance()); 1228 EXPECT_EQ(new_site_instance, shell()->web_contents()->GetSiteInstance());
1207 } 1229 }
1208 1230
1209 } // namespace content 1231 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/web_contents/interstitial_page_impl.h » ('j') | content/shell/shell.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698