// Various tests in this directory may define gTestBrowser, to use as the // default browser under test in some of the functions below. /* global gTestBrowser:true */
function waitForCondition(condition, nextTest, errorMsg, aTries, aWait) {
let tries = 0;
let maxTries = aTries || 100; // 100 tries
let maxWait = aWait || 100; // 100 msec x 100 tries = ten seconds
let interval = setInterval(function () { if (tries >= maxTries) {
ok(false, errorMsg);
moveOn();
}
let conditionPassed; try {
conditionPassed = condition();
} catch (e) {
ok(false, e + "\n" + e.stack);
conditionPassed = false;
} if (conditionPassed) {
moveOn();
}
tries++;
}, maxWait);
let moveOn = function () {
clearInterval(interval);
nextTest();
};
}
// Waits for a conditional function defined by the caller to return true. function promiseForCondition(aConditionFn, aMessage, aTries, aWait) { returnnew Promise(resolve => {
waitForCondition(
aConditionFn,
resolve,
aMessage || "Condition didn't pass.",
aTries,
aWait
);
});
}
// Returns a promise for nsIObjectLoadingContent props data. function promiseForPluginInfo(aId, aBrowser) {
let browser = aBrowser || gTestBrowser; return SpecialPowers.spawn(browser, [aId], async function (contentId) {
let plugin = content.document.getElementById(contentId); if (!(plugin instanceof Ci.nsIObjectLoadingContent)) { thrownew Error("no plugin found");
} return {
activated: plugin.activated,
hasRunningPlugin: plugin.hasRunningPlugin,
displayedType: plugin.displayedType,
};
});
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.