Skip to content

SpeechSynthesis.speak requires activation - #12327

Merged
foolip merged 6 commits into
web-platform-tests:masterfrom
csharrison:speech-autoplay
Aug 9, 2018
Merged

foolip merged 6 commits into
web-platform-tests:masterfrom
csharrison:speech-autoplay

Conversation

@csharrison

Copy link
Copy Markdown
Contributor

To be merged with WebAudio/web-speech-api#28 if it ends up with normative changes involving user activation.

CC @foolip

<script>
// using an utterance for different SpeechSynthesis instances should throw
test(t => {
var t = async_test(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous test(f(t), name) structure works for async_test as well, just change test to async_test.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

test(t => {
var t = async_test(
'Using the same SpeechSynthesisUtterance with two SpeechSynthesis instances');
test_driver.click(document.body).then(t.step_func(() => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you use test_driver.bless, this test will be easier to run manually. (Caveat: I haven't tried it myself.)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

var t = async_test('speechSynthesis.speak requires user activation');
const utter = new SpeechSynthesisUtterance('1');
utter.onerror = t.step_func_done((e) => {
assert_equals(e.name, "not-allowed");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great test, thank you!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:)

<p>Some body text.
<script>
var t = async_test('speechSynthesis.speak requires user activation');
const utter = new SpeechSynthesisUtterance('1');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use the async_test(f(n), name) structure here as well? The reason is that if new SpeechSynthesisUtterance('1') throws an exception in the current structure, it would be a harness error plus a test that times out, instead of a failing test. Putting all the interesting code inside the first callback or in t.step_func for callbacks avoids this kind of problem.

@@ -0,0 +1,13 @@
<!doctype html>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed in WebAudio/web-speech-api#28 (comment), maybe make this test tenatative (name it "SpeechSynthesis-speak-without-activation-fails.tentative.html") and link to an open issue in the speech-api repo.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@csharrison

Copy link
Copy Markdown
Contributor Author

Thanks for the review, Philip!

@foolip foolip left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM % nits

iframe.contentWindow.speechSynthesis.speak(utter);
});
async_test(t => {
test_driver.bless('speechSynthesis.speak', t.step_func(() => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, looks like this test will never finish, using t.step_func_done here would fix it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Also changed some of the other tests to use t.step_func as arguments to bless(), which I think is needed.

<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<p>Some body text.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You probably don't need this text now that you're using test_driver.bless instead. Ditto in following tests.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually we still need it, since bless requires the document body to be around.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, if that's all you need then <body> would be clearer. Plenty of tests to that ahead of doing something with document.body.

@csharrison

Copy link
Copy Markdown
Contributor Author

Hey Philip, is there anything else blocking merging this and the associated spec PR?

@foolip

foolip commented Aug 9, 2018

Copy link
Copy Markdown
Member

I made the <body> changes? Can you check that the tests still work? Then I'll merge.

@csharrison

Copy link
Copy Markdown
Contributor Author

I confirmed the tests are working properly, thanks for the quick fixes.

foolip pushed a commit to WebAudio/web-speech-api that referenced this pull request Aug 9, 2018
@foolip
foolip merged commit d79d572 into web-platform-tests:master Aug 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants