file_fullscreen-esc-exit.html 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <!DOCTYPE HTML>
  2. <html>
  3. <!--
  4. https://bugzilla.mozilla.org/show_bug.cgi?id=700764
  5. Verify that an ESC key press in a subdoc of a full-screen doc causes us to
  6. exit DOM full-screen mode.
  7. -->
  8. <head>
  9. <title>Test for Bug 700764</title>
  10. <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  11. <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
  12. <script type="application/javascript" src="file_fullscreen-utils.js"></script>
  13. <style>
  14. body:fullscreen, div:fullscreen {
  15. background-color: red;
  16. }
  17. </style>
  18. </head>
  19. <body>
  20. <script type="application/javascript">
  21. function ok(condition, msg) {
  22. opener.ok(condition, "[esc-exit] " + msg);
  23. }
  24. function is(a, b, msg) {
  25. opener.is(a, b, "[esc-exit] " + msg);
  26. }
  27. function finish() {
  28. opener.nextTest();
  29. }
  30. function fullscreenchange1(event) {
  31. is(document.fullscreenElement, document.body, "FSE should be doc");
  32. addFullscreenChangeContinuation("exit", fullscreenchange2);
  33. ok(!document.getElementById("subdoc").contentWindow.escKeySent, "Should not yet have sent ESC key press.");
  34. document.getElementById("subdoc").contentWindow.startTest();
  35. }
  36. function fullscreenchange2(event) {
  37. ok(document.getElementById("subdoc").contentWindow.escKeySent, "Should have sent ESC key press.");
  38. ok(!document.getElementById("subdoc").contentWindow.escKeyReceived, "ESC key press to exit should not be delivered.");
  39. ok(!document.fullscreenElement, "Should have left full-screen mode on ESC key press");
  40. finish();
  41. }
  42. function begin() {
  43. addFullscreenChangeContinuation("enter", fullscreenchange1);
  44. document.body.requestFullscreen();
  45. }
  46. </script>
  47. <!-- This subframe conducts the test. -->
  48. <iframe id="subdoc" src="file_fullscreen-esc-exit-inner.html"></iframe>
  49. </pre>
  50. </body>
  51. </html>