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 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/base/test/test_meta_refresh_referrer.html
parentInitial commit. (diff)
downloadfirefox-esr-upstream.tar.xz
firefox-esr-upstream.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
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>