You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This commit was created on GitHub.com and signed with GitHub’s verified signature.
Added
RailsJsdom.page_setup names a module of the app that Node calls for every page, before the page's scripts, as pageSetup(window, { track, session }). It gives pages an object that only Node can make, such as a class Node has and jsdom lacks. track(promise) makes actions wait for the promise, session is a Map that lasts for the pages of one session in one test, and a function the module returns runs when the page closes.
Pages get structuredClone and crypto.subtle from Node, as they get Headers, Request and Response. Actions wait for crypto.subtle calls, and their results use the page's own ArrayBuffer.
The README describes how an app adds a browser API that jsdom lacks. A fake in plain JavaScript, such as fake-indexeddb, goes into the page through inject in esbuild_config. rails-jsdom installs no fakes.
Changed
A page that posts messages to itself without end fails the action with RailsJsdom: the page did not settle. Before, the action returned and the page kept looping behind later commands.
Fixed
Actions wait for the tasks jsdom queues for a page: window.postMessage, FileReader reads, and storage, hashchange, popstate and selectionchange events. jsdom runs them on a Node timer outside the page's clock, so an action could return before a chain of them finished.
An Atomics.waitAsync timeout runs on the virtual clock, so a timed wait no longer takes real time. A notify still wakes the wait, a notify from the page does not count waits that have timed out, and a wait that is woken cancels its timeout.