blob: ae8c8607928432cfd412cc7ea68a5c85d0cef150 (
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
|
/* Any copyright is dedicated to the Public Domain.
* https://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
function getDataFromNextSubmitMessage() {
return new Promise(resolve => {
LoginManagerParent.setListenerForTests((msg, data) => {
if (msg == "ShowDoorhanger") {
resolve(data);
}
});
});
}
add_task(async function testCrossOriginFormUsesCorrectOrigin() {
const registry = Cc["@mozilla.org/chrome/chrome-registry;1"].getService(
Ci.nsIChromeRegistry
);
let dataPromise = getDataFromNextSubmitMessage();
let url =
registry.convertChromeURL(Services.io.newURI(getRootDirectory(gTestPath)))
.asciiSpec + "form_basic.html";
await BrowserTestUtils.withNewTab(
{
gBrowser,
url,
},
async function (browser) {
await SpecialPowers.spawn(browser.browsingContext, [], () => {
let doc = content.document;
doc.getElementById("form-basic-username").setUserInput("username");
doc.getElementById("form-basic-password").setUserInput("password");
doc.getElementById("form-basic").submit();
info("Submitting form");
});
}
);
let data = await dataPromise;
info("Origin retrieved from message listener");
Assert.equal(
data.origin,
"file://",
"Message origin should match form origin"
);
});
|