Skip to content

Commit

Permalink
Assert relative changes in history.length in same-url.html
Browse files Browse the repository at this point in the history
All browsers except Firefox spuriously fail the precondition in
`onload` [0] because their history includes `about:blank` (initially
loaded by WebDriver [1, 2]), followed by `same-url.html`. Avoid encoding
this implementation detail in the test.

Also, add the current state to each assertion to make failure more
informative.

[0]: https://wpt.fyi/results/html/browsers/browsing-the-web/history-traversal/same-url.html?run_id=5145442707046400&run_id=5078811356168192&run_id=5154571592925184&run_id=6326848455966720
[1]: https://www.w3.org/TR/webdriver/#new-window
[2]: https://github.com/web-platform-tests/wpt/blob/3939cbfd/tools/wptrunner/wptrunner/executors/executorwebdriver.py#L811-L818
  • Loading branch information
jonathan-j-lee authored and domenic committed Sep 20, 2024
1 parent 4877111 commit 707a73f
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions html/browsers/browsing-the-web/history-traversal/same-url.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,31 @@
<script>
async_test((t) => {
let state = "begin"
let initialLength = history.length

self[0].frameElement.onload = t.step_func(() => {
if(state === "b first") {
assert_equals(history.length, 2)
assert_equals(history.length, initialLength + 1, state)

state = "c first"
navigateFrameAfterDelay(t, "resources/c.html")
} else if (state === "c first") {
assert_equals(history.length, 3)
assert_equals(history.length, initialLength + 2, state)

state = "a second"
history.back(2)
} else if (state === "a second") {
assert_equals(history.length, 3)
assert_equals(history.length, initialLength + 2, state)

state = "a third"
navigateFrameAfterDelay(t, "resources/a.html")
} else if (state === "a third") {
assert_equals(history.length, 3)
assert_equals(history.length, initialLength + 2, state)
t.done()
}
})
onload = t.step_func(() => {
assert_equals(state, "begin")
assert_equals(history.length, 1)

state = "b first"

Expand Down

0 comments on commit 707a73f

Please sign in to comment.