{"ScriptPreparationCode":"function getHtmlString() {\r\n return \u0060\r\n \u003Cdiv\u003E\u003Cb\u003EHELLO\u003C/b\u003EW\u003Cspan style=\u0022color:blue;\u0022\u003EO\u003C/span\u003ERLD!\u003C/div\u003E\r\n \u003Cp\u003EBelow is a red dot!\u003C/p\u003E\r\n \u003Cimg src=\u0022data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==\u0022 alt=\u0022Red dot\u0022 /\u003E\r\n \u003Cspan\u003ERANDOM! ${Math.random()}\u003C/span\u003E\r\n \u003Cdiv\u003E\r\n \u003Cdiv\u003E\r\n \u003Cdiv\u003E\r\n \u003Cdiv\u003E\r\n \u003Cdiv\u003E\r\n \u003Cdiv\u003E\r\n \u003Cp\u003ECupcake tiramisu tiramisu oat cake biscuit jelly. Biscuit pie jujubes chocolate macaroon chupa chups. Brownie sweet roll pudding icing jelly liquorice. Sugar plum powder chupa chups powder carrot cake pie ice cream topping macaroon. Marshmallow macaroon cookie tiramisu bear claw tiramisu sweet. Tootsie roll jelly-o lemon drops dessert lemon drops toffee chocolate. Jelly beans fruitcake chocolate bar marzipan candy canes cheesecake. Lollipop donut marzipan drag\u00E9e croissant shortbread. Gingerbread chupa chups liquorice apple pie ice cream gingerbread bonbon. Sweet roll brownie fruitcake pudding pie caramels tart. Icing topping tart chocolate cake brownie marshmallow cookie icing. Tootsie roll lemon drops toffee macaroon gummies. Halvah cookie gummi bears ice cream croissant chocolate bar jelly beans bonbon.\u003C/p\u003E\r\n \u003Cp\u003EChupa chups powder liquorice bonbon cake. Tootsie roll tiramisu sweet roll apple pie gingerbread jelly beans marshmallow dessert powder. Chocolate bar dessert halvah carrot cake cake candy canes biscuit. Macaroon marzipan liquorice chocolate cake muffin sesame snaps shortbread gummi bears apple pie. Pudding jelly-o gummi bears lollipop cake. Chocolate cake tootsie roll wafer sesame snaps souffl\u00E9 macaroon jelly-o macaroon caramels. Tart danish donut fruitcake icing chupa chups toffee biscuit. Sweet oat cake ice cream shortbread caramels pie gummies topping topping. Jelly cake chocolate bar pudding sweet roll cotton candy marshmallow. Tiramisu marshmallow danish sweet roll jujubes croissant halvah. Muffin ice cream liquorice cheesecake candy jelly tootsie roll caramels sesame snaps. Toffee marshmallow carrot cake cake muffin carrot cake tootsie roll gummies. Cupcake chocolate bar fruitcake cotton candy gummies caramels muffin. Apple pie marshmallow apple pie carrot cake croissant halvah tiramisu.\u003C/p\u003E\r\n \u003Cp\u003EMacaroon sweet liquorice oat cake fruitcake jelly beans shortbread gummi bears. Halvah danish drag\u00E9e dessert macaroon candy canes cake pie cookie. Croissant cupcake topping bonbon jelly beans sweet roll sugar plum jelly-o pie. Toffee pie pudding chupa chups tootsie roll. Cookie candy cookie gummies bear claw candy candy canes icing gummi bears. Chupa chups gingerbread sesame snaps candy cotton candy halvah fruitcake sesame snaps jelly beans. Cake pastry wafer pudding gummi bears jelly-o jelly tiramisu candy canes. Toffee dessert toffee gummi bears topping gummi bears croissant toffee. Marzipan ice cream icing pudding lemon drops cake gummi bears icing. Sesame snaps toffee gingerbread souffl\u00E9 cotton candy liquorice cookie. Sweet roll candy canes icing gummies cake pudding gingerbread. Biscuit cake chocolate pudding lemon drops pastry. Fruitcake oat cake caramels gummies jelly beans chocolate.\u003C/p\u003E\r\n \u003C/div\u003E\r\n \u003C/div\u003E\r\n \u003C/div\u003E\r\n \u003C/div\u003E\r\n \u003C/div\u003E\r\n \u003C/div\u003E\r\n \u0060;\r\n}\r\n\r\n//[Unsafe] Image onload/onerror code will stll run\r\nfunction toTextContentViaElement(htmlString) {\r\n const element = document.createElement(\u0022div\u0022);\r\n element.innerHTML = htmlString;\r\n return element.textContent;\r\n}\r\n\r\n//[Unsafe] Image onload/onerror code will stll run\r\nconst cachedElement = document.createElement(\u0022div\u0022);\r\nfunction toTextContentViaElementWithCache(htmlString) {\r\n cachedElement.innerHTML = htmlString;\r\n const textContent = cachedElement.textContent;\r\n cachedElement.textContent = \u0022\u0022;\r\n return textContent;\r\n}\r\n\r\nfunction toTextContentViaParser(htmlString) {\r\n const parser = new DOMParser();\r\n const doc = parser.parseFromString(htmlString, \u0022text/html\u0022);\r\n return doc.body.textContent;\r\n}\r\n\r\nconst cachedParser = new DOMParser();\r\nfunction toTextContentViaParserWithCache(htmlString) {\r\n const doc = cachedParser.parseFromString(htmlString, \u0022text/html\u0022);\r\n return doc.body.textContent;\r\n}\r\n\r\nfunction toTextContentViaNewDocument(htmlString) {\r\n const doc = document.implementation.createHTMLDocument();\r\n doc.body.innerHTML = htmlString;\r\n return doc.body.textContent;\r\n}\r\n\r\nconst cachedDoc = document.implementation.createHTMLDocument();\r\nfunction toTextContentViaNewDocumentWithCache(htmlString) {\r\n cachedDoc.body.innerHTML = htmlString;\r\n const textContent = cachedDoc.body.textContent;\r\n cachedDoc.body.textContent = htmlString;\r\n return textContent;\r\n}\r\n\r\n\r\n\r\nconst domPurifyConfig = { RETURN_DOM: true };\r\nfunction toTextContentViaDomPurify(htmlString) {\r\n return DOMPurify.sanitize(htmlString, domPurifyConfig).textContent;\r\n}\r\n\r\nwindow.tempStore = [];","TestCases":[{"Name":"[Unsafe] HTML string to text via creating an unattached DOM element.","Code":"window.tempStore.length = 0;\r\nfor(let i = 0; i \u003C 1000; i\u002B\u002B) {\r\n const textContent = toTextContentViaElement(getHtmlString());\r\n window.tempStore.push(textContent); \r\n}","IsDeferred":false},{"Name":"[Unsafe] HTML string to text via reusing an unattached DOM element.","Code":"window.tempStore.length = 0;\r\nfor(let i = 0; i \u003C 1000; i\u002B\u002B) {\r\n const textContent = toTextContentViaElementWithCache(getHtmlString());\r\n window.tempStore.push(textContent);\r\n}","IsDeferred":false},{"Name":"[Safe] HTML string to text via creating and using a DOMParser","Code":"window.tempStore.length = 0;\r\nfor(let i = 0; i \u003C 1000; i\u002B\u002B) {\r\n const textContent = toTextContentViaParser(getHtmlString());\r\n window.tempStore.push(textContent);\r\n}","IsDeferred":false},{"Name":"[Safe] HTML string to text via reusing a DOMParser","Code":"tempStore.length = 0;\r\nfor(let i = 0; i \u003C 1000; i\u002B\u002B) {\r\n const textContent = toTextContentViaParserWithCache(getHtmlString());\r\n tempStore.push(textContent);\r\n}","IsDeferred":false},{"Name":"[Safe] HTML string to text via the a new Document","Code":"window.tempStore.length = 0;\r\nfor(let i = 0; i \u003C 1000; i\u002B\u002B) {\r\n const textContent = toTextContentViaNewDocument(getHtmlString());\r\n window.tempStore.push(textContent);\r\n}","IsDeferred":false},{"Name":"[Safe] HTML string to text via the a cached Document","Code":"window.tempStore.length = 0;\r\nfor(let i = 0; i \u003C 1000; i\u002B\u002B) {\r\n const textContent = toTextContentViaNewDocumentWithCache(getHtmlString());\r\n window.tempStore.push(textContent);\r\n}","IsDeferred":false},{"Name":"[Safe] HTML string to text via the DOMPurify library","Code":"window.tempStore.length = 0;\r\nfor(let i = 0; i \u003C 1000; i\u002B\u002B) {\r\n const textContent = toTextContentViaDomPurify(getHtmlString());\r\n window.tempStore.push(textContent);\r\n}","IsDeferred":false}]}