tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

testing-utils.js (2720B)


      1 var TestingUtils = (function() {
      2 
      3    function checkGridTemplateColumns(element, value) {
      4        if (!Array.isArray(value))
      5            value = new Array(value);
      6        assert_in_array(getComputedStyle(element).gridTemplateColumns, value, "gridTemplateColumns");
      7    }
      8 
      9    function checkGridTemplateRows(element, value) {
     10        if (!Array.isArray(value))
     11            value = new Array(value);
     12        assert_in_array(getComputedStyle(element).gridTemplateRows, value, "gridTemplateRows");
     13    }
     14 
     15    function testGridTemplateColumnsRows(gridId, columnsStyle, rowsStyle, columnsComputedValue, rowsComputedValue, label) {
     16        test(function() {
     17            var grid = document.getElementById(gridId);
     18            grid.style.gridTemplateColumns = columnsStyle;
     19            grid.style.gridTemplateRows = rowsStyle;
     20            checkGridTemplateColumns(grid, columnsComputedValue);
     21            checkGridTemplateRows(grid, rowsComputedValue);
     22        }, (label ? label + " " : "") + "'" + gridId + "' with: grid-template-columns: " + columnsStyle  + "; and grid-template-rows: " + rowsStyle + ";");
     23    }
     24 
     25    function testGridTemplateColumns(gridId, columnsStyle, columnsComputedValue, label) {
     26        test(function() {
     27            var grid = document.getElementById(gridId);
     28            grid.style.gridTemplateColumns = columnsStyle;
     29            checkGridTemplateColumns(grid, columnsComputedValue);
     30        }, (label ? label + " " : "") + "'" + gridId + "' with: grid-template-columns: " + columnsStyle  + ";");
     31    }
     32 
     33    function testGridTemplateRows(gridId, rowsStyle, rowsComputedValue, label) {
     34        test(function() {
     35            var grid = document.getElementById(gridId);
     36            grid.style.gridTemplateRows = rowsStyle;
     37            checkGridTemplateRows(grid, rowsComputedValue);
     38        }, (label ? label + " " : "") + "'" + gridId +"' with: grid-template-rows: " + rowsStyle + ";");
     39    }
     40 
     41    function checkGridTemplateAreas(element, value) {
     42        if (!Array.isArray(value))
     43            value = new Array(value);
     44        assert_in_array(getComputedStyle(element).gridTemplateAreas, value, "gridTemplateAreas");
     45    }
     46 
     47    function testGridTemplateAreas(gridId, style, value) {
     48        test(function() {
     49            var grid = document.getElementById(gridId);
     50            grid.style.gridTemplateAreas = style;
     51            checkGridTemplateAreas(grid, value);
     52        }, "'" + gridId + "' with: grid-template-areas: " + style + ";");
     53    }
     54 
     55    return {
     56        testGridTemplateColumnsRows: testGridTemplateColumnsRows,
     57        testGridTemplateColumns: testGridTemplateColumns,
     58        testGridTemplateRows: testGridTemplateRows,
     59        testGridTemplateAreas: testGridTemplateAreas
     60    }
     61 })();