| 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/browser/search/iframe_source.h" | 5 #include "chrome/browser/search/iframe_source.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/ref_counted_memory.h" | 8 #include "base/memory/ref_counted_memory.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 11 #include "chrome/browser/search/instant_io_context.h" | 11 #include "chrome/browser/search/instant_io_context.h" |
| 12 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
| 13 #include "content/public/browser/resource_request_info.h" | 13 #include "content/public/browser/resource_request_info.h" |
| 14 #include "content/public/test/mock_resource_context.h" | 14 #include "content/public/test/mock_resource_context.h" |
| 15 #include "content/public/test/test_browser_thread_bundle.h" | 15 #include "content/public/test/test_browser_thread_bundle.h" |
| 16 #include "grit/browser_resources.h" | 16 #include "grit/browser_resources.h" |
| 17 #include "ipc/ipc_message.h" | 17 #include "ipc/ipc_message.h" |
| 18 #include "net/base/request_priority.h" | 18 #include "net/base/request_priority.h" |
| 19 #include "net/url_request/url_request.h" | 19 #include "net/url_request/url_request.h" |
| 20 #include "net/url_request/url_request_context.h" | 20 #include "net/url_request/url_request_context.h" |
| 21 #include "net/url_request/url_request_test_util.h" | 21 #include "net/url_request/url_request_test_util.h" |
| 22 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
| 23 #include "url/gurl.h" | 23 #include "url/gurl.h" |
| 24 | 24 |
| 25 using content::ResourceType; |
| 26 |
| 25 const int kNonInstantRendererPID = 0; | 27 const int kNonInstantRendererPID = 0; |
| 26 const char kNonInstantOrigin[] = "http://evil"; | 28 const char kNonInstantOrigin[] = "http://evil"; |
| 27 const int kInstantRendererPID = 1; | 29 const int kInstantRendererPID = 1; |
| 28 const char kInstantOrigin[] = "chrome-search://instant"; | 30 const char kInstantOrigin[] = "chrome-search://instant"; |
| 29 const int kInvalidRendererPID = 42; | 31 const int kInvalidRendererPID = 42; |
| 30 | 32 |
| 31 class TestIframeSource : public IframeSource { | 33 class TestIframeSource : public IframeSource { |
| 32 public: | 34 public: |
| 33 using IframeSource::GetMimeType; | 35 using IframeSource::GetMimeType; |
| 34 using IframeSource::ShouldServiceRequest; | 36 using IframeSource::ShouldServiceRequest; |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 } | 194 } |
| 193 | 195 |
| 194 TEST_F(IframeSourceTest, SendJSWithOrigin) { | 196 TEST_F(IframeSourceTest, SendJSWithOrigin) { |
| 195 SendJSWithOrigin(IDR_MOST_VISITED_TITLE_JS, kInstantRendererPID, 0); | 197 SendJSWithOrigin(IDR_MOST_VISITED_TITLE_JS, kInstantRendererPID, 0); |
| 196 EXPECT_FALSE(response_string().empty()); | 198 EXPECT_FALSE(response_string().empty()); |
| 197 SendJSWithOrigin(IDR_MOST_VISITED_TITLE_JS, kNonInstantRendererPID, 0); | 199 SendJSWithOrigin(IDR_MOST_VISITED_TITLE_JS, kNonInstantRendererPID, 0); |
| 198 EXPECT_FALSE(response_string().empty()); | 200 EXPECT_FALSE(response_string().empty()); |
| 199 SendJSWithOrigin(IDR_MOST_VISITED_TITLE_JS, kInvalidRendererPID, 0); | 201 SendJSWithOrigin(IDR_MOST_VISITED_TITLE_JS, kInvalidRendererPID, 0); |
| 200 EXPECT_TRUE(response_string().empty()); | 202 EXPECT_TRUE(response_string().empty()); |
| 201 } | 203 } |
| OLD | NEW |