From deb08b788004805f40374480e5f452f372171732 Mon Sep 17 00:00:00 2001 From: Karl Seguin Date: Tue, 17 Mar 2026 08:15:49 +0800 Subject: [PATCH] Try to improve stability of history test Tests cannot navigate away from the page page. If they do, the testRunner will crash, as it tries to access `assertOk` on a page that no longer exists. This commit hacks the history test, using an iframe, to try to test the history API without navigating off the main page. --- src/browser/tests/history.html | 42 +++++++------------------- src/browser/tests/support/history.html | 33 ++++++++++++++++++++ src/browser/tests/testing.js | 5 ++- 3 files changed, 46 insertions(+), 34 deletions(-) create mode 100644 src/browser/tests/support/history.html diff --git a/src/browser/tests/history.html b/src/browser/tests/history.html index 1508e232..e2aa0d35 100644 --- a/src/browser/tests/history.html +++ b/src/browser/tests/history.html @@ -2,37 +2,17 @@ + diff --git a/src/browser/tests/support/history.html b/src/browser/tests/support/history.html new file mode 100644 index 00000000..d3356de3 --- /dev/null +++ b/src/browser/tests/support/history.html @@ -0,0 +1,33 @@ + + + + diff --git a/src/browser/tests/testing.js b/src/browser/tests/testing.js index 01bb19db..2e33c1d3 100644 --- a/src/browser/tests/testing.js +++ b/src/browser/tests/testing.js @@ -99,8 +99,7 @@ } } - // our test runner sets this to true - const IS_TEST_RUNNER = window._lightpanda_skip_auto_assert === true; + const IS_TEST_RUNNER = window.navigator.userAgent.startsWith("Lightpanda/"); window.testing = { fail: fail, @@ -118,7 +117,7 @@ BASE_URL: 'http://127.0.0.1:9582/src/browser/tests/', }; - if (window.navigator.userAgent.startsWith("Lightpanda/") == false) { + if (IS_TEST_RUNNER === false) { // The page is running in a different browser. Probably a developer making sure // a test is correct. There are a few tweaks we need to do to make this a // seemless, namely around adapting paths/urls.