diff --git a/dom/base/domerr.msg b/dom/base/domerr.msg index 9c84f42a3f..baf1f05735 100644 --- a/dom/base/domerr.msg +++ b/dom/base/domerr.msg @@ -157,6 +157,12 @@ DOM4_MSG_DEF(NotSupportedError, "The media resource indicated by the src attribu DOM4_MSG_DEF(SyntaxError, "The URI is malformed.", NS_ERROR_DOM_MALFORMED_URI) DOM4_MSG_DEF(SyntaxError, "Invalid header name.", NS_ERROR_DOM_INVALID_HEADER_NAME) +/* User Timing API errors */ +DOM4_MSG_DEF(SyntaxError, "An unknown mark name was provided.", NS_ERROR_DOM_UT_UNKNOWN_MARK_NAME) +DOM4_MSG_DEF(SyntaxError, "markName cannot be a performance timing attribute.", NS_ERROR_DOM_UT_INVALID_TIMING_ATTR) +DOM4_MSG_DEF(InvalidAccessError, "A PerformanceTiming attribute which isn't available yet was provided.", NS_ERROR_DOM_UT_UNAVAILABLE_ATTR) +DOM4_MSG_DEF(InvalidStateError, "Global object is unavailable.", NS_ERROR_DOM_UT_UNAVAILABLE_GLOBAL_OBJECT) + /* XMLHttpRequest errors. */ DOM4_MSG_DEF(InvalidStateError, "XMLHttpRequest has an invalid context.", NS_ERROR_DOM_INVALID_STATE_XHR_HAS_INVALID_CONTEXT) DOM4_MSG_DEF(InvalidStateError, "XMLHttpRequest state must be OPENED.", NS_ERROR_DOM_INVALID_STATE_XHR_MUST_BE_OPENED) diff --git a/dom/bindings/Errors.msg b/dom/bindings/Errors.msg index 0a9babdc73..c894c6c7b4 100644 --- a/dom/bindings/Errors.msg +++ b/dom/bindings/Errors.msg @@ -104,8 +104,6 @@ MSG_DEF(MSG_NO_NEGATIVE_ATTR, 1, JSEXN_TYPEERR, "Given attribute {0} cannot be n MSG_DEF(MSG_PMO_NO_SEPARATE_ENDMARK, 0, JSEXN_TYPEERR, "Cannot provide separate endMark argument if PerformanceMeasureOptions argument is given.") MSG_DEF(MSG_PMO_MISSING_STARTENDMARK, 0, JSEXN_TYPEERR, "PerformanceMeasureOptions must have start and/or end member.") MSG_DEF(MSG_PMO_INVALID_MEMBERS, 0, JSEXN_TYPEERR, "PerformanceMeasureOptions cannot have all of the following members: start, duration, and end.") -MSG_DEF(MSG_PMO_UNKNOWN_MARK_NAME, 1, JSEXN_SYNTAXERR, "Given mark name, {0}, is unknown.") MSG_DEF(MSG_PMO_CONSTRUCTOR_INACCESSIBLE, 0, JSEXN_TYPEERR, "Can't access PerformanceMark constructor, performance is null.") -MSG_DEF(MSG_PMO_INVALID_TIMING_ATTR, 0, JSEXN_SYNTAXERR, "markName cannot be a performance timing attribute.") MSG_DEF(MSG_PMO_UNEXPECTED_START_TIME, 0, JSEXN_TYPEERR, "Expected startTime >= 0.") MSG_DEF(MSG_PMO_INVALID_ATTR_FOR_NON_GLOBAL, 1, JSEXN_TYPEERR, "Cannot get PerformanceTiming attribute values for non-Window global object. Given: {0}.") diff --git a/dom/bindings/Exceptions.cpp b/dom/bindings/Exceptions.cpp index 1785010cc5..1d361740a2 100644 --- a/dom/bindings/Exceptions.cpp +++ b/dom/bindings/Exceptions.cpp @@ -195,6 +195,7 @@ CreateException(JSContext* aCx, nsresult aRv, const nsACString& aMessage) case NS_ERROR_MODULE_DOM_ANIM: case NS_ERROR_MODULE_DOM_PUSH: case NS_ERROR_MODULE_DOM_MEDIA: + case NS_ERROR_MODULE_DOM_USER_TIMING: if (aMessage.IsEmpty()) { return DOMException::Create(aRv); } diff --git a/dom/performance/Performance.cpp b/dom/performance/Performance.cpp index 8e5851ceed..9a1d134626 100755 --- a/dom/performance/Performance.cpp +++ b/dom/performance/Performance.cpp @@ -269,13 +269,13 @@ already_AddRefed Performance::Mark( nsCOMPtr parent = GetParentObject(); if (!parent || parent->IsDying() || !parent->GetGlobalJSObject()) { - aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); + aRv.Throw(NS_ERROR_DOM_UT_UNAVAILABLE_GLOBAL_OBJECT); return nullptr; } GlobalObject global(aCx, parent->GetGlobalJSObject()); if (global.Failed()) { - aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); + aRv.Throw(NS_ERROR_DOM_UT_UNAVAILABLE_GLOBAL_OBJECT); return nullptr; } @@ -340,7 +340,7 @@ Performance::ConvertMarkToTimestampWithString(const nsAString& aName, return arr.LastElement()->StartTime(); } - aRv.ThrowTypeError(aName); + aRv.Throw(NS_ERROR_DOM_UT_UNKNOWN_MARK_NAME); return 0; } @@ -403,8 +403,7 @@ DOMHighResTimeStamp Performance::ConvertNameToTimestamp(const nsAString& aName, GetPerformanceTimingFromString(aName); MOZ_ASSERT(endTime >= 0); if (endTime == 0) { - // Was given a PerformanceTiming attribute which isn't available yet. - aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR); + aRv.Throw(NS_ERROR_DOM_UT_UNAVAILABLE_ATTR); return 0; } diff --git a/dom/performance/PerformanceMark.cpp b/dom/performance/PerformanceMark.cpp index bf8d930c5d..771fc64467 100644 --- a/dom/performance/PerformanceMark.cpp +++ b/dom/performance/PerformanceMark.cpp @@ -54,7 +54,7 @@ already_AddRefed PerformanceMark::Constructor( if (performance->IsGlobalObjectWindow() && performance->IsPerformanceTimingAttribute(aMarkName)) { - aRv.ThrowTypeError(); + aRv.Throw(NS_ERROR_DOM_UT_INVALID_TIMING_ATTR); return nullptr; } diff --git a/xpcom/base/ErrorList.h b/xpcom/base/ErrorList.h index 5ab4bfa297..462e43289c 100644 --- a/xpcom/base/ErrorList.h +++ b/xpcom/base/ErrorList.h @@ -990,6 +990,16 @@ ERROR(NS_ERROR_DOM_MEDIA_CUBEB_INITIALIZATION_ERR, FAILURE(101)), #undef MODULE + /* ======================================================================= */ + /* 42: NS_ERROR_MODULE_DOM_USER_TIMING */ + /* ======================================================================= */ +#define MODULE NS_ERROR_MODULE_DOM_USER_TIMING + ERROR(NS_ERROR_DOM_UT_UNKNOWN_MARK_NAME, FAILURE(1)), + ERROR(NS_ERROR_DOM_UT_INVALID_TIMING_ATTR, FAILURE(2)), + ERROR(NS_ERROR_DOM_UT_UNAVAILABLE_ATTR, FAILURE(3)), + ERROR(NS_ERROR_DOM_UT_UNAVAILABLE_GLOBAL_OBJECT, FAILURE(4)), +#undef MODULE + /* ======================================================================= */ /* 51: NS_ERROR_MODULE_GENERAL */ /* ======================================================================= */ diff --git a/xpcom/base/nsError.h b/xpcom/base/nsError.h index 3743ecfbed..82d368e107 100644 --- a/xpcom/base/nsError.h +++ b/xpcom/base/nsError.h @@ -79,6 +79,7 @@ #define NS_ERROR_MODULE_DOM_ANIM 39 #define NS_ERROR_MODULE_DOM_PUSH 40 #define NS_ERROR_MODULE_DOM_MEDIA 41 +#define NS_ERROR_MODULE_DOM_USER_TIMING 42 /* NS_ERROR_MODULE_GENERAL should be used by modules that do not * care if return code values overlap. Callers of methods that