summaryrefslogtreecommitdiffstats
path: root/dom/media/test/test_referer.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/media/test/test_referer.html
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/media/test/test_referer.html')
-rw-r--r--dom/media/test/test_referer.html88
1 files changed, 88 insertions, 0 deletions
diff --git a/dom/media/test/test_referer.html b/dom/media/test/test_referer.html
new file mode 100644
index 0000000000..4ce78d5fb3
--- /dev/null
+++ b/dom/media/test/test_referer.html
@@ -0,0 +1,88 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=584480
+-->
+<head>
+ <title>Test for Bug 584480</title>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+ <script type="text/javascript" src="manifest.js"></script>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=584480">Mozilla Bug </a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+var media = [];
+
+function checkComplete() {
+ for (var i=0; i<media.length; ++i) {
+ if (!media[i]._complete) {
+ return;
+ }
+ }
+
+ SimpleTest.finish();
+}
+
+function removeNode(v) {
+ v.removeEventListener("error", loadError);
+ v.removeEventListener("loadedmetadata", loadedMetadata);
+ v.remove();
+ v.src = "";
+}
+
+function loadError(evt) {
+ // If no referer is sent then the sjs returns an error
+ ok(false, "check referer is sent with media request");
+ evt.target._complete = true;
+ checkComplete();
+ removeNode(evt.target);
+}
+
+function loadedMetadata(evt) {
+ // If a referer is sent then the sjs returns a valid media
+ ok(true, "check referer is sent with media request");
+ evt.target._complete = true;
+ checkComplete();
+ removeNode(evt.target);
+}
+
+// Create all media objects.
+for (var i=0; i<gSmallTests.length; ++i) {
+ var test = gSmallTests[i];
+ var type;
+ if (/^video/.test(test.type)) {
+ type = "video"
+ } else {
+ type = "audio";
+ }
+ var v = document.createElement(type);
+ if (!v.canPlayType(test.type)) {
+ continue;
+ }
+ // ensure metadata is loaded for default preload is none on b2g
+ v.preload = "metadata";
+ v.autoplay = "true";
+ v._complete = false;
+ v.addEventListener("error", loadError);
+ v.addEventListener("loadedmetadata", loadedMetadata);
+ v.src = 'referer.sjs?name=' + test.name + '&type=' + test.type;
+ document.body.appendChild(v); // Will start load.
+ media.push(v);
+}
+
+if (!media.length) {
+ todo(false, "No types supported");
+} else {
+ SimpleTest.waitForExplicitFinish();
+}
+</script>
+</pre>
+
+</body>
+</html>