| 12
 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
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 
 | <!doctype html>
<link rel="stylesheet" href="../support/base.css" />
<aside style="position:absolute"><!-- THIS IS WHERE WE RUN THE EXPERIMENTS --></aside>
<main><textarea style="display: none; width: 100%"></textarea><script>
    var textarea = document.querySelector('textarea');
    var testingBorderAttributes = true;
    var seed = 0;
    // This is not meant to be a good random number generator; I literally don't care
    function XorshiftMath(seed) {
        var x = 1;
        var y = 2;
        var z = 3;
        var w = seed|0;
        this.random = function random() {
            var t = x;
            t ^= t << 11;
            t ^= t >> 8;
            x = y; y = z; z = w;
            w ^= w >> 19;
            w ^= t;
            return (w%1024)/1024;
        }
    }
    var rndGen = new XorshiftMath(seed);
    function rnd(x) {
        return x > rndGen.random();
    }
    function pickInList(list) {
        var i = list.length; while(i>1 && rnd(1/i)) { i--; }
        return list[i-1];
    }
    function generateMarkup(root) {
        if(rnd(0.99)) {
            //
            // the table has a <table> element
            //
            var table = document.createElement('table');
            //
            if(testingBorderAttributes) {
                if(rnd(0.3)) { table.setAttribute('border',pickInList(['0','10','yes'])); }
                if(rnd(0.3)) { table.setAttribute('frame',pickInList(['box','vsides','none'])); }
                if(rnd(0.3)) { table.setAttribute('rules',pickInList(['all','rows','groups'])); }
                table.setAttribute("cellspacing","0");
            }
            generateRowGroups(table);
            root.appendChild(table);
        } else {
            //
            // the table has no <table> element
            //
            generateRowGroup(root);
        }
    }
    function generateRowGroups(root) {
        if(rnd(0.5)) {
            generateRowGroup(root);
            while(rnd(0.25)) {
                generateRowGroup(root);
            }
        } else {
            generateRows(root);
        }
    }
    function generateRowGroup(root) {
        var tbody; if(rnd(0.7)) {
            tbody = document.createElement('tbody');
        } else if (rnd(0.5)) {
            tbody = document.createElement('thead');
        } else {
            tbody = document.createElement('tfoot');
        }
        generateRows(tbody);
        root.appendChild(tbody);
    }
    function generateRows(root) {
        while(rnd(0.9)) {
            if(rnd(0.9)) {
                generateRow(root);
            } else {
                generateCells(root);
            }
        }
    }
    function generateRow(root) {
        var tr = document.createElement('tr');
        generateCells(tr);
        root.appendChild(tr);
    }
    function generateCells(root) {
        while(rnd(0.9)) {
            if(rnd(0.9)) {
                generateCell(root);
            } else {
                generateCellContent(root);
            }
        }
    }
    function generateCell(root) {
        var td = document.createElement( rnd(0.9) ? 'td' : 'th' );
        generateCellContent(td);
        root.appendChild(td);
    }
    function generateCellContent() {
        // for now, do nothing
    }
    for(var i = 10; i--;) {
        //document.write("<textarea style='width: 100%; display: none'>");
        var div = document.createElement('div');
        generateMarkup(div);
        appendReportFor(div);
        //document.write(div.innerHTML);
        //document.write("</textarea>");
    }
    if(navigator.userAgent.indexOf("Edge") == -1) {
        var downloadLink = document.createElement('a');
        downloadLink.setAttribute("download","report.txt");
        downloadLink.href = "data:," + escape(textarea.value);
        downloadLink.textContent = "download";
        document.body.appendChild(downloadLink);
    }
    function appendReportFor(markup) {
        var report = markup.innerHTML + '\r\n\r\n';
        //
        // append markup to the dom
        //
        var root = document.querySelector('aside');
        root.innerHTML = '';
        root.appendChild(markup);
        //
        // output box stats
        //
        var boxes = markup.getElementsByTagName("*");
        for(var i = 0; i<boxes.length; i++) {
            var box = boxes[i];
            report += '' + i + ': ' + box.tagName + '\r\n';
            report += 'offsetWidth: ' + box.offsetWidth + '\r\n';
            report += 'offsetHeight: ' + box.offsetHeight + '\r\n';
            report += 'offsetLeft: ' + box.offsetLeft + '\r\n';
            report += 'offsetTop: ' + box.offsetTop + '\r\n';
            report += 'borderTopWidth: ' + getComputedStyle(box).borderTopWidth + '\r\n';
            report += 'borderTopStyle: ' + getComputedStyle(box).borderTopStyle + '\r\n';
            report += 'borderTopColor: ' + getComputedStyle(box).borderTopColor + '\r\n';
            report += 'borderLeftWidth: ' + getComputedStyle(box).borderLeftWidth + '\r\n';
            report += 'borderLeftStyle: ' + getComputedStyle(box).borderLeftStyle + '\r\n';
            report += 'borderLeftColor: ' + getComputedStyle(box).borderLeftColor + '\r\n';
            report += '\r\n';
        }
        report += '\r\n';
        report += '=====================================================================\r\n';
        report += '\r\n';
        textarea.value += report;
        root.innerHTML = '';
    }
</script></main>
 |