forked from mirrors/gecko-dev
Bug 1756827 validate add_task properties r=jmaher,rpl
Differential Revision: https://phabricator.services.mozilla.com/D139495
This commit is contained in:
parent
3bd2b256cf
commit
256cdcb8e1
2 changed files with 9 additions and 2 deletions
|
|
@ -1529,6 +1529,7 @@ async function schedulePreciseGCAndForceCC(maxCount) {
|
||||||
* Supported properties:
|
* Supported properties:
|
||||||
* skip_if : An arrow function which has an expression to be
|
* skip_if : An arrow function which has an expression to be
|
||||||
* evaluated whether the test is skipped or not.
|
* evaluated whether the test is skipped or not.
|
||||||
|
* pref_set: An array of preferences to set for the test, reset at end of test.
|
||||||
* @param func
|
* @param func
|
||||||
* A function to be run only if the funcOrProperies is not a function.
|
* A function to be run only if the funcOrProperies is not a function.
|
||||||
* @param isTask
|
* @param isTask
|
||||||
|
|
@ -1540,6 +1541,7 @@ async function schedulePreciseGCAndForceCC(maxCount) {
|
||||||
*
|
*
|
||||||
* @return the test function that was passed in.
|
* @return the test function that was passed in.
|
||||||
*/
|
*/
|
||||||
|
var _gSupportedProperties = ["skip_if", "pref_set"];
|
||||||
var _gTests = [];
|
var _gTests = [];
|
||||||
var _gRunOnlyThisTest = null;
|
var _gRunOnlyThisTest = null;
|
||||||
function add_test(properties, func = properties, isTask = false) {
|
function add_test(properties, func = properties, isTask = false) {
|
||||||
|
|
@ -1547,6 +1549,12 @@ function add_test(properties, func = properties, isTask = false) {
|
||||||
properties = { isTask };
|
properties = { isTask };
|
||||||
_gTests.push([properties, func]);
|
_gTests.push([properties, func]);
|
||||||
} else if (typeof properties == "object") {
|
} else if (typeof properties == "object") {
|
||||||
|
// Ensure only documented properties are in the object.
|
||||||
|
for (let prop of Object.keys(properties)) {
|
||||||
|
if (!_gSupportedProperties.includes(prop)) {
|
||||||
|
do_throw(`Task property is not supported: ${prop}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
properties.isTask = isTask;
|
properties.isTask = isTask;
|
||||||
_gTests.push([properties, func]);
|
_gTests.push([properties, func]);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -570,7 +570,7 @@ add_task(async function test_background_restarted() {
|
||||||
// restart the background once the background has been shutdown or
|
// restart the background once the background has been shutdown or
|
||||||
// put to sleep.
|
// put to sleep.
|
||||||
add_task(
|
add_task(
|
||||||
{ prefs_set: [["extensions.eventPages.enabled", true]] },
|
{ pref_set: [["extensions.eventPages.enabled", true]] },
|
||||||
async function test_eventpage_startup() {
|
async function test_eventpage_startup() {
|
||||||
await AddonTestUtils.promiseStartupManager();
|
await AddonTestUtils.promiseStartupManager();
|
||||||
|
|
||||||
|
|
@ -672,6 +672,5 @@ add_task(
|
||||||
|
|
||||||
await extension.unload();
|
await extension.unload();
|
||||||
await AddonTestUtils.promiseShutdownManager();
|
await AddonTestUtils.promiseShutdownManager();
|
||||||
Services.prefs.setBoolPref("extensions.eventPages.enabled", false);
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue