Revision 8efcf2b57818807058a785bc55ebe13cb0139123 authored by Philip Jägenstedt on 29 March 2018, 13:44:01 UTC, committed by Geoffrey Sneddon on 29 March 2018, 13:44:01 UTC
This was inverted so that the Windows instructions were printed on
Linux. Rather than just changing the condition, switch the messages,
to match the order of some preceding code.
1 parent 604d17e
Raw File
wakelock-document-hidden.https.html
<!DOCTYPE html>
<meta charset="utf-8">
<title>screen wake lock will not be actived in hidden document</title>
<link rel="help" href="https://w3c.github.io/wake-lock/#dfn-requesting-the-wake-lock">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>

promise_test(async t => {
  const wakeLock = await navigator.getWakeLock("screen");
  const request = wakeLock.createRequest();
  assert_true(wakeLock.active, "the active is true when wake lock is acquired");
  const eventWatcher = new EventWatcher(t, document, "visibilitychange");
  const win = window.open("about:blank", "_blank");

  await eventWatcher.wait_for("visibilitychange");
  assert_true(document.hidden, "document is hidden when new window is opened");
  assert_false(wakeLock.active, "the active is false when document is hidden");
  win.close();

  await eventWatcher.wait_for("visibilitychange");
  assert_false(document.hidden, "document is visiable when new window is closed");
  assert_true(wakeLock.active, "the active is true when document regains visibility");
  request.cancel();
}, "Test that screen wake lock will not be actived in hidden document");

</script>
back to top