diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /dom/tests/mochitest/beacon/test_beaconCookies.html | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-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_beaconCookies.html')
-rw-r--r-- | dom/tests/mochitest/beacon/test_beaconCookies.html | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/dom/tests/mochitest/beacon/test_beaconCookies.html b/dom/tests/mochitest/beacon/test_beaconCookies.html new file mode 100644 index 000000000..e2c4f3b7d --- /dev/null +++ b/dom/tests/mochitest/beacon/test_beaconCookies.html @@ -0,0 +1,89 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=936340 +--> +<head> + <title>Test whether sendBeacon sets cookies</title> + <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" /> +</head> +<body> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=936340">Mozilla Bug 936340</a> +<p id="display"></p> +<div id="content" style="display: none"> + +</div> +<pre id="test"> +<script class="testbody" type="text/javascript"> + +// not enabled by default yet. +SimpleTest.waitForExplicitFinish(); +SpecialPowers.pushPrefEnv({'set': [["beacon.enabled", true]]}, beginTest); + +var Ci = Components.interfaces; +var Cu = Components.utils; +Cu.import("resource://gre/modules/Services.jsm"); + +var baseURL = "http://mochi.test:8888/chrome/dom/tests/mochitest/beacon/"; + +function whenDelayedStartupFinished(aWindow, aCallback) { + Services.obs.addObserver(function observer(aSubject, aTopic) { + if (aWindow == aSubject) { + Services.obs.removeObserver(observer, aTopic); + setTimeout(aCallback, 0); + } + }, "browser-delayed-startup-finished", false); +} + +function testOnWindow(options, callback) { + var mainWindow = window.QueryInterface(Ci.nsIInterfaceRequestor) + .getInterface(Ci.nsIWebNavigation) + .QueryInterface(Ci.nsIDocShellTreeItem) + .rootTreeItem + .QueryInterface(Ci.nsIInterfaceRequestor) + .getInterface(Ci.nsIDOMWindow); + + var win = mainWindow.OpenBrowserWindow(options); + windowsToClose.push(win); + whenDelayedStartupFinished(win, function() { + callback(win); + }); +}; + +var windowsToClose = []; +var next; + +function beginTest() { + testOnWindow({}, function(aNormalWindow) { + Services.obs.addObserver(function waitCookie() { + Services.obs.removeObserver(waitCookie, "cookie-changed"); + ok(true, "cookie set by beacon request in normal window"); + testOnPrivateWindow(); + }, "cookie-changed", false); + aNormalWindow.gBrowser.selectedBrowser.loadURI(baseURL + "file_beaconCookies.html"); + }); +} + +function testOnPrivateWindow() { + testOnWindow({private: true}, function(aPrivateWindow) { + Services.obs.addObserver(function waitCookie() { + Services.obs.removeObserver(waitCookie, "private-cookie-changed"); + ok(true, "private cookie set by beacon request in private window"); + cleanup(); + }, "private-cookie-changed", false); + aPrivateWindow.gBrowser.selectedBrowser.loadURI(baseURL + "file_beaconCookies.html"); + }); +} + +function cleanup() { + for (var i = 0; i < windowsToClose.length; ++i) { + windowsToClose[i].close(); + } + SimpleTest.finish(); +} + +</script> +</pre> +</body> +</html> |