Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Side by Side Diff: sky/tests/mutation-observer/document-fragment-insertion.html

Issue 685623002: Move the tests from .html to .sky (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <html>
2 <link rel="import" href="../resources/mocha.html" />
3 <link rel="import" href="../resources/chai.html" />
4 <script>
5 describe('DocumentFragments should remove all children of the fragment before mo ving children, ', function() {
6 var mutations;
7 var observer;
8
9 beforeEach(function() {
10 mutations = null;
11 observer = new MutationObserver(function(records) {
12 mutations = records;
13 });
14 });
15
16 function createObservedFragment() {
17 var fragment = document.createDocumentFragment();
18 fragment.appendChild(document.createElement('b'));
19 fragment.appendChild(document.createElement('i'));
20 observer.observe(fragment, {childList: true});
21 return fragment;
22 }
23
24 it('using appendChild', function(done) {
25 var div = document.createElement('div');
26 observer.observe(div, {childList: true});
27 div.appendChild(createObservedFragment());
28 setTimeout(function() {
29 assert.equal(mutations.length, 2);
30 assert.equal(mutations[0].addedNodes.length, 0);
31 assert.equal(mutations[0].removedNodes.length, 2);
32 assert.equal(mutations[1].addedNodes.length, 2);
33 assert.equal(mutations[1].removedNodes.length, 0);
34 done();
35 }, 0);
36 });
37
38 it('using insertBefore', function(done) {
39 var div = document.createElement('div');
40 div.appendChild(document.createElement('span'));
41 observer.observe(div, {childList: true});
42 div.insertBefore(createObservedFragment(), div.firstChild);
43 setTimeout(function() {
44 assert.equal(mutations.length, 2);
45 assert.equal(mutations[0].addedNodes.length, 0);
46 assert.equal(mutations[0].removedNodes.length, 2);
47 assert.equal(mutations[1].addedNodes.length, 2);
48 assert.equal(mutations[1].removedNodes.length, 0);
49 done();
50 }, 0);
51 });
52
53 it('using replaceChild', function(done) {
54 var div = document.createElement('div');
55 div.appendChild(document.createElement('span'));
56 observer.observe(div, {childList: true});
57 div.replaceChild(createObservedFragment(), div.firstChild);
58 setTimeout(function() {
59 assert.equal(mutations.length, 2);
60 assert.equal(mutations[0].addedNodes.length, 0);
61 assert.equal(mutations[0].removedNodes.length, 2);
62 assert.equal(mutations[1].addedNodes.length, 2);
63 assert.equal(mutations[1].removedNodes.length, 1);
64 done();
65 }, 0);
66 });
67 });
68 </script>
69 </html>
OLDNEW
« no previous file with comments | « sky/tests/mutation-observer/disconnect-cancel-pending.sky ('k') | sky/tests/mutation-observer/document-fragment-insertion.sky » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698