summaryrefslogtreecommitdiffstats
path: root/dom/base/test/test_meta_refresh_referrer.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
commit6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /dom/base/test/test_meta_refresh_referrer.html
parentInitial commit. (diff)
downloadthunderbird-upstream.tar.xz
thunderbird-upstream.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/base/test/test_meta_refresh_referrer.html')
-rw-r--r--dom/base/test/test_meta_refresh_referrer.html98
1 files changed, 98 insertions, 0 deletions
diff --git a/dom/base/test/test_meta_refresh_referrer.html b/dom/base/test/test_meta_refresh_referrer.html
new file mode 100644
index 0000000000..2af0a1f1f8
--- /dev/null
+++ b/dom/base/test/test_meta_refresh_referrer.html
@@ -0,0 +1,98 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <meta charset="utf-8">
+ <meta name='referrer' content='origin'>
+ <title>Test for referrer of meta refresh request</title>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+
+<script type="application/javascript">
+
+SimpleTest.waitForExplicitFinish();
+var advance = function() { tests.next(); };
+
+/**
+ * Listen for notifications from the child.
+ */
+window.addEventListener("message", function(event) {
+ if (event.data == "childLoadComplete") {
+ advance();
+ }
+});
+
+var tests = (function*() {
+ var iframe = document.getElementById("testframe");
+
+ // reset counter to make the test pass --repeat test
+ yield reset();
+
+ // load the test frame
+ yield iframe.src =
+ '/tests/dom/base/test/iframe_meta_refresh.sjs?action=test&load=refresh';
+
+ // check the test result
+ yield checkResults(referrerHeaderChecker);
+
+ // complete.
+ SimpleTest.finish();
+})();
+
+function referrerHeaderChecker(results) {
+ var expected = {'count': 2, 'referrers': ['origin', 'none']};
+ is(results.count, expected.count, "Correct number of referrer header");
+ is(results.referrers[0], expected.referrers[0], "Correct load referrer header");
+ is(results.referrers[1], expected.referrers[1], "Correct refresh referrer header");
+
+ advance();
+}
+
+/**
+ * helper to perform an XHR.
+ */
+function doXHR(url, onSuccess, onFail) {
+ var xhr = new XMLHttpRequest();
+ xhr.onload = function () {
+ if (xhr.status == 200) {
+ onSuccess(xhr);
+ } else {
+ onFail(xhr);
+ }
+ };
+ xhr.open('GET', url, true);
+ xhr.send(null);
+}
+
+/**
+ * Grabs the results via XHR and passes to checker.
+ */
+function checkResults(checker) {
+ doXHR('/tests/dom/base/test/iframe_meta_refresh.sjs?action=results',
+ function(xhr) {
+ checker(JSON.parse(xhr.responseText));
+ },
+ function(xhr) {
+ ok(false, "Can't get results from server.");
+ });
+}
+
+/**
+ * Reset the counter.
+ */
+function reset() {
+ doXHR('/tests/dom/base/test/iframe_meta_refresh.sjs?action=reset',
+ advance,
+ function(xhr) {
+ ok(false, "error in reset state");
+ SimpleTest.finish();
+ });
+}
+
+</script>
+</head>
+
+<body onload="tests.next();">
+ <iframe id="testframe"></iframe>
+
+</body>
+</html></html>