OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/renderer/chrome_content_renderer_client.h" | 5 #include "chrome/renderer/chrome_content_renderer_client.h" |
6 | 6 |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/common/extensions/extension.h" | 8 #include "chrome/common/extensions/extension.h" |
9 #include "chrome/common/extensions/extension_builder.h" | 9 #include "chrome/common/extensions/extension_builder.h" |
10 #include "chrome/common/extensions/extension_manifest_constants.h" | 10 #include "chrome/common/extensions/extension_manifest_constants.h" |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 GURL("filesystem:chrome-extension://" + | 335 GURL("filesystem:chrome-extension://" + |
336 kRandomExtensionID + "/foo"))); | 336 kRandomExtensionID + "/foo"))); |
337 EXPECT_TRUE(client.IsRequestOSFileHandleAllowedForURL( | 337 EXPECT_TRUE(client.IsRequestOSFileHandleAllowedForURL( |
338 GURL("filesystem:http://127.0.0.1/foo"))); | 338 GURL("filesystem:http://127.0.0.1/foo"))); |
339 EXPECT_FALSE(client.IsRequestOSFileHandleAllowedForURL( | 339 EXPECT_FALSE(client.IsRequestOSFileHandleAllowedForURL( |
340 GURL("http://127.0.0.1/foo"))); | 340 GURL("http://127.0.0.1/foo"))); |
341 EXPECT_TRUE(client.IsRequestOSFileHandleAllowedForURL( | 341 EXPECT_TRUE(client.IsRequestOSFileHandleAllowedForURL( |
342 GURL("filesystem:http://192.168.0.1/foo"))); | 342 GURL("filesystem:http://192.168.0.1/foo"))); |
343 } | 343 } |
344 | 344 |
| 345 TEST_F(ChromeContentRendererClientTest, SetOriginForSuggestionRequest) { |
| 346 ChromeContentRendererClient client; |
| 347 // The origin parameter should be set from top_url. |
| 348 EXPECT_EQ(GURL("chrome-search://suggestion/result.js?" |
| 349 "origin=http://sanity.example.com"), |
| 350 client.SetOriginForSuggestionRequest( |
| 351 GURL("chrome-search://suggestion/result.js"), |
| 352 GURL("http://sanity.example.com"))); |
| 353 // Any existing &origin parameter should be replaced by origin=top_url. |
| 354 EXPECT_EQ(GURL("chrome-search://suggestion/result.js?" |
| 355 "origin=http://evil.example.com"), |
| 356 client.SetOriginForSuggestionRequest( |
| 357 GURL("chrome-search://suggestion/result.js?" |
| 358 "origin=http://good.example.com/"), |
| 359 GURL("http://evil.example.com"))); |
| 360 // Multiple &origin parameters should also be replaced by origin=top_url. |
| 361 EXPECT_EQ(GURL("chrome-search://suggestion/result.js?" |
| 362 "origin=http://evil.example.com"), |
| 363 client.SetOriginForSuggestionRequest( |
| 364 GURL("chrome-search://suggestion/result.js?" |
| 365 "origin=http://good.example.com/&" |
| 366 "origin=http://better.example.com"), |
| 367 GURL("http://evil.example.com"))); |
| 368 // A malformed top_url should result in an empty origin. |
| 369 EXPECT_EQ(GURL("chrome-search://suggestion/result.js?origin="), |
| 370 client.SetOriginForSuggestionRequest( |
| 371 GURL("chrome-search://suggestion/result.js"), |
| 372 GURL("\"<script>alert('evil')</script>"))); |
| 373 } |
| 374 |
345 } // namespace chrome | 375 } // namespace chrome |
OLD | NEW |