Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / dom / MutationObserver / takeRecords.html
blobf44a98071862ced2b7ae37ed87f1809e5802b786
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta charset="utf-8">
5 <script src="../../../resources/js-test.js"></script>
6 <title></title>
7 </head>
8 <body>
9 <p id=description></p>
10 <div id="console"></div>
11 <script>
13 window.jsTestIsAsync = true;
14 var mutations;
16 function testBasic() {
17 var observer;
19 function start() {
20 debug('Testing takeRecords.');
22 mutations = null;
23 div = document.createElement('div');
24 subDiv = div.appendChild(document.createElement('div'));
25 subDiv.innerHTML = 'hello, world';
26 observer = new MutationObserver(function(mutations) {
27 window.mutations = mutations;
28 });
30 observer.observe(div, {attributes: true, characterData: true, subtree: true});
31 subDiv.setAttribute('foo', 'bar');
32 subDiv.firstChild.textContent = 'goodbye!';
33 div.removeChild(subDiv);
35 mutations = observer.takeRecords();
37 debug('...records are taken synchronously.');
39 shouldBe('mutations.length', '2');
40 shouldBe('mutations[0].type', '"attributes"');
41 shouldBe('mutations[0].target', 'subDiv');
42 shouldBe('mutations[0].attributeName', '"foo"');
43 shouldBe('mutations[0].attributeNamespace', 'null');
44 shouldBe('mutations[1].type', '"characterData"');
45 shouldBe('mutations[1].target', 'subDiv.firstChild');
47 subDiv.setAttribute('foo', 'baz');
48 setTimeout(finish, 0);
51 function finish() {
52 debug('...takeRecord took records, but did not clear transient observers');
54 shouldBe('mutations.length', '1');
55 shouldBe('mutations[0].type', '"attributes"');
56 shouldBe('mutations[0].target', 'subDiv');
57 shouldBe('mutations[0].attributeName', '"foo"');
58 observer.disconnect();
59 debug('');
60 runNextTest();
63 start();
66 var tests = [testBasic];
67 var testIndex = 0;
69 function runNextTest() {
70 if (testIndex < tests.length)
71 tests[testIndex++]();
72 else
73 finishJSTest();
76 description('Testing WebKitMutationObserver.takeRecords');
78 runNextTest();
79 </script>
80 </body>
81 </html>