Bug 967432, labelElement should still be set even when an access key is not present, r=neil

This commit is contained in:
Neil Deakin 2014-02-11 09:40:12 -05:00
Родитель 285a3a25dd
Коммит 76d49131f7
3 изменённых файлов: 56 добавлений и 11 удалений

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

@ -95,6 +95,7 @@ skip-if = os == "win" # Intermittent failures, bug 919016
[test_hiddenitems.xul]
[test_hiddenpaging.xul]
[test_keys.xul]
[test_labelcontrol.xul]
[test_largemenu.xul]
[test_menu.xul]
[test_menu_anchored.xul]

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

@ -0,0 +1,44 @@
<?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"?>
<!--
XUL Widget Test for label control="value"
-->
<window title="tabindex" width="500" height="600"
onload="runTests()"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
<label id="lab" control="ctl"/>
<textbox id="ctl" value="Test"/>
<checkbox id="chk" value="Checkbox"/>
<body xmlns="http://www.w3.org/1999/xhtml">
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
</pre>
</body>
<script>
<![CDATA[
SimpleTest.waitForExplicitFinish();
function runTests()
{
is($("lab").control, "ctl", "control");
is($("lab").labeledControlElement, $("ctl"), "labeledControlElement");
is($("ctl").labelElement, $("lab"), "labelElement");
is($("chk").labelElement.className, "checkbox-label", "labelElement");
SimpleTest.finish();
}
]]>
</script>
</window>

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

@ -67,6 +67,17 @@
<parameter name="firstTime"/>
<body>
<![CDATA[
var control = this.labeledControlElement;
if (!control) {
var bindingParent = document.getBindingParent(this);
if (bindingParent instanceof Components.interfaces.nsIDOMXULLabeledControlElement) {
control = bindingParent; // For controls that make the <label> an anon child
}
}
if (control) {
control.labelElement = this;
}
var accessKey = this.accessKey;
// No need to remove existing formatting the first time.
if (firstTime && !accessKey)
@ -102,17 +113,6 @@
if (!this.mUnderlineAccesskey)
return;
var control = this.labeledControlElement;
if (!control) {
var bindingParent = document.getBindingParent(this);
if (bindingParent instanceof Components.interfaces.nsIDOMXULLabeledControlElement) {
control = bindingParent; // For controls that make the <label> an anon child
}
}
if (control) {
control.labelElement = this;
}
var afterLabel = document.getAnonymousElementByAttribute(this, "anonid", "accessKeyParens");
afterLabel.textContent = "";