1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
/* eslint-disable mozilla/no-arbitrary-setTimeout */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
// Tests that with speculative connections enabled, connections to servers that
// request a client authentication certificate succeed (the specific bug that
// was addressed with this patch involved navigation hanging because the
// connection to the server couldn't make progress without asking for a client
// authentication certificate, but it also wouldn't ask for a client
// authentication certificate until the connection had been claimed, which
// required that it make progress first).
const { MockRegistrar } = ChromeUtils.importESModule(
"resource://testing-common/MockRegistrar.sys.mjs"
);
const TEST_PATH = getRootDirectory(gTestPath).replace(
"chrome://mochitests/content",
"https://example.com"
);
let chooseCertificateCalled = false;
const clientAuthDialogs = {
chooseCertificate(
hostname,
port,
organization,
issuerOrg,
certList,
selectedIndex,
rememberClientAuthCertificate
) {
is(certList.length, 1, "should have only one client certificate available");
selectedIndex.value = 0;
rememberClientAuthCertificate.value = false;
ok(
!chooseCertificateCalled,
"chooseCertificate should only be called once"
);
chooseCertificateCalled = true;
return true;
},
QueryInterface: ChromeUtils.generateQI(["nsIClientAuthDialogs"]),
};
add_setup(async function () {
await SpecialPowers.pushPrefEnv({
set: [
// Enable speculative connections.
["network.http.speculative-parallel-limit", 6],
// Always ask to select a client authentication certificate.
["security.default_personal_cert", "Ask Every Time"],
],
});
let clientAuthDialogsCID = MockRegistrar.register(
"@mozilla.org/nsClientAuthDialogs;1",
clientAuthDialogs
);
registerCleanupFunction(async function () {
MockRegistrar.unregister(clientAuthDialogsCID);
});
});
add_task(
async function test_no_client_auth_selection_dialog_for_speculative_connections() {
await BrowserTestUtils.withNewTab(
`${TEST_PATH}browser_clientAuth_speculative_connection.html`,
async browser => {
// Click the link to navigate to a page that requests a client
// authentication certificate. Necko will make a speculative
// connection, but unfortunately there's no event or notification to
// observe. This test ensures that the navigation succeeds and that a
// client authentication certificate was requested.
let loaded = BrowserTestUtils.browserLoaded(
browser,
false,
"https://requireclientcert.example.com/"
);
await BrowserTestUtils.synthesizeMouseAtCenter("#link", {}, browser);
await loaded;
ok(chooseCertificateCalled, "chooseCertificate must have been called");
}
);
}
);
|