dom/tests/mochitest/pointerlock/pointerlock_utils.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/tests/mochitest/pointerlock/pointerlock_utils.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,62 @@
     1.4 +const isWinXP = navigator.userAgent.indexOf("Windows NT 5.1") != -1;
     1.5 +const isOSXLion = navigator.userAgent.indexOf("Mac OS X 10.7") != -1;
     1.6 +
     1.7 +// If we're running in a child window, shim things so it works the same
     1.8 +// as if we were running stand-alone.
     1.9 +if (window.opener) {
    1.10 +  // Get test filename for page being run in popup so errors are more useful
    1.11 +  var testName = location.pathname.split('/').pop();
    1.12 +
    1.13 +  // Wrap test functions and pass to parent window
    1.14 +  window.ok = function(a, msg) {
    1.15 +    opener.ok(a, testName + ": " + msg);
    1.16 +  };
    1.17 +
    1.18 +  window.is = function(a, b, msg) {
    1.19 +    opener.is(a, b, testName + ": " + msg);
    1.20 +  };
    1.21 +
    1.22 +  window.isnot = function(a, b, msg) {
    1.23 +    opener.isnot(a, b, testName + ": " + msg);
    1.24 +  };
    1.25 +
    1.26 +  window.todo = function(a, msg) {
    1.27 +    opener.todo(a, testName + ": " + msg);
    1.28 +  };
    1.29 +
    1.30 +  window.todo_is = function(a, b, msg) {
    1.31 +    opener.todo_is(a, b, testName + ": " + msg);
    1.32 +  };
    1.33 +
    1.34 +  window.todo_isnot = function(a, b, msg) {
    1.35 +    opener.todo_isnot(a, b, testName + ": " + msg);
    1.36 +  };
    1.37 +
    1.38 +  // Override bits of SimpleTest so test files work stand-alone
    1.39 +  var SimpleTest = SimpleTest || {};
    1.40 +
    1.41 +  SimpleTest.waitForExplicitFinish = function() {
    1.42 +    dump("[POINTERLOCK] Starting " + testName+ "\n");
    1.43 +  };
    1.44 +
    1.45 +  SimpleTest.finish = function () {
    1.46 +    dump("[POINTERLOCK] Finishing " + testName+ "\n");
    1.47 +    opener.nextTest();
    1.48 +  };
    1.49 +} else {
    1.50 +  // If we're not running in a child window, prefs need to get flipped here,
    1.51 +  // otherwise it was already done in the test runner parent.
    1.52 +
    1.53 +  // Ensure the full-screen api is enabled, and will be disabled on test exit.
    1.54 +  SpecialPowers.setBoolPref("full-screen-api.enabled", true);
    1.55 +
    1.56 +  // Disable the requirement for trusted contexts only, so the tests are easier to write.
    1.57 +  SpecialPowers.setBoolPref("full-screen-api.allow-trusted-requests-only", false);
    1.58 +}
    1.59 +
    1.60 +addLoadEvent(function() {
    1.61 +  if (typeof start !== 'undefined') {
    1.62 +    SimpleTest.waitForFocus(start);
    1.63 +  }
    1.64 +});
    1.65 +

mercurial