| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/browser.h" | 5 #include "chrome/browser/browser.h" |
| 6 #include "chrome/browser/browser_list.h" | 6 #include "chrome/browser/browser_list.h" |
| 7 #include "chrome/browser/browser_window.h" | 7 #include "chrome/browser/browser_window.h" |
| 8 #include "chrome/browser/extensions/browser_action_test_util.h" | 8 #include "chrome/browser/extensions/browser_action_test_util.h" |
| 9 #include "chrome/browser/extensions/extension_apitest.h" | 9 #include "chrome/browser/extensions/extension_apitest.h" |
| 10 #include "chrome/browser/extensions/extensions_service.h" | 10 #include "chrome/browser/extensions/extensions_service.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 // Open incognito window and navigate to test page. | 88 // Open incognito window and navigate to test page. |
| 89 ui_test_utils::OpenURLOffTheRecord(browser()->profile(), | 89 ui_test_utils::OpenURLOffTheRecord(browser()->profile(), |
| 90 GURL("http://www.example.com:1337/files/extensions/test_file.html")); | 90 GURL("http://www.example.com:1337/files/extensions/test_file.html")); |
| 91 | 91 |
| 92 ASSERT_TRUE(LoadExtensionIncognito(test_data_dir_ | 92 ASSERT_TRUE(LoadExtensionIncognito(test_data_dir_ |
| 93 .AppendASCII("incognito").AppendASCII("apis"))); | 93 .AppendASCII("incognito").AppendASCII("apis"))); |
| 94 | 94 |
| 95 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 95 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 96 } | 96 } |
| 97 | 97 |
| 98 // Tests that the APIs in an incognito-enabled split-mode extension work |
| 99 // properly. |
| 100 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, IncognitoSplitMode) { |
| 101 host_resolver()->AddRule("*", "127.0.0.1"); |
| 102 ASSERT_TRUE(test_server()->Start()); |
| 103 |
| 104 // We need 2 ResultCatchers because we'll be running the same test in both |
| 105 // regular and incognito mode. |
| 106 ResultCatcher catcher; |
| 107 catcher.RestrictToProfile(browser()->profile()); |
| 108 ResultCatcher catcher_incognito; |
| 109 catcher_incognito.RestrictToProfile( |
| 110 browser()->profile()->GetOffTheRecordProfile()); |
| 111 |
| 112 // Open incognito window and navigate to test page. |
| 113 ui_test_utils::OpenURLOffTheRecord(browser()->profile(), |
| 114 GURL("http://www.example.com:1337/files/extensions/test_file.html")); |
| 115 |
| 116 ASSERT_TRUE(LoadExtensionIncognito(test_data_dir_ |
| 117 .AppendASCII("incognito").AppendASCII("split"))); |
| 118 |
| 119 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 120 EXPECT_TRUE(catcher_incognito.GetNextResult()) << catcher.message(); |
| 121 } |
| 122 |
| 98 // Tests that the APIs in an incognito-disabled extension don't see incognito | 123 // Tests that the APIs in an incognito-disabled extension don't see incognito |
| 99 // events or callbacks. | 124 // events or callbacks. |
| 100 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, IncognitoDisabled) { | 125 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, IncognitoDisabled) { |
| 101 host_resolver()->AddRule("*", "127.0.0.1"); | 126 host_resolver()->AddRule("*", "127.0.0.1"); |
| 102 ASSERT_TRUE(test_server()->Start()); | 127 ASSERT_TRUE(test_server()->Start()); |
| 103 | 128 |
| 104 ResultCatcher catcher; | 129 ResultCatcher catcher; |
| 105 | 130 |
| 106 // Open incognito window and navigate to test page. | 131 // Open incognito window and navigate to test page. |
| 107 ui_test_utils::OpenURLOffTheRecord(browser()->profile(), | 132 ui_test_utils::OpenURLOffTheRecord(browser()->profile(), |
| (...skipping 20 matching lines...) Expand all Loading... |
| 128 GURL("http://www.example.com:1337/files/extensions/test_file.html")); | 153 GURL("http://www.example.com:1337/files/extensions/test_file.html")); |
| 129 Browser* incognito_browser = BrowserList::FindBrowserWithType( | 154 Browser* incognito_browser = BrowserList::FindBrowserWithType( |
| 130 browser()->profile()->GetOffTheRecordProfile(), Browser::TYPE_NORMAL, | 155 browser()->profile()->GetOffTheRecordProfile(), Browser::TYPE_NORMAL, |
| 131 false); | 156 false); |
| 132 | 157 |
| 133 // Simulate the incognito's browser action being clicked. | 158 // Simulate the incognito's browser action being clicked. |
| 134 BrowserActionTestUtil(incognito_browser).Press(0); | 159 BrowserActionTestUtil(incognito_browser).Press(0); |
| 135 | 160 |
| 136 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 161 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 137 } | 162 } |
| OLD | NEW |