Bug 1369862 P1 Expose LoadInfo::SynthesizeServiceWorkerTainting(). r=ckerschb
authorBen Kelly <ben@wanderview.com>
Wed, 07 Jun 2017 08:34:51 -0700
changeset 410825 d61441b6594ef4e483f54b32df07ab6906b37b84
parent 410824 24c5cff1eadb25aba955c18a509651921dc4831e
child 410826 7d7d7b7c2d2910a0eef815e926817c6d8070c2af
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
bugs1369862
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 1369862 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.