Bug 1283754 - Part 3: Add setupSynchronousObserver to write synchronouse tests for MutaionObserver. r?boris draft
authorHiroyuki Ikezoe <hiikezoe@mozilla-japan.org>
Fri, 14 Oct 2016 06:52:11 +0900
changeset 425008 3c4b3a5881e52b3a1822845959c279f1840ca1ab
parent 425007 637e88009a2a27518f257b17fc980960da367199
child 425009 4ead8dac8e8cac95b2eec57f0f7568a8dbf45c9f
push id32314
push userbmo:hiikezoe@mozilla-japan.org
push dateFri, 14 Oct 2016 00:31:54 +0000
reviewersboris
bugs1283754
milestone52.0a1
Bug 1283754 - Part 3: Add setupSynchronousObserver to write synchronouse tests for MutaionObserver. r?boris MozReview-Commit-ID: 1sV5QHVeEyw
dom/animation/test/testcommon.js
--- a/dom/animation/test/testcommon.js
+++ b/dom/animation/test/testcommon.js
@@ -181,8 +181,28 @@ if (opener) {
 
   function done() {
     opener.add_completion_callback(function() {
       self.close();
     });
     opener.done();
   }
 }
+
+/**
+ * Return a new MutaionObserver which started observing |target| element
+ * with { animations: true, subtree: |subtree| } option.
+ * NOTE: This observer should be used only with takeRecords(). If any of
+ * MutationRecords are observed in the callback of the MutationObserver,
+ * it will raise an assertion.
+ */
+function setupSynchronousObserver(t, target, subtree) {
+   var observer = new MutationObserver(records => {
+     assert_unreached("Any MutationRecords should not be observed in this " +
+                      "callback");
+   });
+  t.add_cleanup(() => {
+    observer.disconnect();
+  });
+  observer.observe(target, { animations: true, subtree: subtree });
+  return observer;
+}
+