Bug 1578973 - Don't use autofocus in data URL since the data URL is treated as cross-origin thus autofocus doesn't work there. r=mikedeboer

We also use SpecialPowers.spawn to run the script to focus to the input element
so that it will work in fission world.

Differential Revision: https://phabricator.services.mozilla.com/D44949

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Hiroyuki Ikezoe 2019-09-12 21:37:46 +00:00
Родитель a355f15d53
Коммит 2eb5e006f1
1 изменённых файлов: 15 добавлений и 4 удалений

Просмотреть файл

@ -117,13 +117,12 @@ add_task(async function test_url_check() {
add_task(async function test_nested() {
const URL =
"data:text/html;charset=utf-8," +
"<iframe src='data:text/html;charset=utf-8," +
"<input autofocus=true>'/>";
"<iframe src='data:text/html;charset=utf-8,<input/>'/>";
const FORM_DATA = {
children: [
{
url: "data:text/html;charset=utf-8,<input autofocus=true>",
url: "data:text/html;charset=utf-8,<input/>",
xpath: { "/xhtml:html/xhtml:body/xhtml:input": "m" },
},
],
@ -132,7 +131,19 @@ add_task(async function test_nested() {
// Create a tab with an iframe containing an input field.
let tab = (gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, URL));
let browser = tab.linkedBrowser;
await promiseBrowserLoaded(browser);
await promiseBrowserLoaded(browser, false /* don't ignore subframes */);
const iframe = await SpecialPowers.spawn(browser, [], () => {
return content.document.querySelector("iframe").browsingContext;
});
await SpecialPowers.spawn(iframe, [], async () => {
const input = content.document.querySelector("input");
const focusPromise = new Promise(resolve => {
input.addEventListener("focus", resolve, { once: true });
});
input.focus();
await focusPromise;
});
// Modify the input field's value.
await BrowserTestUtils.synthesizeKey("m", {}, browser);