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/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" |
(...skipping 18 matching lines...) Expand all Loading... |
29 | 29 |
30 // Open incognito window and navigate to test page. | 30 // Open incognito window and navigate to test page. |
31 Browser* otr_browser = ui_test_utils::OpenURLOffTheRecord( | 31 Browser* otr_browser = ui_test_utils::OpenURLOffTheRecord( |
32 browser()->profile(), | 32 browser()->profile(), |
33 test_server()->GetURL("files/extensions/test_file.html")); | 33 test_server()->GetURL("files/extensions/test_file.html")); |
34 | 34 |
35 WebContents* tab = chrome::GetActiveWebContents(otr_browser); | 35 WebContents* tab = chrome::GetActiveWebContents(otr_browser); |
36 | 36 |
37 // Verify the script didn't run. | 37 // Verify the script didn't run. |
38 bool result = false; | 38 bool result = false; |
39 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( | 39 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
40 tab->GetRenderViewHost(), | 40 tab, |
41 "", | |
42 "window.domAutomationController.send(document.title == 'Unmodified')", | 41 "window.domAutomationController.send(document.title == 'Unmodified')", |
43 &result)); | 42 &result)); |
44 EXPECT_TRUE(result); | 43 EXPECT_TRUE(result); |
45 } | 44 } |
46 | 45 |
47 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, IncognitoYesScript) { | 46 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, IncognitoYesScript) { |
48 host_resolver()->AddRule("*", "127.0.0.1"); | 47 host_resolver()->AddRule("*", "127.0.0.1"); |
49 ASSERT_TRUE(StartTestServer()); | 48 ASSERT_TRUE(StartTestServer()); |
50 | 49 |
51 // Load a dummy extension. This just tests that we don't regress a | 50 // Load a dummy extension. This just tests that we don't regress a |
(...skipping 13 matching lines...) Expand all Loading... |
65 | 64 |
66 // Open incognito window and navigate to test page. | 65 // Open incognito window and navigate to test page. |
67 Browser* otr_browser = ui_test_utils::OpenURLOffTheRecord( | 66 Browser* otr_browser = ui_test_utils::OpenURLOffTheRecord( |
68 browser()->profile(), | 67 browser()->profile(), |
69 test_server()->GetURL("files/extensions/test_file.html")); | 68 test_server()->GetURL("files/extensions/test_file.html")); |
70 | 69 |
71 WebContents* tab = chrome::GetActiveWebContents(otr_browser); | 70 WebContents* tab = chrome::GetActiveWebContents(otr_browser); |
72 | 71 |
73 // Verify the script ran. | 72 // Verify the script ran. |
74 bool result = false; | 73 bool result = false; |
75 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( | 74 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
76 tab->GetRenderViewHost(), | 75 tab, |
77 "", | |
78 "window.domAutomationController.send(document.title == 'modified')", | 76 "window.domAutomationController.send(document.title == 'modified')", |
79 &result)); | 77 &result)); |
80 EXPECT_TRUE(result); | 78 EXPECT_TRUE(result); |
81 } | 79 } |
82 | 80 |
83 // 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 |
84 // accidentially create and incognito profile. | 82 // accidentially create and incognito profile. |
85 // Test disabled due to http://crbug.com/89054. | 83 // Test disabled due to http://crbug.com/89054. |
86 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DISABLED_DontCreateIncognitoProfile) { | 84 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DISABLED_DontCreateIncognitoProfile) { |
87 ASSERT_FALSE(browser()->profile()->HasOffTheRecordProfile()); | 85 ASSERT_FALSE(browser()->profile()->HasOffTheRecordProfile()); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 // Open incognito window and navigate to test page. | 193 // Open incognito window and navigate to test page. |
196 Browser* incognito_browser = ui_test_utils::OpenURLOffTheRecord( | 194 Browser* incognito_browser = ui_test_utils::OpenURLOffTheRecord( |
197 browser()->profile(), | 195 browser()->profile(), |
198 test_server()->GetURL("files/extensions/test_file.html")); | 196 test_server()->GetURL("files/extensions/test_file.html")); |
199 | 197 |
200 // Simulate the incognito's browser action being clicked. | 198 // Simulate the incognito's browser action being clicked. |
201 BrowserActionTestUtil(incognito_browser).Press(0); | 199 BrowserActionTestUtil(incognito_browser).Press(0); |
202 | 200 |
203 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 201 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
204 } | 202 } |
OLD | NEW |