| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <stdint.h> | 5 #include <stdint.h> |
| 6 #include <utility> |
| 6 | 7 |
| 7 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 8 #include "base/macros.h" | 9 #include "base/macros.h" |
| 9 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 10 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 11 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 12 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
| 13 #include "content/public/common/content_switches.h" | 14 #include "content/public/common/content_switches.h" |
| 14 #include "content/public/common/manifest.h" | 15 #include "content/public/common/manifest.h" |
| 15 #include "content/public/test/browser_test_utils.h" | 16 #include "content/public/test/browser_test_utils.h" |
| (...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 const net::test_server::HttpRequest& request) { | 491 const net::test_server::HttpRequest& request) { |
| 491 if (request.relative_url == "/index.html") { | 492 if (request.relative_url == "/index.html") { |
| 492 scoped_ptr<net::test_server::BasicHttpResponse> http_response( | 493 scoped_ptr<net::test_server::BasicHttpResponse> http_response( |
| 493 new net::test_server::BasicHttpResponse()); | 494 new net::test_server::BasicHttpResponse()); |
| 494 http_response->set_code(net::HTTP_OK); | 495 http_response->set_code(net::HTTP_OK); |
| 495 http_response->set_content_type("text/html"); | 496 http_response->set_content_type("text/html"); |
| 496 http_response->set_content( | 497 http_response->set_content( |
| 497 "<html><head>" | 498 "<html><head>" |
| 498 "<link rel=manifest crossorigin='use-credentials' href=/manifest.json>" | 499 "<link rel=manifest crossorigin='use-credentials' href=/manifest.json>" |
| 499 "</head></html>"); | 500 "</head></html>"); |
| 500 return http_response.Pass(); | 501 return std::move(http_response); |
| 501 } | 502 } |
| 502 | 503 |
| 503 const auto& iter = request.headers.find("Cookie"); | 504 const auto& iter = request.headers.find("Cookie"); |
| 504 if (iter == request.headers.end() || request.relative_url != "/manifest.json") | 505 if (iter == request.headers.end() || request.relative_url != "/manifest.json") |
| 505 return scoped_ptr<net::test_server::HttpResponse>(); | 506 return scoped_ptr<net::test_server::HttpResponse>(); |
| 506 | 507 |
| 507 scoped_ptr<net::test_server::BasicHttpResponse> http_response( | 508 scoped_ptr<net::test_server::BasicHttpResponse> http_response( |
| 508 new net::test_server::BasicHttpResponse()); | 509 new net::test_server::BasicHttpResponse()); |
| 509 http_response->set_code(net::HTTP_OK); | 510 http_response->set_code(net::HTTP_OK); |
| 510 http_response->set_content_type("application/json"); | 511 http_response->set_content_type("application/json"); |
| 511 http_response->set_content( | 512 http_response->set_content( |
| 512 base::StringPrintf("{\"name\": \"%s\"}", iter->second.c_str())); | 513 base::StringPrintf("{\"name\": \"%s\"}", iter->second.c_str())); |
| 513 | 514 |
| 514 return http_response.Pass(); | 515 return std::move(http_response); |
| 515 } | 516 } |
| 516 | 517 |
| 517 } // anonymous namespace | 518 } // anonymous namespace |
| 518 | 519 |
| 519 // This tests that when fetching a Manifest with 'use-credentials' set, the | 520 // This tests that when fetching a Manifest with 'use-credentials' set, the |
| 520 // cookies associated with it are passed along the request. | 521 // cookies associated with it are passed along the request. |
| 521 IN_PROC_BROWSER_TEST_F(ManifestBrowserTest, UseCredentialsSendCookies) { | 522 IN_PROC_BROWSER_TEST_F(ManifestBrowserTest, UseCredentialsSendCookies) { |
| 522 scoped_ptr<net::EmbeddedTestServer> custom_embedded_test_server( | 523 scoped_ptr<net::EmbeddedTestServer> custom_embedded_test_server( |
| 523 new net::EmbeddedTestServer()); | 524 new net::EmbeddedTestServer()); |
| 524 custom_embedded_test_server->RegisterRequestHandler( | 525 custom_embedded_test_server->RegisterRequestHandler( |
| (...skipping 25 matching lines...) Expand all Loading... |
| 550 | 551 |
| 551 scoped_ptr<net::test_server::HttpResponse> CustomHandleRequestForNoCookies( | 552 scoped_ptr<net::test_server::HttpResponse> CustomHandleRequestForNoCookies( |
| 552 const net::test_server::HttpRequest& request) { | 553 const net::test_server::HttpRequest& request) { |
| 553 if (request.relative_url == "/index.html") { | 554 if (request.relative_url == "/index.html") { |
| 554 scoped_ptr<net::test_server::BasicHttpResponse> http_response( | 555 scoped_ptr<net::test_server::BasicHttpResponse> http_response( |
| 555 new net::test_server::BasicHttpResponse()); | 556 new net::test_server::BasicHttpResponse()); |
| 556 http_response->set_code(net::HTTP_OK); | 557 http_response->set_code(net::HTTP_OK); |
| 557 http_response->set_content_type("text/html"); | 558 http_response->set_content_type("text/html"); |
| 558 http_response->set_content( | 559 http_response->set_content( |
| 559 "<html><head><link rel=manifest href=/manifest.json></head></html>"); | 560 "<html><head><link rel=manifest href=/manifest.json></head></html>"); |
| 560 return http_response.Pass(); | 561 return std::move(http_response); |
| 561 } | 562 } |
| 562 | 563 |
| 563 const auto& iter = request.headers.find("Cookie"); | 564 const auto& iter = request.headers.find("Cookie"); |
| 564 if (iter != request.headers.end() || request.relative_url != "/manifest.json") | 565 if (iter != request.headers.end() || request.relative_url != "/manifest.json") |
| 565 return scoped_ptr<net::test_server::HttpResponse>(); | 566 return scoped_ptr<net::test_server::HttpResponse>(); |
| 566 | 567 |
| 567 scoped_ptr<net::test_server::BasicHttpResponse> http_response( | 568 scoped_ptr<net::test_server::BasicHttpResponse> http_response( |
| 568 new net::test_server::BasicHttpResponse()); | 569 new net::test_server::BasicHttpResponse()); |
| 569 http_response->set_code(net::HTTP_OK); | 570 http_response->set_code(net::HTTP_OK); |
| 570 http_response->set_content_type("application/json"); | 571 http_response->set_content_type("application/json"); |
| 571 http_response->set_content("{\"name\": \"no cookies\"}"); | 572 http_response->set_content("{\"name\": \"no cookies\"}"); |
| 572 | 573 |
| 573 return http_response.Pass(); | 574 return std::move(http_response); |
| 574 } | 575 } |
| 575 | 576 |
| 576 } // anonymous namespace | 577 } // anonymous namespace |
| 577 | 578 |
| 578 // This tests that when fetching a Manifest without 'use-credentials' set, the | 579 // This tests that when fetching a Manifest without 'use-credentials' set, the |
| 579 // cookies associated with it are not passed along the request. | 580 // cookies associated with it are not passed along the request. |
| 580 IN_PROC_BROWSER_TEST_F(ManifestBrowserTest, NoUseCredentialsNoCookies) { | 581 IN_PROC_BROWSER_TEST_F(ManifestBrowserTest, NoUseCredentialsNoCookies) { |
| 581 scoped_ptr<net::EmbeddedTestServer> custom_embedded_test_server( | 582 scoped_ptr<net::EmbeddedTestServer> custom_embedded_test_server( |
| 582 new net::EmbeddedTestServer()); | 583 new net::EmbeddedTestServer()); |
| 583 custom_embedded_test_server->RegisterRequestHandler( | 584 custom_embedded_test_server->RegisterRequestHandler( |
| (...skipping 15 matching lines...) Expand all Loading... |
| 599 HasManifestAndWait(); | 600 HasManifestAndWait(); |
| 600 EXPECT_TRUE(has_manifest()); | 601 EXPECT_TRUE(has_manifest()); |
| 601 EXPECT_EQ(0u, console_error_count()); | 602 EXPECT_EQ(0u, console_error_count()); |
| 602 | 603 |
| 603 // The custom embedded test server will fill set the name to 'no cookies' if | 604 // The custom embedded test server will fill set the name to 'no cookies' if |
| 604 // it did not find cookies. | 605 // it did not find cookies. |
| 605 EXPECT_TRUE(base::EqualsASCII(manifest().name.string(), "no cookies")); | 606 EXPECT_TRUE(base::EqualsASCII(manifest().name.string(), "no cookies")); |
| 606 } | 607 } |
| 607 | 608 |
| 608 } // namespace content | 609 } // namespace content |
| OLD | NEW |