diff --git a/dom/workers/WorkerPrivate.cpp b/dom/workers/WorkerPrivate.cpp index fba090160935..1b982aac4a6a 100644 --- a/dom/workers/WorkerPrivate.cpp +++ b/dom/workers/WorkerPrivate.cpp @@ -1993,6 +1993,14 @@ WorkerLoadInfo::FinalChannelPrincipalIsValid(nsIChannel* aChannel) return false; } + +bool +WorkerLoadInfo::PrincipalIsValid() const +{ + return mPrincipal && mPrincipalInfo && + mPrincipalInfo->type() != PrincipalInfo::T__None && + mPrincipalInfo->type() <= PrincipalInfo::T__Last; +} #endif // defined(DEBUG) || !defined(RELEASE_OR_BETA) bool @@ -4017,6 +4025,15 @@ WorkerPrivateParent::AssertInnerWindowIsCorrect() const #endif +#if defined(DEBUG) || !defined(RELEASE_OR_BETA) +template +bool +WorkerPrivateParent::PrincipalIsValid() const +{ + return mLoadInfo.PrincipalIsValid(); +} +#endif + class PostDebuggerMessageRunnable final : public Runnable { WorkerDebugger *mDebugger; @@ -4589,6 +4606,8 @@ WorkerPrivate::Constructor(JSContext* aCx, worker->EnableDebugger(); + MOZ_DIAGNOSTIC_ASSERT(worker->PrincipalIsValid()); + RefPtr compiler = new CompileScriptRunnable(worker, aScriptURL); if (!compiler->Dispatch()) { @@ -4858,6 +4877,8 @@ WorkerPrivate::GetLoadInfo(JSContext* aCx, nsPIDOMWindowInner* aWindow, NS_ENSURE_SUCCESS(rv, rv); } + MOZ_DIAGNOSTIC_ASSERT(loadInfo.PrincipalIsValid()); + aLoadInfo->StealFrom(loadInfo); return NS_OK; } diff --git a/dom/workers/WorkerPrivate.h b/dom/workers/WorkerPrivate.h index b780866b2cc6..8b9198868f5a 100644 --- a/dom/workers/WorkerPrivate.h +++ b/dom/workers/WorkerPrivate.h @@ -867,6 +867,11 @@ public: AssertInnerWindowIsCorrect() const { } #endif + +#if defined(DEBUG) || !defined(RELEASE_OR_BETA) + bool + PrincipalIsValid() const; +#endif }; class WorkerDebugger : public nsIWorkerDebugger { diff --git a/dom/workers/Workers.h b/dom/workers/Workers.h index 13e7ab69a4b8..66e5b9ecceab 100644 --- a/dom/workers/Workers.h +++ b/dom/workers/Workers.h @@ -293,6 +293,9 @@ struct WorkerLoadInfo #if defined(DEBUG) || !defined(RELEASE_OR_BETA) bool FinalChannelPrincipalIsValid(nsIChannel* aChannel); + + bool + PrincipalIsValid() const; #endif bool