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 <stdio.h> | 5 #include <stdio.h> |
6 #if defined(OS_POSIX) | 6 #if defined(OS_POSIX) |
7 #include <unistd.h> | 7 #include <unistd.h> |
8 #elif defined(OS_WIN) | 8 #elif defined(OS_WIN) |
9 #include <windows.h> | 9 #include <windows.h> |
10 #endif | 10 #endif |
11 | 11 |
12 #define TELEMETRY 1 | 12 #define TELEMETRY 1 |
13 | 13 |
14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
15 #include "base/environment.h" | 15 #include "base/environment.h" |
16 #include "base/path_service.h" | 16 #include "base/path_service.h" |
| 17 #include "base/process/kill.h" |
| 18 #include "base/process/launch.h" |
| 19 #include "base/strings/string_number_conversions.h" |
17 #include "base/win/windows_version.h" | 20 #include "base/win/windows_version.h" |
18 #include "chrome/common/chrome_switches.h" | 21 #include "chrome/common/chrome_switches.h" |
19 #include "chrome/test/nacl/nacl_browsertest_util.h" | 22 #include "chrome/test/nacl/nacl_browsertest_util.h" |
| 23 #include "components/nacl/browser/nacl_browser.h" |
20 #include "components/nacl/common/nacl_switches.h" | 24 #include "components/nacl/common/nacl_switches.h" |
21 #include "content/public/common/content_switches.h" | 25 #include "content/public/common/content_switches.h" |
22 | 26 |
23 namespace { | 27 namespace { |
24 | 28 |
25 #if defined(OS_WIN) | 29 #if defined(OS_WIN) |
26 // crbug.com/98721 | 30 // crbug.com/98721 |
27 # define MAYBE_Crash DISABLED_Crash | 31 # define MAYBE_Crash DISABLED_Crash |
28 # define MAYBE_SysconfNprocessorsOnln DISABLED_SysconfNprocessorsOnln | 32 # define MAYBE_SysconfNprocessorsOnln DISABLED_SysconfNprocessorsOnln |
29 #else | 33 #else |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 } | 198 } |
195 | 199 |
196 IN_PROC_BROWSER_TEST_F(NaClBrowserTestStatic, CORSNoCookie) { | 200 IN_PROC_BROWSER_TEST_F(NaClBrowserTestStatic, CORSNoCookie) { |
197 RunLoadTest(FILE_PATH_LITERAL("cross_origin/cors_no_cookie.html")); | 201 RunLoadTest(FILE_PATH_LITERAL("cross_origin/cors_no_cookie.html")); |
198 } | 202 } |
199 | 203 |
200 IN_PROC_BROWSER_TEST_F(NaClBrowserTestStatic, RelativeManifest) { | 204 IN_PROC_BROWSER_TEST_F(NaClBrowserTestStatic, RelativeManifest) { |
201 RunLoadTest(FILE_PATH_LITERAL("manifest/relative_manifest.html")); | 205 RunLoadTest(FILE_PATH_LITERAL("manifest/relative_manifest.html")); |
202 } | 206 } |
203 | 207 |
204 class NaClBrowserTestPnaclDebugURL : public NaClBrowserTestPnacl { | 208 // Test with the NaCl debug flag turned on. |
| 209 class NaClBrowserTestPnaclDebug : public NaClBrowserTestPnacl { |
205 public: | 210 public: |
206 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 211 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
207 NaClBrowserTestPnacl::SetUpCommandLine(command_line); | 212 NaClBrowserTestPnacl::SetUpCommandLine(command_line); |
208 // Turn on debugging to influence the PNaCl URL loaded | 213 // Turn on debugging to influence the PNaCl URL loaded |
209 command_line->AppendSwitch(switches::kEnableNaClDebug); | 214 command_line->AppendSwitch(switches::kEnableNaClDebug); |
210 // On windows, the debug stub requires --no-sandbox: | 215 // On windows, the debug stub requires --no-sandbox: |
211 // crbug.com/265624 | 216 // crbug.com/265624 |
212 #if defined(OS_WIN) | 217 #if defined(OS_WIN) |
213 command_line->AppendSwitch(switches::kNoSandbox); | 218 command_line->AppendSwitch(switches::kNoSandbox); |
214 #endif | 219 #endif |
215 // Don't actually debug the app though. | 220 } |
| 221 |
| 222 // On some platforms this test does not work. |
| 223 bool TestIsBroken() { |
| 224 // TODO(jvoung): Make this test work on Windows 32-bit. When --no-sandbox |
| 225 // is used, the required 1GB sandbox address space is not reserved. |
| 226 // (see note in chrome/browser/nacl_host/test/nacl_gdb_browsertest.cc) |
| 227 #if defined(OS_WIN) |
| 228 if (base::win::OSInfo::GetInstance()->wow64_status() == |
| 229 base::win::OSInfo::WOW64_DISABLED && |
| 230 base::win::OSInfo::GetInstance()->architecture() == |
| 231 base::win::OSInfo::X86_ARCHITECTURE) { |
| 232 return true; |
| 233 } |
| 234 #endif |
| 235 return false; |
| 236 } |
| 237 |
| 238 void StartTestScript(base::ProcessHandle* test_process, |
| 239 int debug_stub_port) { |
| 240 // We call a python script that speaks to the debug stub, and |
| 241 // lets the app continue, so that the load progress event completes. |
| 242 CommandLine cmd(base::FilePath(FILE_PATH_LITERAL("python"))); |
| 243 base::FilePath script; |
| 244 PathService::Get(base::DIR_SOURCE_ROOT, &script); |
| 245 script = script.AppendASCII( |
| 246 "chrome/browser/nacl_host/test/debug_stub_browser_tests.py"); |
| 247 cmd.AppendArgPath(script); |
| 248 cmd.AppendArg(base::IntToString(debug_stub_port)); |
| 249 cmd.AppendArg("continue"); |
| 250 LOG(INFO) << cmd.GetCommandLineString(); |
| 251 base::LaunchProcess(cmd, base::LaunchOptions(), test_process); |
| 252 } |
| 253 |
| 254 void RunWithTestDebugger(const base::FilePath::StringType& test_url) { |
| 255 base::ProcessHandle test_script; |
| 256 scoped_ptr<base::Environment> env(base::Environment::Create()); |
| 257 nacl::NaClBrowser::GetInstance()->SetGdbDebugStubPortListener( |
| 258 base::Bind(&NaClBrowserTestPnaclDebug::StartTestScript, |
| 259 base::Unretained(this), &test_script)); |
| 260 // Turn on debug stub logging. |
| 261 env->SetVar("NACLVERBOSITY", "1"); |
| 262 RunLoadTest(test_url); |
| 263 env->UnSetVar("NACLVERBOSITY"); |
| 264 nacl::NaClBrowser::GetInstance()->ClearGdbDebugStubPortListener(); |
| 265 int exit_code; |
| 266 LOG(INFO) << "Waiting for script to exit (which waits for embed to die)."; |
| 267 base::WaitForExitCode(test_script, &exit_code); |
| 268 EXPECT_EQ(0, exit_code); |
| 269 } |
| 270 }; |
| 271 |
| 272 // Test with the NaCl debug flag turned on, but mask off every URL |
| 273 // so that nothing is actually debugged. |
| 274 class NaClBrowserTestPnaclDebugMasked : public NaClBrowserTestPnaclDebug { |
| 275 public: |
| 276 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 277 NaClBrowserTestPnaclDebug::SetUpCommandLine(command_line); |
216 command_line->AppendSwitchASCII(switches::kNaClDebugMask, | 278 command_line->AppendSwitchASCII(switches::kNaClDebugMask, |
217 "!<all_urls>"); | 279 "!<all_urls>"); |
218 } | 280 } |
219 }; | 281 }; |
220 | 282 |
221 IN_PROC_BROWSER_TEST_F(NaClBrowserTestPnaclDebugURL, | 283 // The tests which actually start a debug session must use the debug stub |
222 MAYBE_PNACL(PnaclDebugURLFlagAndURL)) { | 284 // to continue the app startup. However, NaCl on windows can't open the |
223 // TODO(jvoung): Make this test work on Windows 32-bit. When --no-sandbox | 285 // debug stub socket in the browser process as needed by the test. |
224 // is used, the required 1GB sandbox address space is not reserved. | 286 // See http://crbug.com/157312. |
225 // (see note in chrome/browser/nacl_host/test/nacl_gdb_browsertest.cc) | |
226 #if defined(OS_WIN) | 287 #if defined(OS_WIN) |
227 if (base::win::OSInfo::GetInstance()->wow64_status() == | 288 #define MAYBE_PnaclDebugURLFlagAndURL DISABLED_PnaclDebugURLFlagAndURL |
228 base::win::OSInfo::WOW64_DISABLED && | 289 #define MAYBE_PnaclDebugURLFlagNoURL DISABLED_PnaclDebugURLFlagNoURL |
229 base::win::OSInfo::GetInstance()->architecture() == | 290 #else |
230 base::win::OSInfo::X86_ARCHITECTURE) { | 291 #define MAYBE_PnaclDebugURLFlagAndURL PnaclDebugURLFlagAndURL |
231 return; | 292 #define MAYBE_PnaclDebugURLFlagNoURL PnaclDebugURLFlagNoURL |
232 } | |
233 #endif | 293 #endif |
234 RunLoadTest(FILE_PATH_LITERAL( | 294 IN_PROC_BROWSER_TEST_F(NaClBrowserTestPnaclDebug, |
| 295 MAYBE_PnaclDebugURLFlagAndURL) { |
| 296 RunWithTestDebugger(FILE_PATH_LITERAL( |
235 "pnacl_debug_url.html?nmf_file=pnacl_has_debug.nmf")); | 297 "pnacl_debug_url.html?nmf_file=pnacl_has_debug.nmf")); |
236 } | 298 } |
237 | 299 |
238 IN_PROC_BROWSER_TEST_F(NaClBrowserTestPnaclDebugURL, | 300 IN_PROC_BROWSER_TEST_F(NaClBrowserTestPnaclDebug, |
239 MAYBE_PNACL(PnaclDebugURLFlagNoURL)) { | 301 MAYBE_PnaclDebugURLFlagNoURL) { |
240 #if defined(OS_WIN) | 302 RunWithTestDebugger(FILE_PATH_LITERAL( |
241 if (base::win::OSInfo::GetInstance()->wow64_status() == | |
242 base::win::OSInfo::WOW64_DISABLED && | |
243 base::win::OSInfo::GetInstance()->architecture() == | |
244 base::win::OSInfo::X86_ARCHITECTURE) { | |
245 return; | |
246 } | |
247 #endif | |
248 RunLoadTest(FILE_PATH_LITERAL( | |
249 "pnacl_debug_url.html?nmf_file=pnacl_no_debug.nmf")); | 303 "pnacl_debug_url.html?nmf_file=pnacl_no_debug.nmf")); |
250 } | 304 } |
251 | 305 |
252 IN_PROC_BROWSER_TEST_F(NaClBrowserTestPnacl, | 306 IN_PROC_BROWSER_TEST_F(NaClBrowserTestPnacl, |
253 MAYBE_PNACL(PnaclDebugURLFlagOff)) { | 307 MAYBE_PNACL(PnaclDebugURLFlagOff)) { |
254 RunLoadTest(FILE_PATH_LITERAL( | 308 RunLoadTest(FILE_PATH_LITERAL( |
255 "pnacl_debug_url.html?nmf_file=pnacl_has_debug_flag_off.nmf")); | 309 "pnacl_debug_url.html?nmf_file=pnacl_has_debug_flag_off.nmf")); |
256 } | 310 } |
257 | 311 |
| 312 IN_PROC_BROWSER_TEST_F(NaClBrowserTestPnaclDebugMasked, |
| 313 MAYBE_PNACL(PnaclDebugURLFlagMaskedOff)) { |
| 314 if (TestIsBroken()) { |
| 315 return; |
| 316 } |
| 317 // If the mask excludes debugging, it's as if the flag was off. |
| 318 RunLoadTest(FILE_PATH_LITERAL( |
| 319 "pnacl_debug_url.html?nmf_file=pnacl_has_debug_flag_off.nmf")); |
| 320 } |
| 321 |
258 IN_PROC_BROWSER_TEST_F(NaClBrowserTestPnacl, | 322 IN_PROC_BROWSER_TEST_F(NaClBrowserTestPnacl, |
259 MAYBE_PNACL(PnaclErrorHandling)) { | 323 MAYBE_PNACL(PnaclErrorHandling)) { |
260 RunNaClIntegrationTest(FILE_PATH_LITERAL("pnacl_error_handling.html")); | 324 RunNaClIntegrationTest(FILE_PATH_LITERAL("pnacl_error_handling.html")); |
261 } | 325 } |
262 | 326 |
263 IN_PROC_BROWSER_TEST_F(NaClBrowserTestPnacl, | 327 IN_PROC_BROWSER_TEST_F(NaClBrowserTestPnacl, |
264 MAYBE_PNACL(PnaclNMFOptionsO0)) { | 328 MAYBE_PNACL(PnaclNMFOptionsO0)) { |
265 RunLoadTest(FILE_PATH_LITERAL("pnacl_options.html?use_nmf=o_0")); | 329 RunLoadTest(FILE_PATH_LITERAL("pnacl_options.html?use_nmf=o_0")); |
266 } | 330 } |
267 | 331 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 } | 437 } |
374 }; | 438 }; |
375 | 439 |
376 // TODO(ncbray) support glibc and PNaCl | 440 // TODO(ncbray) support glibc and PNaCl |
377 IN_PROC_BROWSER_TEST_F(NaClBrowserTestNewlibExtension, MimeHandler) { | 441 IN_PROC_BROWSER_TEST_F(NaClBrowserTestNewlibExtension, MimeHandler) { |
378 RunNaClIntegrationTest(FILE_PATH_LITERAL( | 442 RunNaClIntegrationTest(FILE_PATH_LITERAL( |
379 "ppapi_extension_mime_handler.html")); | 443 "ppapi_extension_mime_handler.html")); |
380 } | 444 } |
381 | 445 |
382 } // namespace | 446 } // namespace |
OLD | NEW |