commit f3a8cf96dc999748798ae544a9b5c8a68f4be918
parent bc0c631e2e027444a8c154eec417ce8eaf7a9ac5
Author: Tommy Sandanasamy <rosan@ualberta.ca>
Date: Tue, 18 Nov 2025 02:56:07 +0000
Bug 1960753 Removed JS::EnqueueJob method and updated tests. r=arai
Differential Revision: https://phabricator.services.mozilla.com/D272816
Diffstat:
5 files changed, 14 insertions(+), 41 deletions(-)
diff --git a/js/src/jit-test/tests/debug/save-queue-resets-draining.js b/js/src/jit-test/tests/debug/save-queue-resets-draining.js
@@ -8,11 +8,11 @@ let gw = dbg.addDebuggee(g);
dbg.onDebuggerStatement = frame => {
// Enqueue a new job from within the debugger while executing another job
// from outside of the debugger.
- enqueueJob(function() {});
+ Promise.resolve()
+ .then(function() {});
};
g.eval(`
- enqueueJob(function() {
- debugger;
- });
+ Promise.resolve()
+ .then(function() {debugger});
`);
diff --git a/js/src/jit-test/tests/saved-stacks/async-implicit.js b/js/src/jit-test/tests/saved-stacks/async-implicit.js
@@ -44,9 +44,13 @@ caller(bindAndExpect({ stack: fakeStack, cause: 'ano', explicit: false },
caller(bindAndExpect({ stack: fakeStack, cause: 'hi', explicit: true },
"bindee, hi*fake2, fake1, (top level)"));
-enqueueJob(bindAndExpect({ stack: fakeStack, cause: 'mita', explicit: false },
- "bindee, mita*fake2, fake1, (top level)"));
-
-enqueueJob(bindAndExpect({ stack: fakeStack, cause: 'hana', explicit: true },
- "bindee, hana*fake2, fake1, (top level)"));
-
+Promise.resolve()
+ .then(function () {
+ bindAndExpect({ stack: fakeStack, cause: 'hana', explicit: true },
+ "bindee, hana*fake2, fake1, (top level)");
+ });
+Promise.resolve()
+ .then(function () {
+ bindAndExpect({ stack: fakeStack, cause: 'hana', explicit: true },
+ "bindee, hana*fake2, fake1, (top level)");
+ });
diff --git a/js/src/jsfriendapi.h b/js/src/jsfriendapi.h
@@ -211,14 +211,6 @@ extern JS_PUBLIC_API JSObject* GetJobsInInternalJobQueue(JSContext* cx);
#endif
/**
- * Enqueue |job| on the internal job queue.
- *
- * This is useful in tests for creating situations where a call occurs with no
- * other JavaScript on the stack.
- */
-extern JS_PUBLIC_API bool EnqueueJob(JSContext* cx, JS::HandleObject job);
-
-/**
* Instruct the runtime to stop draining the internal job queue.
*
* Useful if the embedding is in the process of quitting in reaction to a
diff --git a/js/src/shell/js.cpp b/js/src/shell/js.cpp
@@ -1418,20 +1418,6 @@ static bool MaybeRunShellTasks(JSContext* cx) {
return ranTasks;
}
-static bool EnqueueJob(JSContext* cx, unsigned argc, Value* vp) {
- CallArgs args = CallArgsFromVp(argc, vp);
-
- if (!IsFunctionObject(args.get(0))) {
- JS_ReportErrorASCII(cx, "EnqueueJob's first argument must be a function");
- return false;
- }
-
- args.rval().setUndefined();
-
- RootedObject job(cx, &args[0].toObject());
- return js::EnqueueJob(cx, job);
-}
-
static void RunShellJobs(JSContext* cx) {
ShellContext* sc = GetShellContext(cx);
if (sc->quitting) {
@@ -10529,10 +10515,6 @@ JS_FN_HELP("createUserArrayBuffer", CreateUserArrayBuffer, 1, 0,
" Return an int32 value which corresponds to the offset of the latest stack\n"
" pointer, such that one can take the differences of 2 to estimate a frame-size."),
- JS_FN_HELP("enqueueJob", EnqueueJob, 1, 0,
-"enqueueJob(fn)",
-" Enqueue 'fn' on the shell's job queue."),
-
JS_FN_HELP("globalOfFirstJobInQueue", GlobalOfFirstJobInQueue, 0, 0,
"globalOfFirstJobInQueue()",
" Returns the global of the first item in the job queue. Throws an exception\n"
diff --git a/js/src/vm/JSContext.cpp b/js/src/vm/JSContext.cpp
@@ -837,11 +837,6 @@ JS_PUBLIC_API JSObject* js::GetJobsInInternalJobQueue(JSContext* cx) {
}
#endif
-JS_PUBLIC_API bool js::EnqueueJob(JSContext* cx, JS::HandleObject job) {
- MOZ_ASSERT(cx->jobQueue);
- return cx->jobQueue->enqueuePromiseJob(cx, nullptr, job, nullptr, nullptr);
-}
-
JS_PUBLIC_API void js::StopDrainingJobQueue(JSContext* cx) {
MOZ_ASSERT(cx->internalJobQueue.ref());
cx->internalJobQueue->interrupt();