OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <body> |
| 4 <script src="../resources/testharness.js"></script> |
| 5 <script src="../resources/testharnessreport.js"></script> |
| 6 <script> |
| 7 |
| 8 var nestedFrameTest = async_test( |
| 9 'Test that keepAwake state is independent in main and nested frames'); |
| 10 |
| 11 var nextStep; |
| 12 |
| 13 function onMessageReceived(e) { |
| 14 nextStep(e.data.keepAwake); |
| 15 } |
| 16 |
| 17 function setNestedWakeLock(state) { |
| 18 document.getElementById('subframe').contentWindow.postMessage( |
| 19 {'tag': 'setKeepAwake', 'keepAwake': state}, '*'); |
| 20 } |
| 21 |
| 22 function getNestedWakeLock(callback) { |
| 23 document.getElementById('subframe').contentWindow.postMessage( |
| 24 {'tag': 'getKeepAwake'}, '*'); |
| 25 nextStep = callback; |
| 26 } |
| 27 |
| 28 window.addEventListener('message', onMessageReceived); |
| 29 |
| 30 window.onload = nestedFrameTest.step_func(function() { |
| 31 screen.keepAwake = true; |
| 32 getNestedWakeLock(nestedFrameTest.step_func(function(nestedKeepAwake) { |
| 33 assert_false(nestedKeepAwake); |
| 34 screen.keepAwake = false; |
| 35 setNestedWakeLock(true); |
| 36 getNestedWakeLock(nestedFrameTest.step_func(function(nestedKeepAwake) { |
| 37 assert_true(nestedKeepAwake); |
| 38 assert_false(screen.keepAwake); |
| 39 nestedFrameTest.done(); |
| 40 })); |
| 41 })); |
| 42 }); |
| 43 |
| 44 </script> |
| 45 <iframe src="resources/subframe.html" id="subframe"/> |
| 46 </body> |
| 47 </html> |
OLD | NEW |