mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 20:05:49 +00:00
Bug 1298436 - Don't get caught in an endless loop when narrating last paragraph. r=jaws
MozReview-Commit-ID: 7SMh0MGusgM --HG-- extra : rebase_source : 03f3c0c9d4b3de248f39e7d013e34df0260594a3
This commit is contained in:
parent
ae1f9fd8ec
commit
57a244c4d9
@ -144,8 +144,8 @@ Narrator.prototype = {
|
||||
this._win.speechSynthesis.cancel();
|
||||
let tw = this._treeWalker;
|
||||
let paragraph = tw.currentNode;
|
||||
if (!paragraph) {
|
||||
tw.currentNode = tw.root;
|
||||
if (paragraph == tw.root) {
|
||||
this._sendTestEvent("paragraphsdone", {});
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
@ -193,7 +193,7 @@ Narrator.prototype = {
|
||||
// User pressed stopped.
|
||||
resolve();
|
||||
} else {
|
||||
tw.nextNode();
|
||||
tw.currentNode = tw.nextNode() || tw.root;
|
||||
this._speakInner().then(resolve, reject);
|
||||
}
|
||||
});
|
||||
|
@ -118,9 +118,15 @@ add_task(function* testNarrate() {
|
||||
ok(!NarrateTestUtils.isVisible(popup), "popup is dismissed while speaking");
|
||||
NarrateTestUtils.isStartedState(content, ok);
|
||||
|
||||
promiseEvent = ContentTaskUtils.waitForEvent(content, "paragraphend");
|
||||
$(NarrateTestUtils.STOP).click();
|
||||
yield promiseEvent;
|
||||
// Go forward all the way to the end of the article. We should eventually
|
||||
// stop.
|
||||
do {
|
||||
promiseEvent = Promise.race([
|
||||
ContentTaskUtils.waitForEvent(content, "paragraphstart"),
|
||||
ContentTaskUtils.waitForEvent(content, "paragraphsdone")]);
|
||||
$(NarrateTestUtils.FORWARD).click();
|
||||
} while ((yield promiseEvent).type == "paragraphstart");
|
||||
|
||||
yield ContentTaskUtils.waitForCondition(
|
||||
() => !$(NarrateTestUtils.STOP), "transitioned to stopped state");
|
||||
NarrateTestUtils.isStoppedState(content, ok);
|
||||
|
Loading…
Reference in New Issue
Block a user