| 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/browser_tabstrip.h" | 10 #include "chrome/browser/ui/browser_tabstrip.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 ASSERT_TRUE(LoadExtension(basedir.AppendASCII("extension_with_permission"))); | 28 ASSERT_TRUE(LoadExtension(basedir.AppendASCII("extension_with_permission"))); |
| 29 ASSERT_TRUE(LoadExtension(basedir.AppendASCII("extension_no_permission"))); | 29 ASSERT_TRUE(LoadExtension(basedir.AppendASCII("extension_no_permission"))); |
| 30 std::string result; | 30 std::string result; |
| 31 | 31 |
| 32 // Test that the icons are loaded and that the chrome://extension-icon | 32 // Test that the icons are loaded and that the chrome://extension-icon |
| 33 // parameters work correctly. | 33 // parameters work correctly. |
| 34 ui_test_utils::NavigateToURL( | 34 ui_test_utils::NavigateToURL( |
| 35 browser(), | 35 browser(), |
| 36 GURL("chrome-extension://gbmgkahjioeacddebbnengilkgbkhodg/index.html")); | 36 GURL("chrome-extension://gbmgkahjioeacddebbnengilkgbkhodg/index.html")); |
| 37 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractString( | 37 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractString( |
| 38 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), | 38 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), L"", |
| 39 "", | 39 L"window.domAutomationController.send(document.title)", |
| 40 "window.domAutomationController.send(document.title)", | |
| 41 &result)); | 40 &result)); |
| 42 EXPECT_EQ(result, "Loaded"); | 41 EXPECT_EQ(result, "Loaded"); |
| 43 | 42 |
| 44 // Verify that the an extension can't load chrome://extension-icon icons | 43 // Verify that the an extension can't load chrome://extension-icon icons |
| 45 // without the management permission. | 44 // without the management permission. |
| 46 ui_test_utils::NavigateToURL( | 45 ui_test_utils::NavigateToURL( |
| 47 browser(), | 46 browser(), |
| 48 GURL("chrome-extension://apocjbpjpkghdepdngjlknfpmabcmlao/index.html")); | 47 GURL("chrome-extension://apocjbpjpkghdepdngjlknfpmabcmlao/index.html")); |
| 49 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractString( | 48 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractString( |
| 50 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), | 49 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), L"", |
| 51 "", | 50 L"window.domAutomationController.send(document.title)", |
| 52 "window.domAutomationController.send(document.title)", | |
| 53 &result)); | 51 &result)); |
| 54 EXPECT_EQ(result, "Not Loaded"); | 52 EXPECT_EQ(result, "Not Loaded"); |
| 55 } | 53 } |
| 56 | 54 |
| 57 IN_PROC_BROWSER_TEST_F(ExtensionIconSourceTest, IconsLoadedIncognito) { | 55 IN_PROC_BROWSER_TEST_F(ExtensionIconSourceTest, IconsLoadedIncognito) { |
| 58 FilePath basedir = test_data_dir_.AppendASCII("icons"); | 56 FilePath basedir = test_data_dir_.AppendASCII("icons"); |
| 59 ASSERT_TRUE(LoadExtensionIncognito( | 57 ASSERT_TRUE(LoadExtensionIncognito( |
| 60 basedir.AppendASCII("extension_with_permission"))); | 58 basedir.AppendASCII("extension_with_permission"))); |
| 61 ASSERT_TRUE(LoadExtensionIncognito( | 59 ASSERT_TRUE(LoadExtensionIncognito( |
| 62 basedir.AppendASCII("extension_no_permission"))); | 60 basedir.AppendASCII("extension_no_permission"))); |
| 63 std::string result; | 61 std::string result; |
| 64 | 62 |
| 65 // Test that the icons are loaded and that the chrome://extension-icon | 63 // Test that the icons are loaded and that the chrome://extension-icon |
| 66 // parameters work correctly. | 64 // parameters work correctly. |
| 67 Browser* otr_browser = ui_test_utils::OpenURLOffTheRecord( | 65 Browser* otr_browser = ui_test_utils::OpenURLOffTheRecord( |
| 68 browser()->profile(), | 66 browser()->profile(), |
| 69 GURL("chrome-extension://gbmgkahjioeacddebbnengilkgbkhodg/index.html")); | 67 GURL("chrome-extension://gbmgkahjioeacddebbnengilkgbkhodg/index.html")); |
| 70 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractString( | 68 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractString( |
| 71 chrome::GetActiveWebContents(otr_browser)->GetRenderViewHost(), | 69 chrome::GetActiveWebContents(otr_browser)->GetRenderViewHost(), L"", |
| 72 "", | 70 L"window.domAutomationController.send(document.title)", |
| 73 "window.domAutomationController.send(document.title)", | |
| 74 &result)); | 71 &result)); |
| 75 EXPECT_EQ(result, "Loaded"); | 72 EXPECT_EQ(result, "Loaded"); |
| 76 | 73 |
| 77 // Verify that the an extension can't load chrome://extension-icon icons | 74 // Verify that the an extension can't load chrome://extension-icon icons |
| 78 // without the management permission. | 75 // without the management permission. |
| 79 ui_test_utils::OpenURLOffTheRecord( | 76 ui_test_utils::OpenURLOffTheRecord( |
| 80 browser()->profile(), | 77 browser()->profile(), |
| 81 GURL("chrome-extension://apocjbpjpkghdepdngjlknfpmabcmlao/index.html")); | 78 GURL("chrome-extension://apocjbpjpkghdepdngjlknfpmabcmlao/index.html")); |
| 82 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractString( | 79 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractString( |
| 83 chrome::GetActiveWebContents(otr_browser)->GetRenderViewHost(), | 80 chrome::GetActiveWebContents(otr_browser)->GetRenderViewHost(), L"", |
| 84 "", | 81 L"window.domAutomationController.send(document.title)", |
| 85 "window.domAutomationController.send(document.title)", | |
| 86 &result)); | 82 &result)); |
| 87 EXPECT_EQ(result, "Not Loaded"); | 83 EXPECT_EQ(result, "Not Loaded"); |
| 88 } | 84 } |
| OLD | NEW |