Change fast/s* and fast/t* files to use pre and post js files in LayoutTests/resources.
[WebKit-https.git] / LayoutTests / fast / speech / scripted / speechrecognition-errors.html
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html>
3 <head>
4 <script src="../../../resources/js-test-pre.js"></script>
5 </head>
6 <body>
7 <script type="text/javascript">
8 description('Test Speech JavaScript API errors');
9
10 function run() {
11     // Check availability of constructors.
12     shouldBeTrue("'webkitSpeechRecognition' in self");
13     shouldBeFalse("webkitSpeechRecognition == null");
14
15     notAllowedTest();
16 }
17
18 function setDefaultHandlers(r) {
19     for (var prop in r) {
20         if (prop.match('^on')) {
21             r[prop] = function() {
22                 testFailed('unexpected ' + event.type + ' event!');
23                 finishJSTest();
24             }
25         }
26     }
27 }
28
29 function notAllowedTest() {
30     debug('\nnotAllowedTest():');
31     var r = new webkitSpeechRecognition();
32     setDefaultHandlers(r);
33     window.count = 0;
34
35     r.start();
36     testRunner.setMockSpeechRecognitionError("NotAllowedError", "not allowed");
37
38     // Check that we get an error event.
39     r.onerror = function() {
40         debug('onerror');
41         shouldBe('count', '0');
42         count++;
43         shouldBeEqualToString('event.error', 'not-allowed');
44         shouldBeEqualToString('event.message', 'not allowed');
45         shouldBeEqualToString('event.type', 'error');
46     }
47
48     // Check that we get an end event after the error event.
49     r.onend = function() {
50         debug('onend');
51         shouldBe('count', '1');
52         finishJSTest();
53     }
54 }
55
56 window.onload = run;
57 window.jsTestIsAsync = true;
58 </script>
59 <script src="../../../resources/js-test-post.js"></script>
60 </body>
61 </html>
62