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/extension_apitest.h" | 5 #include "chrome/browser/extensions/extension_apitest.h" |
6 #include "chrome/browser/extensions/extension_host.h" | 6 #include "chrome/browser/extensions/extension_host.h" |
7 #include "chrome/browser/extensions/extension_service.h" | 7 #include "chrome/browser/extensions/extension_service.h" |
8 #include "chrome/browser/extensions/process_map.h" | 8 #include "chrome/browser/extensions/process_map.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
11 #include "chrome/browser/ui/browser_commands.h" | 11 #include "chrome/browser/ui/browser_commands.h" |
12 #include "chrome/browser/ui/browser_finder.h" | 12 #include "chrome/browser/ui/browser_finder.h" |
13 #include "chrome/browser/ui/browser_list.h" | 13 #include "chrome/browser/ui/browser_list.h" |
14 #include "chrome/browser/ui/browser_tabstrip.h" | 14 #include "chrome/browser/ui/browser_tabstrip.h" |
15 #include "chrome/browser/ui/browser_window.h" | 15 #include "chrome/browser/ui/browser_window.h" |
16 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 16 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
17 #include "chrome/common/chrome_notification_types.h" | 17 #include "chrome/common/chrome_notification_types.h" |
18 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
19 #include "chrome/common/extensions/extension.h" | 19 #include "chrome/common/extensions/extension.h" |
20 #include "chrome/common/extensions/extension_file_util.h" | 20 #include "chrome/common/extensions/extension_file_util.h" |
21 #include "chrome/common/string_ordinal.h" | |
22 #include "chrome/test/base/ui_test_utils.h" | 21 #include "chrome/test/base/ui_test_utils.h" |
23 #include "content/public/browser/navigation_entry.h" | 22 #include "content/public/browser/navigation_entry.h" |
24 #include "content/public/browser/notification_service.h" | 23 #include "content/public/browser/notification_service.h" |
25 #include "content/public/browser/render_process_host.h" | 24 #include "content/public/browser/render_process_host.h" |
26 #include "content/public/browser/render_view_host.h" | 25 #include "content/public/browser/render_view_host.h" |
27 #include "content/public/browser/web_contents.h" | 26 #include "content/public/browser/web_contents.h" |
28 #include "content/public/test/browser_test_utils.h" | 27 #include "content/public/test/browser_test_utils.h" |
29 #include "content/public/test/test_navigation_observer.h" | 28 #include "content/public/test/test_navigation_observer.h" |
30 #include "net/base/mock_host_resolver.h" | 29 #include "net/base/mock_host_resolver.h" |
| 30 #include "sync/api/string_ordinal.h" |
31 | 31 |
32 using content::NavigationController; | 32 using content::NavigationController; |
33 using content::RenderViewHost; | 33 using content::RenderViewHost; |
34 using content::WebContents; | 34 using content::WebContents; |
35 using extensions::Extension; | 35 using extensions::Extension; |
36 | 36 |
37 class AppApiTest : public ExtensionApiTest { | 37 class AppApiTest : public ExtensionApiTest { |
38 protected: | 38 protected: |
39 // Gets the base URL for files for a specific test, making sure that it uses | 39 // Gets the base URL for files for a specific test, making sure that it uses |
40 // "localhost" as the hostname, since that is what the extent is declared | 40 // "localhost" as the hostname, since that is what the extent is declared |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 GURL base_url = GetTestBaseURL("app_process"); | 246 GURL base_url = GetTestBaseURL("app_process"); |
247 | 247 |
248 // Load an app as a bookmark app. | 248 // Load an app as a bookmark app. |
249 std::string error; | 249 std::string error; |
250 scoped_refptr<const Extension> extension(extension_file_util::LoadExtension( | 250 scoped_refptr<const Extension> extension(extension_file_util::LoadExtension( |
251 test_data_dir_.AppendASCII("app_process"), | 251 test_data_dir_.AppendASCII("app_process"), |
252 Extension::LOAD, | 252 Extension::LOAD, |
253 Extension::FROM_BOOKMARK, | 253 Extension::FROM_BOOKMARK, |
254 &error)); | 254 &error)); |
255 service->OnExtensionInstalled(extension, false, | 255 service->OnExtensionInstalled(extension, false, |
256 StringOrdinal::CreateInitialOrdinal()); | 256 syncer::StringOrdinal::CreateInitialOrdinal()); |
257 ASSERT_TRUE(extension.get()); | 257 ASSERT_TRUE(extension.get()); |
258 ASSERT_TRUE(extension->from_bookmark()); | 258 ASSERT_TRUE(extension->from_bookmark()); |
259 | 259 |
260 // Test both opening a URL in a new tab, and opening a tab and then navigating | 260 // Test both opening a URL in a new tab, and opening a tab and then navigating |
261 // it. Either way, bookmark app tabs should be considered normal processes | 261 // it. Either way, bookmark app tabs should be considered normal processes |
262 // with no elevated privileges and no WebUI bindings. | 262 // with no elevated privileges and no WebUI bindings. |
263 ui_test_utils::NavigateToURLWithDisposition( | 263 ui_test_utils::NavigateToURLWithDisposition( |
264 browser(), base_url.Resolve("path1/empty.html"), NEW_FOREGROUND_TAB, | 264 browser(), base_url.Resolve("path1/empty.html"), NEW_FOREGROUND_TAB, |
265 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 265 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
266 EXPECT_FALSE(process_map->Contains( | 266 EXPECT_FALSE(process_map->Contains( |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 content::Source<NavigationController>( | 583 content::Source<NavigationController>( |
584 &chrome::GetActiveWebContents(browser())->GetController())); | 584 &chrome::GetActiveWebContents(browser())->GetController())); |
585 chrome::Reload(browser(), CURRENT_TAB); | 585 chrome::Reload(browser(), CURRENT_TAB); |
586 observer.Wait(); | 586 observer.Wait(); |
587 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( | 587 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( |
588 contents->GetRenderViewHost(), L"", | 588 contents->GetRenderViewHost(), L"", |
589 L"window.domAutomationController.send(chrome.app.isInstalled)", | 589 L"window.domAutomationController.send(chrome.app.isInstalled)", |
590 &is_installed)); | 590 &is_installed)); |
591 ASSERT_TRUE(is_installed); | 591 ASSERT_TRUE(is_installed); |
592 } | 592 } |
OLD | NEW |