Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(433)

Side by Side Diff: LayoutTests/inspector-protocol/css/css-get-platform-fonts.html

Issue 1187073016: DevTools: generalize getPlatformFonts code (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 <html> 1 <html>
2 <head> 2 <head>
3 <script type="text/javascript" src="../../http/tests/inspector-protocol/inspecto r-protocol-test.js"></script> 3 <script type="text/javascript" src="../../http/tests/inspector-protocol/inspecto r-protocol-test.js"></script>
4 <script type="text/javascript" src="../../http/tests/inspector-protocol/css-prot ocol-test.js"></script>
5 <script type="text/javascript" src="../../http/tests/inspector-protocol/dom-prot ocol-test.js"></script>
4 <script type="text/javascript"> 6 <script type="text/javascript">
5 7
6 function test() 8 function test()
7 { 9 {
8 function sendCommand(command, properties, callback) { 10 var documentNodeId;
9 InspectorTest.sendCommand(command, properties || {}, commandCallback); 11
10 function commandCallback(msg) 12 InspectorTest.requestDocumentNodeId(onDocumentNodeId);
13
14 function onDocumentNodeId(nodeId)
15 {
16 documentNodeId = nodeId;
17 InspectorTest.runTestSuite([
18 function testFirstLetterPseudoClass(next)
19 {
20 platformFontsForElementWithSelector("#fancy", next);
21 },
22
23 function testSelectElementPlatformFonts(next)
24 {
25 platformFontsForElementWithSelector("select", next);
26 }
27 ]);
28 }
29
30
31 function platformFontsForElementWithSelector(selector, callback)
32 {
33 InspectorTest.requestNodeId(documentNodeId, selector, onNodeId);
34
35 function onNodeId(nodeId)
11 { 36 {
12 if (msg.error) { 37 InspectorTest.sendCommandOrDie("CSS.getPlatformFontsForNode", { node Id: nodeId }, onGotComputedFonts);
13 InspectorTest.log(msg.error.message); 38 }
14 InspectorTest.completeTest(); 39
15 return; 40 function onGotComputedFonts(response)
16 } 41 {
17 callback(msg.result); 42 dumpComputedFonts(response);
43 callback();
18 } 44 }
19 } 45 }
20 sendCommand("DOM.getDocument", {}, onGotDocument);
21 46
22 function onGotDocument(result) 47 function dumpComputedFonts(response)
23 {
24 var root = result.root;
25 sendCommand("DOM.querySelector", { "nodeId": root.nodeId , "selector": " #fancy" }, onGotNode);
26 }
27
28 function onGotNode(node)
29 {
30 sendCommand("CSS.getPlatformFontsForNode", { "nodeId": node.nodeId }, on GotComputedFonts);
31 }
32
33 function onGotComputedFonts(response)
34 { 48 {
35 var cssFamilyName = response.cssFamilyName; 49 var cssFamilyName = response.cssFamilyName;
36 InspectorTest.log("cssFamilyName: " + cssFamilyName); 50 InspectorTest.log("cssFamilyName: " + cssFamilyName);
37 var fonts = response.fonts; 51 var fonts = response.fonts;
38 fonts.sort(function(a, b) { 52 fonts.sort(function(a, b) {
39 return b.glyphCount - a.glyphCount; 53 return b.glyphCount - a.glyphCount;
40 }); 54 });
41 for (var i = 0; i < fonts.length; ++i) 55 for (var i = 0; i < fonts.length; ++i)
42 fonts[i].familyName = "<Some-family-name-" + i + ">"; 56 fonts[i].familyName = "<Some-family-name-" + i + ">";
43 InspectorTest.log(JSON.stringify(fonts)); 57 InspectorTest.log(JSON.stringify(fonts));
44 InspectorTest.completeTest();
45 } 58 }
46 }; 59 };
47 60
48 window.addEventListener("DOMContentLoaded", function () { 61 window.addEventListener("DOMContentLoaded", function () {
49 runTest(); 62 runTest();
50 }, false); 63 }, false);
51 64
52 </script> 65 </script>
53 <style> 66 <style>
54 #fancy { 67 #fancy {
55 font-family: 'Arial'; 68 font-family: 'Arial';
56 background-color: gray; 69 background-color: gray;
57 } 70 }
58 #fancy:first-letter { 71 #fancy:first-letter {
59 font-family: 'Times New Roman'; 72 font-family: 'Times New Roman';
60 font-size: 400%; 73 font-size: 400%;
61 background-color: blue; 74 background-color: blue;
62 } 75 }
63 76
64 #fancy:first-line { 77 #fancy:first-line {
65 font-family: 'Courier New'; 78 font-family: 'Courier New';
66 background-color: yellow; 79 background-color: yellow;
67 } 80 }
68 </style> 81 </style>
69 </head> 82 </head>
70 <body> 83 <body>
71 84
72 <div id="fancy"> 85 <div id="fancy">
73 First line. 86 7chars.<br>
74 <br> 87 Some line with 29 characters.
75 Second line.
76 </div> 88 </div>
89 <select>
90 <option>Short</option>
91 <option selected>Option with a lot of chars.</option>
92 </select>
77 93
78 </body> 94 </body>
79 </html> 95 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698