Bug 1331798 Bookmark panel for new bookmark shouldn't be closed automatically during composition and after text input without keyboard events nor composition events r=jaws

Bookmark panel for a new bookmark shouldn't be closed automatically during composition even if mouse cursor is moved outside the panel because user may click in IME's UI.

Additionally, editor might be modified without keyboard events nor composition events.  In such case, the bookmark panel shouldn't be closed automatically too.

MozReview-Commit-ID: 1FAUmkXjid

--HG--
extra : rebase_source : b4bc6eeeebfeeafe12d9cb16df7b3d31e60c5ae5
This commit is contained in:
Masayuki Nakano 2017-01-19 15:04:56 +09:00
Родитель b797477463
Коммит 4515205f36
2 изменённых файлов: 110 добавлений и 1 удалений

Просмотреть файл

@ -7,6 +7,7 @@ var StarUI = {
uri: null,
_batching: false,
_isNewBookmark: false,
_isComposing: false,
_autoCloseTimer: 0,
_element(aID) {
@ -23,6 +24,9 @@ var StarUI = {
element.addEventListener("keypress", this);
element.addEventListener("mouseout", this);
element.addEventListener("mousemove", this);
element.addEventListener("compositionstart", this);
element.addEventListener("compositionend", this);
element.addEventListener("input", this);
element.addEventListener("popuphidden", this);
element.addEventListener("popupshown", this);
return this.panel = element;
@ -135,6 +139,25 @@ var StarUI = {
break;
}
break;
case "compositionstart":
if (aEvent.defaultPrevented) {
// If the composition was canceled, nothing to do here.
break;
}
// During composition, panel shouldn't be hidden automatically.
clearTimeout(this._autoCloseTimer);
this._isComposing = true;
break;
case "compositionend":
// After composition is committed, "mouseout" or something can set
// auto close timer.
this._isComposing = false;
break;
case "input":
// Might be edited some text without keyboard events nor composition
// events. Let's cancel auto close in such case.
clearTimeout(this._autoCloseTimer);
break;
case "mouseout":
// Explicit fall-through
case "popupshown":
@ -143,7 +166,7 @@ var StarUI = {
break;
}
// auto-close if new and not interacted with
if (this._isNewBookmark) {
if (this._isNewBookmark && !this._isComposing) {
// 3500ms matches the timeout that Pocket uses in
// browser/extensions/pocket/content/panels/js/saved.js
let delay = 3500;

Просмотреть файл

@ -196,6 +196,92 @@ add_task(function* panel_shown_for_new_bookmark_keypress_no_autoclose() {
});
});
add_task(function* panel_shown_for_new_bookmark_compositionstart_no_autoclose() {
yield test_bookmarks_popup({
isNewBookmark: true,
popupShowFn() {
bookmarkStar.click();
},
*popupEditFn() {
let compositionStartPromise = BrowserTestUtils.waitForEvent(bookmarkPanel, "compositionstart");
EventUtils.synthesizeComposition({ type: "compositionstart" }, window);
info("Waiting for compositionstart event");
yield compositionStartPromise;
info("Got compositionstart event");
},
shouldAutoClose: false,
popupHideFn() {
EventUtils.synthesizeComposition({ type: "compositioncommitasis" });
bookmarkPanel.hidePopup();
},
isBookmarkRemoved: false,
});
});
add_task(function* panel_shown_for_new_bookmark_compositionstart_mouseout_no_autoclose() {
yield test_bookmarks_popup({
isNewBookmark: true,
popupShowFn() {
bookmarkStar.click();
},
*popupEditFn() {
let mouseMovePromise = BrowserTestUtils.waitForEvent(bookmarkPanel, "mousemove");
EventUtils.synthesizeMouseAtCenter(bookmarkPanel, {type: "mousemove"});
info("Waiting for mousemove event");
yield mouseMovePromise;
info("Got mousemove event");
let compositionStartPromise = BrowserTestUtils.waitForEvent(bookmarkPanel, "compositionstart");
EventUtils.synthesizeComposition({ type: "compositionstart" }, window);
info("Waiting for compositionstart event");
yield compositionStartPromise;
info("Got compositionstart event");
let mouseOutPromise = BrowserTestUtils.waitForEvent(bookmarkPanel, "mouseout");
EventUtils.synthesizeMouse(bookmarkPanel, 0, 0, {type: "mouseout"});
EventUtils.synthesizeMouseAtCenter(document.documentElement, {type: "mousemove"});
info("Waiting for mouseout event");
yield mouseOutPromise;
info("Got mouseout event, but shouldn't run autoclose");
},
shouldAutoClose: false,
popupHideFn() {
EventUtils.synthesizeComposition({ type: "compositioncommitasis" });
bookmarkPanel.hidePopup();
},
isBookmarkRemoved: false,
});
});
add_task(function* panel_shown_for_new_bookmark_compositionend_mouseout_autoclose() {
yield test_bookmarks_popup({
isNewBookmark: true,
popupShowFn() {
bookmarkStar.click();
},
*popupEditFn() {
let mouseMovePromise = BrowserTestUtils.waitForEvent(bookmarkPanel, "mousemove");
EventUtils.synthesizeMouseAtCenter(bookmarkPanel, {type: "mousemove"});
info("Waiting for mousemove event");
yield mouseMovePromise;
info("Got mousemove event");
EventUtils.synthesizeComposition({ type: "compositioncommit", data: "committed text" });
},
*popupHideFn() {
let mouseOutPromise = BrowserTestUtils.waitForEvent(bookmarkPanel, "mouseout");
EventUtils.synthesizeMouse(bookmarkPanel, 0, 0, {type: "mouseout"});
EventUtils.synthesizeMouseAtCenter(document.documentElement, {type: "mousemove"});
info("Waiting for mouseout event");
yield mouseOutPromise;
info("Got mouseout event, should autoclose now");
},
shouldAutoClose: false,
isBookmarkRemoved: false,
});
});
add_task(function* contextmenu_new_bookmark_keypress_no_autoclose() {
yield test_bookmarks_popup({
isNewBookmark: true,