add wpt tests

This commit is contained in:
Pierre Tachoire
2023-12-15 11:06:53 +01:00
parent d7f8014d53
commit 923296426e
22 changed files with 955 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
"use strict";
function makeStaticNodeList(length) {
const fooRoot = document.createElement("div");
for (var i = 0; i < length; i++) {
const el = document.createElement("span");
el.className = "foo";
fooRoot.append(el);
}
document.body.append(fooRoot);
return fooRoot.querySelectorAll(".foo");
}
const indexOfNodeList = new Function("nodeList", `
const __cacheBust = ${Math.random()};
const el = nodeList[50];
let index = -1;
for (var i = 0; i < 1e5 / 2; i++) {
for (var j = 0; j < nodeList.length; j++) {
if (nodeList[j] === el) {
index = j;
break;
}
}
}
return index;
`);
const arrayIndexOfNodeList = new Function("nodeList", `
const __cacheBust = ${Math.random()};
const el = nodeList[50];
const {indexOf} = Array.prototype;
for (var i = 0; i < 1e5; i++) {
var index = indexOf.call(nodeList, el);
}
return index;
`);