OLD | NEW |
(Empty) | |
| 1 <!doctype html> |
| 2 <title>await a stable state and sync event handlers</title> |
| 3 <script src="../../../../../../../resources/testharness.js"></script> |
| 4 <script src="../../../../../../../resources/testharnessreport.js"></script> |
| 5 <div id=log></div> |
| 6 <video></video> |
| 7 <script> |
| 8 var v; |
| 9 var t = async_test(function(t) { |
| 10 v = document.querySelector('video'); |
| 11 var a = document.createElement('a'); |
| 12 a.onclick = t.step_func(function() { |
| 13 v.setAttribute('src', '#'); // invokes media load which invokes resource sel
ection |
| 14 assert_equals(v.networkState, v.NETWORK_NO_SOURCE, 'networkState in onclick
handler'); |
| 15 }); |
| 16 a.click(); // sync fires click, so sets src |
| 17 // now we should still await a stable state because the script hasn't |
| 18 // finished, the event handler has just returned |
| 19 assert_equals(v.networkState, v.NETWORK_NO_SOURCE, 'networkState after click()
'); |
| 20 v.removeAttribute('src'); |
| 21 }); |
| 22 </script> |
| 23 <script> |
| 24 t.step(function() { |
| 25 // now the sync section of resource selection should have run and should |
| 26 // have found no src="" or <source> thus networkState being set to NETWORK_EMP
TY. |
| 27 // if the sync section was run when onclick returned, then networkState |
| 28 // would be either NETWORK_LOADING or NETWORK_NO_SOURCE. |
| 29 assert_equals(v.networkState, v.NETWORK_EMPTY, 'networkState in separate scrip
t'); |
| 30 t.done(); |
| 31 }); |
| 32 </script> |
OLD | NEW |