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

Unified Diff: content/renderer/render_view_browsertest.cc

Issue 14188060: Change decidePolicyForNavigation() to takea WebDataSource::ExtraData (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/public/renderer/navigation_state.h ('k') | content/renderer/render_view_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/render_view_browsertest.cc
===================================================================
--- content/renderer/render_view_browsertest.cc (revision 197024)
+++ content/renderer/render_view_browsertest.cc (working copy)
@@ -12,6 +12,8 @@
#include "content/public/browser/web_ui_controller_factory.h"
#include "content/public/common/bindings_policy.h"
#include "content/public/common/url_constants.h"
+#include "content/public/renderer/document_state.h"
+#include "content/public/renderer/navigation_state.h"
#include "content/public/test/render_view_test.h"
#include "content/renderer/render_view_impl.h"
#include "content/shell/shell_content_browser_client.h"
@@ -315,10 +317,14 @@
WebUITestWebUIControllerFactory factory;
WebUIControllerFactory::RegisterFactory(&factory);
+ DocumentState state;
+ state.set_navigation_state(NavigationState::CreateContentInitiated());
+
// Navigations to normal HTTP URLs can be handled locally.
WebKit::WebURLRequest request(GURL("http://foo.com"));
WebKit::WebNavigationPolicy policy = view()->decidePolicyForNavigation(
GetMainFrame(),
+ &state,
request,
WebKit::WebNavigationTypeLinkClicked,
WebKit::WebNavigationPolicyCurrentTab,
@@ -330,6 +336,7 @@
form_request.setHTTPMethod("POST");
policy = view()->decidePolicyForNavigation(
GetMainFrame(),
+ &state,
form_request,
WebKit::WebNavigationTypeFormSubmitted,
WebKit::WebNavigationPolicyCurrentTab,
@@ -340,6 +347,7 @@
WebKit::WebURLRequest popup_request(GURL("chrome://foo"));
policy = view()->decidePolicyForNavigation(
GetMainFrame(),
+ &state,
popup_request,
WebKit::WebNavigationTypeLinkClicked,
WebKit::WebNavigationPolicyNewForegroundTab,
@@ -351,10 +359,14 @@
// Enable bindings to simulate a WebUI view.
view()->OnAllowBindings(BINDINGS_POLICY_WEB_UI);
+ DocumentState state;
+ state.set_navigation_state(NavigationState::CreateContentInitiated());
+
// Navigations to normal HTTP URLs will be sent to browser process.
WebKit::WebURLRequest request(GURL("http://foo.com"));
WebKit::WebNavigationPolicy policy = view()->decidePolicyForNavigation(
GetMainFrame(),
+ &state,
request,
WebKit::WebNavigationTypeLinkClicked,
WebKit::WebNavigationPolicyCurrentTab,
@@ -365,6 +377,7 @@
WebKit::WebURLRequest webui_request(GURL("chrome://foo"));
policy = view()->decidePolicyForNavigation(
GetMainFrame(),
+ &state,
webui_request,
WebKit::WebNavigationTypeLinkClicked,
WebKit::WebNavigationPolicyCurrentTab,
@@ -376,6 +389,7 @@
data_request.setHTTPMethod("POST");
policy = view()->decidePolicyForNavigation(
GetMainFrame(),
+ &state,
data_request,
WebKit::WebNavigationTypeFormSubmitted,
WebKit::WebNavigationPolicyCurrentTab,
@@ -392,6 +406,7 @@
RenderViewImpl* new_view = RenderViewImpl::FromWebView(new_web_view);
policy = new_view->decidePolicyForNavigation(
new_web_view->mainFrame(),
+ &state,
popup_request,
WebKit::WebNavigationTypeLinkClicked,
WebKit::WebNavigationPolicyNewForegroundTab,
@@ -1388,6 +1403,15 @@
error.reason = net::ERR_FILE_NOT_FOUND;
error.unreachableURL = GURL("http://foo");
WebFrame* web_frame = GetMainFrame();
+
+ // Start a load that will reach provisional state synchronously,
+ // but won't complete synchronously.
+ ViewMsg_Navigate_Params params;
+ params.page_id = -1;
+ params.navigation_type = ViewMsg_Navigate_Type::NORMAL;
+ params.url = GURL("data:text/html,test data");
+ view()->OnNavigate(params);
+
// An error occurred.
view()->didFailProvisionalLoad(web_frame, error);
// Frame should exit view-source mode.
@@ -1401,6 +1425,15 @@
error.reason = net::ERR_ABORTED;
error.unreachableURL = GURL("http://foo");
WebFrame* web_frame = GetMainFrame();
+
+ // Start a load that will reach provisional state synchronously,
+ // but won't complete synchronously.
+ ViewMsg_Navigate_Params params;
+ params.page_id = -1;
+ params.navigation_type = ViewMsg_Navigate_Type::NORMAL;
+ params.url = GURL("data:text/html,test data");
+ view()->OnNavigate(params);
+
// A cancellation occurred.
view()->didFailProvisionalLoad(web_frame, error);
// Frame should stay in view-source mode.
« no previous file with comments | « content/public/renderer/navigation_state.h ('k') | content/renderer/render_view_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698