Skip to content

Commit

Permalink
Bug 1212636 - Add a better error message for the content corrupcted e…
Browse files Browse the repository at this point in the history
…rror caused by the Promise being passed to FetchEvent.respondWith; r=bkelly
  • Loading branch information
ehsan committed Oct 7, 2015
1 parent d3d1b52 commit 1869e89
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docshell/base/nsDocShell.cpp
Expand Up @@ -5004,6 +5004,7 @@ nsDocShell::DisplayLoadError(nsresult aError, nsIURI* aURI,
case NS_ERROR_CLIENT_REQUEST_OPAQUE_INTERCEPTION:
case NS_ERROR_BAD_OPAQUE_REDIRECT_INTERCEPTION:
case NS_ERROR_INTERCEPTION_CANCELED:
case NS_ERROR_REJECTED_RESPONSE_INTERCEPTION:
// ServiceWorker intercepted request, but something went wrong.
nsContentUtils::MaybeReportInterceptionErrorToConsole(GetDocument(),
aError);
Expand Down Expand Up @@ -7669,6 +7670,7 @@ nsDocShell::EndPageLoad(nsIWebProgress* aProgress,
aStatus == NS_ERROR_INTERCEPTED_USED_RESPONSE ||
aStatus == NS_ERROR_CLIENT_REQUEST_OPAQUE_INTERCEPTION ||
aStatus == NS_ERROR_INTERCEPTION_CANCELED ||
aStatus == NS_ERROR_REJECTED_RESPONSE_INTERCEPTION ||
NS_ERROR_GET_MODULE(aStatus) == NS_ERROR_MODULE_SECURITY) {
// Errors to be shown for any frame
DisplayLoadError(aStatus, url, nullptr, aChannel);
Expand Down
2 changes: 2 additions & 0 deletions dom/base/nsContentUtils.cpp
Expand Up @@ -3494,6 +3494,8 @@ nsContentUtils::MaybeReportInterceptionErrorToConsole(nsIDocument* aDocument,
messageName = "BadOpaqueRedirectInterception";
} else if (aError == NS_ERROR_INTERCEPTION_CANCELED) {
messageName = "InterceptionCanceled";
} else if (aError == NS_ERROR_REJECTED_RESPONSE_INTERCEPTION) {
messageName = "InterceptionRejectedResponse";
}

if (messageName) {
Expand Down
2 changes: 2 additions & 0 deletions dom/locales/en-US/chrome/dom/dom.properties
Expand Up @@ -182,5 +182,7 @@ ClientRequestOpaqueInterception=A ServiceWorker passed an opaque Response to Fet
BadOpaqueRedirectInterception=A ServiceWorker passed an opaqueredirect Response to FetchEvent.respondWith() while FetchEvent.request was not a navigation request.
# LOCALIZATION NOTE: Do not translate "ServiceWorker" or "FetchEvent.preventDefault()".
InterceptionCanceled=ServiceWorker canceled network interception by calling FetchEvent.preventDefault().
# LOCALIZATION NOTE: Do not translate "ServiceWorker", "Promise", or "FetchEvent.respondWith()".
InterceptionRejectedResponse=ServiceWorker passed a rejected Promise to FetchEvent.respondWith(). This typically means that the code that resolves the Promise has failed.
WebrtcDeprecatedPrefixWarning=WebRTC interfaces with the "moz" prefix (mozRTCPeerConnection, mozRTCSessionDescription, mozRTCIceCandidate) have been deprecated.
NavigatorGetUserMediaWarning=navigator.mozGetUserMedia has been replaced by navigator.mediaDevices.getUserMedia
2 changes: 1 addition & 1 deletion dom/workers/ServiceWorkerEvents.cpp
Expand Up @@ -395,7 +395,7 @@ RespondWithHandler::ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValu
void
RespondWithHandler::RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue)
{
CancelRequest(NS_ERROR_INTERCEPTION_FAILED);
CancelRequest(NS_ERROR_REJECTED_RESPONSE_INTERCEPTION);
}

void
Expand Down
2 changes: 2 additions & 0 deletions xpcom/base/ErrorList.h
Expand Up @@ -337,6 +337,8 @@
ERROR(NS_ERROR_BAD_OPAQUE_REDIRECT_INTERCEPTION, FAILURE(106)),
/* Service worker intentionally canceled load via preventDefault(). */
ERROR(NS_ERROR_INTERCEPTION_CANCELED, FAILURE(107)),
/* Service worker passed a rejected promise to respondwith. */
ERROR(NS_ERROR_REJECTED_RESPONSE_INTERCEPTION, FAILURE(108)),
#undef MODULE


Expand Down

0 comments on commit 1869e89

Please sign in to comment.