2015-05-03 19:32:37 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2013-09-09 03:28:50 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#include "mozilla/dom/DOMException.h"
|
|
|
|
|
|
|
|
#include "jsprf.h"
|
2013-12-09 02:52:54 +00:00
|
|
|
#include "mozilla/ArrayUtils.h"
|
2013-09-10 15:29:43 +00:00
|
|
|
#include "mozilla/HoldDropJSObjects.h"
|
2013-09-09 03:29:21 +00:00
|
|
|
#include "mozilla/dom/Exceptions.h"
|
2013-09-09 03:28:50 +00:00
|
|
|
#include "nsContentUtils.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsIClassInfoImpl.h"
|
|
|
|
#include "nsIDocument.h"
|
|
|
|
#include "nsIDOMDOMException.h"
|
|
|
|
#include "nsIException.h"
|
2013-09-23 17:29:27 +00:00
|
|
|
#include "nsIProgrammingLanguage.h"
|
2013-09-09 03:28:50 +00:00
|
|
|
#include "nsMemory.h"
|
|
|
|
#include "prprf.h"
|
|
|
|
#include "xpcprivate.h"
|
|
|
|
|
|
|
|
#include "mozilla/dom/DOMExceptionBinding.h"
|
2014-07-04 05:25:16 +00:00
|
|
|
#include "mozilla/ErrorResult.h"
|
2013-09-09 03:28:50 +00:00
|
|
|
|
|
|
|
using namespace mozilla;
|
|
|
|
|
|
|
|
enum DOM4ErrorTypeCodeMap {
|
|
|
|
/* DOM4 errors from http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#domexception */
|
|
|
|
IndexSizeError = nsIDOMDOMException::INDEX_SIZE_ERR,
|
|
|
|
HierarchyRequestError = nsIDOMDOMException::HIERARCHY_REQUEST_ERR,
|
|
|
|
WrongDocumentError = nsIDOMDOMException::WRONG_DOCUMENT_ERR,
|
|
|
|
InvalidCharacterError = nsIDOMDOMException::INVALID_CHARACTER_ERR,
|
|
|
|
NoModificationAllowedError = nsIDOMDOMException::NO_MODIFICATION_ALLOWED_ERR,
|
|
|
|
NotFoundError = nsIDOMDOMException::NOT_FOUND_ERR,
|
|
|
|
NotSupportedError = nsIDOMDOMException::NOT_SUPPORTED_ERR,
|
|
|
|
// Can't remove until setNamedItem is removed
|
|
|
|
InUseAttributeError = nsIDOMDOMException::INUSE_ATTRIBUTE_ERR,
|
|
|
|
InvalidStateError = nsIDOMDOMException::INVALID_STATE_ERR,
|
|
|
|
SyntaxError = nsIDOMDOMException::SYNTAX_ERR,
|
|
|
|
InvalidModificationError = nsIDOMDOMException::INVALID_MODIFICATION_ERR,
|
|
|
|
NamespaceError = nsIDOMDOMException::NAMESPACE_ERR,
|
|
|
|
InvalidAccessError = nsIDOMDOMException::INVALID_ACCESS_ERR,
|
|
|
|
TypeMismatchError = nsIDOMDOMException::TYPE_MISMATCH_ERR,
|
|
|
|
SecurityError = nsIDOMDOMException::SECURITY_ERR,
|
|
|
|
NetworkError = nsIDOMDOMException::NETWORK_ERR,
|
|
|
|
AbortError = nsIDOMDOMException::ABORT_ERR,
|
|
|
|
URLMismatchError = nsIDOMDOMException::URL_MISMATCH_ERR,
|
|
|
|
QuotaExceededError = nsIDOMDOMException::QUOTA_EXCEEDED_ERR,
|
|
|
|
TimeoutError = nsIDOMDOMException::TIMEOUT_ERR,
|
|
|
|
InvalidNodeTypeError = nsIDOMDOMException::INVALID_NODE_TYPE_ERR,
|
|
|
|
DataCloneError = nsIDOMDOMException::DATA_CLONE_ERR,
|
2014-04-04 17:09:10 +00:00
|
|
|
InvalidPointerId = nsIDOMDOMException::INVALID_POINTER_ERR,
|
2013-09-09 03:28:50 +00:00
|
|
|
EncodingError = 0,
|
|
|
|
|
|
|
|
/* XXX Should be JavaScript native errors */
|
|
|
|
TypeError = 0,
|
|
|
|
RangeError = 0,
|
|
|
|
|
|
|
|
/* IndexedDB errors http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#exceptions */
|
|
|
|
UnknownError = 0,
|
|
|
|
ConstraintError = 0,
|
|
|
|
DataError = 0,
|
|
|
|
TransactionInactiveError = 0,
|
|
|
|
ReadOnlyError = 0,
|
|
|
|
VersionError = 0,
|
|
|
|
|
|
|
|
/* File API errors http://dev.w3.org/2006/webapi/FileAPI/#ErrorAndException */
|
|
|
|
NotReadableError = 0,
|
|
|
|
|
|
|
|
/* FileHandle API errors */
|
2014-06-12 03:35:29 +00:00
|
|
|
FileHandleInactiveError = 0,
|
2014-05-15 10:20:00 +00:00
|
|
|
|
|
|
|
/* WebCrypto errors https://dvcs.w3.org/hg/webcrypto-api/raw-file/tip/spec/Overview.html#dfn-DataError */
|
|
|
|
OperationError = 0,
|
2014-08-25 06:51:20 +00:00
|
|
|
|
|
|
|
/* Bluetooth API errors */
|
|
|
|
BtFailError = 0,
|
|
|
|
BtNotReadyError = 0,
|
|
|
|
BtNoMemError = 0,
|
|
|
|
BtBusyError = 0,
|
|
|
|
BtDoneError = 0,
|
|
|
|
BtUnsupportedError = 0,
|
|
|
|
BtParmInvalidError = 0,
|
|
|
|
BtUnhandledError = 0,
|
|
|
|
BtAuthFailureError = 0,
|
|
|
|
BtRmtDevDownError = 0,
|
|
|
|
BtAuthRejectedError = 0,
|
2013-09-09 03:28:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#define DOM4_MSG_DEF(name, message, nsresult) {(nsresult), name, #name, message},
|
|
|
|
#define DOM_MSG_DEF(val, message) {(val), NS_ERROR_GET_CODE(val), #val, message},
|
|
|
|
|
|
|
|
static const struct ResultStruct
|
|
|
|
{
|
|
|
|
nsresult mNSResult;
|
|
|
|
uint16_t mCode;
|
|
|
|
const char* mName;
|
|
|
|
const char* mMessage;
|
|
|
|
} sDOMErrorMsgMap[] = {
|
|
|
|
#include "domerr.msg"
|
|
|
|
};
|
|
|
|
|
|
|
|
#undef DOM4_MSG_DEF
|
|
|
|
#undef DOM_MSG_DEF
|
|
|
|
|
|
|
|
static void
|
|
|
|
NSResultToNameAndMessage(nsresult aNSResult,
|
2014-01-20 16:51:41 +00:00
|
|
|
nsCString& aName,
|
|
|
|
nsCString& aMessage,
|
2013-09-09 03:28:50 +00:00
|
|
|
uint16_t* aCode)
|
|
|
|
{
|
2014-01-20 16:51:41 +00:00
|
|
|
aName.Truncate();
|
|
|
|
aMessage.Truncate();
|
2013-09-09 03:28:50 +00:00
|
|
|
*aCode = 0;
|
|
|
|
for (uint32_t idx = 0; idx < ArrayLength(sDOMErrorMsgMap); idx++) {
|
|
|
|
if (aNSResult == sDOMErrorMsgMap[idx].mNSResult) {
|
2014-01-20 16:51:41 +00:00
|
|
|
aName.Rebind(sDOMErrorMsgMap[idx].mName,
|
|
|
|
strlen(sDOMErrorMsgMap[idx].mName));
|
|
|
|
aMessage.Rebind(sDOMErrorMsgMap[idx].mMessage,
|
|
|
|
strlen(sDOMErrorMsgMap[idx].mMessage));
|
2013-09-09 03:28:50 +00:00
|
|
|
*aCode = sDOMErrorMsgMap[idx].mCode;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_WARNING("Huh, someone is throwing non-DOM errors using the DOM module!");
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2014-01-20 16:51:41 +00:00
|
|
|
NS_GetNameAndMessageForDOMNSResult(nsresult aNSResult, nsACString& aName,
|
|
|
|
nsACString& aMessage, uint16_t* aCode)
|
2013-09-09 03:28:50 +00:00
|
|
|
{
|
2014-01-20 16:51:41 +00:00
|
|
|
nsCString name;
|
|
|
|
nsCString message;
|
2013-09-09 03:28:50 +00:00
|
|
|
uint16_t code = 0;
|
2014-01-20 16:51:41 +00:00
|
|
|
NSResultToNameAndMessage(aNSResult, name, message, &code);
|
2013-09-09 03:28:50 +00:00
|
|
|
|
2014-01-20 16:51:41 +00:00
|
|
|
if (!name.IsEmpty() && !message.IsEmpty()) {
|
|
|
|
aName = name;
|
|
|
|
aMessage = message;
|
2013-09-09 03:28:50 +00:00
|
|
|
if (aCode) {
|
|
|
|
*aCode = code;
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
bool Exception::sEverMadeOneFromFactory = false;
|
|
|
|
|
|
|
|
NS_IMPL_CLASSINFO(Exception, nullptr, nsIClassInfo::DOM_OBJECT,
|
|
|
|
NS_XPCEXCEPTION_CID)
|
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(Exception)
|
2014-11-07 19:40:04 +00:00
|
|
|
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
|
|
|
NS_INTERFACE_MAP_ENTRY(Exception)
|
2013-09-09 03:28:50 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIException)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIXPCException)
|
|
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIException)
|
|
|
|
NS_IMPL_QUERY_CLASSINFO(Exception)
|
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(Exception)
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(Exception)
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_CLASS(Exception)
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(Exception)
|
2014-01-08 00:53:18 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mLocation)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mInner)
|
2013-09-09 03:28:50 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(Exception)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_JSVAL_MEMBER_CALLBACK(mThrownJSVal);
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_END
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(Exception)
|
2014-01-08 00:53:18 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mLocation)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mInner)
|
2013-09-09 03:28:50 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
|
2013-10-19 18:59:31 +00:00
|
|
|
tmp->mThrownJSVal.setNull();
|
2013-09-09 03:28:50 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
|
|
|
|
2014-04-27 07:06:00 +00:00
|
|
|
NS_IMPL_CI_INTERFACE_GETTER(Exception, nsIXPCException)
|
2013-09-09 03:28:50 +00:00
|
|
|
|
2014-01-20 16:51:41 +00:00
|
|
|
Exception::Exception(const nsACString& aMessage,
|
2013-09-09 03:28:50 +00:00
|
|
|
nsresult aResult,
|
2014-01-20 16:51:41 +00:00
|
|
|
const nsACString& aName,
|
2013-09-09 03:28:50 +00:00
|
|
|
nsIStackFrame *aLocation,
|
|
|
|
nsISupports *aData)
|
2014-01-20 16:51:41 +00:00
|
|
|
: mResult(NS_OK),
|
2013-09-09 03:28:50 +00:00
|
|
|
mLineNumber(0),
|
|
|
|
mInitialized(false),
|
|
|
|
mHoldingJSVal(false)
|
|
|
|
{
|
|
|
|
// A little hack... The nsIGenericModule nsIClassInfo scheme relies on there
|
|
|
|
// having been at least one instance made via the factory. Otherwise, the
|
|
|
|
// shared factory/classinsance object never gets created and our QI getter
|
|
|
|
// for our instance's pointer to our nsIClassInfo will always return null.
|
|
|
|
// This is bad because it means that wrapped exceptions will never have a
|
|
|
|
// shared prototype. So... We force one to be created via the factory
|
|
|
|
// *once* and then go about our business.
|
|
|
|
if (!sEverMadeOneFromFactory) {
|
|
|
|
nsCOMPtr<nsIXPCException> e =
|
|
|
|
do_CreateInstance(XPC_EXCEPTION_CONTRACTID);
|
|
|
|
sEverMadeOneFromFactory = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIStackFrame> location;
|
|
|
|
if (aLocation) {
|
|
|
|
location = aLocation;
|
|
|
|
} else {
|
2013-09-09 03:29:21 +00:00
|
|
|
location = GetCurrentJSStack();
|
2013-09-09 03:28:50 +00:00
|
|
|
// it is legal for there to be no active JS stack, if C++ code
|
|
|
|
// is operating on a JS-implemented interface pointer without
|
|
|
|
// having been called in turn by JS. This happens in the JS
|
|
|
|
// component loader, and will become more common as additional
|
|
|
|
// components are implemented in JS.
|
|
|
|
}
|
|
|
|
// We want to trim off any leading native 'dataless' frames
|
|
|
|
if (location) {
|
|
|
|
while (1) {
|
|
|
|
uint32_t language;
|
|
|
|
int32_t lineNumber;
|
|
|
|
if (NS_FAILED(location->GetLanguage(&language)) ||
|
|
|
|
language == nsIProgrammingLanguage::JAVASCRIPT ||
|
|
|
|
NS_FAILED(location->GetLineNumber(&lineNumber)) ||
|
|
|
|
lineNumber) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
nsCOMPtr<nsIStackFrame> caller;
|
|
|
|
if (NS_FAILED(location->GetCaller(getter_AddRefs(caller))) || !caller) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
location = caller;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Initialize(aMessage, aResult, aName, location, aData, nullptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
Exception::Exception()
|
2014-01-20 16:51:41 +00:00
|
|
|
: mResult(NS_OK),
|
2013-09-09 03:28:50 +00:00
|
|
|
mLineNumber(-1),
|
|
|
|
mInitialized(false),
|
|
|
|
mHoldingJSVal(false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Exception::~Exception()
|
|
|
|
{
|
|
|
|
if (mHoldingJSVal) {
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
|
|
|
|
mozilla::DropJSObjects(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
Exception::StealJSVal(JS::Value* aVp)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
|
|
|
|
if (mHoldingJSVal) {
|
|
|
|
*aVp = mThrownJSVal;
|
2013-09-09 03:29:21 +00:00
|
|
|
mThrownJSVal.setNull();
|
2013-09-09 03:28:50 +00:00
|
|
|
|
|
|
|
mozilla::DropJSObjects(this);
|
|
|
|
mHoldingJSVal = false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Exception::StowJSVal(JS::Value& aVp)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
|
|
|
|
mThrownJSVal = aVp;
|
|
|
|
if (!mHoldingJSVal) {
|
|
|
|
mozilla::HoldJSObjects(this);
|
|
|
|
mHoldingJSVal = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-20 16:51:41 +00:00
|
|
|
/* readonly attribute AUTF8String message; */
|
2013-09-09 03:28:50 +00:00
|
|
|
NS_IMETHODIMP
|
2014-01-20 16:51:41 +00:00
|
|
|
Exception::GetMessageMoz(nsACString& aMessage)
|
2013-09-09 03:28:50 +00:00
|
|
|
{
|
|
|
|
NS_ENSURE_TRUE(mInitialized, NS_ERROR_NOT_INITIALIZED);
|
|
|
|
|
2014-01-20 16:51:41 +00:00
|
|
|
aMessage.Assign(mMessage);
|
2013-09-09 03:28:50 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* readonly attribute nsresult result; */
|
|
|
|
NS_IMETHODIMP
|
|
|
|
Exception::GetResult(nsresult* aResult)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aResult);
|
|
|
|
NS_ENSURE_TRUE(mInitialized, NS_ERROR_NOT_INITIALIZED);
|
|
|
|
|
|
|
|
*aResult = mResult;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-01-20 16:51:41 +00:00
|
|
|
/* readonly attribute AUTF8String name; */
|
2013-09-09 03:28:50 +00:00
|
|
|
NS_IMETHODIMP
|
2014-01-20 16:51:41 +00:00
|
|
|
Exception::GetName(nsACString& aName)
|
2013-09-09 03:28:50 +00:00
|
|
|
{
|
|
|
|
NS_ENSURE_TRUE(mInitialized, NS_ERROR_NOT_INITIALIZED);
|
|
|
|
|
2014-01-20 16:51:41 +00:00
|
|
|
if (!mName.IsEmpty()) {
|
|
|
|
aName.Assign(mName);
|
|
|
|
} else {
|
|
|
|
aName.Truncate();
|
|
|
|
|
|
|
|
const char* name = nullptr;
|
2013-09-09 03:28:50 +00:00
|
|
|
nsXPCException::NameAndFormatForNSResult(mResult, &name, nullptr);
|
|
|
|
|
2014-01-20 16:51:41 +00:00
|
|
|
if (name) {
|
|
|
|
aName.Assign(name);
|
|
|
|
}
|
2013-09-09 03:28:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-04-12 02:20:40 +00:00
|
|
|
/* readonly attribute AString filename; */
|
2013-09-09 03:28:50 +00:00
|
|
|
NS_IMETHODIMP
|
2014-04-12 02:20:40 +00:00
|
|
|
Exception::GetFilename(nsAString& aFilename)
|
2013-09-09 03:28:50 +00:00
|
|
|
{
|
|
|
|
NS_ENSURE_TRUE(mInitialized, NS_ERROR_NOT_INITIALIZED);
|
2014-01-08 00:53:18 +00:00
|
|
|
|
|
|
|
if (mLocation) {
|
|
|
|
return mLocation->GetFilename(aFilename);
|
|
|
|
}
|
|
|
|
|
2014-01-20 16:51:41 +00:00
|
|
|
aFilename.Assign(mFilename);
|
|
|
|
return NS_OK;
|
2013-09-09 03:28:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* readonly attribute uint32_t lineNumber; */
|
|
|
|
NS_IMETHODIMP
|
|
|
|
Exception::GetLineNumber(uint32_t *aLineNumber)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aLineNumber);
|
|
|
|
NS_ENSURE_TRUE(mInitialized, NS_ERROR_NOT_INITIALIZED);
|
|
|
|
|
2014-01-08 00:53:18 +00:00
|
|
|
if (mLocation) {
|
|
|
|
int32_t lineno;
|
|
|
|
nsresult rv = mLocation->GetLineNumber(&lineno);
|
|
|
|
*aLineNumber = lineno;
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2013-09-09 03:28:50 +00:00
|
|
|
*aLineNumber = mLineNumber;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* readonly attribute uint32_t columnNumber; */
|
|
|
|
NS_IMETHODIMP
|
|
|
|
Exception::GetColumnNumber(uint32_t* aColumnNumber)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aColumnNumber);
|
|
|
|
NS_ENSURE_TRUE(mInitialized, NS_ERROR_NOT_INITIALIZED);
|
|
|
|
|
|
|
|
*aColumnNumber = 0;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* readonly attribute nsIStackFrame location; */
|
|
|
|
NS_IMETHODIMP
|
|
|
|
Exception::GetLocation(nsIStackFrame** aLocation)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aLocation);
|
|
|
|
NS_ENSURE_TRUE(mInitialized, NS_ERROR_NOT_INITIALIZED);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIStackFrame> location = mLocation;
|
|
|
|
location.forget(aLocation);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* readonly attribute nsISupports data; */
|
|
|
|
NS_IMETHODIMP
|
|
|
|
Exception::GetData(nsISupports** aData)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aData);
|
|
|
|
NS_ENSURE_TRUE(mInitialized, NS_ERROR_NOT_INITIALIZED);
|
|
|
|
|
|
|
|
nsCOMPtr<nsISupports> data = mData;
|
|
|
|
data.forget(aData);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* readonly attribute nsIException inner; */
|
|
|
|
NS_IMETHODIMP
|
|
|
|
Exception::GetInner(nsIException** aException)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aException);
|
|
|
|
NS_ENSURE_TRUE(mInitialized, NS_ERROR_NOT_INITIALIZED);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIException> inner = mInner;
|
|
|
|
inner.forget(aException);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-01-20 16:51:41 +00:00
|
|
|
/* AUTF8String toString (); */
|
2013-09-09 03:28:50 +00:00
|
|
|
NS_IMETHODIMP
|
2014-01-20 16:51:41 +00:00
|
|
|
Exception::ToString(nsACString& _retval)
|
2013-09-09 03:28:50 +00:00
|
|
|
{
|
|
|
|
NS_ENSURE_TRUE(mInitialized, NS_ERROR_NOT_INITIALIZED);
|
|
|
|
|
|
|
|
static const char defaultMsg[] = "<no message>";
|
|
|
|
static const char defaultLocation[] = "<unknown>";
|
|
|
|
static const char format[] =
|
|
|
|
"[Exception... \"%s\" nsresult: \"0x%x (%s)\" location: \"%s\" data: %s]";
|
|
|
|
|
2014-01-20 16:51:41 +00:00
|
|
|
nsCString location;
|
2013-09-09 03:28:50 +00:00
|
|
|
|
|
|
|
if (mLocation) {
|
|
|
|
// we need to free this if it does not fail
|
2014-01-20 16:51:41 +00:00
|
|
|
nsresult rv = mLocation->ToString(location);
|
2013-09-09 03:28:50 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
}
|
|
|
|
|
2014-01-20 16:51:41 +00:00
|
|
|
if (location.IsEmpty()) {
|
|
|
|
location.Assign(defaultLocation);
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* msg = mMessage.IsEmpty() ? nullptr : mMessage.get();
|
|
|
|
|
|
|
|
const char* resultName = mName.IsEmpty() ? nullptr: mName.get();
|
2013-09-09 03:28:50 +00:00
|
|
|
if (!resultName &&
|
|
|
|
!nsXPCException::NameAndFormatForNSResult(mResult, &resultName,
|
|
|
|
(!msg) ? &msg : nullptr)) {
|
|
|
|
if (!msg) {
|
|
|
|
msg = defaultMsg;
|
|
|
|
}
|
|
|
|
resultName = "<unknown>";
|
|
|
|
}
|
|
|
|
const char* data = mData ? "yes" : "no";
|
|
|
|
|
2014-01-20 16:51:41 +00:00
|
|
|
_retval.Truncate();
|
|
|
|
_retval.AppendPrintf(format, msg, mResult, resultName,
|
|
|
|
location.get(), data);
|
|
|
|
return NS_OK;
|
2013-09-09 03:28:50 +00:00
|
|
|
}
|
|
|
|
|
2014-01-20 16:51:41 +00:00
|
|
|
/* void initialize (in AUTF8String aMessage, in nsresult aResult,
|
|
|
|
* in AUTF8String aName, in nsIStackFrame aLocation,
|
|
|
|
* in nsISupports aData, in nsIException aInner); */
|
2013-09-09 03:28:50 +00:00
|
|
|
NS_IMETHODIMP
|
2014-01-20 16:51:41 +00:00
|
|
|
Exception::Initialize(const nsACString& aMessage, nsresult aResult,
|
|
|
|
const nsACString& aName, nsIStackFrame *aLocation,
|
|
|
|
nsISupports *aData, nsIException *aInner)
|
2013-09-09 03:28:50 +00:00
|
|
|
{
|
|
|
|
NS_ENSURE_FALSE(mInitialized, NS_ERROR_ALREADY_INITIALIZED);
|
|
|
|
|
2014-01-20 16:51:41 +00:00
|
|
|
mMessage = aMessage;
|
|
|
|
mName = aName;
|
2013-09-09 03:28:50 +00:00
|
|
|
mResult = aResult;
|
|
|
|
|
|
|
|
if (aLocation) {
|
|
|
|
mLocation = aLocation;
|
|
|
|
} else {
|
|
|
|
nsresult rv;
|
|
|
|
nsXPConnect* xpc = nsXPConnect::XPConnect();
|
|
|
|
rv = xpc->GetCurrentJSStack(getter_AddRefs(mLocation));
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mData = aData;
|
|
|
|
mInner = aInner;
|
|
|
|
|
|
|
|
mInitialized = true;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
JSObject*
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 14:13:33 +00:00
|
|
|
Exception::WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto)
|
2013-09-09 03:28:50 +00:00
|
|
|
{
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 14:13:33 +00:00
|
|
|
return ExceptionBinding::Wrap(cx, this, aGivenProto);
|
2013-09-09 03:28:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Exception::GetMessageMoz(nsString& retval)
|
|
|
|
{
|
2014-01-20 16:51:41 +00:00
|
|
|
nsCString str;
|
2013-09-09 03:28:50 +00:00
|
|
|
#ifdef DEBUG
|
2014-05-15 10:20:00 +00:00
|
|
|
DebugOnly<nsresult> rv =
|
2013-09-09 03:28:50 +00:00
|
|
|
#endif
|
2014-01-20 16:51:41 +00:00
|
|
|
GetMessageMoz(str);
|
2013-09-09 03:28:50 +00:00
|
|
|
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
|
|
|
CopyUTF8toUTF16(str, retval);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
Exception::Result() const
|
|
|
|
{
|
|
|
|
return (uint32_t)mResult;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Exception::GetName(nsString& retval)
|
|
|
|
{
|
2014-01-20 16:51:41 +00:00
|
|
|
nsCString str;
|
2013-09-09 03:28:50 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
DebugOnly<nsresult> rv =
|
|
|
|
#endif
|
2014-01-20 16:51:41 +00:00
|
|
|
GetName(str);
|
2013-09-09 03:28:50 +00:00
|
|
|
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
|
|
|
CopyUTF8toUTF16(str, retval);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
Exception::LineNumber() const
|
|
|
|
{
|
2014-01-08 00:53:18 +00:00
|
|
|
if (mLocation) {
|
|
|
|
int32_t lineno;
|
|
|
|
if (NS_SUCCEEDED(mLocation->GetLineNumber(&lineno))) {
|
|
|
|
return lineno;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-09-09 03:28:50 +00:00
|
|
|
return mLineNumber;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
Exception::ColumnNumber() const
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<nsIStackFrame>
|
|
|
|
Exception::GetLocation() const
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIStackFrame> location = mLocation;
|
|
|
|
return location.forget();
|
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<nsISupports>
|
|
|
|
Exception::GetInner() const
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIException> inner = mInner;
|
|
|
|
return inner.forget();
|
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<nsISupports>
|
|
|
|
Exception::GetData() const
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsISupports> data = mData;
|
|
|
|
return data.forget();
|
|
|
|
}
|
|
|
|
|
2014-07-04 05:25:16 +00:00
|
|
|
void
|
|
|
|
Exception::GetStack(nsAString& aStack, ErrorResult& aRv) const
|
|
|
|
{
|
|
|
|
if (mLocation) {
|
|
|
|
aRv = mLocation->GetFormattedStack(aStack);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-09 03:28:50 +00:00
|
|
|
void
|
|
|
|
Exception::Stringify(nsString& retval)
|
|
|
|
{
|
2014-01-20 16:51:41 +00:00
|
|
|
nsCString str;
|
2013-09-09 03:28:50 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
DebugOnly<nsresult> rv =
|
|
|
|
#endif
|
2014-01-20 16:51:41 +00:00
|
|
|
ToString(str);
|
2013-09-09 03:28:50 +00:00
|
|
|
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
|
|
|
CopyUTF8toUTF16(str, retval);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMPL_ADDREF_INHERITED(DOMException, Exception)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(DOMException, Exception)
|
|
|
|
NS_INTERFACE_MAP_BEGIN(DOMException)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMDOMException)
|
|
|
|
NS_INTERFACE_MAP_END_INHERITING(Exception)
|
|
|
|
|
2014-01-20 16:51:41 +00:00
|
|
|
DOMException::DOMException(nsresult aRv, const nsACString& aMessage,
|
|
|
|
const nsACString& aName, uint16_t aCode)
|
|
|
|
: Exception(EmptyCString(), aRv, EmptyCString(), nullptr, nullptr),
|
2013-09-09 03:28:50 +00:00
|
|
|
mName(aName),
|
|
|
|
mMessage(aMessage),
|
|
|
|
mCode(aCode)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
DOMException::GetCode(uint16_t* aCode)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aCode);
|
|
|
|
*aCode = mCode;
|
|
|
|
|
|
|
|
// Warn only when the code was changed (other than DOM Core)
|
|
|
|
// or the code is useless (zero)
|
|
|
|
if (NS_ERROR_GET_MODULE(mResult) != NS_ERROR_MODULE_DOM || !mCode) {
|
|
|
|
nsCOMPtr<nsIDocument> doc = nsContentUtils::GetDocumentFromCaller();
|
|
|
|
if (doc) {
|
|
|
|
doc->WarnOnceAbout(nsIDocument::eDOMExceptionCode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2014-01-20 16:51:41 +00:00
|
|
|
DOMException::ToString(nsACString& aReturn)
|
2013-09-09 03:28:50 +00:00
|
|
|
{
|
2014-01-20 16:51:41 +00:00
|
|
|
aReturn.Truncate();
|
2013-09-09 03:28:50 +00:00
|
|
|
|
|
|
|
static const char defaultMsg[] = "<no message>";
|
|
|
|
static const char defaultLocation[] = "<unknown>";
|
|
|
|
static const char defaultName[] = "<unknown>";
|
|
|
|
static const char format[] =
|
|
|
|
"[Exception... \"%s\" code: \"%d\" nsresult: \"0x%x (%s)\" location: \"%s\"]";
|
|
|
|
|
|
|
|
nsAutoCString location;
|
|
|
|
|
|
|
|
if (mInner) {
|
2014-04-12 02:20:40 +00:00
|
|
|
nsString filename;
|
2014-01-20 16:51:41 +00:00
|
|
|
mInner->GetFilename(filename);
|
2013-09-09 03:28:50 +00:00
|
|
|
|
|
|
|
if (!filename.IsEmpty()) {
|
|
|
|
uint32_t line_nr = 0;
|
|
|
|
|
|
|
|
mInner->GetLineNumber(&line_nr);
|
|
|
|
|
2014-04-12 02:20:40 +00:00
|
|
|
char *temp = PR_smprintf("%s Line: %d",
|
|
|
|
NS_ConvertUTF16toUTF8(filename).get(),
|
|
|
|
line_nr);
|
2013-09-09 03:28:50 +00:00
|
|
|
if (temp) {
|
|
|
|
location.Assign(temp);
|
|
|
|
PR_smprintf_free(temp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (location.IsEmpty()) {
|
|
|
|
location = defaultLocation;
|
|
|
|
}
|
|
|
|
|
2014-01-20 16:51:41 +00:00
|
|
|
const char* msg = !mMessage.IsEmpty() ? mMessage.get() : defaultMsg;
|
|
|
|
const char* resultName = !mName.IsEmpty() ? mName.get() : defaultName;
|
2013-09-09 03:28:50 +00:00
|
|
|
|
2014-01-20 16:51:41 +00:00
|
|
|
aReturn.AppendPrintf(format, msg, mCode, mResult, resultName,
|
|
|
|
location.get());
|
2013-09-09 03:28:50 +00:00
|
|
|
|
2014-01-20 16:51:41 +00:00
|
|
|
return NS_OK;
|
2013-09-09 03:28:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DOMException::GetName(nsString& retval)
|
|
|
|
{
|
|
|
|
CopyUTF8toUTF16(mName, retval);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DOMException::GetMessageMoz(nsString& retval)
|
|
|
|
{
|
|
|
|
CopyUTF8toUTF16(mMessage, retval);
|
|
|
|
}
|
|
|
|
|
2015-01-02 22:08:33 +00:00
|
|
|
already_AddRefed<DOMException>
|
|
|
|
DOMException::Constructor(GlobalObject& /* unused */,
|
|
|
|
const nsAString& aMessage,
|
|
|
|
const Optional<nsAString>& aName,
|
|
|
|
ErrorResult& aError)
|
|
|
|
{
|
|
|
|
nsresult exceptionResult = NS_OK;
|
|
|
|
uint16_t exceptionCode = 0;
|
|
|
|
nsCString name(NS_LITERAL_CSTRING("Error"));
|
|
|
|
|
|
|
|
if (aName.WasPassed()) {
|
|
|
|
CopyUTF16toUTF8(aName.Value(), name);
|
|
|
|
for (uint32_t idx = 0; idx < ArrayLength(sDOMErrorMsgMap); idx++) {
|
|
|
|
if (name.EqualsASCII(sDOMErrorMsgMap[idx].mName)) {
|
|
|
|
exceptionResult = sDOMErrorMsgMap[idx].mNSResult;
|
|
|
|
exceptionCode = sDOMErrorMsgMap[idx].mCode;
|
2015-02-13 19:34:53 +00:00
|
|
|
break;
|
2015-01-02 22:08:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsRefPtr<DOMException> retval =
|
|
|
|
new DOMException(exceptionResult,
|
|
|
|
NS_ConvertUTF16toUTF8(aMessage),
|
|
|
|
name,
|
|
|
|
exceptionCode);
|
|
|
|
return retval.forget();
|
|
|
|
}
|
|
|
|
|
2013-09-09 03:28:50 +00:00
|
|
|
JSObject*
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 14:13:33 +00:00
|
|
|
DOMException::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
2013-09-09 03:28:50 +00:00
|
|
|
{
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 14:13:33 +00:00
|
|
|
return DOMExceptionBinding::Wrap(aCx, this, aGivenProto);
|
2013-09-09 03:28:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* static */already_AddRefed<DOMException>
|
|
|
|
DOMException::Create(nsresult aRv)
|
|
|
|
{
|
2014-01-20 16:51:41 +00:00
|
|
|
nsCString name;
|
|
|
|
nsCString message;
|
2013-09-09 03:28:50 +00:00
|
|
|
uint16_t code;
|
2014-01-20 16:51:41 +00:00
|
|
|
NSResultToNameAndMessage(aRv, name, message, &code);
|
2013-09-09 03:28:50 +00:00
|
|
|
nsRefPtr<DOMException> inst =
|
|
|
|
new DOMException(aRv, message, name, code);
|
|
|
|
return inst.forget();
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|