Skip to content

Commit

Permalink
Backed out changeset 7c18fbb292d1 (bug 1323781) for assertion failures
Browse files Browse the repository at this point in the history
--HG--
extra : rebase_source : 0d9518d855e463eb85e262452e9a957716735f12
  • Loading branch information
BavarianTomcat committed Dec 16, 2016
1 parent 366f6eb commit 6fce618
Showing 1 changed file with 37 additions and 27 deletions.
64 changes: 37 additions & 27 deletions dom/console/Console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ class ConsoleCallData final

ConsoleCallData()
: mMethodName(Console::MethodLog)
, mPrivate(false)
, mTimeStamp(JS_Now() / PR_USEC_PER_MSEC)
, mStartTimerValue(0)
, mStartTimerStatus(false)
Expand Down Expand Up @@ -200,6 +201,7 @@ class ConsoleCallData final
nsTArray<JS::Heap<JS::Value>> mCopiedArguments;

Console::MethodName mMethodName;
bool mPrivate;
int64_t mTimeStamp;

// These values are set in the owning thread and they contain the timestamp of
Expand Down Expand Up @@ -568,6 +570,20 @@ class ConsoleCallDataRunnable final : public ConsoleRunnable

if (aOuterWindow) {
mCallData->SetIDs(aOuterWindow->WindowID(), aInnerWindow->WindowID());

// Save the principal's OriginAttributes in the console event data
// so that we will be able to filter messages by origin attributes.
nsCOMPtr<nsIScriptObjectPrincipal> sop = do_QueryInterface(aInnerWindow);
if (NS_WARN_IF(!sop)) {
return;
}

nsCOMPtr<nsIPrincipal> principal = sop->GetPrincipal();
if (NS_WARN_IF(!principal)) {
return;
}

mCallData->SetOriginAttributes(BasePrincipal::Cast(principal)->OriginAttributesRef());
} else {
ConsoleStackEntry frame;
if (mCallData->mTopStackFrame) {
Expand All @@ -588,6 +604,15 @@ class ConsoleCallDataRunnable final : public ConsoleRunnable
}

mCallData->SetIDs(id, innerID);

// Save the principal's OriginAttributes in the console event data
// so that we will be able to filter messages by origin attributes.
nsCOMPtr<nsIPrincipal> principal = mWorkerPrivate->GetPrincipal();
if (NS_WARN_IF(!principal)) {
return;
}

mCallData->SetOriginAttributes(BasePrincipal::Cast(principal)->OriginAttributesRef());
}

// Now we could have the correct window (if we are not window-less).
Expand Down Expand Up @@ -1202,9 +1227,17 @@ Console::MethodInternal(JSContext* aCx, MethodName aMethodName,
return;
}

PrincipalOriginAttributes oa;

if (mWindow) {
nsCOMPtr<nsIWebNavigation> webNav = do_GetInterface(mWindow);
if (!webNav) {
return;
}

nsCOMPtr<nsILoadContext> loadContext = do_QueryInterface(webNav);
MOZ_ASSERT(loadContext);

loadContext->GetUsePrivateBrowsing(&callData->mPrivate);

// Save the principal's OriginAttributes in the console event data
// so that we will be able to filter messages by origin attributes.
nsCOMPtr<nsIScriptObjectPrincipal> sop = do_QueryInterface(mWindow);
Expand All @@ -1217,32 +1250,9 @@ Console::MethodInternal(JSContext* aCx, MethodName aMethodName,
return;
}

oa = BasePrincipal::Cast(principal)->OriginAttributesRef();

#ifdef DEBUG
nsCOMPtr<nsIWebNavigation> webNav = do_GetInterface(mWindow);
if (!webNav) {
return;
}

nsCOMPtr<nsILoadContext> loadContext = do_QueryInterface(webNav);
MOZ_ASSERT(loadContext);

bool pb;
if (NS_FAILED(loadContext->GetUsePrivateBrowsing(&pb))) {
return;
}

MOZ_ASSERT(pb == !!oa.mPrivateBrowsingId);
#endif
} else {
WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
MOZ_ASSERT(workerPrivate);
oa = workerPrivate->GetOriginAttributes();
callData->SetOriginAttributes(BasePrincipal::Cast(principal)->OriginAttributesRef());
}

callData->SetOriginAttributes(oa);

JS::StackCapture captureMode = ShouldIncludeStackTrace(aMethodName) ?
JS::StackCapture(JS::MaxFrames(DEFAULT_MAX_STACKTRACE_DEPTH)) :
JS::StackCapture(JS::FirstSubsumedFrame(aCx));
Expand Down Expand Up @@ -1539,7 +1549,7 @@ Console::PopulateConsoleNotificationInTheTargetScope(JSContext* aCx,
event.mColumnNumber = frame.mColumnNumber;
event.mFunctionName = frame.mFunctionName;
event.mTimeStamp = aData->mTimeStamp;
event.mPrivate = !!aData->mOriginAttributes.mPrivateBrowsingId;
event.mPrivate = aData->mPrivate;

switch (aData->mMethodName) {
case MethodLog:
Expand Down

0 comments on commit 6fce618

Please sign in to comment.