Revert to using window.onload

To support top level await, jasmine-browser-runner needs to be able
to delay env execution until after spec files have initialized. The
old-fashioned event listener style makes that straightforward.
This commit is contained in:
Steve Gravrock
2025-12-01 18:33:08 -08:00
parent c999ce0787
commit f3dba82b04
2 changed files with 14 additions and 4 deletions

View File

@@ -49,11 +49,16 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
env.configure(urls.configFromCurrentUrl());
window.addEventListener('load', function() {
const currentWindowOnload = window.onload;
window.onload = function() {
if (currentWindowOnload) {
currentWindowOnload();
}
// The HTML reporter needs to be set up here so it can access the DOM. Other
// reporters can be added at any time before env.execute() is called.
const htmlReporter = new jasmine.HtmlReporterV2({ env, urls });
env.addReporter(htmlReporter);
env.execute();
});
};
})();

View File

@@ -25,11 +25,16 @@
*/
env.configure(urls.configFromCurrentUrl());
window.addEventListener('load', function() {
const currentWindowOnload = window.onload;
window.onload = function() {
if (currentWindowOnload) {
currentWindowOnload();
}
// The HTML reporter needs to be set up here so it can access the DOM. Other
// reporters can be added at any time before env.execute() is called.
const htmlReporter = new jasmine.HtmlReporterV2({ env, urls });
env.addReporter(htmlReporter);
env.execute();
});
};
})();