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 #include "chrome/test/nacl/pnacl_header_test.h" | 5 #include "chrome/test/nacl/pnacl_header_test.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "base/test/scoped_path_override.h" | 9 #include "base/test/scoped_path_override.h" |
10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 } | 92 } |
93 | 93 |
94 scoped_ptr<HttpResponse> PnaclHeaderTest::WatchForPexeFetch( | 94 scoped_ptr<HttpResponse> PnaclHeaderTest::WatchForPexeFetch( |
95 const HttpRequest& request) { | 95 const HttpRequest& request) { |
96 // Avoid favicon.ico warning by giving it a dummy icon. | 96 // Avoid favicon.ico warning by giving it a dummy icon. |
97 if (request.relative_url.find("favicon.ico") != std::string::npos) { | 97 if (request.relative_url.find("favicon.ico") != std::string::npos) { |
98 scoped_ptr<BasicHttpResponse> http_response(new BasicHttpResponse()); | 98 scoped_ptr<BasicHttpResponse> http_response(new BasicHttpResponse()); |
99 http_response->set_code(net::HTTP_OK); | 99 http_response->set_code(net::HTTP_OK); |
100 http_response->set_content(""); | 100 http_response->set_content(""); |
101 http_response->set_content_type("application/octet-stream"); | 101 http_response->set_content_type("application/octet-stream"); |
102 return http_response.PassAs<HttpResponse>(); | 102 return http_response.Pass(); |
103 } | 103 } |
104 | 104 |
105 // Skip other non-pexe files and let ServeFilesFromDirectory handle it. | 105 // Skip other non-pexe files and let ServeFilesFromDirectory handle it. |
106 GURL absolute_url = embedded_test_server()->GetURL(request.relative_url); | 106 GURL absolute_url = embedded_test_server()->GetURL(request.relative_url); |
107 if (absolute_url.path().find(".pexe") == std::string::npos) | 107 if (absolute_url.path().find(".pexe") == std::string::npos) |
108 return scoped_ptr<HttpResponse>(); | 108 return scoped_ptr<HttpResponse>(); |
109 | 109 |
110 // For pexe files, check for the special Accept header, | 110 // For pexe files, check for the special Accept header, |
111 // along with the expected ResourceType of the URL request. | 111 // along with the expected ResourceType of the URL request. |
112 EXPECT_NE(0U, request.headers.count("Accept")); | 112 EXPECT_NE(0U, request.headers.count("Accept")); |
(...skipping 12 matching lines...) Expand all Loading... |
125 EXPECT_EQ(1U, request.headers.count("Origin")); | 125 EXPECT_EQ(1U, request.headers.count("Origin")); |
126 cors_loads_ += 1; | 126 cors_loads_ += 1; |
127 } | 127 } |
128 | 128 |
129 // After checking the header, just return a 404. We don't need to actually | 129 // After checking the header, just return a 404. We don't need to actually |
130 // compile and stopping with a 404 is faster. | 130 // compile and stopping with a 404 is faster. |
131 scoped_ptr<BasicHttpResponse> http_response(new BasicHttpResponse()); | 131 scoped_ptr<BasicHttpResponse> http_response(new BasicHttpResponse()); |
132 http_response->set_code(net::HTTP_NOT_FOUND); | 132 http_response->set_code(net::HTTP_NOT_FOUND); |
133 http_response->set_content("PEXE ... not found"); | 133 http_response->set_content("PEXE ... not found"); |
134 http_response->set_content_type("application/octet-stream"); | 134 http_response->set_content_type("application/octet-stream"); |
135 return http_response.PassAs<HttpResponse>(); | 135 return http_response.Pass(); |
136 } | 136 } |
137 | 137 |
138 IN_PROC_BROWSER_TEST_F(PnaclHeaderTest, TestHasPnaclHeader) { | 138 IN_PROC_BROWSER_TEST_F(PnaclHeaderTest, TestHasPnaclHeader) { |
139 // Load 2 pexes, one same origin and one cross orgin. | 139 // Load 2 pexes, one same origin and one cross orgin. |
140 RunLoadTest("/nacl/pnacl_request_header/pnacl_request_header.html", 1, 1); | 140 RunLoadTest("/nacl/pnacl_request_header/pnacl_request_header.html", 1, 1); |
141 } | 141 } |
OLD | NEW |