import changes from `dev' branch of rmottola/Arctic-Fox:

- Bug 1132213 - Remove newChannel2 and asyncFetch2 calls in the "jsdownloads" folder. r=paolo (15afbc22f6)
- Bug 1223437 - Use channel.asyncOpen2 in toolkit/components/jsdownloads/test/unit (r=sicking) (62de0552b6)
- Bug 1225641 - Change default security flags within NetUtil.newChannel (r=sicking) (f04a8d6a1d)
- Bug 1224467 - Add a preference for controlling whether oneCRL blocklists are updated via AMO. Also add a test. r=keeler,mossop (06c4ce13f9)
- Bug 1170760 part 1. Introduce a PromiseCapability struct. r=baku,efaust (068615a4cd)
- Bug 1170760 part 2. Pass in the 'this' value to Promise static methods. r=peterv (170fd5de55)
- Bug 1170760 part 3. Add an @@species getter on Promise. r=peterv (182a90f4ee)
- Bug 1170760 part 4. Change Promise::Constructor to run in the Xray compartment when new Promise happens over Xrays. r=peterv (ac9bf8968b)
- Bug 1170760 part 5. Implement NewPromiseCapability which can either return a PromiseCapability as in the spec, or one that has a native promise and maybe resolve/reject functions if the consumer asked for them. r=baku,efaust (6c74f4ebdf)
- Bug 1170760 part 6. Fix GetDependentPromise to deal with a situation when someone called then() and passed it the resolve/reject functions that come from a promise's constructor. r=baku (fa6504ca29)
- Bug 1170760 part 7. Add subclassing support to Promise::Race. r=baku,efaust (d43c0782d6)
- Bug 1170760 part 8. Add subclassing support to Promise::All. r=baku,efaust (37d8577256)
- Bug 1170760 part 9. Stop using Promise::Resolve in the bindings for PromiseDebugging. r=baku (3c3073d0fa)
- Bug 1170760 part 10. Add subclassing support to Promise::Resolve. r=baku,efaust (22a5f2b385)
- Bug 1170760 part 11. Add subclassing support to Promise::Reject. r=baku,efaust (c696a0a9fe)
- Bug 1170760 part 12. Rip out the promise-resolved-with-promise fast path. r=baku (a1815842e2)
- Bug 1170760 part 13. Add subclassing support to Promise::Then/Catch. r=baku,efaust (3fd8f2502d)
This commit is contained in:
2023-03-30 10:36:09 +08:00
parent d64e96b4a0
commit 09c7525bc8
48 changed files with 2634 additions and 468 deletions
+10 -4
View File
@@ -13,6 +13,7 @@
#include "mozilla/dom/Event.h"
#include "mozilla/dom/Promise.h"
#include "mozilla/dom/ScriptSettings.h"
#include "jsfriendapi.h"
using mozilla::dom::AnyCallback;
using mozilla::dom::DOMError;
@@ -206,14 +207,16 @@ DOMRequest::RootResultVal()
mozilla::HoldJSObjects(this);
}
already_AddRefed<Promise>
void
DOMRequest::Then(JSContext* aCx, AnyCallback* aResolveCallback,
AnyCallback* aRejectCallback, mozilla::ErrorResult& aRv)
AnyCallback* aRejectCallback,
JS::MutableHandle<JS::Value> aRetval,
mozilla::ErrorResult& aRv)
{
if (!mPromise) {
mPromise = Promise::Create(DOMEventTargetHelper::GetParentObject(), aRv);
if (aRv.Failed()) {
return nullptr;
return;
}
if (mDone) {
// Since we create mPromise lazily, it's possible that the DOMRequest object
@@ -228,7 +231,10 @@ DOMRequest::Then(JSContext* aCx, AnyCallback* aResolveCallback,
}
}
return mPromise->Then(aCx, aResolveCallback, aRejectCallback, aRv);
// Just use the global of the Promise itself as the callee global.
JS::Rooted<JSObject*> global(aCx, mPromise->GetWrapper());
global = js::GetGlobalForObjectCrossCompartment(global);
mPromise->Then(aCx, global, aResolveCallback, aRejectCallback, aRetval, aRv);
}
NS_IMPL_ISUPPORTS(DOMRequestService, nsIDOMRequestService)