Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / cssom / cssstyledeclaration-csstext-final-delimiter.html
blob3294c72f4da3703535f544f4accd85a78a767a14
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>CSSOM - CSSStyleDeclaration - Text - Serialization - Delimiters</title>
5 <link rel="author" title="Glenn Adams" href="mailto:glenn@skynav.com"/>
6 <link rel="help" href="http://www.w3.org/TR/cssom/#the-cssstyledeclaration-interface"/>
7 <meta name="flags" content="dom"/>
8 <script src="../resources/testharness.js"></script>
9 <script src="../resources/testharnessreport.js"></script>
10 </head>
11 <body>
12 <div id="log"></div>
13 <div id="box"></div>
14 <script>
15 var style = document.getElementById('box').style;
16 var delim = new RegExp ( /(\s*\;\s*)/ );
18 function countDelimiters(s) {
19 var k = ( s.split(delim).length - 1 ) / 2;
20 return k;
23 function getNthDelimiter(s,n) {
24 if ( n > 0 ) {
25 var sa = s.split(delim);
26 var k = 1;
27 for ( var i in sa ) {
28 var s = sa[i];
29 var m = delim.exec(s);
30 if ( m && ( m.length > 1 ) ) {
31 if ( k++ == n ) {
32 return s;
37 return '';
40 test(function(){
42 style.cssText = "";
43 assert_equals(countDelimiters(style.cssText), 0);
44 assert_equals(getNthDelimiter(style.cssText,0), "");
45 assert_equals(style.cssText, "");
47 }, 'inline style - text - delimiters - zero declarations');
49 test(function(){
51 style.cssText = "left: 10px";
52 assert_equals(countDelimiters(style.cssText), 1);
53 assert_equals(getNthDelimiter(style.cssText,1), ";");
54 assert_equals(style.cssText, "left: 10px;");
56 }, 'inline style - text - delimiters - one declaration');
58 test(function(){
60 style.cssText = "left: 10px; right: 20px";
61 assert_equals(countDelimiters(style.cssText), 2);
62 assert_equals(getNthDelimiter(style.cssText,1), "; ");
63 assert_equals(getNthDelimiter(style.cssText,2), ";");
64 assert_equals(style.cssText, "left: 10px; right: 20px;");
66 }, 'inline style - text - delimiters - two declarations');
67 </script>
68 </body>
69 </html>