зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1255261 - Read current paragraph after pressing stop. r=jaws
We always had to make sure we were one paragraph back from where we wanted to start. That seems broken. I made it so that we start from the current paragraph. MozReview-Commit-ID: 4HMTdXcF644
This commit is contained in:
Родитель
757d82e0ba
Коммит
5123fa44ad
|
@ -143,7 +143,7 @@ Narrator.prototype = {
|
|||
_speakInner: function() {
|
||||
this._win.speechSynthesis.cancel();
|
||||
let tw = this._treeWalker;
|
||||
let paragraph = tw.nextNode();
|
||||
let paragraph = tw.currentNode;
|
||||
if (!paragraph) {
|
||||
tw.currentNode = tw.root;
|
||||
return Promise.resolve();
|
||||
|
@ -193,6 +193,7 @@ Narrator.prototype = {
|
|||
// User pressed stopped.
|
||||
resolve();
|
||||
} else {
|
||||
tw.nextNode();
|
||||
this._speakInner().then(resolve, reject);
|
||||
}
|
||||
});
|
||||
|
@ -216,14 +217,10 @@ Narrator.prototype = {
|
|||
let tw = this._treeWalker;
|
||||
if (!this._isParagraphInView(tw.currentNode)) {
|
||||
tw.currentNode = tw.root;
|
||||
while (tw.nextNode()) {
|
||||
if (this._isParagraphInView(tw.currentNode)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// _speakInner will advance to the next node for us, so we need
|
||||
// to have it one paragraph back from the first visible one.
|
||||
tw.previousNode();
|
||||
while (tw.nextNode() && !this._isParagraphInView(tw.currentNode)) {}
|
||||
}
|
||||
if (tw.currentNode == tw.root) {
|
||||
tw.nextNode();
|
||||
}
|
||||
|
||||
return this._speakInner();
|
||||
|
|
|
@ -64,6 +64,19 @@ add_task(function* testNarrate() {
|
|||
|
||||
NarrateTestUtils.isStartedState(content, ok);
|
||||
|
||||
paragraph = speechinfo.paragraph;
|
||||
$(NarrateTestUtils.STOP).click();
|
||||
yield ContentTaskUtils.waitForCondition(
|
||||
() => !$(NarrateTestUtils.STOP), "transitioned to stopped state");
|
||||
NarrateTestUtils.isStoppedState(content, ok);
|
||||
|
||||
promiseEvent = ContentTaskUtils.waitForEvent(content, "paragraphstart");
|
||||
$(NarrateTestUtils.START).click();
|
||||
speechinfo = (yield promiseEvent).detail;
|
||||
is(speechinfo.paragraph, paragraph, "read same paragraph again");
|
||||
|
||||
NarrateTestUtils.isStartedState(content, ok);
|
||||
|
||||
let eventUtils = NarrateTestUtils.getEventUtils(content);
|
||||
|
||||
promiseEvent = ContentTaskUtils.waitForEvent(content, "paragraphstart");
|
||||
|
|
Загрузка…
Ссылка в новой задаче