From 43a97878ce14b72f0981164f87f2e35e14151312 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:22:09 +0200 Subject: Adding upstream version 110.0.1. Signed-off-by: Daniel Baumann --- .../support/NodeList-static-length-tampered.js | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 testing/web-platform/tests/dom/nodes/support/NodeList-static-length-tampered.js (limited to 'testing/web-platform/tests/dom/nodes/support') diff --git a/testing/web-platform/tests/dom/nodes/support/NodeList-static-length-tampered.js b/testing/web-platform/tests/dom/nodes/support/NodeList-static-length-tampered.js new file mode 100644 index 0000000000..51167e2ddc --- /dev/null +++ b/testing/web-platform/tests/dom/nodes/support/NodeList-static-length-tampered.js @@ -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; +`); -- cgit v1.2.3