Issue #2402 - Don't call WorkerPrivate::WorkerName() to get service worker scope. https://bugzilla.mozilla.org/show_bug.cgi?id=1350433

This commit is contained in:
Brian Smith 2024-01-07 07:34:05 -06:00 committed by roytam1
commit 5202c08cfb
5 changed files with 14 additions and 7 deletions

View file

@ -598,7 +598,7 @@ private:
innerID = NS_LITERAL_STRING("ServiceWorker");
// Use scope as ID so the webconsole can decide if the message should
// show up per tab
id.AssignWithConversion(mWorkerPrivate->WorkerName());
id.AssignWithConversion(mWorkerPrivate->ServiceWorkerScope());
} else {
innerID = NS_LITERAL_STRING("Worker");
}

View file

@ -710,7 +710,7 @@ WorkerFetchResolver::FlushConsoleReport()
return;
}
swm->FlushReportsToAllClients(worker->WorkerName(), mReporter);
swm->FlushReportsToAllClients(worker->ServiceWorkerScope(), mReporter);
return;
}

View file

@ -805,7 +805,7 @@ public:
WaitUntilHandler(WorkerPrivate* aWorkerPrivate, JSContext* aCx)
: mWorkerPrivate(aWorkerPrivate)
, mScope(mWorkerPrivate->WorkerName())
, mScope(mWorkerPrivate->ServiceWorkerScope())
, mLine(0)
, mColumn(0)
{

View file

@ -550,7 +550,7 @@ private:
RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
if (swm) {
swm->HandleError(aCx, aWorkerPrivate->GetPrincipal(),
aWorkerPrivate->WorkerName(),
aWorkerPrivate->ServiceWorkerScope(),
aWorkerPrivate->ScriptURL(),
EmptyString(), EmptyString(), EmptyString(),
0, 0, JSREPORT_ERROR, JSEXN_ERR);
@ -1255,7 +1255,7 @@ private:
RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
if (swm) {
swm->HandleError(aCx, aWorkerPrivate->GetPrincipal(),
aWorkerPrivate->WorkerName(),
aWorkerPrivate->ServiceWorkerScope(),
aWorkerPrivate->ScriptURL(),
mReport.mMessage,
mReport.mFilename, mReport.mLine, mReport.mLineNumber,
@ -6727,7 +6727,7 @@ WorkerPrivate::GetOrCreateGlobalScope(JSContext* aCx)
if (IsSharedWorker()) {
globalScope = new SharedWorkerGlobalScope(this, WorkerName());
} else if (IsServiceWorker()) {
globalScope = new ServiceWorkerGlobalScope(this, WorkerName());
globalScope = new ServiceWorkerGlobalScope(this, ServiceWorkerScope());
} else {
globalScope = new DedicatedWorkerGlobalScope(this);
}

View file

@ -535,6 +535,13 @@ public:
return mLoadInfo.mServiceWorkerID;
}
const nsCString&
ServiceWorkerScope() const
{
MOZ_DIAGNOSTIC_ASSERT(IsServiceWorker());
return mWorkerName;
}
nsIURI*
GetBaseURI() const
{
@ -831,7 +838,7 @@ public:
const nsCString&
WorkerName() const
{
MOZ_ASSERT(IsServiceWorker() || IsSharedWorker());
MOZ_ASSERT(IsSharedWorker());
return mWorkerName;
}