Commit 800666fd authored by Mike West's avatar Mike West Committed by Commit Bot

Ensure that PPAPI requests send `Sec-Fetch-Dest: embed`

Currently, we're sending `Sec-Fetch-Dest: unknown` for PPAPI-driven
requests. We ought to be sending `embed` or `object`.

This patch adds some tests to ensure that we're setting the context
for PPAPI requests to PLUGIN, and changes Blink's behavior to report
PLUGIN as `embed`. We ought to be distinguishing between `embed` and
`object`, but don't currently have the context when creating the
request to make that possible (and "embed" is strictly better than
"unknown" :) ).

Bug: 1021432
Change-Id: Ie0d2dff1dee85e34c2fab6f7ea2e542fede644e6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1899446Reviewed-by: default avatarBill Budge <bbudge@chromium.org>
Commit-Queue: Mike West <mkwst@chromium.org>
Cr-Commit-Position: refs/heads/master@{#712911}
parent 9da83c32
......@@ -251,10 +251,10 @@ int32_t PepperURLLoaderHost::InternalOnHostMsgOpen(
return PP_ERROR_FAILED;
}
web_request.SetRequestContext(blink::mojom::RequestContextType::PLUGIN);
// Requests from plug-ins must skip service workers, see the comment in
// CreateWebURLRequest.
// Requests from plug-ins must be marked as PLUGIN, and must skip service
// workers, see the comment in CreateWebURLRequest.
DCHECK_EQ(blink::mojom::RequestContextType::PLUGIN,
web_request.GetRequestContext());
DCHECK(web_request.GetSkipServiceWorker());
WebAssociatedURLLoaderOptions options;
......
......@@ -68,6 +68,14 @@ class URLRequestInfoTest : public RenderViewTest {
return web_request.HttpMethod();
}
blink::mojom::RequestContextType GetContext() {
WebURLRequest web_request;
URLRequestInfoData data = info_->GetData();
if (!CreateWebURLRequest(pp_instance_, &data, GetMainFrame(), &web_request))
return blink::mojom::RequestContextType::UNSPECIFIED;
return web_request.GetRequestContext();
}
WebString GetHeaderValue(const char* field) {
WebURLRequest web_request;
URLRequestInfoData data = info_->GetData();
......@@ -206,6 +214,11 @@ TEST_F(URLRequestInfoTest, SetHeaders) {
EXPECT_STREQ("baz", GetHeaderValue("bar").Utf8().data());
}
TEST_F(URLRequestInfoTest, RequestContext) {
// Test context is PLUGIN.
EXPECT_EQ(blink::mojom::RequestContextType::PLUGIN, GetContext());
}
// TODO(bbudge) Unit tests for AppendDataToBody, AppendFileToBody.
} // namespace content
......@@ -248,6 +248,8 @@ bool CreateWebURLRequest(PP_Instance instance,
dest->SetExtraData(std::move(extra_data));
}
dest->SetRequestContext(blink::mojom::RequestContextType::PLUGIN);
return true;
}
......
......@@ -61,8 +61,14 @@ const char* GetRequestDestinationFromContext(
return "xslt";
case mojom::RequestContextType::IMPORT:
case mojom::RequestContextType::INTERNAL:
case mojom::RequestContextType::PLUGIN:
return "unknown";
// TODO(mkwst): We don't currently distinguish between plugin content loaded
// via `<embed>` or `<object>` as https://github.com/whatwg/fetch/pull/948
// asks us to do. See `content::PepperURLLoaderHost::InternalOnHostMsgOpen`
// for details.
case mojom::RequestContextType::PLUGIN:
return "embed";
}
NOTREACHED();
return "";
......
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