Bug 1805511 - Add targeting for default PDF and HTML handlers r=nalexander,omc-reviewers,emcminn
This also fixes a bug in ASRouter devtools that prevented evaluation of expressions containing nested promises. Objects containing promises are now correctly serialized to the ASRouter devtools and expressions evaluate correctly. Differential Revision: https://phabricator.services.mozilla.com/D169408
This commit is contained in:
@@ -1140,14 +1140,26 @@ class _ASRouter {
|
||||
* and ASRouter._getMessagesContext parameters and values
|
||||
*/
|
||||
async getTargetingParameters(environment, localContext) {
|
||||
const targetingParameters = {};
|
||||
for (const param of Object.keys(environment)) {
|
||||
targetingParameters[param] = await environment[param];
|
||||
}
|
||||
for (const param of Object.keys(localContext)) {
|
||||
targetingParameters[param] = await localContext[param];
|
||||
// Resolve objects that may contain promises.
|
||||
async function resolve(object) {
|
||||
const target = {};
|
||||
|
||||
for (const param of Object.keys(object)) {
|
||||
target[param] = await object[param];
|
||||
|
||||
if (typeof target[param] === "object" && target[param] !== null) {
|
||||
target[param] = await resolve(target[param]);
|
||||
}
|
||||
}
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
const targetingParameters = {
|
||||
...(await resolve(environment)),
|
||||
...(await resolve(localContext)),
|
||||
};
|
||||
|
||||
return targetingParameters;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user