Bug 919265 - Part 2: Add ClearOnShutdown() call on the static WebVTTParserWrapper. r=bz
authorRick Eyre <rick.eyre@hotmail.com>
Tue, 24 Sep 2013 15:17:15 -0400
changeset 148805 07e358bb9954fb6ab0f7a6ba66223e0aeb16ae2b
parent 148804 fd0ad8462ba78ddbe6e915404cdceb8f79d1db8a
child 148806 ff6fed474ee21287e1ff94a148353063768f52dd
push id25360
push userryanvm@gmail.com
push dateFri, 27 Sep 2013 01:29:18 +0000
treeherdermozilla-central@4313ea50a8ee [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs919265
milestone27.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 919265 - Part 2: Add ClearOnShutdown() call on the static WebVTTParserWrapper. r=bz
content/media/TextTrackCue.cpp
content/media/test/Makefile.in
content/media/test/test_bug919265.html
--- a/content/media/TextTrackCue.cpp
+++ b/content/media/TextTrackCue.cpp
@@ -3,16 +3,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/dom/HTMLTrackElement.h"
 #include "mozilla/dom/TextTrackCue.h"
 #include "nsIFrame.h"
 #include "nsVideoFrame.h"
 #include "nsComponentManagerUtils.h"
+#include "mozilla/ClearOnShutdown.h"
 
 // Alternate value for the 'auto' keyword.
 #define WEBVTT_AUTO -1
 
 namespace mozilla {
 namespace dom {
 
 NS_IMPL_CYCLE_COLLECTION_INHERITED_4(TextTrackCue,
@@ -157,16 +158,17 @@ TextTrackCue::GetCueAsHTML()
   if (!sParserWrapper) {
     nsresult rv;
     nsCOMPtr<nsIWebVTTParserWrapper> parserWrapper =
       do_CreateInstance(NS_WEBVTTPARSERWRAPPER_CONTRACTID, &rv);
     if (NS_FAILED(rv)) {
       return mDocument->CreateDocumentFragment();
     }
     sParserWrapper = parserWrapper;
+    ClearOnShutdown(&sParserWrapper);
   }
 
   nsPIDOMWindow* window = mDocument->GetWindow();
   if (!window) {
     return mDocument->CreateDocumentFragment();
   }
 
   nsCOMPtr<nsIDOMHTMLElement> div;
--- a/content/media/test/Makefile.in
+++ b/content/media/test/Makefile.in
@@ -59,20 +59,26 @@ MOCHITEST_FILES = \
 		seek11.js \
 		seek12.js \
 		seek13.js \
 		seekLies.sjs \
 		test_access_control.html \
 		test_audio1.html \
 		test_audio2.html \
 		test_autoplay.html \
+		test_bug448534.html \
+		test_bug463162.xhtml \
 		test_bug495145.html \
 		test_bug495300.html \
 		test_bug654550.html \
 		test_bug686942.html \
+		test_bug883173.html \
+		test_bug895305.html \
+		test_bug895091.html \
+		test_bug919265.html \
 		test_can_play_type.html \
 		test_can_play_type_mpeg.html \
 		test_closing_connections.html \
 		test_constants.html \
 		test_controls.html \
 		test_currentTime.html \
 		test_decode_error.html \
 		test_defaultMuted.html \
@@ -113,18 +119,16 @@ MOCHITEST_FILES = \
 		test_mediarecorder_creation.html \
 		test_mediarecorder_avoid_recursion.html \
 		test_mediarecorder_record_timeslice.html \
 		test_mediarecorder_record_audiocontext.html \
 		test_mediarecorder_record_stopms.html \
 		test_mozHasAudio.html \
 		test_source_media.html \
 		test_autoplay_contentEditable.html \
-		test_bug448534.html \
-		test_bug463162.xhtml \
 		test_decoder_disable.html \
 		test_mediarecorder_record_no_timeslice.html \
 		test_mediarecorder_reload_crash.html \
 		test_mediarecorder_record_immediate_stop.html \
 		test_media_selection.html \
 		test_playback.html \
 		test_seekLies.html \
 		test_media_sniffer.html \
@@ -141,19 +145,16 @@ MOCHITEST_FILES = \
 		test_texttrack.html \
 		test_texttrackcue.html \
 		test_texttrackregion.html \
 		test_timeupdate_small_files.html \
 		test_unseekable.html \
 		test_VideoPlaybackQuality.html \
 		test_VideoPlaybackQuality_disabled.html \
 		test_webvtt_disabled.html \
-		test_bug895305.html \
-		test_bug895091.html \
-		test_bug883173.html \
 		$(NULL)
 
 # Don't run in suite
 ifndef MOZ_SUITE
 MOCHITEST_FILES += test_play_twice.html
 else
 $(filter disabled-pending-investigation--bug-598252, test_play_twice.html)
 endif
new file mode 100644
--- /dev/null
+++ b/content/media/test/test_bug919265.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=919265
+-->
+<head>
+  <meta charset='utf-8'>
+  <title>Regression test for bug 919265 - Leak on VTTCue::GetCueAsHTML()</title>
+  <script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<p id="display"></p>
+<div id="content" style="display: none">
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+SimpleTest.waitForExplicitFinish();
+SpecialPowers.pushPrefEnv({"set": [["media.webvtt.enabled", true]]},
+  function() {
+    // We shouldn't leak upon shutdown.
+    (new VTTCue(0, 0, "")).getCueAsHTML();
+    // We need to assert something for Mochitest to be happy.
+    ok(true);
+    SimpleTest.finish();
+  }
+);
+</script>
+</pre>
+</body>
+</html>