зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1847469 - Part 24: Use column number types in JS::DescribeScriptedCaller. r=iain
Differential Revision: https://phabricator.services.mozilla.com/D185762
This commit is contained in:
Родитель
f61ba91ee2
Коммит
5c4dc17c44
|
@ -71,6 +71,7 @@
|
|||
#include "nsContentUtils.h"
|
||||
#include "nsJSUtils.h"
|
||||
#include "nsILoadInfo.h"
|
||||
#include "js/ColumnNumber.h" // JS::ColumnNumberZeroOrigin
|
||||
|
||||
// This should be probably defined on some other place... but I couldn't find it
|
||||
#define WEBAPPS_PERM_NAME "webapps-manage"
|
||||
|
@ -532,7 +533,7 @@ bool nsScriptSecurityManager::ContentSecurityPolicyPermitsJSAction(
|
|||
JS::AutoFilename scriptFilename;
|
||||
nsAutoString fileName;
|
||||
uint32_t lineNum = 0;
|
||||
uint32_t columnNum = 0;
|
||||
JS::ColumnNumberZeroOrigin columnNum;
|
||||
if (JS::DescribeScriptedCaller(cx, &scriptFilename, &lineNum, &columnNum)) {
|
||||
if (const char* file = scriptFilename.get()) {
|
||||
CopyUTF8toUTF16(nsDependentCString(file), fileName);
|
||||
|
@ -554,7 +555,7 @@ bool nsScriptSecurityManager::ContentSecurityPolicyPermitsJSAction(
|
|||
csp->LogViolationDetails(violationType,
|
||||
nullptr, // triggering element
|
||||
cspEventListener, fileName, scriptSample, lineNum,
|
||||
columnNum, u""_ns, u""_ns);
|
||||
columnNum.zeroOriginValue(), u""_ns, u""_ns);
|
||||
}
|
||||
|
||||
return evalOK;
|
||||
|
|
|
@ -4323,9 +4323,7 @@ void Document::NoteScriptTrackingStatus(const nsACString& aURL,
|
|||
|
||||
bool Document::IsScriptTracking(JSContext* aCx) const {
|
||||
JS::AutoFilename filename;
|
||||
uint32_t line = 0;
|
||||
uint32_t column = 0;
|
||||
if (!JS::DescribeScriptedCaller(aCx, &filename, &line, &column)) {
|
||||
if (!JS::DescribeScriptedCaller(aCx, &filename)) {
|
||||
return false;
|
||||
}
|
||||
return mTrackingScripts.Contains(nsDependentCString(filename.get()));
|
||||
|
|
|
@ -51,9 +51,13 @@ using namespace mozilla::dom;
|
|||
bool nsJSUtils::GetCallingLocation(JSContext* aContext, nsACString& aFilename,
|
||||
uint32_t* aLineno, uint32_t* aColumn) {
|
||||
JS::AutoFilename filename;
|
||||
if (!JS::DescribeScriptedCaller(aContext, &filename, aLineno, aColumn)) {
|
||||
JS::ColumnNumberZeroOrigin column;
|
||||
if (!JS::DescribeScriptedCaller(aContext, &filename, aLineno, &column)) {
|
||||
return false;
|
||||
}
|
||||
if (aColumn) {
|
||||
*aColumn = column.zeroOriginValue();
|
||||
}
|
||||
|
||||
return aFilename.Assign(filename.get(), fallible);
|
||||
}
|
||||
|
@ -61,9 +65,13 @@ bool nsJSUtils::GetCallingLocation(JSContext* aContext, nsACString& aFilename,
|
|||
bool nsJSUtils::GetCallingLocation(JSContext* aContext, nsAString& aFilename,
|
||||
uint32_t* aLineno, uint32_t* aColumn) {
|
||||
JS::AutoFilename filename;
|
||||
if (!JS::DescribeScriptedCaller(aContext, &filename, aLineno, aColumn)) {
|
||||
JS::ColumnNumberZeroOrigin column;
|
||||
if (!JS::DescribeScriptedCaller(aContext, &filename, aLineno, &column)) {
|
||||
return false;
|
||||
}
|
||||
if (aColumn) {
|
||||
*aColumn = column.zeroOriginValue();
|
||||
}
|
||||
|
||||
return aFilename.Assign(NS_ConvertUTF8toUTF16(filename.get()), fallible);
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
// Microsoft's API Name hackery sucks
|
||||
#undef CreateEvent
|
||||
|
||||
#include "js/ColumnNumber.h" // JS::ColumnNumberZeroOrigin
|
||||
#include "js/loader/LoadedScript.h"
|
||||
#include "mozilla/BasicEvents.h"
|
||||
#include "mozilla/CycleCollectedJSRuntime.h"
|
||||
|
@ -979,7 +980,7 @@ nsresult EventListenerManager::SetEventHandler(nsAtom* aName,
|
|||
// Perform CSP check
|
||||
nsCOMPtr<nsIContentSecurityPolicy> csp = doc->GetCsp();
|
||||
uint32_t lineNum = 0;
|
||||
uint32_t columnNum = 0;
|
||||
JS::ColumnNumberZeroOrigin columnNum;
|
||||
|
||||
JSContext* cx = nsContentUtils::GetCurrentJSContext();
|
||||
if (cx && !JS::DescribeScriptedCaller(cx, nullptr, &lineNum, &columnNum)) {
|
||||
|
@ -995,7 +996,7 @@ nsresult EventListenerManager::SetEventHandler(nsAtom* aName,
|
|||
true, // aParserCreated (true because attribute event handler)
|
||||
aElement,
|
||||
nullptr, // nsICSPEventListener
|
||||
aBody, lineNum, columnNum, &allowsInlineScript);
|
||||
aBody, lineNum, columnNum.zeroOriginValue(), &allowsInlineScript);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// return early if CSP wants us to block inline scripts
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include "ErrorList.h"
|
||||
#include "js/ArrayBuffer.h"
|
||||
#include "js/ColumnNumber.h" // JS::ColumnNumberZeroOrigin
|
||||
#include "js/JSON.h"
|
||||
#include "js/Utility.h"
|
||||
#include "js/experimental/TypedData.h"
|
||||
|
@ -290,7 +291,7 @@ static bool AssertParentProcessWithCallerLocationImpl(GlobalObject& aGlobal,
|
|||
|
||||
JS::AutoFilename scriptFilename;
|
||||
uint32_t lineNo = 0;
|
||||
uint32_t colNo = 0;
|
||||
JS::ColumnNumberZeroOrigin colNo;
|
||||
|
||||
NS_ENSURE_TRUE(
|
||||
JS::DescribeScriptedCaller(cx, &scriptFilename, &lineNo, &colNo), false);
|
||||
|
@ -298,7 +299,7 @@ static bool AssertParentProcessWithCallerLocationImpl(GlobalObject& aGlobal,
|
|||
NS_ENSURE_TRUE(scriptFilename.get(), false);
|
||||
|
||||
reason.AppendPrintf(" Called from %s:%d:%d.", scriptFilename.get(), lineNo,
|
||||
colNo);
|
||||
colNo.zeroOriginValue());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "mozilla/dom/WebSocketBinding.h"
|
||||
#include "mozilla/net/WebSocketChannel.h"
|
||||
|
||||
#include "js/ColumnNumber.h" // JS::ColumnNumberZeroOrigin
|
||||
#include "jsapi.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "mozilla/Atomics.h"
|
||||
|
@ -1371,7 +1372,8 @@ already_AddRefed<WebSocket> WebSocket::ConstructorCommon(
|
|||
WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
|
||||
MOZ_ASSERT(workerPrivate);
|
||||
|
||||
uint32_t lineno, column;
|
||||
uint32_t lineno;
|
||||
JS::ColumnNumberZeroOrigin column;
|
||||
JS::AutoFilename file;
|
||||
if (!JS::DescribeScriptedCaller(aGlobal.Context(), &file, &lineno,
|
||||
&column)) {
|
||||
|
@ -1381,7 +1383,8 @@ already_AddRefed<WebSocket> WebSocket::ConstructorCommon(
|
|||
RefPtr<InitRunnable> runnable = new InitRunnable(
|
||||
workerPrivate, webSocketImpl,
|
||||
workerPrivate->GlobalScope()->GetClientInfo(), !!aTransportProvider,
|
||||
aUrl, protocolArray, nsDependentCString(file.get()), lineno, column);
|
||||
aUrl, protocolArray, nsDependentCString(file.get()), lineno,
|
||||
column.zeroOriginValue());
|
||||
runnable->Dispatch(Canceling, aRv);
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return nullptr;
|
||||
|
@ -1608,12 +1611,13 @@ nsresult WebSocketImpl::Init(JSContext* aCx, bool aIsSecure,
|
|||
} else {
|
||||
MOZ_ASSERT(aCx);
|
||||
|
||||
uint32_t lineno, column;
|
||||
uint32_t lineno;
|
||||
JS::ColumnNumberZeroOrigin column;
|
||||
JS::AutoFilename file;
|
||||
if (JS::DescribeScriptedCaller(aCx, &file, &lineno, &column)) {
|
||||
mScriptFile = file.get();
|
||||
mScriptLine = lineno;
|
||||
mScriptColumn = column;
|
||||
mScriptColumn = column.zeroOriginValue();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include <algorithm>
|
||||
#include "mozilla/ipc/BackgroundChild.h"
|
||||
#include "GeckoProfiler.h"
|
||||
#include "js/ColumnNumber.h" // JS::ColumnNumberZeroOrigin
|
||||
#include "js/experimental/CTypes.h" // JS::CTypesActivityType, JS::SetCTypesActivityCallback
|
||||
#include "jsfriendapi.h"
|
||||
#include "js/friend/ErrorMessages.h" // js::GetErrorMessage, JSMSG_*
|
||||
|
@ -518,7 +519,7 @@ bool ContentSecurityPolicyAllows(JSContext* aCx, JS::RuntimeCode aKind,
|
|||
if (reportViolation) {
|
||||
nsString fileName;
|
||||
uint32_t lineNum = 0;
|
||||
uint32_t columnNum = 0;
|
||||
JS::ColumnNumberZeroOrigin columnNum;
|
||||
|
||||
JS::AutoFilename file;
|
||||
if (JS::DescribeScriptedCaller(aCx, &file, &lineNum, &columnNum) &&
|
||||
|
@ -530,7 +531,8 @@ bool ContentSecurityPolicyAllows(JSContext* aCx, JS::RuntimeCode aKind,
|
|||
|
||||
RefPtr<LogViolationDetailsRunnable> runnable =
|
||||
new LogViolationDetailsRunnable(worker, violationType, fileName,
|
||||
lineNum, columnNum, scriptSample);
|
||||
lineNum, columnNum.zeroOriginValue(),
|
||||
scriptSample);
|
||||
|
||||
ErrorResult rv;
|
||||
runnable->Dispatch(Killing, rv);
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
#include "jit/JitSpewer.h"
|
||||
#include "js/CallAndConstruct.h" // JS::IsCallable
|
||||
#include "js/CharacterEncoding.h"
|
||||
#include "js/ColumnNumber.h" // JS::TaggedColumnNumberZeroOrigin, JS::ColumnNumberOneOrigin
|
||||
#include "js/ColumnNumber.h" // JS::TaggedColumnNumberZeroOrigin, JS::ColumnNumberZeroOrigin, JS::ColumnNumberOneOrigin
|
||||
#include "js/CompileOptions.h"
|
||||
#include "js/ContextOptions.h" // JS::ContextOptions{,Ref}
|
||||
#include "js/Conversions.h"
|
||||
|
@ -4524,7 +4524,8 @@ const char* AutoFilename::get() const {
|
|||
}
|
||||
|
||||
JS_PUBLIC_API bool DescribeScriptedCaller(JSContext* cx, AutoFilename* filename,
|
||||
uint32_t* lineno, uint32_t* column) {
|
||||
uint32_t* lineno,
|
||||
JS::ColumnNumberZeroOrigin* column) {
|
||||
if (filename) {
|
||||
filename->reset();
|
||||
}
|
||||
|
@ -4532,7 +4533,7 @@ JS_PUBLIC_API bool DescribeScriptedCaller(JSContext* cx, AutoFilename* filename,
|
|||
*lineno = 0;
|
||||
}
|
||||
if (column) {
|
||||
*column = 0;
|
||||
*column = JS::ColumnNumberZeroOrigin::zero();
|
||||
}
|
||||
|
||||
if (!cx->compartment()) {
|
||||
|
@ -4569,12 +4570,12 @@ JS_PUBLIC_API bool DescribeScriptedCaller(JSContext* cx, AutoFilename* filename,
|
|||
JS::TaggedColumnNumberZeroOrigin columnNumber;
|
||||
*lineno = i.computeLine(&columnNumber);
|
||||
if (column) {
|
||||
*column = columnNumber.zeroOriginValue();
|
||||
*column = JS::ColumnNumberZeroOrigin(columnNumber.zeroOriginValue());
|
||||
}
|
||||
} else if (column) {
|
||||
JS::TaggedColumnNumberZeroOrigin columnNumber;
|
||||
i.computeLine(&columnNumber);
|
||||
*column = columnNumber.zeroOriginValue();
|
||||
*column = JS::ColumnNumberZeroOrigin(columnNumber.zeroOriginValue());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -934,7 +934,7 @@ class MOZ_RAII JS_PUBLIC_API AutoFilename {
|
|||
*/
|
||||
extern JS_PUBLIC_API bool DescribeScriptedCaller(
|
||||
JSContext* cx, AutoFilename* filename = nullptr, uint32_t* lineno = nullptr,
|
||||
uint32_t* column = nullptr);
|
||||
JS::ColumnNumberZeroOrigin* column = nullptr);
|
||||
|
||||
extern JS_PUBLIC_API JSObject* GetScriptedCallerGlobal(JSContext* cx);
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include "jsapi.h"
|
||||
#include "js/CallAndConstruct.h" // JS::Call, JS::Construct, JS::IsCallable
|
||||
#include "js/ColumnNumber.h" // JS::ColumnNumberZeroOrigin
|
||||
#include "js/experimental/TypedData.h" // JS_GetTypedArrayLength
|
||||
#include "js/friend/WindowProxy.h" // js::IsWindowProxy
|
||||
#include "js/friend/XrayJitInfo.h" // JS::XrayJitInfo
|
||||
|
@ -217,14 +218,15 @@ bool ReportWrapperDenial(JSContext* cx, HandleId id, WrapperDenialType type,
|
|||
return false;
|
||||
}
|
||||
AutoFilename filename;
|
||||
uint32_t line = 0, column = 0;
|
||||
uint32_t line = 0;
|
||||
JS::ColumnNumberZeroOrigin column;
|
||||
DescribeScriptedCaller(cx, &filename, &line, &column);
|
||||
|
||||
// Warn to the terminal for the logs.
|
||||
NS_WARNING(
|
||||
nsPrintfCString("Silently denied access to property %s: %s (@%s:%u:%u)",
|
||||
NS_LossyConvertUTF16toASCII(propertyName).get(), reason,
|
||||
filename.get(), line, column)
|
||||
filename.get(), line, column.zeroOriginValue())
|
||||
.get());
|
||||
|
||||
// If this isn't the first warning on this topic for this global, we've
|
||||
|
@ -271,7 +273,8 @@ bool ReportWrapperDenial(JSContext* cx, HandleId id, WrapperDenialType type,
|
|||
nsString filenameStr(NS_ConvertASCIItoUTF16(filename.get()));
|
||||
nsresult rv = errorObject->InitWithWindowID(
|
||||
NS_ConvertASCIItoUTF16(errorMessage.ref()), filenameStr, u""_ns, line,
|
||||
column, nsIScriptError::warningFlag, "XPConnect", windowId);
|
||||
column.zeroOriginValue(), nsIScriptError::warningFlag, "XPConnect",
|
||||
windowId);
|
||||
NS_ENSURE_SUCCESS(rv, true);
|
||||
rv = consoleService->LogMessage(errorObject);
|
||||
NS_ENSURE_SUCCESS(rv, true);
|
||||
|
|
Загрузка…
Ссылка в новой задаче