forked from mirrors/gecko-dev
Bug 1813597 - Support reach experiments in the FxMS schemas r=omc-reviewers,emcminn
Differential Revision: https://phabricator.services.mozilla.com/D168322
This commit is contained in:
parent
d307cab06d
commit
1149bd525e
9 changed files with 376 additions and 264 deletions
6
.gitignore
vendored
6
.gitignore
vendored
|
|
@ -58,6 +58,12 @@ security/manager/.nss.checkout
|
||||||
# Ignore newtab component build assets
|
# Ignore newtab component build assets
|
||||||
browser/components/newtab/logs/
|
browser/components/newtab/logs/
|
||||||
|
|
||||||
|
# Ignore ASRouter generated test files
|
||||||
|
browser/components/newtab/content-src/asrouter/schemas/corpus/CFRMessageProvider.messages.json
|
||||||
|
browser/components/newtab/content-src/asrouter/schemas/corpus/OnboardingMessageProvider.messages.json
|
||||||
|
browser/components/newtab/content-src/asrouter/schemas/corpus/PanelTestProvider.messages.json
|
||||||
|
browser/components/newtab/content-src/asrouter/schemas/corpus/PanelTestProvider_toast_notification.messages.json
|
||||||
|
|
||||||
# Ignore Pocket component build and dev assets
|
# Ignore Pocket component build and dev assets
|
||||||
browser/components/pocket/content/panels/css/main.compiled.css.map
|
browser/components/pocket/content/panels/css/main.compiled.css.map
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,12 @@ compile_commands\.json
|
||||||
# Ignore newtab component build assets
|
# Ignore newtab component build assets
|
||||||
^browser/components/newtab/logs/
|
^browser/components/newtab/logs/
|
||||||
|
|
||||||
|
# Ignore ASRouter generated test files
|
||||||
|
^browser/components/newtab/content-src/asrouter/schemas/corpus/CFRMessageProvider.messages.json
|
||||||
|
^browser/components/newtab/content-src/asrouter/schemas/corpus/OnboardingMessageProvider.messages.json
|
||||||
|
^browser/components/newtab/content-src/asrouter/schemas/corpus/PanelTestProvider.messages.json
|
||||||
|
^browser/components/newtab/content-src/asrouter/schemas/corpus/PanelTestProvider_toast_notification.messages.json
|
||||||
|
|
||||||
# Ignore Pocket component build and dev assets
|
# Ignore Pocket component build and dev assets
|
||||||
browser/components/pocket/content/panels/css/main.compiled.css.map
|
browser/components/pocket/content/panels/css/main.compiled.css.map
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,37 +3,28 @@
|
||||||
"$id": "resource://activity-stream/schemas/BackgroundTaskMessagingExperiment.schema.json",
|
"$id": "resource://activity-stream/schemas/BackgroundTaskMessagingExperiment.schema.json",
|
||||||
"title": "Messaging Experiment",
|
"title": "Messaging Experiment",
|
||||||
"description": "A Firefox Messaging System message.",
|
"description": "A Firefox Messaging System message.",
|
||||||
"oneOf": [
|
"allOf": [
|
||||||
{
|
{
|
||||||
"description": "An empty FxMS message.",
|
"$ref": "resource://activity-stream/schemas/BackgroundTaskMessagingExperiment.schema.json#/$defs/Message"
|
||||||
"type": "object",
|
|
||||||
"additionalProperties": false
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allOf": [
|
"if": {
|
||||||
{
|
"type": "object",
|
||||||
"$ref": "resource://activity-stream/schemas/BackgroundTaskMessagingExperiment.schema.json#/$defs/Message"
|
"properties": {
|
||||||
},
|
"template": {
|
||||||
{
|
"type": "string",
|
||||||
"if": {
|
"enum": [
|
||||||
"type": "object",
|
"toast_notification"
|
||||||
"properties": {
|
|
||||||
"template": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"toast_notification"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"required": [
|
|
||||||
"template"
|
|
||||||
]
|
]
|
||||||
},
|
|
||||||
"then": {
|
|
||||||
"$ref": "resource://activity-stream/schemas/BackgroundTaskMessagingExperiment.schema.json#/$defs/ToastNotification"
|
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
]
|
"required": [
|
||||||
|
"template"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"then": {
|
||||||
|
"$ref": "resource://activity-stream/schemas/BackgroundTaskMessagingExperiment.schema.json#/$defs/ToastNotification"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"$defs": {
|
"$defs": {
|
||||||
|
|
@ -240,11 +231,20 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": true,
|
"additionalProperties": true,
|
||||||
"required": [
|
"dependentRequired": {
|
||||||
"id",
|
"id": [
|
||||||
"content",
|
"content",
|
||||||
"template"
|
"template"
|
||||||
]
|
],
|
||||||
|
"content": [
|
||||||
|
"id",
|
||||||
|
"template"
|
||||||
|
],
|
||||||
|
"template": [
|
||||||
|
"id",
|
||||||
|
"content"
|
||||||
|
]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"localizedText": {
|
"localizedText": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
|
|
||||||
|
|
@ -102,11 +102,11 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": true,
|
"additionalProperties": true,
|
||||||
"required": [
|
"dependentRequired": {
|
||||||
"id",
|
"id": ["content", "template"],
|
||||||
"content",
|
"content": ["id", "template"],
|
||||||
"template"
|
"template": ["id", "content"]
|
||||||
]
|
}
|
||||||
},
|
},
|
||||||
"localizedText": {
|
"localizedText": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
|
|
||||||
|
|
@ -3,210 +3,201 @@
|
||||||
"$id": "resource://activity-stream/schemas/MessagingExperiment.schema.json",
|
"$id": "resource://activity-stream/schemas/MessagingExperiment.schema.json",
|
||||||
"title": "Messaging Experiment",
|
"title": "Messaging Experiment",
|
||||||
"description": "A Firefox Messaging System message.",
|
"description": "A Firefox Messaging System message.",
|
||||||
"oneOf": [
|
"allOf": [
|
||||||
{
|
{
|
||||||
"description": "An empty FxMS message.",
|
"$ref": "resource://activity-stream/schemas/MessagingExperiment.schema.json#/$defs/Message"
|
||||||
"type": "object",
|
|
||||||
"additionalProperties": false
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allOf": [
|
"if": {
|
||||||
{
|
"type": "object",
|
||||||
"$ref": "resource://activity-stream/schemas/MessagingExperiment.schema.json#/$defs/Message"
|
"properties": {
|
||||||
},
|
"template": {
|
||||||
{
|
"type": "string",
|
||||||
"if": {
|
"enum": [
|
||||||
"type": "object",
|
"cfr_urlbar_chiclet"
|
||||||
"properties": {
|
|
||||||
"template": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"cfr_urlbar_chiclet"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"required": [
|
|
||||||
"template"
|
|
||||||
]
|
]
|
||||||
},
|
|
||||||
"then": {
|
|
||||||
"$ref": "resource://activity-stream/schemas/MessagingExperiment.schema.json#/$defs/CFRUrlbarChiclet"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
"required": [
|
||||||
"if": {
|
"template"
|
||||||
"type": "object",
|
]
|
||||||
"properties": {
|
},
|
||||||
"template": {
|
"then": {
|
||||||
"type": "string",
|
"$ref": "resource://activity-stream/schemas/MessagingExperiment.schema.json#/$defs/CFRUrlbarChiclet"
|
||||||
"enum": [
|
}
|
||||||
"cfr_doorhanger",
|
},
|
||||||
"milestone_message"
|
{
|
||||||
]
|
"if": {
|
||||||
}
|
"type": "object",
|
||||||
},
|
"properties": {
|
||||||
"required": [
|
"template": {
|
||||||
"template"
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"cfr_doorhanger",
|
||||||
|
"milestone_message"
|
||||||
]
|
]
|
||||||
},
|
|
||||||
"then": {
|
|
||||||
"$ref": "resource://activity-stream/schemas/MessagingExperiment.schema.json#/$defs/ExtensionDoorhanger"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
"required": [
|
||||||
"if": {
|
"template"
|
||||||
"type": "object",
|
]
|
||||||
"properties": {
|
},
|
||||||
"template": {
|
"then": {
|
||||||
"type": "string",
|
"$ref": "resource://activity-stream/schemas/MessagingExperiment.schema.json#/$defs/ExtensionDoorhanger"
|
||||||
"enum": [
|
}
|
||||||
"infobar"
|
},
|
||||||
]
|
{
|
||||||
}
|
"if": {
|
||||||
},
|
"type": "object",
|
||||||
"required": [
|
"properties": {
|
||||||
"template"
|
"template": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"infobar"
|
||||||
]
|
]
|
||||||
},
|
|
||||||
"then": {
|
|
||||||
"$ref": "resource://activity-stream/schemas/MessagingExperiment.schema.json#/$defs/InfoBar"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
"required": [
|
||||||
"if": {
|
"template"
|
||||||
"type": "object",
|
]
|
||||||
"properties": {
|
},
|
||||||
"template": {
|
"then": {
|
||||||
"type": "string",
|
"$ref": "resource://activity-stream/schemas/MessagingExperiment.schema.json#/$defs/InfoBar"
|
||||||
"enum": [
|
}
|
||||||
"pb_newtab"
|
},
|
||||||
]
|
{
|
||||||
}
|
"if": {
|
||||||
},
|
"type": "object",
|
||||||
"required": [
|
"properties": {
|
||||||
"template"
|
"template": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"pb_newtab"
|
||||||
]
|
]
|
||||||
},
|
|
||||||
"then": {
|
|
||||||
"$ref": "resource://activity-stream/schemas/MessagingExperiment.schema.json#/$defs/NewtabPromoMessage"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
"required": [
|
||||||
"if": {
|
"template"
|
||||||
"type": "object",
|
]
|
||||||
"properties": {
|
},
|
||||||
"template": {
|
"then": {
|
||||||
"type": "string",
|
"$ref": "resource://activity-stream/schemas/MessagingExperiment.schema.json#/$defs/NewtabPromoMessage"
|
||||||
"enum": [
|
}
|
||||||
"protections_panel"
|
},
|
||||||
]
|
{
|
||||||
}
|
"if": {
|
||||||
},
|
"type": "object",
|
||||||
"required": [
|
"properties": {
|
||||||
"template"
|
"template": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"protections_panel"
|
||||||
]
|
]
|
||||||
},
|
|
||||||
"then": {
|
|
||||||
"$ref": "resource://activity-stream/schemas/MessagingExperiment.schema.json#/$defs/ProtectionsPanelMessage"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
"required": [
|
||||||
"if": {
|
"template"
|
||||||
"type": "object",
|
]
|
||||||
"properties": {
|
},
|
||||||
"template": {
|
"then": {
|
||||||
"type": "string",
|
"$ref": "resource://activity-stream/schemas/MessagingExperiment.schema.json#/$defs/ProtectionsPanelMessage"
|
||||||
"enum": [
|
}
|
||||||
"spotlight",
|
},
|
||||||
"feature_callout"
|
{
|
||||||
]
|
"if": {
|
||||||
}
|
"type": "object",
|
||||||
},
|
"properties": {
|
||||||
"required": [
|
"template": {
|
||||||
"template"
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"spotlight",
|
||||||
|
"feature_callout"
|
||||||
]
|
]
|
||||||
},
|
|
||||||
"then": {
|
|
||||||
"$ref": "resource://activity-stream/schemas/MessagingExperiment.schema.json#/$defs/Spotlight"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
"required": [
|
||||||
"if": {
|
"template"
|
||||||
"type": "object",
|
]
|
||||||
"properties": {
|
},
|
||||||
"template": {
|
"then": {
|
||||||
"type": "string",
|
"$ref": "resource://activity-stream/schemas/MessagingExperiment.schema.json#/$defs/Spotlight"
|
||||||
"enum": [
|
}
|
||||||
"toast_notification"
|
},
|
||||||
]
|
{
|
||||||
}
|
"if": {
|
||||||
},
|
"type": "object",
|
||||||
"required": [
|
"properties": {
|
||||||
"template"
|
"template": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"toast_notification"
|
||||||
]
|
]
|
||||||
},
|
|
||||||
"then": {
|
|
||||||
"$ref": "resource://activity-stream/schemas/MessagingExperiment.schema.json#/$defs/ToastNotification"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
"required": [
|
||||||
"if": {
|
"template"
|
||||||
"type": "object",
|
]
|
||||||
"properties": {
|
},
|
||||||
"template": {
|
"then": {
|
||||||
"type": "string",
|
"$ref": "resource://activity-stream/schemas/MessagingExperiment.schema.json#/$defs/ToastNotification"
|
||||||
"enum": [
|
}
|
||||||
"toolbar_badge"
|
},
|
||||||
]
|
{
|
||||||
}
|
"if": {
|
||||||
},
|
"type": "object",
|
||||||
"required": [
|
"properties": {
|
||||||
"template"
|
"template": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"toolbar_badge"
|
||||||
]
|
]
|
||||||
},
|
|
||||||
"then": {
|
|
||||||
"$ref": "resource://activity-stream/schemas/MessagingExperiment.schema.json#/$defs/ToolbarBadgeMessage"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
"required": [
|
||||||
"if": {
|
"template"
|
||||||
"type": "object",
|
]
|
||||||
"properties": {
|
},
|
||||||
"template": {
|
"then": {
|
||||||
"type": "string",
|
"$ref": "resource://activity-stream/schemas/MessagingExperiment.schema.json#/$defs/ToolbarBadgeMessage"
|
||||||
"enum": [
|
}
|
||||||
"update_action"
|
},
|
||||||
]
|
{
|
||||||
}
|
"if": {
|
||||||
},
|
"type": "object",
|
||||||
"required": [
|
"properties": {
|
||||||
"template"
|
"template": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"update_action"
|
||||||
]
|
]
|
||||||
},
|
|
||||||
"then": {
|
|
||||||
"$ref": "resource://activity-stream/schemas/MessagingExperiment.schema.json#/$defs/UpdateAction"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
"required": [
|
||||||
"if": {
|
"template"
|
||||||
"type": "object",
|
]
|
||||||
"properties": {
|
},
|
||||||
"template": {
|
"then": {
|
||||||
"type": "string",
|
"$ref": "resource://activity-stream/schemas/MessagingExperiment.schema.json#/$defs/UpdateAction"
|
||||||
"enum": [
|
}
|
||||||
"whatsnew_panel_message"
|
},
|
||||||
]
|
{
|
||||||
}
|
"if": {
|
||||||
},
|
"type": "object",
|
||||||
"required": [
|
"properties": {
|
||||||
"template"
|
"template": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"whatsnew_panel_message"
|
||||||
]
|
]
|
||||||
},
|
|
||||||
"then": {
|
|
||||||
"$ref": "resource://activity-stream/schemas/MessagingExperiment.schema.json#/$defs/WhatsNewMessage"
|
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
]
|
"required": [
|
||||||
|
"template"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"then": {
|
||||||
|
"$ref": "resource://activity-stream/schemas/MessagingExperiment.schema.json#/$defs/WhatsNewMessage"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"$defs": {
|
"$defs": {
|
||||||
|
|
@ -1567,11 +1558,20 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": true,
|
"additionalProperties": true,
|
||||||
"required": [
|
"dependentRequired": {
|
||||||
"id",
|
"id": [
|
||||||
"content",
|
"content",
|
||||||
"template"
|
"template"
|
||||||
]
|
],
|
||||||
|
"content": [
|
||||||
|
"id",
|
||||||
|
"template"
|
||||||
|
],
|
||||||
|
"template": [
|
||||||
|
"id",
|
||||||
|
"content"
|
||||||
|
]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"localizedText": {
|
"localizedText": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"trigger": {
|
||||||
|
"id": "defaultBrowserCheck"
|
||||||
|
},
|
||||||
|
"targeting": "source == 'startup' && !isMajorUpgrade && !activeNotifications && totalBookmarksCount == 5"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"groups": [
|
||||||
|
"eco"
|
||||||
|
],
|
||||||
|
"trigger": {
|
||||||
|
"id": "defaultBrowserCheck"
|
||||||
|
},
|
||||||
|
"targeting": "source == 'startup' && !isMajorUpgrade && !activeNotifications && totalBookmarksCount == 5"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
@ -91,8 +91,9 @@ SCHEMAS = [
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
bundle_common=True,
|
bundle_common=True,
|
||||||
# These are generated via extract-test-corpus.js
|
|
||||||
test_corpus={
|
test_corpus={
|
||||||
|
"ReachExperiments": Path("corpus", "ReachExperiments.messages.json"),
|
||||||
|
# These are generated via extract-test-corpus.js
|
||||||
"CFRMessageProvider": Path("corpus", "CFRMessageProvider.messages.json"),
|
"CFRMessageProvider": Path("corpus", "CFRMessageProvider.messages.json"),
|
||||||
"OnboardingMessageProvider": Path(
|
"OnboardingMessageProvider": Path(
|
||||||
"corpus", "OnboardingMessageProvider.messages.json"
|
"corpus", "OnboardingMessageProvider.messages.json"
|
||||||
|
|
@ -316,57 +317,42 @@ def bundle_schema(schema_def: SchemaDefinition):
|
||||||
"$id": schema_def.schema_id,
|
"$id": schema_def.schema_id,
|
||||||
"title": "Messaging Experiment",
|
"title": "Messaging Experiment",
|
||||||
"description": "A Firefox Messaging System message.",
|
"description": "A Firefox Messaging System message.",
|
||||||
# A message must be one of
|
"allOf": [
|
||||||
# - an empty message (i.e., a completely empty object), which is the
|
# Ensure each message has all the fields defined in the base
|
||||||
# equivalent of an experiment branch not providing a message; or
|
# Message type.
|
||||||
# - An object that contains a template field
|
#
|
||||||
"oneOf": [
|
# This is slightly redundant because each message should
|
||||||
{
|
# already inherit from this message type, but it is easier
|
||||||
"description": "An empty FxMS message.",
|
# to add this requirement here than to verify that each
|
||||||
"type": "object",
|
# message's schema is properly inheriting.
|
||||||
"additionalProperties": False,
|
{"$ref": f"{schema_def.schema_id}#/$defs/Message"},
|
||||||
},
|
# For each message type, create a subschema that says if the
|
||||||
{
|
# template field matches a value for a message type defined
|
||||||
"allOf": [
|
# in MESSAGE_TYPES, then the message must also match the
|
||||||
# Ensure each message has all the fields defined in the base
|
# schema for that message type.
|
||||||
# Message type.
|
#
|
||||||
#
|
# This is done using `allOf: [{ if, then }]` instead of `oneOf: []`
|
||||||
# This is slightly redundant because each message should
|
# because it provides better error messages. Using `if-then`
|
||||||
# already inherit from this message type, but it is easier
|
# will only show validation errors for the sub-schema that
|
||||||
# to add this requirement here than to verify that each
|
# matches template, whereas using `oneOf` will show
|
||||||
# message's schema is properly inheriting.
|
# validation errors for *all* sub-schemas, which makes
|
||||||
{"$ref": f"{schema_def.schema_id}#/$defs/Message"},
|
# debugging messages much harder.
|
||||||
# For each message type, create a subschema that says if the
|
*(
|
||||||
# template field matches a value for a message type defined
|
{
|
||||||
# in MESSAGE_TYPES, then the message must also match the
|
"if": {
|
||||||
# schema for that message type.
|
"type": "object",
|
||||||
#
|
"properties": {
|
||||||
# This is done using `allOf: [{ if, then }]` instead of `oneOf: []`
|
"template": {
|
||||||
# because it provides better error messages. Using `if-then`
|
"type": "string",
|
||||||
# will only show validation errors for the sub-schema that
|
"enum": templates[message_type],
|
||||||
# matches template, whereas using `oneOf` will show
|
|
||||||
# validation errors for *all* sub-schemas, which makes
|
|
||||||
# debugging messages much harder.
|
|
||||||
*(
|
|
||||||
{
|
|
||||||
"if": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"template": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": templates[message_type],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"required": ["template"],
|
|
||||||
},
|
},
|
||||||
"then": {
|
},
|
||||||
"$ref": f"{schema_def.schema_id}#/$defs/{message_type}"
|
"required": ["template"],
|
||||||
},
|
},
|
||||||
}
|
"then": {"$ref": f"{schema_def.schema_id}#/$defs/{message_type}"},
|
||||||
for message_type in schema_def.message_types
|
}
|
||||||
),
|
for message_type in schema_def.message_types
|
||||||
],
|
),
|
||||||
},
|
|
||||||
],
|
],
|
||||||
"$defs": defs,
|
"$defs": defs,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,96 @@
|
||||||
|
/* Any copyright is dedicated to the Public Domain.
|
||||||
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||||
|
|
||||||
|
const { ObjectUtils } = ChromeUtils.import(
|
||||||
|
"resource://gre/modules/ObjectUtils.jsm"
|
||||||
|
);
|
||||||
|
|
||||||
|
const MESSAGES = [
|
||||||
|
{
|
||||||
|
trigger: { id: "defaultBrowserCheck" },
|
||||||
|
targeting:
|
||||||
|
"source == 'startup' && !isMajorUpgrade && !activeNotifications && totalBookmarksCount == 5",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
groups: ["eco"],
|
||||||
|
trigger: {
|
||||||
|
id: "defaultBrowserCheck",
|
||||||
|
},
|
||||||
|
targeting:
|
||||||
|
"source == 'startup' && !isMajorUpgrade && !activeNotifications && totalBookmarksCount == 5",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
let EXPERIMENT_VALIDATOR;
|
||||||
|
|
||||||
|
add_setup(async function setup() {
|
||||||
|
EXPERIMENT_VALIDATOR = await schemaValidatorFor(
|
||||||
|
"resource://activity-stream/schemas/MessagingExperiment.schema.json"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
add_task(function test_reach_experiments_validation() {
|
||||||
|
for (const [index, message] of MESSAGES.entries()) {
|
||||||
|
assertValidates(
|
||||||
|
EXPERIMENT_VALIDATOR,
|
||||||
|
message,
|
||||||
|
`Message ${index} validates as a MessagingExperiment`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function depError(has, missing) {
|
||||||
|
return {
|
||||||
|
instanceLocation: "#",
|
||||||
|
keyword: "dependentRequired",
|
||||||
|
keywordLocation: "#/oneOf/1/allOf/0/$ref/dependantRequired",
|
||||||
|
error: `Instance has "${has}" but does not have "${missing}".`,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function assertContains(haystack, needle) {
|
||||||
|
Assert.ok(
|
||||||
|
haystack.find(item => ObjectUtils.deepEqual(item, needle)) !== null
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
add_task(function test_reach_experiment_dependentRequired() {
|
||||||
|
info("Testing that if id is present then content and template are required");
|
||||||
|
|
||||||
|
{
|
||||||
|
const message = {
|
||||||
|
...MESSAGES[0],
|
||||||
|
id: "message-id",
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = EXPERIMENT_VALIDATOR.validate(message);
|
||||||
|
Assert.ok(!result.valid, "message should not validate");
|
||||||
|
|
||||||
|
assertContains(result.errors, depError("id", "content"));
|
||||||
|
assertContains(result.errors, depError("id", "template"));
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
const message = {
|
||||||
|
...MESSAGES[0],
|
||||||
|
content: {},
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = EXPERIMENT_VALIDATOR.validate(message);
|
||||||
|
Assert.ok(!result.valid, "message should not validate");
|
||||||
|
assertContains(result.errors, depError("content", "id"));
|
||||||
|
assertContains(result.errors, depError("content", "template"));
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
const message = {
|
||||||
|
...MESSAGES[0],
|
||||||
|
template: "cfr",
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = EXPERIMENT_VALIDATOR.validate(message);
|
||||||
|
Assert.ok(!result.valid, "message should not validate");
|
||||||
|
assertContains(result.errors, depError("template", "content"));
|
||||||
|
assertContains(result.errors, depError("template", "id"));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
@ -26,3 +26,4 @@ skip-if =
|
||||||
[test_InflightAssetsMessageProvider.js]
|
[test_InflightAssetsMessageProvider.js]
|
||||||
[test_OnboardingMessageProvider.js]
|
[test_OnboardingMessageProvider.js]
|
||||||
[test_PanelTestProvider.js]
|
[test_PanelTestProvider.js]
|
||||||
|
[test_reach_experiments.js]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue