зеркало из https://github.com/mozilla/gecko-dev.git
Bug 441530 Toolkit autocomplete sets the nomatch attribute on the popup rather than the textbox. r=enndeakin
This commit is contained in:
Родитель
e99311aec3
Коммит
b50c36eb2c
|
@ -64,6 +64,7 @@ _TEST_FILES = findbar_window.xul \
|
|||
frame_popup_anchor.xul \
|
||||
test_preferences.xul \
|
||||
window_preferences.xul \
|
||||
test_autocomplete2.xul \
|
||||
$(NULL)
|
||||
|
||||
ifeq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
|
||||
|
|
|
@ -0,0 +1,117 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
|
||||
|
||||
<window title="Autocomplete Widget Test 2"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/MochiKit/packed.js"/>
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
|
||||
|
||||
<textbox id="autocomplete" type="autocomplete"
|
||||
autocompletesearch="simple"
|
||||
onsearchcomplete="checkResult();"/>
|
||||
|
||||
<script class="testbody" type="application/javascript">
|
||||
<![CDATA[
|
||||
|
||||
// Set to indicate whether or not we want autoCompleteSimple to return a result
|
||||
var returnResult = false;
|
||||
|
||||
// A basic autocomplete implementation that either returns one result or none
|
||||
var autoCompleteSimpleID = Components.ID("0a2afbdb-f30e-47d1-9cb1-0cd160240aca");
|
||||
var autoCompleteSimpleName = "@mozilla.org/autocomplete/search;1?name=simple"
|
||||
var autoCompleteSimple = {
|
||||
QueryInterface: function(iid) {
|
||||
if (iid.equals(Components.interfaces.nsISupports) ||
|
||||
iid.equals(Components.interfaces.nsIFactory) ||
|
||||
iid.equals(Components.interfaces.nsIAutoCompleteSearch))
|
||||
return this;
|
||||
|
||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
||||
},
|
||||
|
||||
createInstance: function(outer, iid) {
|
||||
return this.QueryInterface(iid);
|
||||
},
|
||||
|
||||
startSearch: function(aString, aParam, aResult, aListener) {
|
||||
const ACR = Components.interfaces.nsIAutoCompleteResult;
|
||||
|
||||
var result = {
|
||||
searchString: aString,
|
||||
searchResult: returnResult ? ACR.RESULT_SUCCESS : ACR.RESULT_FAILURE,
|
||||
defaultIndex: -1,
|
||||
errorDescription: null,
|
||||
matchCount: returnResult ? 1 : 0,
|
||||
getValueAt: function() { return returnResult ? "result" : ""; },
|
||||
getCommentAt: function() { return null; },
|
||||
getStyleAt: function() { return null; },
|
||||
getImageAt: function() { return null; },
|
||||
removeValueAt: function() {}
|
||||
};
|
||||
aListener.onSearchResult(this, result);
|
||||
},
|
||||
|
||||
stopSearch: function() {}
|
||||
};
|
||||
|
||||
var componentManager = Components.manager
|
||||
.QueryInterface(Components.interfaces.nsIComponentRegistrar);
|
||||
componentManager.registerFactory(autoCompleteSimpleID, "Test Simple Autocomplete",
|
||||
autoCompleteSimpleName, autoCompleteSimple);
|
||||
|
||||
|
||||
// The main test code.
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
setTimeout(check, 0);
|
||||
|
||||
function check() {
|
||||
var autocomplete = $("autocomplete");
|
||||
|
||||
// Toggle this value, so we can re-use the one function.
|
||||
returnResult = !returnResult;
|
||||
|
||||
autocomplete.focus();
|
||||
synthesizeKey("r", {});
|
||||
}
|
||||
|
||||
function checkResult() {
|
||||
var autocomplete = $("autocomplete");
|
||||
|
||||
if (returnResult) {
|
||||
// Result was returned, so there should not be a nomatch attribute
|
||||
is(autocomplete.hasAttribute("nomatch"), false,
|
||||
"nomatch attribute shouldn't be present here");
|
||||
setTimeout(check, 0);
|
||||
}
|
||||
else {
|
||||
// No result was returned, so there should be nomatch attribute
|
||||
is(autocomplete.getAttribute("nomatch"), "true",
|
||||
"nomatch attribute not correctly set when expected");
|
||||
setTimeout(function() {
|
||||
// Unregister the factory so that we don't get in the way of other tests
|
||||
componentManager.unregisterFactory(autoCompleteSimpleID, autoCompleteSimple);
|
||||
SimpleTest.finish();
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
|
||||
]]>
|
||||
</script>
|
||||
|
||||
<body xmlns="http://www.w3.org/1999/xhtml">
|
||||
<p id="display">
|
||||
</p>
|
||||
<div id="content" style="display: none">
|
||||
</div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
</body>
|
||||
|
||||
</window>
|
|
@ -210,9 +210,9 @@
|
|||
<method name="onSearchComplete">
|
||||
<body><![CDATA[
|
||||
if (this.mController.matchCount == 0)
|
||||
this.popup.setAttribute("nomatch", "true");
|
||||
this.setAttribute("nomatch", "true");
|
||||
else
|
||||
this.popup.removeAttribute("nomatch");
|
||||
this.removeAttribute("nomatch");
|
||||
|
||||
this.fireEvent("searchcomplete");
|
||||
]]></body>
|
||||
|
|
Загрузка…
Ссылка в новой задаче