# HG changeset patch # User Patrick Brosset # Date 1517539221 18000 # Node ID 83725aa063c5798fc0898b25ffa845251cb68613 # Parent 1d0f45a52e8adb571f3bc1b28857ef40d5c21c41 Bug 1434981 - Display fonts for text nodes too; r=gl MozReview-Commit-ID: 4hzEowvZWk diff --git a/devtools/client/inspector/fonts/fonts.js b/devtools/client/inspector/fonts/fonts.js --- a/devtools/client/inspector/fonts/fonts.js +++ b/devtools/client/inspector/fonts/fonts.js @@ -134,23 +134,25 @@ class FontInspector { return; } let node = this.inspector.selection.nodeFront; let fonts = []; let { fontOptions } = this.store.getState(); let { showAllFonts, previewText } = fontOptions; - // Clear the list of fonts if the currently selected node is not connected or an - // element node unless all fonts are supposed to be shown. + // Clear the list of fonts if the currently selected node is not connected or a text + // or element node unless all fonts are supposed to be shown. + let isElementOrTextNode = this.inspector.selection.isElementNode() || + this.inspector.selection.isTextNode(); if (!showAllFonts && (!node || !this.isPanelVisible() || !this.inspector.selection.isConnected() || - !this.inspector.selection.isElementNode())) { + !isElementOrTextNode)) { this.store.dispatch(updateFonts(fonts)); return; } let options = { includePreviews: true, previewText, previewFillStyle: getColor("body-color") diff --git a/devtools/client/inspector/fonts/test/browser.ini b/devtools/client/inspector/fonts/test/browser.ini --- a/devtools/client/inspector/fonts/test/browser.ini +++ b/devtools/client/inspector/fonts/test/browser.ini @@ -12,9 +12,10 @@ support-files = !/devtools/client/inspector/test/head.js !/devtools/client/inspector/test/shared-head.js !/devtools/client/shared/test/test-actor.js !/devtools/client/shared/test/test-actor-registry.js [browser_fontinspector.js] [browser_fontinspector_edit-previews.js] [browser_fontinspector_edit-previews-show-all.js] +[browser_fontinspector_text-node.js] [browser_fontinspector_theme-change.js] diff --git a/devtools/client/inspector/fonts/test/browser_fontinspector_text-node.js b/devtools/client/inspector/fonts/test/browser_fontinspector_text-node.js new file mode 100644 --- /dev/null +++ b/devtools/client/inspector/fonts/test/browser_fontinspector_text-node.js @@ -0,0 +1,22 @@ +/* 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 the font-inspector also display fonts when a text node is selected. + +const TEST_URI = URL_ROOT + "browser_fontinspector.html"; + +add_task(function* () { + let { inspector, view } = yield openFontInspectorForURL(TEST_URI); + let viewDoc = view.document; + + info("Selecting the first text-node first-child of "); + let bodyNode = yield getNodeFront("body", inspector); + let { nodes } = yield inspector.walker.children(bodyNode); + yield selectNode(nodes[0], inspector); + + let sections = viewDoc.querySelectorAll("#all-fonts > section"); + is(sections.length, 1, "Font inspector shows 1 font"); +});