Bug 1269646 - Console API should be NOP after window-inner-destroyed, r=smaug

This commit is contained in:
Andrea Marchesini 2016-05-03 10:19:39 +02:00
Родитель 06c125d9b7
Коммит a29728b62b
2 изменённых файлов: 17 добавлений и 14 удалений

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

@ -1049,7 +1049,6 @@ void
Console::Trace(JSContext* aCx)
{
AssertIsOnOwningThread();
MOZ_ASSERT(mStatus == eInitialized);
const Sequence<JS::Value> data;
Method(aCx, MethodTrace, NS_LITERAL_STRING("trace"), data);
@ -1067,7 +1066,6 @@ void
Console::Time(JSContext* aCx, const JS::Handle<JS::Value> aTime)
{
AssertIsOnOwningThread();
MOZ_ASSERT(mStatus == eInitialized);
Sequence<JS::Value> data;
SequenceRooter<JS::Value> rooter(aCx, &data);
@ -1083,7 +1081,6 @@ void
Console::TimeEnd(JSContext* aCx, const JS::Handle<JS::Value> aTime)
{
AssertIsOnOwningThread();
MOZ_ASSERT(mStatus == eInitialized);
Sequence<JS::Value> data;
SequenceRooter<JS::Value> rooter(aCx, &data);
@ -1099,7 +1096,6 @@ void
Console::TimeStamp(JSContext* aCx, const JS::Handle<JS::Value> aData)
{
AssertIsOnOwningThread();
MOZ_ASSERT(mStatus == eInitialized);
Sequence<JS::Value> data;
SequenceRooter<JS::Value> rooter(aCx, &data);
@ -1115,8 +1111,6 @@ void
Console::Profile(JSContext* aCx, const Sequence<JS::Value>& aData)
{
AssertIsOnOwningThread();
MOZ_ASSERT(mStatus == eInitialized);
ProfileMethod(aCx, NS_LITERAL_STRING("profile"), aData);
}
@ -1124,8 +1118,6 @@ void
Console::ProfileEnd(JSContext* aCx, const Sequence<JS::Value>& aData)
{
AssertIsOnOwningThread();
MOZ_ASSERT(mStatus == eInitialized);
ProfileMethod(aCx, NS_LITERAL_STRING("profileEnd"), aData);
}
@ -1133,7 +1125,9 @@ void
Console::ProfileMethod(JSContext* aCx, const nsAString& aAction,
const Sequence<JS::Value>& aData)
{
MOZ_ASSERT(mStatus == eInitialized);
if (IsShuttingDown()) {
return;
}
if (!NS_IsMainThread()) {
// Here we are in a worker thread.
@ -1191,7 +1185,6 @@ Console::Assert(JSContext* aCx, bool aCondition,
const Sequence<JS::Value>& aData)
{
AssertIsOnOwningThread();
MOZ_ASSERT(mStatus == eInitialized);
if (!aCondition) {
Method(aCx, MethodAssert, NS_LITERAL_STRING("assert"), aData);
@ -1204,7 +1197,6 @@ void
Console::NoopMethod()
{
AssertIsOnOwningThread();
MOZ_ASSERT(mStatus == eInitialized);
// Nothing to do.
}
@ -1278,7 +1270,9 @@ Console::Method(JSContext* aCx, MethodName aMethodName,
const Sequence<JS::Value>& aData)
{
AssertIsOnOwningThread();
MOZ_ASSERT(mStatus == eInitialized);
if (IsShuttingDown()) {
return;
}
RefPtr<ConsoleCallData> callData(new ConsoleCallData());
@ -2411,5 +2405,12 @@ Console::AssertIsOnOwningThread() const
MOZ_ASSERT(PR_GetCurrentThread() == mOwningThread);
}
bool
Console::IsShuttingDown() const
{
MOZ_ASSERT(mStatus != eUnknown);
return mStatus == eShuttingDown;
}
} // namespace dom
} // namespace mozilla

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

@ -36,8 +36,6 @@ class Console final : public nsIObserver
, public nsWrapperCache
, public nsSupportsWeakReference
{
~Console();
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(Console, nsIObserver)
@ -133,6 +131,7 @@ public:
private:
explicit Console(nsPIDOMWindowInner* aWindow);
~Console();
void
Initialize(ErrorResult& aRv);
@ -343,6 +342,9 @@ private:
void
AssertIsOnOwningThread() const;
bool
IsShuttingDown() const;
// All these nsCOMPtr are touched on main thread only.
nsCOMPtr<nsPIDOMWindowInner> mWindow;
nsCOMPtr<nsIConsoleAPIStorage> mStorage;