Bug 1368962 P1 Expose LoadInfo::SynthesizeServiceWorkerTainting(). r=ckerschb
☠☠ backed out by 24c5cff1eadb ☠ ☠
authorBen Kelly <ben@wanderview.com>
Wed, 07 Jun 2017 08:14:57 -0700
changeset 410820 78533a4ef62ecdd63a84aa292a51f04431762c49
parent 410819 962439237d24616b544177f8febf7f49e51634de
child 410821 674e032ea90c615bcd295f17fd2b420fc663b8df
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersckerschb
bugs1368962
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1368962 P1 Expose LoadInfo::SynthesizeServiceWorkerTainting(). r=ckerschb
netwerk/base/LoadInfo.cpp
netwerk/base/LoadInfo.h
--- a/netwerk/base/LoadInfo.cpp
+++ b/netwerk/base/LoadInfo.cpp
@@ -947,16 +947,23 @@ LoadInfo::MaybeIncreaseTainting(uint32_t
   NS_ENSURE_ARG(aTainting <= TAINTING_OPAQUE);
   LoadTainting tainting = static_cast<LoadTainting>(aTainting);
   if (tainting > mTainting) {
     mTainting = tainting;
   }
   return NS_OK;
 }
 
+void
+LoadInfo::SynthesizeServiceWorkerTainting(LoadTainting aTainting)
+{
+  MOZ_DIAGNOSTIC_ASSERT(aTainting <= LoadTainting::Opaque);
+  mTainting = aTainting;
+}
+
 NS_IMETHODIMP
 LoadInfo::GetIsTopLevelLoad(bool *aResult)
 {
   *aResult = mFrameOuterWindowID ? mFrameOuterWindowID == mOuterWindowID
                                  : mParentOuterWindowID == mOuterWindowID;
   return NS_OK;
 }
 
--- a/netwerk/base/LoadInfo.h
+++ b/netwerk/base/LoadInfo.h
@@ -69,16 +69,24 @@ public:
   // nsBaseChannel::Redirect()
   already_AddRefed<nsILoadInfo>
   CloneWithNewSecFlags(nsSecurityFlags aSecurityFlags) const;
   // creates a copy of the loadinfo which is appropriate to use for a
   // separate request. I.e. not for a redirect or an inner channel, but
   // when a separate request is made with the same security properties.
   already_AddRefed<nsILoadInfo> CloneForNewRequest() const;
 
+  // The service worker and fetch specifications require returning the
+  // exact tainting level of the Response passed to FetchEvent.respondWith().
+  // This method allows us to override the tainting level in that case.
+  //
+  // NOTE: This should not be used outside of service worker code! Use
+  //       nsILoadInfo::MaybeIncreaseTainting() instead.
+  void SynthesizeServiceWorkerTainting(LoadTainting aTainting);
+
   void SetIsPreflight();
   void SetUpgradeInsecureRequests();
 
 private:
   // private constructor that is only allowed to be called from within
   // HttpChannelParent and FTPChannelParent declared as friends undeneath.
   // In e10s we can not serialize nsINode, hence we store the innerWindowID.
   // Please note that aRedirectChain uses swapElements.