зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1486487 - Toggle a label's control in case it's a checkbox; r=dao
Differential Revision: https://phabricator.services.mozilla.com/D4833
This commit is contained in:
Родитель
945900da3d
Коммит
8038c6973e
|
@ -6,6 +6,7 @@ skip-if = os == 'android'
|
|||
support-files =
|
||||
tree_shared.js
|
||||
popup_shared.js
|
||||
window_label_checkbox.xul
|
||||
window_menubar.xul
|
||||
seek_with_sound.ogg
|
||||
|
||||
|
@ -14,6 +15,7 @@ skip-if = os == 'linux' # Bug 1116215
|
|||
[test_contextmenu_menugroup.xul]
|
||||
skip-if = os == 'linux' # Bug 1115088
|
||||
[test_editor_currentURI.xul]
|
||||
[test_label_checkbox.xul]
|
||||
[test_menubar.xul]
|
||||
skip-if = os == 'mac'
|
||||
[test_popupanchor.xul]
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
<?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="Label Checkbox Tests"
|
||||
onload="onLoad()"
|
||||
xmlns:html="http://www.w3.org/1999/xhtml"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<title>Label Checkbox Tests</title>
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
|
||||
<script>
|
||||
ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
function onLoad()
|
||||
{
|
||||
runTest();
|
||||
}
|
||||
|
||||
function runTest()
|
||||
{
|
||||
window.open("window_label_checkbox.xul", "_blank", "width=600,height=600");
|
||||
}
|
||||
|
||||
onmessage = function onMessage()
|
||||
{
|
||||
SimpleTest.finish();
|
||||
}
|
||||
</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>
|
|
@ -0,0 +1,46 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
||||
|
||||
<window title="Label Checkbox Tests" width="200" height="200"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
|
||||
|
||||
<hbox>
|
||||
<label control="checkbox" value="Label" id="label"/>
|
||||
<checkbox id="checkbox"/>
|
||||
<label control="radio2" value="Label" id="label2"/>
|
||||
<radiogroup>
|
||||
<radio/>
|
||||
<radio id="radio2"/>
|
||||
</radiogroup>
|
||||
</hbox>
|
||||
|
||||
<script class="testbody" type="application/javascript">
|
||||
<![CDATA[
|
||||
|
||||
let SimpleTest = opener.SimpleTest;
|
||||
SimpleTest.waitForFocus(() => {
|
||||
let ok = SimpleTest.ok;
|
||||
let label = document.getElementById("label");
|
||||
let checkbox = document.getElementById("checkbox");
|
||||
let label2 = document.getElementById("label2");
|
||||
let radio2 = document.getElementById("radio2");
|
||||
checkbox.checked = true;
|
||||
radio2.selected = false;
|
||||
ok(checkbox.checked, "sanity check");
|
||||
ok(!radio2.selected, "sanity check");
|
||||
setTimeout(() => {
|
||||
synthesizeMouseAtCenter(label, {});
|
||||
ok(!checkbox.checked, "Checkbox should be unchecked");
|
||||
synthesizeMouseAtCenter(label2, {});
|
||||
ok(radio2.selected, "Radio2 should be selected");
|
||||
opener.postMessage("done", "*");
|
||||
window.close();
|
||||
}, 0);
|
||||
});
|
||||
|
||||
]]>
|
||||
</script>
|
||||
|
||||
</window>
|
|
@ -281,11 +281,26 @@
|
|||
</implementation>
|
||||
|
||||
<handlers>
|
||||
<handler event="click" action="if (this.disabled) return;
|
||||
var controlElement = this.labeledControlElement;
|
||||
if(controlElement)
|
||||
controlElement.focus();
|
||||
"/>
|
||||
<handler event="click"><![CDATA[
|
||||
if (this.disabled) {
|
||||
return;
|
||||
}
|
||||
var controlElement = this.labeledControlElement;
|
||||
if (!controlElement) {
|
||||
return;
|
||||
}
|
||||
controlElement.focus();
|
||||
const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
||||
|
||||
if (controlElement.namespaceURI != XUL_NS) {
|
||||
return;
|
||||
}
|
||||
if (controlElement.localName == "checkbox") {
|
||||
controlElement.checked = !controlElement.checked;
|
||||
} else if (controlElement.localName == "radio") {
|
||||
controlElement.control.selectedItem = controlElement;
|
||||
}
|
||||
]]></handler>
|
||||
</handlers>
|
||||
</binding>
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче