Bug 1307185 - Ensure image loads don't short-circuit if the element changed trees since the last load. r=echen a=ritu
authorJosh Matthews <josh@joshmatthews.net>
Tue, 04 Oct 2016 13:50:33 -0400
changeset 350702 03e2d6478f09e7b2cc61b0fea81286a31c6d92e4
parent 350701 f6f63e52c4c70e1ce358e4cf1130b863c651685d
child 350703 4b1f9598c7e13033a550f7a138f51cbb83203bd5
push id1230
push userjlund@mozilla.com
push dateMon, 31 Oct 2016 18:13:35 +0000
treeherdermozilla-release@5e06e3766db2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersechen, ritu
bugs1307185
milestone50.0
Bug 1307185 - Ensure image loads don't short-circuit if the element changed trees since the last load. r=echen a=ritu
dom/html/HTMLImageElement.cpp
dom/html/reftests/image-load-shortcircuit-ref.html
dom/html/reftests/image-load-shortcircuit.html
dom/html/reftests/reftest.list
--- a/dom/html/HTMLImageElement.cpp
+++ b/dom/html/HTMLImageElement.cpp
@@ -660,16 +660,18 @@ HTMLImageElement::UnbindFromTree(bool aD
     nsIDocument* doc = GetOurOwnerDoc();
     MOZ_ASSERT(doc);
     if (doc) {
       doc->RemoveResponsiveContent(this);
       mInDocResponsiveContent = false;
     }
   }
 
+  mLastSelectedSource = nullptr;
+
   nsImageLoadingContent::UnbindFromTree(aDeep, aNullParent);
   nsGenericHTMLElement::UnbindFromTree(aDeep, aNullParent);
 }
 
 void
 HTMLImageElement::UpdateFormOwner()
 {
   if (!mForm) {
new file mode 100644
--- /dev/null
+++ b/dom/html/reftests/image-load-shortcircuit-ref.html
@@ -0,0 +1,1 @@
+<div><img src=pass.png></div>
new file mode 100644
--- /dev/null
+++ b/dom/html/reftests/image-load-shortcircuit.html
@@ -0,0 +1,8 @@
+<html>
+<div></div>
+<script>
+  var d = (new DOMParser()).parseFromString("<img src=pass.png>", "text/html");
+  var n = d.adoptNode(d.querySelector('img'));
+  document.querySelector('div').appendChild(n);
+</script>
+</html>
--- a/dom/html/reftests/reftest.list
+++ b/dom/html/reftests/reftest.list
@@ -30,16 +30,17 @@ skip-if(Android||B2G) == 649134-2.html 6
 
 == bug448564-1_malformed.html bug448564-1_well-formed.html
 == bug448564-1_malformed.html bug448564-1_ideal.html
 
 == bug448564-4a.html          bug448564-4b.html
 == bug502168-1_malformed.html bug502168-1_well-formed.html
 
 == responsive-image-load-shortcircuit.html responsive-image-load-shortcircuit-ref.html
+== image-load-shortcircuit.html image-load-shortcircuit-ref.html
 
 # Test that image documents taken into account CSS properties like
 # image-orientation when determining the size of the image.
 # (Fuzzy necessary due to pixel-wise comparison of different JPEGs.
 # The vast majority of the fuzziness comes from Linux and WinXP.)
 fuzzy(1,149) == bug917595-iframe-1.html    bug917595-1-ref.html
 skip-if(B2G||Mulet) fuzzy-if((!B2G&&!Mulet),3,640) == bug917595-exif-rotated.jpg bug917595-pixel-rotated.jpg # bug 1060869 # Bug 1150490 disabling on Mulet as on B2G