Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / dom / script-tests / dataset-xhtml.js
blob839b74d6aba9372c54e4466ff07d7fec495e41d3
1 description("This tests element.dataset for XHTML.");
3 function testGet(attr, expected)
5 var d = document.createElement("div");
6 d.setAttribute(attr, "value");
7 return d.dataset[expected] == "value";
10 shouldBeTrue("testGet('data-foo', 'foo')");
11 shouldBeTrue("testGet('data-foo-bar', 'fooBar')");
12 shouldBeTrue("testGet('data--', '-')");
13 shouldBeTrue("testGet('data--foo', 'Foo')");
14 shouldBeTrue("testGet('data---foo', '-Foo')");
15 shouldBeTrue("testGet('data-', '')");
16 shouldBeTrue("testGet('data-\xE0', '\xE0')");
17 debug("");
19 function matchesNothingInDataset(attr)
21 var d = document.createElement("div");
22 d.setAttribute(attr, "value");
24 var count = 0;
25 for (var item in d.dataset)
26 count++;
27 return count == 0;
30 shouldBeTrue("matchesNothingInDataset('dataFoo')");
31 shouldBeTrue("matchesNothingInDataset('data-Foo')");
32 debug("");
34 function testSet(prop, expected)
36 var d = document.createElement("div");
37 d.dataset[prop] = "value";
38 return d.getAttribute(expected) == "value";
41 shouldBeTrue("testSet('foo', 'data-foo')");
42 shouldBeTrue("testSet('fooBar', 'data-foo-bar')");
43 shouldBeTrue("testSet('-', 'data--')");
44 shouldBeTrue("testSet('Foo', 'data--foo')");
45 shouldBeTrue("testSet('-Foo', 'data---foo')");
46 shouldBeTrue("testSet('', 'data-')");
47 shouldBeTrue("testSet('\xE0', 'data-\xE0')");
48 debug("");
50 shouldThrow("testSet('-foo', 'dummy')", '"SyntaxError: Failed to set the \'-foo\' property on \'DOMStringMap\': \'-foo\' is not a valid property name."');
51 shouldThrow("testSet('foo\x20', 'dummy')", '"InvalidCharacterError: Failed to set the \'foo\x20\' property on \'DOMStringMap\': \'data-foo\x20\' is not a valid attribute name."');
52 shouldThrow("testSet('foo\uF900', 'dummy')", '"InvalidCharacterError: Failed to set the \'foo\uF900\' property on \'DOMStringMap\': \'data-foo\uF900\' is not a valid attribute name."');
53 debug("");
55 function testDelete(attr, prop)
57 var d = document.createElement("div");
58 d.setAttribute(attr, "value");
59 delete d.dataset[prop];
60 return d.getAttribute(attr) != "value";
63 shouldBeTrue("testDelete('data-foo', 'foo')");
64 shouldBeTrue("testDelete('data-foo-bar', 'fooBar')");
65 shouldBeTrue("testDelete('data--', '-')");
66 shouldBeTrue("testDelete('data--foo', 'Foo')");
67 shouldBeTrue("testDelete('data---foo', '-Foo')");
68 shouldBeTrue("testDelete('data-', '')");
69 shouldBeTrue("testDelete('data-\xE0', '\xE0')");
70 debug("");
72 shouldBeFalse("testDelete('dummy', '-foo')");
73 debug("");
75 function testForIn(array)
77 var d = document.createElement("div");
78 for (var i = 0; i < array.length; ++i) {
79 d.setAttribute(array[i], "value");
82 var count = 0;
83 for (var item in d.dataset)
84 count++;
86 return count;
89 shouldBe("testForIn(['data-foo', 'data-bar', 'data-baz'])", "3");
90 shouldBe("testForIn(['data-foo', 'data-bar', 'dataFoo'])", "2");
91 shouldBe("testForIn(['data-foo', 'data-bar', 'style'])", "2");
92 shouldBe("testForIn(['data-foo', 'data-bar', 'data-'])", "3");