blob: 25b703067188f4b0cc4ad8271f8f265463c4710f (
plain)
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
|
"use strict";
const { ExtensionUtils } = ChromeUtils.importESModule(
"resource://gre/modules/ExtensionUtils.sys.mjs"
);
const proxy = createHttpServer();
add_task(async function test_speculative_connect() {
function background() {
// Handle the proxy request.
browser.proxy.onRequest.addListener(
details => {
browser.test.log(`onRequest ${JSON.stringify(details)}`);
browser.test.assertEq(
details.type,
"speculative",
"Should have seen a speculative proxy request."
);
return [{ type: "direct" }];
},
{ urls: ["<all_urls>"], types: ["speculative"] }
);
}
let handlingExt = ExtensionTestUtils.loadExtension({
manifest: {
permissions: ["proxy", "<all_urls>"],
},
background: `(${background})()`,
});
Services.prefs.setBoolPref("network.http.debug-observations", true);
await handlingExt.startup();
let notificationPromise = ExtensionUtils.promiseObserved(
"speculative-connect-request"
);
let uri = Services.io.newURI(
`http://${proxy.identity.primaryHost}:${proxy.identity.primaryPort}`
);
Services.io.speculativeConnect(
uri,
Services.scriptSecurityManager.getSystemPrincipal(),
null,
false
);
await notificationPromise;
await handlingExt.unload();
});
|