Bug 827541 - Traverse/Unlink nsGlobalWindow::mAudioContexts. r=ehsan
authorAndrew McCreight <amccreight@mozilla.com>
Mon, 14 Jan 2013 15:22:00 -0800
changeset 118818 0ff42bab2f662cf3dc78e43d7b4f2bd0e0d8a2ee
parent 118817 809dac438e946fcea8e50f112d293d627ab26837
child 118819 7c102b657a17761295a0eedbd18f5f8cee5f8d5b
push id24180
push useremorley@mozilla.com
push dateTue, 15 Jan 2013 22:58:27 +0000
treeherdermozilla-central@72e34ce7fd92 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs827541
milestone21.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 827541 - Traverse/Unlink nsGlobalWindow::mAudioContexts. r=ehsan
content/media/webaudio/test/Makefile.in
content/media/webaudio/test/test_bug827541.html
dom/base/nsGlobalWindow.cpp
--- a/content/media/webaudio/test/Makefile.in
+++ b/content/media/webaudio/test/Makefile.in
@@ -8,16 +8,17 @@ srcdir         := @srcdir@
 VPATH          := @srcdir@
 relativesrcdir := @relativesrcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MOCHITEST_FILES := \
   webaudio.js \
   test_bug808374.html \
+  test_bug827541.html \
   test_AudioBuffer.html \
   test_AudioContext.html \
   test_AudioListener.html \
   test_badConnect.html \
   test_biquadFilterNode.html \
   test_delayNode.html \
   test_dynamicsCompressorNode.html \
   test_gainNode.html \
new file mode 100644
--- /dev/null
+++ b/content/media/webaudio/test/test_bug827541.html
@@ -0,0 +1,25 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Tell the cycle collector about the audio contexts owned by nsGlobalWindow</title>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+  SpecialPowers.setBoolPref("media.webaudio.enabled", true);
+
+  var iframe = document.createElementNS("http://www.w3.org/1999/xhtml", "iframe");
+  document.body.appendChild(iframe);
+  var frameWin = iframe.contentWindow;
+  frameWin.mozAudioContext;
+  document.body.removeChild(iframe);
+  frameWin.mozAudioContext();
+
+  ok(true, "This test should not leak");
+  SpecialPowers.clearUserPref("media.webaudio.enabled");
+</script>
+</pre>
+</body>
+</html>
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -1288,28 +1288,26 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_
   }
 
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mLocalStorage)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSessionStorage)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mApplicationCache)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDocumentPrincipal)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDoc)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mIdleService)
+  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPendingStorageEvents)
+  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mIdleObservers)
 
   // Traverse stuff from nsPIDOMWindow
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mChromeEventHandler)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mParentTarget)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDocument)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mFrameElement)
-
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mFocusedNode)
-
-  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPendingStorageEvents)
-
-  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mIdleObservers)
+  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mAudioContexts)
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsGlobalWindow)
   nsGlobalWindow::CleanupCachedXBLHandlers(tmp);
 
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mContext)
 
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mControllers)
@@ -1328,30 +1326,27 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(ns
     tmp->mListenerManager->Disconnect();
     NS_IMPL_CYCLE_COLLECTION_UNLINK(mListenerManager)
   }
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mLocalStorage)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mSessionStorage)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mApplicationCache)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mDocumentPrincipal)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mDoc)
+  NS_IMPL_CYCLE_COLLECTION_UNLINK(mIdleService)
+  NS_IMPL_CYCLE_COLLECTION_UNLINK(mPendingStorageEvents)
+  NS_IMPL_CYCLE_COLLECTION_UNLINK(mIdleObservers)
 
   // Unlink stuff from nsPIDOMWindow
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mChromeEventHandler)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mParentTarget)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mDocument)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mFrameElement)
-
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mFocusedNode)
-  NS_IMPL_CYCLE_COLLECTION_UNLINK(mIdleService)
-
-  NS_IMPL_CYCLE_COLLECTION_UNLINK(mPendingStorageEvents)
-
-  NS_IMPL_CYCLE_COLLECTION_UNLINK(mIdleObservers)
-
+  NS_IMPL_CYCLE_COLLECTION_UNLINK(mAudioContexts)
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 
 struct TraceData
 {
   TraceData(TraceCallback& aCallback, void* aClosure) :
     callback(aCallback), closure(aClosure) {}
 
   TraceCallback& callback;