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

Side by Side Diff: sky/tests/mutation-observer/takeRecords.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
« no previous file with comments | « sky/tests/mutation-observer/shadow-dom.sky ('k') | sky/tests/mutation-observer/takeRecords.sky » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <html>
2 <link rel="import" href="../resources/chai.html" />
3 <link rel="import" href="../resources/mocha.html" />
4 <script>
5 describe('MutationObserver.takeRecords', function() {
6 it('should allow taking records synchronously or getting a notification', func tion(done) {
7 var mutations;
8 var div;
9 var subDiv;
10 var observer;
11
12 // Testing takeRecords.
13 mutations = null;
14 div = document.createElement('div');
15 subDiv = div.appendChild(document.createElement('div'));
16 subDiv.textContent = 'hello, world';
17 observer = new MutationObserver(function(records) {
18 mutations = records;
19 });
20
21 observer.observe(div, {attributes: true, characterData: true, subtree: true} );
22 subDiv.setAttribute('foo', 'bar');
23 subDiv.firstChild.textContent = 'goodbye!';
24 div.removeChild(subDiv);
25
26 mutations = observer.takeRecords();
27
28 // ...records are taken synchronously.
29
30 assert.equal(mutations.length, 2);
31 assert.equal(mutations[0].type, "attributes");
32 assert.equal(mutations[0].target, subDiv);
33 assert.equal(mutations[0].attributeName, "foo");
34 assert.equal(mutations[1].type, "characterData");
35 assert.equal(mutations[1].target, subDiv.firstChild);
36
37 subDiv.setAttribute('foo', 'baz');
38
39 setTimeout(function() {
40 // ...takeRecord took records, but did not clear transient observers.
41
42 assert.equal(mutations.length, 1);
43 assert.equal(mutations[0].type, "attributes");
44 assert.equal(mutations[0].target, subDiv);
45 assert.equal(mutations[0].attributeName, "foo");
46 observer.disconnect();
47
48 done();
49 }, 0);
50 });
51 });
52 </script>
53 </html>
OLDNEW
« no previous file with comments | « sky/tests/mutation-observer/shadow-dom.sky ('k') | sky/tests/mutation-observer/takeRecords.sky » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698