No Bug - Backout bug 375008 (6c59b73c8c4b) and re-enable test_focus.xul. r=distress

This commit is contained in:
Mounir Lamouri 2013-02-27 15:53:41 +00:00
parent b00bf5543d
commit ba864d4737
5 changed files with 3 additions and 148 deletions

View File

@ -3131,38 +3131,8 @@ nsEventStateManager::PostHandleEvent(nsPresContext* aPresContext,
if (mCurrentTarget) {
mCurrentTarget->GetContentForEvent(aEvent, getter_AddRefs(newFocus));
const nsStyleUserInterface* ui = mCurrentTarget->StyleUserInterface();
activeContent = mCurrentTarget->GetContent();
// In some cases, we do not want to even blur the current focused
// element. Those cases are:
// 1. -moz-user-focus CSS property is set to 'ignore';
// 2. Element with NS_EVENT_STATE_DISABLED
// (aka :disabled pseudo-class for HTML element);
// 3. XUL control element has the disabled property set to 'true'.
//
// We can't use nsIFrame::IsFocusable() because we want to blur when
// we click on a visibility: none element.
// We can't use nsIContent::IsFocusable() because we want to blur when
// we click on a non-focusable element like a <div>.
// We have to use |aEvent->target| to not make sure we do not check an
// anonymous node of the targeted element.
suppressBlur = (ui->mUserFocus == NS_STYLE_USER_FOCUS_IGNORE);
if (!suppressBlur) {
nsCOMPtr<Element> element = do_QueryInterface(aEvent->target);
suppressBlur = element &&
element->State().HasState(NS_EVENT_STATE_DISABLED);
}
if (!suppressBlur) {
nsCOMPtr<nsIDOMXULControlElement> xulControl =
do_QueryInterface(aEvent->target);
if (xulControl) {
bool disabled;
xulControl->GetDisabled(&disabled);
suppressBlur = disabled;
}
}
activeContent = mCurrentTarget->GetContent();
}
nsIFrame* currFrame = mCurrentTarget;

View File

@ -101,7 +101,6 @@ MOCHITEST_FILES = \
test_dragstart.html \
test_bug812744.html \
test_addEventListenerExtraArg.html \
test_focus_disabled.html \
$(NULL)
MOCHITEST_CHROME_FILES = \

View File

@ -1,116 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=375008
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 375008</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=375008">Mozilla Bug 375008</a>
<p id="display"></p>
<div id="content">
<div>
<input id='witness'>
</div>
<div id='not-focusable'>
<!-- Disabled elements -->
<button hidden disabled>foo</button>
<input hidden disabled>
<fieldset hidden disabled>foo</fieldset>
<select hidden disabled><option>foo</option></select>
<textarea hidden disabled></textarea>
<optgroup hidden disabled><option>foo</option></optgroup>
<option hidden disabled>foo</option>
</div>
<div id='focusable'>
<button hidden>foo</button>
<input hidden>
<select hidden><option>foo</option></select>
<textarea hidden></textarea>
<!-- Those elements are not focusable by default. -->
<fieldset tabindex=1 hidden>foo</fieldset>
<optgroup tabindex=1 hidden><option>foo</option></optgroup>
<option tabindex=1 hidden>foo</option>
</div>
<!-- Hidden elements, they have a frame but focus will go through them. -->
<div id='hidden' style='visibility: hidden;'>
<button hidden>foo</button>
<input hidden>
<fieldset hidden>foo</fieldset>
<select hidden><option>foo</option></select>
<textarea hidden></textarea>
<optgroup hidden><option>foo</option></optgroup>
<option hidden>foo</option>
</div>
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 375008 **/
/*
* This test is divided in three parts:
* - cases where focus isn't doable but blur should not happen;
* - cases where focus is doable;
* - cases where focus isn't doable but blur should still happen.
*/
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
var witness = document.getElementById('witness');
witness.focus();
var notFocusableElements = document.getElementById('not-focusable').children;
for (var i=0; i<notFocusableElements.length; ++i) {
var element = notFocusableElements[i];
element.hidden = false;
synthesizeMouseAtCenter(element, {});
is(document.activeElement, witness,
"[" + element.tagName + "] witness should still be focused");
// Cleanup.
witness.focus();
}
var focusableElements = document.getElementById('focusable').children;
for (var i=0; i<focusableElements.length; ++i) {
var element = focusableElements[i];
element.hidden = false;
synthesizeMouseAtCenter(element, {});
is(document.activeElement, element, "focus should have moved to " + element);
// Cleanup.
element.hidden = true;
witness.focus();
}
var hiddenElements = document.getElementById('hidden').children;
for (var i=0; i<hiddenElements.length; ++i) {
var element = hiddenElements[i];
element.hidden = false;
synthesizeMouseAtCenter(element, {});
is(document.activeElement, document.body,
"focus should have moved to the body");
// Cleanup.
element.hidden = true;
witness.focus();
}
SimpleTest.finish();
});
</script>
</pre>
</body>
</html>

View File

@ -21,6 +21,7 @@ MOCHITEST_CHROME_FILES = \
focus_frameset.html \
child_focus_frame.html \
test_focus_switchbinding.xul \
test_focus.xul \
window_focus.xul \
test_focused_link_scroll.xul \
test_geolocation.xul \

View File

@ -362,6 +362,7 @@ select:disabled:disabled /* Need the pseudo-class twice to have the specificity
be at least the same as select[size][multiple] above */
{
-moz-user-input: disabled;
-moz-user-focus: ignore;
color: GrayText;
background-color: ThreeDFace;
cursor: inherit;