Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion runtimes/jsc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@ const jsc = globalThis["\x24"];
const DollarCreateRealm = jsc.createRealm;
const DollarEvalScript = jsc.evalScript.bind(jsc);

var $262 = Object.assign({}, jsc);
var $262 = {};
// Copy "own" properties from the JSC-defined object to the normalized `$262`
// object. Neither `Object.assign` nor the object "spread" syntax can be used
// for this task because not all properties on the source object are
// enumerable.
Object.getOwnPropertyNames(jsc).forEach(function(name) {
$262[name] = jsc[name];
});
$262.global = globalThis;
$262.source = $SOURCE;
$262.destroy = function() {};
Expand Down
21 changes: 21 additions & 0 deletions test/runify.js
Original file line number Diff line number Diff line change
Expand Up @@ -958,5 +958,26 @@ hosts.forEach(function (record) {
await agent.destroy();
});
});

describe("agent", () => {
if (!["jsc", "jsshell", "d8"].includes(type)) {
return;
}

const read = async (expression) => {
const result = await agent.evalScript(`print(${expression});`);
expect(result.error).toBe(null);
return result.stdout;
};

it("exposes the complete Test262-defined API", async () => {
expect(await read("typeof $262.agent")).toMatch(/^object/);
expect(await read("typeof $262.agent.start")).toMatch(/^function/);
expect(await read("typeof $262.agent.broadcast")).toMatch(/^function/);
expect(await read("typeof $262.agent.getReport")).toMatch(/^function/);
expect(await read("typeof $262.agent.sleep")).toMatch(/^function/);
expect(await read("typeof $262.agent.monotonicNow")).toMatch(/^function/);
});
});
});
});