зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 3 changesets (bug 1712724) for causing mochitests without e10s failures in test_focus.xhtml
CLOSED TREE Backed out changeset 61d8ca98120b (bug 1712724) Backed out changeset 46b1d60b6b6b (bug 1712724) Backed out changeset 36504d508b34 (bug 1712724)
This commit is contained in:
Родитель
2cc5f863ce
Коммит
1df3b4b4d2
|
@ -478,7 +478,7 @@ nsFocusManager::GetLastFocusMethod(mozIDOMWindowProxy* aWindow,
|
|||
|
||||
*aLastFocusMethod = window ? window->GetFocusMethod() : 0;
|
||||
|
||||
NS_ASSERTION((*aLastFocusMethod & METHOD_MASK) == *aLastFocusMethod,
|
||||
NS_ASSERTION((*aLastFocusMethod & FOCUSMETHOD_MASK) == *aLastFocusMethod,
|
||||
"invalid focus method");
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -527,7 +527,7 @@ nsFocusManager::MoveFocus(mozIDOMWindowProxy* aWindow, Element* aStartElement,
|
|||
// the other focus methods is already set, or we're just moving to the root
|
||||
// or caret position.
|
||||
if (aType != MOVEFOCUS_ROOT && aType != MOVEFOCUS_CARET &&
|
||||
(aFlags & METHOD_MASK) == 0) {
|
||||
(aFlags & FOCUSMETHOD_MASK) == 0) {
|
||||
aFlags |= FLAG_BYMOVEFOCUS;
|
||||
}
|
||||
|
||||
|
@ -1062,7 +1062,7 @@ void nsFocusManager::WindowHidden(mozIDOMWindowProxy* aWindow,
|
|||
if (presShell) {
|
||||
SendFocusOrBlurEvent(eBlur, presShell,
|
||||
oldFocusedElement->GetComposedDoc(),
|
||||
oldFocusedElement, false);
|
||||
oldFocusedElement, 1, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1746,7 +1746,7 @@ void nsFocusManager::SetFocusInner(Element* aNewContent, int32_t aFlags,
|
|||
|
||||
// set the focus node and method as needed
|
||||
uint32_t focusMethod =
|
||||
aFocusChanged ? aFlags & METHODANDRING_MASK
|
||||
aFocusChanged ? aFlags & FOCUSMETHODANDRING_MASK
|
||||
: newWindow->GetFocusMethod() |
|
||||
(aFlags & (FLAG_SHOWRING | FLAG_NOSHOWRING));
|
||||
newWindow->SetFocusedElement(elementToFocus, focusMethod);
|
||||
|
@ -2346,7 +2346,7 @@ bool nsFocusManager::BlurImpl(BrowsingContext* aBrowsingContextToClear,
|
|||
}
|
||||
|
||||
SendFocusOrBlurEvent(eBlur, presShell, element->GetComposedDoc(), element,
|
||||
false, false, aElementToFocus);
|
||||
1, false, false, aElementToFocus);
|
||||
}
|
||||
|
||||
// if we are leaving the document or the window was lowered, make the caret
|
||||
|
@ -2387,13 +2387,16 @@ bool nsFocusManager::BlurImpl(BrowsingContext* aBrowsingContextToClear,
|
|||
SetFocusedWindowInternal(nullptr, aActionId);
|
||||
mFocusedElement = nullptr;
|
||||
|
||||
// pass 1 for the focus method when calling SendFocusOrBlurEvent just so
|
||||
// that the check is made for suppressed documents. Check to ensure that
|
||||
// the document isn't null in case someone closed it during the blur above
|
||||
Document* doc = window->GetExtantDoc();
|
||||
if (doc) {
|
||||
SendFocusOrBlurEvent(eBlur, presShell, doc, ToSupports(doc), false);
|
||||
SendFocusOrBlurEvent(eBlur, presShell, doc, ToSupports(doc), 1, false);
|
||||
}
|
||||
if (!GetFocusedBrowsingContext()) {
|
||||
SendFocusOrBlurEvent(eBlur, presShell, doc,
|
||||
window->GetCurrentInnerWindow(), false);
|
||||
window->GetCurrentInnerWindow(), 1, false);
|
||||
}
|
||||
|
||||
// check if a different window was focused
|
||||
|
@ -2483,7 +2486,7 @@ void nsFocusManager::Focus(
|
|||
// Otherwise, just get the current focus method and use that. This ensures
|
||||
// that the method is set during the document and window focus events.
|
||||
uint32_t focusMethod = aFocusChanged
|
||||
? aFlags & METHODANDRING_MASK
|
||||
? aFlags & FOCUSMETHODANDRING_MASK
|
||||
: aWindow->GetFocusMethod() |
|
||||
(aFlags & (FLAG_SHOWRING | FLAG_NOSHOWRING));
|
||||
|
||||
|
@ -2558,13 +2561,13 @@ void nsFocusManager::Focus(
|
|||
}
|
||||
if (doc && !focusInOtherContentProcess) {
|
||||
SendFocusOrBlurEvent(eFocus, presShell, doc, ToSupports(doc),
|
||||
aWindowRaised);
|
||||
aFlags & FOCUSMETHOD_MASK, aWindowRaised);
|
||||
}
|
||||
if (GetFocusedBrowsingContext() == aWindow->GetBrowsingContext() &&
|
||||
!mFocusedElement && !focusInOtherContentProcess) {
|
||||
SendFocusOrBlurEvent(eFocus, presShell, doc,
|
||||
aWindow->GetCurrentInnerWindow(),
|
||||
aWindowRaised);
|
||||
aFlags & FOCUSMETHOD_MASK, aWindowRaised);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2613,7 +2616,7 @@ void nsFocusManager::Focus(
|
|||
if (!focusInOtherContentProcess) {
|
||||
SendFocusOrBlurEvent(
|
||||
eFocus, presShell, aElement->GetComposedDoc(), aElement,
|
||||
aWindowRaised, isRefocus,
|
||||
aFlags & FOCUSMETHOD_MASK, aWindowRaised, isRefocus,
|
||||
aBlurredElementInfo ? aBlurredElementInfo->mElement.get()
|
||||
: nullptr);
|
||||
}
|
||||
|
@ -2744,7 +2747,7 @@ void nsFocusManager::FireFocusInOrOutEvent(
|
|||
|
||||
void nsFocusManager::SendFocusOrBlurEvent(
|
||||
EventMessage aEventMessage, PresShell* aPresShell, Document* aDocument,
|
||||
nsISupports* aTarget, bool aWindowRaised,
|
||||
nsISupports* aTarget, uint32_t aFocusMethod, bool aWindowRaised,
|
||||
bool aIsRefocus, EventTarget* aRelatedTarget) {
|
||||
NS_ASSERTION(aEventMessage == eFocus || aEventMessage == eBlur,
|
||||
"Wrong event type for SendFocusOrBlurEvent");
|
||||
|
@ -3640,7 +3643,7 @@ nsresult nsFocusManager::DetermineElementToMoveFocus(
|
|||
}
|
||||
|
||||
uint32_t nsFocusManager::ProgrammaticFocusFlags(const FocusOptions& aOptions) {
|
||||
uint32_t flags = FLAG_BYJS;
|
||||
uint32_t flags = 0;
|
||||
if (aOptions.mPreventScroll) {
|
||||
flags |= FLAG_NOSCROLL;
|
||||
}
|
||||
|
|
|
@ -17,6 +17,9 @@
|
|||
#include "mozilla/RefPtr.h"
|
||||
#include "mozilla/StaticPtr.h"
|
||||
|
||||
#define FOCUSMETHOD_MASK 0xF000
|
||||
#define FOCUSMETHODANDRING_MASK 0xF0F000
|
||||
|
||||
#define FOCUSMANAGER_CONTRACTID "@mozilla.org/focus-manager;1"
|
||||
|
||||
class nsIContent;
|
||||
|
@ -471,12 +474,13 @@ class nsFocusManager final : public nsIFocusManager,
|
|||
* event queue if the document is suppressing events.
|
||||
*
|
||||
* aEventMessage should be either eFocus or eBlur.
|
||||
* For blur events, aFocusMethod should normally be non-zero.
|
||||
*
|
||||
* aWindowRaised should only be true if called from WindowRaised.
|
||||
*/
|
||||
void SendFocusOrBlurEvent(
|
||||
mozilla::EventMessage aEventMessage, mozilla::PresShell* aPresShell,
|
||||
Document* aDocument, nsISupports* aTarget,
|
||||
Document* aDocument, nsISupports* aTarget, uint32_t aFocusMethod,
|
||||
bool aWindowRaised, bool aIsRefocus = false,
|
||||
mozilla::dom::EventTarget* aRelatedTarget = nullptr);
|
||||
/**
|
||||
|
|
|
@ -4379,7 +4379,7 @@ void nsGlobalWindowInner::SetFocusedElement(Element* aElement,
|
|||
UpdateCanvasFocus(false, aElement);
|
||||
mFocusedElement = aElement;
|
||||
// TODO: Maybe this should be set on refocus too?
|
||||
mFocusMethod = aFocusMethod & nsIFocusManager::METHOD_MASK;
|
||||
mFocusMethod = aFocusMethod & FOCUSMETHOD_MASK;
|
||||
}
|
||||
|
||||
if (mFocusedElement) {
|
||||
|
@ -4421,9 +4421,7 @@ bool nsGlobalWindowInner::TakeFocus(bool aFocus, uint32_t aFocusMethod) {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (aFocus) {
|
||||
mFocusMethod = aFocusMethod & nsIFocusManager::METHOD_MASK;
|
||||
}
|
||||
if (aFocus) mFocusMethod = aFocusMethod & FOCUSMETHOD_MASK;
|
||||
|
||||
if (mHasFocus != aFocus) {
|
||||
mHasFocus = aFocus;
|
||||
|
|
|
@ -3739,19 +3739,16 @@ nsresult HTMLInputElement::PostHandleEvent(EventChainPostVisitor& aVisitor) {
|
|||
// for text and password fields when the field was focused by the
|
||||
// keyboard or a navigation, the platform allows it, and it wasn't
|
||||
// just because we raised a window.
|
||||
//
|
||||
// While it'd usually make sense, we don't do this for JS callers
|
||||
// because it causes some compat issues, see bug 1712724 for example.
|
||||
nsFocusManager* fm = nsFocusManager::GetFocusManager();
|
||||
if (fm && IsSingleLineTextControl(false) &&
|
||||
!aVisitor.mEvent->AsFocusEvent()->mFromRaise &&
|
||||
SelectTextFieldOnFocus()) {
|
||||
if (Document* document = GetComposedDoc()) {
|
||||
Document* document = GetComposedDoc();
|
||||
if (document) {
|
||||
uint32_t lastFocusMethod;
|
||||
fm->GetLastFocusMethod(document->GetWindow(), &lastFocusMethod);
|
||||
if (lastFocusMethod & (nsIFocusManager::FLAG_BYKEY |
|
||||
nsIFocusManager::FLAG_BYMOVEFOCUS) &&
|
||||
!(lastFocusMethod & nsIFocusManager::FLAG_BYJS)) {
|
||||
nsIFocusManager::FLAG_BYMOVEFOCUS)) {
|
||||
RefPtr<nsPresContext> presContext =
|
||||
GetPresContext(eForComposedDoc);
|
||||
DispatchSelectEvent(presContext);
|
||||
|
|
|
@ -236,18 +236,11 @@ interface nsIFocusManager : nsISupports
|
|||
*/
|
||||
const unsigned long FLAG_BYTOUCH = 0x200000;
|
||||
|
||||
/** Focus is changing due to a JS focus() call or similar operation. */
|
||||
const unsigned long FLAG_BYJS = 0x400000;
|
||||
|
||||
/** Focus is changing due to a long press operation by touch or mouse. */
|
||||
/*
|
||||
* Focus is changing due to a long press operation by touch or mouse.
|
||||
*/
|
||||
const unsigned long FLAG_BYLONGPRESS = 0x800000;
|
||||
|
||||
/** Mask with all the focus methods. */
|
||||
const unsigned long METHOD_MASK = FLAG_BYMOUSE | FLAG_BYKEY | FLAG_BYMOVEFOCUS | FLAG_BYTOUCH | FLAG_BYJS | FLAG_BYLONGPRESS;
|
||||
|
||||
/** Mask with all the focus methods, plus the SHOW / NOSHOWRING flags. */
|
||||
const unsigned long METHODANDRING_MASK = METHOD_MASK | FLAG_SHOWRING | FLAG_NOSHOWRING;
|
||||
|
||||
// these constants are used with the aType argument to MoveFocus
|
||||
|
||||
/** move focus forward one element, used when pressing TAB */
|
||||
|
|
|
@ -487,7 +487,7 @@ function startTest()
|
|||
}
|
||||
|
||||
// focus() method
|
||||
gLastFocusMethod = fm.FLAG_BYJS;
|
||||
gLastFocusMethod = 0;
|
||||
for (idx = kTabbableSteps; idx >= 1; idx--) {
|
||||
if ((navigator.platform.indexOf("Mac") == 0) && (idx == kBeforeTabboxIndex + 1))
|
||||
continue;
|
||||
|
@ -523,10 +523,11 @@ function startTest()
|
|||
// 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) {
|
||||
gLastFocusMethod = fm.FLAG_BYJS;
|
||||
gLastFocusMethod = fm.FLAG_BYMOVEFOCUS;
|
||||
var legend = getById("legend");
|
||||
expectFocusShift(() => legend.focus(),
|
||||
null, getById("t28"), true, "focus method on unfocusable legend");
|
||||
gLastFocusMethod = 0;
|
||||
legend.tabIndex = "0";
|
||||
expectFocusShift(() => legend.focus(),
|
||||
null, getById("legend"), true, "focus method on focusable legend");
|
||||
|
@ -562,7 +563,7 @@ function startTest()
|
|||
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");
|
||||
gLastFocusMethod = fm.FLAG_BYJS;
|
||||
gLastFocusMethod = 0;
|
||||
expectFocusShift(() => synthesizeMouse(getById("aj"), 2, 2, { }),
|
||||
null, getById("o9"), true, "mouse on xul label with content inside");
|
||||
expectFocusShift(() => synthesizeMouse(getById("ak"), 2, 2, { }),
|
||||
|
@ -570,7 +571,6 @@ function startTest()
|
|||
|
||||
// test accesskeys that shouldn't work
|
||||
k = "o".charCodeAt(0);
|
||||
gLastFocusMethod = fm.FLAG_BYJS;
|
||||
while (k++ < "v".charCodeAt(0)) {
|
||||
var key = String.fromCharCode(k);
|
||||
expectFocusShift(() => synthesizeKey(key, accessKeyDetails),
|
||||
|
@ -759,7 +759,7 @@ function startTest()
|
|||
|
||||
// ---- tests for the FLAG_NOSWITCHFRAME flag
|
||||
getById("o5").focus();
|
||||
gLastFocusMethod = fm.FLAG_BYJS;
|
||||
gLastFocusMethod = 0;
|
||||
gEvents = "";
|
||||
// focus is being shifted in a child, so the focus should not change
|
||||
expectFocusShift(() => fm.setFocus(getById("t20"), fm.FLAG_NOSWITCHFRAME),
|
||||
|
@ -798,7 +798,7 @@ function startTest()
|
|||
var input2 = document.createElement("input");
|
||||
$("innerbox").appendChild(input2);
|
||||
|
||||
gLastFocusMethod = fm.FLAG_BYJS;
|
||||
gLastFocusMethod = 0;
|
||||
expectFocusShift(() => input2.focus(),
|
||||
null, input2, true, "focus on input");
|
||||
gLastFocusMethod = fm.FLAG_BYKEY;
|
||||
|
@ -807,7 +807,7 @@ function startTest()
|
|||
|
||||
input1.tabIndex = 2;
|
||||
input2.tabIndex = 2;
|
||||
gLastFocusMethod = fm.FLAG_BYJS;
|
||||
gLastFocusMethod = 0;
|
||||
expectFocusShift(() => input2.focus(),
|
||||
null, input2, true, "focus on input with tabindex set");
|
||||
gLastFocusMethod = fm.FLAG_BYKEY;
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
<!doctype html>
|
||||
<link rel="author" title="Emilio Cobos Álvarez" href="mailto:emilio@crisal.io">
|
||||
<link rel="author" title="Mozilla" href="https://mozilla.org">
|
||||
<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1712724">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/resources/testdriver.js"></script>
|
||||
<script src="/resources/testdriver-vendor.js"></script>
|
||||
<input type=text id=text value=abc>
|
||||
<script>
|
||||
let text = document.getElementById("text");
|
||||
|
||||
document.addEventListener("keyup", function(e) {
|
||||
text.focus();
|
||||
});
|
||||
|
||||
promise_test(async t => {
|
||||
await test_driver.send_keys(document.body, " ");
|
||||
|
||||
assert_equals(document.activeElement, text, "#text should be focused by our event listener");
|
||||
assert_true(text.matches(":focus"), "#text should match :focus");
|
||||
assert_true(text.matches(":focus-visible"), "#text should match :focus-visible");
|
||||
assert_equals(text.selectionStart, text.selectionEnd, "#text should not be selected");
|
||||
assert_equals(text.value, "abc", "#text should not have changed value");
|
||||
});
|
||||
</script>
|
Загрузка…
Ссылка в новой задаче