dom/tests/mochitest/pointerlock/pointerlock_utils.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial