From e954d2455e14f8f209fcbaca6093f7901170fa5d Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Thu, 29 Sep 2022 20:16:52 +0200 Subject: [PATCH] [xhr] abort --- src/ecmascript/spidermonkey/xhr.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/ecmascript/spidermonkey/xhr.cpp b/src/ecmascript/spidermonkey/xhr.cpp index 1ab342040..1ff9e7732 100644 --- a/src/ecmascript/spidermonkey/xhr.cpp +++ b/src/ecmascript/spidermonkey/xhr.cpp @@ -270,8 +270,22 @@ xhr_abort(JSContext *ctx, unsigned int argc, JS::Value *rval) fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__); #endif JS::CallArgs args = JS::CallArgsFromVp(argc, rval); -// JS::RootedObject hobj(ctx, &args.thisv().toObject()); -/// TODO + JS::RootedObject hobj(ctx, &args.thisv().toObject()); + JS::Realm *comp = js::GetContextRealm(ctx); + + if (!comp) { +#ifdef ECMASCRIPT_DEBUG + fprintf(stderr, "%s:%s %d\n", __FILE__, __FUNCTION__, __LINE__); +#endif + return false; + } + struct ecmascript_interpreter *interpreter = (struct ecmascript_interpreter *)JS::GetRealmPrivate(comp); + struct xhr *xhr = (struct xhr *)(JS::GetPrivate(hobj)); + + if (xhr && xhr->download.conn) { + abort_connection(xhr->download.conn, connection_state(S_INTERRUPTED)); + } + args.rval().setUndefined(); return true; }