Bug 1337522 P1 Add diagnostic assertions that worker principal is valid before compilation. r=baku

This commit is contained in:
Ben Kelly 2017-02-14 10:06:39 -05:00
Родитель 52b735a227
Коммит adfc2e425e
3 изменённых файлов: 29 добавлений и 0 удалений

Просмотреть файл

@ -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<Derived>::AssertInnerWindowIsCorrect() const
#endif
#if defined(DEBUG) || !defined(RELEASE_OR_BETA)
template <class Derived>
bool
WorkerPrivateParent<Derived>::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<CompileScriptRunnable> 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;
}

Просмотреть файл

@ -867,6 +867,11 @@ public:
AssertInnerWindowIsCorrect() const
{ }
#endif
#if defined(DEBUG) || !defined(RELEASE_OR_BETA)
bool
PrincipalIsValid() const;
#endif
};
class WorkerDebugger : public nsIWorkerDebugger {

Просмотреть файл

@ -293,6 +293,9 @@ struct WorkerLoadInfo
#if defined(DEBUG) || !defined(RELEASE_OR_BETA)
bool
FinalChannelPrincipalIsValid(nsIChannel* aChannel);
bool
PrincipalIsValid() const;
#endif
bool