summaryrefslogtreecommitdiffstats
path: root/dom/tests/mochitest/beacon/test_beaconRedirect.html
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /dom/tests/mochitest/beacon/test_beaconRedirect.html
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/tests/mochitest/beacon/test_beaconRedirect.html')
-rw-r--r--dom/tests/mochitest/beacon/test_beaconRedirect.html62
1 files changed, 62 insertions, 0 deletions
diff --git a/dom/tests/mochitest/beacon/test_beaconRedirect.html b/dom/tests/mochitest/beacon/test_beaconRedirect.html
new file mode 100644
index 000000000..614e3b5b3
--- /dev/null
+++ b/dom/tests/mochitest/beacon/test_beaconRedirect.html
@@ -0,0 +1,62 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <title>Bug 1280692 - sendBeacon() should follow 30x redirect</title>
+ <!-- Including SimpleTest.js so we can use waitForExplicitFinish !-->
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+ <p id="display"></p>
+ <div id="content" style="visibility: hidden">
+ <iframe style="width:100%;" id="testframe"></iframe>
+ </div>
+
+<script class="testbody" type="text/javascript">
+
+/* Description of the test:
+ * We do perform a non simple sendBeacon request which should not use CORS and should follow
+ * a 30x cross origin redirect, which is allowed by the spec.
+ */
+
+SimpleTest.waitForExplicitFinish();
+
+const BEACON_URL = "http://example.com/tests/dom/tests/mochitest/beacon/beacon-redirect-handler.sjs?beacon";
+
+SpecialPowers.pushPrefEnv({'set': [["beacon.enabled", true]]}, runTest);
+
+var intervalID = null;
+
+function queryIfRedirectSucceeded() {
+ clearInterval(intervalID);
+ var xhr = new XMLHttpRequest();
+ xhr.open("GET", "beacon-redirect-handler.sjs?verifyRedirectDidSucceed", true);
+ xhr.onload = function() {
+ is(xhr.responseText, "green", "SendBeacon should follow cross origin redirects!");
+ SimpleTest.finish();
+ };
+ xhr.onerror = function() {
+ ok(false, "xhr request returned error");
+ SimpleTest.finish();
+ };
+ xhr.send();
+}
+
+function runTest() {
+ var data = new Uint8Array([0,1,2,3]);
+ navigator.sendBeacon(BEACON_URL, data);
+
+ // we have to make sure the channel did follow the redirect hence
+ // we have to wait for a few seconds before we can query the result.
+ interval = 4000;
+ if (navigator.appVersion.indexOf("Android") >= 0) {
+ // Android Debug on an emulator can be very slow
+ interval = 10000;
+ }
+ intervalID = setInterval(queryIfRedirectSucceeded, interval);
+}
+
+</script>
+</pre>
+</body>
+</html>