dom/tests/mochitest/pointerlock/pointerlock_utils.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 const isWinXP = navigator.userAgent.indexOf("Windows NT 5.1") != -1;
     2 const isOSXLion = navigator.userAgent.indexOf("Mac OS X 10.7") != -1;
     4 // If we're running in a child window, shim things so it works the same
     5 // as if we were running stand-alone.
     6 if (window.opener) {
     7   // Get test filename for page being run in popup so errors are more useful
     8   var testName = location.pathname.split('/').pop();
    10   // Wrap test functions and pass to parent window
    11   window.ok = function(a, msg) {
    12     opener.ok(a, testName + ": " + msg);
    13   };
    15   window.is = function(a, b, msg) {
    16     opener.is(a, b, testName + ": " + msg);
    17   };
    19   window.isnot = function(a, b, msg) {
    20     opener.isnot(a, b, testName + ": " + msg);
    21   };
    23   window.todo = function(a, msg) {
    24     opener.todo(a, testName + ": " + msg);
    25   };
    27   window.todo_is = function(a, b, msg) {
    28     opener.todo_is(a, b, testName + ": " + msg);
    29   };
    31   window.todo_isnot = function(a, b, msg) {
    32     opener.todo_isnot(a, b, testName + ": " + msg);
    33   };
    35   // Override bits of SimpleTest so test files work stand-alone
    36   var SimpleTest = SimpleTest || {};
    38   SimpleTest.waitForExplicitFinish = function() {
    39     dump("[POINTERLOCK] Starting " + testName+ "\n");
    40   };
    42   SimpleTest.finish = function () {
    43     dump("[POINTERLOCK] Finishing " + testName+ "\n");
    44     opener.nextTest();
    45   };
    46 } else {
    47   // If we're not running in a child window, prefs need to get flipped here,
    48   // otherwise it was already done in the test runner parent.
    50   // Ensure the full-screen api is enabled, and will be disabled on test exit.
    51   SpecialPowers.setBoolPref("full-screen-api.enabled", true);
    53   // Disable the requirement for trusted contexts only, so the tests are easier to write.
    54   SpecialPowers.setBoolPref("full-screen-api.allow-trusted-requests-only", false);
    55 }
    57 addLoadEvent(function() {
    58   if (typeof start !== 'undefined') {
    59     SimpleTest.waitForFocus(start);
    60   }
    61 });

mercurial