Index: LayoutTests/wake_lock/wakelock-in-nested-frame.html |
diff --git a/LayoutTests/wake_lock/wakelock-in-nested-frame.html b/LayoutTests/wake_lock/wakelock-in-nested-frame.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..7286a43ea188ea66a7d83923ddfdd59698720e0c |
--- /dev/null |
+++ b/LayoutTests/wake_lock/wakelock-in-nested-frame.html |
@@ -0,0 +1,47 @@ |
+<!DOCTYPE html> |
+<html> |
+<body> |
+<script src="../resources/testharness.js"></script> |
+<script src="../resources/testharnessreport.js"></script> |
+<script> |
+ |
+var nestedFrameTest = async_test( |
+ 'Test that keepAwake state is independent in main and nested frames'); |
+ |
+var nextStep; |
+ |
+function onMessageReceived(e) { |
+ nextStep(e.data.keepAwake); |
+} |
+ |
+function setNestedWakeLock(state) { |
+ document.getElementById('subframe').contentWindow.postMessage( |
+ {'tag': 'setKeepAwake', 'keepAwake': state}, '*'); |
+} |
+ |
+function getNestedWakeLock(callback) { |
+ document.getElementById('subframe').contentWindow.postMessage( |
+ {'tag': 'getKeepAwake'}, '*'); |
+ nextStep = callback; |
+} |
+ |
+window.addEventListener('message', onMessageReceived); |
+ |
+window.onload = nestedFrameTest.step_func(function() { |
+ screen.keepAwake = true; |
+ getNestedWakeLock(nestedFrameTest.step_func(function(nestedKeepAwake) { |
+ assert_false(nestedKeepAwake); |
+ screen.keepAwake = false; |
+ setNestedWakeLock(true); |
+ getNestedWakeLock(nestedFrameTest.step_func(function(nestedKeepAwake) { |
+ assert_true(nestedKeepAwake); |
+ assert_false(screen.keepAwake); |
+ nestedFrameTest.done(); |
+ })); |
+ })); |
+}); |
+ |
+</script> |
+<iframe src="resources/subframe.html" id="subframe"/> |
+</body> |
+</html> |