Commit 70ac7300 authored by arthursonzogni's avatar arthursonzogni Committed by Commit Bot

Ensure commit_params->frame_policy is populated.

Only some of the browser initiated main frame navigation can have no
FramePolicy assigned. The renderer-initiated and subframes ones must
always have it defined.
TODO(arthursonzogni): Consider always defining it in the future.

This patch fixes a few cases and adds a DCHECK in the NavigationRequest
to enforce this property in the future.

Bug: 1086734, 1041376
Change-Id: Id2936a89193322fa609e4135820037fcbf7bd85c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2216255
Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org>
Reviewed-by: default avatarAlex Moshchuk <alexmos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#772611}
parent 74dc0a2b
......@@ -3416,6 +3416,11 @@ void NavigationControllerImpl::LoadPostCommitErrorPage(
mojom::CommitNavigationParamsPtr commit_params =
CreateCommitNavigationParams();
// Error pages have a fully permissive FramePolicy.
// TODO(arthursonzogni): Consider providing the minimal capabilities to the
// error pages.
commit_params->frame_policy = blink::FramePolicy();
std::unique_ptr<NavigationRequest> navigation_request =
NavigationRequest::CreateBrowserInitiated(
node, std::move(common_params), std::move(commit_params),
......
......@@ -887,7 +887,7 @@ std::unique_ptr<NavigationRequest> NavigationRequest::CreateForCommit(
network::mojom::IPAddressSpace::kUnknown,
GURL() /* web_bundle_physical_url */,
GURL() /* base_url_override_for_web_bundle */,
base::nullopt /* frame policy */,
frame_tree_node->pending_frame_policy(),
std::vector<std::string>() /* force_enabled_origin_trials */
);
mojom::BeginNavigationParamsPtr begin_params =
......@@ -951,6 +951,9 @@ NavigationRequest::NavigationRequest(
DCHECK(browser_initiated_ || common_params_->initiator_origin.has_value());
DCHECK(!IsRendererDebugURL(common_params_->url));
DCHECK(common_params_->method == "POST" || !common_params_->post_data);
DCHECK((IsInMainFrame() && browser_initiated) ||
commit_params_->frame_policy.has_value());
TRACE_EVENT_NESTABLE_ASYNC_BEGIN2(
"navigation", "NavigationRequest", this, "frame_tree_node",
frame_tree_node_->frame_tree_node_id(), "url",
......
......@@ -192,9 +192,12 @@ class NavigationRequestTest : public RenderViewHostImplTestHarness {
auto common_params = CreateCommonNavigationParams();
common_params->initiator_origin =
url::Origin::Create(GURL("https://initiator.example.com"));
auto commit_params = CreateCommitNavigationParams();
commit_params->frame_policy =
main_test_rfh()->frame_tree_node()->pending_frame_policy();
request_ = NavigationRequest::CreateBrowserInitiated(
main_test_rfh()->frame_tree_node(), std::move(common_params),
CreateCommitNavigationParams(), false /* browser-initiated */,
std::move(commit_params), false /* browser-initiated */,
GlobalFrameRoutingId() /* initiator_routing_id */,
std::string() /* extra_headers */, nullptr /* frame_entry */,
nullptr /* entry */, nullptr /* post_body */,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment