OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 // Tests for the --load-and-launch-app switch. | 5 // Tests for the --load-and-launch-app switch. |
6 // The two cases are when chrome is running and another process uses the switch | 6 // The two cases are when chrome is running and another process uses the switch |
7 // and when chrome is started from scratch. | 7 // and when chrome is started from scratch. |
8 | 8 |
9 #include "apps/switches.h" | 9 #include "apps/switches.h" |
10 #include "base/process/launch.h" | 10 #include "base/process/launch.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 new_cmdline.CopySwitchesFrom(cmdline, kSwitchNames, arraysize(kSwitchNames)); | 43 new_cmdline.CopySwitchesFrom(cmdline, kSwitchNames, arraysize(kSwitchNames)); |
44 | 44 |
45 base::FilePath app_path = test_data_dir_ | 45 base::FilePath app_path = test_data_dir_ |
46 .AppendASCII("platform_apps") | 46 .AppendASCII("platform_apps") |
47 .AppendASCII("minimal"); | 47 .AppendASCII("minimal"); |
48 | 48 |
49 new_cmdline.AppendSwitchNative(apps::kLoadAndLaunchApp, | 49 new_cmdline.AppendSwitchNative(apps::kLoadAndLaunchApp, |
50 app_path.value()); | 50 app_path.value()); |
51 | 51 |
52 new_cmdline.AppendSwitch(content::kLaunchAsBrowser); | 52 new_cmdline.AppendSwitch(content::kLaunchAsBrowser); |
| 53 base::LaunchOptions options; |
| 54 #if defined(OS_LINUX) |
| 55 // To prevent accidental privilege sharing to an untrusted child, processes |
| 56 // are started with PR_SET_NO_NEW_PRIVS. Do not set that here, since this |
| 57 // new child will be a test browser process. |
| 58 options.allow_new_privs = true; |
| 59 #endif |
53 base::ProcessHandle process; | 60 base::ProcessHandle process; |
54 base::LaunchProcess(new_cmdline, base::LaunchOptions(), &process); | 61 base::LaunchProcess(new_cmdline, options, &process); |
55 ASSERT_NE(base::kNullProcessHandle, process); | 62 ASSERT_NE(base::kNullProcessHandle, process); |
56 | 63 |
57 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); | 64 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); |
58 ASSERT_TRUE(base::WaitForSingleProcess( | 65 ASSERT_TRUE(base::WaitForSingleProcess( |
59 process, TestTimeouts::action_timeout())); | 66 process, TestTimeouts::action_timeout())); |
60 } | 67 } |
61 | 68 |
62 // TODO(jackhou): Enable this test once it works on OSX. It currently does not | 69 // TODO(jackhou): Enable this test once it works on OSX. It currently does not |
63 // work for the same reason --app-id doesn't. See http://crbug.com/148465 | 70 // work for the same reason --app-id doesn't. See http://crbug.com/148465 |
64 #if defined(OS_MACOSX) | 71 #if defined(OS_MACOSX) |
(...skipping 21 matching lines...) Expand all Loading... |
86 base::FilePath test_file_path = test_data_dir_ | 93 base::FilePath test_file_path = test_data_dir_ |
87 .AppendASCII("platform_apps") | 94 .AppendASCII("platform_apps") |
88 .AppendASCII("launch_files") | 95 .AppendASCII("launch_files") |
89 .AppendASCII("test.txt"); | 96 .AppendASCII("test.txt"); |
90 | 97 |
91 new_cmdline.AppendSwitchNative(apps::kLoadAndLaunchApp, | 98 new_cmdline.AppendSwitchNative(apps::kLoadAndLaunchApp, |
92 app_path.value()); | 99 app_path.value()); |
93 new_cmdline.AppendSwitch(content::kLaunchAsBrowser); | 100 new_cmdline.AppendSwitch(content::kLaunchAsBrowser); |
94 new_cmdline.AppendArgPath(test_file_path); | 101 new_cmdline.AppendArgPath(test_file_path); |
95 | 102 |
| 103 base::LaunchOptions options; |
| 104 #if defined(OS_LINUX) |
| 105 // To prevent accidental privilege sharing to an untrusted child, processes |
| 106 // are started with PR_SET_NO_NEW_PRIVS. Do not set that here, since this |
| 107 // new child will be a test browser process. |
| 108 options.allow_new_privs = true; |
| 109 #endif |
96 base::ProcessHandle process; | 110 base::ProcessHandle process; |
97 base::LaunchProcess(new_cmdline, base::LaunchOptions(), &process); | 111 base::LaunchProcess(new_cmdline, options, &process); |
98 ASSERT_NE(base::kNullProcessHandle, process); | 112 ASSERT_NE(base::kNullProcessHandle, process); |
99 | 113 |
100 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); | 114 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); |
101 ASSERT_TRUE(base::WaitForSingleProcess( | 115 ASSERT_TRUE(base::WaitForSingleProcess( |
102 process, TestTimeouts::action_timeout())); | 116 process, TestTimeouts::action_timeout())); |
103 } | 117 } |
104 | 118 |
105 namespace { | 119 namespace { |
106 | 120 |
107 // TestFixture that appends --load-and-launch-app before calling BrowserMain. | 121 // TestFixture that appends --load-and-launch-app before calling BrowserMain. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 LoadAndLaunchAppChromeNotRunning | 160 LoadAndLaunchAppChromeNotRunning |
147 #endif | 161 #endif |
148 | 162 |
149 // Case where Chrome is not running. | 163 // Case where Chrome is not running. |
150 IN_PROC_BROWSER_TEST_F(PlatformAppLoadAndLaunchBrowserTest, | 164 IN_PROC_BROWSER_TEST_F(PlatformAppLoadAndLaunchBrowserTest, |
151 MAYBE_LoadAndLaunchAppChromeNotRunning) { | 165 MAYBE_LoadAndLaunchAppChromeNotRunning) { |
152 LoadAndLaunchApp(); | 166 LoadAndLaunchApp(); |
153 } | 167 } |
154 | 168 |
155 } // namespace apps | 169 } // namespace apps |
OLD | NEW |