1
0
Fork 0
firefox/testing/web-platform/tests/fenced-frame/resources/history-length-test-helper.js
Daniel Baumann 5e9a113729
Adding upstream version 140.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
2025-06-25 09:37:52 +02:00

23 lines
906 B
JavaScript

// Perform real navigations as well as history.pushState navigations to the
// loaded page until we reach the specified navigation limit. This will be the
// first function that runs in the test, and will result in the test
// reloading/restarting until we reach the desired history length.
function maybeNavigateForHistory() {
const kNavigationLimit = 5
const url = new URL(location.href);
// First, perform some real navigations as well as history.pushState to this
// same page. Normally this would increase `history.length`.
if (url.searchParams.get("navigationCount") == null)
url.searchParams.append("navigationCount", 1);
let navigationCount = parseInt(url.searchParams.get("navigationCount"));
if (navigationCount <= kNavigationLimit) {
url.searchParams.set('navigationCount', ++navigationCount);
location.href = url;
history.pushState({} , "");
return;
}
}