Commit 38ce44ca authored by Ciure Andrei's avatar Ciure Andrei
Browse files

Backed out 2 changesets (bug 1545766, bug 1546633) for causing...

Backed out 2 changesets (bug 1545766, bug 1546633) for causing browser_PanelMultiView_keyboard.js to perma fail CLOSED TREE

Backed out changeset 041741ce1646 (bug 1546633)
Backed out changeset fbc294a6fe78 (bug 1545766)
parent 6b2c1efe
......@@ -1411,9 +1411,7 @@ var PanelView = class extends AssociatedToNode {
_isNavigableWithTabOnly(element) {
let tag = element.localName;
return tag == "menulist" || tag == "textbox" || tag == "input"
|| tag == "textarea"
// Allow tab to reach embedded documents in extension panels.
|| tag == "browser";
|| tag == "textarea";
}
/**
......@@ -1567,24 +1565,6 @@ var PanelView = class extends AssociatedToNode {
return;
}
let focus = this.document.activeElement;
// Make sure the focus is actually inside the panel. (It might not be if
// the panel was opened with the mouse.) If it isn't, we don't care
// about it for our purposes.
// We use Node.compareDocumentPosition because Node.contains doesn't
// behave as expected for anonymous content; e.g. the input inside a
// textbox.
if (focus && !(this.node.compareDocumentPosition(focus)
& Node.DOCUMENT_POSITION_CONTAINED_BY)) {
focus = null;
}
// Extension panels contain embedded documents. We can't manage
// keyboard navigation within those.
if (focus && focus.tagName == "browser") {
return;
}
let stop = () => {
event.stopPropagation();
event.preventDefault();
......@@ -1598,7 +1578,20 @@ var PanelView = class extends AssociatedToNode {
// We use the real focus rather than this.selectedElement because focus
// might have been moved without keyboard navigation (e.g. mouse click)
// and this.selectedElement is only updated for keyboard navigation.
return focus && this._isNavigableWithTabOnly(focus);
let focus = this.document.activeElement;
if (!focus) {
return false;
}
// Make sure the focus is actually inside the panel.
// (It might not be if the panel was opened with the mouse.)
// We use Node.compareDocumentPosition because Node.contains doesn't
// behave as expected for anonymous content; e.g. the input inside a
// textbox.
if (!(this.node.compareDocumentPosition(focus)
& Node.DOCUMENT_POSITION_CONTAINED_BY)) {
return false;
}
return this._isNavigableWithTabOnly(focus);
};
let keyCode = event.code;
......@@ -1664,17 +1657,12 @@ var PanelView = class extends AssociatedToNode {
this._doingKeyboardActivation = true;
// Unfortunately, 'tabindex' doesn't execute the default action, so
// we explicitly do this here.
// We are sending a command event, a mousedown event and then a click
// event. This is done in order to mimic a "real" mouse click event.
// Normally, the command event executes the action, then the click event
// closes the menu. However, in some cases (e.g. the Library button),
// there is no command event handler and the mousedown event executes the
// action instead.
// We are sending a command event and then a click event.
// This is done in order to mimic a "real" mouse click event.
// The command event executes the action, then the click event closes the menu.
button.doCommand();
let dispEvent = new event.target.ownerGlobal.MouseEvent("mousedown", {"bubbles": true});
button.dispatchEvent(dispEvent);
dispEvent = new event.target.ownerGlobal.MouseEvent("click", {"bubbles": true});
button.dispatchEvent(dispEvent);
let clickEvent = new event.target.ownerGlobal.MouseEvent("click", {"bubbles": true});
button.dispatchEvent(clickEvent);
this._doingKeyboardActivation = false;
break;
}
......
......@@ -23,8 +23,6 @@ let gMainArrowOrder;
let gSubView;
let gSubButton;
let gSubTextarea;
let gDocView;
let gDocBrowser;
async function openPopup() {
let shown = BrowserTestUtils.waitForEvent(gMainView, "ViewShown");
......@@ -38,10 +36,9 @@ async function hidePopup() {
await hidden;
}
async function showSubView(view = gSubView) {
let shown = BrowserTestUtils.waitForEvent(view, "ViewShown");
// We must show with an anchor so the Back button is generated.
gPanelMultiView.showSubView(view, gMainButton1);
async function showSubView() {
let shown = BrowserTestUtils.waitForEvent(gSubView, "ViewShown");
gPanelMultiView.showSubView(gSubView);
await shown;
}
......@@ -77,8 +74,6 @@ add_task(async function setup() {
gMainButton1 = document.createXULElement("button");
gMainButton1.id = "gMainButton1";
gMainView.appendChild(gMainButton1);
// We use this for anchoring subviews, so it must have a label.
gMainButton1.setAttribute("label", "gMainButton1");
gMainMenulist = document.createXULElement("menulist");
gMainMenulist.id = "gMainMenulist";
gMainView.appendChild(gMainMenulist);
......@@ -116,18 +111,6 @@ add_task(async function setup() {
gSubView.appendChild(gSubTextarea);
gSubTextarea.value = "value";
gDocView = document.createXULElement("panelview");
gDocView.id = "testDocView";
gPanelMultiView.appendChild(gDocView);
gDocBrowser = document.createXULElement("browser");
gDocBrowser.id = "gDocBrowser";
gDocBrowser.setAttribute("type", "content");
gDocBrowser.setAttribute("src",
'data:text/html,<textarea id="docTextarea">value</textarea><button id="docButton"></button>');
gDocBrowser.setAttribute("width", 100);
gDocBrowser.setAttribute("height", 100);
gDocView.appendChild(gDocBrowser);
registerCleanupFunction(() => {
gAnchor.remove();
gPanel.remove();
......@@ -287,48 +270,3 @@ add_task(async function testActivation() {
checkActivated(gMainButton1, () => EventUtils.synthesizeKey("KEY_Enter", {code: "NumpadEnter"}), "pressing numpad enter");
await hidePopup();
});
// Test that keyboard activation works for buttons responding to mousedown
// events (instead of command or click). The Library button does this, for
// example.
add_task(async function testActivationMousedown() {
await openPopup();
await expectFocusAfterKey("ArrowDown", gMainButton1);
let activated = false;
gMainButton1.onmousedown = function() { activated = true; };
EventUtils.synthesizeKey(" ");
ok(activated, "mousedown activated after space");
gMainButton1.onmousedown = null;
await hidePopup();
});
// Test that tab and the arrow keys aren't overridden in embedded documents.
add_task(async function testTabArrowsBrowser() {
await openPopup();
await showSubView(gDocView);
let backButton = gDocView.querySelector(".subviewbutton-back");
backButton.id = "docBack";
await expectFocusAfterKey("Tab", backButton);
let doc = gDocBrowser.contentDocument;
// Documents don't have an id property, but expectFocusAfterKey wants one.
doc.id = "doc";
await expectFocusAfterKey("Tab", doc);
// Make sure tab/arrows aren't overridden within the embedded document.
let textarea = doc.getElementById("docTextarea");
// Tab should really focus the textarea, but default tab handling seems to
// skip everything inside the browser element when run in this test. This
// behaves as expected in real panels, though. Force focus to the textarea
// and then test from there.
textarea.focus();
is(doc.activeElement, textarea, "textarea focused");
EventUtils.synthesizeKey("KEY_End");
is(textarea.selectionStart, 5, "selectionStart 5 after End");
EventUtils.synthesizeKey("KEY_ArrowLeft");
is(textarea.selectionStart, 4, "selectionStart 4 after ArrowLeft");
is(doc.activeElement, textarea, "textarea still focused");
let docButton = doc.getElementById("docButton");
expectFocusAfterKey("Tab", docButton);
// Make sure tab leaves the document and reaches the Back button.
expectFocusAfterKey("Tab", backButton);
await hidePopup();
});
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment