[email protected] | fad7367 | 2012-06-15 23:26:06 | [diff] [blame] | 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 | ||||
3 | // found in the LICENSE file. | ||||
4 | |||||
5 | #include "chrome/browser/extensions/extension_browsertest.h" | ||||
6 | #include "chrome/browser/ui/browser.h" | ||||
[email protected] | 47ae2337 | 2013-01-29 01:50:48 | [diff] [blame] | 7 | #include "chrome/browser/ui/tabs/tab_strip_model.h" |
[email protected] | fad7367 | 2012-06-15 23:26:06 | [diff] [blame] | 8 | #include "chrome/test/base/ui_test_utils.h" |
[email protected] | 7d478cb | 2012-07-24 17:19:42 | [diff] [blame] | 9 | #include "content/public/test/browser_test_utils.h" |
[email protected] | fad7367 | 2012-06-15 23:26:06 | [diff] [blame] | 10 | |
11 | // Tests that we can load extension pages into the tab area and they can call | ||||
12 | // extension APIs. | ||||
13 | IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, WebContents) { | ||||
14 | ASSERT_TRUE(LoadExtension( | ||||
15 | test_data_dir_.AppendASCII("good").AppendASCII("Extensions") | ||||
16 | .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") | ||||
17 | .AppendASCII("1.0.0.0"))); | ||||
18 | |||||
19 | ui_test_utils::NavigateToURL( | ||||
20 | browser(), | ||||
21 | GURL("chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/page.html")); | ||||
22 | |||||
23 | bool result = false; | ||||
[email protected] | b6987e0 | 2013-01-04 18:30:43 | [diff] [blame] | 24 | ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
[email protected] | 47ae2337 | 2013-01-29 01:50:48 | [diff] [blame] | 25 | browser()->tab_strip_model()->GetActiveWebContents(), |
[email protected] | 06bc5d9 | 2013-01-02 22:44:13 | [diff] [blame] | 26 | "testTabsAPI()", |
27 | &result)); | ||||
[email protected] | fad7367 | 2012-06-15 23:26:06 | [diff] [blame] | 28 | EXPECT_TRUE(result); |
29 | |||||
30 | // There was a bug where we would crash if we navigated to a page in the same | ||||
31 | // extension because no new render view was getting created, so we would not | ||||
32 | // do some setup. | ||||
33 | ui_test_utils::NavigateToURL( | ||||
34 | browser(), | ||||
35 | GURL("chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/page.html")); | ||||
36 | result = false; | ||||
[email protected] | b6987e0 | 2013-01-04 18:30:43 | [diff] [blame] | 37 | ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
[email protected] | 47ae2337 | 2013-01-29 01:50:48 | [diff] [blame] | 38 | browser()->tab_strip_model()->GetActiveWebContents(), |
[email protected] | 06bc5d9 | 2013-01-02 22:44:13 | [diff] [blame] | 39 | "testTabsAPI()", |
40 | &result)); | ||||
[email protected] | fad7367 | 2012-06-15 23:26:06 | [diff] [blame] | 41 | EXPECT_TRUE(result); |
42 | } |