Bug 1291837 - Wind all the way back when pressing previous in Narrate. r=jaws

MozReview-Commit-ID: 7dbbPPXHPuX

--HG--
extra : rebase_source : 7a3ad1eaa8e1c3d37d7db85a979546cf2aef2499
This commit is contained in:
Eitan Isaacson 2016-08-03 10:40:58 -07:00
parent 7043587cd4
commit 4ab986dd19
2 changed files with 19 additions and 9 deletions

View File

@ -240,25 +240,28 @@ Narrator.prototype = {
},
skipPrevious: function() {
let tw = this._treeWalker;
tw.previousNode();
if (this._timeIntoParagraph < PREV_THRESHOLD) {
tw.previousNode();
}
this._win.speechSynthesis.cancel();
this._goBackParagraphs(this._timeIntoParagraph < PREV_THRESHOLD ? 2 : 1);
},
setRate: function(rate) {
this._speechOptions.rate = rate;
/* repeat current paragraph */
this._treeWalker.previousNode();
this._win.speechSynthesis.cancel();
this._goBackParagraphs(1);
},
setVoice: function(voice) {
this._speechOptions.voice = this._getVoice(voice);
/* repeat current paragraph */
this._treeWalker.previousNode();
this._goBackParagraphs(1);
},
_goBackParagraphs: function(count) {
let tw = this._treeWalker;
for (let i = 0; i < count; i++) {
if (!tw.previousNode()) {
tw.currentNode = tw.root;
}
}
this._win.speechSynthesis.cancel();
}
};

View File

@ -57,6 +57,13 @@ add_task(function* testNarrate() {
NarrateTestUtils.isStartedState(content, ok);
promiseEvent = ContentTaskUtils.waitForEvent(content, "paragraphstart");
$(NarrateTestUtils.BACK).click();
speechinfo = (yield promiseEvent).detail;
is(speechinfo.paragraph, paragraph, "first paragraph being spoken");
NarrateTestUtils.isStartedState(content, ok);
let eventUtils = NarrateTestUtils.getEventUtils(content);
promiseEvent = ContentTaskUtils.waitForEvent(content, "paragraphstart");