From 939af08ee1c2610a9cb7cb1f2f3da5e8539179d3 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Mon, 26 Oct 2020 12:26:37 +0100 Subject: [PATCH] Remove SystemJS usage from the font-tests With these changes, SystemJS is now *only* used to load the worker-file in development mode (pending removal once https://bugzilla.mozilla.org/show_bug.cgi?id=1247687 is fixed). --- test/font/font_test.html | 16 +++++++++++++--- test/font/jasmine-boot.js | 31 ++++++++++++++++--------------- 2 files changed, 29 insertions(+), 18 deletions(-) diff --git a/test/font/font_test.html b/test/font/font_test.html index c2e87bfd4692b..e5bacf0c740e5 100644 --- a/test/font/font_test.html +++ b/test/font/font_test.html @@ -5,12 +5,22 @@ - - - + + + + diff --git a/test/font/jasmine-boot.js b/test/font/jasmine-boot.js index 913d0fe9b0465..460c461f9aa24 100644 --- a/test/font/jasmine-boot.js +++ b/test/font/jasmine-boot.js @@ -48,7 +48,8 @@ async function initializePDFJS(callback) { "pdfjs-test/font/font_post_spec.js", "pdfjs-test/font/font_fpgm_spec.js", ].map(function (moduleName) { - return SystemJS.import(moduleName); + // eslint-disable-next-line no-unsanitized/method + return import(moduleName); }) ); @@ -133,26 +134,26 @@ async function initializePDFJS(callback) { // Sets longer timeout. jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000; - // Replace the browser window's `onload`, ensure it's called, and then run - // all of the loaded specs. This includes initializing the `HtmlReporter` - // instance and then executing the loaded Jasmine environment. - const currentWindowOnload = window.onload; - - window.onload = function () { - if (currentWindowOnload) { - currentWindowOnload(); + function extend(destination, source) { + for (const property in source) { + destination[property] = source[property]; } + return destination; + } + function fontTestInit() { initializePDFJS(function () { htmlReporter.initialize(); env.execute(); }); - }; + } - function extend(destination, source) { - for (const property in source) { - destination[property] = source[property]; - } - return destination; + if ( + document.readyState === "interactive" || + document.readyState === "complete" + ) { + fontTestInit(); + } else { + document.addEventListener("DOMContentLoaded", fontTestInit, true); } })();