pointerevent_utils.js (1426B)
1 // Get test filename for page being run in popup so errors are more useful 2 var testName = location.pathname.split("/").pop(); 3 4 // Wrap test functions and pass to parent window 5 window.ok = function (a, msg) { 6 opener.ok(a, testName + ": " + msg); 7 }; 8 9 window.is = function (a, b, msg) { 10 opener.is(a, b, testName + ": " + msg); 11 }; 12 13 window.isnot = function (a, b, msg) { 14 opener.isnot(a, b, testName + ": " + msg); 15 }; 16 17 window.todo = function (a, msg) { 18 opener.todo(a, testName + ": " + msg); 19 }; 20 21 window.todo_is = function (a, b, msg) { 22 opener.todo_is(a, b, testName + ": " + msg); 23 }; 24 25 window.todo_isnot = function (a, b, msg) { 26 opener.todo_isnot(a, b, testName + ": " + msg); 27 }; 28 29 window.info = function (msg) { 30 opener.info(testName + ": " + msg); 31 }; 32 33 // Override bits of SimpleTest so test files work stand-alone 34 var SimpleTest = SimpleTest || {}; 35 36 SimpleTest.waitForExplicitFinish = function () { 37 dump("[POINTEREVENT] Starting " + testName + "\n"); 38 }; 39 40 SimpleTest.finish = function () { 41 dump("[POINTEREVENT] Finishing " + testName + "\n"); 42 opener.nextTest(); 43 }; 44 45 // Utility functions 46 function waitForEvent(aTarget, aEvent, aCallback) { 47 return new Promise(aResolve => { 48 aTarget.addEventListener( 49 aEvent, 50 e => { 51 ok(true, `got ${e.type} event on ${e.target.id}`); 52 if (aCallback) { 53 aCallback(e); 54 } 55 aResolve(); 56 }, 57 { once: true } 58 ); 59 }); 60 }