diff --git a/test/helpers.js b/test/helpers.js index 1382af0691..f118a818f7 100644 --- a/test/helpers.js +++ b/test/helpers.js @@ -102,7 +102,7 @@ function cleanChildren(node) { }); // recurse - [...node.childNodes].forEach((child) => { + for (let child of node.childNodes) { if (child.nodeType === 3) { // text if ( @@ -130,7 +130,7 @@ function cleanChildren(node) { } previous = child; - }); + } // collapse whitespace if (node.firstChild && node.firstChild.nodeType === 3) { diff --git a/test/runtime-puppeteer/assert.js b/test/runtime-puppeteer/assert.js index e4d6f02f33..32e14b6830 100644 --- a/test/runtime-puppeteer/assert.js +++ b/test/runtime-puppeteer/assert.js @@ -43,8 +43,23 @@ function normalizeHtml(window, html) { .replace(//g, '') .replace(/>[\s\r\n]+<') .trim(); + + cleanStyle(node); + return node.innerHTML.replace(/<\/?noscript\/?>/g, ''); } catch (err) { throw new Error(`Failed to normalize HTML:\n${html}`); } } + +function cleanStyle(node) { + if (node.nodeType === 1) { + if (node.hasAttribute('style')) { + node.style = node.style.cssText; + } + + for (const child of node.childNodes) { + cleanStyle(child); + } + } +}