blob: a95a29a73b835a512b362aab323fff8b9bbe736b [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../../../../resources/js-test.js"></script>
<script src="../../../../resources/ui-helper.js"></script>
</head>
<body>
<input type="file" accept=".png" onchange="changed(event)"></input>
<script>
description("Tests a HEIC image, chosen via the file picker which accepts PNG, will be converted to a PNG image.");
jsTestIsAsync = true;
function runTest()
{
testRunner.setOpenPanelFiles(['resources/images/green-400x400.heic']);
inputElement = document.getElementsByTagName('input')[0];
UIHelper.activateAt(inputElement.offsetLeft + inputElement.offsetWidth / 2,
inputElement.offsetTop + inputElement.offsetHeight / 2);
}
function changed(event)
{
fileList = event.target.files;
shouldBe("fileList.length", "1");
file = fileList[0];
shouldBeEqualToString("file.type", "image/png");
shouldBeNonZero("file.size");
img = document.createElement("img");
document.body.appendChild(img);
var reader = new FileReader();
reader.onload = () => {
img.onload = () => {
debug("Image was loaded.");
shouldBe("img.width", "400");
shouldBe("img.height", "400");
finishJSTest();
};
img.onerror = () => {
debug("Image could not be loaded.");
shouldNotBe("img.width", "400");
shouldNotBe("img.height", "400");
finishJSTest();
};
img.src = reader.result;
};
reader.readAsDataURL(file);
}
runTest();
</script>
</body>
</html>