1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
6 const { HttpServer
} = ChromeUtils
.importESModule(
7 "resource://testing-common/httpd.sys.mjs"
10 const { XPCShellContentUtils
} = ChromeUtils
.importESModule(
11 "resource://testing-common/XPCShellContentUtils.sys.mjs"
14 XPCShellContentUtils
.ensureInitialized(this);
18 add_setup(async
function () {
19 gHttpServer
= new HttpServer();
20 let invalidHandler
= (req
, res
) => {
21 res
.setStatusLine(req
.httpVersion
, 500, "Oh no, it broke");
22 res
.write("Uh oh, it broke.");
24 let validHandler
= (req
, res
) => {
25 res
.setHeader("Content-Type", "application/ohttp-keys");
29 gHttpServer
.registerPathHandler("/.wellknown/invalid", invalidHandler
);
30 gHttpServer
.registerPathHandler("/.wellknown/valid", validHandler
);
32 gHttpServer
.start(-1);
35 function getLocalURL(path
) {
36 return `http://localhost:${gHttpServer.identity.primaryPort}/.wellknown/${path}`;
39 add_task(async
function test_out_of_process_use() {
40 let page
= await XPCShellContentUtils
.loadContentPage("about:certificate", {
44 let fetchURL
= getLocalURL("valid");
45 let contentFetch
= await page
.spawn([fetchURL
], url
=> {
46 // eslint-disable-next-line no-shadow
47 let { HPKEConfigManager
} = ChromeUtils
.importESModule(
48 "resource://gre/modules/HPKEConfigManager.sys.mjs"
51 return HPKEConfigManager
.get(url
);
53 Assert
.deepEqual(contentFetch
, new TextEncoder().encode("1234"));
55 page
.browsingContext
.currentWindowGlobal
.domProcess
.getActor(
58 "Should be able to get a parent actor for this browsingContext"
61 let randomPage
= await XPCShellContentUtils
.loadContentPage(
69 randomPage
.spawn([fetchURL
], async url
=> {
70 // eslint-disable-next-line no-shadow
71 let { HPKEConfigManager
} = ChromeUtils
.importESModule(
72 "resource://gre/modules/HPKEConfigManager.sys.mjs"
75 return HPKEConfigManager
.get(url
);
78 "Shouldn't be able to use HPKEConfigManager from random content processes."
82 randomPage
.browsingContext
.currentWindowGlobal
.domProcess
.getActor(
85 /Process protocol .*support remote type/,
86 "Should not be able to get a parent actor for a non-privilegedabout browsingContext"