Skip to content

Truly independent web browser

Tests/LibWeb: Make Navigation-object-properties.html deterministic

sideshowbarkerc871d1fbdf9d
diff --git a/Tests/LibWeb/TestConfig.ini b/Tests/LibWeb/TestConfig.ini
index 97fcb8a94d0..0b1646bb85e 100644
--- a/Tests/LibWeb/TestConfig.ini
+++ b/Tests/LibWeb/TestConfig.ini
@@ -1442,9 +1442,6 @@ Text/input/wpt-import/html/webappapis/dynamic-markup-insertion/opening-the-input
Text/input/wpt-import/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/016-1.html
Text/input/wpt-import/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/document.open-03-frame.html
-; See: https://github.com/LadybirdBrowser/ladybird/issues/7931
-Text/input/HTML/Navigation-object-properties.html
-
; Timing out Fullscreen tests
Ref/input/wpt-import/fullscreen/rendering/backdrop-iframe.html
Ref/input/wpt-import/fullscreen/rendering/backdrop-inherit.html
diff --git a/Tests/LibWeb/Text/expected/HTML/Navigation-object-properties.txt b/Tests/LibWeb/Text/expected/HTML/Navigation-object-properties.txt
index ca60c46eb2c..7852288cd7f 100644
--- a/Tests/LibWeb/Text/expected/HTML/Navigation-object-properties.txt
+++ b/Tests/LibWeb/Text/expected/HTML/Navigation-object-properties.txt
@@ -1,5 +1,5 @@
entries[length - 1] is current entry: true
currentEntry is a [object NavigationHistoryEntry]
transition is null: true
-canGoBack: true
+canGoBack: false
canGoForward: false
diff --git a/Tests/LibWeb/Text/input/HTML/Navigation-object-properties.html b/Tests/LibWeb/Text/input/HTML/Navigation-object-properties.html
index ded57e1a1d5..387cbdf8f97 100644
--- a/Tests/LibWeb/Text/input/HTML/Navigation-object-properties.html
+++ b/Tests/LibWeb/Text/input/HTML/Navigation-object-properties.html
@@ -1,16 +1,24 @@
<!DOCTYPE html>
<script src="../include.js"></script>
<script>
- test(() => {
- let n = window.navigation;
+ // A fresh iframe has a session history of its own, so what came before this test can't change its results.
+ asyncTest(async done => {
+ const iframe = document.createElement("iframe");
+ iframe.srcdoc = "<!DOCTYPE html>";
+ await new Promise(resolve => {
+ iframe.onload = resolve;
+ document.body.appendChild(iframe);
+ });
- let len = n.entries().length;
+ const n = iframe.contentWindow.navigation;
+ const len = n.entries().length;
println(`entries[length - 1] is current entry: ${n.entries()[len - 1] === n.currentEntry}`);
println(`currentEntry is a ${n.currentEntry}`);
println(`transition is null: ${n.transition == null}`);
println(`canGoBack: ${n.canGoBack}`);
- println(`canGoForward: ${n.canGoForward}`);
+ println(`canGoForward: ${n.canGoForward}`);
+ done();
});
</script>