Bug 1642149 - P2 ImportScript() in workers must respect the coressponding COEP header r=dom-workers-and-storage-reviewers,perry

When loading a sub-script in workers, the corresponding COEP must be set on the channel's nsILoadInfo, such that its CORP header can be checked as expected.

Differential Revision: https://phabricator.services.mozilla.com/D77720
This commit is contained in:
Eden Chuang 2020-06-18 10:02:51 +00:00
Родитель 400b4664ad
Коммит 8c86a3e215
2 изменённых файлов: 16 добавлений и 4 удалений

Просмотреть файл

@ -1119,6 +1119,22 @@ class ScriptLoaderRunnable final : public nsIRunnable, public nsINamed {
} }
} }
if (StaticPrefs::browser_tabs_remote_useCrossOriginEmbedderPolicy()) {
nsILoadInfo::CrossOriginEmbedderPolicy respectedCOEP =
mWorkerPrivate->GetEmbedderPolicy();
if (mWorkerPrivate->IsDedicatedWorker() &&
respectedCOEP == nsILoadInfo::EMBEDDER_POLICY_NULL) {
respectedCOEP = mWorkerPrivate->GetOwnerEmbedderPolicy();
}
nsCOMPtr<nsILoadInfo> channelLoadInfo;
rv = channel->GetLoadInfo(getter_AddRefs(channelLoadInfo));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
channelLoadInfo->SetLoadingEmbedderPolicy(respectedCOEP);
}
if (loadInfo.mCacheStatus != ScriptLoadInfo::ToBeCached) { if (loadInfo.mCacheStatus != ScriptLoadInfo::ToBeCached) {
rv = channel->AsyncOpen(loader); rv = channel->AsyncOpen(loader);
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(rv))) {

Просмотреть файл

@ -1,4 +0,0 @@
[require-corp-sw.https.html]
[importScripts() fails for a script with no corp.]
expected: FAIL