dom/tests/mochitest/pointerlock/pointerlock_utils.js

branch
TOR_BUG_9701
changeset 9
a63d609f5ebe
equal deleted inserted replaced
-1:000000000000 0:e0b363085aaf
1 const isWinXP = navigator.userAgent.indexOf("Windows NT 5.1") != -1;
2 const isOSXLion = navigator.userAgent.indexOf("Mac OS X 10.7") != -1;
3
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();
9
10 // Wrap test functions and pass to parent window
11 window.ok = function(a, msg) {
12 opener.ok(a, testName + ": " + msg);
13 };
14
15 window.is = function(a, b, msg) {
16 opener.is(a, b, testName + ": " + msg);
17 };
18
19 window.isnot = function(a, b, msg) {
20 opener.isnot(a, b, testName + ": " + msg);
21 };
22
23 window.todo = function(a, msg) {
24 opener.todo(a, testName + ": " + msg);
25 };
26
27 window.todo_is = function(a, b, msg) {
28 opener.todo_is(a, b, testName + ": " + msg);
29 };
30
31 window.todo_isnot = function(a, b, msg) {
32 opener.todo_isnot(a, b, testName + ": " + msg);
33 };
34
35 // Override bits of SimpleTest so test files work stand-alone
36 var SimpleTest = SimpleTest || {};
37
38 SimpleTest.waitForExplicitFinish = function() {
39 dump("[POINTERLOCK] Starting " + testName+ "\n");
40 };
41
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.
49
50 // Ensure the full-screen api is enabled, and will be disabled on test exit.
51 SpecialPowers.setBoolPref("full-screen-api.enabled", true);
52
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 }
56
57 addLoadEvent(function() {
58 if (typeof start !== 'undefined') {
59 SimpleTest.waitForFocus(start);
60 }
61 });
62

mercurial