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

Side by Side Diff: chrome/browser/extensions/window_open_apitest.cc

Issue 301033004: replaced the string 'chrome-extensions://' with constants (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed whitespace before a newline Created 6 years, 6 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/memory/scoped_vector.h" 6 #include "base/memory/scoped_vector.h"
7 #include "base/path_service.h" 7 #include "base/path_service.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "chrome/browser/extensions/extension_apitest.h" 9 #include "chrome/browser/extensions/extension_apitest.h"
10 #include "chrome/browser/extensions/extension_test_message_listener.h" 10 #include "chrome/browser/extensions/extension_test_message_listener.h"
11 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/ui/browser.h" 12 #include "chrome/browser/ui/browser.h"
13 #include "chrome/browser/ui/browser_finder.h" 13 #include "chrome/browser/ui/browser_finder.h"
14 #include "chrome/browser/ui/browser_iterator.h" 14 #include "chrome/browser/ui/browser_iterator.h"
15 #include "chrome/browser/ui/panels/panel_manager.h" 15 #include "chrome/browser/ui/panels/panel_manager.h"
16 #include "chrome/browser/ui/tabs/tab_strip_model.h" 16 #include "chrome/browser/ui/tabs/tab_strip_model.h"
17 #include "chrome/common/chrome_paths.h" 17 #include "chrome/common/chrome_paths.h"
18 #include "chrome/common/chrome_switches.h" 18 #include "chrome/common/chrome_switches.h"
19 #include "chrome/test/base/test_switches.h" 19 #include "chrome/test/base/test_switches.h"
20 #include "chrome/test/base/ui_test_utils.h" 20 #include "chrome/test/base/ui_test_utils.h"
21 #include "content/public/browser/render_process_host.h" 21 #include "content/public/browser/render_process_host.h"
22 #include "content/public/browser/web_contents.h" 22 #include "content/public/browser/web_contents.h"
23 #include "content/public/common/result_codes.h" 23 #include "content/public/common/result_codes.h"
24 #include "content/public/common/url_constants.h"
24 #include "content/public/test/browser_test_utils.h" 25 #include "content/public/test/browser_test_utils.h"
25 #include "extensions/browser/extension_host.h" 26 #include "extensions/browser/extension_host.h"
26 #include "extensions/browser/extension_system.h" 27 #include "extensions/browser/extension_system.h"
27 #include "extensions/browser/process_manager.h" 28 #include "extensions/browser/process_manager.h"
29 #include "extensions/common/constants.h"
28 #include "extensions/common/extension.h" 30 #include "extensions/common/extension.h"
29 #include "extensions/common/switches.h" 31 #include "extensions/common/switches.h"
30 #include "net/dns/mock_host_resolver.h" 32 #include "net/dns/mock_host_resolver.h"
31 #include "net/test/embedded_test_server/embedded_test_server.h" 33 #include "net/test/embedded_test_server/embedded_test_server.h"
32 #include "testing/gtest/include/gtest/gtest.h" 34 #include "testing/gtest/include/gtest/gtest.h"
33 35
34 #if defined(USE_ASH) 36 #if defined(USE_ASH)
35 #include "apps/app_window_registry.h" 37 #include "apps/app_window_registry.h"
36 #endif 38 #endif
37 39
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 ASSERT_TRUE(RunExtensionTest("window_open/window_size")) << message_; 446 ASSERT_TRUE(RunExtensionTest("window_open/window_size")) << message_;
445 EXPECT_TRUE(WaitForTabsAndPopups(browser(), 0, 1, 0)); 447 EXPECT_TRUE(WaitForTabsAndPopups(browser(), 0, 1, 0));
446 } 448 }
447 449
448 // Tests that an extension page can call window.open to an extension URL and 450 // Tests that an extension page can call window.open to an extension URL and
449 // the new window has extension privileges. 451 // the new window has extension privileges.
450 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, WindowOpenExtension) { 452 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, WindowOpenExtension) {
451 ASSERT_TRUE(LoadExtension( 453 ASSERT_TRUE(LoadExtension(
452 test_data_dir_.AppendASCII("uitest").AppendASCII("window_open"))); 454 test_data_dir_.AppendASCII("uitest").AppendASCII("window_open")));
453 455
454 GURL start_url(std::string("chrome-extension://") + 456 GURL start_url(std::string(extensions::kExtensionScheme) +
455 last_loaded_extension_id() + "/test.html"); 457 content::kStandardSchemeSeparator +
458 last_loaded_extension_id() + "/test.html");
456 ui_test_utils::NavigateToURL(browser(), start_url); 459 ui_test_utils::NavigateToURL(browser(), start_url);
457 WebContents* newtab = NULL; 460 WebContents* newtab = NULL;
458 ASSERT_NO_FATAL_FAILURE( 461 ASSERT_NO_FATAL_FAILURE(
459 OpenWindow(browser()->tab_strip_model()->GetActiveWebContents(), 462 OpenWindow(browser()->tab_strip_model()->GetActiveWebContents(),
460 start_url.Resolve("newtab.html"), true, &newtab)); 463 start_url.Resolve("newtab.html"), true, &newtab));
461 464
462 bool result = false; 465 bool result = false;
463 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(newtab, "testExtensionApi()", 466 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(newtab, "testExtensionApi()",
464 &result)); 467 &result));
465 EXPECT_TRUE(result); 468 EXPECT_TRUE(result);
466 } 469 }
467 470
468 // Tests that if an extension page calls window.open to an invalid extension 471 // Tests that if an extension page calls window.open to an invalid extension
469 // URL, the browser doesn't crash. 472 // URL, the browser doesn't crash.
470 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, WindowOpenInvalidExtension) { 473 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, WindowOpenInvalidExtension) {
471 ASSERT_TRUE(LoadExtension( 474 ASSERT_TRUE(LoadExtension(
472 test_data_dir_.AppendASCII("uitest").AppendASCII("window_open"))); 475 test_data_dir_.AppendASCII("uitest").AppendASCII("window_open")));
473 476
474 GURL start_url(std::string("chrome-extension://") + 477 GURL start_url(std::string(extensions::kExtensionScheme) +
475 last_loaded_extension_id() + "/test.html"); 478 content::kStandardSchemeSeparator +
479 last_loaded_extension_id() + "/test.html");
476 ui_test_utils::NavigateToURL(browser(), start_url); 480 ui_test_utils::NavigateToURL(browser(), start_url);
477 ASSERT_NO_FATAL_FAILURE( 481 ASSERT_NO_FATAL_FAILURE(
478 OpenWindow(browser()->tab_strip_model()->GetActiveWebContents(), 482 OpenWindow(browser()->tab_strip_model()->GetActiveWebContents(),
479 GURL("chrome-extension://thisissurelynotavalidextensionid/newtab.html"), 483 GURL("chrome-extension://thisissurelynotavalidextensionid/newtab.html"),
480 false, NULL)); 484 false, NULL));
481 485
482 // If we got to this point, we didn't crash, so we're good. 486 // If we got to this point, we didn't crash, so we're good.
483 } 487 }
484 488
485 // Tests that calling window.open from the newtab page to an extension URL 489 // Tests that calling window.open from the newtab page to an extension URL
486 // gives the new window extension privileges - even though the opening page 490 // gives the new window extension privileges - even though the opening page
487 // does not have extension privileges, we break the script connection, so 491 // does not have extension privileges, we break the script connection, so
488 // there is no privilege leak. 492 // there is no privilege leak.
489 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, WindowOpenNoPrivileges) { 493 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, WindowOpenNoPrivileges) {
490 ASSERT_TRUE(LoadExtension( 494 ASSERT_TRUE(LoadExtension(
491 test_data_dir_.AppendASCII("uitest").AppendASCII("window_open"))); 495 test_data_dir_.AppendASCII("uitest").AppendASCII("window_open")));
492 496
493 ui_test_utils::NavigateToURL(browser(), GURL("about:blank")); 497 ui_test_utils::NavigateToURL(browser(), GURL("about:blank"));
494 WebContents* newtab = NULL; 498 WebContents* newtab = NULL;
495 ASSERT_NO_FATAL_FAILURE( 499 ASSERT_NO_FATAL_FAILURE(
496 OpenWindow(browser()->tab_strip_model()->GetActiveWebContents(), 500 OpenWindow(browser()->tab_strip_model()->GetActiveWebContents(),
497 GURL(std::string("chrome-extension://") + last_loaded_extension_id() + 501 GURL(std::string(extensions::kExtensionScheme) +
498 "/newtab.html"), false, &newtab)); 502 content::kStandardSchemeSeparator +
503 last_loaded_extension_id() + "/newtab.html"),
504 false,
505 &newtab));
499 506
500 // Extension API should succeed. 507 // Extension API should succeed.
501 bool result = false; 508 bool result = false;
502 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(newtab, "testExtensionApi()", 509 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(newtab, "testExtensionApi()",
503 &result)); 510 &result));
504 EXPECT_TRUE(result); 511 EXPECT_TRUE(result);
505 } 512 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/gtalk_extension_browsertest.cc ('k') | extensions/common/csp_validator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698