Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
<?xml version="1.0"?>
|
|
|
|
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
|
|
|
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
|
|
|
|
type="text/css"?>
|
|
|
|
<!--
|
|
|
|
This test checks focus in various ways
|
|
|
|
-->
|
|
|
|
<window id="outer-document" title="Focus Test" width="600" height="550"
|
|
|
|
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
|
|
|
<script type="application/javascript"
|
|
|
|
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
|
|
|
<script type="application/javascript"
|
|
|
|
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
|
|
|
|
|
|
|
|
<body xmlns="http://www.w3.org/1999/xhtml"/>
|
|
|
|
|
|
|
|
<script type="application/javascript"><![CDATA[
|
|
|
|
|
|
|
|
var fm = Components.classes["@mozilla.org/focus-manager;1"].
|
|
|
|
getService(Components.interfaces.nsIFocusManager);
|
|
|
|
|
|
|
|
const kChildDocumentRootIndex = 13;
|
|
|
|
const kBeforeTabboxIndex = 34;
|
|
|
|
const kTabbableSteps = 38;
|
2013-03-01 04:15:59 +04:00
|
|
|
const kFocusSteps = 26;
|
|
|
|
const kNoFocusSteps = 7;
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
const kOverflowElementIndex = 27;
|
|
|
|
|
|
|
|
var gTestStarted = false;
|
|
|
|
var gPartialTabbing = false;
|
|
|
|
var gMoveToFocusFrame = false;
|
|
|
|
var gLastFocus = null;
|
|
|
|
var gLastFocusWindow = window;
|
|
|
|
var gLastFocusMethod = -1;
|
|
|
|
var gEvents = "";
|
|
|
|
var gExpectedEvents = "";
|
|
|
|
var gEventMatched = true;
|
|
|
|
var gShowOutput = false;
|
|
|
|
var gChildWindow = null;
|
|
|
|
|
|
|
|
var gOldExpectedWindow = null;
|
|
|
|
var gNewExpectedWindow = null;
|
|
|
|
|
|
|
|
function is(l, r, n) { window.opener.wrappedJSObject.SimpleTest.is(l,r,n); }
|
|
|
|
function ok(v, n) { window.opener.wrappedJSObject.SimpleTest.ok(v,n); }
|
|
|
|
|
|
|
|
function initEvents(target)
|
|
|
|
{
|
|
|
|
target.addEventListener("focus", eventOccured, true);
|
|
|
|
target.addEventListener("blur", eventOccured, true);
|
2009-10-29 22:11:00 +03:00
|
|
|
getTopWindow(target).addEventListener("activate", eventOccured, true);
|
|
|
|
getTopWindow(target).addEventListener("deactivate", eventOccured, true);
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
function eventOccured(event)
|
|
|
|
{
|
|
|
|
// iframes should never receive focus or blur events directly
|
|
|
|
if (event.target instanceof Element && event.target.localName == "iframe")
|
|
|
|
ok(false, "iframe " + event.type + "occured");
|
|
|
|
|
|
|
|
var id;
|
|
|
|
if (gOldExpectedWindow && event.type == "blur") {
|
|
|
|
if (event.target instanceof Window)
|
|
|
|
id = "frame-" + gOldExpectedWindow.document.documentElement.id + "-window";
|
|
|
|
else if (event.target instanceof Document)
|
|
|
|
id = "frame-" + gOldExpectedWindow.document.documentElement.id + "-document";
|
|
|
|
else
|
|
|
|
id = event.originalTarget.id;
|
|
|
|
}
|
|
|
|
else if (gNewExpectedWindow && event.type == "focus") {
|
|
|
|
if (event.target instanceof Window)
|
|
|
|
id = "frame-" + gNewExpectedWindow.document.documentElement.id + "-window";
|
|
|
|
else if (event.target instanceof Document)
|
|
|
|
id = "frame-" + gNewExpectedWindow.document.documentElement.id + "-document";
|
|
|
|
else
|
|
|
|
id = event.originalTarget.id;
|
|
|
|
}
|
2009-10-29 22:11:00 +03:00
|
|
|
else if (event.type == "activate" || event.type == "deactivate")
|
|
|
|
id = event.target.document.documentElement.id + "-window";
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
else if (event.target instanceof Window)
|
|
|
|
id = (event.target == window) ? "outer-window" : "child-window";
|
|
|
|
else if (event.target instanceof Document)
|
|
|
|
id = (event.target == document) ? "outer-document" : "child-document";
|
|
|
|
else
|
|
|
|
id = event.originalTarget.id;
|
|
|
|
|
|
|
|
if (gEvents)
|
|
|
|
gEvents += " ";
|
|
|
|
gEvents += event.type + ": " + id;
|
|
|
|
}
|
|
|
|
|
2009-09-08 15:24:20 +04:00
|
|
|
function expectFocusShift(callback, expectedWindow, expectedElement, focusChanged, testid)
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
{
|
|
|
|
if (expectedWindow == null)
|
|
|
|
expectedWindow = expectedElement ?
|
|
|
|
expectedElement.ownerDocument.defaultView :
|
|
|
|
gLastFocusWindow;
|
|
|
|
|
|
|
|
var expectedEvents = "";
|
|
|
|
if (focusChanged) {
|
2009-10-29 22:11:00 +03:00
|
|
|
var id;
|
|
|
|
if (getTopWindow(gLastFocusWindow) != getTopWindow(expectedWindow)) {
|
|
|
|
id = getTopWindow(gLastFocusWindow).document.documentElement.id;
|
|
|
|
expectedEvents += "deactivate: " + id + "-window";
|
|
|
|
}
|
|
|
|
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
if (gLastFocus && gLastFocus.id != "t" + kChildDocumentRootIndex &&
|
|
|
|
(!gOldExpectedWindow || gOldExpectedWindow.document.documentElement != gLastFocus)) {
|
2009-10-29 22:11:00 +03:00
|
|
|
if (expectedEvents)
|
|
|
|
expectedEvents += " ";
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
if (!gOldExpectedWindow)
|
|
|
|
expectedEvents += "commandupdate: cu ";
|
|
|
|
expectedEvents += "blur: " + gLastFocus.id;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gLastFocusWindow && gLastFocusWindow != expectedWindow) {
|
|
|
|
if (!gMoveToFocusFrame) {
|
|
|
|
if (gOldExpectedWindow)
|
|
|
|
id = "frame-" + gOldExpectedWindow.document.documentElement.id;
|
|
|
|
else
|
|
|
|
id = (gLastFocusWindow == window) ? "outer" : "child";
|
|
|
|
if (expectedEvents)
|
|
|
|
expectedEvents += " ";
|
|
|
|
expectedEvents += "blur: " + id + "-document " +
|
|
|
|
"blur: " + id + "-window";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-29 22:11:00 +03:00
|
|
|
if (getTopWindow(gLastFocusWindow) != getTopWindow(expectedWindow)) {
|
|
|
|
id = getTopWindow(expectedWindow).document.documentElement.id;
|
|
|
|
if (expectedEvents)
|
|
|
|
expectedEvents += " ";
|
|
|
|
expectedEvents += "activate: " + id + "-window";
|
|
|
|
}
|
|
|
|
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
if (expectedWindow && gLastFocusWindow != expectedWindow) {
|
|
|
|
if (gNewExpectedWindow)
|
|
|
|
id = "frame-" + gNewExpectedWindow.document.documentElement.id;
|
|
|
|
else
|
|
|
|
id = (expectedWindow == window) ? "outer" : "child";
|
|
|
|
if (expectedEvents)
|
|
|
|
expectedEvents += " ";
|
|
|
|
expectedEvents += "focus: " + id + "-document " +
|
|
|
|
"focus: " + id + "-window";
|
|
|
|
}
|
|
|
|
|
|
|
|
// for this test which fires a mouse event on a label, the document will
|
|
|
|
// be focused first and then the label code will focus the related
|
|
|
|
// control. This doesn't result in different focus events, but a command
|
2015-07-08 07:46:48 +03:00
|
|
|
// update will occur for the document and then a second command update will
|
|
|
|
// occur when the control is focused. However, this will only happen on
|
|
|
|
// platforms or controls where mouse clicks cause trigger focus.
|
|
|
|
if (testid == "mouse on html label with content inside" &&
|
|
|
|
mouseWillTriggerFocus(expectedElement)) {
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
expectedEvents += " commandupdate: cu";
|
2015-07-08 07:46:48 +03:00
|
|
|
}
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
|
2010-04-21 17:14:35 +04:00
|
|
|
if (expectedElement &&
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
(!gNewExpectedWindow || gNewExpectedWindow.document.documentElement != expectedElement)) {
|
2010-04-21 17:14:35 +04:00
|
|
|
if (!gNewExpectedWindow) {
|
|
|
|
if (expectedEvents)
|
|
|
|
expectedEvents += " ";
|
|
|
|
expectedEvents += "commandupdate: cu";
|
|
|
|
}
|
|
|
|
if (expectedElement.id != "t" + kChildDocumentRootIndex) {
|
|
|
|
if (expectedEvents)
|
|
|
|
expectedEvents += " ";
|
|
|
|
expectedEvents += "focus: " + expectedElement.id;
|
|
|
|
}
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
}
|
|
|
|
else if (expectedWindow && gLastFocusWindow != expectedWindow &&
|
|
|
|
!expectedElement) {
|
|
|
|
if (expectedEvents)
|
|
|
|
expectedEvents += " ";
|
|
|
|
expectedEvents += "commandupdate: cu";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gLastFocus = expectedElement;
|
|
|
|
gLastFocusWindow = expectedWindow;
|
|
|
|
|
|
|
|
callback();
|
|
|
|
|
|
|
|
compareEvents(expectedEvents, expectedWindow, expectedElement, testid);
|
|
|
|
}
|
|
|
|
|
|
|
|
function compareEvents(expectedEvents, expectedWindow, expectedElement, testid)
|
|
|
|
{
|
|
|
|
if (!gShowOutput) {
|
|
|
|
gEvents = "";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
is(gEvents, expectedEvents, testid + " events");
|
|
|
|
gEvents = "";
|
|
|
|
|
|
|
|
var doc;
|
|
|
|
if (expectedWindow == window)
|
|
|
|
doc = "outer-document";
|
|
|
|
else if (expectedWindow == gChildWindow)
|
|
|
|
doc = "inner-document";
|
|
|
|
else if (gNewExpectedWindow)
|
|
|
|
doc = gNewExpectedWindow.document.body ? gNewExpectedWindow.document.body.id :
|
|
|
|
gNewExpectedWindow.document.documentElement.id;
|
|
|
|
else
|
|
|
|
doc = "other-document";
|
|
|
|
|
|
|
|
var focusedElement = fm.focusedElement;
|
|
|
|
is(focusedElement ? focusedElement.id : "none",
|
|
|
|
expectedElement ? expectedElement.id : "none", testid + " focusedElement");
|
|
|
|
is(fm.focusedWindow, expectedWindow, testid + " focusedWindow");
|
|
|
|
var focusedWindow = {};
|
|
|
|
is(fm.getFocusedElementForWindow(expectedWindow, false, focusedWindow),
|
|
|
|
expectedElement, testid + " getFocusedElementForWindow");
|
|
|
|
is(focusedWindow.value, expectedWindow, testid + " getFocusedElementForWindow frame");
|
|
|
|
is(expectedWindow.document.hasFocus(), true, testid + " hasFocus");
|
|
|
|
is(expectedWindow.document.activeElement ? expectedWindow.document.activeElement.id : "none",
|
|
|
|
expectedElement ? expectedElement.id : doc, testid + " activeElement");
|
|
|
|
var cdwindow = getTopWindow(expectedWindow);
|
|
|
|
if (cdwindow.document.commandDispatcher) {
|
|
|
|
is(cdwindow.document.commandDispatcher.focusedWindow, expectedWindow, testid + " commandDispatcher focusedWindow");
|
|
|
|
is(cdwindow.document.commandDispatcher.focusedElement, focusedElement, testid + " commandDispatcher focusedElement");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gLastFocusMethod != -1) {
|
|
|
|
is(fm.getLastFocusMethod(null), gLastFocusMethod, testid + " lastFocusMethod null");
|
|
|
|
is(fm.getLastFocusMethod(expectedWindow), gLastFocusMethod, testid + " lastFocusMethod window");
|
|
|
|
}
|
|
|
|
|
|
|
|
// the parent should have the iframe focused
|
|
|
|
if (doc == "inner-document") {
|
|
|
|
is(document.hasFocus(), true, testid + " hasFocus");
|
|
|
|
is(fm.getFocusedElementForWindow(window, false, focusedWindow),
|
|
|
|
$("childframe"), testid + " getFocusedElementForWindow for parent");
|
|
|
|
is(focusedWindow.value, window, testid + " getFocusedElementForWindow for parent frame");
|
|
|
|
is(fm.getFocusedElementForWindow(window, true, focusedWindow),
|
|
|
|
expectedElement, testid + " getFocusedElementForWindow deep for parent");
|
|
|
|
is(focusedWindow.value, gChildWindow, testid + " getFocusedElementForWindow deep for parent frame");
|
|
|
|
is(document.activeElement.id, "childframe", testid + " activeElement for parent");
|
|
|
|
}
|
|
|
|
|
|
|
|
// compare the selection for the child window. Skip mouse tests as the caret
|
|
|
|
// is adjusted by the selection code for mouse clicks, and not the focus code.
|
|
|
|
if (expectedWindow == window) {
|
|
|
|
var selection = window.getSelection();
|
|
|
|
ok(selection.focusNode == null && selection.focusOffset == 0 &&
|
|
|
|
selection.anchorNode == null && selection.anchorOffset == 0, testid + " selection");
|
|
|
|
}
|
|
|
|
else if ((expectedWindow == gChildWindow) && !testid.indexOf("mouse") == -1) {
|
|
|
|
checkSelection(expectedElement, testid);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function checkSelection(node, testid)
|
|
|
|
{
|
|
|
|
var selection = gChildWindow.getSelection();
|
|
|
|
|
|
|
|
var range = gChildWindow.document.createRange();
|
|
|
|
range.selectNodeContents(node);
|
|
|
|
if (!node.firstChild || node.localName == "input" ||
|
|
|
|
node.localName == "select" || node.localName == "button") {
|
|
|
|
range.setStartBefore(node);
|
|
|
|
range.setEndBefore(node);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (node.firstChild)
|
|
|
|
range.setEnd(range.startContainer, range.startOffset);
|
|
|
|
|
|
|
|
is(selection.focusNode, range.startContainer, testid + " selection focusNode");
|
|
|
|
is(selection.focusOffset, range.startOffset, testid + " selection focusOffset");
|
|
|
|
is(selection.anchorNode, range.endContainer, testid + " selection anchorNode");
|
|
|
|
is(selection.anchorOffset, range.endOffset, testid + " selection anchorOffset");
|
|
|
|
}
|
|
|
|
|
|
|
|
function getTopWindow(win)
|
|
|
|
{
|
|
|
|
return win.QueryInterface(Components.interfaces.nsIInterfaceRequestor).
|
|
|
|
getInterface(Components.interfaces.nsIWebNavigation).
|
|
|
|
QueryInterface(Components.interfaces.nsIDocShellTreeItem).rootTreeItem.
|
|
|
|
QueryInterface(Components.interfaces.nsIInterfaceRequestor).
|
|
|
|
getInterface(Components.interfaces.nsIDOMWindow);
|
|
|
|
}
|
|
|
|
|
2015-07-08 07:46:48 +03:00
|
|
|
function mouseWillTriggerFocus(element)
|
|
|
|
{
|
|
|
|
if (!element) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (navigator.platform.indexOf("Mac") != 0) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (element.namespaceURI == "http://www.w3.org/1999/xhtml") {
|
|
|
|
// links are special. They can be focused but show no focus ring
|
|
|
|
if (element.localName == "a" || element.localName == "div" ||
|
|
|
|
element.localName == "select" ||
|
|
|
|
element.localName == "input" && (element.type == "text" ||
|
|
|
|
element.type == "password")) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} else if (element.localName == "listbox") {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-04-21 18:53:42 +04:00
|
|
|
function mouseOnElement(element, expectedElement, focusChanged, testid)
|
|
|
|
{
|
|
|
|
var expectedWindow = (element.ownerDocument.defaultView == gChildWindow) ? gChildWindow : window;
|
2011-01-05 16:23:37 +03:00
|
|
|
// on Mac, form elements are not focused when clicking, except for lists and textboxes.
|
2015-07-08 07:46:48 +03:00
|
|
|
var noFocusOnMouse = !mouseWillTriggerFocus(element)
|
2010-06-21 16:37:34 +04:00
|
|
|
|
|
|
|
if (noFocusOnMouse) {
|
2010-04-21 18:53:42 +04:00
|
|
|
// no focus so the last focus method will be 0
|
|
|
|
gLastFocusMethod = 0;
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => synthesizeMouse(element, 4, 4, { }, element.ownerDocument.defaultView),
|
2010-04-21 18:53:42 +04:00
|
|
|
expectedWindow, null, true, testid);
|
|
|
|
gLastFocusMethod = fm.FLAG_BYMOUSE;
|
|
|
|
}
|
|
|
|
else {
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => synthesizeMouse(element, 4, 4, { }, element.ownerDocument.defaultView),
|
2010-04-21 18:53:42 +04:00
|
|
|
element.ownerDocument.defaultView,
|
|
|
|
expectedElement, focusChanged, testid);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
function done()
|
|
|
|
{
|
|
|
|
var opener = window.opener;
|
|
|
|
window.close();
|
|
|
|
opener.wrappedJSObject.SimpleTest.finish();
|
|
|
|
}
|
|
|
|
|
2015-09-23 12:39:15 +03:00
|
|
|
var pressTab = () => synthesizeKey("VK_TAB", { });
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
|
|
|
|
function setFocusTo(id, fwindow)
|
|
|
|
{
|
|
|
|
gLastFocus = getById(id);
|
|
|
|
gLastFocusWindow = fwindow;
|
2010-04-21 18:53:42 +04:00
|
|
|
if (gLastFocus)
|
|
|
|
gLastFocus.focus();
|
|
|
|
else
|
|
|
|
fm.clearFocus(fwindow);
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
gEvents = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
function getById(id)
|
|
|
|
{
|
|
|
|
if (gNewExpectedWindow)
|
|
|
|
return gNewExpectedWindow.document.getElementById(id);
|
|
|
|
var element = $(id);
|
|
|
|
if (!element)
|
|
|
|
element = $("childframe").contentDocument.getElementById(id);
|
|
|
|
return element;
|
|
|
|
}
|
|
|
|
|
|
|
|
function startTest()
|
|
|
|
{
|
|
|
|
if (gTestStarted)
|
|
|
|
return;
|
|
|
|
gTestStarted = true;
|
|
|
|
|
|
|
|
gChildWindow = $("childframe").contentWindow;
|
|
|
|
gShowOutput = true;
|
|
|
|
|
|
|
|
// synthesize a mousemove over the image to ensure that the imagemap data is
|
|
|
|
// created. Otherwise, the special imagemap frames might not exist, and
|
|
|
|
// won't be focusable.
|
|
|
|
synthesizeMouse(getById("image"), 4, 4, { type: "mousemove" }, gChildWindow);
|
|
|
|
|
|
|
|
initEvents(window);
|
|
|
|
|
|
|
|
is(fm.activeWindow, window, "activeWindow");
|
|
|
|
is(gChildWindow.document.hasFocus(), false, " child document hasFocus");
|
|
|
|
|
|
|
|
// test to see if the Mac Full Keyboard Access setting is set. If t3 is
|
|
|
|
// focused after tab is pressed, then it is set to textboxes and lists only.
|
|
|
|
// Otherwise, all elements are in the tab order.
|
|
|
|
pressTab();
|
|
|
|
|
|
|
|
if (fm.focusedElement.id == "t3")
|
|
|
|
gPartialTabbing = true;
|
|
|
|
else
|
|
|
|
is(fm.focusedElement.id, "t1", "initial tab key");
|
|
|
|
|
|
|
|
is(fm.getLastFocusMethod(null), fm.FLAG_BYKEY, "last focus method null start");
|
|
|
|
is(fm.getLastFocusMethod(window), fm.FLAG_BYKEY, "last focus method window start");
|
|
|
|
|
|
|
|
fm.clearFocus(window);
|
|
|
|
gEvents = "";
|
|
|
|
|
|
|
|
gLastFocusMethod = fm.FLAG_BYKEY;
|
|
|
|
if (gPartialTabbing) {
|
2010-07-02 18:50:08 +04:00
|
|
|
var partialTabList = ["t3", "t5", "t9", "t10", "t11", "t12", "t13", "t14", "t15",
|
|
|
|
"t16", "t19", "t20", "t21", "t22", "t26", "t27", "t28", "t29", "t30"];
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
for (var idx = 0; idx < partialTabList.length; idx++) {
|
2009-09-08 15:24:20 +04:00
|
|
|
expectFocusShift(pressTab, null, getById(partialTabList[idx]), true, "partial tab key " + partialTabList[idx]);
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
}
|
|
|
|
setFocusTo("last", window);
|
2009-09-08 15:24:20 +04:00
|
|
|
expectFocusShift(pressTab, null, getById(partialTabList[0]), true, "partial tab key wrap to start");
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => synthesizeKey("VK_TAB", { shiftKey: true }),
|
2009-09-08 15:24:20 +04:00
|
|
|
null, getById("last"), true, "partial shift tab key wrap to end");
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
for (var idx = partialTabList.length - 1; idx >= 0; idx--) {
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => synthesizeKey("VK_TAB", { shiftKey: true }),
|
2009-09-08 15:24:20 +04:00
|
|
|
null, getById(partialTabList[idx]), true, "partial tab key " + partialTabList[idx]);
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// TAB key
|
|
|
|
for (var idx = 1; idx <= kTabbableSteps; idx++) {
|
2009-09-08 15:24:20 +04:00
|
|
|
expectFocusShift(pressTab, null, getById("t" + idx), true, "tab key t" + idx);
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// wrapping around at end with TAB key
|
|
|
|
setFocusTo("last", window);
|
2009-09-08 15:24:20 +04:00
|
|
|
expectFocusShift(pressTab, null, getById("t1"), true, "tab key wrap to start");
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => synthesizeKey("VK_TAB", { shiftKey: true }),
|
2009-09-08 15:24:20 +04:00
|
|
|
null, getById("last"), true, "shift tab key wrap to end");
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
|
|
|
|
// Shift+TAB key
|
|
|
|
setFocusTo("o5", window);
|
|
|
|
for (idx = kTabbableSteps; idx > 0; idx--) {
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => synthesizeKey("VK_TAB", { shiftKey: true }),
|
2009-09-08 15:24:20 +04:00
|
|
|
null, getById("t" + idx), true, "shift tab key t" + idx);
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var t19 = getById("t19");
|
|
|
|
is(t19.selectionStart, 0, "input focused from tab key selectionStart");
|
|
|
|
is(t19.selectionEnd, 5, "input focused from tab key selectionEnd");
|
|
|
|
t19.setSelectionRange(0, 0);
|
|
|
|
|
2009-07-13 15:55:56 +04:00
|
|
|
gLastFocusMethod = 0;
|
|
|
|
var selectFired = false;
|
|
|
|
function selectListener() { selectFired = true; }
|
|
|
|
t19.addEventListener("select", selectListener, false);
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => t19.select(),
|
2009-09-08 15:24:20 +04:00
|
|
|
null, getById("t" + 19), true, "input.select()");
|
2009-07-13 15:55:56 +04:00
|
|
|
t19.removeEventListener("select", selectListener, false);
|
|
|
|
ok(selectFired, "select event fires for input");
|
|
|
|
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
// mouse clicking
|
|
|
|
gLastFocusMethod = fm.FLAG_BYMOUSE;
|
|
|
|
for (idx = kTabbableSteps; idx >= 1; idx--) {
|
|
|
|
// skip the document root and the overflow element
|
|
|
|
if (idx == kChildDocumentRootIndex || idx == kOverflowElementIndex)
|
|
|
|
continue;
|
|
|
|
if ((navigator.platform.indexOf("Mac") == 0) && (idx == kBeforeTabboxIndex + 1))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
var element = getById("t" + idx);
|
|
|
|
// skip area elements, as getBoundingClientRect doesn't return their actual coordinates
|
|
|
|
if (element.localName == "area")
|
|
|
|
continue;
|
|
|
|
|
2010-04-21 18:53:42 +04:00
|
|
|
mouseOnElement(element, getById("t" + idx), true, "mouse on element t" + idx);
|
|
|
|
var expectedWindow = (element.ownerDocument.defaultView == gChildWindow) ? gChildWindow : window;
|
|
|
|
if (element.localName == "listbox" && expectedWindow == window &&
|
|
|
|
navigator.platform.indexOf("Mac") == 0) {
|
|
|
|
// after focusing a listbox on Mac, clear the focus before continuing.
|
|
|
|
setFocusTo(null, window);
|
|
|
|
}
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
}
|
|
|
|
|
2015-07-08 11:10:00 +03:00
|
|
|
ok(t19.selectionStart == t19.selectionEnd, "input focused from mouse selection");
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
|
|
|
|
// mouse clicking on elements that are not tabbable
|
|
|
|
for (idx = 1; idx <= kFocusSteps; idx++) {
|
|
|
|
var element = getById("o" + (idx % 2 ? idx : idx - 1));
|
2010-04-21 18:53:42 +04:00
|
|
|
|
|
|
|
mouseOnElement(element, element, idx % 2,
|
|
|
|
"mouse on non-tabbable element o" + idx);
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// mouse clicking on elements that are not tabbable and have user-focus: none
|
|
|
|
// or are not focusable for other reasons (for instance, being disabled)
|
|
|
|
// These elements will clear the focus when clicked.
|
|
|
|
for (idx = 1; idx <= kNoFocusSteps; idx++) {
|
|
|
|
var element = getById("n" + idx);
|
|
|
|
gLastFocusMethod = idx % 2 ? 0 : fm.FLAG_BYMOUSE;
|
2010-04-21 18:53:42 +04:00
|
|
|
|
|
|
|
mouseOnElement(element, idx % 2 ? null: element, true, "mouse on unfocusable element n" + idx);
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (idx == kOverflowElementIndex) {
|
|
|
|
gLastFocusMethod = fm.FLAG_BYMOUSE;
|
|
|
|
var element = getById("t" + idx);
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => synthesizeMouse(element, 4, 4, { }, element.ownerDocument.defaultView),
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
window, null, true, "mouse on scrollable element");
|
|
|
|
}
|
|
|
|
|
|
|
|
// focus() method
|
|
|
|
gLastFocusMethod = 0;
|
|
|
|
for (idx = kTabbableSteps; idx >= 1; idx--) {
|
|
|
|
if ((navigator.platform.indexOf("Mac") == 0) && (idx == kBeforeTabboxIndex + 1))
|
|
|
|
continue;
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => getById("t" + idx).focus(),
|
2009-09-08 15:24:20 +04:00
|
|
|
null, getById("t" + idx), true, "focus method on element t" + idx);
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
$("t1").focus();
|
|
|
|
ok(gEvents === "", "focusing element that is already focused");
|
|
|
|
|
|
|
|
$("t2").blur();
|
2012-05-17 03:55:08 +04:00
|
|
|
$("t7").blur();
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
ok(gEvents === "", "blurring element that is not focused");
|
2012-05-17 03:55:08 +04:00
|
|
|
is(document.activeElement, $("t1"), "old element still focused after blur() on another element");
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
|
|
|
|
// focus() method on elements that are not tabbable
|
|
|
|
for (idx = 1; idx <= kFocusSteps; idx++) {
|
2009-09-08 15:24:20 +04:00
|
|
|
var expected = getById("o" + (idx % 2 ? idx : idx - 1));
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => getById("o" + idx).focus(),
|
2009-09-08 15:24:20 +04:00
|
|
|
expected.ownerDocument.defaultView,
|
|
|
|
expected, idx % 2, "focus method on non-tabbable element o" + idx);
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// focus() method on elements that are not tabbable and have user-focus: none
|
|
|
|
// or are not focusable for other reasons (for instance, being disabled)
|
|
|
|
for (idx = 1; idx <= kNoFocusSteps; idx++) {
|
2009-09-08 15:24:20 +04:00
|
|
|
var expected = getById("o" + (idx % 2 ? idx : idx - 1));
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => getById("o" + idx).focus(),
|
2009-09-08 15:24:20 +04:00
|
|
|
expected.ownerDocument.defaultView,
|
|
|
|
expected, idx % 2, "focus method on unfocusable element n" + idx);
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// the focus() method on the legend element should focus the legend if it is
|
|
|
|
// focusable, or the first element after the legend if it is not focusable.
|
|
|
|
if (!gPartialTabbing) {
|
2009-08-26 20:19:41 +04:00
|
|
|
gLastFocusMethod = fm.FLAG_BYMOVEFOCUS;
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
var legend = getById("legend");
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => legend.focus(),
|
2009-09-08 15:24:20 +04:00
|
|
|
null, getById("t28"), true, "focus method on unfocusable legend");
|
2009-08-26 20:19:41 +04:00
|
|
|
gLastFocusMethod = 0;
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
legend.tabIndex = "0";
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => legend.focus(),
|
2009-09-08 15:24:20 +04:00
|
|
|
null, getById("legend"), true, "focus method on focusable legend");
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
legend.tabIndex = "-1";
|
|
|
|
}
|
|
|
|
|
|
|
|
var accessKeyDetails = (navigator.platform.indexOf("Mac") >= 0) ?
|
|
|
|
{ ctrlKey : true } : { altKey : true };
|
|
|
|
|
|
|
|
// test accesskeys
|
2013-03-01 04:15:59 +04:00
|
|
|
var keys = ["t26", "t19", "t22", "t29", "t15", "t17", "n6",
|
|
|
|
"t4", "o1", "o9", "n4"];
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
for (var k = 0; k < keys.length; k++) {
|
|
|
|
var key = String.fromCharCode(65 + k);
|
|
|
|
|
2009-08-26 20:19:41 +04:00
|
|
|
// accesskeys D and G are for labels so get redirected
|
|
|
|
gLastFocusMethod = (key == "D" || key == "G") ? fm.FLAG_BYMOVEFOCUS : fm.FLAG_BYKEY;
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
|
|
|
|
// on Windows and Linux, the shift key must be pressed for content area access keys
|
2012-03-16 10:29:15 +04:00
|
|
|
// and on Mac, the alt key must be pressed for content area access keys
|
|
|
|
var isContent = (getById(keys[k]).ownerDocument.defaultView == gChildWindow);
|
|
|
|
if (navigator.platform.indexOf("Mac") == -1) {
|
|
|
|
accessKeyDetails.shiftKey = isContent;
|
|
|
|
} else {
|
|
|
|
accessKeyDetails.altKey = isContent;
|
|
|
|
}
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => synthesizeKey(key, accessKeyDetails),
|
2009-09-08 15:24:20 +04:00
|
|
|
null, getById(keys[k]), true, "accesskey " + key);
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// clicking on the labels
|
2015-07-08 07:46:48 +03:00
|
|
|
gLastFocusMethod = fm.FLAG_BYMOVEFOCUS | fm.FLAG_BYMOUSE;
|
|
|
|
mouseOnElement(getById("ad"), getById("t29"), true, "mouse on html label with content inside");
|
|
|
|
mouseOnElement(getById("ag"), getById("n6"), true, "mouse on html label with for attribute");
|
2009-08-26 20:19:41 +04:00
|
|
|
gLastFocusMethod = 0;
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => synthesizeMouse(getById("aj"), 2, 2, { }),
|
2009-09-08 15:24:20 +04:00
|
|
|
null, getById("o9"), true, "mouse on xul label with content inside");
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => synthesizeMouse(getById("ak"), 2, 2, { }),
|
2013-03-01 04:15:59 +04:00
|
|
|
null, getById("n4"), true, "mouse on xul label with control attribute");
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
|
|
|
|
// test accesskeys that shouldn't work
|
|
|
|
k = "o".charCodeAt(0);
|
|
|
|
while (k++ < "v".charCodeAt(0)) {
|
|
|
|
var key = String.fromCharCode(k);
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => synthesizeKey(key, accessKeyDetails),
|
2013-03-01 04:15:59 +04:00
|
|
|
window, getById("n4"), false, "non accesskey " + key);
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
}
|
|
|
|
gLastFocusMethod = -1;
|
|
|
|
|
|
|
|
// should focus the for element when using the focus method on a label as well
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => getById("ad").focus(),
|
2009-09-08 15:24:20 +04:00
|
|
|
null, getById("t29"), true, "mouse on html label using focus method");
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
|
|
|
|
// make sure that the text is selected when clicking a label associated with an input
|
|
|
|
getById("ag").htmlFor = "t19";
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => synthesizeMouse(getById("ag"), 2, 2, { }, gChildWindow),
|
2009-09-08 15:24:20 +04:00
|
|
|
null, getById("t19"), true, "mouse on html label with for attribute changed");
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
is(t19.selectionStart, 0, "input focused from label, selectionStart");
|
|
|
|
is(t19.selectionEnd, 5, "input focused from label, selectionEnd");
|
|
|
|
|
|
|
|
// switch to another panel in a tabbox and ensure that tabbing moves between
|
|
|
|
// elements on the new panel.
|
|
|
|
$("tabbox").selectedIndex = 1;
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => getById("t" + kBeforeTabboxIndex).focus(),
|
2009-09-08 15:24:20 +04:00
|
|
|
null, getById("t" + kBeforeTabboxIndex), true, "focus method on element before tabbox");
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
|
|
|
|
if (!gPartialTabbing) {
|
2009-09-08 15:24:20 +04:00
|
|
|
expectFocusShift(pressTab, null, getById("tab2"), true, "focus method on tab");
|
|
|
|
expectFocusShift(pressTab, null, getById("htab1"), true, "tab key switch tabpanel 1");
|
|
|
|
expectFocusShift(pressTab, null, getById("htab2"), true, "tab key switch tabpanel 2");
|
|
|
|
expectFocusShift(pressTab, null, getById("t" + (kBeforeTabboxIndex + 4)), true, "tab key switch tabpanel 3");
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
}
|
|
|
|
$("tabbox").selectedIndex = 0;
|
|
|
|
|
|
|
|
// ---- the following checks when the focus changes during a blur or focus event ----
|
|
|
|
|
|
|
|
var o5 = $("o5");
|
|
|
|
var o9 = $("o9");
|
2010-04-21 18:53:42 +04:00
|
|
|
var t3 = $("t3");
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
var t17 = getById("t17");
|
|
|
|
var t19 = getById("t19");
|
2015-09-23 12:39:15 +03:00
|
|
|
var shiftFocusParentDocument = () => o9.focus();
|
|
|
|
var shiftFocusChildDocument = () => t17.focus();
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
|
|
|
|
var trapBlur = function (element, eventListener, blurFunction)
|
|
|
|
{
|
|
|
|
element.focus();
|
|
|
|
gEvents = "";
|
|
|
|
element.addEventListener("blur", eventListener, false);
|
|
|
|
blurFunction();
|
|
|
|
element.removeEventListener("blur", eventListener, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
var functions = [
|
2015-09-23 12:39:15 +03:00
|
|
|
element => element.focus(),
|
|
|
|
element => synthesizeMouse(element, 4, 4, { }, element.ownerDocument.defaultView)
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
];
|
|
|
|
|
|
|
|
// first, check cases where the focus is adjusted during the blur event. Iterate twice,
|
|
|
|
// once with the focus method and then focusing by mouse clicking
|
|
|
|
for (var l = 0; l < 2; l++) {
|
|
|
|
var adjustFocus = functions[l];
|
|
|
|
var mod = (l == 1) ? " with mouse" : "";
|
|
|
|
|
|
|
|
// an attempt is made to switch the focus from one element (o5) to another
|
2010-04-21 18:53:42 +04:00
|
|
|
// element (t3) within the same document, yet the focus is shifted to a
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
// third element (o9) in the same document during the blur event for the
|
|
|
|
// first element.
|
2015-09-23 12:39:15 +03:00
|
|
|
trapBlur(o5, shiftFocusParentDocument, () => adjustFocus(t3));
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
compareEvents("commandupdate: cu blur: o5 commandupdate: cu focus: o9",
|
|
|
|
window, o9, "change focus to sibling during element blur, attempted sibling" + mod);
|
|
|
|
|
|
|
|
// similar, but the third element (t17) is in a child document
|
2015-09-23 12:39:15 +03:00
|
|
|
trapBlur(o9, shiftFocusChildDocument, () => adjustFocus(t3));
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
compareEvents("commandupdate: cu blur: o9 blur: outer-document blur: outer-window " +
|
|
|
|
"focus: child-document focus: child-window commandupdate: cu focus: t17",
|
|
|
|
gChildWindow, t17, "change focus to child document during element blur, attempted sibling" + mod);
|
|
|
|
|
|
|
|
// similar, but an attempt to switch focus within the same document, but the
|
|
|
|
// third element (t17) is in a parent document
|
2015-09-23 12:39:15 +03:00
|
|
|
trapBlur(t17, shiftFocusParentDocument, () => adjustFocus(t19));
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
compareEvents("commandupdate: cu blur: t17 blur: child-document blur: child-window " +
|
|
|
|
"focus: outer-document focus: outer-window commandupdate: cu focus: o9",
|
|
|
|
window, o9, "change focus to parent document during element blur, attempted sibling" + mod);
|
|
|
|
|
|
|
|
// similar, but blur is called instead of switching focus
|
2015-09-23 12:39:15 +03:00
|
|
|
trapBlur(t3, shiftFocusParentDocument, () => t3.blur());
|
2010-04-21 18:53:42 +04:00
|
|
|
compareEvents("commandupdate: cu blur: t3 commandupdate: cu focus: o9",
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
window, o9, "change focus to same document during clear focus" + mod);
|
|
|
|
|
|
|
|
// check when an element in the same document is focused during the
|
|
|
|
// element's blur event, but an attempt was made to focus an element in the
|
|
|
|
// child document. In this case, the focus in the parent document should be
|
|
|
|
// what was set during the blur event, but the actual focus should still
|
|
|
|
// move to the child document.
|
2015-09-23 12:39:15 +03:00
|
|
|
trapBlur(t3, shiftFocusParentDocument, () => adjustFocus(t17));
|
2010-04-21 18:53:42 +04:00
|
|
|
compareEvents("commandupdate: cu blur: t3 commandupdate: cu focus: o9 " +
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
"blur: outer-document blur: outer-window " +
|
|
|
|
"focus: child-document focus: child-window commandupdate: cu focus: t17",
|
|
|
|
gChildWindow, t17, "change focus to sibling during element blur, attempted child" + mod);
|
|
|
|
is(fm.getFocusedElementForWindow(window, false, {}), $("childframe"),
|
|
|
|
"change focus to sibling during element blur, attempted child, focused in parent" + mod);
|
|
|
|
|
|
|
|
// similar, but with a parent
|
2015-09-23 12:39:15 +03:00
|
|
|
trapBlur(t19, shiftFocusChildDocument, () => adjustFocus(t3));
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
compareEvents("commandupdate: cu blur: t19 commandupdate: cu focus: t17 " +
|
|
|
|
"blur: child-document blur: child-window " +
|
2010-04-21 18:53:42 +04:00
|
|
|
"focus: outer-document focus: outer-window commandupdate: cu focus: t3",
|
|
|
|
window, t3, "change focus to sibling during element blur, attempted parent" + mod);
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
is(fm.getFocusedElementForWindow(gChildWindow, false, {}), t17,
|
|
|
|
"change focus to sibling during element blur, attempted child, focused in child" + mod);
|
|
|
|
|
|
|
|
// similar, with a child, but the blur event focuses a child element also
|
2015-09-23 12:39:15 +03:00
|
|
|
trapBlur(t3, shiftFocusChildDocument, () => adjustFocus(t19));
|
2010-04-21 18:53:42 +04:00
|
|
|
compareEvents("commandupdate: cu blur: t3 blur: outer-document blur: outer-window " +
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
"focus: child-document focus: child-window commandupdate: cu focus: t17",
|
|
|
|
gChildWindow, t17, "change focus to child during element blur, attempted child" + mod);
|
|
|
|
|
|
|
|
// similar, with a parent, where the blur event focuses a parent element also
|
2015-09-23 12:39:15 +03:00
|
|
|
trapBlur(t17, shiftFocusParentDocument, () => adjustFocus(t3));
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
compareEvents("commandupdate: cu blur: t17 blur: child-document blur: child-window " +
|
|
|
|
"focus: outer-document focus: outer-window commandupdate: cu focus: o9",
|
|
|
|
window, o9, "change focus to parent during element blur, attempted parent" + mod);
|
|
|
|
}
|
|
|
|
|
|
|
|
var trapFocus = function (element, eventListener)
|
|
|
|
{
|
|
|
|
element.addEventListener("focus", eventListener, false);
|
|
|
|
element.focus();
|
|
|
|
element.removeEventListener("focus", eventListener, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
fm.clearFocus(window);
|
|
|
|
gEvents = "";
|
|
|
|
|
|
|
|
// next, check cases where the focus is adjusted during the focus event
|
|
|
|
|
|
|
|
// switch focus to an element in the same document
|
|
|
|
trapFocus(o5, shiftFocusParentDocument);
|
|
|
|
compareEvents("commandupdate: cu focus: o5 commandupdate: cu blur: o5 commandupdate: cu focus: o9",
|
|
|
|
window, o9, "change focus to sibling during element focus");
|
|
|
|
|
|
|
|
// similar, but the new element (t17) is in a child document
|
|
|
|
trapFocus(o5, shiftFocusChildDocument);
|
|
|
|
compareEvents("commandupdate: cu blur: o9 " +
|
|
|
|
"commandupdate: cu focus: o5 commandupdate: cu blur: o5 " +
|
|
|
|
"blur: outer-document blur: outer-window " +
|
|
|
|
"focus: child-document focus: child-window commandupdate: cu focus: t17",
|
|
|
|
gChildWindow, t17, "change focus to child document during element focus");
|
|
|
|
|
|
|
|
// similar, but the new element (o9) is in a parent document.
|
|
|
|
trapFocus(t19, shiftFocusParentDocument);
|
|
|
|
compareEvents("commandupdate: cu blur: t17 " +
|
|
|
|
"commandupdate: cu focus: t19 commandupdate: cu blur: t19 " +
|
|
|
|
"blur: child-document blur: child-window " +
|
|
|
|
"focus: outer-document focus: outer-window commandupdate: cu focus: o9",
|
|
|
|
window, o9, "change focus to parent document during element focus");
|
|
|
|
|
|
|
|
// clear the focus during the focus event
|
2015-09-23 12:39:15 +03:00
|
|
|
trapFocus(t3, () => fm.clearFocus(window));
|
2010-04-21 18:53:42 +04:00
|
|
|
compareEvents("commandupdate: cu blur: o9 commandupdate: cu focus: t3 commandupdate: cu blur: t3",
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
window, null, "clear focus during focus event");
|
|
|
|
|
|
|
|
if (!gPartialTabbing)
|
|
|
|
doCommandDispatcherTests();
|
|
|
|
|
|
|
|
testMoveFocus();
|
|
|
|
|
2009-08-26 20:19:41 +04:00
|
|
|
doRemoveTests();
|
|
|
|
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
// tests various focus manager apis for null checks
|
|
|
|
var exh = false;
|
|
|
|
try {
|
|
|
|
fm.clearFocus(null);
|
|
|
|
}
|
|
|
|
catch (ex) { exh = true; }
|
|
|
|
is(exh, true, "clearFocus with null window causes exception");
|
|
|
|
|
|
|
|
var exh = false;
|
|
|
|
try {
|
|
|
|
fm.getFocusedElementForWindow(null, false, focusedWindow);
|
|
|
|
}
|
|
|
|
catch (ex) { exh = true; }
|
|
|
|
is(exh, true, "getFocusedElementForWindow with null window causes exception");
|
|
|
|
|
|
|
|
// just make sure that this doesn't crash
|
|
|
|
fm.moveCaretToFocus(null);
|
|
|
|
|
|
|
|
// ---- tests for the FLAG_NOSWITCHFRAME flag
|
|
|
|
getById("o5").focus();
|
2009-08-26 20:19:41 +04:00
|
|
|
gLastFocusMethod = 0;
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
gEvents = "";
|
|
|
|
// focus is being shifted in a child, so the focus should not change
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => fm.setFocus(getById("t20"), fm.FLAG_NOSWITCHFRAME),
|
2009-09-08 15:24:20 +04:00
|
|
|
window, getById("o5"), false, "no switch frame focus to child");
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
setFocusTo("t20", gChildWindow);
|
|
|
|
|
|
|
|
// here, however, focus is being shifted in a parent, which will have to blur
|
|
|
|
// the child, so the focus will always change
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => fm.setFocus(getById("o5"), fm.FLAG_NOSWITCHFRAME),
|
2009-09-08 15:24:20 +04:00
|
|
|
window, getById("o5"), true, "no switch frame focus to parent");
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => fm.setFocus(getById("t1"), fm.FLAG_NOSWITCHFRAME),
|
2009-09-08 15:24:20 +04:00
|
|
|
window, getById("t1"), true, "no switch frame focus to same window");
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
|
|
|
|
// ---- tests for focus and scrolling into view ----
|
|
|
|
var inscroll = getById("inscroll");
|
|
|
|
inscroll.tabIndex = 0;
|
|
|
|
is(inscroll.parentNode.scrollTop, 0, "scroll position before focus");
|
|
|
|
inscroll.focus();
|
|
|
|
ok(inscroll.parentNode.scrollTop > 5, "scroll position after focus");
|
|
|
|
inscroll.parentNode.scrollTop = 0;
|
|
|
|
fm.setFocus(inscroll, fm.FLAG_NOSCROLL);
|
|
|
|
is(inscroll.parentNode.scrollTop, 0, "scroll position after noscroll focus");
|
|
|
|
|
|
|
|
getById("t9").focus();
|
|
|
|
getById("inpopup1").focus();
|
|
|
|
is(fm.focusedElement, getById("t9"), "focus in closed popup");
|
|
|
|
|
2009-08-04 22:03:39 +04:00
|
|
|
// ---- tests to check if tabbing out of a textbox works
|
|
|
|
|
|
|
|
setFocusTo("t1", window);
|
|
|
|
|
|
|
|
var textbox1 = document.createElement("textbox");
|
|
|
|
$("innerbox").appendChild(textbox1);
|
|
|
|
|
|
|
|
var textbox2 = document.createElement("textbox");
|
|
|
|
$("innerbox").appendChild(textbox2);
|
|
|
|
|
2009-08-26 20:19:41 +04:00
|
|
|
gLastFocusMethod = 0;
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => textbox2.focus(),
|
2009-09-08 15:24:20 +04:00
|
|
|
null, textbox2.inputField, true, "focus on textbox");
|
2009-08-26 20:19:41 +04:00
|
|
|
gLastFocusMethod = fm.FLAG_BYKEY;
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => synthesizeKey("VK_TAB", { shiftKey: true }),
|
2009-09-08 15:24:20 +04:00
|
|
|
null, textbox1.inputField, true, "shift+tab on textbox");
|
2009-08-04 22:03:39 +04:00
|
|
|
|
|
|
|
textbox1.tabIndex = 2;
|
|
|
|
textbox2.tabIndex = 2;
|
2009-08-26 20:19:41 +04:00
|
|
|
gLastFocusMethod = 0;
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => textbox2.focus(),
|
2009-09-08 15:24:20 +04:00
|
|
|
null, textbox2.inputField, true, "focus on textbox with tabindex set");
|
2009-08-26 20:19:41 +04:00
|
|
|
gLastFocusMethod = fm.FLAG_BYKEY;
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => synthesizeKey("VK_TAB", { shiftKey: true }),
|
2009-09-08 15:24:20 +04:00
|
|
|
null, textbox1.inputField, true, "shift+tab on textbox with tabindex set");
|
2009-08-04 22:03:39 +04:00
|
|
|
|
2011-01-24 17:50:37 +03:00
|
|
|
// ---- test for bug 618907 which ensures that canceling the mousedown event still focuses the
|
|
|
|
// right frame
|
|
|
|
|
|
|
|
var childContentFrame = document.getElementById("ifa")
|
|
|
|
childContentFrame.style.MozUserFocus = "";
|
|
|
|
|
|
|
|
var frab = childContentFrame.contentDocument.getElementById("fra-b");
|
2015-09-23 12:39:15 +03:00
|
|
|
var mouseDownListener = event => event.preventDefault();
|
2011-01-24 17:50:37 +03:00
|
|
|
frab.addEventListener("mousedown", mouseDownListener, false);
|
|
|
|
|
|
|
|
var childElementToFocus = childContentFrame.contentDocument.getElementById("fra");
|
|
|
|
gLastFocus = childElementToFocus;
|
|
|
|
gLastFocusWindow = childContentFrame.contentWindow;
|
|
|
|
gLastFocus.focus();
|
|
|
|
gEvents = "";
|
|
|
|
|
|
|
|
setFocusTo("t1", window);
|
|
|
|
|
|
|
|
gLastFocusMethod = -1;
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => synthesizeMouse(frab, 5, 5, { }, childContentFrame.contentWindow),
|
2011-01-24 17:50:37 +03:00
|
|
|
null, childElementToFocus, true,
|
|
|
|
"mousedown event canceled - chrome to content");
|
|
|
|
|
|
|
|
frab.removeEventListener("mousedown", mouseDownListener, false);
|
|
|
|
|
|
|
|
var t5 = getById("t5");
|
|
|
|
t5.addEventListener("mousedown", mouseDownListener, false);
|
|
|
|
synthesizeMouse(t5, 10, 10, { })
|
|
|
|
t5.removeEventListener("mousedown", mouseDownListener, false);
|
|
|
|
is(fm.focusedElement, childElementToFocus,
|
|
|
|
"mousedown event cancelled - content to chrome - element");
|
|
|
|
is(fm.focusedWindow, childContentFrame.contentWindow, "mousedown event cancelled - content to chrome - window");
|
|
|
|
|
2009-09-28 18:17:04 +04:00
|
|
|
// ---- test to check that refocusing an element during a blur event doesn't succeed
|
|
|
|
|
|
|
|
var t1 = getById("t1");
|
2015-09-23 12:39:15 +03:00
|
|
|
t1.addEventListener("blur", () => t1.focus(), true);
|
2009-09-28 18:17:04 +04:00
|
|
|
t1.focus();
|
2010-04-21 18:53:42 +04:00
|
|
|
var t3 = getById("t3");
|
|
|
|
synthesizeMouse(t3, 2, 2, { });
|
|
|
|
is(fm.focusedElement, t3, "focus during blur");
|
2009-09-28 18:17:04 +04:00
|
|
|
|
2009-08-04 22:03:39 +04:00
|
|
|
setFocusTo("t9", window);
|
2009-08-26 20:19:41 +04:00
|
|
|
gLastFocusMethod = -1;
|
2009-09-18 21:02:44 +04:00
|
|
|
window.openDialog("focus_window2.xul", "_blank", "chrome", otherWindowFocused);
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
function doCommandDispatcherTests()
|
|
|
|
{
|
|
|
|
var t19 = getById("t19");
|
|
|
|
t19.focus();
|
|
|
|
gLastFocusWindow = gChildWindow;
|
|
|
|
gLastFocus = t19;
|
|
|
|
gEvents = "";
|
|
|
|
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => document.commandDispatcher.focusedElement = getById("o9"),
|
2009-09-08 15:24:20 +04:00
|
|
|
null, getById("o9"), true, "command dispatcher set focusedElement");
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => document.commandDispatcher.advanceFocus(),
|
2009-09-08 15:24:20 +04:00
|
|
|
null, getById("o13"), true, "command dispatcher advanceFocus");
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => document.commandDispatcher.rewindFocus(),
|
2009-09-08 15:24:20 +04:00
|
|
|
null, getById("o9"), true, "command dispatcher rewindFocus");
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => document.commandDispatcher.focusedElement = null,
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
null, null, true, "command dispatcher set focusedElement to null");
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => document.commandDispatcher.focusedWindow = gChildWindow,
|
2009-09-08 15:24:20 +04:00
|
|
|
null, getById("t19"), true, "command dispatcher set focusedElement to null");
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => document.commandDispatcher.focusedElement = null,
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
gChildWindow, null, true, "command dispatcher set focusedElement to null in child");
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => document.commandDispatcher.advanceFocusIntoSubtree(getById("t19")),
|
2009-09-08 15:24:20 +04:00
|
|
|
null, getById("t20"), true, "command dispatcher advanceFocusIntoSubtree child");
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => document.commandDispatcher.advanceFocusIntoSubtree(null),
|
2009-09-08 15:24:20 +04:00
|
|
|
null, getById("t21"), true, "command dispatcher advanceFocusIntoSubtree null child");
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => document.commandDispatcher.advanceFocusIntoSubtree(getById("o9").parentNode),
|
2009-09-08 15:24:20 +04:00
|
|
|
null, getById("o9"), true, "command dispatcher advanceFocusIntoSubtree parent");
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
function doRemoveTests()
|
|
|
|
{
|
|
|
|
// next, some tests which remove elements
|
|
|
|
var t19 = getById("t19");
|
|
|
|
t19.focus();
|
|
|
|
t19.parentNode.removeChild(t19);
|
|
|
|
|
|
|
|
is(fm.focusedElement, null, "removed element focusedElement");
|
|
|
|
is(fm.focusedWindow, gChildWindow, "removed element focusedWindow");
|
|
|
|
is(gChildWindow.document.hasFocus(), true, "removed element hasFocus");
|
|
|
|
is(gChildWindow.document.activeElement, getById("inner-document"), "removed element activeElement");
|
|
|
|
|
|
|
|
getById("t15").focus();
|
|
|
|
var abs = getById("abs");
|
|
|
|
abs.parentNode.removeChild(abs);
|
|
|
|
|
|
|
|
is(fm.focusedElement, null, "removed ancestor focusedElement");
|
|
|
|
is(fm.focusedWindow, gChildWindow, "removed ancestor focusedWindow");
|
|
|
|
is(gChildWindow.document.hasFocus(), true, "removed ancestor hasFocus");
|
|
|
|
is(gChildWindow.document.activeElement, getById("inner-document"), "removed ancestor activeElement");
|
|
|
|
}
|
|
|
|
|
|
|
|
// tests for the FocusManager moveFocus method
|
|
|
|
function testMoveFocus()
|
|
|
|
{
|
|
|
|
setFocusTo("t6", window);
|
|
|
|
|
|
|
|
// moving focus while an element is already focused
|
|
|
|
var newFocus;
|
2009-08-26 20:19:41 +04:00
|
|
|
gLastFocusMethod = fm.FLAG_BYMOVEFOCUS;
|
2009-09-08 15:24:20 +04:00
|
|
|
var expectedFirst = getById(gPartialTabbing ? "t3" : "t1");
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => newFocus = fm.moveFocus(null, null, fm.MOVEFOCUS_FIRST, 0),
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
window, expectedFirst, true, "moveFocus to first null window null content");
|
|
|
|
is(newFocus, fm.focusedElement, "moveFocus to first null window null content return value");
|
|
|
|
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => newFocus = fm.moveFocus(null, null, fm.MOVEFOCUS_LAST, 0),
|
2009-09-08 15:24:20 +04:00
|
|
|
window, getById("last"), true, "moveFocus to last null window null content");
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
is(newFocus, fm.focusedElement, "moveFocus to last null window null content return value");
|
|
|
|
|
2009-08-26 20:19:41 +04:00
|
|
|
gLastFocusMethod = 0;
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
newFocus = fm.moveFocus(null, null, fm.MOVEFOCUS_ROOT, 0);
|
|
|
|
is(newFocus, null, "moveFocus to root null window null content return value");
|
|
|
|
is(fm.focusedWindow, window, "moveFocus to root null window null content focusedWindow");
|
|
|
|
is(fm.focusedElement, null, "moveFocus to root null window null content focusedElement");
|
|
|
|
|
|
|
|
// moving focus while no element is focused
|
|
|
|
fm.clearFocus(window);
|
|
|
|
gEvents = "";
|
|
|
|
gLastFocus = null;
|
2009-08-26 20:19:41 +04:00
|
|
|
gLastFocusMethod = fm.FLAG_BYMOVEFOCUS;
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => newFocus = fm.moveFocus(null, null, fm.MOVEFOCUS_FIRST, 0),
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
window, expectedFirst, true, "moveFocus to first null window null content no focus");
|
|
|
|
is(newFocus, fm.focusedElement, "moveFocus to first null window null content no focus return value");
|
|
|
|
fm.clearFocus(window);
|
|
|
|
gEvents = "";
|
|
|
|
gLastFocus = null;
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => newFocus = fm.moveFocus(null, null, fm.MOVEFOCUS_LAST, 0),
|
2009-09-08 15:24:20 +04:00
|
|
|
window, getById("last"), true, "moveFocus to last null window null content no focus");
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
is(newFocus, fm.focusedElement, "moveFocus to last null window null content no focus return value");
|
|
|
|
fm.clearFocus(window);
|
|
|
|
gEvents = "";
|
2009-08-26 20:19:41 +04:00
|
|
|
gLastFocusMethod = 0;
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
newFocus = fm.moveFocus(null, null, fm.MOVEFOCUS_ROOT, 0);
|
|
|
|
is(newFocus, null, "moveFocus to root null window null content no focus return value");
|
|
|
|
is(fm.focusedWindow, window, "moveFocus to root null window null content no focus focusedWindow");
|
|
|
|
is(fm.focusedElement, null, "moveFocus to root null window null content no focus focusedElement");
|
|
|
|
|
|
|
|
// moving focus from a specified element
|
|
|
|
setFocusTo("t6", window);
|
2009-08-26 20:19:41 +04:00
|
|
|
gLastFocusMethod = fm.FLAG_BYMOVEFOCUS;
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => newFocus = fm.moveFocus(null, getById("specialroot"), fm.MOVEFOCUS_FIRST, 0),
|
2009-09-08 15:24:20 +04:00
|
|
|
window, getById("t3"), true, "moveFocus to first null window with content");
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
// XXXndeakin P3 this doesn't work
|
2015-09-23 12:39:15 +03:00
|
|
|
// expectFocusShift(() => newFocus = fm.moveFocus(null, getById("specialroot"), fm.MOVEFOCUS_LAST, 0),
|
2009-09-08 15:24:20 +04:00
|
|
|
// window, getById("o3"), true, "moveFocus to last null window with content");
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
|
|
|
|
// move focus to first in child window
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => newFocus = fm.moveFocus(gChildWindow, null, fm.MOVEFOCUS_FIRST, 0),
|
2009-09-08 15:24:20 +04:00
|
|
|
gChildWindow, getById("t" + (kChildDocumentRootIndex + 1)), true,
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
"moveFocus to first child window null content");
|
|
|
|
is(newFocus, getById("t" + (kChildDocumentRootIndex + 1)),
|
|
|
|
"moveFocus to first child window null content return value");
|
|
|
|
|
|
|
|
// move focus to last in child window
|
|
|
|
setFocusTo("t6", window);
|
2009-09-08 15:24:20 +04:00
|
|
|
var expectedLast = getById(gPartialTabbing ? "t30" : "t" + (kBeforeTabboxIndex - 1));
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => newFocus = fm.moveFocus(gChildWindow, null, fm.MOVEFOCUS_LAST, 0),
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
gChildWindow, expectedLast, true,
|
|
|
|
"moveFocus to last child window null content");
|
|
|
|
is(newFocus, getById(expectedLast),
|
|
|
|
"moveFocus to last child window null content return value");
|
|
|
|
|
|
|
|
// move focus to root in child window
|
|
|
|
setFocusTo("t6", window);
|
|
|
|
var childroot = getById("t" + kChildDocumentRootIndex);
|
2009-08-26 20:19:41 +04:00
|
|
|
gLastFocusMethod = 0;
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
newFocus = fm.moveFocus(gChildWindow, null, fm.MOVEFOCUS_ROOT, 0),
|
|
|
|
is(newFocus, childroot, "moveFocus to root child window null content return value");
|
|
|
|
is(fm.focusedWindow, gChildWindow, "moveFocus to root child window null content focusedWindow");
|
|
|
|
is(fm.focusedElement, childroot, "moveFocus to root child window null content focusedElement");
|
|
|
|
|
|
|
|
// MOVEFOCUS_CARET tests
|
|
|
|
getById("t20").focus();
|
|
|
|
gEvents = "";
|
|
|
|
|
|
|
|
var selection = gChildWindow.getSelection();
|
|
|
|
selection.removeAllRanges();
|
|
|
|
|
2010-02-23 21:16:19 +03:00
|
|
|
newFocus = fm.moveFocus(gChildWindow, null, fm.MOVEFOCUS_CARET, 0);
|
|
|
|
is(newFocus, null, "move caret when at document root");
|
|
|
|
is(fm.focusedElement, null, "move caret when at document root");
|
|
|
|
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
var node = getById("t16").firstChild;
|
|
|
|
var range = gChildWindow.document.createRange();
|
|
|
|
range.setStart(node, 3);
|
|
|
|
range.setEnd(node, 3);
|
|
|
|
selection.addRange(range);
|
|
|
|
|
|
|
|
newFocus = fm.moveFocus(gChildWindow, null, fm.MOVEFOCUS_CARET, 0);
|
|
|
|
is(newFocus, null, "move caret to non-link return value");
|
|
|
|
is(fm.focusedElement, null, "move caret to non-link");
|
|
|
|
|
2010-02-23 21:16:19 +03:00
|
|
|
var t25 = getById("t25");
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
var node = t25.firstChild;
|
|
|
|
range.setStart(node, 1);
|
|
|
|
range.setEnd(node, 1);
|
2010-02-23 21:16:19 +03:00
|
|
|
newFocus = fm.moveFocus(gChildWindow, null, fm.MOVEFOCUS_CARET, 0);
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
|
|
|
|
is(newFocus, t25, "move caret to link return value");
|
|
|
|
is(fm.focusedElement, t25, "move caret to link focusedElement");
|
|
|
|
|
|
|
|
// enable caret browsing temporarily to test caret movement
|
|
|
|
var prefs = Components.classes["@mozilla.org/preferences-service;1"].
|
|
|
|
getService(Components.interfaces.nsIPrefBranch);
|
|
|
|
prefs.setBoolPref("accessibility.browsewithcaret", true);
|
|
|
|
|
|
|
|
synthesizeKey("VK_LEFT", { }, gChildWindow);
|
|
|
|
synthesizeKey("VK_LEFT", { }, gChildWindow);
|
|
|
|
is(fm.focusedElement, null, "move caret away from link");
|
|
|
|
|
|
|
|
synthesizeKey("VK_LEFT", { }, gChildWindow);
|
|
|
|
is(fm.focusedElement, getById("t24"), "move caret away onto link");
|
|
|
|
|
|
|
|
prefs.setBoolPref("accessibility.browsewithcaret", false);
|
2009-08-26 20:19:41 +04:00
|
|
|
|
2009-11-20 15:09:33 +03:00
|
|
|
// cases where focus in on a content node with no frame
|
|
|
|
|
|
|
|
if (!gPartialTabbing) {
|
|
|
|
getById("t24").blur();
|
|
|
|
gEvents = "";
|
|
|
|
gLastFocus = null;
|
|
|
|
gLastFocusWindow = gChildWindow;
|
|
|
|
gLastFocusMethod = fm.FLAG_BYKEY;
|
|
|
|
|
|
|
|
selection.selectAllChildren(getById("hiddenspan"));
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => synthesizeKey("VK_TAB", { }),
|
2009-11-20 15:09:33 +03:00
|
|
|
gChildWindow, getById("t26"), true, "tab with selection on hidden content");
|
|
|
|
|
|
|
|
setFocusTo($("o15"), window);
|
|
|
|
$("o15").hidden = true;
|
|
|
|
document.documentElement.getBoundingClientRect(); // flush after hiding
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => synthesizeKey("VK_TAB", { }),
|
2009-11-20 15:09:33 +03:00
|
|
|
window, $("o17"), true, "tab with focus on hidden content");
|
|
|
|
|
|
|
|
$("o17").hidden = true;
|
|
|
|
document.documentElement.getBoundingClientRect();
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => synthesizeKey("VK_TAB", { shiftKey: true }),
|
2009-11-20 15:09:33 +03:00
|
|
|
window, $("o13"), true, "shift+tab with focus on hidden content");
|
|
|
|
}
|
|
|
|
|
|
|
|
// cases with selection in an <input>
|
|
|
|
|
2009-08-26 20:19:41 +04:00
|
|
|
var t19 = getById("t19");
|
|
|
|
t19.setSelectionRange(0, 0);
|
|
|
|
setFocusTo("t18", gChildWindow);
|
|
|
|
|
|
|
|
gLastFocusMethod = fm.FLAG_BYMOVEFOCUS;
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => newFocus = fm.moveFocus(null, null, fm.MOVEFOCUS_FORWARD, 0),
|
2009-08-26 20:19:41 +04:00
|
|
|
gChildWindow, t19, true, "moveFocus to next textbox");
|
|
|
|
is(t19.selectionStart, 0, "input focused after moveFocus selectionStart");
|
|
|
|
is(t19.selectionEnd, 5, "input focused after moveFocus selectionEnd");
|
|
|
|
|
|
|
|
t19.setSelectionRange(0, 0);
|
|
|
|
setFocusTo("t18", gChildWindow);
|
|
|
|
gLastFocusMethod = fm.FLAG_BYKEY;
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => newFocus = fm.moveFocus(null, null, fm.MOVEFOCUS_FORWARD, fm.FLAG_BYKEY),
|
2009-08-26 20:19:41 +04:00
|
|
|
gChildWindow, t19, true, "moveFocus to next textbox by key");
|
|
|
|
is(t19.selectionStart, 0, "input focused after moveFocus by key selectionStart");
|
|
|
|
is(t19.selectionEnd, 5, "input focused after moveFocus by key selectionEnd");
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
function otherWindowFocused(otherWindow)
|
|
|
|
{
|
|
|
|
var expectedElement = getById("t9");
|
|
|
|
|
|
|
|
is(fm.activeWindow, otherWindow, "other activeWindow");
|
|
|
|
is(fm.focusedWindow, otherWindow, "other focusedWindow");
|
|
|
|
is(window.document.hasFocus(), false, "when lowered document hasFocus");
|
|
|
|
var focusedWindow = {};
|
|
|
|
is(fm.getFocusedElementForWindow(window, false, focusedWindow),
|
|
|
|
expectedElement, "when lowered getFocusedElementForWindow");
|
|
|
|
is(focusedWindow.value, window, "when lowered getFocusedElementForWindow frame");
|
|
|
|
is(document.activeElement.id, expectedElement.id, "when lowered activeElement");
|
|
|
|
is(window.document.commandDispatcher.focusedWindow, window, " commandDispatcher in other window focusedWindow");
|
|
|
|
is(window.document.commandDispatcher.focusedElement, expectedElement, " commandDispatcher in other window focusedElement");
|
|
|
|
|
2009-10-29 22:11:00 +03:00
|
|
|
compareEvents("deactivate: outer-document-window blur: t9 blur: outer-document blur: outer-window",
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
otherWindow, null, "other window opened");
|
|
|
|
|
|
|
|
otherWindow.document.getElementById("other").focus();
|
|
|
|
|
|
|
|
for (var idx = kTabbableSteps; idx >= 1; idx--) {
|
|
|
|
expectedElement = getById("t" + idx);
|
|
|
|
if (!expectedElement) // skip elements that were removed in doRemoveTests()
|
|
|
|
continue;
|
|
|
|
if ((navigator.platform.indexOf("Mac") == 0) && (idx == kBeforeTabboxIndex + 1))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
expectedElement.focus();
|
|
|
|
|
|
|
|
is(fm.focusedElement.id, "other", "when lowered focusedElement t" + idx);
|
|
|
|
is(fm.focusedWindow, otherWindow, "when lowered focusedWindow t" + idx);
|
|
|
|
|
|
|
|
var checkWindow = expectedElement.ownerDocument.defaultView;
|
|
|
|
is(fm.getFocusedElementForWindow(checkWindow, false, {}).id, expectedElement.id,
|
|
|
|
"when lowered getFocusedElementForWindow t" + idx);
|
|
|
|
is(checkWindow.document.activeElement.id, expectedElement.id, "when lowered activeElement t" + idx);
|
|
|
|
if (checkWindow != window) {
|
|
|
|
is(fm.getFocusedElementForWindow(window, false, {}), $("childframe"),
|
|
|
|
"when lowered parent getFocusedElementForWindow t" + idx);
|
|
|
|
is(document.activeElement.id, "childframe",
|
|
|
|
"when lowered parent activeElement t" + idx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gEvents = gEvents.replace(/commandupdate: cu\s?/g, "");
|
|
|
|
is(gEvents, "", "when lowered no events fired");
|
|
|
|
|
|
|
|
var other = otherWindow.document.getElementById("other");
|
|
|
|
other.focus();
|
|
|
|
is(fm.focusedElement, other, "focus method in second window");
|
|
|
|
|
|
|
|
otherWindow.close();
|
|
|
|
|
|
|
|
getById("n2").focus();
|
2013-09-06 17:47:36 +04:00
|
|
|
|
|
|
|
// next, check modal dialogs
|
2013-09-19 22:26:58 +04:00
|
|
|
// XXXndeakin Bug 621399 - the modal dialog test as well as later tests sometime fail
|
|
|
|
// on Windows 8 so just end the test here.
|
2013-09-06 17:47:36 +04:00
|
|
|
if (navigator.userAgent.indexOf("Windows NT 6.2") >= 0) {
|
2013-09-19 22:26:58 +04:00
|
|
|
done();
|
2013-09-06 17:47:36 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
window.openDialog("focus_window2.xul", "_blank", "chrome,modal", modalWindowOpened);
|
|
|
|
}
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
function modalWindowOpened(modalWindow)
|
|
|
|
{
|
|
|
|
var elem = modalWindow.document.getElementById("other");
|
|
|
|
if (gPartialTabbing)
|
2010-04-21 18:53:42 +04:00
|
|
|
elem.focus();
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
else
|
2010-06-15 09:05:37 +04:00
|
|
|
synthesizeKey("VK_TAB", { }, modalWindow);
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
is(fm.activeWindow, modalWindow, "modal activeWindow");
|
|
|
|
is(fm.focusedElement, elem, "modal focusedElement");
|
|
|
|
|
|
|
|
modalWindow.close();
|
2009-09-18 21:02:44 +04:00
|
|
|
SimpleTest.waitForFocus(modalWindowClosed);
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
function modalWindowClosed()
|
|
|
|
{
|
|
|
|
is(fm.activeWindow, window, "modal window closed activeWindow");
|
|
|
|
is(fm.focusedElement, getById("n2"), "modal window closed focusedElement");
|
|
|
|
|
2009-09-18 21:02:44 +04:00
|
|
|
window.open("focus_frameset.html", "_blank", "width=400,height=400,toolbar=no");
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
function framesetWindowLoaded(framesetWindow)
|
|
|
|
{
|
|
|
|
gLastFocus = null;
|
2009-10-29 22:11:00 +03:00
|
|
|
gLastFocusWindow = framesetWindow;
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
gEvents = "";
|
|
|
|
|
|
|
|
is(fm.activeWindow, getTopWindow(framesetWindow), "frameset window active");
|
|
|
|
gOldExpectedWindow = getTopWindow(framesetWindow);
|
|
|
|
|
|
|
|
gMoveToFocusFrame = true;
|
|
|
|
for (var idx = 1; idx <= 8; idx++) {
|
|
|
|
gNewExpectedWindow = framesetWindow.frames[(idx - 1) >> 1];
|
|
|
|
if (idx % 2)
|
|
|
|
initEvents(gNewExpectedWindow);
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => synthesizeKey("VK_TAB", { }, framesetWindow),
|
2009-09-08 15:24:20 +04:00
|
|
|
gNewExpectedWindow, getById("f" + idx), true, "frameset tab key f" + idx);
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
gMoveToFocusFrame = false;
|
|
|
|
gOldExpectedWindow = gNewExpectedWindow;
|
|
|
|
}
|
|
|
|
|
|
|
|
gNewExpectedWindow = framesetWindow.frames[0];
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => synthesizeKey("VK_TAB", { }, framesetWindow),
|
2009-09-08 15:24:20 +04:00
|
|
|
gNewExpectedWindow, getById("f1"), true, "frameset tab key wrap to start");
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
gOldExpectedWindow = gNewExpectedWindow;
|
|
|
|
gNewExpectedWindow = framesetWindow.frames[3];
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => synthesizeKey("VK_TAB", { shiftKey: true }, framesetWindow),
|
2009-09-08 15:24:20 +04:00
|
|
|
gNewExpectedWindow, getById("f8"), true, "frameset shift tab key wrap to end");
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
|
|
|
|
for (idx = 7; idx >= 1; idx--) {
|
|
|
|
gOldExpectedWindow = gNewExpectedWindow;
|
|
|
|
gNewExpectedWindow = framesetWindow.frames[(idx - 1) >> 1];
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => synthesizeKey("VK_TAB", { shiftKey: true }, framesetWindow),
|
2009-09-08 15:24:20 +04:00
|
|
|
gNewExpectedWindow, getById("f" + idx), true, "frameset shift tab key f" + idx);
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// document shifting
|
|
|
|
// XXXndeakin P3 ctrl+tab doesn't seem to be testable currently for some reason
|
|
|
|
gNewExpectedWindow = framesetWindow.frames[1];
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => synthesizeKey("VK_F6", { ctrlKey: true }, framesetWindow),
|
2009-09-08 15:24:20 +04:00
|
|
|
gNewExpectedWindow, getById("f3"), true, "switch document forward with f6");
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
gOldExpectedWindow = gNewExpectedWindow;
|
|
|
|
gNewExpectedWindow = framesetWindow.frames[2];
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => synthesizeKey("VK_F6", { }, framesetWindow),
|
2009-09-08 15:24:20 +04:00
|
|
|
gNewExpectedWindow, getById("f5"), true, "switch document forward with ctrl+tab");
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
gOldExpectedWindow = gNewExpectedWindow;
|
|
|
|
gNewExpectedWindow = framesetWindow.frames[3];
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => synthesizeKey("VK_F6", { ctrlKey: true }, framesetWindow),
|
2009-09-08 15:24:20 +04:00
|
|
|
gNewExpectedWindow, getById("f7"), true, "switch document forward with ctrl+f6");
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
gOldExpectedWindow = gNewExpectedWindow;
|
|
|
|
gNewExpectedWindow = framesetWindow.frames[0];
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => synthesizeKey("VK_F6", { ctrlKey: true }, framesetWindow),
|
2009-09-08 15:24:20 +04:00
|
|
|
gNewExpectedWindow, getById("f1"), true, "switch document forward and wrap");
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
|
|
|
|
// going backwards by document and wrapping doesn't currently work, but didn't work
|
|
|
|
// before the focus reworking either
|
|
|
|
|
|
|
|
/*
|
|
|
|
gOldExpectedWindow = gNewExpectedWindow;
|
|
|
|
gNewExpectedWindow = framesetWindow.frames[3];
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => synthesizeKey("VK_F6", { ctrlKey: true, shiftKey: true }, framesetWindow),
|
2009-09-08 15:24:20 +04:00
|
|
|
gNewExpectedWindow, getById("f7"), true, "switch document backward and wrap");
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
fm.moveFocus(framesetWindow.frames[3], null, fm.MOVEFOCUS_ROOT, 0);
|
|
|
|
gEvents = "";
|
|
|
|
|
|
|
|
gOldExpectedWindow = gNewExpectedWindow;
|
|
|
|
gNewExpectedWindow = framesetWindow.frames[2];
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => synthesizeKey("VK_F6", { ctrlKey: true, shiftKey: true }, framesetWindow),
|
2009-09-08 15:24:20 +04:00
|
|
|
gNewExpectedWindow, getById("f5"), true, "switch document backward with f6");
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
gOldExpectedWindow = gNewExpectedWindow;
|
|
|
|
gNewExpectedWindow = framesetWindow.frames[1];
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => synthesizeKey("VK_F6", { ctrlKey: true, shiftKey: true }, framesetWindow),
|
2009-09-08 15:24:20 +04:00
|
|
|
gNewExpectedWindow, getById("f3"), true, "switch document backward with ctrl+tab");
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
gOldExpectedWindow = gNewExpectedWindow;
|
|
|
|
gNewExpectedWindow = framesetWindow.frames[0];
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => synthesizeKey("VK_F6", { ctrlKey: true, shiftKey: true }, framesetWindow),
|
2009-09-08 15:24:20 +04:00
|
|
|
gNewExpectedWindow, getById("f1"), true, "switch document backward with ctrl+f6");
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
|
2009-09-18 21:02:44 +04:00
|
|
|
// skip the window switching tests for now on Linux, as raising and lowering
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
// a window is asynchronous there
|
|
|
|
if (navigator.platform.indexOf("Linux") == -1) {
|
|
|
|
window.openDialog("focus_window2.xul", "_blank", "chrome", switchWindowTest, framesetWindow);
|
|
|
|
}
|
|
|
|
else {
|
2009-06-25 22:09:41 +04:00
|
|
|
gOldExpectedWindow = null;
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
gNewExpectedWindow = null;
|
|
|
|
framesetWindow.close();
|
2009-09-18 21:02:44 +04:00
|
|
|
SimpleTest.waitForFocus(doWindowNoRootTest);
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// test switching between two windows
|
|
|
|
function switchWindowTest(otherWindow, framesetWindow)
|
|
|
|
{
|
|
|
|
initEvents(otherWindow);
|
|
|
|
var otherElement = otherWindow.document.getElementById("other");
|
|
|
|
otherElement.focus();
|
|
|
|
|
|
|
|
framesetWindow.frames[1].document.getElementById("f4").focus();
|
|
|
|
|
|
|
|
is(fm.focusedElement, otherElement, "focus after inactive window focus");
|
|
|
|
|
|
|
|
gLastFocus = otherElement;
|
2009-10-29 22:11:00 +03:00
|
|
|
gLastFocusWindow = otherWindow;
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
gEvents = "";
|
|
|
|
gOldExpectedWindow = otherWindow;
|
|
|
|
gNewExpectedWindow = framesetWindow.frames[1];
|
|
|
|
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => gNewExpectedWindow.focus(),
|
2009-09-08 15:24:20 +04:00
|
|
|
gNewExpectedWindow, getById("f4"), true, "switch to frame in another window");
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
is(fm.getFocusedElementForWindow(otherWindow, false, {}).id, "other", "inactive window has focused element");
|
|
|
|
|
|
|
|
gOldExpectedWindow = framesetWindow.frames[1];
|
|
|
|
gNewExpectedWindow = otherWindow;
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => otherWindow.focus(),
|
2009-09-08 15:24:20 +04:00
|
|
|
gNewExpectedWindow, getById("other"), true, "switch to another window");
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
|
|
|
|
var exh = false;
|
|
|
|
try {
|
|
|
|
fm.activeWindow = framesetWindow.frames[0];
|
|
|
|
}
|
|
|
|
catch (ex) { exh = true; }
|
|
|
|
is(exh, true, "activeWindow set to non top-level window");
|
|
|
|
|
|
|
|
exh = false;
|
|
|
|
try {
|
|
|
|
fm.activeWindow = null;
|
|
|
|
}
|
|
|
|
catch (ex) { exh = true; }
|
|
|
|
is(exh, true, "activeWindow set to null");
|
|
|
|
is(fm.activeWindow, otherWindow, "window not changed when activeWindow set to null");
|
|
|
|
|
2009-09-21 21:39:44 +04:00
|
|
|
var topWindow = getTopWindow(framesetWindow);
|
|
|
|
|
|
|
|
ok(topWindow.document.commandDispatcher.getControllerForCommand("cmd_copy"),
|
|
|
|
"getControllerForCommand for focused window set");
|
|
|
|
ok(otherWindow.document.commandDispatcher.getControllerForCommand("cmd_copy"),
|
|
|
|
"getControllerForCommand for non-focused window set");
|
|
|
|
ok(topWindow.document.commandDispatcher.getControllerForCommand("cmd_copy") !=
|
|
|
|
otherWindow.document.commandDispatcher.getControllerForCommand("cmd_copy"),
|
|
|
|
"getControllerForCommand for two windows different");
|
|
|
|
ok(topWindow.document.commandDispatcher.getControllers() !=
|
|
|
|
otherWindow.document.commandDispatcher.getControllers(),
|
|
|
|
"getControllers for two windows different");
|
|
|
|
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
gOldExpectedWindow = otherWindow;
|
|
|
|
gNewExpectedWindow = framesetWindow.frames[1];
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => fm.activeWindow = topWindow,
|
2009-09-08 15:24:20 +04:00
|
|
|
gNewExpectedWindow, getById("f4"), true, "switch to frame activeWindow");
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
|
|
|
|
fm.clearFocus(otherWindow);
|
|
|
|
gOldExpectedWindow = gNewExpectedWindow;
|
|
|
|
gNewExpectedWindow = otherWindow;
|
2015-09-23 12:39:15 +03:00
|
|
|
expectFocusShift(() => fm.setFocus(otherElement, fm.FLAG_RAISE),
|
2009-09-08 15:24:20 +04:00
|
|
|
gNewExpectedWindow, getById("other"), true, "switch to window with raise");
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
|
|
|
|
getTopWindow(framesetWindow).document.commandDispatcher.focusedWindow = gOldExpectedWindow;
|
|
|
|
is(fm.activeWindow, gNewExpectedWindow, "setting commandDispatcher focusedWindow doesn't raise window");
|
|
|
|
|
2009-10-01 21:53:10 +04:00
|
|
|
fm.moveFocus(otherWindow, null, fm.MOVEFOCUS_FORWARD, 0);
|
|
|
|
var otherTextbox = otherWindow.document.getElementById("other-textbox");
|
|
|
|
otherTextbox.setSelectionRange(2, 3);
|
|
|
|
fm.activeWindow = topWindow;
|
|
|
|
fm.activeWindow = otherWindow;
|
|
|
|
is(otherTextbox.selectionStart, 2, "selectionStart after textbox focus and window raise");
|
|
|
|
is(otherTextbox.selectionEnd, 3, "selectionEnd after textbox focus and window raise");
|
|
|
|
is(fm.getLastFocusMethod(null), fm.FLAG_BYMOVEFOCUS, "last focus method after textbox focus and window raise");
|
|
|
|
|
|
|
|
fm.clearFocus(otherWindow);
|
|
|
|
|
|
|
|
// test to ensure that a synthetic event works
|
|
|
|
var synevent = document.createEvent("Event");
|
|
|
|
synevent.initEvent("focus", false, false);
|
|
|
|
otherTextbox.inputField.dispatchEvent(synevent);
|
|
|
|
is(synevent.type, "focus", "event.type after synthetic focus event");
|
|
|
|
is(synevent.target, otherTextbox, "event.target after synthetic focus event");
|
|
|
|
is(fm.focusedElement, null, "focusedElement after synthetic focus event");
|
|
|
|
is(otherWindow.document.activeElement, otherWindow.document.documentElement,
|
|
|
|
"document.activeElement after synthetic focus event");
|
|
|
|
|
|
|
|
// check accessing a focus event after the event has finishing firing
|
|
|
|
function continueTest(event) {
|
|
|
|
is(event.type, "focus", "event.type after accessing focus event in timeout");
|
|
|
|
is(event.target, otherTextbox, "event.target after accessing focus event in timeout");
|
|
|
|
|
|
|
|
gOldExpectedWindow = null;
|
|
|
|
gNewExpectedWindow = null;
|
|
|
|
otherWindow.close();
|
|
|
|
framesetWindow.close();
|
|
|
|
|
|
|
|
SimpleTest.waitForFocus(doWindowNoRootTest);
|
|
|
|
}
|
|
|
|
|
|
|
|
function textboxFocused(event) {
|
|
|
|
otherTextbox.removeEventListener("focus", textboxFocused, true);
|
|
|
|
setTimeout(continueTest, 0, event);
|
|
|
|
}
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
|
2009-10-01 21:53:10 +04:00
|
|
|
otherTextbox.addEventListener("focus", textboxFocused, true);
|
|
|
|
otherTextbox.focus();
|
2009-06-24 21:12:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// open a window with no root element
|
|
|
|
var noRootWindow = null;
|
|
|
|
function doWindowNoRootTest()
|
|
|
|
{
|
|
|
|
var data = "data:application/vnd.mozilla.xul+xml," + unescape(
|
|
|
|
"<window onfocus='dostuff()' xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul'" +
|
|
|
|
" style='-moz-user-focus: normal;'>" +
|
|
|
|
"<script>function dostuff() { setTimeout(function() { " +
|
|
|
|
"document.documentElement.focus(); document.removeChild(document.documentElement);" +
|
|
|
|
"window.opener.focus(); }, 100); }</script></window>");
|
|
|
|
|
2009-09-18 21:02:44 +04:00
|
|
|
addEventListener("focus", doFrameSwitchingTests, true);
|
2009-06-24 21:12:37 +04:00
|
|
|
noRootWindow = window.open(data, "_blank", "chrome,width=100,height=100");
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// these tests check when focus is moved between a tree of frames to ensure
|
|
|
|
// that the focus is in the right place at each event step.
|
|
|
|
function doFrameSwitchingTests()
|
|
|
|
{
|
2009-09-18 21:02:44 +04:00
|
|
|
removeEventListener("focus", doFrameSwitchingTests, true);
|
2009-06-24 21:12:37 +04:00
|
|
|
noRootWindow.close();
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
|
|
|
|
var framea = document.getElementById("ifa");
|
|
|
|
var frameb = document.getElementById("ifb");
|
|
|
|
framea.style.MozUserFocus = "";
|
|
|
|
frameb.style.MozUserFocus = "";
|
|
|
|
|
|
|
|
window.removeEventListener("focus", eventOccured, true);
|
|
|
|
window.removeEventListener("blur", eventOccured, true);
|
|
|
|
|
|
|
|
var inputa = framea.contentDocument.body.firstChild;
|
|
|
|
inputa.focus();
|
|
|
|
|
|
|
|
addFrameSwitchingListeners(framea);
|
|
|
|
addFrameSwitchingListeners(frameb);
|
|
|
|
var framec = framea.contentDocument.body.lastChild;
|
|
|
|
addFrameSwitchingListeners(framec);
|
|
|
|
|
|
|
|
var framed = framec.contentDocument.body.lastChild;
|
|
|
|
addFrameSwitchingListeners(framed);
|
|
|
|
|
|
|
|
var inputc = framec.contentDocument.body.firstChild;
|
|
|
|
|
|
|
|
var expectedMainWindowFocus = framea;
|
|
|
|
|
|
|
|
// An element in the immediate parent frame is focused. Focus an element in
|
|
|
|
// the child. The child should be focused and the parent's current focus should
|
|
|
|
// be the child iframe.
|
|
|
|
gEventMatched = true;
|
|
|
|
is(fm.getFocusedElementForWindow(window, false, {}), expectedMainWindowFocus,
|
|
|
|
"parent of framea has iframe focused");
|
|
|
|
gExpectedEvents = [[inputa, "blur", null, framea.contentWindow, window, framea],
|
|
|
|
[framea.contentDocument, "blur", null, null, window, framea],
|
|
|
|
[framea.contentWindow, "blur", null, null, window, framea],
|
|
|
|
[framec.contentDocument, "focus", null, framec.contentWindow, window, framea],
|
|
|
|
[framec.contentWindow, "focus", null, framec.contentWindow, window, framea],
|
|
|
|
[inputc, "focus", inputc, framec.contentWindow, window, framea]];
|
|
|
|
inputc.focus();
|
|
|
|
ok(gEventMatched && gExpectedEvents.length == 0, "frame switch from parent input to child input" + gExpectedEvents);
|
|
|
|
|
|
|
|
// An element in a child is focused. Focus an element in the immediate
|
|
|
|
// parent.
|
|
|
|
gEventMatched = true;
|
|
|
|
gExpectedEvents = [[inputc, "blur", null, framec.contentWindow, window, framea],
|
|
|
|
[framec.contentDocument, "blur", null, null, window, framea],
|
|
|
|
[framec.contentWindow, "blur", null, null, window, framea],
|
|
|
|
[framea.contentDocument, "focus", null, framea.contentWindow, window, framea],
|
|
|
|
[framea.contentWindow, "focus", null, framea.contentWindow, window, framea],
|
|
|
|
[inputa, "focus", inputa, framea.contentWindow, window, framea]];
|
|
|
|
inputa.focus();
|
|
|
|
ok(gEventMatched && gExpectedEvents.length == 0, "frame switch from child input to parent input");
|
|
|
|
|
|
|
|
// An element in a frame is focused. Focus an element in a sibling frame.
|
|
|
|
// The common ancestor of the two frames should have its focused node
|
|
|
|
// cleared after the element is blurred.
|
|
|
|
var inputb = frameb.contentDocument.body.firstChild;
|
|
|
|
|
|
|
|
gEventMatched = true;
|
|
|
|
gExpectedEvents = [[inputa, "blur", null, framea.contentWindow, window, framea],
|
|
|
|
[framea.contentDocument, "blur", null, null, window, null],
|
|
|
|
[framea.contentWindow, "blur", null, null, window, null],
|
|
|
|
[frameb.contentDocument, "focus", null, frameb.contentWindow, window, frameb],
|
|
|
|
[frameb.contentWindow, "focus", null, frameb.contentWindow, window, frameb],
|
|
|
|
[inputb, "focus", inputb, frameb.contentWindow, window, frameb]];
|
|
|
|
inputb.focus();
|
|
|
|
ok(gEventMatched && gExpectedEvents.length == 0, "frame switch from input to sibling frame");
|
|
|
|
is(fm.getFocusedElementForWindow(framea.contentWindow, false, {}), inputa,
|
|
|
|
"blurred frame still has input as focus");
|
|
|
|
|
|
|
|
// focus a descendant in a sibling
|
|
|
|
var inputd = framed.contentDocument.body.firstChild;
|
|
|
|
gEventMatched = true;
|
|
|
|
gExpectedEvents = [[inputb, "blur", null, frameb.contentWindow, window, frameb],
|
|
|
|
[frameb.contentDocument, "blur", null, null, window, null],
|
|
|
|
[frameb.contentWindow, "blur", null, null, window, null],
|
|
|
|
[framed.contentDocument, "focus", null, framed.contentWindow, window, framea],
|
|
|
|
[framed.contentWindow, "focus", null, framed.contentWindow, window, framea],
|
|
|
|
[inputd, "focus", inputd, framed.contentWindow, window, framea]];
|
|
|
|
inputd.focus();
|
|
|
|
ok(gEventMatched && gExpectedEvents.length == 0, "frame switch from input to sibling descendant");
|
|
|
|
is(fm.getFocusedElementForWindow(framea.contentWindow, false, {}), framec,
|
|
|
|
"sibling parent focus has shifted to frame");
|
|
|
|
|
|
|
|
// focus an ancestor
|
|
|
|
gEventMatched = true;
|
|
|
|
gExpectedEvents = [[inputd, "blur", null, framed.contentWindow, window, framea],
|
|
|
|
[framed.contentDocument, "blur", null, null, window, framea],
|
|
|
|
[framed.contentWindow, "blur", null, null, window, framea],
|
|
|
|
[framea.contentDocument, "focus", null, framea.contentWindow, window, framea],
|
|
|
|
[framea.contentWindow, "focus", null, framea.contentWindow, window, framea],
|
|
|
|
[inputa, "focus", inputa, framea.contentWindow, window, framea]];
|
|
|
|
inputa.focus();
|
|
|
|
ok(gEventMatched && gExpectedEvents.length == 0, "frame switch from child input to ancestor");
|
|
|
|
|
|
|
|
// focus a descendant
|
|
|
|
gEventMatched = true;
|
|
|
|
gExpectedEvents = [[inputa, "blur", null, framea.contentWindow, window, framea],
|
|
|
|
[framea.contentDocument, "blur", null, null, window, framea],
|
|
|
|
[framea.contentWindow, "blur", null, null, window, framea],
|
|
|
|
[framed.contentDocument, "focus", null, framed.contentWindow, window, framea],
|
|
|
|
[framed.contentWindow, "focus", null, framed.contentWindow, window, framea],
|
|
|
|
[inputd, "focus", inputd, framed.contentWindow, window, framea]];
|
|
|
|
inputd.focus();
|
|
|
|
ok(gEventMatched && gExpectedEvents.length == 0, "frame switch from child input to ancestor");
|
|
|
|
is(fm.getFocusedElementForWindow(framea.contentWindow, false, {}), framec,
|
|
|
|
"parent focus has shifted to frame");
|
|
|
|
|
|
|
|
// focus a sibling frame by setting focusedWindow
|
|
|
|
gEventMatched = true;
|
|
|
|
gExpectedEvents = [[inputd, "blur", null, framed.contentWindow, window, framea],
|
|
|
|
[framed.contentDocument, "blur", null, null, window, null],
|
|
|
|
[framed.contentWindow, "blur", null, null, window, null],
|
|
|
|
[frameb.contentDocument, "focus", null, frameb.contentWindow, window, frameb],
|
|
|
|
[frameb.contentWindow, "focus", null, frameb.contentWindow, window, frameb],
|
|
|
|
[inputb, "focus", inputb, frameb.contentWindow, window, frameb]];
|
|
|
|
fm.focusedWindow = frameb.contentWindow;
|
|
|
|
ok(gEventMatched && gExpectedEvents.length == 0, "frame switch using focusedWindow");
|
|
|
|
|
|
|
|
// clear the focus in an unfocused frame
|
|
|
|
gEventMatched = true;
|
|
|
|
gExpectedEvents = [];
|
|
|
|
fm.clearFocus(framec.contentWindow);
|
|
|
|
ok(gEventMatched && gExpectedEvents.length == 0, "clearFocus in unfocused frame");
|
|
|
|
|
|
|
|
// focus a sibling frame by setting focusedWindow when no element is focused in that frame
|
|
|
|
gEventMatched = true;
|
|
|
|
gExpectedEvents = [[inputb, "blur", null, frameb.contentWindow, window, frameb],
|
|
|
|
[frameb.contentDocument, "blur", null, null, window, null],
|
|
|
|
[frameb.contentWindow, "blur", null, null, window, null],
|
|
|
|
[framec.contentDocument, "focus", null, framec.contentWindow, window, framea],
|
|
|
|
[framec.contentWindow, "focus", null, framec.contentWindow, window, framea]];
|
|
|
|
fm.focusedWindow = framec.contentWindow;
|
|
|
|
ok(gEventMatched && gExpectedEvents.length == 0, "frame switch using focusedWindow with no element focused");
|
|
|
|
is(fm.getFocusedElementForWindow(framea.contentWindow, false, {}), framec,
|
|
|
|
"parent focus has shifted to frame using focusedWindow");
|
|
|
|
|
|
|
|
// focus the parent frame by setting focusedWindow. This should have no effect.
|
|
|
|
gEventMatched = true;
|
|
|
|
gExpectedEvents = [];
|
|
|
|
fm.focusedWindow = framea.contentWindow;
|
|
|
|
ok(gEventMatched && gExpectedEvents.length == 0, "frame switch to parent using focusedWindow");
|
|
|
|
|
|
|
|
// clear the focus in the parent frame
|
|
|
|
gEventMatched = true;
|
|
|
|
gExpectedEvents = [[framec.contentDocument, "blur", null, null, window, framea],
|
|
|
|
[framec.contentWindow, "blur", null, null, window, framea],
|
|
|
|
[framea.contentDocument, "focus", null, framea.contentWindow, window, framea],
|
|
|
|
[framea.contentWindow, "focus", null, framea.contentWindow, window, framea]];
|
|
|
|
fm.clearFocus(framea.contentWindow);
|
|
|
|
ok(gEventMatched && gExpectedEvents.length == 0, "clearFocus in parent frame");
|
|
|
|
|
|
|
|
// clear the focus in an unfocused child frame
|
|
|
|
gEventMatched = true;
|
|
|
|
gExpectedEvents = [];
|
|
|
|
fm.clearFocus(framed.contentWindow);
|
|
|
|
ok(gEventMatched && gExpectedEvents.length == 0, "clearFocus in unfocused child frame");
|
|
|
|
|
|
|
|
var exh = false;
|
|
|
|
try {
|
|
|
|
fm.focusedWindow = null;
|
|
|
|
}
|
|
|
|
catch (ex) { exh = true; }
|
|
|
|
is(exh, true, "focusedWindow set to null");
|
|
|
|
is(fm.focusedWindow, framea.contentWindow, "window not changed when focusedWindow set to null");
|
|
|
|
|
|
|
|
doFrameHistoryTests()
|
|
|
|
}
|
|
|
|
|
|
|
|
function doFrameHistoryTests()
|
|
|
|
{
|
|
|
|
var t20 = getById("t20");
|
|
|
|
t20.focus();
|
|
|
|
|
|
|
|
gChildWindow.addEventListener("focus",
|
|
|
|
function(event) {
|
|
|
|
if (event.target == t20) {
|
|
|
|
is(fm.focusedElement, t20, "focus restored after history back"); done();
|
|
|
|
}
|
|
|
|
}, true);
|
|
|
|
|
|
|
|
// make sure that loading a new page and then going back maintains the focus
|
2014-04-08 22:48:37 +04:00
|
|
|
gChildWindow.location = "data:text/html,<script>window.onload=function() {setTimeout(function () {SpecialPowers.wrap(window).back();}, 0);}</script>";
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
function addFrameSwitchingListeners(frame)
|
|
|
|
{
|
|
|
|
frame.contentWindow.addEventListener("focus", frameSwitchingEventOccured, false);
|
|
|
|
frame.contentWindow.addEventListener("blur", frameSwitchingEventOccured, false);
|
|
|
|
frame.contentDocument.addEventListener("focus", frameSwitchingEventOccured, false);
|
|
|
|
frame.contentDocument.addEventListener("blur", frameSwitchingEventOccured, false);
|
|
|
|
|
|
|
|
var node = frame.contentDocument.body.firstChild;
|
|
|
|
node.addEventListener("focus", frameSwitchingEventOccured, false);
|
|
|
|
node.addEventListener("blur", frameSwitchingEventOccured, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
function frameSwitchingEventOccured(event)
|
|
|
|
{
|
|
|
|
if (!gExpectedEvents.length) {
|
|
|
|
gEventMatched = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
var events = gExpectedEvents.shift();
|
|
|
|
is(event.target, events[0], "event target");
|
|
|
|
is(event.type, events[1], "event type");
|
|
|
|
is(fm.focusedElement, events[2], "focused element");
|
|
|
|
is(fm.focusedWindow, events[3], "focused frame");
|
|
|
|
if (events[4])
|
|
|
|
is(fm.getFocusedElementForWindow(events[4], false, {}), events[5], "focused element in frame");
|
|
|
|
|
|
|
|
if (gEventMatched && event.target == events[0] && event.type == events[1] &&
|
|
|
|
fm.focusedElement == events[2] && fm.focusedWindow == events[3]) {
|
|
|
|
if (!events[4] || fm.getFocusedElementForWindow(events[4], false, {}) == events[5])
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} catch (ex) { ok(ex, "exception"); }
|
|
|
|
|
|
|
|
gEventMatched = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
2009-09-18 21:02:44 +04:00
|
|
|
SimpleTest.waitForFocus(startTest);
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
|
|
|
|
]]>
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<commandset id="cu"
|
|
|
|
commandupdater="true"
|
|
|
|
events="focus"
|
|
|
|
oncommandupdate="eventOccured(event)"/>
|
|
|
|
|
|
|
|
<!--
|
|
|
|
The elements with ids starting with t are focusable and in the taborder.
|
|
|
|
The elements with ids starting with o are:
|
|
|
|
odd numbered ids - focusable but not part of the tab order
|
2013-03-01 04:15:59 +04:00
|
|
|
even numbered ids - not focusable with -moz-user-focus: ignore or disabled
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
The elements with ids starting with n are:
|
|
|
|
odd numbered ids - not focusable with -moz-user-focus: none
|
|
|
|
even numbered ids - focusable but not part of the tab order
|
|
|
|
-->
|
|
|
|
<vbox id="buttonbox">
|
2009-08-04 22:03:39 +04:00
|
|
|
<hbox id="innerbox">
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
<button id="t4" accesskey="h" label="no tabindex"/>
|
|
|
|
<button id="o1" accesskey="i" label="tabindex = -1" tabindex="-1"/>
|
|
|
|
<listbox id="t5" label="tabindex = 0" tabindex="0" rows="1">
|
|
|
|
<listitem/>
|
|
|
|
</listbox>
|
|
|
|
<button id="t1" label="tabindex = 2" tabindex="2"/>
|
|
|
|
</hbox>
|
|
|
|
<hbox>
|
|
|
|
<button id="o2" accesskey="o" style="-moz-user-focus: ignore;" label="no tabindex"/>
|
|
|
|
<button id="o4" style="-moz-user-focus: ignore;" label="tabindex = -1" tabindex="-1"/>
|
|
|
|
<button id="t6" style="-moz-user-focus: ignore;" label="tabindex = 0" tabindex="0"/>
|
|
|
|
<button id="t2" style="-moz-user-focus: ignore;" label="tabindex = 2" tabindex="2"/>
|
|
|
|
</hbox>
|
|
|
|
<hbox id="specialroot">
|
|
|
|
<button id="t7" style="-moz-user-focus: normal;" label="no tabindex"/>
|
|
|
|
<button id="o3" style="-moz-user-focus: normal;" label="tabindex = -1" tabindex="-1"/>
|
|
|
|
<button id="t8" style="-moz-user-focus: normal;" label="tabindex = 0" tabindex="0"/>
|
|
|
|
<listbox id="t3" style="-moz-user-focus: normal;" label="tabindex = 2" tabindex="2" rows="1">
|
|
|
|
<listitem/>
|
|
|
|
</listbox>
|
|
|
|
</hbox>
|
|
|
|
<hbox>
|
|
|
|
<button accesskey="p" style="display: none;"/> <button accesskey="q" style="visibility: collapse;"/>
|
|
|
|
<button style="display: none;" tabindex="2"/> <button style="visibility: collapse;" tabindex="2"/>
|
|
|
|
</hbox>
|
|
|
|
<hbox>
|
2013-03-01 04:15:59 +04:00
|
|
|
<button id="o20" accesskey="s" label="no tabindex" disabled="true"/>
|
|
|
|
<button id="o22" label="tabindex = -1" tabindex="-1" disabled="true"/>
|
|
|
|
<button id="o24" label="tabindex = 0" tabindex="0" disabled="true"/>
|
|
|
|
<button id="o26" label="tabindex = 2" tabindex="2" disabled="true"/>
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
</hbox>
|
|
|
|
</vbox>
|
|
|
|
<vbox>
|
|
|
|
<hbox>
|
|
|
|
<dropmarker id="o6" value="no tabindex"/>
|
|
|
|
<dropmarker id="o8" value="tabindex = -1" tabindex="-1"/>
|
|
|
|
<dropmarker id="o10" value="tabindex = 0" tabindex="0"/>
|
|
|
|
<dropmarker id="o12" value="tabindex = 2" tabindex="2"/>
|
|
|
|
<dropmarker id="t9" accesskey="r" style="-moz-user-focus: normal;" value="no tabindex" />
|
|
|
|
<dropmarker id="t10" style="-moz-user-focus: normal;" value="tabindex = -1" tabindex="-1" />
|
|
|
|
<dropmarker id="t11" style="-moz-user-focus: normal;" value="tabindex = 0" tabindex="0" />
|
|
|
|
<dropmarker id="t12" style="-moz-user-focus: normal;" value="tabindex = 2" tabindex="2" />
|
|
|
|
<dropmarker id="o14" style="-moz-user-focus: ignore;" value="no tabindex"/>
|
|
|
|
<dropmarker id="o16" style="-moz-user-focus: ignore;" value="tabindex = -1" tabindex="-1"/>
|
|
|
|
<dropmarker id="n1" style="-moz-user-focus: none;" value="tabindex = 0" tabindex="0"/>
|
|
|
|
<dropmarker id="n3" style="-moz-user-focus: none;" value="tabindex = 2" tabindex="2"/>
|
|
|
|
</hbox>
|
|
|
|
</vbox>
|
|
|
|
<browser id="childframe" type="content" src="child_focus_frame.html" width="300" height="195"/>
|
|
|
|
<button id="t34"/>
|
|
|
|
<tabbox id="tabbox">
|
|
|
|
<tabs><tab id="t35" label="One"/><tab id="tab2" label="Two"/></tabs>
|
|
|
|
<tabpanels>
|
|
|
|
<tabpanel>
|
|
|
|
<checkbox id="t36"/>
|
|
|
|
<button id="t37"/>
|
|
|
|
</tabpanel>
|
|
|
|
<tabpanel>
|
|
|
|
<checkbox id="htab1"/>
|
|
|
|
<button id="nohtab2" tabindex="7"/>
|
|
|
|
<checkbox id="htab2" tabindex="0"/>
|
|
|
|
</tabpanel>
|
|
|
|
</tabpanels>
|
|
|
|
</tabbox>
|
|
|
|
<hbox>
|
|
|
|
<panel>
|
|
|
|
<button id="inpopup1" label="One"/>
|
|
|
|
<textbox label="Two"/>
|
|
|
|
</panel>
|
|
|
|
<description label="o" accesskey="v"/>
|
|
|
|
<button id="t38"/>
|
|
|
|
<!-- The 't' element tests end here so it doesn't matter that these elements are tabbable -->
|
|
|
|
<label id="aj" value="j" accesskey="j" control="o9"/>
|
2013-03-01 04:15:59 +04:00
|
|
|
<label id="ak" accesskey="k" control="n4">k</label>
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
<checkbox id="o5"/><checkbox id="o7"/><hbox><checkbox id="o9"/></hbox>
|
2013-03-01 04:15:59 +04:00
|
|
|
<checkbox id="o13"/><checkbox id="o15"/><checkbox id="o17"/><checkbox id="o19"/><checkbox id="o21"/><checkbox id="o23"/><checkbox id="o25"/>
|
|
|
|
<checkbox id="n2"/><checkbox id="n4"/>
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
<listbox id="last" width="20" rows="1"/>
|
|
|
|
|
2011-01-24 17:50:37 +03:00
|
|
|
<iframe id="ifa" width="40" height="60" style="-moz-user-focus: ignore;" type="content"
|
|
|
|
src="data:text/html,<input id=fra size='2'><input id='fra-b' size='2'>
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
<iframe src='data:text/html,<input id=frc><iframe src="data:text/html,<input id=frd>"></iframe>'></iframe>"/>
|
|
|
|
<iframe id="ifb" width="20" height="20" style="-moz-user-focus: ignore;"
|
|
|
|
src="data:text/html,<input id=frd></iframe>"/>
|
|
|
|
|
|
|
|
</hbox>
|
|
|
|
</window>
|