Bug 1283754 - Part 3: Add setupSynchronousObserver to write synchronouse tests for MutaionObserver. r?boris
MozReview-Commit-ID: 1sV5QHVeEyw
--- 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;
+}
+