Bug 1576154 - Check mSVGDocumentWrapper when trying to report use counters; r=smaug
authorEdgar Chen <echen@mozilla.com>
Sun, 25 Aug 2019 22:45:33 +0000
changeset 553565 b72d1d6131cce6845af6ffd6f83de7f993930961
parent 553564 929421783c5b36bf179f503d82f709eaff53c94e
child 553566 1429658f80ca4dc9d2e02fbfa9fdafe7e10b1393
push id2165
push userffxbld-merge
push dateMon, 14 Oct 2019 16:30:58 +0000
treeherdermozilla-release@0eae18af659f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1576154
milestone70.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1576154 - Check mSVGDocumentWrapper when trying to report use counters; r=smaug Differential Revision: https://phabricator.services.mozilla.com/D43256
dom/base/test/bug1576154.sjs
dom/base/test/green.png
dom/base/test/mochitest.ini
dom/base/test/test_bug1576154.html
image/VectorImage.cpp
new file mode 100644
--- /dev/null
+++ b/dom/base/test/bug1576154.sjs
@@ -0,0 +1,8 @@
+function handleRequest(request, response)
+{
+  response.setStatusLine("1.1", 500, "Internal Server Error");
+  response.setHeader("Content-Type", "image/svg+xml", false);
+
+  let body = "<svg xmlns='http://www.w3.org/2000/svg' width='70' height='0'></svg>";
+  response.bodyOutputStream.write(body, body.length);
+}
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..7df25f33bdb26cc7f41138501ab399059839137d
GIT binary patch
literal 255
zc%17D@N?(olHy`uVBq!ia0vp^DIm<j1SJ1AFfjuu&H|6fVg?3oVGw3ym^DWND9B#o
z>FdgVmrY2>Os;yW$XlS$JWm(LkcwMxFBmd1FmNz0$ozjU>fm{HrGS|QSGZD6PEz%r
zro*}k!eEMoFdB8hjHM3Kz>FXTZ!kl1f-0CHassR?l5*|8wspoc9#?7J!~=9GgQu&X
J%Q~loCICH_Rq+4-
--- a/dom/base/test/mochitest.ini
+++ b/dom/base/test/mochitest.ini
@@ -47,16 +47,17 @@ support-files =
   bug638112-response.txt
   bug638112.sjs
   bug696301-script-1.js
   bug696301-script-1.js^headers^
   bug696301-script-2.js
   bug704320.sjs
   bug704320_counter.sjs
   bug819051.sjs
+  bug1576154.sjs
   chrome/bug418986-1.js
   copypaste.js
   delayedServerEvents.sjs
   eventsource.resource
   eventsource.resource^headers^
   eventsource_redirect.resource
   eventsource_redirect.resource^headers^
   eventsource_redirect_to.resource
@@ -239,16 +240,17 @@ support-files =
   file2_setting_opener.html
   file3_setting_opener.html
   file4_setting_opener.html
   PASS.html
   FAIL.html
   !/dom/animation/test/testcommon.js
   !/dom/events/test/event_leak_utils.js
   ../../../browser/extensions/pdfjs/test/file_pdfjs_test.pdf
+  green.png
 
 [test_anchor_area_referrer.html]
 [test_anchor_area_referrer_changing.html]
 [test_anchor_area_referrer_invalid.html]
 [test_anchor_area_referrer_rel.html]
 [test_anonymousContent_api.html]
 [test_anonymousContent_append_after_reflow.html]
 [test_anonymousContent_canvas.html]
@@ -629,16 +631,17 @@ skip-if = toolkit == 'android'
 [test_bug1404385.html]
 [test_bug1406102.html]
 [test_bug1421568.html]
 [test_bug1453693.html]
 skip-if = os == "mac" # Different tab focus behavior on mac
 [test_bug1472427.html]
 [test_bug1499169.html]
 skip-if = toolkit == 'android' # Timeouts on android due to page closing issues with embedded pdf
+[test_bug1576154.html]
 [test_caretPositionFromPoint.html]
 [test_change_policy.html]
 [test_clearTimeoutIntervalNoArg.html]
 [test_constructor-assignment.html]
 [test_constructor.html]
 [test_content_iterator_post_order.html]
 [test_content_iterator_pre_order.html]
 [test_content_iterator_subtree.html]
new file mode 100644
--- /dev/null
+++ b/dom/base/test/test_bug1576154.html
@@ -0,0 +1,36 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1576154
+-->
+<head>
+  <title>Test for Bug 1576154</title>
+  <script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
+  <script src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1576154">Mozilla Bug 1576154</a>
+<p id="display"></p>
+<!-- bug1576154.sjs returns an SVG image with HTTP error code 500. -->
+<img src="bug1576154.sjs">
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+/** Test for Bug 657191 **/
+SimpleTest.waitForExplicitFinish();
+
+window.onload = function() {
+  let img = document.querySelector("img");
+  img.src = "green.png";
+  img.onload = function() {
+    // As long as this doesn't crash, this test passes.
+    ok(true, "test passed");
+    SimpleTest.finish();
+  };
+}
+
+</script>
+</pre>
+</body>
+</html>
--- a/image/VectorImage.cpp
+++ b/image/VectorImage.cpp
@@ -1278,17 +1278,18 @@ NS_IMETHODIMP
 VectorImage::RequestDiscard() {
   MOZ_ASSERT(NS_IsMainThread());
 
   if (mDiscardable && mLockCount == 0) {
     SurfaceCache::RemoveImage(ImageKey(this));
     mProgressTracker->OnDiscard();
   }
 
-  if (Document* doc = mSVGDocumentWrapper->GetDocument()) {
+  if (Document* doc =
+          mSVGDocumentWrapper ? mSVGDocumentWrapper->GetDocument() : nullptr) {
     doc->ReportUseCounters();
   }
 
   return NS_OK;
 }
 
 void VectorImage::OnSurfaceDiscarded(const SurfaceKey& aSurfaceKey) {
   MOZ_ASSERT(mProgressTracker);