Bug 1321300 - Back out bug 1264768 and add test. r=hsivonen. a=gchang
authorEdgar Chen <echen@mozilla.com>
Mon, 09 Jan 2017 11:50:55 +0800
changeset 353600 6d03505155dd3d0f53f4679418f803712dd0f0b7
parent 353599 29164ffa1889e8a8e94c6e61f4c80f8f3c1427f7
child 353601 f987327e5c36f94610120cd97fed376e0447893f
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)
reviewershsivonen, gchang
bugs1321300, 1264768
milestone52.0a2
Bug 1321300 - Back out bug 1264768 and add test. r=hsivonen. a=gchang MozReview-Commit-ID: KsN18tG0Ptb
dom/base/nsImageLoadingContent.cpp
dom/tests/mochitest/general/test_img_mutations.html
testing/web-platform/meta/html/semantics/embedded-content/the-img-element/invalid-src.html.ini
--- a/dom/base/nsImageLoadingContent.cpp
+++ b/dom/base/nsImageLoadingContent.cpp
@@ -761,23 +761,18 @@ nsImageLoadingContent::LoadImage(const n
   }
 
   // Fire loadstart event
   FireEvent(NS_LITERAL_STRING("loadstart"));
 
   // Parse the URI string to get image URI
   nsCOMPtr<nsIURI> imageURI;
   nsresult rv = StringToURI(aNewURI, doc, getter_AddRefs(imageURI));
-  if (NS_FAILED(rv)) {
-    // Cancel image requests and then fire error and loadend events per spec
-    CancelImageRequests(aNotify);
-    FireEvent(NS_LITERAL_STRING("error"));
-    FireEvent(NS_LITERAL_STRING("loadend"));
-    return NS_OK;
-  }
+  NS_ENSURE_SUCCESS(rv, rv);
+  // XXXbiesi fire onerror if that failed?
 
   NS_TryToSetImmutable(imageURI);
 
   return LoadImage(imageURI, aForce, aNotify, aImageLoadType, false, doc);
 }
 
 nsresult
 nsImageLoadingContent::LoadImage(nsIURI* aNewURI,
--- a/dom/tests/mochitest/general/test_img_mutations.html
+++ b/dom/tests/mochitest/general/test_img_mutations.html
@@ -62,16 +62,19 @@
     //
     // Test that img.src still does some work synchronously per the older spec (bug 1076583)
     //
     tests.push(function test1() {
       info("test 1");
       img.src = testPNG50;
       is(img.currentSrc, testPNG50, "Should have synchronously selected source");
 
+      // Assigning a wrong URL should not trigger error event (bug 1321300).
+      img.src = '//:0'; // Wrong URL
+
       img.src = "non_existent_image.404";
       ok(img.currentSrc.endsWith("non_existent_image.404"), "Should have synchronously selected source");
 
       img.removeAttribute("src");
       is(img.currentSrc, '', "Should have dropped currentSrc");
 
       // Load another image while previous load is still pending
       img.src = testPNG200;
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/meta/html/semantics/embedded-content/the-img-element/invalid-src.html.ini
@@ -0,0 +1,6 @@
+[invalid-src.html]
+  type: testharness
+  expected: TIMEOUT
+  [src="http://also a broken url"]
+    expected: TIMEOUT
+