author | Masayuki Nakano <masayuki@d-toybox.com> |
Tue, 13 Nov 2012 10:18:57 +0900 | |
changeset 113150 | b6bd99bf0c1ffba4f030150c7837eed001c7516b |
parent 113149 | 876764fbf6dc4c2234a725146102c843f0f40ee5 |
child 113151 | 9558170464c0854eb9e5ce5e2c2aa9793dbf57a4 |
push id | 23859 |
push user | emorley@mozilla.com |
push date | Wed, 14 Nov 2012 14:36:31 +0000 |
treeherder | mozilla-central@87928cd21b40 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | enndeakin |
bugs | 805766 |
milestone | 19.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
dom/base/nsFocusManager.cpp | file | annotate | diff | comparison | revisions | |
widget/tests/test_imestate.html | file | annotate | diff | comparison | revisions |
--- a/dom/base/nsFocusManager.cpp +++ b/dom/base/nsFocusManager.cpp @@ -1750,16 +1750,18 @@ nsFocusManager::Focus(nsPIDOMWindow* aWi if (widget) widget->SetFocus(false); } } // if switching to a new document, first fire the focus event on the // document and then the window. if (aIsNewDocument) { + nsIMEStateManager::OnChangeFocus(presShell->GetPresContext(), nullptr, + GetFocusMoveActionCause(aFlags)); nsIDocument* doc = aWindow->GetExtantDoc(); if (doc) SendFocusOrBlurEvent(NS_FOCUS_CONTENT, presShell, doc, doc, aFlags & FOCUSMETHOD_MASK, aWindowRaised); if (mFocusedWindow == aWindow && mFocusedContent == nullptr) SendFocusOrBlurEvent(NS_FOCUS_CONTENT, presShell, doc, aWindow, aFlags & FOCUSMETHOD_MASK, aWindowRaised); }
--- a/widget/tests/test_imestate.html +++ b/widget/tests/test_imestate.html @@ -155,31 +155,35 @@ function runBasicTest(aIsEditable, aInDe document.getElementById("display").focus(); } else if (aTest.expectedEnabled == gUtils.IME_STATUS_ENABLED) { document.getElementById("password").focus(); } else { document.getElementById("text").focus(); } var previousFocusedElement = gFM.focusedElement; var element = document.getElementById(aTest.id); + var focusEventTarget = element; var subDocument = null; if (element.contentDocument) { + focusEventTarget = element.contentDocument; subDocument = element.contentDocument; element = element.contentDocument.documentElement; } + focusEventTarget.addEventListener("focus", aFocusEventHandler, true); document.addEventListener("MozIMEFocusIn", aFocusEventHandler, true); document.addEventListener("MozIMEFocusOut", aFocusEventHandler, true); if (subDocument) { subDocument.addEventListener("MozIMEFocusIn", aFocusEventHandler, true); subDocument.addEventListener("MozIMEFocusOut", aFocusEventHandler, true); } element.focus(); + focusEventTarget.removeEventListener("focus", aFocusEventHandler, true); document.removeEventListener("MozIMEFocusIn", aFocusEventHandler, true); document.removeEventListener("MozIMEFocusOut", aFocusEventHandler, true); if (element.contentDocument) { subDocument.removeEventListener("MozIMEFocusIn", aFocusEventHandler, true); subDocument.removeEventListener("MozIMEFocusOut", aFocusEventHandler, true); } var focusedElement = gFM.focusedElement; @@ -210,23 +214,29 @@ function runBasicTest(aIsEditable, aInDe ", wrong opened state"; is(gUtils.IMEIsOpen, aTest.changeOpened ? aTest.expectedOpened : aOpened, message); } // IME Enabled state testing var enabled = gUtils.IME_STATUS_ENABLED; if (kIMEEnabledSupported) { + var focusEventCount = 0; var mozIMEFocusInCount = 0; var mozIMEFocusOutCount = 0; var IMEHasFocus = false; function onFocus(aEvent) { switch (aEvent.type) { + case "focus": + focusEventCount++; + is(gUtils.IMEStatus, aTest.expectedEnabled, + aDescription + ": " + aTest.description + ", wrong enabled state at focus event"); + break; case "MozIMEFocusIn": mozIMEFocusInCount++; IMEHasFocus = true; is(gUtils.IMEStatus, aTest.expectedEnabled, aDescription + ": " + aTest.description + ", MozIMEFocusIn event must be fired after IME state is updated"); break; case "MozIMEFocusOut": @@ -240,60 +250,49 @@ function runBasicTest(aIsEditable, aInDe } if (!moveFocus(aTest, onFocus)) { return; } if (aTest.focusable) { if (!aTest.focusEventNotFired) { + ok(focusEventCount > 0, + aDescription + ": " + aTest.description + ", focus event is never fired"); if (aTest.expectedEnabled == gUtils.IME_STATUS_ENABLED || aTest.expectedEnabled == gUtils.IME_STATUS_PASSWORD) { + ok(mozIMEFocusInCount > 0, + aDescription + ": " + aTest.description + ", MozIMEFocusIn event should be fired"); var toDesignModeEditor = (document.activeElement.contentDocument && (document.activeElement.contentDocument.designMode == "on")); - if (aInDesignMode && toDesignModeEditor) { + if (aInDesignMode && !toDesignModeEditor) { is(mozIMEFocusOutCount, 0, aDescription + ": " + aTest.description + ", MozIMEFocusOut event shouldn't be fired in designMode since focus isn't moved from another editor"); - todo(mozIMEFocusInCount > 0, - aDescription + ": " + aTest.description + ", MozIMEFocusIn event should be fired"); // bug 805766 } else { ok(mozIMEFocusOutCount > 0, aDescription + ": " + aTest.description + ", MozIMEFocusOut event should be fired for the previous focused editor"); - if (toDesignModeEditor) { - todo(mozIMEFocusInCount > 0, - aDescription + ": " + aTest.description + ", MozIMEFocusIn event should be fired"); // bug 805766 - } else { - ok(mozIMEFocusInCount > 0, - aDescription + ": " + aTest.description + ", MozIMEFocusIn event should be fired"); - } } - if (aInDesignMode || toDesignModeEditor) { // bug 805766 - todo(IMEHasFocus, - aDescription + ": " + aTest.description + - ", The latest MozIMEFocus* event must be MozIMEFocusIn"); - } else { - ok(IMEHasFocus, - aDescription + ": " + aTest.description + - ", The latest MozIMEFocus* event must be MozIMEFocusIn"); - } + ok(IMEHasFocus, + aDescription + ": " + aTest.description + + ", The latest MozIMEFocus* event must be MozIMEFocusIn"); } else { is(mozIMEFocusInCount, 0, aDescription + ": " + aTest.description + ", MozIMEFocusIn event shouldn't be fired"); ok(mozIMEFocusOutCount > 0, aDescription + ": " + aTest.description + ", MozIMEFocusOut event should be fired"); ok(!IMEHasFocus, aDescription + ": " + aTest.description + ", The latest MozIMEFocus* event must be MozIMEFocusOut"); } } else { - todo(false, aDescription + ": " + aTest.description + - ", In this case, focus event isn't fired, it's a bug, so, couldn't test it"); + todo(focusEventCount > 0, + aDescription + ": " + aTest.description + ", focus event should be fired"); } } else { is(mozIMEFocusInCount, 0, aDescription + ": " + aTest.description + ", MozIMEFocusIn event shouldn't be fired at testing non-focusable element"); is(mozIMEFocusOutCount, 0, aDescription + ": " + aTest.description + ", MozIMEFocusOut event shouldn't be fired at testing non-focusable element");