зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1544244 - fix cookie-checking in test_toolkit_securityreporter.js r=mgoodwin
Before this patch, test_toolkit_securityreporter.js would unconditionally try to get the value of the "Cookie" header. If a header isn't available, httpd.js apparently throws an exception. Interestingly, exceptions thrown in httpd.js path handlers aren't reported to the test framework, so we weren't aware of this. Additionally, the test didn't have any way of waiting until the security report it was expecting had arrived, so it just continued on and "succeeded". This patch addresses these issues by using "throws" to make sure no cookies are available and by inserting extra add_test/run_next_test pairs when the test is waiting for a report. Differential Revision: https://phabricator.services.mozilla.com/D27613 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
f69345fb1f
Коммит
e97d2e6b33
|
@ -44,10 +44,11 @@ function getReportCheck(expectReport, expectedError) {
|
|||
function(request, response) {
|
||||
if (expectReport) {
|
||||
let report = JSON.parse(readDataFromRequest(request));
|
||||
Assert.equal(request.getHeader("Cookie"), "", "No cookie sent.");
|
||||
throws(() => request.getHeader("Cookie"), /NS_ERROR_NOT_AVAILABLE/);
|
||||
Assert.equal(report.errorCode, expectedError);
|
||||
response.setStatusLine(null, 201, "Created");
|
||||
response.write("Created");
|
||||
run_next_test(); // resolve a "test" waiting on this report to be sent/received
|
||||
} else {
|
||||
do_throw("No report should have been received");
|
||||
}
|
||||
|
@ -133,11 +134,13 @@ function run_test() {
|
|||
add_connection_test("good.include-subdomains.pinning.example.com",
|
||||
PRErrorCodeSuccess, null,
|
||||
getReportCheck(true, PRErrorCodeSuccess));
|
||||
add_test(() => {}); // add a "test" so we wait for the report to be sent
|
||||
|
||||
// Test sending a report where there is an error and a failed cert chain.
|
||||
add_connection_test("expired.example.com",
|
||||
SEC_ERROR_EXPIRED_CERTIFICATE, null,
|
||||
getReportCheck(true, SEC_ERROR_EXPIRED_CERTIFICATE));
|
||||
add_test(() => {}); // add a "test" so we wait for the report to be sent
|
||||
|
||||
run_next_test();
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче