From ce340d7a19f2d60a952820aac9e7c942f884eb98 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sun, 23 May 2021 10:54:28 -0400 Subject: Update document tests (#1703) * Update iframe content * Add srcdoc test --- test/data/html/test-document2.html | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'test') diff --git a/test/data/html/test-document2.html b/test/data/html/test-document2.html index 7f7120d2..bb7bfb97 100644 --- a/test/data/html/test-document2.html +++ b/test/data/html/test-document2.html @@ -98,7 +98,7 @@ <iframe> element with data URL. - + @@ -106,6 +106,11 @@ + + <iframe> element with srcdoc. + + + SVG <img>. @@ -154,14 +159,19 @@ return array; } - function dataUrlToBlob(dataUrl) { - let [, type, isBase64, data] = /^data:([^;]*);(base64,)?([\w\W]*)$/.exec(dataUrl); - data = ( + function dataUrlToContent(dataUrl) { + const [, type, isBase64, data] = /^data:([^;]*);(base64,)?([\w\W]*)$/.exec(dataUrl); + const content = ( isBase64 ? new TextDecoder().decode(stringToTypedArray(atob(data))) : data ); - return new Blob([data], {type}); + return {content, type}; + } + + function dataUrlToBlob(dataUrl) { + const {content, type} = dataUrlToContent(dataUrl); + return new Blob([content], {type}); } for (const element of document.querySelectorAll('y-test')) { @@ -170,7 +180,9 @@ const iframeWithDataUrl = document.querySelector('#iframe-with-data-url'); const iframeWithBlobUrl = document.querySelector('#iframe-with-blob-url'); + const iframeWithSrcdoc = document.querySelector('#iframe-with-srcdoc'); iframeWithBlobUrl.src = URL.createObjectURL(dataUrlToBlob(iframeWithDataUrl.src)); + iframeWithSrcdoc.srcdoc = dataUrlToContent(iframeWithDataUrl.src).content; })(); -- cgit v1.2.3