An HTMLImageElement can be adopted across documents while an image update is still pending. In that case the element's wrapper realm can still be the old iframe realm, but the image request must be created and fetched using the element's current node document. Using the old iframe realm associates the request with the removed iframe's document-owned image request cache, so the adopted image can fail to complete in the parent document. Use document().realm() when creating/updating/fetching image requests so adopted images continue loading in their new document. Add a regression for an image created in an iframe, then adopted into the parent after the iframe is removed. Chromium and Webkit do not fire a load event for the test, but Firefox does. All load the image, where we previously did not. See: https://github.com/whatwg/html/issues/8492
29 lines
1 KiB
HTML
29 lines
1 KiB
HTML
<!DOCTYPE html>
|
|
<script src="../include.js"></script>
|
|
<script>
|
|
asyncTest(done => {
|
|
const iframe = document.createElement("iframe");
|
|
iframe.onload = () => {
|
|
const img = iframe.contentDocument.createElement("img");
|
|
|
|
// See: https://github.com/whatwg/html/issues/8492
|
|
img.onload = () => {
|
|
println("image loaded after adoption");
|
|
println(`width=${img.width} height=${img.height} naturalWidth=${img.naturalWidth} naturalHeight=${img.naturalHeight} complete=${img.complete}`);
|
|
done();
|
|
};
|
|
img.onerror = () => {
|
|
println("image errored after adoption");
|
|
done();
|
|
};
|
|
|
|
img.src = new URL("../../../Assets/120.png", document.baseURI).href;
|
|
iframe.contentDocument.body.appendChild(img);
|
|
|
|
iframe.remove();
|
|
document.body.appendChild(document.adoptNode(img));
|
|
};
|
|
|
|
document.body.appendChild(iframe);
|
|
});
|
|
</script>
|