blob: e2dbc43951bd7e6362e179b9bdc7873c6eb8e2f4 [file] [edit]
<!DOCTYPE html>
<html>
<body>
<script src="../../resources/js-test.js"></script>
<div id="destination" contenteditable="true" style="width: 500px; height: 100px; border: solid red 1px"></div>
<iframe id="iframe" src="../resources/abe.png" onload="selectInFrame()"></iframe>
</body>
<script>
description("Tests that pasted images use data URLs with valid MIME types.");
jsTestIsAsync = true;
function selectInFrame() {
if (window.internals)
window.internals.settings.setPreferMIMETypeForImages(true);
var iframe = document.getElementById("iframe");
var iframeDocument = iframe.contentDocument;
var destination = document.getElementById("destination");
iframeDocument.body.focus();
iframeDocument.execCommand("SelectAll");
iframeDocument.execCommand("Copy");
destination.focus();
document.execCommand("Paste");
pastedImages = destination.getElementsByTagName("img");
shouldBe("pastedImages.length", "1");
img = pastedImages[0];
url = new URL(img.src);
shouldBeEqualToString("url.protocol", "data:");
shouldBeTrue("img.src.startsWith('data:image/')");
shouldBeTrue("img.src.includes(';base64,')");
finishJSTest();
}
</script>
</html>