aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/data/html/test-document2.html22
1 files changed, 17 insertions, 5 deletions
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 @@
<y-test>
<y-description>&lt;iframe&gt; element with data URL.</y-description>
- <iframe id="iframe-with-data-url" src="data:text/html;base64,PCFET0NUWVBFIGh0bWw+DQo8aHRtbD4NCiAgICA8aGVhZD4NCiAgICAgICAgPG1ldGEgY2hhcnNldD0iVVRGLTgiPg0KICAgICAgICA8bWV0YSBuYW1lPSJ2aWV3cG9ydCIgY29udGVudD0id2lkdGg9ZGV2aWNlLXdpZHRoLGluaXRpYWwtc2NhbGU9MSIgLz4NCiAgICAgICAgPHRpdGxlPllvbWljaGFuIFRlc3RzPC90aXRsZT4NCiAgICAgICAgPHNjcmlwdD4NCmZ1bmN0aW9uIHRvZ2dsZUZ1bGxzY3JlZW4oZWxlbWVudCkgew0KICAgIGlmIChnZXRGdWxsc2NyZWVuRWxlbWVudCgpKSB7DQogICAgICAgIGV4aXRGdWxsc2NyZWVuKCk7DQogICAgfSBlbHNlIHsNCiAgICAgICAgcmVxdWVzdEZ1bGxzY3JlZW4oZWxlbWVudCk7DQogICAgfQ0KfQ0KDQpmdW5jdGlvbiBzZXR1cChjb250YWluZXIsIGZ1bGxzY3JlZW5FbGVtZW50PW51bGwpIHsNCiAgICBjb25zdCBmdWxsc2NyZWVuTGluayA9IGNvbnRhaW5lci5xdWVyeVNlbGVjdG9yKCcuZnVsbHNjcmVlbi1saW5rJyk7DQogICAgaWYgKGZ1bGxzY3JlZW5MaW5rICE9PSBudWxsKSB7DQogICAgICAgIGlmIChmdWxsc2NyZWVuRWxlbWVudCA9PT0gbnVsbCkgew0KICAgICAgICAgICAgZnVsbHNjcmVlbkVsZW1lbnQgPSBjb250YWluZXIucXVlcnlTZWxlY3Rvc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2E+DQogICAgPHNjcmlwdD5zZXR1cChkb2N1bWVudC5ib2R5LCBkb2N1bWVudC5ib2R5KTs8L3NjcmlwdD4NCjwvZGl2Pg0KPC9kaXY+PC9ib2R5Pg0KPC9odG1sPg==" allowfullscreen="true" class="container"></iframe>
+ <iframe id="iframe-with-data-url" src="data:text/html;base64,PCFET0NUWVBFIGh0bWw+DQo8aHRtbD4NCiAgICA8aGVhZD4NCiAgICAgICAgPG1ldGEgY2hhcnNldD0iVVRGLTgiPg0KICAgICAgICA8bWV0YSBuYW1lPSJ2aWV3cG9ydCIgY29udGVudD0id2lkdGg9ZGV2aWNlLXdpZHRoLGluaXRpYWwtc2NhbGU9MSI+DQogICAgICAgIDx0aXRsZT5Zb21pY2hhbiBUZXN0czwvdGl0bGU+DQogICAgICAgIDxzY3JpcHQ+DQogZnVuY3Rpb24gcmVxdWVzdEZ1bGxzY3JlZW4oZWxlbWVudCkgew0KICAgIGlmIChlbGVtZW50LnJlcXVlc3RGdWxsc2NyZWVuKSB7DQogICAgICAgIGVsZW1lbnQucmVxdWVzdEZ1bGxzY3JlZW4oKTsNCiAgICB9IGVsc2UgaWYgKGVsZW1lbnQubW96UmVxdWVzdEZ1bGxTY3JlZW4pIHsNCiAgICAgICAgZWxlbWVudC5tb3pSZXF1ZXN0RnVsbFNjcmVlbigpOw0KICAgIH0gZWxzZSBpZiAoZWxlbWVudC53ZWJraXRSZXF1ZXN0RnVsbHNjcmVlbikgew0KICAgICAgICBlbGVtZW50LndlYmtpdFJlcXVlc3RGdWxsc2NyZWVuKCk7DQogICAgfSBlbHNlIGlmIChlbGVtZW50Lm1zUmVxdWVzdEZ1bGxzY3JlZW4pIHsNCiAgICAgICAgZWxlbWVudC5tc1JlcXVlc3RGdWxsc2NyZWVuKCk7DQogICAgfQ0KfQ0KDQpmdW5jdGlvbiBleGl0RnVsbHNjcmVlbigpIHsNCiAgICBpZiAoZG9jdW1lbnQuZXhpdEZ1bGxzY3JlZW4pIHsNCiAgICAgICAg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ZG9jdW1lbnQuYm9keSk7PC9zY3JpcHQ+DQo8L2Rpdj4NCjwvZGl2PjwvYm9keT4NCjwvaHRtbD4=" allowfullscreen="true" class="container"></iframe>
</y-test>
<y-test>
@@ -107,6 +107,11 @@
</y-test>
<y-test>
+ <y-description>&lt;iframe&gt; element with srcdoc.</y-description>
+ <iframe id="iframe-with-srcdoc" allowfullscreen="true" class="container"></iframe>
+ </y-test>
+
+ <y-test>
<y-description>SVG &lt;img&gt;.</y-description>
<img src="test-document2-frame2.svg" class="container" alt="">
</y-test>
@@ -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;
})();
</script>