From 70737aa4fed8900c1d5bcc287f4c3ca86e52c36c Mon Sep 17 00:00:00 2001 From: zcorpan Date: Mon, 4 Sep 2023 10:18:39 +0200 Subject: [PATCH] HTML: pushState() url resolves against relevant settings object See https://github.com/web-platform-tests/wpt/issues/4934#issuecomment-1703898962 --- .../query-encoding/resources/resolve-url.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/html/infrastructure/urls/resolving-urls/query-encoding/resources/resolve-url.js b/html/infrastructure/urls/resolving-urls/query-encoding/resources/resolve-url.js index cda98fb021319f..30ffaf9716a731 100644 --- a/html/infrastructure/urls/resolving-urls/query-encoding/resources/resolve-url.js +++ b/html/infrastructure/urls/resolving-urls/query-encoding/resources/resolve-url.js @@ -405,6 +405,7 @@ onload = function() { // history.replaceState function test_history(prop) { subsetTestByKey('history', async_test, function() { + var url = input_url_html.replace('resources/', ''); var iframe = document.createElement('iframe'); iframe.src = blank; document.body.appendChild(iframe); @@ -412,10 +413,13 @@ onload = function() { document.body.removeChild(iframe); }); iframe.onload = this.step_func_done(function() { - iframe.contentWindow.history[prop](null, null, input_url_html); // this should resolve against the test's URL, not the iframe's URL + // this should resolve against the iframe's URL + // "Parse url, relative to the relevant settings object of history." + // https://html.spec.whatwg.org/multipage/nav-history-apis.html#shared-history-push%2Freplace-state-steps + iframe.contentWindow.history[prop](null, null, url); var got = iframe.contentWindow.location.href; assert_true(got.indexOf(expected_current) > -1, msg(expected_current, got)); - assert_equals(got.indexOf('/resources/resources/'), -1, 'url was resolved against the iframe\'s URL instead of the settings object\'s API base URL'); + assert_not_equals(got.indexOf('/resources/'), -1, 'url was resolved against the test\'s URL'); }); }, 'history.'+prop); }