Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(343)

Side by Side Diff: chrome/browser/extensions/app_background_page_apitest.cc

Issue 655063002: Use uint16 for port numbers more pervasively. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert bad change Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "base/path_service.h" 5 #include "base/path_service.h"
6 #include "base/strings/stringprintf.h" 6 #include "base/strings/stringprintf.h"
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/background/background_contents_service.h" 8 #include "chrome/browser/background/background_contents_service.h"
9 #include "chrome/browser/background/background_contents_service_factory.h" 9 #include "chrome/browser/background/background_contents_service_factory.h"
10 #include "chrome/browser/background/background_mode_manager.h" 10 #include "chrome/browser/background/background_mode_manager.h"
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 std::string app_manifest = base::StringPrintf( 219 std::string app_manifest = base::StringPrintf(
220 "{" 220 "{"
221 " \"name\": \"App\"," 221 " \"name\": \"App\","
222 " \"version\": \"0.1\"," 222 " \"version\": \"0.1\","
223 " \"manifest_version\": 2," 223 " \"manifest_version\": 2,"
224 " \"app\": {" 224 " \"app\": {"
225 " \"urls\": [" 225 " \"urls\": ["
226 " \"http://a.com/\"" 226 " \"http://a.com/\""
227 " ]," 227 " ],"
228 " \"launch\": {" 228 " \"launch\": {"
229 " \"web_url\": \"http://a.com:%d/\"" 229 " \"web_url\": \"http://a.com:%u/\""
230 " }" 230 " }"
231 " }," 231 " },"
232 " \"permissions\": [\"background\"]" 232 " \"permissions\": [\"background\"]"
233 "}", 233 "}",
234 embedded_test_server()->port()); 234 embedded_test_server()->port());
235 235
236 base::FilePath app_dir; 236 base::FilePath app_dir;
237 ASSERT_TRUE(CreateApp(app_manifest, &app_dir)); 237 ASSERT_TRUE(CreateApp(app_manifest, &app_dir));
238 ASSERT_TRUE(LoadExtension(app_dir)); 238 ASSERT_TRUE(LoadExtension(app_dir));
239 // Background mode should not be active until a background page is created. 239 // Background mode should not be active until a background page is created.
(...skipping 12 matching lines...) Expand all
252 std::string app_manifest = base::StringPrintf( 252 std::string app_manifest = base::StringPrintf(
253 "{" 253 "{"
254 " \"name\": \"App\"," 254 " \"name\": \"App\","
255 " \"version\": \"0.1\"," 255 " \"version\": \"0.1\","
256 " \"manifest_version\": 2," 256 " \"manifest_version\": 2,"
257 " \"app\": {" 257 " \"app\": {"
258 " \"urls\": [" 258 " \"urls\": ["
259 " \"http://a.com/\"" 259 " \"http://a.com/\""
260 " ]," 260 " ],"
261 " \"launch\": {" 261 " \"launch\": {"
262 " \"web_url\": \"http://a.com:%d/\"" 262 " \"web_url\": \"http://a.com:%u/\""
263 " }" 263 " }"
264 " }" 264 " }"
265 "}", 265 "}",
266 embedded_test_server()->port()); 266 embedded_test_server()->port());
267 267
268 base::FilePath app_dir; 268 base::FilePath app_dir;
269 ASSERT_TRUE(CreateApp(app_manifest, &app_dir)); 269 ASSERT_TRUE(CreateApp(app_manifest, &app_dir));
270 ASSERT_TRUE(LoadExtension(app_dir)); 270 ASSERT_TRUE(LoadExtension(app_dir));
271 ASSERT_TRUE(RunExtensionTest("app_background_page/lacks_permission")) 271 ASSERT_TRUE(RunExtensionTest("app_background_page/lacks_permission"))
272 << message_; 272 << message_;
273 ASSERT_TRUE(WaitForBackgroundMode(false)); 273 ASSERT_TRUE(WaitForBackgroundMode(false));
274 } 274 }
275 275
276 IN_PROC_BROWSER_TEST_F(AppBackgroundPageApiTest, ManifestBackgroundPage) { 276 IN_PROC_BROWSER_TEST_F(AppBackgroundPageApiTest, ManifestBackgroundPage) {
277 host_resolver()->AddRule("a.com", "127.0.0.1"); 277 host_resolver()->AddRule("a.com", "127.0.0.1");
278 ASSERT_TRUE(StartEmbeddedTestServer()); 278 ASSERT_TRUE(StartEmbeddedTestServer());
279 279
280 std::string app_manifest = base::StringPrintf( 280 std::string app_manifest = base::StringPrintf(
281 "{" 281 "{"
282 " \"name\": \"App\"," 282 " \"name\": \"App\","
283 " \"version\": \"0.1\"," 283 " \"version\": \"0.1\","
284 " \"manifest_version\": 2," 284 " \"manifest_version\": 2,"
285 " \"app\": {" 285 " \"app\": {"
286 " \"urls\": [" 286 " \"urls\": ["
287 " \"http://a.com/\"" 287 " \"http://a.com/\""
288 " ]," 288 " ],"
289 " \"launch\": {" 289 " \"launch\": {"
290 " \"web_url\": \"http://a.com:%d/\"" 290 " \"web_url\": \"http://a.com:%u/\""
291 " }" 291 " }"
292 " }," 292 " },"
293 " \"permissions\": [\"background\"]," 293 " \"permissions\": [\"background\"],"
294 " \"background\": {" 294 " \"background\": {"
295 " \"page\": \"http://a.com:%d/test.html\"" 295 " \"page\": \"http://a.com:%u/test.html\""
296 " }" 296 " }"
297 "}", 297 "}",
298 embedded_test_server()->port(), 298 embedded_test_server()->port(),
299 embedded_test_server()->port()); 299 embedded_test_server()->port());
300 300
301 base::FilePath app_dir; 301 base::FilePath app_dir;
302 ASSERT_TRUE(CreateApp(app_manifest, &app_dir)); 302 ASSERT_TRUE(CreateApp(app_manifest, &app_dir));
303 // Background mode should not be active now because no background app was 303 // Background mode should not be active now because no background app was
304 // loaded. 304 // loaded.
305 ASSERT_TRUE(LoadExtension(app_dir)); 305 ASSERT_TRUE(LoadExtension(app_dir));
(...skipping 27 matching lines...) Expand all
333 std::string app_manifest = base::StringPrintf( 333 std::string app_manifest = base::StringPrintf(
334 "{" 334 "{"
335 " \"name\": \"App\"," 335 " \"name\": \"App\","
336 " \"version\": \"0.1\"," 336 " \"version\": \"0.1\","
337 " \"manifest_version\": 2," 337 " \"manifest_version\": 2,"
338 " \"app\": {" 338 " \"app\": {"
339 " \"urls\": [" 339 " \"urls\": ["
340 " \"http://a.com/\"" 340 " \"http://a.com/\""
341 " ]," 341 " ],"
342 " \"launch\": {" 342 " \"launch\": {"
343 " \"web_url\": \"http://a.com:%d/test.html\"" 343 " \"web_url\": \"http://a.com:%u/test.html\""
344 " }" 344 " }"
345 " }," 345 " },"
346 " \"permissions\": [\"background\"]," 346 " \"permissions\": [\"background\"],"
347 " \"background\": {" 347 " \"background\": {"
348 " \"allow_js_access\": false" 348 " \"allow_js_access\": false"
349 " }" 349 " }"
350 "}", 350 "}",
351 embedded_test_server()->port()); 351 embedded_test_server()->port());
352 352
353 base::FilePath app_dir; 353 base::FilePath app_dir;
(...skipping 23 matching lines...) Expand all
377 std::string app_manifest = base::StringPrintf( 377 std::string app_manifest = base::StringPrintf(
378 "{" 378 "{"
379 " \"name\": \"App\"," 379 " \"name\": \"App\","
380 " \"version\": \"0.1\"," 380 " \"version\": \"0.1\","
381 " \"manifest_version\": 2," 381 " \"manifest_version\": 2,"
382 " \"app\": {" 382 " \"app\": {"
383 " \"urls\": [" 383 " \"urls\": ["
384 " \"http://a.com/\"" 384 " \"http://a.com/\""
385 " ]," 385 " ],"
386 " \"launch\": {" 386 " \"launch\": {"
387 " \"web_url\": \"http://a.com:%d/\"" 387 " \"web_url\": \"http://a.com:%u/\""
388 " }" 388 " }"
389 " }," 389 " },"
390 " \"permissions\": [\"background\"]," 390 " \"permissions\": [\"background\"],"
391 " \"background\": {" 391 " \"background\": {"
392 " \"page\": \"http://a.com:%d/bg.html\"," 392 " \"page\": \"http://a.com:%u/bg.html\","
393 " \"allow_js_access\": false" 393 " \"allow_js_access\": false"
394 " }" 394 " }"
395 "}", 395 "}",
396 embedded_test_server()->port(), 396 embedded_test_server()->port(),
397 embedded_test_server()->port()); 397 embedded_test_server()->port());
398 398
399 base::FilePath app_dir; 399 base::FilePath app_dir;
400 ASSERT_TRUE(CreateApp(app_manifest, &app_dir)); 400 ASSERT_TRUE(CreateApp(app_manifest, &app_dir));
401 ASSERT_TRUE(LoadExtension(app_dir)); 401 ASSERT_TRUE(LoadExtension(app_dir));
402 402
(...skipping 14 matching lines...) Expand all
417 std::string app_manifest = base::StringPrintf( 417 std::string app_manifest = base::StringPrintf(
418 "{" 418 "{"
419 " \"name\": \"App\"," 419 " \"name\": \"App\","
420 " \"version\": \"0.1\"," 420 " \"version\": \"0.1\","
421 " \"manifest_version\": 2," 421 " \"manifest_version\": 2,"
422 " \"app\": {" 422 " \"app\": {"
423 " \"urls\": [" 423 " \"urls\": ["
424 " \"http://a.com/\"" 424 " \"http://a.com/\""
425 " ]," 425 " ],"
426 " \"launch\": {" 426 " \"launch\": {"
427 " \"web_url\": \"http://a.com:%d/\"" 427 " \"web_url\": \"http://a.com:%u/\""
428 " }" 428 " }"
429 " }," 429 " },"
430 " \"permissions\": [\"background\"]" 430 " \"permissions\": [\"background\"]"
431 "}", 431 "}",
432 embedded_test_server()->port()); 432 embedded_test_server()->port());
433 433
434 base::FilePath app_dir; 434 base::FilePath app_dir;
435 ASSERT_TRUE(CreateApp(app_manifest, &app_dir)); 435 ASSERT_TRUE(CreateApp(app_manifest, &app_dir));
436 ASSERT_TRUE(LoadExtension(app_dir)); 436 ASSERT_TRUE(LoadExtension(app_dir));
437 const Extension* extension = GetSingleLoadedExtension(); 437 const Extension* extension = GetSingleLoadedExtension();
438 ASSERT_TRUE(RunExtensionTest("app_background_page/two_pages")) << message_; 438 ASSERT_TRUE(RunExtensionTest("app_background_page/two_pages")) << message_;
439 UnloadExtension(extension->id()); 439 UnloadExtension(extension->id());
440 } 440 }
441 441
442 IN_PROC_BROWSER_TEST_F(AppBackgroundPageApiTest, OpenTwoPagesWithManifest) { 442 IN_PROC_BROWSER_TEST_F(AppBackgroundPageApiTest, OpenTwoPagesWithManifest) {
443 host_resolver()->AddRule("a.com", "127.0.0.1"); 443 host_resolver()->AddRule("a.com", "127.0.0.1");
444 ASSERT_TRUE(StartEmbeddedTestServer()); 444 ASSERT_TRUE(StartEmbeddedTestServer());
445 445
446 std::string app_manifest = base::StringPrintf( 446 std::string app_manifest = base::StringPrintf(
447 "{" 447 "{"
448 " \"name\": \"App\"," 448 " \"name\": \"App\","
449 " \"version\": \"0.1\"," 449 " \"version\": \"0.1\","
450 " \"manifest_version\": 2," 450 " \"manifest_version\": 2,"
451 " \"app\": {" 451 " \"app\": {"
452 " \"urls\": [" 452 " \"urls\": ["
453 " \"http://a.com/\"" 453 " \"http://a.com/\""
454 " ]," 454 " ],"
455 " \"launch\": {" 455 " \"launch\": {"
456 " \"web_url\": \"http://a.com:%d/\"" 456 " \"web_url\": \"http://a.com:%u/\""
457 " }" 457 " }"
458 " }," 458 " },"
459 " \"background\": {" 459 " \"background\": {"
460 " \"page\": \"http://a.com:%d/bg.html\"" 460 " \"page\": \"http://a.com:%u/bg.html\""
461 " }," 461 " },"
462 " \"permissions\": [\"background\"]" 462 " \"permissions\": [\"background\"]"
463 "}", 463 "}",
464 embedded_test_server()->port(), 464 embedded_test_server()->port(),
465 embedded_test_server()->port()); 465 embedded_test_server()->port());
466 466
467 base::FilePath app_dir; 467 base::FilePath app_dir;
468 ASSERT_TRUE(CreateApp(app_manifest, &app_dir)); 468 ASSERT_TRUE(CreateApp(app_manifest, &app_dir));
469 ASSERT_TRUE(LoadExtension(app_dir)); 469 ASSERT_TRUE(LoadExtension(app_dir));
470 const Extension* extension = GetSingleLoadedExtension(); 470 const Extension* extension = GetSingleLoadedExtension();
(...skipping 10 matching lines...) Expand all
481 std::string app_manifest = base::StringPrintf( 481 std::string app_manifest = base::StringPrintf(
482 "{" 482 "{"
483 " \"name\": \"App\"," 483 " \"name\": \"App\","
484 " \"version\": \"0.1\"," 484 " \"version\": \"0.1\","
485 " \"manifest_version\": 2," 485 " \"manifest_version\": 2,"
486 " \"app\": {" 486 " \"app\": {"
487 " \"urls\": [" 487 " \"urls\": ["
488 " \"http://a.com/\"" 488 " \"http://a.com/\""
489 " ]," 489 " ],"
490 " \"launch\": {" 490 " \"launch\": {"
491 " \"web_url\": \"http://a.com:%d/\"" 491 " \"web_url\": \"http://a.com:%u/\""
492 " }" 492 " }"
493 " }," 493 " },"
494 " \"background\": { \"page\": \"http://a.com:%d/extensions/api_test/" 494 " \"background\": { \"page\": \"http://a.com:%u/extensions/api_test/"
495 "app_background_page/bg_open/bg_open_bg.html\" }," 495 "app_background_page/bg_open/bg_open_bg.html\" },"
496 " \"permissions\": [\"background\"]" 496 " \"permissions\": [\"background\"]"
497 "}", 497 "}",
498 embedded_test_server()->port(), 498 embedded_test_server()->port(),
499 embedded_test_server()->port()); 499 embedded_test_server()->port());
500 500
501 base::FilePath app_dir; 501 base::FilePath app_dir;
502 ASSERT_TRUE(CreateApp(app_manifest, &app_dir)); 502 ASSERT_TRUE(CreateApp(app_manifest, &app_dir));
503 ASSERT_TRUE(LoadExtension(app_dir)); 503 ASSERT_TRUE(LoadExtension(app_dir));
504 ASSERT_TRUE(RunExtensionTest("app_background_page/bg_open")) << message_; 504 ASSERT_TRUE(RunExtensionTest("app_background_page/bg_open")) << message_;
505 } 505 }
506 506
507 IN_PROC_BROWSER_TEST_F(AppBackgroundPageApiTest, DISABLED_OpenThenClose) { 507 IN_PROC_BROWSER_TEST_F(AppBackgroundPageApiTest, DISABLED_OpenThenClose) {
508 host_resolver()->AddRule("a.com", "127.0.0.1"); 508 host_resolver()->AddRule("a.com", "127.0.0.1");
509 ASSERT_TRUE(StartEmbeddedTestServer()); 509 ASSERT_TRUE(StartEmbeddedTestServer());
510 510
511 std::string app_manifest = base::StringPrintf( 511 std::string app_manifest = base::StringPrintf(
512 "{" 512 "{"
513 " \"name\": \"App\"," 513 " \"name\": \"App\","
514 " \"version\": \"0.1\"," 514 " \"version\": \"0.1\","
515 " \"manifest_version\": 2," 515 " \"manifest_version\": 2,"
516 " \"app\": {" 516 " \"app\": {"
517 " \"urls\": [" 517 " \"urls\": ["
518 " \"http://a.com/\"" 518 " \"http://a.com/\""
519 " ]," 519 " ],"
520 " \"launch\": {" 520 " \"launch\": {"
521 " \"web_url\": \"http://a.com:%d/\"" 521 " \"web_url\": \"http://a.com:%u/\""
522 " }" 522 " }"
523 " }," 523 " },"
524 " \"permissions\": [\"background\"]" 524 " \"permissions\": [\"background\"]"
525 "}", 525 "}",
526 embedded_test_server()->port()); 526 embedded_test_server()->port());
527 527
528 base::FilePath app_dir; 528 base::FilePath app_dir;
529 ASSERT_TRUE(CreateApp(app_manifest, &app_dir)); 529 ASSERT_TRUE(CreateApp(app_manifest, &app_dir));
530 ASSERT_TRUE(LoadExtension(app_dir)); 530 ASSERT_TRUE(LoadExtension(app_dir));
531 // There isn't a background page loaded initially. 531 // There isn't a background page loaded initially.
(...skipping 25 matching lines...) Expand all
557 std::string app_manifest = base::StringPrintf( 557 std::string app_manifest = base::StringPrintf(
558 "{" 558 "{"
559 " \"name\": \"App\"," 559 " \"name\": \"App\","
560 " \"version\": \"0.1\"," 560 " \"version\": \"0.1\","
561 " \"manifest_version\": 2," 561 " \"manifest_version\": 2,"
562 " \"app\": {" 562 " \"app\": {"
563 " \"urls\": [" 563 " \"urls\": ["
564 " \"http://a.com/\"" 564 " \"http://a.com/\""
565 " ]," 565 " ],"
566 " \"launch\": {" 566 " \"launch\": {"
567 " \"web_url\": \"http://a.com:%d/\"" 567 " \"web_url\": \"http://a.com:%u/\""
568 " }" 568 " }"
569 " }," 569 " },"
570 " \"permissions\": [\"background\"]," 570 " \"permissions\": [\"background\"],"
571 " \"background\": {" 571 " \"background\": {"
572 " \"page\": \"http://a.com:%d/test.html\"" 572 " \"page\": \"http://a.com:%u/test.html\""
573 " }" 573 " }"
574 "}", 574 "}",
575 embedded_test_server()->port(), 575 embedded_test_server()->port(),
576 embedded_test_server()->port()); 576 embedded_test_server()->port());
577 577
578 base::FilePath app_dir; 578 base::FilePath app_dir;
579 ASSERT_TRUE(CreateApp(app_manifest, &app_dir)); 579 ASSERT_TRUE(CreateApp(app_manifest, &app_dir));
580 // Background mode should not be active now because no background app was 580 // Background mode should not be active now because no background app was
581 // loaded. 581 // loaded.
582 ASSERT_TRUE(LoadExtension(app_dir)); 582 ASSERT_TRUE(LoadExtension(app_dir));
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 extensions::ProcessManager::Get(browser()->profile()); 642 extensions::ProcessManager::Get(browser()->profile());
643 ImpulseCallbackCounter idle_impulse_counter(manager, extension()->id()); 643 ImpulseCallbackCounter idle_impulse_counter(manager, extension()->id());
644 EXPECT_TRUE(nacl_modules_loaded.WaitUntilSatisfied()); 644 EXPECT_TRUE(nacl_modules_loaded.WaitUntilSatisfied());
645 645
646 manager->SetKeepaliveImpulseDecrementCallbackForTesting( 646 manager->SetKeepaliveImpulseDecrementCallbackForTesting(
647 idle_impulse_counter.SetGoalAndGetCallback(1)); 647 idle_impulse_counter.SetGoalAndGetCallback(1));
648 nacl_modules_loaded.Reply("be idle"); 648 nacl_modules_loaded.Reply("be idle");
649 idle_impulse_counter.Wait(); 649 idle_impulse_counter.Wait();
650 #endif 650 #endif
651 } 651 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/web_navigation/web_navigation_apitest.cc ('k') | chrome/browser/net/dns_probe_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698