summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/text-autosizing/resize-window.html
blob: 3cc038cde7a107fe021660a9b472f4908aa1f9c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<!DOCTYPE HTML>
<html>
<head>
<style>
#autosize {
  font-size: 10px;
}
</style>
<script>
  if (window.internals) {
    window.internals.settings.setTextAutosizingEnabled(true);
    window.internals.settings.setTextAutosizingWindowSizeOverride(320, 480);
  } else if (window.console && console.warn) {
    console.warn("This test depends on the Text Autosizing setting being true, so run it in DumpRenderTree, or manually enable Text Autosizing");
  }

  function test() {
    var fontSizeOriginal = getAutosizedFontSize();
    window.internals.settings.setTextAutosizingWindowSizeOverride(520, 480);
    var fontSizeUpdated = getAutosizedFontSize();

    if (fontSizeOriginal != fontSizeUpdated)
      document.write('PASS');
    else
      document.write('FAIL. Expected font size to change but it stayed at ' + fontSizeOriginal);
    if (window.testRunner)
      testRunner.dumpAsText();
  }

  function getAutosizedFontSize() {
    var autosizeContainer = document.getElementById('autosize');
    var forceLayout = autosizeContainer.offsetWidth;
    return parseInt(window.getComputedStyle(autosizeContainer).fontSize);
  }
</script>
</head>
<body onload="test()">
  <div id="autosize">
    This test passes if this text changes size due to autosizing after a dynamic window size change occurs. I'm just adding lines so this text is long enough to autosize. I'm just adding lines so this text is long enough to autosize. I'm just adding lines so this text is long enough to autosize. I'm just adding lines so this text is long enough to autosize. I'm just adding lines so this text is long enough to autosize. I'm just adding lines so this text is long enough to autosize. 
  </div>
</body>
</html>