forked from web-platform-tests/wpt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests to verify origin headers sent by ping (web-platform-tests#2…
- Loading branch information
Showing
10 changed files
with
219 additions
and
0 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
html/semantics/links/downloading-resources/header-origin-no-referrer-when-downgrade.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Ping attribute Origin Header No Referrer When Downgrade Policy</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<meta name='referrer' content='no-referrer-when-downgrade'> | ||
</head> | ||
<body> | ||
<a id="a" href="#"> | ||
<script src="/common/utils.js"></script> | ||
<script src="/common/get-host-info.sub.js"></script> | ||
<script src="/resources/chromium/enable-hyperlink-auditing.js"></script> | ||
<script src="header-origin.js"></script> | ||
<script> | ||
testOriginHeader(self.location.origin); | ||
</script> | ||
</body> | ||
</html> |
20 changes: 20 additions & 0 deletions
20
html/semantics/links/downloading-resources/header-origin-no-referrer.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Ping attribute Origin Header No Referrer Policy</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<meta name='referrer' content='no-referrer'> | ||
</head> | ||
<body> | ||
<a id="a" href="#"> | ||
<script src="/common/utils.js"></script> | ||
<script src="/common/get-host-info.sub.js"></script> | ||
<script src="/resources/chromium/enable-hyperlink-auditing.js"></script> | ||
<script src="header-origin.js"></script> | ||
<script> | ||
testOriginHeader("null"); | ||
</script> | ||
</body> | ||
</html> |
20 changes: 20 additions & 0 deletions
20
html/semantics/links/downloading-resources/header-origin-origin-when-cross-origin.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Ping attribute Origin Header Origin When Cross Origin Policy</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<meta name='referrer' content='origin-when-cross-origin'> | ||
</head> | ||
<body> | ||
<a id="a" href="#"> | ||
<script src="/common/utils.js"></script> | ||
<script src="/common/get-host-info.sub.js"></script> | ||
<script src="/resources/chromium/enable-hyperlink-auditing.js"></script> | ||
<script src="header-origin.js"></script> | ||
<script> | ||
testOriginHeader(self.location.origin); | ||
</script> | ||
</body> | ||
</html> |
20 changes: 20 additions & 0 deletions
20
html/semantics/links/downloading-resources/header-origin-origin.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Ping attribute Origin Header Origin Policy</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<meta name='referrer' content='origin'> | ||
</head> | ||
<body> | ||
<a id="a" href="#"> | ||
<script src="/common/utils.js"></script> | ||
<script src="/common/get-host-info.sub.js"></script> | ||
<script src="/resources/chromium/enable-hyperlink-auditing.js"></script> | ||
<script src="header-origin.js"></script> | ||
<script> | ||
testOriginHeader(self.location.origin); | ||
</script> | ||
</body> | ||
</html> |
20 changes: 20 additions & 0 deletions
20
html/semantics/links/downloading-resources/header-origin-same-origin.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Ping attribute Origin Header Same Origin Policy</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<meta name='referrer' content='same-origin'> | ||
</head> | ||
<body> | ||
<a id="a" href="#"> | ||
<script src="/common/utils.js"></script> | ||
<script src="/common/get-host-info.sub.js"></script> | ||
<script src="/resources/chromium/enable-hyperlink-auditing.js"></script> | ||
<script src="header-origin.js"></script> | ||
<script> | ||
testOriginHeader(self.location.origin); | ||
</script> | ||
</body> | ||
</html> |
20 changes: 20 additions & 0 deletions
20
.../semantics/links/downloading-resources/header-origin-strict-origin-when-cross-origin.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Ping attribute Origin Header Strict Origin When Cross Origin Policy</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<meta name='referrer' content='strict-origin-when-cross-origin'> | ||
</head> | ||
<body> | ||
<a id="a" href="#"> | ||
<script src="/common/utils.js"></script> | ||
<script src="/common/get-host-info.sub.js"></script> | ||
<script src="/resources/chromium/enable-hyperlink-auditing.js"></script> | ||
<script src="header-origin.js"></script> | ||
<script> | ||
testOriginHeader(self.location.origin); | ||
</script> | ||
</body> | ||
</html> |
20 changes: 20 additions & 0 deletions
20
html/semantics/links/downloading-resources/header-origin-strict-origin.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Ping attribute Origin Header Strict Origin Policy</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<meta name='referrer' content='strict-origin'> | ||
</head> | ||
<body> | ||
<a id="a" href="#"> | ||
<script src="/common/utils.js"></script> | ||
<script src="/common/get-host-info.sub.js"></script> | ||
<script src="/resources/chromium/enable-hyperlink-auditing.js"></script> | ||
<script src="header-origin.js"></script> | ||
<script> | ||
testOriginHeader(self.location.origin); | ||
</script> | ||
</body> | ||
</html> |
20 changes: 20 additions & 0 deletions
20
html/semantics/links/downloading-resources/header-origin-unsafe-url.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Ping attribute Origin Header Unsafe Url Policy</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<meta name='referrer' content='unsafe-url'> | ||
</head> | ||
<body> | ||
<a id="a" href="#"> | ||
<script src="/common/utils.js"></script> | ||
<script src="/common/get-host-info.sub.js"></script> | ||
<script src="/resources/chromium/enable-hyperlink-auditing.js"></script> | ||
<script src="header-origin.js"></script> | ||
<script> | ||
testOriginHeader(self.location.origin); | ||
</script> | ||
</body> | ||
</html> |
19 changes: 19 additions & 0 deletions
19
html/semantics/links/downloading-resources/header-origin.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Ping attribute Origin no Referrer Policy</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
</head> | ||
<body> | ||
<a id="a" href="#"> | ||
<script src="/common/utils.js"></script> | ||
<script src="/common/get-host-info.sub.js"></script> | ||
<script src="/resources/chromium/enable-hyperlink-auditing.js"></script> | ||
<script src="header-origin.js"></script> | ||
<script> | ||
testOriginHeader(self.location.origin); | ||
</script> | ||
</body> | ||
</html> |
40 changes: 40 additions & 0 deletions
40
html/semantics/links/downloading-resources/header-origin.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
const RESOURCES_DIR = "/html/semantics/links/downloading-resources/resources/"; | ||
|
||
function testOriginHeader(expectedOrigin) { | ||
var id = self.token(); | ||
let testUrl = RESOURCES_DIR + "inspect-header.py?header=origin&cmd=put&id=" + id; | ||
|
||
promise_test(function(test) { | ||
const anchor = document.getElementById("a"); | ||
anchor.setAttribute("ping", testUrl); | ||
anchor.click(); | ||
return pollResult(id) .then(result => { | ||
assert_equals(result, expectedOrigin, "Correct origin header result"); | ||
}); | ||
}, "Test origin header " + RESOURCES_DIR); | ||
} | ||
|
||
// Sending a ping is an asynchronous and non-blocking request to a web server. | ||
// We may have to create a poll loop to get result from server | ||
function pollResult(id) { | ||
let checkUrl = RESOURCES_DIR + "inspect-header.py?header=origin&cmd=get&id=" + id; | ||
|
||
return new Promise(resolve => { | ||
function checkResult() { | ||
fetch(checkUrl).then( | ||
function(response) { | ||
assert_equals(response.status, 200, "Inspect header response's status is 200"); | ||
let result = response.headers.get("x-request-origin"); | ||
|
||
if (result != undefined) { | ||
resolve(result); | ||
} else { | ||
step_timeout(checkResult.bind(this), 100); | ||
} | ||
}); | ||
} | ||
|
||
checkResult(); | ||
}); | ||
|
||
} |