| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 #include <tuple> | 7 #include <tuple> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 #include "content/shell/browser/shell_browser_context.h" | 59 #include "content/shell/browser/shell_browser_context.h" |
| 60 #include "content/test/mock_keyboard.h" | 60 #include "content/test/mock_keyboard.h" |
| 61 #include "content/test/test_render_frame.h" | 61 #include "content/test/test_render_frame.h" |
| 62 #include "net/base/net_errors.h" | 62 #include "net/base/net_errors.h" |
| 63 #include "net/cert/cert_status_flags.h" | 63 #include "net/cert/cert_status_flags.h" |
| 64 #include "testing/gtest/include/gtest/gtest.h" | 64 #include "testing/gtest/include/gtest/gtest.h" |
| 65 #include "third_party/WebKit/public/platform/WebData.h" | 65 #include "third_party/WebKit/public/platform/WebData.h" |
| 66 #include "third_party/WebKit/public/platform/WebHTTPBody.h" | 66 #include "third_party/WebKit/public/platform/WebHTTPBody.h" |
| 67 #include "third_party/WebKit/public/platform/WebString.h" | 67 #include "third_party/WebKit/public/platform/WebString.h" |
| 68 #include "third_party/WebKit/public/platform/WebURLResponse.h" | 68 #include "third_party/WebKit/public/platform/WebURLResponse.h" |
| 69 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor
kerNetworkProvider.h" |
| 69 #include "third_party/WebKit/public/web/WebDataSource.h" | 70 #include "third_party/WebKit/public/web/WebDataSource.h" |
| 70 #include "third_party/WebKit/public/web/WebDeviceEmulationParams.h" | 71 #include "third_party/WebKit/public/web/WebDeviceEmulationParams.h" |
| 71 #include "third_party/WebKit/public/web/WebFrameContentDumper.h" | 72 #include "third_party/WebKit/public/web/WebFrameContentDumper.h" |
| 72 #include "third_party/WebKit/public/web/WebHistoryCommitType.h" | 73 #include "third_party/WebKit/public/web/WebHistoryCommitType.h" |
| 73 #include "third_party/WebKit/public/web/WebHistoryItem.h" | 74 #include "third_party/WebKit/public/web/WebHistoryItem.h" |
| 74 #include "third_party/WebKit/public/web/WebInputMethodController.h" | 75 #include "third_party/WebKit/public/web/WebInputMethodController.h" |
| 75 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 76 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 76 #include "third_party/WebKit/public/web/WebPerformance.h" | 77 #include "third_party/WebKit/public/web/WebPerformance.h" |
| 77 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" | 78 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" |
| 78 #include "third_party/WebKit/public/web/WebScriptSource.h" | 79 #include "third_party/WebKit/public/web/WebScriptSource.h" |
| (...skipping 1870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1949 view()->webview()->clearFocusedElement(); | 1950 view()->webview()->clearFocusedElement(); |
| 1950 const IPC::Message* msg3 = render_thread_->sink().GetFirstMessageMatching( | 1951 const IPC::Message* msg3 = render_thread_->sink().GetFirstMessageMatching( |
| 1951 FrameHostMsg_FocusedNodeChanged::ID); | 1952 FrameHostMsg_FocusedNodeChanged::ID); |
| 1952 EXPECT_TRUE(msg3); | 1953 EXPECT_TRUE(msg3); |
| 1953 FrameHostMsg_FocusedNodeChanged::Read(msg3, ¶ms); | 1954 FrameHostMsg_FocusedNodeChanged::Read(msg3, ¶ms); |
| 1954 EXPECT_FALSE(std::get<0>(params)); | 1955 EXPECT_FALSE(std::get<0>(params)); |
| 1955 render_thread_->sink().ClearMessages(); | 1956 render_thread_->sink().ClearMessages(); |
| 1956 } | 1957 } |
| 1957 | 1958 |
| 1958 TEST_F(RenderViewImplTest, ServiceWorkerNetworkProviderSetup) { | 1959 TEST_F(RenderViewImplTest, ServiceWorkerNetworkProviderSetup) { |
| 1959 ServiceWorkerNetworkProvider* provider = NULL; | 1960 blink::WebServiceWorkerNetworkProvider* webprovider = nullptr; |
| 1960 RequestExtraData* extra_data = NULL; | 1961 ServiceWorkerNetworkProvider* provider = nullptr; |
| 1962 RequestExtraData* extra_data = nullptr; |
| 1961 | 1963 |
| 1962 // Make sure each new document has a new provider and | 1964 // Make sure each new document has a new provider and |
| 1963 // that the main request is tagged with the provider's id. | 1965 // that the main request is tagged with the provider's id. |
| 1964 LoadHTML("<b>A Document</b>"); | 1966 LoadHTML("<b>A Document</b>"); |
| 1965 ASSERT_TRUE(GetMainFrame()->dataSource()); | 1967 ASSERT_TRUE(GetMainFrame()->dataSource()); |
| 1966 provider = ServiceWorkerNetworkProvider::FromDocumentState( | 1968 webprovider = GetMainFrame()->dataSource()->getServiceWorkerNetworkProvider(); |
| 1967 DocumentState::FromDataSource(GetMainFrame()->dataSource())); | 1969 ASSERT_TRUE(webprovider); |
| 1968 ASSERT_TRUE(provider); | |
| 1969 extra_data = static_cast<RequestExtraData*>( | 1970 extra_data = static_cast<RequestExtraData*>( |
| 1970 GetMainFrame()->dataSource()->getRequest().getExtraData()); | 1971 GetMainFrame()->dataSource()->getRequest().getExtraData()); |
| 1971 ASSERT_TRUE(extra_data); | 1972 ASSERT_TRUE(extra_data); |
| 1972 EXPECT_EQ(extra_data->service_worker_provider_id(), | 1973 provider = |
| 1973 provider->provider_id()); | 1974 ServiceWorkerNetworkProvider::GetInwardProviderForNavigation(webprovider); |
| 1975 ASSERT_TRUE(provider); |
| 1976 EXPECT_EQ(extra_data->service_worker_provider_id(), provider->provider_id()); |
| 1974 int provider1_id = provider->provider_id(); | 1977 int provider1_id = provider->provider_id(); |
| 1975 | 1978 |
| 1976 LoadHTML("<b>New Document B Goes Here</b>"); | 1979 LoadHTML("<b>New Document B Goes Here</b>"); |
| 1977 ASSERT_TRUE(GetMainFrame()->dataSource()); | 1980 ASSERT_TRUE(GetMainFrame()->dataSource()); |
| 1978 provider = ServiceWorkerNetworkProvider::FromDocumentState( | 1981 webprovider = GetMainFrame()->dataSource()->getServiceWorkerNetworkProvider(); |
| 1979 DocumentState::FromDataSource(GetMainFrame()->dataSource())); | 1982 ASSERT_TRUE(provider); |
| 1983 provider = |
| 1984 ServiceWorkerNetworkProvider::GetInwardProviderForNavigation(webprovider); |
| 1980 ASSERT_TRUE(provider); | 1985 ASSERT_TRUE(provider); |
| 1981 EXPECT_NE(provider1_id, provider->provider_id()); | 1986 EXPECT_NE(provider1_id, provider->provider_id()); |
| 1982 extra_data = static_cast<RequestExtraData*>( | 1987 extra_data = static_cast<RequestExtraData*>( |
| 1983 GetMainFrame()->dataSource()->getRequest().getExtraData()); | 1988 GetMainFrame()->dataSource()->getRequest().getExtraData()); |
| 1984 ASSERT_TRUE(extra_data); | 1989 ASSERT_TRUE(extra_data); |
| 1985 EXPECT_EQ(extra_data->service_worker_provider_id(), | 1990 EXPECT_EQ(extra_data->service_worker_provider_id(), provider->provider_id()); |
| 1986 provider->provider_id()); | |
| 1987 | 1991 |
| 1988 // See that subresource requests are also tagged with the provider's id. | 1992 // See that subresource requests are also tagged with the provider's id. |
| 1989 EXPECT_EQ(frame(), RenderFrameImpl::FromWebFrame(GetMainFrame())); | 1993 EXPECT_EQ(frame(), RenderFrameImpl::FromWebFrame(GetMainFrame())); |
| 1990 blink::WebURLRequest request(GURL("http://foo.com")); | 1994 blink::WebURLRequest request(GURL("http://foo.com")); |
| 1991 request.setRequestContext(blink::WebURLRequest::RequestContextSubresource); | 1995 request.setRequestContext(blink::WebURLRequest::RequestContextSubresource); |
| 1992 blink::WebURLResponse redirect_response; | 1996 blink::WebURLResponse redirect_response; |
| 1993 frame()->willSendRequest(GetMainFrame(), request); | 1997 frame()->willSendRequest(GetMainFrame(), request); |
| 1994 extra_data = static_cast<RequestExtraData*>(request.getExtraData()); | 1998 extra_data = static_cast<RequestExtraData*>(request.getExtraData()); |
| 1995 ASSERT_TRUE(extra_data); | 1999 ASSERT_TRUE(extra_data); |
| 1996 EXPECT_EQ(extra_data->service_worker_provider_id(), | 2000 EXPECT_EQ(extra_data->service_worker_provider_id(), provider->provider_id()); |
| 1997 provider->provider_id()); | |
| 1998 } | 2001 } |
| 1999 | 2002 |
| 2000 TEST_F(RenderViewImplTest, OnSetAccessibilityMode) { | 2003 TEST_F(RenderViewImplTest, OnSetAccessibilityMode) { |
| 2001 ASSERT_EQ(AccessibilityModeOff, frame()->accessibility_mode()); | 2004 ASSERT_EQ(AccessibilityModeOff, frame()->accessibility_mode()); |
| 2002 ASSERT_FALSE(frame()->render_accessibility()); | 2005 ASSERT_FALSE(frame()->render_accessibility()); |
| 2003 | 2006 |
| 2004 frame()->SetAccessibilityMode(ACCESSIBILITY_MODE_WEB_CONTENTS_ONLY); | 2007 frame()->SetAccessibilityMode(ACCESSIBILITY_MODE_WEB_CONTENTS_ONLY); |
| 2005 ASSERT_EQ(ACCESSIBILITY_MODE_WEB_CONTENTS_ONLY, | 2008 ASSERT_EQ(ACCESSIBILITY_MODE_WEB_CONTENTS_ONLY, |
| 2006 frame()->accessibility_mode()); | 2009 frame()->accessibility_mode()); |
| 2007 ASSERT_TRUE(frame()->render_accessibility()); | 2010 ASSERT_TRUE(frame()->render_accessibility()); |
| (...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2589 ExpectPauseAndResume(3); | 2592 ExpectPauseAndResume(3); |
| 2590 blink::WebScriptSource source2( | 2593 blink::WebScriptSource source2( |
| 2591 WebString::fromUTF8("function func2() { func1(); }; func2();")); | 2594 WebString::fromUTF8("function func2() { func1(); }; func2();")); |
| 2592 frame()->GetWebFrame()->executeScriptInIsolatedWorld(17, &source2, 1); | 2595 frame()->GetWebFrame()->executeScriptInIsolatedWorld(17, &source2, 1); |
| 2593 | 2596 |
| 2594 EXPECT_FALSE(IsPaused()); | 2597 EXPECT_FALSE(IsPaused()); |
| 2595 Detach(); | 2598 Detach(); |
| 2596 } | 2599 } |
| 2597 | 2600 |
| 2598 } // namespace content | 2601 } // namespace content |
| OLD | NEW |