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

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: do not dump cssFamilyFontName 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
« no previous file with comments | « no previous file | LayoutTests/inspector-protocol/css/css-get-platform-fonts-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 { 48 {
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 {
35 var cssFamilyName = response.cssFamilyName;
36 InspectorTest.log("cssFamilyName: " + cssFamilyName);
37 var fonts = response.fonts; 49 var fonts = response.fonts;
38 fonts.sort(function(a, b) { 50 fonts.sort(function(a, b) {
39 return b.glyphCount - a.glyphCount; 51 return b.glyphCount - a.glyphCount;
40 }); 52 });
41 for (var i = 0; i < fonts.length; ++i) 53 for (var i = 0; i < fonts.length; ++i)
42 fonts[i].familyName = "<Some-family-name-" + i + ">"; 54 fonts[i].familyName = "<Some-family-name-" + i + ">";
43 InspectorTest.log(JSON.stringify(fonts)); 55 InspectorTest.log(JSON.stringify(fonts));
44 InspectorTest.completeTest();
45 } 56 }
46 }; 57 };
47 58
48 window.addEventListener("DOMContentLoaded", function () { 59 window.addEventListener("DOMContentLoaded", function () {
49 runTest(); 60 runTest();
50 }, false); 61 }, false);
51 62
52 </script> 63 </script>
53 <style> 64 <style>
54 #fancy { 65 #fancy {
55 font-family: 'Arial'; 66 font-family: 'Arial';
56 background-color: gray; 67 background-color: gray;
57 } 68 }
58 #fancy:first-letter { 69 #fancy:first-letter {
59 font-family: 'Times New Roman'; 70 font-family: 'Times New Roman';
60 font-size: 400%; 71 font-size: 400%;
61 background-color: blue; 72 background-color: blue;
62 } 73 }
63 74
64 #fancy:first-line { 75 #fancy:first-line {
65 font-family: 'Courier New'; 76 font-family: 'Courier New';
66 background-color: yellow; 77 background-color: yellow;
67 } 78 }
68 </style> 79 </style>
69 </head> 80 </head>
70 <body> 81 <body>
71 82
72 <div id="fancy"> 83 <div id="fancy">
73 First line. 84 7chars.<br>
74 <br> 85 Some line with 29 characters.
75 Second line.
76 </div> 86 </div>
87 <select>
88 <option>Short</option>
89 <option selected>Option with a lot of chars.</option>
90 </select>
77 91
78 </body> 92 </body>
79 </html> 93 </html>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/inspector-protocol/css/css-get-platform-fonts-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698