Bug 1317901 - Ensure image loads don't short-circuit if element's adopting steps are run; r=jdm, a=jcristau
authorEdgar Chen <echen@mozilla.com>
Fri, 18 Nov 2016 15:54:21 +0800
changeset 352638 b488c41c4a24283e2728f3e3e0c4748c691e79c5
parent 352637 cd6fe5a803f3776a2d89a9a484d36f9183b205dd
child 352639 233a0890b3b35d778b2a50f1d7b064a8bcb82fb1
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-esr52@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdm, jcristau
bugs1317901
milestone52.0a2
Bug 1317901 - Ensure image loads don't short-circuit if element's adopting steps are run; r=jdm, a=jcristau MozReview-Commit-ID: Cbg3EHtyL8f
dom/html/HTMLImageElement.cpp
dom/html/HTMLImageElement.h
dom/html/reftests/image-load-shortcircuit-1.html
dom/html/reftests/image-load-shortcircuit-2.html
dom/html/reftests/image-load-shortcircuit.html
dom/html/reftests/reftest.list
--- a/dom/html/HTMLImageElement.cpp
+++ b/dom/html/HTMLImageElement.cpp
@@ -706,16 +706,23 @@ HTMLImageElement::MaybeLoadImage()
 
 EventStates
 HTMLImageElement::IntrinsicState() const
 {
   return nsGenericHTMLElement::IntrinsicState() |
     nsImageLoadingContent::ImageState();
 }
 
+void
+HTMLImageElement::NodeInfoChanged()
+{
+  // Resetting the last selected source if adoption steps are run.
+  mLastSelectedSource = nullptr;
+}
+
 // static
 already_AddRefed<HTMLImageElement>
 HTMLImageElement::Image(const GlobalObject& aGlobal,
                         const Optional<uint32_t>& aWidth,
                         const Optional<uint32_t>& aHeight,
                         ErrorResult& aError)
 {
   nsCOMPtr<nsPIDOMWindowInner> win = do_QueryInterface(aGlobal.GetAsSupports());
--- a/dom/html/HTMLImageElement.h
+++ b/dom/html/HTMLImageElement.h
@@ -88,16 +88,18 @@ public:
   virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
                               nsIContent* aBindingParent,
                               bool aCompileEventHandlers) override;
   virtual void UnbindFromTree(bool aDeep, bool aNullParent) override;
 
   virtual EventStates IntrinsicState() const override;
   virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const override;
 
+  virtual void NodeInfoChanged() override;
+
   nsresult CopyInnerTo(Element* aDest);
 
   void MaybeLoadImage();
 
   bool IsMap()
   {
     return GetBoolAttr(nsGkAtoms::ismap);
   }
rename from dom/html/reftests/image-load-shortcircuit.html
rename to dom/html/reftests/image-load-shortcircuit-1.html
new file mode 100644
--- /dev/null
+++ b/dom/html/reftests/image-load-shortcircuit-2.html
@@ -0,0 +1,10 @@
+<html>
+<body>
+<template id="template">
+<img src="pass.png" alt="Alt Text" />
+</template>
+<script>
+  document.body.appendChild(document.getElementById('template').content.children[0].cloneNode(1));
+</script>
+</body>
+</html>
--- a/dom/html/reftests/reftest.list
+++ b/dom/html/reftests/reftest.list
@@ -30,17 +30,18 @@ skip-if(Android) == 649134-2.html 649134
 
 == 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
+== image-load-shortcircuit-1.html image-load-shortcircuit-ref.html
+== image-load-shortcircuit-2.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
 fuzzy(3,640) == bug917595-exif-rotated.jpg bug917595-pixel-rotated.jpg # bug 1060869