gecko-dev/toolkit/content/tests/widgets/head.js
Ray Lin 5495fb2264 Bug 1350191 - Change keypress event propagation to capture to correctly preventDefault if control is focused. r=jaws
We could not avoid controls being focused after De-XUL, in order
to preventDefault before event propagate to focused control, we should
change the way of keypress event propagation in media controls.

MozReview-Commit-ID: 4KNPU4XlSDJ

--HG--
extra : rebase_source : 1146e18e3beebca8ae36a4de126c5c920aa5cdfd
2017-03-25 11:48:30 +08:00

41 lines
1.0 KiB
JavaScript

"use strict";
var tests = [];
function waitForCondition(condition, nextTest, errorMsg) {
var tries = 0;
var interval = setInterval(function() {
if (tries >= 30) {
ok(false, errorMsg);
moveOn();
}
var conditionPassed;
try {
conditionPassed = condition();
} catch (e) {
ok(false, e + "\n" + e.stack);
conditionPassed = false;
}
if (conditionPassed) {
moveOn();
}
tries++;
}, 100);
var moveOn = function() { clearInterval(interval); nextTest(); };
}
function getAnonElementWithinVideoByAttribute(video, aName, aValue) {
const domUtils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"].
getService(SpecialPowers.Ci.inIDOMUtils);
const videoControl = domUtils.getChildrenForNode(video, true)[1];
return SpecialPowers.wrap(videoControl.ownerDocument)
.getAnonymousElementByAttribute(videoControl, aName, aValue);
}
function executeTests() {
return tests
.map(fn => () => new Promise(fn))
.reduce((promise, task) => promise.then(task), Promise.resolve());
}