зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1318624 - Should not perform a load of a image if it's document is not active document; r=jdm
MozReview-Commit-ID: CjclOenaBdv
This commit is contained in:
Родитель
af5a3eaef3
Коммит
6bc9368cc5
|
@ -13,26 +13,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1118689
|
|||
/** Test for Bug 1118689 **/
|
||||
SimpleTest.requestFlakyTimeout("Just need some random timeout.");
|
||||
|
||||
function test1() {
|
||||
// test 1, check that error handling in data documents is still the same
|
||||
// as it has been for ages.
|
||||
var d = document.implementation.createHTMLDocument();
|
||||
d.body.innerHTML = "<img onerror='ok(false, \"EventHandler shouldn't be called in data document\")'>";
|
||||
d.body.firstChild.addEventListener("error",
|
||||
function() {
|
||||
ok(true, "EventListener should be called in data document");
|
||||
test2();
|
||||
});
|
||||
d.body.firstChild.addEventListener("load",
|
||||
function() {
|
||||
ok(false, "Images in data document shouldn't be loaded");
|
||||
});
|
||||
d.body.firstChild.src = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP";
|
||||
}
|
||||
|
||||
function test2() {
|
||||
// test 2, check that load event doesn't keep up being dispatched if
|
||||
// window has been closed.
|
||||
function test() {
|
||||
// check that load event doesn't keep up being dispatched if
|
||||
// window has been closed.
|
||||
var win = window.open('data:text/html,<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP" onload="this.src = this.src">',
|
||||
"", "height=100,width=100");
|
||||
setTimeout(function() {
|
||||
|
@ -45,7 +28,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1118689
|
|||
|
||||
</script>
|
||||
</head>
|
||||
<body onload="test1();">
|
||||
<body onload="test();">
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1118689">Mozilla Bug 1118689</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
|
|
@ -534,7 +534,7 @@ HTMLImageElement::SetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
|||
mResponsiveSelector->SetDefaultSource(aValue);
|
||||
}
|
||||
QueueImageLoadTask(true);
|
||||
} else if (aNotify) {
|
||||
} else if (aNotify && OwnerDoc()->IsCurrentActiveDocument()) {
|
||||
// If aNotify is false, we are coming from the parser or some such place;
|
||||
// we'll get bound after all the attributes have been set, so we'll do the
|
||||
// sync image load from BindToTree. Skip the LoadImage call in that case.
|
||||
|
@ -593,7 +593,7 @@ HTMLImageElement::SetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
|||
// per spec, full selection runs when this changes, even though
|
||||
// it doesn't directly affect the source selection
|
||||
QueueImageLoadTask(true);
|
||||
} else {
|
||||
} else if (OwnerDoc()->IsCurrentActiveDocument()) {
|
||||
// Bug 1076583 - We still use the older synchronous algorithm in
|
||||
// non-responsive mode. Force a new load of the image with the
|
||||
// new cross origin policy
|
||||
|
@ -659,7 +659,8 @@ HTMLImageElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
|||
// If loading is temporarily disabled, don't even launch MaybeLoadImage.
|
||||
// Otherwise MaybeLoadImage may run later when someone has reenabled
|
||||
// loading.
|
||||
if (LoadingEnabled()) {
|
||||
if (LoadingEnabled() &&
|
||||
OwnerDoc()->IsCurrentActiveDocument()) {
|
||||
nsContentUtils::AddScriptRunner(
|
||||
NewRunnableMethod(this, &HTMLImageElement::MaybeLoadImage));
|
||||
}
|
||||
|
@ -864,7 +865,8 @@ HTMLImageElement::CopyInnerTo(Element* aDest, bool aPreallocateChildren)
|
|||
// 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)) {
|
||||
dest->HasAttr(kNameSpaceID_None, nsGkAtoms::src) &&
|
||||
dest->OwnerDoc()->IsCurrentActiveDocument()) {
|
||||
// Mark channel as urgent-start before load image if the image load is
|
||||
// initaiated by a user interaction.
|
||||
mUseUrgentStartForChannel = EventStateManager::IsHandlingUserInput();
|
||||
|
|
Загрузка…
Ссылка в новой задаче