Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <html> | 1 <html> |
| 2 <head> | 2 <head> |
| 3 <style> | 3 <style> |
| 4 div.block { height: 400px; border: 1px solid black; margin:10px; } | 4 div.block { height: 400px; border: 1px solid black; margin:10px; } |
| 5 </style> | 5 </style> |
| 6 <script> | 6 <script> |
| 7 var resizecount = 0; | 7 var resizecount = 0; |
| 8 var loaded = false; | 8 var loaded = false; |
| 9 window.onresize = function() { | 9 window.onresize = function() { |
| 10 resizecount++; | 10 resizecount++; |
| 11 document.getElementById('count1').innerHTML = resizecount; | 11 document.getElementById('count1').innerHTML = resizecount; |
| 12 } | 12 } |
| 13 </script> | 13 </script> |
| 14 </head> | 14 </head> |
| 15 <body> | 15 <body> |
| 16 <div> | 16 <div> |
| 17 Test how many resize events are emitted during page load and dynamic con tent generation. | 17 Test how many resize events are emitted during resizing window. |
| 18 | |
| 19 Do not resize the page. It invalidates the test. | |
| 20 <p style="text-indent: 10px" id=result1> | 18 <p style="text-indent: 10px" id=result1> |
| 21 Resize events (should be 0): <span id=count1>0</span> | 19 Resize events (should be 1): <span id=count1>0</span> |
| 22 </div> | 20 </div> |
| 23 <div id=expandingblock> | 21 <div id=expandingblock> |
| 24 </div> | 22 </div> |
| 25 <script> | 23 <script> |
| 26 if (window.testRunner) { | 24 if (window.testRunner) { |
| 27 testRunner.dumpAsText(); | 25 testRunner.dumpAsText(); |
| 28 testRunner.waitUntilDone(); | 26 testRunner.waitUntilDone(); |
| 29 } | 27 } |
| 30 | 28 function resizeWindow() { |
| 31 var blockcount = 0; | 29 window.resizeBy(10, 10); |
| 32 function addBlock() { | 30 setTimeout(finish, 20); |
|
kenneth.r.christiansen
2013/05/06 19:50:51
Any way to avoid setTimeout. It would be sad if th
| |
| 33 var el = document.createElement('div'); | |
| 34 el.setAttribute('class','block'); | |
| 35 document.getElementById('expandingblock').appendChild(el); | |
| 36 if (++blockcount < 10) | |
| 37 setTimeout(addBlock, 20); | |
| 38 else | |
| 39 finish(); | |
| 40 } | 31 } |
| 41 function finish() { | 32 function finish() { |
| 42 var result; | 33 var result; |
| 43 // No resize events are acceptable. | 34 // No resize events are acceptable. |
| 44 if (resizecount < 1) | 35 if (resizecount == 1) |
| 45 result = '<p style="color: green">PASS'; | 36 result = '<p style="color: green">PASS'; |
| 46 else | 37 else |
| 47 result = '<p style="color: red">FAIL'; | 38 result = '<p style="color: red">FAIL'; |
| 48 var resultElement = document.getElementById('result1') | 39 var resultElement = document.getElementById('result1') |
| 49 resultElement.innerHTML += result; | 40 resultElement.innerHTML += result; |
| 50 if (window.testRunner) | 41 if (window.testRunner) |
| 51 testRunner.notifyDone(); | 42 testRunner.notifyDone(); |
| 52 } | 43 } |
| 53 onload = addBlock; | 44 onload = resizeWindow; |
| 54 </script> | 45 </script> |
| 55 </body> | 46 </body> |
| OLD | NEW |