Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / fast / dom / MutationObserver / document-write.html
1 <!DOCTYPE html>
2 <head>
3 </head>
4 <body>
5 <div id="result">RESULT</div>
6 <script>
7
8 var resultDiv = document.getElementById('result');
9
10 if (window.testRunner) {
11     testRunner.dumpAsText();
12     testRunner.waitUntilDone();
13 }
14
15 var count = 0;
16
17 var observer = new MutationObserver(function(r) {
18     count += r.length;
19 });
20
21 var div = document.createElement('div');
22 observer.observe(div, { attributes: true });
23
24 function mutate() {
25       div.setAttribute('count', count);
26 }
27
28 var counts = [];
29 function check() {
30     counts.push(count);
31 }
32
33 function finish() {
34     setTimeout(function() {
35         check();
36
37         var result = counts[0] == 0 &&
38                      counts[1] == 0 &&
39                      counts[2] == 0 &&
40                      counts[3] == 1 ? 'PASSED' : 'FAILED';
41
42         document.documentElement.appendChild(document.createElement('body'));
43         document.body.innerHTML = result;
44         if (window.testRunner) {
45             testRunner.notifyDone();
46         }
47     }, 0);
48 }
49
50 finish();
51 </script>
52 <iframe onload="mutate(); check(); document.write('<script>check();</script>'); document.close(); check(); finish();">
53 </body>