Guest User

Untitled

a guest
Apr 24th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. <script type="application/javascript">
  2.  
  3. /** Test for Bug 633602 **/
  4. SimpleTest.waitForExplicitFinish();
  5.  
  6. SpecialPowers.setBoolPref("full-screen-api.allow-trusted-requests-only", false);
  7. var pointer = navigator.pointer;
  8. var div = document.getElementById("div");
  9.  
  10.  
  11. div.addEventListener("mouselocklost", function() {
  12. is(pointer.islocked(), false, "Mouselocklost event should trigger when window loses focus and mouse should be unlocked");
  13. SimpleTest.finish();
  14. }, false);
  15.  
  16. var successCallback = function () {
  17. // Test if mouse is locked when success callback is dispatched
  18. ok(pointer.islocked(), "When success callback is dispatched, mouse should be locked");
  19.  
  20. // Open a new window to switch focus and blur the current window
  21. window.open('data:text/html;charset=utf-8,%3C%21DOCTYPE%20' +
  22. 'html%3E%0D%0A%3Chtml%20lang%3D%22en%22%3E%0D%0A%3Chead%' +
  23. '3E%3Ctitle%3EEmbedded%20Window%3C%2Ftitle%3E%3C%2Fhead%' +
  24. '3E%0D%0A%3Cbody%3E%3Ch1%3E42%3C%2Fh1%3E%3C%2Fbody%3E%0A' +
  25. '%3C%2Fhtml%3E%0A%0D%0A','_blank','height=300,width=400'
  26. );
  27. };
  28.  
  29. document.addEventListener("mozfullscreenchange", function() {
  30. if (document.mozFullScreenElement === div) {
  31. // Mouse should be locked if the element is in fullscreen mode
  32. pointer.lock(div, successCallback);
  33. }
  34. }, false);
  35.  
  36. div.mozRequestFullScreen();
  37.  
  38. </script>
Add Comment
Please, Sign In to add comment