Skip to content

Commit

Permalink
Fix header-origin-same-origin.html test names as beacon without body …
Browse files Browse the repository at this point in the history
…still use POST (web-platform-tests#44827)
  • Loading branch information
youennf authored Feb 28, 2024
1 parent 5bb0001 commit cc8c736
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions beacon/headers/header-origin-same-origin.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
<script src="header-referrer.js"></script>
<script>
var testBase = RESOURCES_DIR;
const usePOST = true;
const addBody = true;
testOriginHeader(testBase, window.location.origin);
testOriginHeader(testBase, window.location.origin, usePOST);
testOriginHeader(testBase, window.location.origin, addBody);

testBase = get_host_info().HTTP_REMOTE_ORIGIN + RESOURCES_DIR;
testOriginHeader(testBase, "null");
testOriginHeader(testBase, "null", usePOST);
testOriginHeader(testBase, "null", addBody);
</script>
</body>
</html>
6 changes: 3 additions & 3 deletions beacon/headers/header-referrer.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ function testReferrerHeader(testBase, expectedReferrer, mayBeBlockedAsMixedConte
}, "Test referer header " + testBase);
}

function testOriginHeader(testBase, expectedOrigin, usePOST) {
function testOriginHeader(testBase, expectedOrigin, addBody) {
var id = self.token();
var testUrl = testBase + "inspect-header.py?header=origin&cmd=put&id=" + id;

promise_test(function(test) {
const sentBeacon = navigator.sendBeacon(testUrl, usePOST ? "data" : undefined);
const sentBeacon = navigator.sendBeacon(testUrl, addBody ? "data" : undefined);
assert_true(sentBeacon, "SendBeacon Succeeded");
return pollResult(expectedOrigin, id, "origin") .then(result => {
assert_equals(result, expectedOrigin, "Correct origin header result");
});
}, "Test origin header " + testBase + (usePOST ? " - POST" : " - GET"));
}, "Test origin header " + testBase + (addBody ? " - with body" : " - without body"));
}

// SendBeacon is an asynchronous and non-blocking request to a web server.
Expand Down

0 comments on commit cc8c736

Please sign in to comment.