Ticket #25247: 0001-bug-25247-Update-bug23104-test-to-be-DPI-independent.patch

File 0001-bug-25247-Update-bug23104-test-to-be-DPI-independent.patch, 2.0 KB (added by igt0, 3 years ago)
  • tbb-tests/test_tor_bug23104.html

    From 6d78597084340dc3e809b3b4753139da05f82970 Mon Sep 17 00:00:00 2001
    From: Igor Oliveira <igt0@torproject.org>
    Date: Wed, 14 Feb 2018 12:09:16 -0200
    Subject: [PATCH] bug 25247: Update bug23104 test to be DPI independent
    
    Font size is affected by the user's display pixel density. Thus,
    to make the test more robust, we are using now getClientRects and
    calculating the height of the element.
    ---
     tbb-tests/test_tor_bug23104.html | 21 ++++++++++++++-------
     1 file changed, 14 insertions(+), 7 deletions(-)
    
    diff --git a/tbb-tests/test_tor_bug23104.html b/tbb-tests/test_tor_bug23104.html
    index ae73a3446037..f465e2ac635e 100644
    a b  
    1414  </style>
    1515</head>
    1616<body>
    17 <span id="test1">Test1</span>
    18 <span id="test2">كلمة</span>
    19 <span id="test3">ação</span>
     17  <div id="test1-parent">
     18    <span id="test1">Test1</span>
     19  </div>
     20  <div id="test2-parent">
     21    <span id="test2">كلمة</span>
     22  </div>
     23  <div id="test3-parent">
     24    <span id="test3">ação</span>
     25  </div>
    2026<script type="application/javascript;version=1.7">
    2127
    2228let setPref = function* (key, value) {
    function getStyle(el, styleprop) { 
    3137}
    3238
    3339function validateElement(elementName, isFingerprintResistent) {
    34   var fontSize = getStyle(elementName, 'font-size');
    35   var lineHeight = getStyle(elementName, 'line-height');
    36   var validationCb = isFingerprintResistent ? is : isnot;
    37   validationCb(parseFloat(lineHeight), parseFloat(fontSize) * 1.2, 'Line Height validation');
     40  const elementClientRects = document.getElementById(elementName + "-parent").getClientRects();
     41  const calculatedHeight = elementClientRects.reduce((acc, currentValue) => acc + currentValue.height, 0);
     42  const lineHeight = getStyle(elementName, 'line-height');
     43  const validationCb = isFingerprintResistent ? is : isnot;
     44  validationCb(parseFloat(lineHeight), parseFloat(calculatedHeight.toFixed(2)), 'Line Height validation');
    3845}
    3946
    4047add_task(function* () {