forked from harthur/firefox-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
78 lines (66 loc) · 1.6 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
var assert = require('assert'),
FirefoxClient = require("./index");
var url = "http://harthur.github.io/bugzilla-todos";
getFirstTab(function(tab) {
tab.DOM.querySelector("#title", function(err, node) {
console.log("got node:", node.tagName);
tab.DOM.getUsedFontFaces(node, { includePreviews: true }, function(err, fonts) {
for (var i in fonts) {
var font = fonts[i];
console.log("first font", font);
}
});
})
});
/*
loadUrl(url, function(tab) {
tab.DOM.querySelector("#title", function(err, node) {
console.log("got node:", node.tagName);
tab.DOM.getUsedFontFaces(node, function(err, fonts) {
for (var i in fonts) {
var font = fonts[i];
console.log("first font", font);
}
});
})
}) */
/**
{ fromFontGroup: true,
fromLanguagePrefs: false,
fromSystemFallback: false,
name: 'Georgia',
CSSFamilyName: 'Georgia',
rule: null,
srcIndex: -1,
URI: '',
localName: '',
format: '',
metadata: '' }
*/
/**
* Helper functions
*/
function loadUrl(url, callback) {
getFirstTab(function(tab) {
console.log("GOT TAB");
tab.navigateTo(url);
tab.once("navigate", function() {
console.log("NAVIGATED");
callback(tab);
});
});
}
function getFirstTab(callback) {
var client = new FirefoxClient({log: true});
client.connect(function() {
client.listTabs(function(err, tabs) {
if (err) throw err;
var tab = tabs[0];
// attach so we can receive load events
tab.attach(function(err) {
if (err) throw err;
callback(tab);
})
});
});
}