<!DOCTYPE html>
<html>
<body>
<script src="../../resources/js-test-pre.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 blob URL, not webkit fake URLs.");
    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", "blob:");

        finishJSTest();
    }
</script>
<script src="../../resources/js-test-post.js"></script>
</html>
