зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1184647. Cloning an image should ensure that the clone tries to load the src, if any. r=smaug
This commit is contained in:
Родитель
78588ac104
Коммит
68976f61f9
|
@ -800,10 +800,30 @@ HTMLImageElement::GetNaturalWidth(uint32_t* aNaturalWidth)
|
|||
nsresult
|
||||
HTMLImageElement::CopyInnerTo(Element* aDest)
|
||||
{
|
||||
if (aDest->OwnerDoc()->IsStaticDocument()) {
|
||||
CreateStaticImageClone(static_cast<HTMLImageElement*>(aDest));
|
||||
bool destIsStatic = aDest->OwnerDoc()->IsStaticDocument();
|
||||
auto dest = static_cast<HTMLImageElement*>(aDest);
|
||||
if (destIsStatic) {
|
||||
CreateStaticImageClone(dest);
|
||||
}
|
||||
return nsGenericHTMLElement::CopyInnerTo(aDest);
|
||||
|
||||
nsresult rv = nsGenericHTMLElement::CopyInnerTo(aDest);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (!destIsStatic) {
|
||||
// In SetAttr (called from nsGenericHTMLElement::CopyInnerTo), dest skipped
|
||||
// doing the image load because we passed in false for aNotify. But we
|
||||
// really do want it to do the load, so set it up to happen once the cloning
|
||||
// reaches a stable state.
|
||||
if (!dest->InResponsiveMode() &&
|
||||
dest->HasAttr(kNameSpaceID_None, nsGkAtoms::src)) {
|
||||
nsContentUtils::AddScriptRunner(
|
||||
NS_NewRunnableMethod(dest, &HTMLImageElement::MaybeLoadImage));
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
CORSMode
|
||||
|
|
|
@ -599,3 +599,4 @@ skip-if = buildapp == 'b2g' # bug 1129014
|
|||
[test_img_complete.html]
|
||||
[test_viewport_resize.html]
|
||||
[test_extapp.html]
|
||||
[test_image_clone_load.html]
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<title>Test for image clones doing their load</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
var t = async_test("The clone of an image should do the load of the same image, and do it synchronously");
|
||||
t.step(function() {
|
||||
var img = new Image();
|
||||
img.onload = t.step_func(function() {
|
||||
var clone = img.cloneNode();
|
||||
assert_not_equals(img.naturalWidth, 0, "Should have a width");
|
||||
assert_equals(clone.naturalWidth, img.naturalWidth,
|
||||
"Clone should have a width too");
|
||||
// And make sure the clone fires onload too, which happens async.
|
||||
clone.onload = function() { t.done() }
|
||||
});
|
||||
img.src = "image.png";
|
||||
});
|
||||
</script>
|
Загрузка…
Ссылка в новой задаче