Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / inspector / text-autosizing-override.html
blobbae3ff2bff38f9d60f0d0b8eea94c02f7f8b68a8
1 <html>
2 <head>
3 <meta name="viewport" content="width=800">
4 <script src="../http/tests/inspector/inspector-test.js"></script>
5 <style>
6 html { font-size: 16px; }
7 body { width: 800px; margin: 0; overflow-y: hidden; }
8 </style>
9 <script>
10 if (window.internals)
11 window.internals.settings.setTextAutosizingWindowSizeOverride(320, 480);
13 function getAutosizing()
15 return JSON.stringify({ textHeight: document.getElementById('measure').offsetHeight });
18 function test()
20 function assertAutosizingResult(expected, callback)
22 function resultCallback(jsonResult) {
23 var result = JSON.parse(jsonResult.value);
24 var actual = result.textHeight > 200;
25 InspectorTest.addResult('Text ' + (actual ? 'was' : 'was not') + ' autosized. ' + (expected == actual ? 'PASS' : 'FAIL'));
26 if (callback)
27 callback();
29 InspectorTest.evaluateInPage("getAutosizing()", resultCallback);
32 InspectorTest.runTestSuite([
33 function checkNotAutosizedWithoutPageAgent(next)
35 InspectorTest.PageAgent.disable();
36 assertAutosizingResult(false, next);
39 function checkNotAutosizedWithPageAgent(next)
41 InspectorTest.PageAgent.enable();
42 assertAutosizingResult(false, next);
45 function checkNotAutosizedWithZeroDeviceMetrics(next)
47 InspectorTest.PageAgent.invoke_setDeviceMetricsOverride({width: 0, height: 0, deviceScaleFactor: 0, mobile: false, fitWindow: true});
48 assertAutosizingResult(false, next);
51 function checkAutosizedWhenDeviceMetrics(next)
53 InspectorTest.PageAgent.invoke_setDeviceMetricsOverride({width: 320, height: 480, deviceScaleFactor: 0, mobile: true, fitWindow: true});
54 assertAutosizingResult(true, next);
57 function checkCleanupOverrides(next)
59 InspectorTest.PageAgent.clearDeviceMetricsOverride();
60 assertAutosizingResult(false);
61 InspectorTest.evaluateInPage("document.getElementById('measure').remove();", next);
63 ]);
65 </script>
66 </head>
67 <body onload="runTest()">
68 <div id="measure">
69 This text should be autosized to 40px computed font-size (16 * 800/320).<br/>
70 FAIL IF THIS IS VISIBLE<br/>
71 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
72 </div>
73 </body>
74 </html>