mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 644734; r=gps
This commit is contained in:
parent
4ecd66eb46
commit
a7be27abcd
@ -117,9 +117,10 @@ RESTRequest.prototype = {
|
||||
response: null,
|
||||
|
||||
/**
|
||||
* nsIRequest load flags. Don't do any caching by default.
|
||||
* nsIRequest load flags. Don't do any caching by default. Don't send user
|
||||
* cookies and such over the wire (Bug 644734).
|
||||
*/
|
||||
loadFlags: Ci.nsIRequest.LOAD_BYPASS_CACHE | Ci.nsIRequest.INHIBIT_CACHING,
|
||||
loadFlags: Ci.nsIRequest.LOAD_BYPASS_CACHE | Ci.nsIRequest.INHIBIT_CACHING | Ci.nsIRequest.LOAD_ANONYMOUS,
|
||||
|
||||
/**
|
||||
* nsIHttpChannel
|
||||
|
@ -41,7 +41,8 @@ add_test(function test_attributes() {
|
||||
do_check_eq(request.response, null);
|
||||
do_check_eq(request.status, request.NOT_SENT);
|
||||
let expectedLoadFlags = Ci.nsIRequest.LOAD_BYPASS_CACHE |
|
||||
Ci.nsIRequest.INHIBIT_CACHING;
|
||||
Ci.nsIRequest.INHIBIT_CACHING |
|
||||
Ci.nsIRequest.LOAD_ANONYMOUS;
|
||||
do_check_eq(request.loadFlags, expectedLoadFlags);
|
||||
|
||||
run_next_test();
|
||||
@ -766,3 +767,26 @@ add_test(function test_new_channel() {
|
||||
advance();
|
||||
});
|
||||
});
|
||||
|
||||
add_test(function test_not_sending_cookie() {
|
||||
function handler(metadata, response) {
|
||||
let body = "COOKIE!";
|
||||
response.setStatusLine(metadata.httpVersion, 200, "OK");
|
||||
response.bodyOutputStream.write(body, body.length);
|
||||
do_check_false(metadata.hasHeader("Cookie"));
|
||||
}
|
||||
let server = httpd_setup({"/test": handler});
|
||||
|
||||
let cookieSer = Cc["@mozilla.org/cookieService;1"]
|
||||
.getService(Ci.nsICookieService);
|
||||
let uri = CommonUtils.makeURI("http://localhost:8080");
|
||||
cookieSer.setCookieString(uri, null, "test=test; path=/;", null);
|
||||
|
||||
let res = new RESTRequest("http://localhost:8080/test");
|
||||
res.get(function (error) {
|
||||
do_check_null(error);
|
||||
do_check_true(this.response.success);
|
||||
do_check_eq("COOKIE!", this.response.body);
|
||||
server.stop(run_next_test);
|
||||
});
|
||||
});
|
||||
|
@ -143,6 +143,8 @@ AsyncResource.prototype = {
|
||||
// Always validate the cache:
|
||||
channel.loadFlags |= Ci.nsIRequest.LOAD_BYPASS_CACHE;
|
||||
channel.loadFlags |= Ci.nsIRequest.INHIBIT_CACHING;
|
||||
// Don't send user cookies & such over the wire (Bug 644734)
|
||||
channel.loadFlags |= Ci.nsIRequest.LOAD_ANONYMOUS;
|
||||
|
||||
// Setup a callback to handle channel notifications.
|
||||
channel.notificationCallbacks = new ChannelNotificationListener();
|
||||
|
@ -700,6 +700,27 @@ add_test(function test_uri_construction() {
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
add_test(function test_not_sending_cookie() {
|
||||
function handler(metadata, response) {
|
||||
let body = "COOKIE!";
|
||||
response.setStatusLine(metadata.httpVersion, 200, "OK");
|
||||
response.bodyOutputStream.write(body, body.length);
|
||||
do_check_false(metadata.hasHeader("Cookie"));
|
||||
}
|
||||
let cookieSer = Cc["@mozilla.org/cookieService;1"]
|
||||
.getService(Ci.nsICookieService);
|
||||
let uri = CommonUtils.makeURI("http://localhost:8080");
|
||||
cookieSer.setCookieString(uri, null, "test=test; path=/;", null);
|
||||
|
||||
let res = new AsyncResource("http://localhost:8080/test");
|
||||
res.get(function (error) {
|
||||
do_check_null(error);
|
||||
do_check_true(this.response.success);
|
||||
do_check_eq("COOKIE!", this.response.body);
|
||||
server.stop(run_next_test);
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* End of tests that rely on a single HTTP server.
|
||||
* All tests after this point must begin and end their own.
|
||||
|
Loading…
Reference in New Issue
Block a user