Bug 1156847 - Part 3: When loading a service worker from the network, remember the security info of the channel on the WorkerPrivate; r=nsm

This commit is contained in:
Ehsan Akhgari 2015-04-23 19:04:03 -04:00
parent 0b4ac3bba8
commit 7fcc696e50

View File

@ -13,6 +13,7 @@
#include "nsIIOService.h"
#include "nsIProtocolHandler.h"
#include "nsIScriptSecurityManager.h"
#include "nsISerializable.h"
#include "nsIStreamLoader.h"
#include "nsIStreamListenerTee.h"
#include "nsIThreadRetargetableRequest.h"
@ -917,6 +918,20 @@ private:
// Take care of the base URI first.
mWorkerPrivate->SetBaseURI(finalURI);
// Store the security info if needed.
if (mWorkerPrivate->IsServiceWorker()) {
nsCOMPtr<nsISupports> infoObj;
channel->GetSecurityInfo(getter_AddRefs(infoObj));
if (infoObj) {
nsCOMPtr<nsISerializable> serializable = do_QueryInterface(infoObj);
if (serializable) {
mWorkerPrivate->SetSecurityInfo(serializable);
} else {
NS_WARNING("A non-serializable object was obtained from nsIChannel::GetSecurityInfo()!");
}
}
}
// Now to figure out which principal to give this worker.
WorkerPrivate* parent = mWorkerPrivate->GetParent();