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 "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
10 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 10 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 embedded_test_server()->RegisterRequestHandler( | 35 embedded_test_server()->RegisterRequestHandler( |
36 base::Bind(&PnaclHeaderTest::WatchForPexeFetch, base::Unretained(this))); | 36 base::Bind(&PnaclHeaderTest::WatchForPexeFetch, base::Unretained(this))); |
37 embedded_test_server()->ServeFilesFromDirectory(test_data_dir); | 37 embedded_test_server()->ServeFilesFromDirectory(test_data_dir); |
38 } | 38 } |
39 | 39 |
40 void PnaclHeaderTest::RunLoadTest(const std::string& url, | 40 void PnaclHeaderTest::RunLoadTest(const std::string& url, |
41 int expected_noncors, | 41 int expected_noncors, |
42 int expected_cors) { | 42 int expected_cors) { |
43 StartServer(); | 43 StartServer(); |
44 LoadTestMessageHandler handler; | 44 LoadTestMessageHandler handler; |
45 JavascriptTestObserver observer( | 45 content::JavascriptTestObserver observer( |
46 browser()->tab_strip_model()->GetActiveWebContents(), | 46 browser()->tab_strip_model()->GetActiveWebContents(), |
47 &handler); | 47 &handler); |
48 ui_test_utils::NavigateToURL(browser(), embedded_test_server()->GetURL(url)); | 48 ui_test_utils::NavigateToURL(browser(), embedded_test_server()->GetURL(url)); |
49 // Wait until the NMF and pexe are also loaded, not just the HTML. | 49 // Wait until the NMF and pexe are also loaded, not just the HTML. |
50 // Do this by waiting till the LoadTestMessageHandler responds. | 50 // Do this by waiting till the LoadTestMessageHandler responds. |
51 EXPECT_TRUE(observer.Run()) << handler.error_message(); | 51 EXPECT_TRUE(observer.Run()) << handler.error_message(); |
52 EXPECT_TRUE(handler.test_passed()) << "Test failed."; | 52 EXPECT_TRUE(handler.test_passed()) << "Test failed."; |
53 EXPECT_EQ(expected_noncors, noncors_loads_); | 53 EXPECT_EQ(expected_noncors, noncors_loads_); |
54 EXPECT_EQ(expected_cors, cors_loads_); | 54 EXPECT_EQ(expected_cors, cors_loads_); |
55 } | 55 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 http_response->set_code(net::HTTP_NOT_FOUND); | 95 http_response->set_code(net::HTTP_NOT_FOUND); |
96 http_response->set_content("PEXE ... not found"); | 96 http_response->set_content("PEXE ... not found"); |
97 http_response->set_content_type("application/octet-stream"); | 97 http_response->set_content_type("application/octet-stream"); |
98 return http_response.PassAs<HttpResponse>(); | 98 return http_response.PassAs<HttpResponse>(); |
99 } | 99 } |
100 | 100 |
101 IN_PROC_BROWSER_TEST_F(PnaclHeaderTest, TestHasPnaclHeader) { | 101 IN_PROC_BROWSER_TEST_F(PnaclHeaderTest, TestHasPnaclHeader) { |
102 // Load 2 pexes, one same origin and one cross orgin. | 102 // Load 2 pexes, one same origin and one cross orgin. |
103 RunLoadTest("/nacl/pnacl_request_header/pnacl_request_header.html", 1, 1); | 103 RunLoadTest("/nacl/pnacl_request_header/pnacl_request_header.html", 1, 1); |
104 } | 104 } |
OLD | NEW |