Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / css / fontfaceset-set-operations.html
blob48c2fa090aed9460275d69ec5cde536be9ce6831
1 <html>
2 <head>
3 <script src="../../resources/js-test.js"></script>
4 <style>
5 @font-face {
6 font-family: Font1;
7 src: local(Arial);
10 @font-face {
11 font-family: Font2;
12 src: local(Arial);
15 @font-face {
16 font-family: Font3;
17 src: local(Arial);
19 </style>
20 <script>
21 description('Tests Set operations of FontFaceSet.');
23 function runTests() {
24 nonCssConnectedFace = new FontFace("MyFont", "local(Arial)", {});
26 shouldBe('document.fonts.size', '3');
28 thisArg = {};
29 faces = [];
30 document.fonts.forEach(function(face, faceAgain, set) {
31 if (faces.length == 0) {
32 callbackArgs = arguments;
33 thisValue = this;
34 shouldBeTrue('callbackArgs[0] === callbackArgs[1]');
35 shouldBeTrue('callbackArgs[2] === document.fonts');
36 shouldBeTrue('thisValue === thisArg');
38 faces.push(face);
39 }, thisArg);
40 shouldBe('faces.length', '3');
42 shouldBeEqualToString('faces[0].family', 'Font1');
43 shouldBeEqualToString('faces[1].family', 'Font2');
44 shouldBeEqualToString('faces[2].family', 'Font3');
46 shouldBeTrue('document.fonts.has(faces[0])');
47 shouldBeTrue('document.fonts.has(faces[1])');
48 shouldBeTrue('document.fonts.has(faces[2])');
49 shouldBeFalse('document.fonts.has(nonCssConnectedFace)');
50 shouldThrow('document.fonts.has("Font1")', '"TypeError: Failed to execute \'has\' on \'FontFaceSet\': The argument is not a FontFace."');
52 shouldThrow('document.fonts.add(faces[0])', '"InvalidModificationError: Failed to execute \'add\' on \'FontFaceSet\': Cannot add a CSS-connected FontFace."');
53 shouldThrow('document.fonts.delete(faces[0])', '"InvalidModificationError: Failed to execute \'delete\' on \'FontFaceSet\': Cannot delete a CSS-connected FontFace."');
55 document.fonts.add(nonCssConnectedFace);
56 shouldBe('document.fonts.size', '4');
57 shouldBeTrue('document.fonts.has(nonCssConnectedFace)');
58 document.fonts.add(nonCssConnectedFace);
59 shouldBe('document.fonts.size', '4');
60 document.fonts.delete(nonCssConnectedFace);
61 shouldBe('document.fonts.size', '3');
62 shouldBeFalse('document.fonts.has(nonCssConnectedFace)');
63 document.fonts.delete(nonCssConnectedFace);
64 shouldBe('document.fonts.size', '3');
66 document.fonts.add(nonCssConnectedFace);
67 shouldBe('document.fonts.size', '4');
68 document.fonts.clear();
69 shouldBe('document.fonts.size', '3');
72 if (document.fonts)
73 runTests();
74 else
75 testFailed('document.fonts does not exist');
77 </script>
78 </head>
79 <body>
80 </body>
81 </html>