Commit d993063f authored by Tooru Fujisawa's avatar Tooru Fujisawa
Browse files

Bug 1960745 - Part 2: Add Debugger.Object.isMutedError. a=RyanVM

parent 23c803bb
Loading
Loading
Loading
Loading
+32 −0
Changes for js/src/debugger/Object.cpp: 32 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -165,6 +165,7 @@ struct MOZ_STACK_CLASS DebuggerObject::CallData {
  bool boundArgumentsGetter();
  bool allocationSiteGetter();
  bool isErrorGetter();
  bool isMutedErrorGetter();
  bool errorMessageNameGetter();
  bool errorNotesGetter();
  bool errorLineNumberGetter();
@@ -505,6 +506,11 @@ bool DebuggerObject::CallData::isErrorGetter() {
  return true;
}

bool DebuggerObject::CallData::isMutedErrorGetter() {
  args.rval().setBoolean(object->isMutedError(cx));
  return true;
}

bool DebuggerObject::CallData::errorNotesGetter() {
  return DebuggerObject::getErrorNotes(cx, object, args.rval());
}
@@ -1501,6 +1507,7 @@ const JSPropertySpec DebuggerObject::properties_[] = {
    JS_DEBUG_PSG("boundArguments", boundArgumentsGetter),
    JS_DEBUG_PSG("allocationSite", allocationSiteGetter),
    JS_DEBUG_PSG("isError", isErrorGetter),
    JS_DEBUG_PSG("isMutedError", isMutedErrorGetter),
    JS_DEBUG_PSG("errorMessageName", errorMessageNameGetter),
    JS_DEBUG_PSG("errorNotes", errorNotesGetter),
    JS_DEBUG_PSG("errorLineNumber", errorLineNumberGetter),
@@ -1674,6 +1681,31 @@ bool DebuggerObject::isError() const {
  return referent->is<ErrorObject>();
}

bool DebuggerObject::isMutedError(JSContext* cx) const {
  JS::Rooted<JSObject*> referent(cx, this->referent());

  if (IsCrossCompartmentWrapper(referent)) {
    // We only check for error classes, so CheckedUnwrapStatic is OK.
    referent = CheckedUnwrapStatic(referent);
    if (!referent) {
      return false;
    }
  }

  if (!referent->is<ErrorObject>()) {
    return false;
  }

  JSErrorReport* report = referent->as<ErrorObject>().getErrorReport();
  if (!report) {
    // If the error report was missing, isMuted field can never be true,
    // and just returning false is OK.
    return false;
  }

  return report->isMuted;
}

/* static */
bool DebuggerObject::getClassName(JSContext* cx, Handle<DebuggerObject*> object,
                                  MutableHandleString result) {
+1 −0
Changes for js/src/debugger/Object.h: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -174,6 +174,7 @@ class DebuggerObject : public NativeObject {
  bool isScriptedProxy() const;
  bool isPromise() const;
  bool isError() const;
  bool isMutedError(JSContext* cx) const;

  bool name(JSContext* cx, JS::MutableHandle<JSAtom*> result) const;
  bool displayName(JSContext* cx, JS::MutableHandle<JSAtom*> result) const;
+4 −0
Changes for js/src/doc/Debugger/Debugger.Object.md: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -157,6 +157,10 @@ is a function proxy or not debuggee code, this is `undefined`.
### `isError`
`true` if the referent is any potentially wrapped Error; `false` otherwise.

### `isMutedError`
`true` if the referent is any potentially wrapped Error associated with a muted
error report; `false` otherwise.

### `errorMessageName`
If the referent is an error created with an engine internal message template
this is a string which is the name of the template; `undefined` otherwise.