gecko-dev/netwerk/test/mochitests/test_1421324.html
Brian Grinstead ede8c44ef2 Bug 1544322 - Part 2.1 - Remove the [type] attribute for one-liner <script> tags loading files in /tests/SimpleTest/ in everything except for dom/ r=bzbarsky
This excludes dom/, otherwise the file size is too large for phabricator to handle.

This is an autogenerated commit to handle scripts loading mochitest harness files, in
the simple case where the script src is on the same line as the tag.

This was generated with https://bug1544322.bmoattachments.org/attachment.cgi?id=9058170
using the `--part 2` argument.

Differential Revision: https://phabricator.services.mozilla.com/D27456

--HG--
extra : moz-landing-system : lando
2019-04-16 03:50:44 +00:00

87 lines
2.4 KiB
HTML

<!DOCTYPE HTML>
<html>
<!--
-->
<head>
<title>Cookie changes from XHR requests are observed in content processes.</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
<script type="text/javascript">
SimpleTest.waitForExplicitFinish();
var gScript = SpecialPowers.loadChromeScript(SimpleTest.getTestFileURL('file_1331680.js'));
gScript.addMessageListener("cookieName", confirmCookieName);
gScript.addMessageListener("removeObserver:return", finishTest);
gScript.sendAsyncMessage('createObserver');
// Confirm the notify which represents the cookie is updating.
var testsNum = 0;
function confirmCookieName(name) {
testsNum++;
switch(testsNum) {
case 1:
is(name, "testXHR1=xhr_val1", "The cookie which names " + name + " is update to db");
break;
case 2:
document.cookie = "testXHR2=xhr_val2; path=/";
break;
case 3:
is(document.cookie, "testXHR2=xhr_val2", "Confirm the cookie string");
document.cookie = "testXHR1=; path=/; expires=Thu, 01-Jan-1970 00:00:01 GMT";
document.cookie = "testXHR2=; path=/; expires=Thu, 01-Jan-1970 00:00:01 GMT";
gScript.sendAsyncMessage('removeObserver');
break;
}
}
function finishTest() {
SimpleTest.finish();
}
function createXHR(url) {
return new Promise(function (resolve, reject) {
var xhr = new XMLHttpRequest();
xhr.open("GET", url, true); // async request
xhr.onload = function () {
if (this.status >= 200 && this.status < 300) {
resolve(xhr.response);
} else {
reject({
status: this.status,
statusText: xhr.statusText
});
}
};
xhr.onerror = function () {
reject({
status: this.status,
statusText: xhr.statusText
});
};
xhr.send();
});
}
/* Test XHR
* 1. Create two XHR.
* 2. One of the XHR create a cookie names "set_cookie", and other one create a http-only cookie names "modify_cookie".
* 3. Child process only set testXHR1 to cookies hash table.
* 4. Child process only can get the testXHR1 cookie from cookies hash table.
*/
Promise.resolve()
.then(_ => createXHR('reset_cookie_xhr.sjs?set_cookie'))
.then(_ => createXHR('reset_cookie_xhr.sjs?modify_cookie'));
</script>
</head>
<body>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
</pre>
</body>
</html>