Bug 1443850 - Part 1: Don't try to apply the request fragment to an empty response URL when perform service worker interception. r=asuth, a=jcristau
authorBen Kelly <ben@wanderview.com>
Mon, 19 Mar 2018 13:29:00 +0200
changeset 462763 9c0b076211c6f281d0f148c4e4441bc22ee3a52b
parent 462762 be657736c061665f56593834e2e09814ae9126b6
child 462764 267e76b56a4b7ba0de0d6b0d813fd4cde3d4f27e
push id1683
push usersfraser@mozilla.com
push dateThu, 26 Apr 2018 16:43:40 +0000
treeherdermozilla-release@5af6cb21869d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersasuth, jcristau
bugs1443850
milestone60.0
Bug 1443850 - Part 1: Don't try to apply the request fragment to an empty response URL when perform service worker interception. r=asuth, a=jcristau
dom/serviceworkers/ServiceWorkerEvents.cpp
--- a/dom/serviceworkers/ServiceWorkerEvents.cpp
+++ b/dom/serviceworkers/ServiceWorkerEvents.cpp
@@ -721,17 +721,17 @@ RespondWithHandler::ResolvedCallback(JSC
     responseURL = ir->GetUnfilteredURL();
 
     // Similar to how we apply the request fragment to redirects automatically
     // we also want to apply it automatically when propagating the response
     // URL from a service worker interception.  Currently response.url strips
     // the fragment, so this will never conflict with an existing fragment
     // on the response.  In the future we will have to check for a response
     // fragment and avoid overriding in that case.
-    if (!mRequestFragment.IsEmpty()) {
+    if (!mRequestFragment.IsEmpty() && !responseURL.IsEmpty()) {
       MOZ_ASSERT(!responseURL.Contains('#'));
       responseURL.Append(NS_LITERAL_CSTRING("#"));
       responseURL.Append(mRequestFragment);
     }
   }
 
   UniquePtr<RespondWithClosure> closure(new RespondWithClosure(mInterceptedChannel,
                                                                mRegistration,