зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset a88235c19594 (bug 1444327) for ESlint failure at devtools/client/inspector/fonts/test/browser_fontinspector_copy-URL.js
This commit is contained in:
Родитель
68f9aa62e9
Коммит
3c699ccb2c
|
@ -10,10 +10,6 @@ const PropTypes = require("devtools/client/shared/vendor/react-prop-types");
|
|||
|
||||
const FontPreview = createFactory(require("./FontPreview"));
|
||||
|
||||
loader.lazyRequireGetter(this, "Menu", "devtools/client/framework/menu");
|
||||
loader.lazyRequireGetter(this, "MenuItem", "devtools/client/framework/menu-item");
|
||||
loader.lazyRequireGetter(this, "clipboardHelper", "devtools/shared/platform/clipboard");
|
||||
|
||||
const { getStr } = require("../utils/l10n");
|
||||
const Types = require("../types");
|
||||
|
||||
|
@ -34,7 +30,6 @@ class Font extends PureComponent {
|
|||
};
|
||||
|
||||
this.onFontFaceRuleToggle = this.onFontFaceRuleToggle.bind(this);
|
||||
this.onLinkContextMenu = this.onLinkContextMenu.bind(this);
|
||||
}
|
||||
|
||||
componentWillReceiveProps(newProps) {
|
||||
|
@ -47,21 +42,6 @@ class Font extends PureComponent {
|
|||
});
|
||||
}
|
||||
|
||||
copyURL() {
|
||||
clipboardHelper.copyString(this.props.font.URI);
|
||||
}
|
||||
|
||||
onLinkContextMenu(event) {
|
||||
let menu = new Menu();
|
||||
menu.append(new MenuItem({
|
||||
label: getStr("fontinspector.copyURL"),
|
||||
click: () => this.copyURL(),
|
||||
}));
|
||||
menu.popup(event.screenX, event.screenY, {
|
||||
doc: event.target.ownerGlobal.parent.document
|
||||
});
|
||||
}
|
||||
|
||||
onFontFaceRuleToggle(event) {
|
||||
this.setState({
|
||||
isFontFaceRuleExpanded: !this.state.isFontFaceRuleExpanded
|
||||
|
@ -119,8 +99,7 @@ class Font extends PureComponent {
|
|||
dom.a(
|
||||
{
|
||||
className: "font-url",
|
||||
href: url,
|
||||
onContextMenu: this.onLinkContextMenu
|
||||
href: url
|
||||
},
|
||||
format
|
||||
)
|
||||
|
|
|
@ -15,8 +15,6 @@ support-files =
|
|||
!/devtools/client/shared/test/test-actor-registry.js
|
||||
|
||||
[browser_fontinspector.js]
|
||||
[browser_fontinspector_copy-URL.js]
|
||||
subsuite = clipboard
|
||||
[browser_fontinspector_edit-previews.js]
|
||||
[browser_fontinspector_expand-css-code.js]
|
||||
[browser_fontinspector_other-fonts.js]
|
||||
|
|
|
@ -1,48 +0,0 @@
|
|||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
// Test that a context menu appears when right-clicking on a web font URL, and that the
|
||||
// URL can be copied to the clipboard thanks to it.
|
||||
|
||||
const TEST_URI = URL_ROOT + "browser_fontinspector.html";
|
||||
|
||||
add_task(async function () {
|
||||
let { view, toolbox } = await openFontInspectorForURL(TEST_URI);
|
||||
let viewDoc = view.document;
|
||||
let win = viewDoc.defaultView;
|
||||
|
||||
let fontEl = getUsedFontsEls(viewDoc)[0];
|
||||
let linkEl = fontEl.querySelector(".font-url");
|
||||
|
||||
// This is the container for all our popup menus in the toolbox. At this time, the
|
||||
// copy menu (xul <menupopup> element) does not exist inside it yet.
|
||||
let popupset = toolbox.doc.querySelector("popupset");
|
||||
|
||||
// It is only created when the following event is received in the Font component.
|
||||
info("Right-clicking on the first font's link");
|
||||
EventUtils.synthesizeMouse(linkEl, 2, 2, {type: "contextmenu", button: 2}, win);
|
||||
|
||||
// Now the menu exist and is in the process of getting shown. But since this happen
|
||||
// asynchronously, it is fine only starting to listen for the popupshown event only now.
|
||||
// Anyway, it isn't possible to start listening prior to this since the element does not
|
||||
// exist before.
|
||||
info("Waiting for the new menu to open");
|
||||
let menu = popupset.querySelector("menupopup[menu-api]");
|
||||
await once(menu, "popupshown");
|
||||
|
||||
let items = menu.querySelectorAll("menuitem");
|
||||
is(items.length, 1, "There's only one menu item displayed");
|
||||
is(items[0].getAttribute("label"), "Copy Link", "This is the right menu item");
|
||||
|
||||
info("Clicking the menu item and waiting for the clipboard to receive the URL");
|
||||
let expected = linkEl.href;
|
||||
await waitForClipboardPromise(() => items[0].click(), expected);
|
||||
|
||||
info("Closing the menu");
|
||||
let onHidden = once(menu, "popuphidden");
|
||||
menu.hidePopup();
|
||||
await onHidden;
|
||||
});
|
|
@ -25,8 +25,3 @@ fontinspector.otherFontsInPageHeader=Other fonts in page
|
|||
# tooltip on hover of a font preview string. Clicking on the string opens a text input
|
||||
# where users can type to change the preview text.
|
||||
fontinspector.editPreview=Click to edit preview
|
||||
|
||||
# LOCALIZATION NOTE (fontinspector.copyURL): This is the text that appears in a menu item
|
||||
# when a user right-clicks on the link for a remote font file in the font inspector.
|
||||
# It allows the user to copy the URL for the font file to the clipboard.
|
||||
fontinspector.copyURL=Copy Link
|
||||
|
|
Загрузка…
Ссылка в новой задаче