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