зеркало из https://github.com/mozilla/gecko-dev.git
Bug 377687, ensure progressmeter value is between 0-100, minor cleanup and add test, r=mano
This commit is contained in:
Родитель
5441048693
Коммит
75eeeb31df
|
@ -52,6 +52,7 @@ _TEST_FILES = bug288254_window.xul \
|
||||||
test_bug366992.xul \
|
test_bug366992.xul \
|
||||||
bug331215_window.xul \
|
bug331215_window.xul \
|
||||||
test_bug331215.xul \
|
test_bug331215.xul \
|
||||||
|
widget_progressmeter.xul \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
libs:: $(_TEST_FILES)
|
libs:: $(_TEST_FILES)
|
||||||
|
|
|
@ -0,0 +1,74 @@
|
||||||
|
<?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 progressmeter
|
||||||
|
-->
|
||||||
|
<window title="Progressmeter" width="500" height="600"
|
||||||
|
onload="doTests()"
|
||||||
|
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||||
|
<script type="application/javascript"
|
||||||
|
src="chrome://mochikit/content/MochiKit/packed.js"></script>
|
||||||
|
<script type="application/javascript"
|
||||||
|
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||||
|
|
||||||
|
<progressmeter id="n1"/>
|
||||||
|
<progressmeter id="n2" mode="undetermined"/>
|
||||||
|
|
||||||
|
<!-- test resuls are displayed in the html:body -->
|
||||||
|
<body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
|
||||||
|
|
||||||
|
<!-- test code goes here -->
|
||||||
|
<script type="application/javascript"><![CDATA[
|
||||||
|
// ise - is exact - compares using ===
|
||||||
|
function ise(left, right, name) { SimpleTest.ok(left === right, name); }
|
||||||
|
|
||||||
|
SimpleTest.waitForExplicitFinish();
|
||||||
|
|
||||||
|
function doTests() {
|
||||||
|
var n1 = document.getElementById("n1");
|
||||||
|
var n2 = document.getElementById("n2");
|
||||||
|
|
||||||
|
ise(n1.mode, "", "mode determined");
|
||||||
|
ise(n2.mode, "undetermined", "mode undetermined");
|
||||||
|
|
||||||
|
ise(n1.value, "0", "determined value");
|
||||||
|
ise(n2.value, "0", "undetermined value");
|
||||||
|
|
||||||
|
// values can only be incremented in multiples of 4
|
||||||
|
n1.value = 2;
|
||||||
|
ise(n1.value, "0", "determined value set 2");
|
||||||
|
n1.value = -1;
|
||||||
|
ise(n1.value, "0", "determined value set -1");
|
||||||
|
n1.value = 125;
|
||||||
|
ise(n1.value, "100", "determined value set 125");
|
||||||
|
n1.value = 7;
|
||||||
|
ise(n1.value, "7", "determined value set 7");
|
||||||
|
n1.value = "17";
|
||||||
|
ise(n1.value, "17", "determined value set 17 string");
|
||||||
|
n1.value = 18;
|
||||||
|
ise(n1.value, "17", "determined value set 18");
|
||||||
|
n1.value = "Cat";
|
||||||
|
ise(n1.value, "17", "determined value set invalid");
|
||||||
|
|
||||||
|
n2.value = 2;
|
||||||
|
ise(n2.value, "0", "undetermined value set 2");
|
||||||
|
n2.value = -1;
|
||||||
|
ise(n2.value, "0", "undetermined value set -1");
|
||||||
|
n2.value = 125;
|
||||||
|
ise(n2.value, "100", "undetermined value set 125");
|
||||||
|
n2.value = 7;
|
||||||
|
ise(n2.value, "7", "undetermined value set 7");
|
||||||
|
n2.value = "17";
|
||||||
|
ise(n2.value, "17", "undetermined value set 17 string");
|
||||||
|
n2.value = 18;
|
||||||
|
ise(n2.value, "17", "undetermined value set 18");
|
||||||
|
n2.value = "Cat";
|
||||||
|
ise(n2.value, "17", "determined value set invalid");
|
||||||
|
|
||||||
|
SimpleTest.finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
]]></script>
|
||||||
|
|
||||||
|
</window>
|
|
@ -16,15 +16,16 @@
|
||||||
</content>
|
</content>
|
||||||
|
|
||||||
<implementation implements="nsIAccessibleProvider">
|
<implementation implements="nsIAccessibleProvider">
|
||||||
<property name="label" onset="if (this.label != val) this.setAttribute('label',val); return val;"
|
|
||||||
onget="return this.getAttribute('label');"/>
|
|
||||||
|
|
||||||
<property name="mode" onset="if (this.mode != val) this.setAttribute('mode', val); return val;"
|
<property name="mode" onset="if (this.mode != val) this.setAttribute('mode', val); return val;"
|
||||||
onget="return this.getAttribute('mode');"/>
|
onget="return this.getAttribute('mode');"/>
|
||||||
|
|
||||||
<property name="value" onget="return this.getAttribute('value');">
|
<property name="value" onget="return this.getAttribute('value') || '0';">
|
||||||
<setter><![CDATA[
|
<setter><![CDATA[
|
||||||
var p = Math.round(val);
|
var p = Math.round(val);
|
||||||
|
if (p < 0)
|
||||||
|
p = 0;
|
||||||
|
else if (p > 100)
|
||||||
|
p = 100;
|
||||||
var c = this.value;
|
var c = this.value;
|
||||||
if (p != c) {
|
if (p != c) {
|
||||||
var delta = p - c;
|
var delta = p - c;
|
||||||
|
@ -39,7 +40,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return p;
|
return val;
|
||||||
]]></setter>
|
]]></setter>
|
||||||
</property>
|
</property>
|
||||||
|
|
||||||
|
@ -62,7 +63,7 @@
|
||||||
</content>
|
</content>
|
||||||
|
|
||||||
<implementation>
|
<implementation>
|
||||||
<method name="init">
|
<method name="_init">
|
||||||
<body><![CDATA[
|
<body><![CDATA[
|
||||||
var stack = document.getAnonymousElementByAttribute(this, "anonid", "stack");
|
var stack = document.getAnonymousElementByAttribute(this, "anonid", "stack");
|
||||||
var spacer = document.getAnonymousElementByAttribute(this, "anonid", "spacer");
|
var spacer = document.getAnonymousElementByAttribute(this, "anonid", "spacer");
|
||||||
|
@ -94,7 +95,7 @@
|
||||||
]]></body>
|
]]></body>
|
||||||
</method>
|
</method>
|
||||||
|
|
||||||
<constructor>this.init();</constructor>
|
<constructor>this._init();</constructor>
|
||||||
</implementation>
|
</implementation>
|
||||||
</binding>
|
</binding>
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче