Skip to content

Commit d830f9d

Browse files
committed
feat(JobQueue): implement the new JobQueue::getHostDefinedData method on JobQueue for the new SpiderMonkey version
1 parent dcfbb34 commit d830f9d

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

include/JobQueue.hh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,23 @@ explicit JobQueue(JSContext *cx);
3434
*/
3535
bool init(JSContext *cx);
3636

37+
/**
38+
* @brief Ask the embedding for the host defined data.
39+
*
40+
* SpiderMonkey doesn't itself have a notion of host defined data as defined
41+
* by the HTML spec, so we need the embedding to provide this. See
42+
* dom/script/ScriptSettings.h for details.
43+
*
44+
* If the embedding has the host defined data, this method should return the
45+
* host defined data via the `data` out parameter and return `true`.
46+
* The object in the `data` out parameter can belong to any compartment.
47+
* If the embedding doesn't need the host defined data, this method should
48+
* set the `data` out parameter to `nullptr` and return `true`.
49+
* If any error happens while generating the host defined data, this method
50+
* should set a pending exception to `cx` and return `false`.
51+
*/
52+
bool getHostDefinedData(JSContext *cx, JS::MutableHandle<JSObject *> data) const override;
53+
3754
/**
3855
* @brief Enqueue a reaction job `job` for `promise`, which was allocated at
3956
* `allocationSite`. Provide `incumbentGlobal` as the incumbent global for

src/JobQueue.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ JobQueue::JobQueue(JSContext *cx) {
2626
finalizationRegistryCallbacks = new JS::PersistentRooted<FunctionVector>(cx); // Leaks but it's OK since freed at process exit
2727
}
2828

29+
bool JobQueue::getHostDefinedData(JSContext *cx, JS::MutableHandle<JSObject *> data) const {
30+
data.set(nullptr); // We don't need the host defined data
31+
return true; // `true` indicates no error
32+
}
33+
2934
bool JobQueue::enqueuePromiseJob(JSContext *cx,
3035
[[maybe_unused]] JS::HandleObject promise,
3136
JS::HandleObject job,

0 commit comments

Comments
 (0)