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

Side by Side Diff: sky/tests/mutation-observer/shadow-dom.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/chai.html" />
3 <link rel="import" href="../resources/mocha.html" />
4 <div id="range"></div>
5 <script>
6 describe('MutationObservers', function() {
7 it('should handle shadow dom', function() {
8 function mutate(element) {
9 element.setAttribute('data-foo', 'bar');
10 element.insertBefore(document.createTextNode('hello'), element.firstChild) ;
11 element.firstChild.textContent = 'goodbye';
12 element.removeChild(element.firstChild);
13 }
14
15 var range = document.getElementById('range');
16 var shadowRoot = range.createShadowRoot();
17 shadowRoot.appendChild(document.createElement('div'));
18 var observer = new MutationObserver(function() { });
19
20 observer.observe(shadowRoot.firstChild, {attributes: true, childList: true, characterData: true, subtree: true});
21 mutate(shadowRoot.firstChild);
22
23 var mutations = observer.takeRecords();
24 // Mutations in shadow DOM should have been observed:
25 assert.equal(mutations.length, 4);
26 assert.equal(mutations[0].type, "attributes");
27 assert.equal(mutations[1].type, "childList");
28 assert.equal(mutations[2].type, "characterData");
29 assert.equal(mutations[3].type, "childList");
30 observer.disconnect();
31
32 mutations = observer.takeRecords();
33 observer.observe(document, {attributes: true, childList: true, characterData : true, subtree: true});
34 mutate(shadowRoot.firstChild);
35 // Observing from outside shadow DOM should not see mutations in the shadow:
36 assert.equal(mutations.length, 0);
37 });
38 });
39 </script>
40 </html>
OLDNEW
« no previous file with comments | « sky/tests/mutation-observer/script-append.sky ('k') | sky/tests/mutation-observer/shadow-dom.sky » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698