summaryrefslogtreecommitdiff
path: root/addons/website/static/lib/MutationObservers/test/callback.js
diff options
context:
space:
mode:
authorAntony Lesuisse <al@openerp.com>2014-01-31 01:51:57 +0100
committerAntony Lesuisse <al@openerp.com>2014-01-31 01:51:57 +0100
commit4b30f1fcbd8701f82dbbe4e5c8386ee432b063ac (patch)
tree93b17a03b45927c20fbb045cda8c8aa09d853409 /addons/website/static/lib/MutationObservers/test/callback.js
parentba2d4c90307661a79d78e6ce3b274b76b4c62717 (diff)
parent1c283ddf242f0681c1d060f3b8658efa3fcaa0a8 (diff)
[MERGE] trunk-website-al
bzr revid: al@openerp.com-20140131005157-jkf8hz6fh2buml2c
Diffstat (limited to 'addons/website/static/lib/MutationObservers/test/callback.js')
-rw-r--r--addons/website/static/lib/MutationObservers/test/callback.js72
1 files changed, 72 insertions, 0 deletions
diff --git a/addons/website/static/lib/MutationObservers/test/callback.js b/addons/website/static/lib/MutationObservers/test/callback.js
new file mode 100644
index 00000000000..b3083c7bec3
--- /dev/null
+++ b/addons/website/static/lib/MutationObservers/test/callback.js
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2012 The Polymer Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style
+ * license that can be found in the LICENSE file.
+ */
+
+suite('JsMutationObserver callback', function() {
+
+ test('One observer, two attribute changes', function(cont) {
+ var div = document.createElement('div');
+ var observer = new JsMutationObserver(function(records) {
+ assert.strictEqual(records.length, 2);
+
+ expectRecord(records[0], {
+ type: 'attributes',
+ target: div,
+ attributeName: 'a',
+ attributeNamespace: null
+ });
+ expectRecord(records[1], {
+ type: 'attributes',
+ target: div,
+ attributeName: 'a',
+ attributeNamespace: null
+ });
+
+ cont();
+ });
+
+ observer.observe(div, {
+ attributes: true
+ });
+
+ div.setAttribute('a', 'A');
+ div.setAttribute('a', 'B');
+ });
+
+ test('nested changes', function(cont) {
+ var div = document.createElement('div');
+ var i = 0;
+ var observer = new JsMutationObserver(function(records) {
+ assert.strictEqual(records.length, 1);
+
+ if (i === 0) {
+ expectRecord(records[0], {
+ type: 'attributes',
+ target: div,
+ attributeName: 'a',
+ attributeNamespace: null
+ });
+ div.setAttribute('b', 'B');
+ i++;
+ } else {
+ expectRecord(records[0], {
+ type: 'attributes',
+ target: div,
+ attributeName: 'b',
+ attributeNamespace: null
+ });
+
+ cont();
+ }
+ });
+
+ observer.observe(div, {
+ attributes: true
+ });
+
+ div.setAttribute('a', 'A');
+ });
+
+}); \ No newline at end of file