Bug 962085 - Font-inspector "show all fonts" button selects the <body> node remotely; r=paul

This commit is contained in:
Patrick Brosset 2014-01-23 16:54:04 +01:00
parent c40dc845e3
commit 1e3585dfe1
2 changed files with 44 additions and 22 deletions

View File

@ -194,17 +194,16 @@ FontInspector.prototype = {
!this.inspector.selection.isElementNode()) {
return;
}
let node = this.inspector.selection.nodeFront;
let contentDocument = node.ownerDocument;
let root = contentDocument.documentElement;
if (contentDocument.body) {
root = contentDocument.body;
}
this.inspector.selection.setNode(root, "fontinspector");
// Select the body node to show all fonts
let walker = this.inspector.walker;
walker.getRootNode().then(root => walker.querySelector(root, "body")).then(body => {
this.inspector.selection.setNodeFront(body, "fontinspector");
});
},
}
window.setPanel = function(panel) {
window.fontInspector = new FontInspector(panel, window);
}

View File

@ -12,8 +12,8 @@ function test() {
waitForExplicitFinish();
let doc;
let node;
let view;
let viewDoc;
let inspector;
gBrowser.selectedTab = gBrowser.addTab();
@ -43,25 +43,23 @@ function test() {
}
function openFontInspector(aInspector) {
inspector = aInspector;
info("Inspector open");
inspector = aInspector;
inspector.selection.setNode(doc.body);
inspector.sidebar.select("fontinspector");
inspector.sidebar.once("fontinspector-ready", viewReady);
inspector.sidebar.once("fontinspector-ready", testBodyFonts);
}
function viewReady() {
function testBodyFonts() {
info("Font Inspector ready");
view = inspector.sidebar.getWindowForTab("fontinspector");
viewDoc = view.document;
ok(!!view.fontInspector, "Font inspector document is alive.");
let d = view.document;
let s = d.querySelectorAll("#all-fonts > section");
let s = viewDoc.querySelectorAll("#all-fonts > section");
is(s.length, 2, "Found 2 fonts");
is(s[0].querySelector(".font-name").textContent,
@ -76,7 +74,6 @@ function test() {
is(s[0].querySelector(".font-css-name").textContent,
"bar", "font 0: right css name");
let font1Name = s[1].querySelector(".font-name").textContent;
let font1CssName = s[1].querySelector(".font-css-name").textContent;
@ -89,14 +86,40 @@ function test() {
ok((font1CssName == "Arial") || (font1CssName == "Liberation Sans"),
"Arial", "font 1: right css name");
executeSoon(function() {
gDevTools.once("toolbox-destroyed", finishUp);
inspector._toolbox.destroy();
testDivFonts();
}
function testDivFonts() {
inspector.selection.setNode(doc.querySelector("div"));
inspector.once("inspector-updated", () => {
let s = viewDoc.querySelectorAll("#all-fonts > section");
is(s.length, 1, "Found 1 font on DIV");
is(s[0].querySelector(".font-name").textContent, "DeLarge Bold",
"The DIV font has the right name");
testShowAllFonts();
});
}
function testShowAllFonts() {
viewDoc.querySelector("#showall").click();
inspector.once("inspector-updated", () => {
is(inspector.selection.node, doc.body, "Show all fonts selected the body node");
let s = viewDoc.querySelectorAll("#all-fonts > section");
is(s.length, 2, "And font-inspector still shows 2 fonts for body");
finishUp();
});
}
function finishUp() {
executeSoon(function() {
gDevTools.once("toolbox-destroyed", () => {
doc = view = viewDoc = inspector = null;
gBrowser.removeCurrentTab();
finish();
});
inspector._toolbox.destroy();
});
}
}