Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / speech / scripted / speechgrammar-basics.html
blob81a39bf9418e33fd0881f87cbd4ba74bb9cc3bdc
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('Tests the basics of SpeechGrammar and SpeechGrammarList');
10 function run() {
11 window.base = document.baseURI.substring(0, document.baseURI.lastIndexOf('/') + 1);
13 // Check availability of constructors.
14 shouldBeTrue("'webkitSpeechGrammar' in window");
15 shouldBeFalse("webkitSpeechGrammar == null");
16 shouldBeTrue("'webkitSpeechGrammarList' in window");
17 shouldBeFalse("webkitSpeechGrammarList == null");
19 // Test creating a grammar explicitly.
20 evalAndLog("window.g = new webkitSpeechGrammar()");
21 shouldBeFalse("g == null");
22 shouldBe("g.weight", "1.0");
23 shouldBe("g.src", "''");
25 // Test setting the attributes.
26 evalAndLog("g.weight = 2");
27 shouldBe("g.weight", "2.0");
28 shouldThrow("g.weight = NaN");
29 shouldThrow("g.weight = Infinity");
30 shouldBe("g.weight", "2.0");
31 evalAndLog("g.src = 'grammar.xml'");
32 shouldBe("g.src", "base + 'grammar.xml'");
33 evalAndLog("g.src = 'http://example.tld/grammar.xml'");
34 shouldBe("g.src", "'http://example.tld/grammar.xml'");
35 evalAndLog("g.src = 'foo bar'");
36 shouldBe("g.src", "base + 'foo%20bar'");
38 // Test creating a grammar list.
39 evalAndLog("window.gs = new webkitSpeechGrammarList()");
40 shouldBeFalse("gs == null");
41 shouldBe("gs.length", "0");
42 shouldBeTrue("gs.item(0) == null");
43 shouldBeTrue("gs[0] == undefined");
44 shouldBeNull("gs.item(-1)");
45 shouldBeTrue("gs[-1] == undefined");
47 evalAndLog("gs.addFromUri('grammar', 2)");
48 shouldBe("gs.length", "1");
49 shouldBeTrue("gs.item(1) == null");
50 shouldBeTrue("gs[1] == undefined");
51 shouldBeNull("gs.item(-1)");
52 shouldBeTrue("gs[-1] == undefined");
53 shouldBe("gs[0]", "gs.item(0)");
54 shouldBe("gs.item(0).src", "base + 'grammar'");
55 shouldBe("gs.item(0).weight", "2");
57 evalAndLog("gs.addFromUri('http://foo.tld/grammar.xml', 3)");
58 shouldBe("gs.length", "2");
59 shouldBe("gs[1]", "gs.item(1)");
60 shouldBe("gs.item(1).src", "'http://foo.tld/grammar.xml'");
61 shouldBe("gs.item(1).weight", "3");
63 evalAndLog("gs.addFromString('<grammar>foo</grammar>', 4)");
64 shouldBe("gs.length", "3");
65 shouldBe("gs[2]", "gs.item(2)");
66 shouldBe("gs.item(2).src", "'data:application/xml,%3Cgrammar%3Efoo%3C/grammar%3E'");
67 shouldBe("gs.item(2).weight", "4");
68 shouldBe("gs[2].src", "'data:application/xml,%3Cgrammar%3Efoo%3C/grammar%3E'");
69 shouldBe("gs[2].weight", "4");
71 shouldThrow("gs.addFromUri('http://foo.tld/grammar.xml', NaN)");
72 shouldThrow("gs.addFromUri('http://foo.tld/grammar.xml', Infinity)");
73 shouldThrow("gs.addFromString('foo', NaN)");
74 shouldThrow("gs.addFromString('foo', Infinity)");
76 finishJSTest();
79 window.onload = run;
80 window.jsTestIsAsync = true;
81 </script>
82 </body>
83 </html>