| 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/ui/browser.h" | 6 #include "chrome/browser/ui/browser.h" |
| 7 #include "chrome/browser/ui/browser_tabstrip.h" | 7 #include "chrome/browser/ui/browser_tabstrip.h" |
| 8 #include "chrome/test/base/ui_test_utils.h" | 8 #include "chrome/test/base/ui_test_utils.h" |
| 9 #include "content/public/test/browser_test_utils.h" | 9 #include "content/public/test/browser_test_utils.h" |
| 10 | 10 |
| 11 // Tests that we can load extension pages into the tab area and they can call | 11 // Tests that we can load extension pages into the tab area and they can call |
| 12 // extension APIs. | 12 // extension APIs. |
| 13 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, WebContents) { | 13 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, WebContents) { |
| 14 ASSERT_TRUE(LoadExtension( | 14 ASSERT_TRUE(LoadExtension( |
| 15 test_data_dir_.AppendASCII("good").AppendASCII("Extensions") | 15 test_data_dir_.AppendASCII("good").AppendASCII("Extensions") |
| 16 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") | 16 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") |
| 17 .AppendASCII("1.0.0.0"))); | 17 .AppendASCII("1.0.0.0"))); |
| 18 | 18 |
| 19 ui_test_utils::NavigateToURL( | 19 ui_test_utils::NavigateToURL( |
| 20 browser(), | 20 browser(), |
| 21 GURL("chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/page.html")); | 21 GURL("chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/page.html")); |
| 22 | 22 |
| 23 bool result = false; | 23 bool result = false; |
| 24 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( | 24 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( |
| 25 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), | 25 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), L"", |
| 26 "", | 26 L"testTabsAPI()", &result)); |
| 27 "testTabsAPI()", | |
| 28 &result)); | |
| 29 EXPECT_TRUE(result); | 27 EXPECT_TRUE(result); |
| 30 | 28 |
| 31 // There was a bug where we would crash if we navigated to a page in the same | 29 // There was a bug where we would crash if we navigated to a page in the same |
| 32 // extension because no new render view was getting created, so we would not | 30 // extension because no new render view was getting created, so we would not |
| 33 // do some setup. | 31 // do some setup. |
| 34 ui_test_utils::NavigateToURL( | 32 ui_test_utils::NavigateToURL( |
| 35 browser(), | 33 browser(), |
| 36 GURL("chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/page.html")); | 34 GURL("chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/page.html")); |
| 37 result = false; | 35 result = false; |
| 38 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( | 36 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( |
| 39 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), | 37 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), L"", |
| 40 "", | 38 L"testTabsAPI()", &result)); |
| 41 "testTabsAPI()", | |
| 42 &result)); | |
| 43 EXPECT_TRUE(result); | 39 EXPECT_TRUE(result); |
| 44 } | 40 } |
| OLD | NEW |