copy from toolkit/content/tests/chrome/file_autocomplete_with_composition.js
copy to toolkit/content/tests/chrome/file_editor_with_autocomplete.js
--- a/toolkit/content/tests/chrome/file_autocomplete_with_composition.js
+++ b/toolkit/content/tests/chrome/file_editor_with_autocomplete.js
@@ -1,532 +1,377 @@
-// nsDoTestsForAutoCompleteWithComposition tests autocomplete with composition.
-// Users must include SimpleTest.js and EventUtils.js.
+// nsDoTestsForEditorWithAutoComplete tests basic functions of editor with autocomplete.
+// Users must include SimpleTest.js and EventUtils.js, and register "Mozilla" to the autocomplete for the target.
ChromeUtils.import("resource://gre/modules/Services.jsm");
-function waitForCondition(condition, nextTest) {
- var tries = 0;
- var interval = setInterval(function() {
- if (condition() || tries >= 30) {
- moveOn();
- }
- tries++;
- }, 100);
- var moveOn = function() { clearInterval(interval); nextTest(); };
+async function waitForCondition(condition) {
+ return new Promise(resolve => {
+ var tries = 0;
+ var interval = setInterval(function() {
+ if (condition() || tries >= 60) {
+ moveOn();
+ }
+ tries++;
+ }, 100);
+ var moveOn = function() { clearInterval(interval); resolve(); };
+ });
}
-function nsDoTestsForAutoCompleteWithComposition(aDescription,
- aWindow,
- aTarget,
- aAutoCompleteController,
- aIsFunc,
- aGetTargetValueFunc,
- aOnFinishFunc) {
+function nsDoTestsForEditorWithAutoComplete(aDescription,
+ aWindow,
+ aTarget,
+ aAutoCompleteController,
+ aIsFunc,
+ aGetTargetValueFunc) {
this._description = aDescription;
this._window = aWindow;
this._target = aTarget;
this._controller = aAutoCompleteController;
this._is = aIsFunc;
this._getTargetValue = aGetTargetValueFunc;
- this._onFinish = aOnFinishFunc;
this._target.focus();
this._DefaultCompleteDefaultIndex =
this._controller.input.completeDefaultIndex;
-
- this._doTests();
}
-nsDoTestsForAutoCompleteWithComposition.prototype = {
+nsDoTestsForEditorWithAutoComplete.prototype = {
_window: null,
_target: null,
_controller: null,
_DefaultCompleteDefaultIndex: false,
_description: "",
_is: null,
_getTargetValue() { return "not initialized"; },
- _onFinish: null,
- _doTests() {
- if (++this._testingIndex == this._tests.length) {
- this._controller.input.completeDefaultIndex =
- this._DefaultCompleteDefaultIndex;
- this._onFinish();
- return;
- }
-
- var test = this._tests[this._testingIndex];
- if (this._controller.input.completeDefaultIndex != test.completeDefaultIndex) {
- this._controller.input.completeDefaultIndex = test.completeDefaultIndex;
- }
- test.execute(this._window);
+ run: async function runTestsImpl() {
+ for (let test of this._tests) {
+ if (this._controller.input.completeDefaultIndex != test.completeDefaultIndex) {
+ this._controller.input.completeDefaultIndex = test.completeDefaultIndex;
+ }
- waitForCondition(() => {
- return this._controller.searchStatus >=
- Ci.nsIAutoCompleteController.STATUS_COMPLETE_NO_MATCH;
- },
- this._checkResult.bind(this));
- },
+ if (test.execute(this._window, this._target) === false) {
+ continue;
+ }
- _checkResult() {
- var test = this._tests[this._testingIndex];
- this._is(this._getTargetValue(), test.value,
- this._description + ", " + test.description + ": value");
- this._is(this._controller.searchString, test.searchString,
- this._description + ", " + test.description + ": searchString");
- this._is(this._controller.input.popupOpen, test.popup,
- this._description + ", " + test.description + ": popupOpen");
- this._doTests();
+ await waitForCondition(() => {
+ return this._controller.searchStatus >=
+ Ci.nsIAutoCompleteController.STATUS_COMPLETE_NO_MATCH;
+ });
+ this._checkResult(test);
+ }
+ this._controller.input.completeDefaultIndex = this._DefaultCompleteDefaultIndex;
},
- _testingIndex: -1,
+ _checkResult(aTest) {
+ this._is(this._getTargetValue(), aTest.value,
+ this._description + ", " + aTest.description + ": value");
+ this._is(this._controller.searchString, aTest.searchString,
+ this._description + ", " + aTest.description + ": searchString");
+ this._is(this._controller.input.popupOpen, aTest.popup,
+ this._description + ", " + aTest.description + ": popupOpen");
+ this._is(this._controller.searchStatus, Ci.nsIAutoCompleteController.STATUS_COMPLETE_MATCH,
+ this._description + ", " + aTest.description + ": status");
+ },
+
_tests: [
- // Simple composition when popup hasn't been shown.
- // The autocomplete popup should not be shown during composition, but
- // after compositionend, the popup should be shown.
- { description: "compositionstart shouldn't open the popup",
+ { description: "Undo/Redo behavior check when typed text exactly matches the case: type 'Mo'",
completeDefaultIndex: false,
- execute(aWindow) {
- synthesizeCompositionChange(
- { "composition":
- { "string": "M",
- "clauses":
- [
- { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE }
- ]
- },
- "caret": { "start": 1, "length": 0 },
- "key": { key: "M" },
- }, aWindow);
- }, popup: false, value: "M", searchString: ""
+ execute(aWindow, aTarget) {
+ synthesizeKey("M", { shiftKey: true }, aWindow);
+ synthesizeKey("o", {}, aWindow);
+ return true;
+ }, popup: true, value: "Mo", searchString: "Mo"
},
- { description: "modifying composition string shouldn't open the popup",
+ { description: "Undo/Redo behavior check when typed text exactly matches the case: select 'Mozilla' to complete the word",
completeDefaultIndex: false,
- execute(aWindow) {
- synthesizeCompositionChange(
- { "composition":
- { "string": "Mo",
- "clauses":
- [
- { "length": 2, "attr": COMPOSITION_ATTR_RAW_CLAUSE }
- ]
- },
- "caret": { "start": 2, "length": 0 },
- "key": { key: "o" },
- }, aWindow);
- }, popup: false, value: "Mo", searchString: ""
+ execute(aWindow, aTarget) {
+ synthesizeKey("KEY_ArrowDown", {}, aWindow);
+ synthesizeKey("KEY_Enter", {}, aWindow);
+ return true;
+ }, popup: false, value: "Mozilla", searchString: "Mozilla"
},
- { description: "compositionend should open the popup",
+ { description: "Undo/Redo behavior check when typed text exactly matches the case: undo the word, but typed text shouldn't be canceled",
completeDefaultIndex: false,
- execute(aWindow) {
- synthesizeComposition({ type: "compositioncommitasis", key: { key: "KEY_Enter" } }, aWindow);
+ execute(aWindow, aTarget) {
+ synthesizeKey("z", { accelKey: true }, aWindow);
+ return true;
}, popup: true, value: "Mo", searchString: "Mo"
},
- // If composition starts when popup is shown, the compositionstart event
- // should cause closing the popup.
- { description: "compositionstart should close the popup",
- completeDefaultIndex: false,
- execute(aWindow) {
- synthesizeCompositionChange(
- { "composition":
- { "string": "z",
- "clauses":
- [
- { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE }
- ]
- },
- "caret": { "start": 1, "length": 0 },
- "key": { key: "z" },
- }, aWindow);
- }, popup: false, value: "Moz", searchString: "Mo"
- },
- { description: "modifying composition string shouldn't reopen the popup",
- completeDefaultIndex: false,
- execute(aWindow) {
- synthesizeCompositionChange(
- { "composition":
- { "string": "zi",
- "clauses":
- [
- { "length": 2, "attr": COMPOSITION_ATTR_RAW_CLAUSE }
- ]
- },
- "caret": { "start": 2, "length": 0 },
- "key": { key: "i" },
- }, aWindow);
- }, popup: false, value: "Mozi", searchString: "Mo"
- },
- { description: "compositionend should research the result and open the popup",
- completeDefaultIndex: false,
- execute(aWindow) {
- synthesizeComposition({ type: "compositioncommitasis", key: { key: "KEY_Enter" } }, aWindow);
- }, popup: true, value: "Mozi", searchString: "Mozi"
- },
- // If composition is cancelled, the value shouldn't be changed.
- { description: "compositionstart should reclose the popup",
- completeDefaultIndex: false,
- execute(aWindow) {
- synthesizeCompositionChange(
- { "composition":
- { "string": "l",
- "clauses":
- [
- { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE }
- ]
- },
- "caret": { "start": 1, "length": 0 },
- "key": { key: "l" },
- }, aWindow);
- }, popup: false, value: "Mozil", searchString: "Mozi"
- },
- { description: "modifying composition string shouldn't reopen the popup",
- completeDefaultIndex: false,
- execute(aWindow) {
- synthesizeCompositionChange(
- { "composition":
- { "string": "ll",
- "clauses":
- [
- { "length": 2, "attr": COMPOSITION_ATTR_RAW_CLAUSE }
- ]
- },
- "caret": { "start": 2, "length": 0 },
- "key": { key: "l" },
- }, aWindow);
- }, popup: false, value: "Mozill", searchString: "Mozi"
- },
- { description: "modifying composition string to empty string shouldn't reopen the popup",
+ { description: "Undo/Redo behavior check when typed text exactly matches the case: undo the typed text",
completeDefaultIndex: false,
- execute(aWindow) {
- synthesizeCompositionChange(
- { "composition":
- { "string": "",
- "clauses":
- [
- { "length": 0, "attr": 0 }
- ]
- },
- "caret": { "start": 0, "length": 0 },
- "key": { key: "KEY_Backspace" },
- }, aWindow);
- }, popup: false, value: "Mozi", searchString: "Mozi"
+ execute(aWindow, aTarget) {
+ synthesizeKey("z", { accelKey: true }, aWindow);
+ return true;
+ }, popup: false, value: "", searchString: ""
},
- { description: "cancled compositionend should reopen the popup",
- completeDefaultIndex: false,
- execute(aWindow) {
- synthesizeComposition({ type: "compositioncommit", data: "", key: { key: "KEY_Escape" } }, aWindow);
- }, popup: true, value: "Mozi", searchString: "Mozi"
- },
- // But if composition replaces some characters and canceled, the search
- // string should be the latest value.
- { description: "compositionstart with selected string should close the popup",
+ { description: "Undo/Redo behavior check when typed text exactly matches the case: redo the typed text",
completeDefaultIndex: false,
- execute(aWindow) {
- synthesizeKey("VK_LEFT", { shiftKey: true }, aWindow);
- synthesizeKey("VK_LEFT", { shiftKey: true }, aWindow);
- synthesizeCompositionChange(
- { "composition":
- { "string": "z",
- "clauses":
- [
- { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE }
- ]
- },
- "caret": { "start": 1, "length": 0 },
- "key": { key: "z" },
- }, aWindow);
- }, popup: false, value: "Moz", searchString: "Mozi"
- },
- { description: "modifying composition string shouldn't reopen the popup",
- completeDefaultIndex: false,
- execute(aWindow) {
- synthesizeCompositionChange(
- { "composition":
- { "string": "zi",
- "clauses":
- [
- { "length": 2, "attr": COMPOSITION_ATTR_RAW_CLAUSE }
- ]
- },
- "caret": { "start": 2, "length": 0 },
- "key": { key: "i" },
- }, aWindow);
- }, popup: false, value: "Mozi", searchString: "Mozi"
- },
- { description: "modifying composition string to empty string shouldn't reopen the popup",
- completeDefaultIndex: false,
- execute(aWindow) {
- synthesizeCompositionChange(
- { "composition":
- { "string": "",
- "clauses":
- [
- { "length": 0, "attr": 0 }
- ]
- },
- "caret": { "start": 0, "length": 0 },
- "key": { key: "KEY_Backspace" },
- }, aWindow);
- }, popup: false, value: "Mo", searchString: "Mozi"
- },
- { description: "canceled compositionend should search the result with the latest value",
- completeDefaultIndex: false,
- execute(aWindow) {
- synthesizeComposition({ type: "compositioncommitasis", key: { key: "KEY_Escape" } }, aWindow);
+ execute(aWindow, aTarget) {
+ synthesizeKey("Z", { accelKey: true, shiftKey: true }, aWindow);
+ return true;
}, popup: true, value: "Mo", searchString: "Mo"
},
- // If all characters are removed, the popup should be closed.
- { description: "the value becomes empty by backspace, the popup should be closed",
+ { description: "Undo/Redo behavior check when typed text exactly matches the case: redo the word",
+ completeDefaultIndex: false,
+ execute(aWindow, aTarget) {
+ synthesizeKey("Z", { accelKey: true, shiftKey: true }, aWindow);
+ return true;
+ }, popup: true, value: "Mozilla", searchString: "Mozilla"
+ },
+ { description: "Undo/Redo behavior check when typed text exactly matches the case: removing all text for next test...",
+ completeDefaultIndex: false,
+ execute(aWindow, aTarget) {
+ synthesizeKey("a", { accelKey: true }, aWindow);
+ synthesizeKey("KEY_Backspace", {}, aWindow);
+ return true;
+ }, popup: false, value: "", searchString: ""
+ },
+
+ { description: "Undo/Redo behavior check when typed text does not match the case: type 'mo'",
+ completeDefaultIndex: false,
+ execute(aWindow, aTarget) {
+ synthesizeKey("m", {}, aWindow);
+ synthesizeKey("o", {}, aWindow);
+ return true;
+ }, popup: true, value: "mo", searchString: "mo"
+ },
+ { description: "Undo/Redo behavior check when typed text does not match the case: select 'Mozilla' to complete the word",
completeDefaultIndex: false,
- execute(aWindow) {
+ execute(aWindow, aTarget) {
+ synthesizeKey("KEY_ArrowDown", {}, aWindow);
+ synthesizeKey("KEY_Enter", {}, aWindow);
+ return true;
+ }, popup: false, value: "Mozilla", searchString: "Mozilla"
+ },
+ { description: "Undo/Redo behavior check when typed text does not match the case: undo the word, but typed text shouldn't be canceled",
+ completeDefaultIndex: false,
+ execute(aWindow, aTarget) {
+ synthesizeKey("z", { accelKey: true }, aWindow);
+ return true;
+ }, popup: true, value: "mo", searchString: "mo"
+ },
+ { description: "Undo/Redo behavior check when typed text does not match the case: undo the typed text",
+ completeDefaultIndex: false,
+ execute(aWindow, aTarget) {
+ synthesizeKey("z", { accelKey: true }, aWindow);
+ return true;
+ }, popup: false, value: "", searchString: ""
+ },
+ { description: "Undo/Redo behavior check when typed text does not match the case: redo the typed text",
+ completeDefaultIndex: false,
+ execute(aWindow, aTarget) {
+ synthesizeKey("Z", { accelKey: true, shiftKey: true }, aWindow);
+ return true;
+ }, popup: true, value: "mo", searchString: "mo"
+ },
+ { description: "Undo/Redo behavior check when typed text does not match the case: redo the word",
+ completeDefaultIndex: false,
+ execute(aWindow, aTarget) {
+ synthesizeKey("Z", { accelKey: true, shiftKey: true }, aWindow);
+ return true;
+ }, popup: true, value: "Mozilla", searchString: "Mozilla"
+ },
+ { description: "Undo/Redo behavior check when typed text does not match the case: removing all text for next test...",
+ completeDefaultIndex: false,
+ execute(aWindow, aTarget) {
+ synthesizeKey("a", { accelKey: true }, aWindow);
synthesizeKey("KEY_Backspace", {}, aWindow);
- synthesizeKey("KEY_Backspace", {}, aWindow);
+ return true;
}, popup: false, value: "", searchString: ""
},
- // composition which is canceled shouldn't cause opening the popup.
- { description: "compositionstart shouldn't open the popup",
- completeDefaultIndex: false,
- execute(aWindow) {
- synthesizeCompositionChange(
- { "composition":
- { "string": "M",
- "clauses":
- [
- { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE }
- ]
- },
- "caret": { "start": 1, "length": 0 },
- "key": { key: "M" },
- }, aWindow);
- }, popup: false, value: "M", searchString: ""
+
+ // Testing for nsIAutoCompleteInput.completeDefaultIndex being true.
+ { description: "Undo/Redo behavior check when typed text exactly matches the case (completeDefaultIndex is true): type 'Mo'",
+ completeDefaultIndex: true,
+ execute(aWindow, aTarget) {
+ // Undo/Redo behavior on XUL <textbox> with completeDefaultIndex is set to true is unstable. Skip it now.
+ if (aTarget.tagName === "textbox") {
+ return false;
+ }
+ synthesizeKey("M", { shiftKey: true }, aWindow);
+ synthesizeKey("o", {}, aWindow);
+ return true;
+ }, popup: true, value: "Mozilla", searchString: "Mo"
},
- { description: "modifying composition string shouldn't open the popup",
- completeDefaultIndex: false,
- execute(aWindow) {
- synthesizeCompositionChange(
- { "composition":
- { "string": "Mo",
- "clauses":
- [
- { "length": 2, "attr": COMPOSITION_ATTR_RAW_CLAUSE }
- ]
- },
- "caret": { "start": 2, "length": 0 },
- "key": { key: "o" },
- }, aWindow);
- }, popup: false, value: "Mo", searchString: ""
+ { description: "Undo/Redo behavior check when typed text exactly matches the case (completeDefaultIndex is true): select 'Mozilla' to complete the word",
+ completeDefaultIndex: true,
+ execute(aWindow, aTarget) {
+ // Undo/Redo behavior on XUL <textbox> with completeDefaultIndex is set to true is unstable. Skip it now.
+ if (aTarget.tagName === "textbox") {
+ return false;
+ }
+ synthesizeKey("KEY_ArrowDown", {}, aWindow);
+ synthesizeKey("KEY_Enter", {}, aWindow);
+ return true;
+ }, popup: false, value: "Mozilla", searchString: "Mozilla"
},
- { description: "modifying composition string to empty string shouldn't open the popup",
- completeDefaultIndex: false,
- execute(aWindow) {
- synthesizeCompositionChange(
- { "composition":
- { "string": "",
- "clauses":
- [
- { "length": 0, "attr": 0 }
- ]
- },
- "caret": { "start": 0, "length": 0 },
- "key": { key: "KEY_Backspace" },
- }, aWindow);
- }, popup: false, value: "", searchString: ""
+ { description: "Undo/Redo behavior check when typed text exactly matches the case (completeDefaultIndex is true): undo the word, but typed text shouldn't be canceled",
+ completeDefaultIndex: true,
+ execute(aWindow, aTarget) {
+ // Undo/Redo behavior on XUL <textbox> with completeDefaultIndex is set to true is unstable. Skip it now.
+ if (aTarget.tagName === "textbox") {
+ return false;
+ }
+ synthesizeKey("z", { accelKey: true }, aWindow);
+ return true;
+ }, popup: true, value: "Mo", searchString: "Mo"
},
- { description: "canceled compositionend shouldn't open the popup if it was closed",
- completeDefaultIndex: false,
- execute(aWindow) {
- synthesizeComposition({ type: "compositioncommitasis", key: { key: "KEY_Escape" } }, aWindow);
+ { description: "Undo/Redo behavior check when typed text exactly matches the case (completeDefaultIndex is true): undo the typed text",
+ completeDefaultIndex: true,
+ execute(aWindow, aTarget) {
+ // Undo/Redo behavior on XUL <textbox> with completeDefaultIndex is set to true is unstable. Skip it now.
+ if (aTarget.tagName === "textbox") {
+ return false;
+ }
+ synthesizeKey("z", { accelKey: true }, aWindow);
+ return true;
}, popup: false, value: "", searchString: ""
},
- // Down key should open the popup even if the editor is empty.
- { description: "DOWN key should open the popup even if the value is empty",
- completeDefaultIndex: false,
- execute(aWindow) {
- synthesizeKey("KEY_ArrowDown", {}, aWindow);
- }, popup: true, value: "", searchString: ""
- },
- // If popup is open at starting composition, the popup should be reopened
- // after composition anyway.
- { description: "compositionstart shouldn't open the popup",
- completeDefaultIndex: false,
- execute(aWindow) {
- synthesizeCompositionChange(
- { "composition":
- { "string": "M",
- "clauses":
- [
- { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE }
- ]
- },
- "caret": { "start": 1, "length": 0 },
- "key": { key: "M" },
- }, aWindow);
- }, popup: false, value: "M", searchString: ""
+ { description: "Undo/Redo behavior check when typed text exactly matches the case (completeDefaultIndex is true): redo the typed text",
+ completeDefaultIndex: true,
+ execute(aWindow, aTarget) {
+ // Undo/Redo behavior on XUL <textbox> with completeDefaultIndex is set to true is unstable. Skip it now.
+ if (aTarget.tagName === "textbox") {
+ return false;
+ }
+ synthesizeKey("Z", { accelKey: true, shiftKey: true }, aWindow);
+ return true;
+ }, popup: true, value: "Mozilla", searchString: "Mo"
},
- { description: "modifying composition string shouldn't open the popup",
- completeDefaultIndex: false,
- execute(aWindow) {
- synthesizeCompositionChange(
- { "composition":
- { "string": "Mo",
- "clauses":
- [
- { "length": 2, "attr": COMPOSITION_ATTR_RAW_CLAUSE }
- ]
- },
- "caret": { "start": 2, "length": 0 },
- "key": { key: "o" },
- }, aWindow);
- }, popup: false, value: "Mo", searchString: ""
+ { description: "Undo/Redo behavior check when typed text exactly matches the case (completeDefaultIndex is true): redo the word",
+ completeDefaultIndex: true,
+ execute(aWindow, aTarget) {
+ // Undo/Redo behavior on XUL <textbox> with completeDefaultIndex is set to true is unstable. Skip it now.
+ if (aTarget.tagName === "textbox") {
+ return false;
+ }
+ synthesizeKey("Z", { accelKey: true, shiftKey: true }, aWindow);
+ return true;
+ }, popup: true, value: "Mozilla", searchString: "Mo"
},
- { description: "modifying composition string to empty string shouldn't open the popup",
- completeDefaultIndex: false,
- execute(aWindow) {
- synthesizeCompositionChange(
- { "composition":
- { "string": "",
- "clauses":
- [
- { "length": 0, "attr": 0 }
- ]
- },
- "caret": { "start": 0, "length": 0 },
- "key": { key: "KEY_Backspace" },
- }, aWindow);
+ { description: "Undo/Redo behavior check when typed text exactly matches the case (completeDefaultIndex is true): removing all text for next test...",
+ completeDefaultIndex: true,
+ execute(aWindow, aTarget) {
+ // Undo/Redo behavior on XUL <textbox> with completeDefaultIndex is set to true is unstable. Skip it now.
+ if (aTarget.tagName === "textbox") {
+ return false;
+ }
+ synthesizeKey("a", { accelKey: true }, aWindow);
+ synthesizeKey("KEY_Backspace", {}, aWindow);
+ return true;
}, popup: false, value: "", searchString: ""
},
- { description: "canceled compositionend should open the popup if it was opened",
- completeDefaultIndex: false,
- execute(aWindow) {
- synthesizeComposition({ type: "compositioncommitasis", key: { key: "KEY_Escape" } }, aWindow);
- }, popup: true, value: "", searchString: ""
- },
- // Type normally, and hit escape, the popup should be closed.
- { description: "ESCAPE should close the popup after typing something",
- completeDefaultIndex: false,
- execute(aWindow) {
- synthesizeKey("M", {}, aWindow);
+
+ { description: "Undo/Redo behavior check when typed text does not match the case (completeDefaultIndex is true): type 'mo'",
+ completeDefaultIndex: true,
+ execute(aWindow, aTarget) {
+ // Undo/Redo behavior on XUL <textbox> with completeDefaultIndex is set to true is unstable. Skip it now.
+ if (aTarget.tagName === "textbox") {
+ return false;
+ }
+ synthesizeKey("m", {}, aWindow);
synthesizeKey("o", {}, aWindow);
- synthesizeKey("KEY_Escape", {}, aWindow);
- }, popup: false, value: "Mo", searchString: "Mo"
+ return true;
+ }, popup: true, value: "mozilla", searchString: "mo"
},
- // Even if the popup is closed, composition which is canceled should open
- // the popup if the value isn't empty.
- // XXX This might not be good behavior, but anyway, this is minor issue...
- { description: "compositionstart shouldn't open the popup",
- completeDefaultIndex: false,
- execute(aWindow) {
- synthesizeCompositionChange(
- { "composition":
- { "string": "z",
- "clauses":
- [
- { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE }
- ]
- },
- "caret": { "start": 1, "length": 0 },
- "key": { key: "z" },
- }, aWindow);
- }, popup: false, value: "Moz", searchString: "Mo"
+ { description: "Undo/Redo behavior check when typed text does not match the case (completeDefaultIndex is true): select 'Mozilla' to complete the word",
+ completeDefaultIndex: true,
+ execute(aWindow, aTarget) {
+ // Undo/Redo behavior on XUL <textbox> with completeDefaultIndex is set to true is unstable. Skip it now.
+ if (aTarget.tagName === "textbox") {
+ return false;
+ }
+ synthesizeKey("KEY_ArrowDown", {}, aWindow);
+ synthesizeKey("KEY_Enter", {}, aWindow);
+ return true;
+ }, popup: false, value: "Mozilla", searchString: "Mozilla"
},
- { description: "modifying composition string shouldn't open the popup",
- completeDefaultIndex: false,
- execute(aWindow) {
- synthesizeCompositionChange(
- { "composition":
- { "string": "zi",
- "clauses":
- [
- { "length": 2, "attr": COMPOSITION_ATTR_RAW_CLAUSE }
- ]
- },
- "caret": { "start": 2, "length": 0 },
- "key": { key: "i", },
- }, aWindow);
- }, popup: false, value: "Mozi", searchString: "Mo"
+ // Different from "exactly matches the case" case, modifying the case causes one additional transaction.
+ // Although we could make this transaction ignored.
+ { description: "Undo/Redo behavior check when typed text does not match the case (completeDefaultIndex is true): undo the selected word, but typed text shouldn't be canceled",
+ completeDefaultIndex: true,
+ execute(aWindow, aTarget) {
+ // Undo/Redo behavior on XUL <textbox> with completeDefaultIndex is set to true is unstable. Skip it now.
+ if (aTarget.tagName === "textbox") {
+ return false;
+ }
+ synthesizeKey("z", { accelKey: true }, aWindow);
+ return true;
+ }, popup: true, value: "mozilla", searchString: "mozilla"
},
- { description: "modifying composition string to empty string shouldn't open the popup",
- completeDefaultIndex: false,
- execute(aWindow) {
- synthesizeCompositionChange(
- { "composition":
- { "string": "",
- "clauses":
- [
- { "length": 0, "attr": 0 }
- ]
- },
- "caret": { "start": 0, "length": 0 },
- "key": { key: "KEY_Backspace" },
- }, aWindow);
- }, popup: false, value: "Mo", searchString: "Mo"
+ { description: "Undo/Redo behavior check when typed text does not match the case (completeDefaultIndex is true): undo the word, but typed text shouldn't be canceled",
+ completeDefaultIndex: true,
+ execute(aWindow, aTarget) {
+ // Undo/Redo behavior on XUL <textbox> with completeDefaultIndex is set to true is unstable. Skip it now.
+ if (aTarget.tagName === "textbox") {
+ return false;
+ }
+ synthesizeKey("z", { accelKey: true }, aWindow);
+ return true;
+ }, popup: true, value: "mo", searchString: "mo"
},
- { description: "canceled compositionend shouldn't open the popup if the popup was closed",
- completeDefaultIndex: false,
- execute(aWindow) {
- synthesizeComposition({ type: "compositioncommitasis", key: { key: "KEY_Escape" } }, aWindow);
- }, popup: true, value: "Mo", searchString: "Mo"
- },
- // House keeping...
- { description: "house keeping for next tests",
- completeDefaultIndex: false,
- execute(aWindow) {
- synthesizeKey("KEY_Backspace", {}, aWindow);
- synthesizeKey("KEY_Backspace", {}, aWindow);
+ { description: "Undo/Redo behavior check when typed text does not match the case (completeDefaultIndex is true): undo the typed text",
+ completeDefaultIndex: true,
+ execute(aWindow, aTarget) {
+ // Undo/Redo behavior on XUL <textbox> with completeDefaultIndex is set to true is unstable. Skip it now.
+ if (aTarget.tagName === "textbox") {
+ return false;
+ }
+ synthesizeKey("z", { accelKey: true }, aWindow);
+ return true;
}, popup: false, value: "", searchString: ""
},
- // Testing for nsIAutoCompleteInput.completeDefaultIndex being true.
- { description: "compositionstart shouldn't open the popup (completeDefaultIndex is true)",
+ // XXX This is odd case. Consistency with undo behavior, this should restore "mo".
+ // However, looks like that autocomplete automatically restores "mozilla".
+ // Additionally, looks like that it causes clearing the redo stack.
+ // Therefore, the following redo operations do nothing.
+ { description: "Undo/Redo behavior check when typed text does not match the case (completeDefaultIndex is true): redo the typed text",
completeDefaultIndex: true,
- execute(aWindow) {
- synthesizeCompositionChange(
- { "composition":
- { "string": "M",
- "clauses":
- [
- { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE }
- ]
- },
- "caret": { "start": 1, "length": 0 },
- "key": { key: "M" },
- }, aWindow);
- }, popup: false, value: "M", searchString: ""
+ execute(aWindow, aTarget) {
+ // Undo/Redo behavior on XUL <textbox> with completeDefaultIndex is set to true is unstable. Skip it now.
+ if (aTarget.tagName === "textbox") {
+ return false;
+ }
+ synthesizeKey("Z", { accelKey: true, shiftKey: true }, aWindow);
+ return true;
+ }, popup: true, value: "mozilla", searchString: "mo"
},
- { description: "modifying composition string shouldn't open the popup (completeDefaultIndex is true)",
+ { description: "Undo/Redo behavior check when typed text does not match the case (completeDefaultIndex is true): redo the default index word",
completeDefaultIndex: true,
- execute(aWindow) {
- synthesizeCompositionChange(
- { "composition":
- { "string": "Mo",
- "clauses":
- [
- { "length": 2, "attr": COMPOSITION_ATTR_RAW_CLAUSE }
- ]
- },
- "caret": { "start": 2, "length": 0 },
- "key": { key: "o" },
- }, aWindow);
- }, popup: false, value: "Mo", searchString: ""
+ execute(aWindow, aTarget) {
+ // Undo/Redo behavior on XUL <textbox> with completeDefaultIndex is set to true is unstable. Skip it now.
+ if (aTarget.tagName === "textbox") {
+ return false;
+ }
+ synthesizeKey("Z", { accelKey: true, shiftKey: true }, aWindow);
+ return true;
+ }, popup: true, value: "mozilla", searchString: "mo"
},
- { description: "compositionend should open the popup (completeDefaultIndex is true)",
+ { description: "Undo/Redo behavior check when typed text does not match the case (completeDefaultIndex is true): redo the word",
completeDefaultIndex: true,
- execute(aWindow) {
- synthesizeComposition({ type: "compositioncommitasis", key: { key: "KEY_Enter" } }, aWindow);
- }, popup: true, value: "Mozilla", searchString: "Mo"
+ execute(aWindow, aTarget) {
+ // Undo/Redo behavior on XUL <textbox> with completeDefaultIndex is set to true is unstable. Skip it now.
+ if (aTarget.tagName === "textbox") {
+ return false;
+ }
+ synthesizeKey("Z", { accelKey: true, shiftKey: true }, aWindow);
+ return true;
+ }, popup: true, value: "mozilla", searchString: "mo"
},
- // House keeping...
- { description: "house keeping for next tests",
- completeDefaultIndex: false,
- execute(aWindow) {
- synthesizeKey("KEY_Backspace", {}, aWindow);
+ { description: "Undo/Redo behavior check when typed text does not match the case (completeDefaultIndex is true): removing all text for next test...",
+ completeDefaultIndex: true,
+ execute(aWindow, aTarget) {
+ // Undo/Redo behavior on XUL <textbox> with completeDefaultIndex is set to true is unstable. Skip it now.
+ if (aTarget.tagName === "textbox") {
+ return false;
+ }
+ synthesizeKey("a", { accelKey: true }, aWindow);
synthesizeKey("KEY_Backspace", {}, aWindow);
- synthesizeKey("KEY_Backspace", {}, aWindow);
- synthesizeKey("KEY_Backspace", {}, aWindow);
- synthesizeKey("KEY_Backspace", {}, aWindow);
- synthesizeKey("KEY_Backspace", {}, aWindow);
+ return true;
}, popup: false, value: "", searchString: ""
- }
+ },
]
};