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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
7 #include "content/public/browser/web_contents.h" | 7 #include "content/public/browser/web_contents.h" |
8 #include "content/public/common/content_switches.h" | 8 #include "content/public/common/content_switches.h" |
9 #include "content/public/common/manifest.h" | 9 #include "content/public/common/manifest.h" |
10 #include "content/public/test/browser_test_utils.h" | 10 #include "content/public/test/browser_test_utils.h" |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 | 241 |
242 std::string manifest_url = cors_embedded_test_server()->GetURL( | 242 std::string manifest_url = cors_embedded_test_server()->GetURL( |
243 "/manifest/dummy-manifest.json").spec(); | 243 "/manifest/dummy-manifest.json").spec(); |
244 ASSERT_TRUE(content::ExecuteScript(shell()->web_contents(), | 244 ASSERT_TRUE(content::ExecuteScript(shell()->web_contents(), |
245 "setManifestTo('" + manifest_url + "')")); | 245 "setManifestTo('" + manifest_url + "')")); |
246 | 246 |
247 GetManifestAndWait(); | 247 GetManifestAndWait(); |
248 EXPECT_TRUE(manifest().IsEmpty()); | 248 EXPECT_TRUE(manifest().IsEmpty()); |
249 | 249 |
250 EXPECT_EQ(0u, console_error_count()); | 250 EXPECT_EQ(0u, console_error_count()); |
| 251 |
| 252 // The purpose of this second load is to make sure the first load is fully |
| 253 // finished. The first load will fail because of Access Control error but the |
| 254 // underlying Blink loader will continue fetching the file. There is no |
| 255 // reliable way to know when the fetch is finished from the browser test |
| 256 // except by fetching the same file from same origin, making it succeed when |
| 257 // it is actually fully loaded. |
| 258 manifest_url = |
| 259 embedded_test_server()->GetURL("/manifest/dummy-manifest.json").spec(); |
| 260 ASSERT_TRUE(content::ExecuteScript(shell()->web_contents(), |
| 261 "setManifestTo('" + manifest_url + "')")); |
| 262 GetManifestAndWait(); |
251 } | 263 } |
252 | 264 |
253 // If a page's manifest lives in a different origin, it should be accessible if | 265 // If a page's manifest lives in a different origin, it should be accessible if |
254 // it has valid access controls headers. | 266 // it has valid access controls headers. |
255 IN_PROC_BROWSER_TEST_F(ManifestBrowserTest, CORSManifestWithAcessControls) { | 267 IN_PROC_BROWSER_TEST_F(ManifestBrowserTest, CORSManifestWithAcessControls) { |
256 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 268 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
257 ASSERT_TRUE(cors_embedded_test_server()->InitializeAndWaitUntilReady()); | 269 ASSERT_TRUE(cors_embedded_test_server()->InitializeAndWaitUntilReady()); |
258 ASSERT_NE(embedded_test_server()->port(), | 270 ASSERT_NE(embedded_test_server()->port(), |
259 cors_embedded_test_server()->port()); | 271 cors_embedded_test_server()->port()); |
260 | 272 |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 "document.body.appendChild(a); a.click();")); | 409 "document.body.appendChild(a); a.click();")); |
398 navigation_observer.Wait(); | 410 navigation_observer.Wait(); |
399 } | 411 } |
400 | 412 |
401 GetManifestAndWait(); | 413 GetManifestAndWait(); |
402 EXPECT_FALSE(manifest().IsEmpty()); | 414 EXPECT_FALSE(manifest().IsEmpty()); |
403 EXPECT_EQ(0u, console_error_count()); | 415 EXPECT_EQ(0u, console_error_count()); |
404 } | 416 } |
405 | 417 |
406 } // namespace content | 418 } // namespace content |
OLD | NEW |