mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 16:25:38 +00:00
Backed out changeset 2a58697ddd0c (bug 1541923) for ESlint failure at test_NormandyApi.js and build bustages. CLOSED TREE
This commit is contained in:
parent
94ec493862
commit
5e01225e79
@ -43,7 +43,7 @@ var NormandyApi = {
|
||||
}
|
||||
|
||||
const headers = {"Accept": "application/json"};
|
||||
return fetch(url.href, {method, body, headers, credentials: "omit"});
|
||||
return fetch(url.href, {method, body, headers});
|
||||
},
|
||||
|
||||
get(endpoint, data) {
|
||||
|
@ -4,9 +4,6 @@
|
||||
ChromeUtils.import("resource://gre/modules/CanonicalJSON.jsm", this);
|
||||
ChromeUtils.import("resource://gre/modules/osfile.jsm", this);
|
||||
ChromeUtils.import("resource://normandy/lib/NormandyApi.jsm", this);
|
||||
ChromeUtils.import("resource://gre/modules/PromiseUtils.jsm", this);
|
||||
|
||||
Cu.importGlobalProperties(["fetch"]);
|
||||
|
||||
load("utils.js"); /* globals withMockApiServer, MockResponse, withScriptServer, withServer, makeMockApiServer */
|
||||
|
||||
@ -176,42 +173,3 @@ add_task(withScriptServer("query_server.sjs", async function test_postData(serve
|
||||
"NormandyApi sent an incorrect query string."
|
||||
);
|
||||
}));
|
||||
|
||||
// Test that no credentials are sent, even if the cookie store contains them.
|
||||
add_task(withScriptServer("cookie_server.sjs", async function test_sendsNoCredentials(serverUrl) {
|
||||
// This test uses cookie_server.sjs, which responds to all requests with a
|
||||
// response that sets a cookie.
|
||||
|
||||
// send a request, to store a cookie in the cookie store
|
||||
await fetch(serverUrl);
|
||||
|
||||
// A normal request should send that cookie
|
||||
const cookieExpectedDeferred = PromiseUtils.defer();
|
||||
function cookieExpectedObserver(aSubject, aTopic, aData) {
|
||||
equal(aTopic, "http-on-modify-request", "Only the expected topic should be observed");
|
||||
let httpChannel = aSubject.QueryInterface(Ci.nsIHttpChannel);
|
||||
equal(httpChannel.getRequestHeader("Cookie"), "type=chocolate-chip", "The header should be sent");
|
||||
Services.obs.removeObserver(cookieExpectedObserver, "http-on-modify-request");
|
||||
cookieExpectedDeferred.resolve();
|
||||
};
|
||||
Services.obs.addObserver(cookieExpectedObserver, "http-on-modify-request");
|
||||
await fetch(serverUrl);
|
||||
await cookieExpectedDeferred.promise;
|
||||
|
||||
// A request through the NormandyApi method should not send that cookie
|
||||
const cookieNotExpectedDeferred = PromiseUtils.defer();
|
||||
function cookieNotExpectedObserver(aSubject, aTopic, aData) {
|
||||
equal(aTopic, "http-on-modify-request", "Only the expected topic should be observed");
|
||||
let httpChannel = aSubject.QueryInterface(Ci.nsIHttpChannel);
|
||||
Assert.throws(
|
||||
() => httpChannel.getRequestHeader("Cookie"),
|
||||
/NS_ERROR_NOT_AVAILABLE/,
|
||||
"The cookie header should not be sent"
|
||||
);
|
||||
Services.obs.removeObserver(cookieNotExpectedObserver, "http-on-modify-request");
|
||||
cookieNotExpectedDeferred.resolve();
|
||||
};
|
||||
Services.obs.addObserver(cookieNotExpectedObserver, "http-on-modify-request");
|
||||
await NormandyApi.get(serverUrl);
|
||||
await cookieNotExpectedDeferred.promise;
|
||||
}));
|
||||
|
@ -6,7 +6,6 @@ support-files =
|
||||
invalid_recipe_signature_api/**
|
||||
query_server.sjs
|
||||
echo_server.sjs
|
||||
cookie_server.sjs
|
||||
utils.js
|
||||
tags = normandy
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user