Bug 1514894 - Tell the new content process about its principal. r=asuth

By forcing our subject principal to be that of the service worker, we confuse
the permissions-checking code in the new process we create for
clients.openWindow. We need to tell the new process about the principal that's
doing work before it does any work.

Further principals (such as the principal for the loaded page) will be passed
down to the child via the various networking channels that we create for it.

Differential Revision: https://phabricator.services.mozilla.com/D14799

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Blake Kaplan 2018-12-18 18:59:16 +00:00
Родитель f9cc1d1c09
Коммит ba862815a3
1 изменённых файлов: 11 добавлений и 0 удалений

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

@ -579,6 +579,17 @@ class OpenWindowRunnable final : public Runnable {
ClientOpenWindowOpParent* actor =
new ClientOpenWindowOpParent(mArgs, mPromise);
// Normally, we call TransmitPermissionsForPrincipal for the first http
// load, but in this case, ClientOpenWindowOpChild will cause the initial
// about:blank load in the child to have this principal. That causes us to
// assert because the child process doesn't know that it's loading this
// principal.
nsCOMPtr<nsIPrincipal> principal =
PrincipalInfoToPrincipal(mArgs.principalInfo());
DebugOnly<nsresult> rv =
targetProcess->TransmitPermissionsForPrincipal(principal);
Unused << NS_WARN_IF(NS_FAILED(rv));
// If this fails the actor will be automatically destroyed which will
// reject the promise.
Unused << targetProcess->SendPClientOpenWindowOpConstructor(actor, mArgs);