/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* import-globals-from helper_inplace_editor.js */
"use strict";
loadHelperScript("helper_inplace_editor.js");
// Test the inplace-editor behavior with focusEditableFieldAfterApply
// and focusEditableFieldContainerSelector options
add_task(async function () {
await addTab(
"data:text/html;charset=utf-8,inline editor focusEditableFieldAfterApply"
);
const { host, doc } = await createHost();
testFocusNavigationWithMultipleEditor(doc);
testFocusNavigationWithNonMatchingFocusEditableFieldContainerSelector(doc);
testMissingFocusEditableFieldContainerSelector(doc);
host.destroy();
gBrowser.removeCurrentTab();
});
function testFocusNavigationWithMultipleEditor(doc) {
// For some reason
SPAN 3
BUTTON 3
SIDEBAR
`;
const span1 = doc.getElementById("span-1");
const span2 = doc.getElementById("span-2");
const span3 = doc.getElementById("span-3");
info("Create 3 editable fields for the 3 spans inside the main element");
const options = {
focusEditableFieldAfterApply: true,
focusEditableFieldContainerSelector: "main",
};
editableField({
element: span1,
...options,
});
editableField({
element: span2,
...options,
});
editableField({
element: span3,
...options,
});
span1.click();
is(
doc.activeElement.inplaceEditor.elt.id,
"span-1",
"Visible editable field is the one associated with span-1"
);
assertFocusedElementInplaceEditorInput(doc);
EventUtils.sendKey("Tab");
is(
doc.activeElement.inplaceEditor.elt.id,
"span-2",
"Using Tab moved focus to span-2 editable field"
);
assertFocusedElementInplaceEditorInput(doc);
EventUtils.sendKey("Tab");
is(
doc.activeElement.inplaceEditor.elt.id,
"span-3",
"Using Tab moved focus to span-3 editable field"
);
assertFocusedElementInplaceEditorInput(doc);
EventUtils.sendKey("Tab");
is(
doc.activeElement.id,
"sidebar-button",
"Using Tab moved focus outside of "
);
}
function testFocusNavigationWithNonMatchingFocusEditableFieldContainerSelector(
doc
) {
// For some reason