Skip to content

Commit 4c6e83c

Browse files
committed
integrate compat table to browser runner of compat data tests
1 parent 47f8920 commit 4c6e83c

File tree

3 files changed

+75
-9
lines changed

3 files changed

+75
-9
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Contributions are always welcome. If you don't know how you can help, you can ch
1919

2020
For updating `core-js-compat` data:
2121

22-
- If you want to add new data for a browser, run in this browser [`tests/compat/index.html`](https://raw.githack.com/zloirock/core-js/master/tests/compat/index.html) and you will see what `core-js` modules are required for this browser.
22+
- If you want to add new data for a browser, run in this browser [`tests/compat/index.html`](http://es6.zloirock.ru/compat/) and you will see what `core-js` modules are required for this browser.
2323
- If you want to add new data for NodeJS, run `npm run compat-node` with the installed required NodeJS version and you will see the results in the console. Use `npm run compat-node-json` if you want to get the result as JSON.
2424
- If you want to add new data for Deno, run `npm run compat-deno` with the installed required Deno version and you will see the results in the console. Use `npm run compat-deno-json` if you want to get the result as JSON.
2525
- If you want to add new data for Rhino, set the required Rhino version in `compat-rhino-prepare` NPM script in [`package.json`](./package.json), run `npm run compat-rhino` and you will see the results in the console.

tests/compat/browsers-runner.js

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,65 @@
11
var table = document.getElementById('table');
2+
var tests = window.tests;
3+
var data = window.data;
4+
var i;
25

3-
for (var key in window.tests) {
4-
var test = window.tests[key];
6+
var engines = [
7+
'android',
8+
'chrome',
9+
'deno',
10+
'edge',
11+
'electron',
12+
'firefox',
13+
'ie',
14+
'ios',
15+
'node',
16+
'opera',
17+
'opera_mobile',
18+
'phantom',
19+
'rhino',
20+
'safari',
21+
'samsung'
22+
];
23+
24+
var trh = document.createElement('tr');
25+
trh.appendChild(document.createElement('th'));
26+
trh.appendChild(document.createElement('th'));
27+
for (i = 0; i < engines.length; i++) {
28+
var th = document.createElement('th');
29+
th.innerHTML = engines[i];
30+
trh.appendChild(th);
31+
}
32+
table.appendChild(trh);
33+
34+
for (var key in tests) {
35+
var test = tests[key];
536
var result = true;
637
try {
738
if (typeof test == 'function') {
839
result = !!test();
940
} else {
10-
for (var i = 0; i < test.length; i++) result = result && !!test[i].call(undefined);
41+
for (i = 0; i < test.length; i++) result = result && !!test[i].call(undefined);
1142
}
1243
} catch (error) {
1344
result = false;
1445
}
1546

1647
var tr = document.createElement('tr');
17-
tr.className = result;
1848
var td1 = document.createElement('td');
1949
td1.innerHTML = key;
50+
td1.className = result;
2051
tr.appendChild(td1);
2152
var td2 = document.createElement('td');
22-
td2.innerHTML = result ? 'not required' : 'required';
53+
td2.innerHTML = result ? 'not&nbsp;required' : 'required';
54+
td2.className = result;
2355
tr.appendChild(td2);
56+
for (i = 0; i < engines.length; i++) {
57+
var td = document.createElement('td');
58+
var dataExists = !!data[key];
59+
var mod = dataExists && data[key][engines[i]];
60+
td.innerHTML = dataExists ? mod || 'no' : 'no data';
61+
td.className = (dataExists ? !!mod : 'nodata') + ' data';
62+
tr.appendChild(td);
63+
}
2464
table.appendChild(tr);
2565
}

tests/compat/index.html

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,36 @@
22
<meta charset='UTF-8'>
33
<title>core-js-compat</title>
44
<style>
5-
td { color: white; }
6-
.true { background-color: green; }
7-
.false { background-color: red; }
5+
th,td {
6+
padding: 0.25em 0.5em;
7+
font-family: Verdana, Arial, Helvetica, sans-serif;
8+
font-size: 0.8em;
9+
}
10+
th {
11+
background-color: white;
12+
color: black;
13+
position: -webkit-sticky;
14+
position: sticky;
15+
top: 0;
16+
z-index: 2;
17+
}
18+
td {
19+
color: white;
20+
}
21+
.true {
22+
background-color: #00882c;
23+
}
24+
.false {
25+
background-color: #e11;
26+
}
27+
.nodata {
28+
background-color: grey;
29+
}
30+
.data {
31+
text-align: center;
32+
}
833
</style>
934
<table id='table'></table>
35+
<script src='./compat-data.js'></script>
1036
<script src='./tests.js'></script>
1137
<script src='./browsers-runner.js'></script>

0 commit comments

Comments
 (0)