diff options
| author | Christophe Matthieu <chm@openerp.com> | 2013-09-06 10:35:00 +0200 |
|---|---|---|
| committer | Christophe Matthieu <chm@openerp.com> | 2013-09-06 10:35:00 +0200 |
| commit | 8a3f1742e0e9c7acaae726e5c7106d2d7df7e970 (patch) | |
| tree | 78ae5d981fcd25677caea5c8b3999b1e77bf4547 /addons/website/static/lib/MutationObservers/test/characterData.js | |
| parent | 6f6c59ec1de1881a70e4bf728ea5d8b56bd609f9 (diff) | |
| parent | c80cf7d0646463b290137c26fbada568a6942b00 (diff) | |
[MERGE] from website-al
bzr revid: chm@openerp.com-20130906083500-4n5knaxiqt4cg2ht
Diffstat (limited to 'addons/website/static/lib/MutationObservers/test/characterData.js')
| -rw-r--r-- | addons/website/static/lib/MutationObservers/test/characterData.js | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/addons/website/static/lib/MutationObservers/test/characterData.js b/addons/website/static/lib/MutationObservers/test/characterData.js new file mode 100644 index 00000000000..498dc053e6e --- /dev/null +++ b/addons/website/static/lib/MutationObservers/test/characterData.js @@ -0,0 +1,106 @@ +/* + * 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 characterData', function() { + + var testDiv; + + setup(function() { + testDiv = document.body.appendChild(document.createElement('div')); + }); + + teardown(function() { + document.body.removeChild(testDiv); + }); + + test('characterData', function() { + var text = document.createTextNode('abc'); + var observer = new JsMutationObserver(function() {}); + observer.observe(text, { + characterData: true + }); + text.data = 'def'; + text.data = 'ghi'; + + var records = observer.takeRecords(); + assert.strictEqual(records.length, 2); + + expectRecord(records[0], { + type: 'characterData', + target: text + }); + expectRecord(records[1], { + type: 'characterData', + target: text + }); + }); + + test('characterData with old value', function() { + var text = testDiv.appendChild(document.createTextNode('abc')); + var observer = new JsMutationObserver(function() {}); + observer.observe(text, { + characterData: true, + characterDataOldValue: true + }); + text.data = 'def'; + text.data = 'ghi'; + + var records = observer.takeRecords(); + assert.strictEqual(records.length, 2); + + expectRecord(records[0], { + type: 'characterData', + target: text, + oldValue: 'abc' + }); + expectRecord(records[1], { + type: 'characterData', + target: text, + oldValue: 'def' + }); + }); + + test('characterData change in subtree should not generate a record', + function() { + var div = document.createElement('div'); + var text = div.appendChild(document.createTextNode('abc')); + var observer = new JsMutationObserver(function() {}); + observer.observe(div, { + characterData: true + }); + text.data = 'def'; + text.data = 'ghi'; + + var records = observer.takeRecords(); + assert.strictEqual(records.length, 0); + }); + + test('characterData change in subtree', + function() { + var div = document.createElement('div'); + var text = div.appendChild(document.createTextNode('abc')); + var observer = new JsMutationObserver(function() {}); + observer.observe(div, { + characterData: true, + subtree: true + }); + text.data = 'def'; + text.data = 'ghi'; + + var records = observer.takeRecords(); + assert.strictEqual(records.length, 2); + + expectRecord(records[0], { + type: 'characterData', + target: text + }); + expectRecord(records[1], { + type: 'characterData', + target: text + }); + }); + +});
\ No newline at end of file |
