Skip to content

Commit

Permalink
feat(JobQueue): implement the new JobQueue::getHostDefinedData meth…
Browse files Browse the repository at this point in the history
…od on `JobQueue` for the new SpiderMonkey version
  • Loading branch information
Xmader committed Dec 3, 2024
1 parent a3c3494 commit b832fa8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
17 changes: 17 additions & 0 deletions include/JobQueue.hh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,23 @@ explicit JobQueue(JSContext *cx);
*/
bool init(JSContext *cx);

/**
* @brief Ask the embedding for the host defined data.
*
* SpiderMonkey doesn't itself have a notion of host defined data as defined
* by the HTML spec, so we need the embedding to provide this. See
* dom/script/ScriptSettings.h for details.
*
* If the embedding has the host defined data, this method should return the
* host defined data via the `data` out parameter and return `true`.
* The object in the `data` out parameter can belong to any compartment.
* If the embedding doesn't need the host defined data, this method should
* set the `data` out parameter to `nullptr` and return `true`.
* If any error happens while generating the host defined data, this method
* should set a pending exception to `cx` and return `false`.
*/
bool getHostDefinedData(JSContext *cx, JS::MutableHandle<JSObject *> data) const override;

/**
* @brief Enqueue a reaction job `job` for `promise`, which was allocated at
* `allocationSite`. Provide `incumbentGlobal` as the incumbent global for
Expand Down
5 changes: 5 additions & 0 deletions src/JobQueue.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ JobQueue::JobQueue(JSContext *cx) {
finalizationRegistryCallbacks = new JS::PersistentRooted<FunctionVector>(cx); // Leaks but it's OK since freed at process exit
}

bool JobQueue::getHostDefinedData(JSContext *cx, JS::MutableHandle<JSObject *> data) const {
data.set(nullptr); // We don't need the host defined data
return true; // `true` indicates no error
}

bool JobQueue::enqueuePromiseJob(JSContext *cx,
[[maybe_unused]] JS::HandleObject promise,
JS::HandleObject job,
Expand Down

0 comments on commit b832fa8

Please sign in to comment.