mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 440334: Focus does not jump to find toolbar when certain form inputs are focused (non-editable nsIDOMNSEditableElements), r=mano
--HG-- rename : toolkit/content/tests/chrome/bug288254_window.xul => toolkit/content/tests/chrome/findbar_window.xul rename : toolkit/content/tests/chrome/test_bug288254.xul => toolkit/content/tests/chrome/test_findbar.xul
This commit is contained in:
parent
b0c2538c12
commit
5fb38514e3
@ -44,8 +44,8 @@ relativesrcdir = toolkit/content/tests/chrome
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
_TEST_FILES = bug288254_window.xul \
|
||||
test_bug288254.xul \
|
||||
_TEST_FILES = findbar_window.xul \
|
||||
test_findbar.xul \
|
||||
test_bug253481.xul \
|
||||
bug304188_window.xul \
|
||||
test_bug304188.xul \
|
||||
|
@ -52,6 +52,8 @@
|
||||
const Cr = Components.results;
|
||||
|
||||
const SAMPLE_URL = "http://www.mozilla.org/";
|
||||
const SAMPLE_TEXT = "Some text in a text field.";
|
||||
const SEARCH_TEXT = "Text Test";
|
||||
|
||||
var gFindBar = null;
|
||||
var gBrowser;
|
||||
@ -95,7 +97,7 @@
|
||||
gFindBar = document.getElementById("FindToolbar");
|
||||
gBrowser = document.getElementById("content");
|
||||
gBrowser.addEventListener("pageshow", onPageShow, false);
|
||||
gBrowser.loadURI("data:text/html,<h2>Text Test</h2><h2><a href='" + SAMPLE_URL + "'>Link Test</a></h2>");
|
||||
gBrowser.loadURI("data:text/html,<h2 id='h2'>" + SEARCH_TEXT + "</h2><h2><a href='" + SAMPLE_URL + "'>Link Test</a></h2><input id='text' type='text' value='" + SAMPLE_TEXT + "'></input><input id='button' type='button'></input>");
|
||||
}
|
||||
setTimeout(_delayedOnLoad, 1000);
|
||||
}
|
||||
@ -108,11 +110,47 @@
|
||||
testQuickFindText();
|
||||
gFindBar.close();
|
||||
ok(gFindBar.hidden, "Failed to close findbar after testQuickFindText");
|
||||
testFindbarSelection();
|
||||
testQuickFindLink();
|
||||
testStatusText();
|
||||
testQuickFindClose();
|
||||
}
|
||||
|
||||
function testFindbarSelection() {
|
||||
function checkFindbarState(aTestName, aExpSelection) {
|
||||
document.getElementById("cmd_find").doCommand();
|
||||
ok(!gFindBar.hidden, "testFindbarSelection: failed to open findbar: " + aTestName);
|
||||
ok(document.commandDispatcher.focusedElement == gFindBar._findField.inputField,
|
||||
"testFindbarSelection: find field is not focused: " + aTestName);
|
||||
ok(gFindBar._findField.value == aExpSelection,
|
||||
"Incorrect selection in testFindbarSelection: " + aTestName + ". Selection: " + gFindBar._findField.value);
|
||||
|
||||
// Clear the value, close the findbar
|
||||
gFindBar._findField.value = "";
|
||||
gFindBar.close();
|
||||
}
|
||||
|
||||
// test normal selected text
|
||||
var cH2 = gBrowser.contentDocument.getElementById("h2");
|
||||
var cSelection = gBrowser.contentDocument.defaultView.getSelection();
|
||||
var cRange = gBrowser.contentDocument.createRange();
|
||||
cRange.setStart(cH2, 0);
|
||||
cRange.setEnd(cH2, 1);
|
||||
cSelection.removeAllRanges();
|
||||
cSelection.addRange(cRange);
|
||||
checkFindbarState("plain text", SEARCH_TEXT);
|
||||
|
||||
// test nsIDOMNSEditableElement with selection
|
||||
var textInput = gBrowser.contentDocument.getElementById("text");
|
||||
textInput.focus();
|
||||
textInput.select();
|
||||
checkFindbarState("text input", SAMPLE_TEXT);
|
||||
|
||||
// test non-editable nsIDOMNSEditableElement (button)
|
||||
gBrowser.contentDocument.getElementById("button").focus();
|
||||
checkFindbarState("button", "");
|
||||
}
|
||||
|
||||
function testQuickFindClose() {
|
||||
var _isClosedCallback = function() {
|
||||
ok(gFindBar.hidden,
|
||||
@ -142,7 +180,7 @@
|
||||
// also test match-case
|
||||
function testNormalFind() {
|
||||
document.getElementById("cmd_find").doCommand();
|
||||
|
||||
|
||||
ok(!gFindBar.hidden, "testNormalFind: failed to open findbar");
|
||||
ok(document.commandDispatcher.focusedElement == gFindBar._findField.inputField,
|
||||
"testNormalFind: find field is not focused");
|
||||
@ -231,10 +269,9 @@
|
||||
ok(document.commandDispatcher.focusedElement == gFindBar._findField.inputField,
|
||||
"testQuickFindText: find field is not focused");
|
||||
|
||||
var searchStr = "Text Test";
|
||||
enterStringIntoFindField(searchStr);
|
||||
ok(gBrowser.contentWindow.getSelection() == searchStr,
|
||||
"testQuickFindText: failed to find '" + searchStr + "'");
|
||||
enterStringIntoFindField(SEARCH_TEXT);
|
||||
ok(gBrowser.contentWindow.getSelection() == SEARCH_TEXT,
|
||||
"testQuickFindText: failed to find '" + SEARCH_TEXT + "'");
|
||||
}
|
||||
]]></script>
|
||||
|
@ -32,12 +32,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=288254
|
||||
|
||||
/** Test for Bug 288254 **/
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
window.open("bug288254_window.xul", "findbartest",
|
||||
window.open("findbar_window.xul", "findbartest",
|
||||
"chrome,width=600,height=600");
|
||||
|
||||
|
||||
|
||||
|
||||
]]>
|
||||
</script>
|
||||
|
@ -1216,7 +1216,8 @@
|
||||
var selText;
|
||||
|
||||
if (focusedElement instanceof Components.interfaces.nsIDOMNSEditableElement &&
|
||||
focusedElement.ownerDocument.defaultView.top == this._browser.contentWindow)
|
||||
focusedElement.editor &&
|
||||
focusedElement.ownerDocument.defaultView.top == this._browser.contentWindow)
|
||||
{
|
||||
// The user may have a selection in an input or textarea
|
||||
selText = focusedElement.editor.selectionController
|
||||
|
Loading…
Reference in New Issue
Block a user