зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 352a2109c6e6 (bug 987387) for m-oth orange
This commit is contained in:
Родитель
b6a0a0b48e
Коммит
637942adf8
|
@ -1,6 +0,0 @@
|
|||
[DEFAULT]
|
||||
skip-if = buildapp == 'b2g' || e10s
|
||||
|
||||
[test_beaconCookies.html]
|
||||
support-files = beacon-set-cookie.sjs
|
||||
file_beaconCookies.html
|
|
@ -1,8 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
var beaconUrl = "http://mochi.test:8888/chrome/dom/tests/mochitest/beacon/beacon-set-cookie.sjs";
|
||||
|
||||
navigator.sendBeacon(beaconUrl, "ceci n'est pas une demande");
|
||||
|
||||
</script>
|
|
@ -2,8 +2,10 @@
|
|||
skip-if = buildapp == 'b2g' || e10s
|
||||
support-files = beacon-frame.html
|
||||
beacon-handler.sjs
|
||||
beacon-set-cookie.sjs
|
||||
|
||||
[test_beacon.html]
|
||||
[test_beaconFrame.html]
|
||||
[test_beaconPreflight.html]
|
||||
[test_beaconCookies.html]
|
||||
[test_beaconContentPolicy.html]
|
||||
|
|
|
@ -5,5 +5,4 @@
|
|||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
MOCHITEST_MANIFESTS += ['mochitest.ini']
|
||||
MOCHITEST_CHROME_MANIFESTS += ['chrome.ini']
|
||||
|
||||
|
|
|
@ -5,8 +5,8 @@ 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" />
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=936340">Mozilla Bug 936340</a>
|
||||
|
@ -17,75 +17,39 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=936340
|
|||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
var beaconUrl = "http://mochi.test:8888/tests/dom/tests/mochitest/beacon/beacon-set-cookie.sjs";
|
||||
|
||||
// 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");
|
||||
const Cc = SpecialPowers.Cc;
|
||||
const Ci = SpecialPowers.Ci;
|
||||
|
||||
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);
|
||||
function examiner() {
|
||||
SpecialPowers.addObserver(this, "cookie-changed", false);
|
||||
}
|
||||
examiner.prototype = {
|
||||
finished: false,
|
||||
observe: function examiner_observe(subject, topic, data) {
|
||||
if (!this.finished) {
|
||||
ok(true, "cookie set by beacon request");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
}, "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);
|
||||
window.examiner = new examiner();
|
||||
|
||||
var win = mainWindow.OpenBrowserWindow(options);
|
||||
windowsToClose.push(win);
|
||||
whenDelayedStartupFinished(win, function() {
|
||||
callback(win);
|
||||
});
|
||||
};
|
||||
|
||||
var windowsToClose = [];
|
||||
var next;
|
||||
function fail() {
|
||||
examiner.finished = true;
|
||||
ok(false, "cookie event never arrived");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
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, "cookie-changed");
|
||||
ok(false, "cookie set by beacon request in private window");
|
||||
cleanup();
|
||||
}, "cookie-changed", false);
|
||||
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();
|
||||
navigator.sendBeacon(beaconUrl, "ceci n'est pas une demande");
|
||||
setTimeout(2000, fail);
|
||||
}
|
||||
|
||||
</script>
|
||||
|
|
Загрузка…
Ссылка в новой задаче