Bug 710761 - test if CC listener begin fails, don't call listener again. rs=bholley
authorAndrew McCreight <amccreight@mozilla.com>
Wed, 14 Dec 2011 15:56:37 -0800
changeset 83402 4946cb558c97132f050eb22e3eb6ec93630abef8
parent 83401 a9394f00a379e028f472cceec96b90703cd0f63b
child 83403 472b4a4ebea7b1c73fd8c9ec15d07a805acc068d
push idunknown
push userunknown
push dateunknown
reviewersbholley
bugs710761
milestone11.0a1
Bug 710761 - test if CC listener begin fails, don't call listener again. rs=bholley
js/xpconnect/tests/chrome/Makefile.in
js/xpconnect/tests/chrome/test_ccbeginfail.xul
--- a/js/xpconnect/tests/chrome/Makefile.in
+++ b/js/xpconnect/tests/chrome/Makefile.in
@@ -70,16 +70,17 @@ include $(topsrcdir)/config/rules.mk
 		test_bug679861.xul \
 		test_APIExposer.xul \
 		test_bug664689.xul \
 		test_precisegc.xul \
 		test_nodelists.xul \
 		test_getweakmapkeys.xul \
 		test_weakmaps.xul \
 		test_bug706301.xul \
+		test_ccbeginfail.xul \
 		$(NULL)
 
 # Disabled until this test gets updated to test the new proxy based
 # wrappers.
 #		test_wrappers-2.xul \
 
 libs:: $(_CHROME_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/chrome/$(relativesrcdir)
new file mode 100644
--- /dev/null
+++ b/js/xpconnect/tests/chrome/test_ccbeginfail.xul
@@ -0,0 +1,67 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
+<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=710761
+-->
+<window title="Mozilla Bug 710761"
+        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+
+  <!-- test results are displayed in the html:body -->
+  <body xmlns="http://www.w3.org/1999/xhtml">
+  <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=710761"
+     target="_blank">Mozilla Bug 710761</a>
+  </body>
+
+  <!-- test code goes here -->
+  <script type="application/javascript">
+  <![CDATA[
+  /** Test for Bug 710761 **/
+
+  let noCallbacks = true;
+
+  var beginFailListener = {
+    QueryInterface: function QueryInterface(aIID) {
+      if (aIID.equals(Components.interfaces.nsICycleCollectorListener) ||
+          aIID.equals(Components.interfaces.nsISupports))
+        return this;
+      throw Components.results.NS_NOINTERFACE;
+    },
+
+    /* nsICycleCollectorListener */
+    begin: function () {
+      throw Components.results.NS_ERROR_FAILURE;
+    },
+    noteRefCountedObject: function (addr, rc, descr) {
+      noCallbacks = false;
+    },
+    noteGCedObject: function (addr, marked, descr) {
+      noCallbacks = false;
+    },
+    noteEdge: function (addr, descr) {
+      noCallbacks = false;
+    },
+    beginResults: function () {
+      noCallbacks = false;
+    },
+    describeRoot: function (addr, known) {
+      noCallbacks = false;
+    },
+    describeGarbage: function (addr) {
+      noCallbacks = false;
+    },
+    end: function () {
+      noCallbacks = false;
+    },
+  };
+
+  window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
+        .getInterface(Components.interfaces.nsIDOMWindowUtils)
+        .cycleCollect(beginFailListener);
+
+  ok(noCallbacks, "If cycle collector listener begin fails, no further callbacks should be called.");
+
+  ]]>
+  </script>
+</window>