| OLD | NEW |
| 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/logging.h" | 5 #include "base/logging.h" |
| 6 #include "chrome/browser/extensions/extension_apitest.h" | 6 #include "chrome/browser/extensions/extension_apitest.h" |
| 7 #include "chrome/browser/extensions/extension_service.h" | 7 #include "chrome/browser/extensions/extension_service.h" |
| 8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
| 10 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 10 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 11 #include "chrome/common/chrome_switches.h" | 11 #include "chrome/common/chrome_switches.h" |
| 12 #include "chrome/test/base/ui_test_utils.h" | 12 #include "chrome/test/base/ui_test_utils.h" |
| 13 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
| 14 #include "content/public/test/browser_test_utils.h" | 14 #include "content/public/test/browser_test_utils.h" |
| 15 #include "googleurl/src/gurl.h" | 15 #include "googleurl/src/gurl.h" |
| 16 #include "net/dns/mock_host_resolver.h" | 16 #include "net/dns/mock_host_resolver.h" |
| 17 | 17 |
| 18 class ExtensionIconSourceTest : public ExtensionApiTest { | 18 class ExtensionIconSourceTest : public ExtensionApiTest { |
| 19 protected: | 19 protected: |
| 20 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 20 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 21 ExtensionApiTest::SetUpCommandLine(command_line); | 21 ExtensionApiTest::SetUpCommandLine(command_line); |
| 22 command_line->AppendSwitch(switches::kAllowLegacyExtensionManifests); | 22 command_line->AppendSwitch(switches::kAllowLegacyExtensionManifests); |
| 23 } | 23 } |
| 24 }; | 24 }; |
| 25 | 25 |
| 26 IN_PROC_BROWSER_TEST_F(ExtensionIconSourceTest, IconsLoaded) { | 26 // Times out on Mac and Win. http://crbug.com/238705 |
| 27 #if defined(OS_WIN) || defined(OS_MACOSX) |
| 28 #define MAYBE_IconsLoaded DISABLED_IconsLoaded |
| 29 #else |
| 30 #define MAYBE_IconsLoaded IconsLoaded |
| 31 #endif |
| 32 |
| 33 IN_PROC_BROWSER_TEST_F(ExtensionIconSourceTest, MAYBE_IconsLoaded) { |
| 27 base::FilePath basedir = test_data_dir_.AppendASCII("icons"); | 34 base::FilePath basedir = test_data_dir_.AppendASCII("icons"); |
| 28 ASSERT_TRUE(LoadExtension(basedir.AppendASCII("extension_with_permission"))); | 35 ASSERT_TRUE(LoadExtension(basedir.AppendASCII("extension_with_permission"))); |
| 29 ASSERT_TRUE(LoadExtension(basedir.AppendASCII("extension_no_permission"))); | 36 ASSERT_TRUE(LoadExtension(basedir.AppendASCII("extension_no_permission"))); |
| 30 std::string result; | 37 std::string result; |
| 31 | 38 |
| 32 // Test that the icons are loaded and that the chrome://extension-icon | 39 // Test that the icons are loaded and that the chrome://extension-icon |
| 33 // parameters work correctly. | 40 // parameters work correctly. |
| 34 ui_test_utils::NavigateToURL( | 41 ui_test_utils::NavigateToURL( |
| 35 browser(), | 42 browser(), |
| 36 GURL("chrome-extension://gbmgkahjioeacddebbnengilkgbkhodg/index.html")); | 43 GURL("chrome-extension://gbmgkahjioeacddebbnengilkgbkhodg/index.html")); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 60 browser(), | 67 browser(), |
| 61 GURL("chrome://extension-icon/invalid")); | 68 GURL("chrome://extension-icon/invalid")); |
| 62 | 69 |
| 63 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | 70 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
| 64 browser()->tab_strip_model()->GetActiveWebContents(), | 71 browser()->tab_strip_model()->GetActiveWebContents(), |
| 65 "window.domAutomationController.send(document.title)", | 72 "window.domAutomationController.send(document.title)", |
| 66 &result)); | 73 &result)); |
| 67 EXPECT_EQ(result, "invalid (96\xC3\x97""96)"); | 74 EXPECT_EQ(result, "invalid (96\xC3\x97""96)"); |
| 68 } | 75 } |
| 69 | 76 |
| 70 IN_PROC_BROWSER_TEST_F(ExtensionIconSourceTest, IconsLoadedIncognito) { | 77 // Times out on Mac and Win. http://crbug.com/238705 |
| 78 #if defined(OS_WIN) || defined(OS_MACOSX) |
| 79 #define MAYBE_IconsLoadedIncognito DISABLED_IconsLoadedIncognito |
| 80 #else |
| 81 #define MAYBE_IconsLoadedIncognito IconsLoadedIncognito |
| 82 #endif |
| 83 |
| 84 IN_PROC_BROWSER_TEST_F(ExtensionIconSourceTest, MAYBE_IconsLoadedIncognito) { |
| 71 base::FilePath basedir = test_data_dir_.AppendASCII("icons"); | 85 base::FilePath basedir = test_data_dir_.AppendASCII("icons"); |
| 72 ASSERT_TRUE(LoadExtensionIncognito( | 86 ASSERT_TRUE(LoadExtensionIncognito( |
| 73 basedir.AppendASCII("extension_with_permission"))); | 87 basedir.AppendASCII("extension_with_permission"))); |
| 74 ASSERT_TRUE(LoadExtensionIncognito( | 88 ASSERT_TRUE(LoadExtensionIncognito( |
| 75 basedir.AppendASCII("extension_no_permission"))); | 89 basedir.AppendASCII("extension_no_permission"))); |
| 76 std::string result; | 90 std::string result; |
| 77 | 91 |
| 78 // Test that the icons are loaded and that the chrome://extension-icon | 92 // Test that the icons are loaded and that the chrome://extension-icon |
| 79 // parameters work correctly. | 93 // parameters work correctly. |
| 80 Browser* otr_browser = ui_test_utils::OpenURLOffTheRecord( | 94 Browser* otr_browser = ui_test_utils::OpenURLOffTheRecord( |
| 81 browser()->profile(), | 95 browser()->profile(), |
| 82 GURL("chrome-extension://gbmgkahjioeacddebbnengilkgbkhodg/index.html")); | 96 GURL("chrome-extension://gbmgkahjioeacddebbnengilkgbkhodg/index.html")); |
| 83 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | 97 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
| 84 otr_browser->tab_strip_model()->GetActiveWebContents(), | 98 otr_browser->tab_strip_model()->GetActiveWebContents(), |
| 85 "window.domAutomationController.send(document.title)", | 99 "window.domAutomationController.send(document.title)", |
| 86 &result)); | 100 &result)); |
| 87 EXPECT_EQ(result, "Loaded"); | 101 EXPECT_EQ(result, "Loaded"); |
| 88 | 102 |
| 89 // Verify that the an extension can't load chrome://extension-icon icons | 103 // Verify that the an extension can't load chrome://extension-icon icons |
| 90 // without the management permission. | 104 // without the management permission. |
| 91 ui_test_utils::OpenURLOffTheRecord( | 105 ui_test_utils::OpenURLOffTheRecord( |
| 92 browser()->profile(), | 106 browser()->profile(), |
| 93 GURL("chrome-extension://apocjbpjpkghdepdngjlknfpmabcmlao/index.html")); | 107 GURL("chrome-extension://apocjbpjpkghdepdngjlknfpmabcmlao/index.html")); |
| 94 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | 108 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
| 95 otr_browser->tab_strip_model()->GetActiveWebContents(), | 109 otr_browser->tab_strip_model()->GetActiveWebContents(), |
| 96 "window.domAutomationController.send(document.title)", | 110 "window.domAutomationController.send(document.title)", |
| 97 &result)); | 111 &result)); |
| 98 EXPECT_EQ(result, "Not Loaded"); | 112 EXPECT_EQ(result, "Not Loaded"); |
| 99 } | 113 } |
| OLD | NEW |