Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1016)

Side by Side Diff: content/renderer/render_view_browsertest.cc

Issue 1371673002: Remove a bunch of provisionalDataSource() usage. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/renderer/render_frame_impl.cc ('k') | content/renderer/render_view_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/location.h" 8 #include "base/location.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 1616 matching lines...) Expand 10 before | Expand all | Expand 10 after
1627 // Start a load that will reach provisional state synchronously, 1627 // Start a load that will reach provisional state synchronously,
1628 // but won't complete synchronously. 1628 // but won't complete synchronously.
1629 CommonNavigationParams common_params; 1629 CommonNavigationParams common_params;
1630 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; 1630 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
1631 common_params.url = GURL("data:text/html,test data"); 1631 common_params.url = GURL("data:text/html,test data");
1632 frame()->Navigate(common_params, StartNavigationParams(), 1632 frame()->Navigate(common_params, StartNavigationParams(),
1633 RequestNavigationParams()); 1633 RequestNavigationParams());
1634 1634
1635 // An error occurred. 1635 // An error occurred.
1636 view()->GetMainRenderFrame()->didFailProvisionalLoad( 1636 view()->GetMainRenderFrame()->didFailProvisionalLoad(
1637 web_frame, error, blink::WebStandardCommit); 1637 web_frame->provisionalDataSource(), error, blink::WebStandardCommit);
1638 // Frame should exit view-source mode. 1638 // Frame should exit view-source mode.
1639 EXPECT_FALSE(web_frame->isViewSourceModeEnabled()); 1639 EXPECT_FALSE(web_frame->isViewSourceModeEnabled());
1640 } 1640 }
1641 1641
1642 TEST_F(RenderViewImplTest, DidFailProvisionalLoadWithErrorForCancellation) { 1642 TEST_F(RenderViewImplTest, DidFailProvisionalLoadWithErrorForCancellation) {
1643 GetMainFrame()->enableViewSourceMode(true); 1643 GetMainFrame()->enableViewSourceMode(true);
1644 WebURLError error; 1644 WebURLError error;
1645 error.domain = WebString::fromUTF8(net::kErrorDomain); 1645 error.domain = WebString::fromUTF8(net::kErrorDomain);
1646 error.reason = net::ERR_ABORTED; 1646 error.reason = net::ERR_ABORTED;
1647 error.unreachableURL = GURL("http://foo"); 1647 error.unreachableURL = GURL("http://foo");
1648 WebLocalFrame* web_frame = GetMainFrame(); 1648 WebLocalFrame* web_frame = GetMainFrame();
1649 1649
1650 // Start a load that will reach provisional state synchronously, 1650 // Start a load that will reach provisional state synchronously,
1651 // but won't complete synchronously. 1651 // but won't complete synchronously.
1652 CommonNavigationParams common_params; 1652 CommonNavigationParams common_params;
1653 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; 1653 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
1654 common_params.url = GURL("data:text/html,test data"); 1654 common_params.url = GURL("data:text/html,test data");
1655 frame()->Navigate(common_params, StartNavigationParams(), 1655 frame()->Navigate(common_params, StartNavigationParams(),
1656 RequestNavigationParams()); 1656 RequestNavigationParams());
1657 1657
1658 // A cancellation occurred. 1658 // A cancellation occurred.
1659 view()->GetMainRenderFrame()->didFailProvisionalLoad( 1659 view()->GetMainRenderFrame()->didFailProvisionalLoad(
1660 web_frame, error, blink::WebStandardCommit); 1660 web_frame->provisionalDataSource(), error, blink::WebStandardCommit);
1661 // Frame should stay in view-source mode. 1661 // Frame should stay in view-source mode.
1662 EXPECT_TRUE(web_frame->isViewSourceModeEnabled()); 1662 EXPECT_TRUE(web_frame->isViewSourceModeEnabled());
1663 } 1663 }
1664 1664
1665 // Regression test for http://crbug.com/41562 1665 // Regression test for http://crbug.com/41562
1666 TEST_F(RenderViewImplTest, UpdateTargetURLWithInvalidURL) { 1666 TEST_F(RenderViewImplTest, UpdateTargetURLWithInvalidURL) {
1667 const GURL invalid_gurl("http://"); 1667 const GURL invalid_gurl("http://");
1668 view()->setMouseOverURL(blink::WebURL(invalid_gurl)); 1668 view()->setMouseOverURL(blink::WebURL(invalid_gurl));
1669 EXPECT_EQ(invalid_gurl, view()->target_url_); 1669 EXPECT_EQ(invalid_gurl, view()->target_url_);
1670 } 1670 }
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
2055 // Start a load that will reach provisional state synchronously, 2055 // Start a load that will reach provisional state synchronously,
2056 // but won't complete synchronously. 2056 // but won't complete synchronously.
2057 CommonNavigationParams common_params; 2057 CommonNavigationParams common_params;
2058 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; 2058 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
2059 common_params.url = GURL("data:text/html,test data"); 2059 common_params.url = GURL("data:text/html,test data");
2060 TestRenderFrame* main_frame = static_cast<TestRenderFrame*>(frame()); 2060 TestRenderFrame* main_frame = static_cast<TestRenderFrame*>(frame());
2061 main_frame->Navigate(common_params, StartNavigationParams(), 2061 main_frame->Navigate(common_params, StartNavigationParams(),
2062 RequestNavigationParams()); 2062 RequestNavigationParams());
2063 2063
2064 // An error occurred. 2064 // An error occurred.
2065 main_frame->didFailProvisionalLoad(web_frame, error, 2065 main_frame->didFailProvisionalLoad(
2066 blink::WebStandardCommit); 2066 web_frame->provisionalDataSource(), error, blink::WebStandardCommit);
2067 const int kMaxOutputCharacters = 22; 2067 const int kMaxOutputCharacters = 22;
2068 EXPECT_EQ("", base::UTF16ToASCII( 2068 EXPECT_EQ("", base::UTF16ToASCII(
2069 base::StringPiece16(web_frame->contentAsText(kMaxOutputCharacters)))); 2069 base::StringPiece16(web_frame->contentAsText(kMaxOutputCharacters))));
2070 } 2070 }
2071 2071
2072 #if defined(OS_ANDROID) 2072 #if defined(OS_ANDROID)
2073 // Crashing on Android: http://crbug.com/311341 2073 // Crashing on Android: http://crbug.com/311341
2074 #define MAYBE_DoesNotSuppress DISABLED_DoesNotSuppress 2074 #define MAYBE_DoesNotSuppress DISABLED_DoesNotSuppress
2075 #else 2075 #else
2076 #define MAYBE_DoesNotSuppress DoesNotSuppress 2076 #define MAYBE_DoesNotSuppress DoesNotSuppress
2077 #endif 2077 #endif
2078 2078
2079 TEST_F(RendererErrorPageTest, MAYBE_DoesNotSuppress) { 2079 TEST_F(RendererErrorPageTest, MAYBE_DoesNotSuppress) {
2080 WebURLError error; 2080 WebURLError error;
2081 error.domain = WebString::fromUTF8(net::kErrorDomain); 2081 error.domain = WebString::fromUTF8(net::kErrorDomain);
2082 error.reason = net::ERR_FILE_NOT_FOUND; 2082 error.reason = net::ERR_FILE_NOT_FOUND;
2083 error.unreachableURL = GURL("http://example.com/dont-suppress"); 2083 error.unreachableURL = GURL("http://example.com/dont-suppress");
2084 WebLocalFrame* web_frame = GetMainFrame(); 2084 WebLocalFrame* web_frame = GetMainFrame();
2085 2085
2086 // Start a load that will reach provisional state synchronously, 2086 // Start a load that will reach provisional state synchronously,
2087 // but won't complete synchronously. 2087 // but won't complete synchronously.
2088 CommonNavigationParams common_params; 2088 CommonNavigationParams common_params;
2089 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; 2089 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
2090 common_params.url = GURL("data:text/html,test data"); 2090 common_params.url = GURL("data:text/html,test data");
2091 TestRenderFrame* main_frame = static_cast<TestRenderFrame*>(frame()); 2091 TestRenderFrame* main_frame = static_cast<TestRenderFrame*>(frame());
2092 main_frame->Navigate(common_params, StartNavigationParams(), 2092 main_frame->Navigate(common_params, StartNavigationParams(),
2093 RequestNavigationParams()); 2093 RequestNavigationParams());
2094 2094
2095 // An error occurred. 2095 // An error occurred.
2096 main_frame->didFailProvisionalLoad(web_frame, error, 2096 main_frame->didFailProvisionalLoad(
2097 blink::WebStandardCommit); 2097 web_frame->provisionalDataSource(), error, blink::WebStandardCommit);
2098 2098
2099 // The error page itself is loaded asynchronously. 2099 // The error page itself is loaded asynchronously.
2100 FrameLoadWaiter(main_frame).Wait(); 2100 FrameLoadWaiter(main_frame).Wait();
2101 const int kMaxOutputCharacters = 22; 2101 const int kMaxOutputCharacters = 22;
2102 EXPECT_EQ("A suffusion of yellow.", 2102 EXPECT_EQ("A suffusion of yellow.",
2103 base::UTF16ToASCII(base::StringPiece16( 2103 base::UTF16ToASCII(base::StringPiece16(
2104 web_frame->contentAsText(kMaxOutputCharacters)))); 2104 web_frame->contentAsText(kMaxOutputCharacters))));
2105 } 2105 }
2106 2106
2107 #if defined(OS_ANDROID) 2107 #if defined(OS_ANDROID)
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
2219 GetMainFrame()->dataSource()->request().extraData()); 2219 GetMainFrame()->dataSource()->request().extraData());
2220 ASSERT_TRUE(extra_data); 2220 ASSERT_TRUE(extra_data);
2221 EXPECT_EQ(extra_data->service_worker_provider_id(), 2221 EXPECT_EQ(extra_data->service_worker_provider_id(),
2222 provider->provider_id()); 2222 provider->provider_id());
2223 2223
2224 // See that subresource requests are also tagged with the provider's id. 2224 // See that subresource requests are also tagged with the provider's id.
2225 EXPECT_EQ(frame(), RenderFrameImpl::FromWebFrame(GetMainFrame())); 2225 EXPECT_EQ(frame(), RenderFrameImpl::FromWebFrame(GetMainFrame()));
2226 blink::WebURLRequest request(GURL("http://foo.com")); 2226 blink::WebURLRequest request(GURL("http://foo.com"));
2227 request.setRequestContext(blink::WebURLRequest::RequestContextSubresource); 2227 request.setRequestContext(blink::WebURLRequest::RequestContextSubresource);
2228 blink::WebURLResponse redirect_response; 2228 blink::WebURLResponse redirect_response;
2229 frame()->willSendRequest(GetMainFrame(), 0, request, redirect_response); 2229 frame()->willSendRequest(
2230 GetMainFrame()->dataSource(), 0, request, redirect_response);
2230 extra_data = static_cast<RequestExtraData*>(request.extraData()); 2231 extra_data = static_cast<RequestExtraData*>(request.extraData());
2231 ASSERT_TRUE(extra_data); 2232 ASSERT_TRUE(extra_data);
2232 EXPECT_EQ(extra_data->service_worker_provider_id(), 2233 EXPECT_EQ(extra_data->service_worker_provider_id(),
2233 provider->provider_id()); 2234 provider->provider_id());
2234 } 2235 }
2235 2236
2236 TEST_F(RenderViewImplTest, OnSetAccessibilityMode) { 2237 TEST_F(RenderViewImplTest, OnSetAccessibilityMode) {
2237 ASSERT_EQ(AccessibilityModeOff, frame()->accessibility_mode()); 2238 ASSERT_EQ(AccessibilityModeOff, frame()->accessibility_mode());
2238 ASSERT_EQ((RendererAccessibility*) NULL, frame()->renderer_accessibility()); 2239 ASSERT_EQ((RendererAccessibility*) NULL, frame()->renderer_accessibility());
2239 2240
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
2399 FROM_HERE, 2400 FROM_HERE,
2400 base::Bind(&DevToolsAgentTest::CloseWhilePaused, base::Unretained(this))); 2401 base::Bind(&DevToolsAgentTest::CloseWhilePaused, base::Unretained(this)));
2401 ExecuteJavaScriptForTests("debugger;"); 2402 ExecuteJavaScriptForTests("debugger;");
2402 2403
2403 // CloseWhilePaused should resume execution and continue here. 2404 // CloseWhilePaused should resume execution and continue here.
2404 EXPECT_FALSE(IsPaused()); 2405 EXPECT_FALSE(IsPaused());
2405 Detach(); 2406 Detach();
2406 } 2407 }
2407 2408
2408 } // namespace content 2409 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_frame_impl.cc ('k') | content/renderer/render_view_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698