Bug 1083851 part 4. Expose promise stacks on PromiseDebugging.
--- a/dom/promise/PromiseDebugging.cpp
+++ b/dom/promise/PromiseDebugging.cpp
@@ -31,10 +31,31 @@ PromiseDebugging::GetState(GlobalObject&
case Promise::Rejected:
aState.mState = PromiseDebuggingState::Rejected;
JS::ExposeValueToActiveJS(aPromise.mResult);
aState.mReason = aPromise.mResult;
break;
}
}
+/* static */ void
+PromiseDebugging::GetAllocationStack(GlobalObject&, Promise& aPromise,
+ JS::MutableHandle<JSObject*> aStack)
+{
+ aStack.set(aPromise.mAllocationStack);
+}
+
+/* static */ void
+PromiseDebugging::GetRejectionStack(GlobalObject&, Promise& aPromise,
+ JS::MutableHandle<JSObject*> aStack)
+{
+ aStack.set(aPromise.mRejectionStack);
+}
+
+/* static */ void
+PromiseDebugging::GetFullfillmentStack(GlobalObject&, Promise& aPromise,
+ JS::MutableHandle<JSObject*> aStack)
+{
+ aStack.set(aPromise.mFullfillmentStack);
+}
+
} // namespace dom
} // namespace mozilla
--- a/dom/promise/PromiseDebugging.h
+++ b/dom/promise/PromiseDebugging.h
@@ -2,26 +2,35 @@
/* vim: set ts=2 et sw=2 tw=80: */
/* 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/. */
#ifndef mozilla_dom_PromiseDebugging_h
#define mozilla_dom_PromiseDebugging_h
+#include "js/TypeDecls.h"
+
namespace mozilla {
namespace dom {
class Promise;
struct PromiseDebuggingStateHolder;
class GlobalObject;
class PromiseDebugging
{
public:
static void GetState(GlobalObject&, Promise& aPromise,
PromiseDebuggingStateHolder& aState);
+
+ static void GetAllocationStack(GlobalObject&, Promise& aPromise,
+ JS::MutableHandle<JSObject*> aStack);
+ static void GetRejectionStack(GlobalObject&, Promise& aPromise,
+ JS::MutableHandle<JSObject*> aStack);
+ static void GetFullfillmentStack(GlobalObject&, Promise& aPromise,
+ JS::MutableHandle<JSObject*> aStack);
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_PromiseDebugging_h
--- a/dom/webidl/PromiseDebugging.webidl
+++ b/dom/webidl/PromiseDebugging.webidl
@@ -12,9 +12,29 @@ dictionary PromiseDebuggingStateHolder {
any value;
any reason;
};
enum PromiseDebuggingState { "pending", "fulfilled", "rejected" };
[ChromeOnly, Exposed=(Window,System)]
interface PromiseDebugging {
static PromiseDebuggingStateHolder getState(Promise<any> p);
+
+ /**
+ * Return the stack to the promise's allocation point. This can
+ * return null if the promise was not created from script.
+ */
+ static object? getAllocationStack(Promise<any> p);
+
+ /**
+ * Return the stack to the promise's rejection point, if the
+ * rejection happened from script. This can return null if the
+ * promise has not been rejected or was not rejected from script.
+ */
+ static object? getRejectionStack(Promise<any> p);
+
+ /**
+ * Return the stack to the promise's fulfillment point, if the
+ * fulfillment happened from script. This can return null if the
+ * promise has not been fulfilled or was not fulfilled from script.
+ */
+ static object? getFullfillmentStack(Promise<any> p);
};