Backed out changeset 179824908d2d (bug 1788231) for causing mochitest failures on browser_sma_click_element.js CLOSED TREE

This commit is contained in:
Cristian Tuns 2022-09-02 16:59:41 -04:00
Родитель 969900e20a
Коммит 115ce57986
6 изменённых файлов: 5 добавлений и 110 удалений

Просмотреть файл

@ -366,6 +366,11 @@ async function _renderCallout() {
* Render content based on about:welcome multistage template.
*/
async function showFeatureCallout(messageId) {
// Don't show the feature tour if user has already completed it.
if (lazy.featureTourProgress.complete) {
return;
}
await _loadConfig();
if (!CONFIG?.screens?.length) {

Просмотреть файл

@ -393,12 +393,6 @@ const SpecialMessageActions = {
throw new Error(
`Special message action with type ${action.type} is unsupported.`
);
case "CLICK_ELEMENT":
const clickElement = window.document.querySelector(
action.data.selector
);
clickElement?.click();
break;
}
},
};

Просмотреть файл

@ -542,24 +542,6 @@
"required": ["data", "type"],
"additionalProperties": false,
"description": "Runs multiple actions"
},
{
"type": "object",
"properties": {
"data": {
"selector": {
"type": "string",
"description": "A CSS selector for the HTML element to be clicked"
}
},
"type": {
"type": "string",
"enum": ["CLICK_ELEMENT"]
}
},
"required": ["data", "type"],
"additionalProperties": false,
"description": "Selects an element in the current Window's document and triggers a click action"
}
]
}

Просмотреть файл

@ -316,9 +316,3 @@ Action for running multiple actions. Actions should be included in an array of a
}
}
```
### `CLICK_ELEMENT`
* args: `string` A CSS selector for the HTML element to be clicked
Selects an element in the current Window's document and triggers a click action

Просмотреть файл

@ -29,5 +29,4 @@ skip-if = os != "win"
[browser_sma_default_browser.js]
[browser_sma_tcp.js]
[browser_sma_set_prefs.js]
[browser_sma_click_element.js]
[browser_sma_handle_multiaction.js]

Просмотреть файл

@ -1,79 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
const { ASRouter } = ChromeUtils.import(
"resource://activity-stream/lib/ASRouter.jsm"
);
const TEST_MESSAGE = {
message: {
content: {
id: "TEST_MESSAGE",
template: "multistage",
backdrop: "transparent",
transitions: false,
screens: [
{
id: "TEST_SCREEN_ID",
parent_selector: "#tabpickup-steps",
content: {
position: "callout",
arrow_position: "top",
title: {
string_id: "Test",
},
subtitle: {
string_id: "Test",
},
primary_button: {
label: {
string_id: "Test",
},
action: {
type: "CLICK_ELEMENT",
data: {
selector:
"#tab-pickup-container button.primary:not(#error-state-button)",
},
},
},
},
},
],
},
},
};
add_task(async function test_CLICK_ELEMENT() {
const calloutSelector = "#root.featureCallout";
sinon.stub(ASRouter, "sendTriggerMessage").returns(TEST_MESSAGE);
const clickStub = sinon.stub();
await BrowserTestUtils.withNewTab(
{
gBrowser,
url: "about:firefoxview",
},
async browser => {
const { document } = browser.contentWindow;
await BrowserTestUtils.waitForCondition(() => {
return document.querySelector(
`${calloutSelector}:not(.hidden) .${TEST_MESSAGE.message.content.screens[0].id}`
);
});
// Clicking the CTA with the CLICK_ELEMENT action should result in the element found with the configured selector being clicked
const clickElementSelector =
TEST_MESSAGE.message.content.screens[0].content.primary_button.action
.data.selector;
const clickElement = document.querySelector(clickElementSelector);
clickElement.addEventListener("click", clickStub);
document.querySelector(`${calloutSelector} button.primary`).click();
Assert.equal(clickStub.calledOnce, true);
}
);
BrowserTestUtils.removeTab(gBrowser.selectedTab);
});