| 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 "chrome/browser/extensions/extension_browsertest.h" | 5 #include "chrome/browser/extensions/extension_browsertest.h" |
| 6 #include "chrome/browser/extensions/extension_service.h" | 6 #include "chrome/browser/extensions/extension_service.h" |
| 7 #include "chrome/browser/ui/browser.h" | 7 #include "chrome/browser/ui/browser.h" |
| 8 #include "chrome/browser/ui/browser_tabstrip.h" | 8 #include "chrome/browser/ui/browser_tabstrip.h" |
| 9 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 9 #include "chrome/browser/ui/tab_contents/tab_contents.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/extensions/extension.h" | 11 #include "chrome/common/extensions/extension.h" |
| 12 #include "chrome/common/url_constants.h" | 12 #include "chrome/common/url_constants.h" |
| 13 #include "chrome/test/base/ui_test_utils.h" | 13 #include "chrome/test/base/ui_test_utils.h" |
| 14 #include "content/public/test/browser_test_utils.h" |
| 14 | 15 |
| 15 using extensions::Extension; | 16 using extensions::Extension; |
| 16 | 17 |
| 17 // Used to simulate a click on the first button named 'Options'. | 18 // Used to simulate a click on the first button named 'Options'. |
| 18 static const wchar_t* jscript_click_option_button = | 19 static const wchar_t* jscript_click_option_button = |
| 19 L"(function() { " | 20 L"(function() { " |
| 20 L" var button = document.evaluate(\"//button[text()='Options']\"," | 21 L" var button = document.evaluate(\"//button[text()='Options']\"," |
| 21 L" document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE," | 22 L" document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE," |
| 22 L" null).snapshotItem(0);" | 23 L" null).snapshotItem(0);" |
| 23 L" button.click();" | 24 L" button.click();" |
| 24 L"})();"; | 25 L"})();"; |
| 25 | 26 |
| 26 // Test that an extension with an options page makes an 'Options' button appear | 27 // Test that an extension with an options page makes an 'Options' button appear |
| 27 // on chrome://extensions, and that clicking the button opens a new tab with the | 28 // on chrome://extensions, and that clicking the button opens a new tab with the |
| 28 // extension's options page. | 29 // extension's options page. |
| 29 // Disabled. See http://crbug.com/26948 for details. | 30 // Disabled. See http://crbug.com/26948 for details. |
| 30 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, DISABLED_OptionsPage) { | 31 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, DISABLED_OptionsPage) { |
| 31 // Install an extension with an options page. | 32 // Install an extension with an options page. |
| 32 const Extension* extension = | 33 const Extension* extension = |
| 33 InstallExtension(test_data_dir_.AppendASCII("options.crx"), 1); | 34 InstallExtension(test_data_dir_.AppendASCII("options.crx"), 1); |
| 34 ASSERT_TRUE(extension); | 35 ASSERT_TRUE(extension); |
| 35 ExtensionService* service = browser()->profile()->GetExtensionService(); | 36 ExtensionService* service = browser()->profile()->GetExtensionService(); |
| 36 ASSERT_EQ(1u, service->extensions()->size()); | 37 ASSERT_EQ(1u, service->extensions()->size()); |
| 37 | 38 |
| 38 // Go to the Extension Settings page and click the Options button. | 39 // Go to the Extension Settings page and click the Options button. |
| 39 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIExtensionsURL)); | 40 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIExtensionsURL)); |
| 40 TabStripModel* tab_strip = browser()->tab_strip_model(); | 41 TabStripModel* tab_strip = browser()->tab_strip_model(); |
| 41 ASSERT_TRUE(ui_test_utils::ExecuteJavaScript( | 42 ASSERT_TRUE(content::ExecuteJavaScript( |
| 42 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), L"", | 43 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), L"", |
| 43 jscript_click_option_button)); | 44 jscript_click_option_button)); |
| 44 | 45 |
| 45 // If the options page hasn't already come up, wait for it. | 46 // If the options page hasn't already come up, wait for it. |
| 46 if (tab_strip->count() == 1) { | 47 if (tab_strip->count() == 1) { |
| 47 ui_test_utils::WaitForNewTab(browser()); | 48 ui_test_utils::WaitForNewTab(browser()); |
| 48 } | 49 } |
| 49 ASSERT_EQ(2, tab_strip->count()); | 50 ASSERT_EQ(2, tab_strip->count()); |
| 50 | 51 |
| 51 EXPECT_EQ(extension->GetResourceURL("options.html"), | 52 EXPECT_EQ(extension->GetResourceURL("options.html"), |
| 52 tab_strip->GetTabContentsAt(1)->web_contents()->GetURL()); | 53 tab_strip->GetTabContentsAt(1)->web_contents()->GetURL()); |
| 53 } | 54 } |
| OLD | NEW |