summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/fullscreen/api/element-request-fullscreen-after-error.html
blob: 42783827700419977d3339abf8547545e44e32bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<!DOCTYPE html>
<title>Element#requestFullscreen() after error</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<div id="log"></div>
<script>
promise_test(async t => {
  await new Promise(r => window.onload = r);

  const element1 = document.createElement("div");
  document.body.appendChild(element1);

  await test_driver.bless("request full screen");
  let promise = element1.requestFullscreen()
  await new Promise(r => t.step_timeout(r, 0))
  document.body.removeChild(element1);
  try {
    await promise;
    assert_unreached("requestFullscreen shouldn't be successful");
  } catch (e) {
  }
  try {
    await document.exitFullscreen();
  } catch (e) {
  }

  const element2 = document.createElement("div");
  document.body.appendChild(element2);

  await test_driver.bless("request full screen");
  try {
    await element2.requestFullscreen();
  } catch (e) {
    assert_unreached("requestFullscreen shouldn't throw an error - " + e.message);
  }
  await document.exitFullscreen();
}, "requestFullscreen works even if previous requestFullscreen causes an error");
</script>