summaryrefslogtreecommitdiff
path: root/browser/devtools/fontinspector/test
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@gmail.com>2014-05-21 11:38:25 +0200
committerwolfbeast <mcwerewolf@gmail.com>2014-05-21 11:38:25 +0200
commitd25ba7d760b017b038e5aa6c0a605b4a330eb68d (patch)
tree16ec27edc7d5f83986f16236d3a36a2682a0f37e /browser/devtools/fontinspector/test
parenta942906574671868daf122284a9c4689e6924f74 (diff)
downloadpalemoon-gre-d25ba7d760b017b038e5aa6c0a605b4a330eb68d.tar.gz
Recommit working copy to repo with proper line endings.
Diffstat (limited to 'browser/devtools/fontinspector/test')
-rw-r--r--browser/devtools/fontinspector/test/Makefile.in19
-rw-r--r--browser/devtools/fontinspector/test/browser_font.woffbin0 -> 4704 bytes
-rw-r--r--browser/devtools/fontinspector/test/browser_fontinspector.html20
-rw-r--r--browser/devtools/fontinspector/test/browser_fontinspector.js102
-rw-r--r--browser/devtools/fontinspector/test/moz.build6
5 files changed, 147 insertions, 0 deletions
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
--- /dev/null
+++ b/browser/devtools/fontinspector/test/browser_font.woff
Binary files 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 @@
+<!DOCTYPE html>
+
+<style>
+ @font-face {
+ font-family: bar;
+ src: url(bad/font/name.ttf), url(browser_font.woff) format("woff");
+ }
+ body{
+ font-family:Arial;
+ }
+ div {
+ font-family:Arial;
+ font-family:bar;
+ }
+</style>
+
+<body>
+ BODY
+ <div>DIV</div>
+</body>
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/.
+