OLD | NEW |
1 // Copyright (c) 2011 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_list.h" | 10 #include "chrome/browser/ui/browser_finder.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 "googleurl/src/gurl.h" | 14 #include "googleurl/src/gurl.h" |
15 #include "net/base/mock_host_resolver.h" | 15 #include "net/base/mock_host_resolver.h" |
16 | 16 |
17 class ExtensionIconSourceTest : public ExtensionApiTest { | 17 class ExtensionIconSourceTest : public ExtensionApiTest { |
18 protected: | 18 protected: |
19 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 19 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
20 ExtensionApiTest::SetUpCommandLine(command_line); | 20 ExtensionApiTest::SetUpCommandLine(command_line); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 basedir.AppendASCII("extension_with_permission"))); | 57 basedir.AppendASCII("extension_with_permission"))); |
58 ASSERT_TRUE(LoadExtensionIncognito( | 58 ASSERT_TRUE(LoadExtensionIncognito( |
59 basedir.AppendASCII("extension_no_permission"))); | 59 basedir.AppendASCII("extension_no_permission"))); |
60 std::string result; | 60 std::string result; |
61 | 61 |
62 // Test that the icons are loaded and that the chrome://extension-icon | 62 // Test that the icons are loaded and that the chrome://extension-icon |
63 // parameters work correctly. | 63 // parameters work correctly. |
64 ui_test_utils::OpenURLOffTheRecord( | 64 ui_test_utils::OpenURLOffTheRecord( |
65 browser()->profile(), | 65 browser()->profile(), |
66 GURL("chrome-extension://gbmgkahjioeacddebbnengilkgbkhodg/index.html")); | 66 GURL("chrome-extension://gbmgkahjioeacddebbnengilkgbkhodg/index.html")); |
67 Browser* otr_browser = BrowserList::FindTabbedBrowser( | 67 Browser* otr_browser = browser::FindTabbedBrowser( |
68 browser()->profile()->GetOffTheRecordProfile(), false); | 68 browser()->profile()->GetOffTheRecordProfile(), false); |
69 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractString( | 69 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractString( |
70 otr_browser->GetSelectedWebContents()->GetRenderViewHost(), L"", | 70 otr_browser->GetSelectedWebContents()->GetRenderViewHost(), L"", |
71 L"window.domAutomationController.send(document.title)", | 71 L"window.domAutomationController.send(document.title)", |
72 &result)); | 72 &result)); |
73 EXPECT_EQ(result, "Loaded"); | 73 EXPECT_EQ(result, "Loaded"); |
74 | 74 |
75 // Verify that the an extension can't load chrome://extension-icon icons | 75 // Verify that the an extension can't load chrome://extension-icon icons |
76 // without the management permission. | 76 // without the management permission. |
77 ui_test_utils::OpenURLOffTheRecord( | 77 ui_test_utils::OpenURLOffTheRecord( |
78 browser()->profile(), | 78 browser()->profile(), |
79 GURL("chrome-extension://apocjbpjpkghdepdngjlknfpmabcmlao/index.html")); | 79 GURL("chrome-extension://apocjbpjpkghdepdngjlknfpmabcmlao/index.html")); |
80 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractString( | 80 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractString( |
81 otr_browser->GetSelectedWebContents()->GetRenderViewHost(), L"", | 81 otr_browser->GetSelectedWebContents()->GetRenderViewHost(), L"", |
82 L"window.domAutomationController.send(document.title)", | 82 L"window.domAutomationController.send(document.title)", |
83 &result)); | 83 &result)); |
84 EXPECT_EQ(result, "Not Loaded"); | 84 EXPECT_EQ(result, "Not Loaded"); |
85 } | 85 } |
OLD | NEW |