From d25ba7d760b017b038e5aa6c0a605b4a330eb68d Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Wed, 21 May 2014 11:38:25 +0200 Subject: Recommit working copy to repo with proper line endings. --- browser/devtools/fontinspector/test/Makefile.in | 19 ++++ .../devtools/fontinspector/test/browser_font.woff | Bin 0 -> 4704 bytes .../fontinspector/test/browser_fontinspector.html | 20 ++++ .../fontinspector/test/browser_fontinspector.js | 102 +++++++++++++++++++++ browser/devtools/fontinspector/test/moz.build | 6 ++ 5 files changed, 147 insertions(+) create mode 100644 browser/devtools/fontinspector/test/Makefile.in create mode 100644 browser/devtools/fontinspector/test/browser_font.woff create mode 100644 browser/devtools/fontinspector/test/browser_fontinspector.html create mode 100644 browser/devtools/fontinspector/test/browser_fontinspector.js create mode 100644 browser/devtools/fontinspector/test/moz.build (limited to 'browser/devtools/fontinspector/test') diff --git a/browser/devtools/fontinspector/test/Makefile.in b/browser/devtools/fontinspector/test/Makefile.in new file mode 100644 index 000000000..4e1e45775 --- /dev/null +++ b/browser/devtools/fontinspector/test/Makefile.in @@ -0,0 +1,19 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +DEPTH = @DEPTH@ +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ +relativesrcdir = @relativesrcdir@ + +include $(DEPTH)/config/autoconf.mk + +MOCHITEST_BROWSER_FILES := \ + browser_fontinspector.js \ + browser_fontinspector.html \ + browser_font.woff \ + $(NULL) + +include $(topsrcdir)/config/rules.mk diff --git a/browser/devtools/fontinspector/test/browser_font.woff b/browser/devtools/fontinspector/test/browser_font.woff new file mode 100644 index 000000000..e8440843b Binary files /dev/null and b/browser/devtools/fontinspector/test/browser_font.woff differ diff --git a/browser/devtools/fontinspector/test/browser_fontinspector.html b/browser/devtools/fontinspector/test/browser_fontinspector.html new file mode 100644 index 000000000..13d7a2e4b --- /dev/null +++ b/browser/devtools/fontinspector/test/browser_fontinspector.html @@ -0,0 +1,20 @@ + + + + + + BODY +
DIV
+ diff --git a/browser/devtools/fontinspector/test/browser_fontinspector.js b/browser/devtools/fontinspector/test/browser_fontinspector.js new file mode 100644 index 000000000..e57fe6093 --- /dev/null +++ b/browser/devtools/fontinspector/test/browser_fontinspector.js @@ -0,0 +1,102 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +let tempScope = {}; +let {gDevTools} = Cu.import("resource:///modules/devtools/gDevTools.jsm", {}); +let {devtools} = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}); +let TargetFactory = devtools.TargetFactory; + +let DOMUtils = Cc["@mozilla.org/inspector/dom-utils;1"].getService(Ci.inIDOMUtils); + +function test() { + waitForExplicitFinish(); + + let doc; + let node; + let view; + let inspector; + + gBrowser.selectedTab = gBrowser.addTab(); + gBrowser.selectedBrowser.addEventListener("load", function onload() { + gBrowser.selectedBrowser.removeEventListener("load", onload, true); + doc = content.document; + waitForFocus(setupTest, content); + }, true); + + content.location = "http://mochi.test:8888/browser/browser/devtools/fontinspector/test/browser_fontinspector.html"; + + function setupTest() { + let rng = doc.createRange(); + rng.selectNode(doc.body); + let fonts = DOMUtils.getUsedFontFaces(rng); + if (fonts.length != 2) { + // Fonts are not loaded yet. + // Let try again in a couple of milliseconds (hacky, but + // there's not better way to do it. See bug 835247). + setTimeout(setupTest, 500); + } else { + let target = TargetFactory.forTab(gBrowser.selectedTab); + gDevTools.showToolbox(target, "inspector").then(function(toolbox) { + openFontInspector(toolbox.getCurrentPanel()); + }); + } + } + + function openFontInspector(aInspector) { + inspector = aInspector; + + info("Inspector open"); + + inspector.selection.setNode(doc.body); + inspector.sidebar.select("fontinspector"); + inspector.sidebar.once("fontinspector-ready", viewReady); + } + + function viewReady() { + info("Font Inspector ready"); + + view = inspector.sidebar.getWindowForTab("fontinspector"); + + ok(!!view.fontInspector, "Font inspector document is alive."); + + let d = view.document; + + let s = d.querySelectorAll("#all-fonts > section"); + is(s.length, 2, "Found 2 fonts"); + + is(s[0].querySelector(".font-name").textContent, + "DeLarge Bold", "font 0: Right font name"); + ok(s[0].classList.contains("is-remote"), + "font 0: is remote"); + is(s[0].querySelector(".font-url").value, + "http://mochi.test:8888/browser/browser/devtools/fontinspector/test/browser_font.woff", + "font 0: right url"); + is(s[0].querySelector(".font-format").textContent, + "woff", "font 0: right font format"); + 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; + + // On Linux test machines, the Arial font doesn't exist. + // The fallback is "Liberation Sans" + + ok((font1Name == "Arial") || (font1Name == "Liberation Sans"), + "font 1: Right font name"); + ok(s[1].classList.contains("is-local"), "font 1: is local"); + ok((font1CssName == "Arial") || (font1CssName == "Liberation Sans"), + "Arial", "font 1: right css name"); + + executeSoon(function() { + gDevTools.once("toolbox-destroyed", finishUp); + inspector._toolbox.destroy(); + }); + } + + function finishUp() { + gBrowser.removeCurrentTab(); + finish(); + } +} diff --git a/browser/devtools/fontinspector/test/moz.build b/browser/devtools/fontinspector/test/moz.build new file mode 100644 index 000000000..895d11993 --- /dev/null +++ b/browser/devtools/fontinspector/test/moz.build @@ -0,0 +1,6 @@ +# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + -- cgit v1.2.3