зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1323781 - Console API should use OriginAttributes instead a privateBrowsing boolean, r=ehsan
This commit is contained in:
Родитель
4f830c36c0
Коммит
553b437a8c
|
@ -88,7 +88,6 @@ public:
|
||||||
|
|
||||||
ConsoleCallData()
|
ConsoleCallData()
|
||||||
: mMethodName(Console::MethodLog)
|
: mMethodName(Console::MethodLog)
|
||||||
, mPrivate(false)
|
|
||||||
, mTimeStamp(JS_Now() / PR_USEC_PER_MSEC)
|
, mTimeStamp(JS_Now() / PR_USEC_PER_MSEC)
|
||||||
, mStartTimerValue(0)
|
, mStartTimerValue(0)
|
||||||
, mStartTimerStatus(false)
|
, mStartTimerStatus(false)
|
||||||
|
@ -201,7 +200,6 @@ public:
|
||||||
nsTArray<JS::Heap<JS::Value>> mCopiedArguments;
|
nsTArray<JS::Heap<JS::Value>> mCopiedArguments;
|
||||||
|
|
||||||
Console::MethodName mMethodName;
|
Console::MethodName mMethodName;
|
||||||
bool mPrivate;
|
|
||||||
int64_t mTimeStamp;
|
int64_t mTimeStamp;
|
||||||
|
|
||||||
// These values are set in the owning thread and they contain the timestamp of
|
// These values are set in the owning thread and they contain the timestamp of
|
||||||
|
@ -570,20 +568,6 @@ private:
|
||||||
|
|
||||||
if (aOuterWindow) {
|
if (aOuterWindow) {
|
||||||
mCallData->SetIDs(aOuterWindow->WindowID(), aInnerWindow->WindowID());
|
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 {
|
} else {
|
||||||
ConsoleStackEntry frame;
|
ConsoleStackEntry frame;
|
||||||
if (mCallData->mTopStackFrame) {
|
if (mCallData->mTopStackFrame) {
|
||||||
|
@ -604,15 +588,6 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
mCallData->SetIDs(id, innerID);
|
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).
|
// Now we could have the correct window (if we are not window-less).
|
||||||
|
@ -1227,17 +1202,9 @@ Console::MethodInternal(JSContext* aCx, MethodName aMethodName,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PrincipalOriginAttributes oa;
|
||||||
|
|
||||||
if (mWindow) {
|
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
|
// Save the principal's OriginAttributes in the console event data
|
||||||
// so that we will be able to filter messages by origin attributes.
|
// so that we will be able to filter messages by origin attributes.
|
||||||
nsCOMPtr<nsIScriptObjectPrincipal> sop = do_QueryInterface(mWindow);
|
nsCOMPtr<nsIScriptObjectPrincipal> sop = do_QueryInterface(mWindow);
|
||||||
|
@ -1250,9 +1217,32 @@ Console::MethodInternal(JSContext* aCx, MethodName aMethodName,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
callData->SetOriginAttributes(BasePrincipal::Cast(principal)->OriginAttributesRef());
|
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(oa);
|
||||||
|
|
||||||
JS::StackCapture captureMode = ShouldIncludeStackTrace(aMethodName) ?
|
JS::StackCapture captureMode = ShouldIncludeStackTrace(aMethodName) ?
|
||||||
JS::StackCapture(JS::MaxFrames(DEFAULT_MAX_STACKTRACE_DEPTH)) :
|
JS::StackCapture(JS::MaxFrames(DEFAULT_MAX_STACKTRACE_DEPTH)) :
|
||||||
JS::StackCapture(JS::FirstSubsumedFrame(aCx));
|
JS::StackCapture(JS::FirstSubsumedFrame(aCx));
|
||||||
|
@ -1549,7 +1539,7 @@ Console::PopulateConsoleNotificationInTheTargetScope(JSContext* aCx,
|
||||||
event.mColumnNumber = frame.mColumnNumber;
|
event.mColumnNumber = frame.mColumnNumber;
|
||||||
event.mFunctionName = frame.mFunctionName;
|
event.mFunctionName = frame.mFunctionName;
|
||||||
event.mTimeStamp = aData->mTimeStamp;
|
event.mTimeStamp = aData->mTimeStamp;
|
||||||
event.mPrivate = aData->mPrivate;
|
event.mPrivate = !!aData->mOriginAttributes.mPrivateBrowsingId;
|
||||||
|
|
||||||
switch (aData->mMethodName) {
|
switch (aData->mMethodName) {
|
||||||
case MethodLog:
|
case MethodLog:
|
||||||
|
|
Загрузка…
Ссылка в новой задаче