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

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

Issue 10795090: Move ExecuteJavaScript functions from ui_test_utils.h to browser_test_utils.h so they can be reused… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 5 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) 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/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_tabstrip.h" 12 #include "chrome/browser/ui/browser_tabstrip.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/public/browser/web_contents.h" 16 #include "content/public/browser/web_contents.h"
17 #include "content/public/test/browser_test_utils.h"
17 #include "net/base/mock_host_resolver.h" 18 #include "net/base/mock_host_resolver.h"
18 19
19 using content::WebContents; 20 using content::WebContents;
20 21
21 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, IncognitoNoScript) { 22 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, IncognitoNoScript) {
22 ASSERT_TRUE(StartTestServer()); 23 ASSERT_TRUE(StartTestServer());
23 24
24 // Loads a simple extension which attempts to change the title of every page 25 // Loads a simple extension which attempts to change the title of every page
25 // that loads to "modified". 26 // that loads to "modified".
26 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("incognito") 27 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("incognito")
27 .AppendASCII("content_scripts"))); 28 .AppendASCII("content_scripts")));
28 29
29 // Open incognito window and navigate to test page. 30 // Open incognito window and navigate to test page.
30 Browser* otr_browser = ui_test_utils::OpenURLOffTheRecord( 31 Browser* otr_browser = ui_test_utils::OpenURLOffTheRecord(
31 browser()->profile(), 32 browser()->profile(),
32 test_server()->GetURL("files/extensions/test_file.html")); 33 test_server()->GetURL("files/extensions/test_file.html"));
33 34
34 WebContents* tab = chrome::GetActiveWebContents(otr_browser); 35 WebContents* tab = chrome::GetActiveWebContents(otr_browser);
35 36
36 // Verify the script didn't run. 37 // Verify the script didn't run.
37 bool result = false; 38 bool result = false;
38 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 39 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool(
39 tab->GetRenderViewHost(), L"", 40 tab->GetRenderViewHost(), L"",
40 L"window.domAutomationController.send(document.title == 'Unmodified')", 41 L"window.domAutomationController.send(document.title == 'Unmodified')",
41 &result)); 42 &result));
42 EXPECT_TRUE(result); 43 EXPECT_TRUE(result);
43 } 44 }
44 45
45 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, IncognitoYesScript) { 46 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, IncognitoYesScript) {
46 host_resolver()->AddRule("*", "127.0.0.1"); 47 host_resolver()->AddRule("*", "127.0.0.1");
47 ASSERT_TRUE(StartTestServer()); 48 ASSERT_TRUE(StartTestServer());
48 49
(...skipping 14 matching lines...) Expand all
63 64
64 // Open incognito window and navigate to test page. 65 // Open incognito window and navigate to test page.
65 Browser* otr_browser = ui_test_utils::OpenURLOffTheRecord( 66 Browser* otr_browser = ui_test_utils::OpenURLOffTheRecord(
66 browser()->profile(), 67 browser()->profile(),
67 test_server()->GetURL("files/extensions/test_file.html")); 68 test_server()->GetURL("files/extensions/test_file.html"));
68 69
69 WebContents* tab = chrome::GetActiveWebContents(otr_browser); 70 WebContents* tab = chrome::GetActiveWebContents(otr_browser);
70 71
71 // Verify the script ran. 72 // Verify the script ran.
72 bool result = false; 73 bool result = false;
73 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 74 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool(
74 tab->GetRenderViewHost(), L"", 75 tab->GetRenderViewHost(), L"",
75 L"window.domAutomationController.send(document.title == 'modified')", 76 L"window.domAutomationController.send(document.title == 'modified')",
76 &result)); 77 &result));
77 EXPECT_TRUE(result); 78 EXPECT_TRUE(result);
78 } 79 }
79 80
80 // Tests that an extension which is enabled for incognito mode doesn't 81 // Tests that an extension which is enabled for incognito mode doesn't
81 // accidentially create and incognito profile. 82 // accidentially create and incognito profile.
82 // Test disabled due to http://crbug.com/89054. 83 // Test disabled due to http://crbug.com/89054.
83 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DISABLED_DontCreateIncognitoProfile) { 84 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DISABLED_DontCreateIncognitoProfile) {
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 // Open incognito window and navigate to test page. 193 // Open incognito window and navigate to test page.
193 Browser* incognito_browser = ui_test_utils::OpenURLOffTheRecord( 194 Browser* incognito_browser = ui_test_utils::OpenURLOffTheRecord(
194 browser()->profile(), 195 browser()->profile(),
195 test_server()->GetURL("files/extensions/test_file.html")); 196 test_server()->GetURL("files/extensions/test_file.html"));
196 197
197 // Simulate the incognito's browser action being clicked. 198 // Simulate the incognito's browser action being clicked.
198 BrowserActionTestUtil(incognito_browser).Press(0); 199 BrowserActionTestUtil(incognito_browser).Press(0);
199 200
200 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 201 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
201 } 202 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_icon_source_apitest.cc ('k') | chrome/browser/extensions/extension_keybinding_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698