mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1215140 P5 Report the line number where respondWith() was called. r=bz
This commit is contained in:
parent
27a5396efa
commit
d390455098
@ -495,6 +495,7 @@ DOMInterfaces = {
|
||||
'binaryNames': {
|
||||
'request': 'request_'
|
||||
},
|
||||
'implicitJSContext': [ 'respondWith' ],
|
||||
},
|
||||
|
||||
'FileReader': {
|
||||
|
@ -198,6 +198,9 @@ class RespondWithHandler final : public PromiseNativeHandler
|
||||
const DebugOnly<bool> mIsClientRequest;
|
||||
const bool mIsNavigationRequest;
|
||||
const nsCString mScriptSpec;
|
||||
const nsCString mRespondWithScriptSpec;
|
||||
const uint32_t mRespondWithLineNumber;
|
||||
const uint32_t mRespondWithColumnNumber;
|
||||
bool mRequestWasHandled;
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
@ -205,12 +208,18 @@ public:
|
||||
RespondWithHandler(nsMainThreadPtrHandle<nsIInterceptedChannel>& aChannel,
|
||||
RequestMode aRequestMode, bool aIsClientRequest,
|
||||
bool aIsNavigationRequest,
|
||||
const nsACString& aScriptSpec)
|
||||
const nsACString& aScriptSpec,
|
||||
const nsACString& aRespondWithScriptSpec,
|
||||
uint32_t aRespondWithLineNumber,
|
||||
uint32_t aRespondWithColumnNumber)
|
||||
: mInterceptedChannel(aChannel)
|
||||
, mRequestMode(aRequestMode)
|
||||
, mIsClientRequest(aIsClientRequest)
|
||||
, mIsNavigationRequest(aIsNavigationRequest)
|
||||
, mScriptSpec(aScriptSpec)
|
||||
, mRespondWithScriptSpec(aRespondWithScriptSpec)
|
||||
, mRespondWithLineNumber(aRespondWithLineNumber)
|
||||
, mRespondWithColumnNumber(aRespondWithColumnNumber)
|
||||
, mRequestWasHandled(false)
|
||||
{
|
||||
}
|
||||
@ -450,8 +459,9 @@ RespondWithHandler::AsyncLog(const nsACString& aMessageName)
|
||||
reporter->AddConsoleReport(nsIScriptError::errorFlag,
|
||||
NS_LITERAL_CSTRING("Service Worker Interception"),
|
||||
nsContentUtils::eDOM_PROPERTIES,
|
||||
mScriptSpec,
|
||||
0, 0,
|
||||
mRespondWithScriptSpec,
|
||||
mRespondWithLineNumber,
|
||||
mRespondWithColumnNumber,
|
||||
aMessageName,
|
||||
nsTArray<nsString>());
|
||||
}
|
||||
@ -460,19 +470,29 @@ RespondWithHandler::AsyncLog(const nsACString& aMessageName)
|
||||
} // namespace
|
||||
|
||||
void
|
||||
FetchEvent::RespondWith(Promise& aArg, ErrorResult& aRv)
|
||||
FetchEvent::RespondWith(JSContext* aCx, Promise& aArg, ErrorResult& aRv)
|
||||
{
|
||||
if (EventPhase() == nsIDOMEvent::NONE || mWaitToRespond) {
|
||||
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Record where respondWith() was called in the script so we can include the
|
||||
// information in any error reporting. We should be guaranteed not to get
|
||||
// a file:// string here because service workers require http/https.
|
||||
nsCString spec;
|
||||
uint32_t line = 0;
|
||||
uint32_t column = 0;
|
||||
nsJSUtils::GetCallingLocation(aCx, spec, &line, &column);
|
||||
|
||||
RefPtr<InternalRequest> ir = mRequest->GetInternalRequest();
|
||||
StopImmediatePropagation();
|
||||
mWaitToRespond = true;
|
||||
RefPtr<RespondWithHandler> handler =
|
||||
new RespondWithHandler(mChannel, mRequest->Mode(), ir->IsClientRequest(),
|
||||
ir->IsNavigationRequest(), mScriptSpec);
|
||||
ir->IsNavigationRequest(), mScriptSpec,
|
||||
spec, line, column);
|
||||
aArg.AppendNativeHandler(handler);
|
||||
|
||||
WaitUntil(aArg, aRv);
|
||||
|
@ -147,7 +147,7 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
RespondWith(Promise& aArg, ErrorResult& aRv);
|
||||
RespondWith(JSContext* aCx, Promise& aArg, ErrorResult& aRv);
|
||||
|
||||
already_AddRefed<Promise>
|
||||
ForwardTo(const nsAString& aUrl);
|
||||
|
Loading…
Reference in New Issue
Block a user