Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / speech / scripted / start-exception.html
blobc21ff433696c6281b4c1c99a2548cdb2e5b66819
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html>
3 <head>
4 <script src="../../../resources/js-test.js"></script>
5 </head>
6 <body>
7 <script type="text/javascript">
8 description('Test getting an exception when calling start() in the Speech JavaScript API');
10 function run() {
11 // Check availability of constructors.
12 shouldBeTrue("'webkitSpeechRecognition' in self");
13 shouldBeFalse("webkitSpeechRecognition == null");
15 doubleStart();
18 function doubleStart() {
19 debug('\ndoubleStart():');
20 evalAndLog("window.r = new webkitSpeechRecognition()");
22 // Set default handlers.
23 for (var prop in r) {
24 if (prop.match('^on')) {
25 r[prop] = function() {
26 debug('on' + event.type);
28 if (event.type === 'end') {
29 shouldNotThrow("r.start()");
30 evalAndLog("r.abort()");
32 r.onend = function() {
33 debug('onend');
34 finishJSTest();
36 } else {
37 shouldThrow("r.start()", '"InvalidStateError: Failed to execute \'start\' on \'SpeechRecognition\': recognition has already started."');
43 shouldNotThrow("r.start()");
44 shouldThrow("r.start()", '"InvalidStateError: Failed to execute \'start\' on \'SpeechRecognition\': recognition has already started."');
47 window.onload = run;
48 window.jsTestIsAsync = true;
49 </script>
50 </body>
51 </html>