Bug 1343589 - Move setupSynchronousObserver from testcommon.js to test_animation_observers_sync.html
This function is only used in test_animation_observers_sync.html. Putting it in
another file makes test_animation_observers_sync.html harder to follow so until
we actually share it with other files we should be it in the one file.
MozReview-Commit-ID: DJXWH4wFWxZ
--- a/dom/animation/test/chrome/test_animation_observers_sync.html
+++ b/dom/animation/test/chrome/test_animation_observers_sync.html
@@ -22,16 +22,36 @@ Test chrome-only MutationObserver animat
to { transform: translate(100px); }
}
@keyframes anotherAnim {
to { transform: translate(0px); }
}
</style>
<script>
+/**
+ * Return a new MutationObserver which 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;
+}
+
function assert_record_list(actual, expected, desc, index, listName) {
assert_equals(actual.length, expected.length,
`${desc} - record[${index}].${listName} length`);
if (actual.length != expected.length) {
return;
}
for (var i = 0; i < actual.length; i++) {
assert_not_equals(actual.indexOf(expected[i]), -1,
--- a/dom/animation/test/testcommon.js
+++ b/dom/animation/test/testcommon.js
@@ -277,35 +277,16 @@ if (opener) {
function done() {
opener.add_completion_callback(function() {
self.close();
});
opener.done();
}
}
-/**
- * Return a new MutationObserver 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;
-}
-
/*
* Returns a promise that is resolved when the document has finished loading.
*/
function waitForDocumentLoad() {
return new Promise(function(resolve, reject) {
if (document.readyState === "complete") {
resolve();
} else {