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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/bind.h" | 6 #include "base/bind.h" |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/memory/shared_memory.h" | 8 #include "base/memory/shared_memory.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
11 #include "base/win/windows_version.h" | 11 #include "base/win/windows_version.h" |
12 #include "content/child/request_extra_data.h" | |
13 #include "content/child/service_worker/service_worker_network_provider.h" | |
12 #include "content/common/frame_messages.h" | 14 #include "content/common/frame_messages.h" |
13 #include "content/common/ssl_status_serialization.h" | 15 #include "content/common/ssl_status_serialization.h" |
14 #include "content/common/view_messages.h" | 16 #include "content/common/view_messages.h" |
15 #include "content/public/browser/browser_context.h" | 17 #include "content/public/browser/browser_context.h" |
16 #include "content/public/browser/native_web_keyboard_event.h" | 18 #include "content/public/browser/native_web_keyboard_event.h" |
17 #include "content/public/browser/web_ui_controller_factory.h" | 19 #include "content/public/browser/web_ui_controller_factory.h" |
18 #include "content/public/common/bindings_policy.h" | 20 #include "content/public/common/bindings_policy.h" |
19 #include "content/public/common/page_zoom.h" | 21 #include "content/public/common/page_zoom.h" |
20 #include "content/public/common/url_constants.h" | 22 #include "content/public/common/url_constants.h" |
21 #include "content/public/common/url_utils.h" | 23 #include "content/public/common/url_utils.h" |
(...skipping 2221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2243 | 2245 |
2244 view()->webview()->clearFocusedElement(); | 2246 view()->webview()->clearFocusedElement(); |
2245 const IPC::Message* msg3 = render_thread_->sink().GetFirstMessageMatching( | 2247 const IPC::Message* msg3 = render_thread_->sink().GetFirstMessageMatching( |
2246 ViewHostMsg_FocusedNodeChanged::ID); | 2248 ViewHostMsg_FocusedNodeChanged::ID); |
2247 EXPECT_TRUE(msg3); | 2249 EXPECT_TRUE(msg3); |
2248 ViewHostMsg_FocusedNodeChanged::Read(msg3, ¶ms); | 2250 ViewHostMsg_FocusedNodeChanged::Read(msg3, ¶ms); |
2249 EXPECT_FALSE(params.a); | 2251 EXPECT_FALSE(params.a); |
2250 render_thread_->sink().ClearMessages(); | 2252 render_thread_->sink().ClearMessages(); |
2251 } | 2253 } |
2252 | 2254 |
2255 TEST_F(RenderViewImplTest, ServiceWorkerNetworkProviderSetup) { | |
2256 ServiceWorkerNetworkProvider* provider = NULL; | |
2257 RequestExtraData* extra_data = NULL; | |
Charlie Reis
2014/03/05 18:32:56
nit: Remove extra space after *.
| |
2258 | |
2259 // Make sure each new document has a new provider and | |
2260 // that the main request is tagged with our id. | |
Charlie Reis
2014/03/05 18:32:56
nit: our -> the provider's
(I got confused about
| |
2261 LoadHTML("<b>A Document</b>"); | |
2262 ASSERT_TRUE(GetMainFrame()->dataSource()); | |
2263 provider = ServiceWorkerNetworkProvider::FromDocumentState( | |
2264 DocumentState::FromDataSource(GetMainFrame()->dataSource())); | |
2265 ASSERT_TRUE(provider); | |
2266 extra_data = static_cast<RequestExtraData*>( | |
2267 GetMainFrame()->dataSource()->request().extraData()); | |
2268 ASSERT_TRUE(extra_data); | |
2269 EXPECT_EQ(extra_data->service_worker_provider_id(), | |
2270 provider->provider_id()); | |
2271 int provider1_id = provider->provider_id(); | |
2272 | |
2273 LoadHTML("<b>New Document B Goes Here</b>"); | |
2274 ASSERT_TRUE(GetMainFrame()->dataSource()); | |
2275 provider = ServiceWorkerNetworkProvider::FromDocumentState( | |
2276 DocumentState::FromDataSource(GetMainFrame()->dataSource())); | |
2277 ASSERT_TRUE(provider); | |
2278 EXPECT_NE(provider1_id, provider->provider_id()); | |
2279 extra_data = static_cast<RequestExtraData*>( | |
2280 GetMainFrame()->dataSource()->request().extraData()); | |
2281 ASSERT_TRUE(extra_data); | |
2282 EXPECT_EQ(extra_data->service_worker_provider_id(), | |
2283 provider->provider_id()); | |
2284 | |
2285 // See subresource requests are also tagged with our id. | |
2286 EXPECT_EQ(frame(), RenderFrameImpl::FromWebFrame(GetMainFrame())); | |
2287 blink::WebURLRequest request(GURL("http://foo.com")); | |
2288 request.setTargetType(blink::WebURLRequest::TargetIsSubresource); | |
2289 blink::WebURLResponse redirect_response; | |
2290 frame()->willSendRequest(GetMainFrame(), 0, request, redirect_response); | |
2291 extra_data = static_cast<RequestExtraData*>(request.extraData()); | |
2292 ASSERT_TRUE(extra_data); | |
2293 EXPECT_EQ(extra_data->service_worker_provider_id(), | |
2294 provider->provider_id()); | |
2295 } | |
2296 | |
2253 } // namespace content | 2297 } // namespace content |
OLD | NEW |