Commit 382366ae authored by Glenn Adams's avatar Glenn Adams

Populate level 3 cookies test.

parent 01eab788
"use strict";
function run(t) {
var defProperties = t.properties.def;
t.done();
var ident = 'test';
var url = './resources/set-cookie.py?ident=' + ident;
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.onload = t.step_func(function() {
test(function() {
assert_equals(xhr.status, 200);
}, defProperties.expandedName + '-test-response-status');
if (xhr.status == 200) {
test(function() {
assert_equals(xhr.response, "NO_COOKIE");
}, defProperties.expandedName + '-test-cookie-not-present');
xhr.open('GET', url, true);
xhr.onload = t.step_func_done(function() {
test(function() {
assert_equals(xhr.response, "COOKIE");
}, defProperties.expandedName + '-test-cookie-present');
});
xhr.send();
} else
t.done();
});
xhr.onerror = function() {
assert_unreached('unable to load ' + url);
};
document.cookie = ident + '=; expires=Thu, 01 Jan 1970 00:00:00 UTC';
xhr.send();
}
import pprint
def main(request, response):
headers = [("Content-Type", "text/plain")]
ident = request.GET.first('ident', 'test')
if ident in request.cookies:
body = request.cookies[ident].value
response.delete_cookie(ident)
else:
response.set_cookie(ident, "COOKIE");
body = "NO_COOKIE"
return headers, body
This diff is collapsed.
"use strict";
function run(t) {
var defProperties = t.properties.def;
t.done();
var ident = 'test';
var url = './resources/set-cookie.py?ident=' + ident;
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.onload = t.step_func(function() {
test(function() {
assert_equals(xhr.status, 200);
}, defProperties.expandedName + '-test-response-status');
if (xhr.status == 200) {
test(function() {
assert_equals(xhr.response, "NO_COOKIE");
}, defProperties.expandedName + '-test-cookie-not-present');
xhr.open('GET', url, true);
xhr.onload = t.step_func_done(function() {
test(function() {
assert_equals(xhr.response, "COOKIE");
}, defProperties.expandedName + '-test-cookie-present');
});
xhr.send();
} else
t.done();
});
xhr.onerror = function() {
assert_unreached('unable to load ' + url);
};
document.cookie = ident + '=; expires=Thu, 01 Jan 1970 00:00:00 UTC';
xhr.send();
}
import pprint
def main(request, response):
headers = [("Content-Type", "text/plain")]
ident = request.GET.first('ident', 'test')
if ident in request.cookies:
body = request.cookies[ident].value
response.delete_cookie(ident)
else:
response.set_cookie(ident, "COOKIE");
body = "NO_COOKIE"
return headers, body
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment