Bug 1291839 - Change the Narrate input[type=range] to use 'change' events instead of 'input' events because we are not interested in intermediate values of the slider. r=eeejay

* * *
[mq]: temp

MozReview-Commit-ID: JpGbdSonDTD
This commit is contained in:
Jared Wein 2016-08-16 15:44:15 -04:00
Родитель 2794558914
Коммит f038f5ea4c
2 изменённых файлов: 9 добавлений и 18 удалений

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

@ -121,9 +121,7 @@ function NarrateControls(mm, win) {
dropdown.addEventListener("click", this, true);
let rateRange = dropdown.querySelector("#narrate-rate > input");
rateRange.addEventListener("input", this);
rateRange.addEventListener("mousedown", this);
rateRange.addEventListener("mouseup", this);
rateRange.addEventListener("change", this);
// The rate is stored as an integer.
rateRange.value = branch.getIntPref("rate");
@ -140,17 +138,12 @@ function NarrateControls(mm, win) {
NarrateControls.prototype = {
handleEvent: function(evt) {
switch (evt.type) {
case "mousedown":
this._rateMousedown = true;
break;
case "mouseup":
this._rateMousedown = false;
break;
case "input":
this._onRateInput(evt);
break;
case "change":
this._onVoiceChange();
if (evt.target.id == "narrate-rate-input") {
this._onRateInput(evt);
} else {
this._onVoiceChange();
}
break;
case "click":
this._onButtonClick(evt);
@ -190,10 +183,8 @@ NarrateControls.prototype = {
},
_onRateInput: function(evt) {
if (!this._rateMousedown) {
AsyncPrefs.set("narrate.rate", parseInt(evt.target.value, 10));
this.narrator.setRate(this._convertRate(evt.target.value));
}
AsyncPrefs.set("narrate.rate", parseInt(evt.target.value, 10));
this.narrator.setRate(this._convertRate(evt.target.value));
},
_onVoiceChange: function() {

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

@ -82,7 +82,7 @@ add_task(function* testNarrate() {
promiseEvent = ContentTaskUtils.waitForEvent(content, "paragraphstart");
prefChanged = NarrateTestUtils.waitForPrefChange("narrate.rate");
$(NarrateTestUtils.RATE).focus();
eventUtils.sendKey("PAGE_UP", content);
eventUtils.sendKey("UP", content);
let newspeechinfo = (yield promiseEvent).detail;
is(newspeechinfo.paragraph, speechinfo.paragraph, "same paragraph");
isnot(newspeechinfo.rate, speechinfo.rate, "rate changed");