Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Side by Side Diff: chrome/browser/extensions/extension_incognito_apitest.cc

Issue 9015022: Replace most of Browser::GetSelectedTabContents calls into Browser::GetSelectedWebContents. I've ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/browser_action_test_util.h" 5 #include "chrome/browser/extensions/browser_action_test_util.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/extensions/extension_test_message_listener.h" 8 #include "chrome/browser/extensions/extension_test_message_listener.h"
9 #include "chrome/browser/extensions/user_script_master.h" 9 #include "chrome/browser/extensions/user_script_master.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/ui/browser.h" 11 #include "chrome/browser/ui/browser.h"
12 #include "chrome/browser/ui/browser_list.h" 12 #include "chrome/browser/ui/browser_list.h"
13 #include "chrome/browser/ui/browser_window.h" 13 #include "chrome/browser/ui/browser_window.h"
14 #include "chrome/common/url_constants.h" 14 #include "chrome/common/url_constants.h"
15 #include "chrome/test/base/ui_test_utils.h" 15 #include "chrome/test/base/ui_test_utils.h"
16 #include "content/browser/tab_contents/tab_contents.h" 16 #include "content/public/browser/web_contents.h"
17 #include "net/base/mock_host_resolver.h" 17 #include "net/base/mock_host_resolver.h"
18 18
19 using content::WebContents;
20
19 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, IncognitoNoScript) { 21 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, IncognitoNoScript) {
20 ASSERT_TRUE(StartTestServer()); 22 ASSERT_TRUE(StartTestServer());
21 23
22 // Loads a simple extension which attempts to change the title of every page 24 // Loads a simple extension which attempts to change the title of every page
23 // that loads to "modified". 25 // that loads to "modified".
24 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("incognito") 26 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("incognito")
25 .AppendASCII("content_scripts"))); 27 .AppendASCII("content_scripts")));
26 28
27 // Open incognito window and navigate to test page. 29 // Open incognito window and navigate to test page.
28 ui_test_utils::OpenURLOffTheRecord( 30 ui_test_utils::OpenURLOffTheRecord(
29 browser()->profile(), 31 browser()->profile(),
30 test_server()->GetURL("files/extensions/test_file.html")); 32 test_server()->GetURL("files/extensions/test_file.html"));
31 33
32 Browser* otr_browser = BrowserList::FindTabbedBrowser( 34 Browser* otr_browser = BrowserList::FindTabbedBrowser(
33 browser()->profile()->GetOffTheRecordProfile(), false); 35 browser()->profile()->GetOffTheRecordProfile(), false);
34 TabContents* tab = otr_browser->GetSelectedTabContents(); 36 WebContents* tab = otr_browser->GetSelectedWebContents();
35 37
36 // Verify the script didn't run. 38 // Verify the script didn't run.
37 bool result = false; 39 bool result = false;
38 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 40 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
39 tab->GetRenderViewHost(), L"", 41 tab->GetRenderViewHost(), L"",
40 L"window.domAutomationController.send(document.title == 'Unmodified')", 42 L"window.domAutomationController.send(document.title == 'Unmodified')",
41 &result)); 43 &result));
42 EXPECT_TRUE(result); 44 EXPECT_TRUE(result);
43 } 45 }
44 46
(...skipping 16 matching lines...) Expand all
61 ASSERT_TRUE(LoadExtension(test_data_dir_ 63 ASSERT_TRUE(LoadExtension(test_data_dir_
62 .AppendASCII("content_scripts").AppendASCII("isolated_world1"))); 64 .AppendASCII("content_scripts").AppendASCII("isolated_world1")));
63 65
64 // Open incognito window and navigate to test page. 66 // Open incognito window and navigate to test page.
65 ui_test_utils::OpenURLOffTheRecord( 67 ui_test_utils::OpenURLOffTheRecord(
66 browser()->profile(), 68 browser()->profile(),
67 test_server()->GetURL("files/extensions/test_file.html")); 69 test_server()->GetURL("files/extensions/test_file.html"));
68 70
69 Browser* otr_browser = BrowserList::FindTabbedBrowser( 71 Browser* otr_browser = BrowserList::FindTabbedBrowser(
70 browser()->profile()->GetOffTheRecordProfile(), false); 72 browser()->profile()->GetOffTheRecordProfile(), false);
71 TabContents* tab = otr_browser->GetSelectedTabContents(); 73 WebContents* tab = otr_browser->GetSelectedWebContents();
72 74
73 // Verify the script ran. 75 // Verify the script ran.
74 bool result = false; 76 bool result = false;
75 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 77 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
76 tab->GetRenderViewHost(), L"", 78 tab->GetRenderViewHost(), L"",
77 L"window.domAutomationController.send(document.title == 'modified')", 79 L"window.domAutomationController.send(document.title == 'modified')",
78 &result)); 80 &result));
79 EXPECT_TRUE(result); 81 EXPECT_TRUE(result);
80 } 82 }
81 83
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 test_server()->GetURL("files/extensions/test_file.html")); 184 test_server()->GetURL("files/extensions/test_file.html"));
183 185
184 Browser* incognito_browser = BrowserList::FindTabbedBrowser( 186 Browser* incognito_browser = BrowserList::FindTabbedBrowser(
185 browser()->profile()->GetOffTheRecordProfile(), false); 187 browser()->profile()->GetOffTheRecordProfile(), false);
186 188
187 // Simulate the incognito's browser action being clicked. 189 // Simulate the incognito's browser action being clicked.
188 BrowserActionTestUtil(incognito_browser).Press(0); 190 BrowserActionTestUtil(incognito_browser).Press(0);
189 191
190 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 192 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
191 } 193 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698