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 "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
10 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 11 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
11 #include "chrome/common/chrome_paths.h" | 12 #include "chrome/common/chrome_paths.h" |
12 #include "chrome/test/base/ui_test_utils.h" | 13 #include "chrome/test/base/ui_test_utils.h" |
13 #include "chrome/test/nacl/nacl_browsertest_util.h" | 14 #include "chrome/test/nacl/nacl_browsertest_util.h" |
14 #include "content/public/browser/web_contents.h" | 15 #include "content/public/browser/web_contents.h" |
15 #include "net/test/embedded_test_server/embedded_test_server.h" | 16 #include "net/test/embedded_test_server/embedded_test_server.h" |
16 #include "net/test/embedded_test_server/http_request.h" | 17 #include "net/test/embedded_test_server/http_request.h" |
17 #include "net/test/embedded_test_server/http_response.h" | 18 #include "net/test/embedded_test_server/http_response.h" |
18 | 19 |
(...skipping 19 matching lines...) Expand all Loading... |
38 } | 39 } |
39 | 40 |
40 void PnaclHeaderTest::RunLoadTest(const std::string& url, | 41 void PnaclHeaderTest::RunLoadTest(const std::string& url, |
41 int expected_noncors, | 42 int expected_noncors, |
42 int expected_cors) { | 43 int expected_cors) { |
43 StartServer(); | 44 StartServer(); |
44 LoadTestMessageHandler handler; | 45 LoadTestMessageHandler handler; |
45 content::JavascriptTestObserver observer( | 46 content::JavascriptTestObserver observer( |
46 browser()->tab_strip_model()->GetActiveWebContents(), | 47 browser()->tab_strip_model()->GetActiveWebContents(), |
47 &handler); | 48 &handler); |
| 49 |
| 50 // Make sure this is able to do a pexe fetch, even without access |
| 51 // to the PNaCl component files (make DIR_PNACL_COMPONENT empty). |
| 52 // The pexe fetch that is done with special headers must be able to |
| 53 // start before the component files are on disk. This is because it |
| 54 // is the pexe fetch that helps trigger an on-demand installation |
| 55 // which installs the files to disk (if that hasn't already happened |
| 56 // in the background). |
| 57 base::ScopedPathOverride component_dir(chrome::DIR_PNACL_COMPONENT); |
| 58 |
48 ui_test_utils::NavigateToURL(browser(), embedded_test_server()->GetURL(url)); | 59 ui_test_utils::NavigateToURL(browser(), embedded_test_server()->GetURL(url)); |
49 // Wait until the NMF and pexe are also loaded, not just the HTML. | 60 // Wait until the NMF and pexe are also loaded, not just the HTML. |
50 // Do this by waiting till the LoadTestMessageHandler responds. | 61 // Do this by waiting till the LoadTestMessageHandler responds. |
51 EXPECT_TRUE(observer.Run()) << handler.error_message(); | 62 EXPECT_TRUE(observer.Run()) << handler.error_message(); |
52 EXPECT_TRUE(handler.test_passed()) << "Test failed."; | 63 EXPECT_TRUE(handler.test_passed()) << "Test failed."; |
53 EXPECT_EQ(expected_noncors, noncors_loads_); | 64 EXPECT_EQ(expected_noncors, noncors_loads_); |
54 EXPECT_EQ(expected_cors, cors_loads_); | 65 EXPECT_EQ(expected_cors, cors_loads_); |
55 } | 66 } |
56 | 67 |
57 scoped_ptr<HttpResponse> PnaclHeaderTest::WatchForPexeFetch( | 68 scoped_ptr<HttpResponse> PnaclHeaderTest::WatchForPexeFetch( |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 http_response->set_code(net::HTTP_NOT_FOUND); | 106 http_response->set_code(net::HTTP_NOT_FOUND); |
96 http_response->set_content("PEXE ... not found"); | 107 http_response->set_content("PEXE ... not found"); |
97 http_response->set_content_type("application/octet-stream"); | 108 http_response->set_content_type("application/octet-stream"); |
98 return http_response.PassAs<HttpResponse>(); | 109 return http_response.PassAs<HttpResponse>(); |
99 } | 110 } |
100 | 111 |
101 IN_PROC_BROWSER_TEST_F(PnaclHeaderTest, TestHasPnaclHeader) { | 112 IN_PROC_BROWSER_TEST_F(PnaclHeaderTest, TestHasPnaclHeader) { |
102 // Load 2 pexes, one same origin and one cross orgin. | 113 // Load 2 pexes, one same origin and one cross orgin. |
103 RunLoadTest("/nacl/pnacl_request_header/pnacl_request_header.html", 1, 1); | 114 RunLoadTest("/nacl/pnacl_request_header/pnacl_request_header.html", 1, 1); |
104 } | 115 } |
OLD | NEW |