mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-23 02:05:42 +00:00
Bug 1539362 Don't send cookies with langpack lookup requests r=johannh
Differential Revision: https://phabricator.services.mozilla.com/D26059 --HG-- extra : rebase_source : f311f2947d3a3b400fac706dbd3abd7439fdfb7f
This commit is contained in:
parent
8df9e89219
commit
352f277b26
@ -786,7 +786,7 @@ var AddonRepository = {
|
||||
// http://addons-server.readthedocs.io/en/latest/topics/api/addons.html#language-tools
|
||||
let url = this._formatURLPref(PREF_GET_LANGPACKS);
|
||||
|
||||
let response = await fetch(url);
|
||||
let response = await fetch(url, {credentials: "omit"});
|
||||
if (!response.ok) {
|
||||
throw new Error("fetching available language packs failed");
|
||||
}
|
||||
|
@ -1,10 +1,9 @@
|
||||
const PREF_GET_LANGPACKS = "extensions.getAddons.langpacks.url";
|
||||
|
||||
let server = AddonTestUtils.createHttpServer({hosts: ["example.com"]});
|
||||
Services.prefs.setStringPref(PREF_GET_LANGPACKS, "http://example.com/langpacks.json");
|
||||
|
||||
add_task(async function setup() {
|
||||
Services.prefs.setStringPref(PREF_GET_LANGPACKS, "http://example.com/langpacks.json");
|
||||
|
||||
add_task(async function test_getlangpacks() {
|
||||
function setData(data) {
|
||||
if (typeof data != "string") {
|
||||
data = JSON.stringify(data);
|
||||
@ -90,3 +89,23 @@ add_task(async function setup() {
|
||||
await Assert.rejects(AddonRepository.getAvailableLangpacks(),
|
||||
/SyntaxError/, "Got parse error on invalid JSON");
|
||||
});
|
||||
|
||||
// Tests that cookies are not sent with langpack requests.
|
||||
add_task(async function test_cookies() {
|
||||
let lastRequest = null;
|
||||
server.registerPathHandler("/langpacks.json", (request, response) => {
|
||||
lastRequest = request;
|
||||
response.write(JSON.stringify({results: []}));
|
||||
});
|
||||
|
||||
const COOKIE = "test";
|
||||
let expiration = Date.now() / 1000 + 60 * 60;
|
||||
Services.cookies.add("example.com", "/", COOKIE, "testing",
|
||||
false, false, false, expiration, {},
|
||||
Ci.nsICookie2.SAMESITE_UNSET);
|
||||
|
||||
await AddonRepository.getAvailableLangpacks();
|
||||
|
||||
notEqual(lastRequest, null, "Received langpack request");
|
||||
equal(lastRequest.hasHeader("Cookie"), false, "Langpack request has no cookies");
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user