From e1e313cb9657f524cb31781994435474e6d901b3 Mon Sep 17 00:00:00 2001 From: kkapsner Date: Mon, 6 Jan 2020 14:56:49 +0100 Subject: [PATCH] Added test for appendChild --- test/performanceTest.js | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/test/performanceTest.js b/test/performanceTest.js index 4e72624..a23a452 100644 --- a/test/performanceTest.js +++ b/test/performanceTest.js @@ -171,8 +171,30 @@ const innerHTMlTest = function(html, repeats){ } }; }; +const appendChildTest = function(tagName, repeats){ + "use strict"; + + let div; + + return { + prepareOnce: function(){ + div = document.createElement("div"); + div.style.visibility = "hidden"; + document.body.appendChild(div); + }, + test: function(){ + for (let i = repeats; i--;){ + const element = document.createElement(tagName); + div.appendChild(element); + div.removeChild(element); + } + } + }; +}; performTest("fingerprinting", fingerprintTest, 10, 100); performTest("big random image", randomImageTest, 10, 10); -performTest("innerHTML (100 times)", innerHTMlTest("text
no iframe", 1000), 10, 30); -performTest("innerHTML with iframe (20 times)", innerHTMlTest("text
iframe: ", 20), 10, 10); \ No newline at end of file +performTest("innerHTML (1000 times)", innerHTMlTest("text
no iframe", 1000), 10, 30); +performTest("innerHTML with iframe (20 times)", innerHTMlTest("text
iframe: ", 20), 10, 10); +performTest("appendChild (300 times)", appendChildTest("span", 300), 10, 30); +performTest("appendChild with iframe (20 times)", appendChildTest("iframe", 20), 10, 30); \ No newline at end of file