Bug 1540722 - Copy link location should work for learn-more links. r=nchevobbe

Support for coping link location from within the Console panel (through the context menu) can be extended and cover learn more links too.

Differential Revision: https://phabricator.services.mozilla.com/D38546

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Armando Ferreira 2019-07-23 18:34:08 +00:00
Родитель 7fd5fb983a
Коммит 237ff71915
3 изменённых файлов: 34 добавлений и 1 удалений

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

@ -144,6 +144,7 @@ class Message extends Component {
onLearnMoreClick(e) {
const { exceptionDocURL } = this.props;
this.props.serviceContainer.openLink(exceptionDocURL, e);
e.preventDefault();
}
toggleMessage(e) {
@ -428,6 +429,7 @@ class Message extends Component {
learnMore = dom.a(
{
className: "learn-more-link webconsole-learn-more-link",
href: exceptionDocURL,
title: exceptionDocURL.split("?")[0],
onClick: this.onLearnMoreClick,
},

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

@ -31,7 +31,8 @@ async function performTests() {
for (const [errorMessageName, expression] of Object.entries(
ErrorDocStatements
)) {
const title = ErrorDocs.GetURL({ errorMessageName }).split("?")[0];
const errorUrl = ErrorDocs.GetURL({ errorMessageName });
const title = errorUrl.split("?")[0];
hud.ui.clearOutput();
const onMessage = waitForMessage(hud, "RangeError:");
@ -47,5 +48,10 @@ async function performTests() {
title,
`The link has the expected "${title}" title`
);
is(
learnMoreLink.href,
errorUrl,
`The link has the expected "${errorUrl}" href value`
);
}
}

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

@ -72,5 +72,30 @@ add_task(async function() {
await waitForClipboardPromise(() => copyURLItem.click(), TEST_URI);
ok(true, "Expected text was copied to the clipboard.");
await hideContextMenu(hud);
hud.ui.clearOutput();
info("Test Copy URL menu item from [Learn More] link");
info("Generate a Reference Error in the JS Console");
message = await executeAndWaitForMessage(
hud,
"area51.aliens",
"ReferenceError:"
);
ok(message, "Error log found in the console");
const learnMoreElement = message.node.querySelector(".learn-more-link");
menuPopup = await openContextMenu(hud, learnMoreElement);
copyURLItem = menuPopup.querySelector(CONTEXT_MENU_ID);
ok(copyURLItem, "Copy url menu item is available in context menu");
info("Click on Copy URL menu item and wait for clipboard to be updated");
await waitForClipboardPromise(
() => copyURLItem.click(),
learnMoreElement.href
);
ok(true, "Expected text was copied to the clipboard.");
await hideContextMenu(hud);
});