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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
import { GlobalOverrider } from "test/unit/utils";
import { TippyTopProvider } from "lib/TippyTopProvider.sys.mjs";
describe("TippyTopProvider", () => {
let instance;
let globals;
beforeEach(async () => {
globals = new GlobalOverrider();
let fetchStub = globals.sandbox.stub();
globals.set("fetch", fetchStub);
fetchStub.resolves({
ok: true,
status: 200,
json: () =>
Promise.resolve([
{
domains: ["facebook.com"],
image_url: "images/facebook-com.png",
favicon_url: "images/facebook-com.png",
background_color: "#3b5998",
},
{
domains: ["gmail.com", "mail.google.com"],
image_url: "images/gmail-com.png",
favicon_url: "images/gmail-com.png",
background_color: "#000000",
},
]),
});
instance = new TippyTopProvider();
await instance.init();
});
it("should provide an icon for facebook.com", () => {
const site = instance.processSite({ url: "https://facebook.com" });
assert.equal(
site.tippyTopIcon,
"chrome://activity-stream/content/data/content/tippytop/images/facebook-com.png"
);
assert.equal(
site.smallFavicon,
"chrome://activity-stream/content/data/content/tippytop/images/facebook-com.png"
);
assert.equal(site.backgroundColor, "#3b5998");
});
it("should provide an icon for www.facebook.com", () => {
const site = instance.processSite({ url: "https://www.facebook.com" });
assert.equal(
site.tippyTopIcon,
"chrome://activity-stream/content/data/content/tippytop/images/facebook-com.png"
);
assert.equal(
site.smallFavicon,
"chrome://activity-stream/content/data/content/tippytop/images/facebook-com.png"
);
assert.equal(site.backgroundColor, "#3b5998");
});
it("should not provide an icon for other.facebook.com", () => {
const site = instance.processSite({ url: "https://other.facebook.com" });
assert.isUndefined(site.tippyTopIcon);
});
it("should provide an icon for other.facebook.com with stripping", () => {
const site = instance.processSite(
{ url: "https://other.facebook.com" },
"*"
);
assert.equal(
site.tippyTopIcon,
"chrome://activity-stream/content/data/content/tippytop/images/facebook-com.png"
);
});
it("should provide an icon for facebook.com/foobar", () => {
const site = instance.processSite({ url: "https://facebook.com/foobar" });
assert.equal(
site.tippyTopIcon,
"chrome://activity-stream/content/data/content/tippytop/images/facebook-com.png"
);
assert.equal(
site.smallFavicon,
"chrome://activity-stream/content/data/content/tippytop/images/facebook-com.png"
);
assert.equal(site.backgroundColor, "#3b5998");
});
it("should provide an icon for gmail.com", () => {
const site = instance.processSite({ url: "https://gmail.com" });
assert.equal(
site.tippyTopIcon,
"chrome://activity-stream/content/data/content/tippytop/images/gmail-com.png"
);
assert.equal(
site.smallFavicon,
"chrome://activity-stream/content/data/content/tippytop/images/gmail-com.png"
);
assert.equal(site.backgroundColor, "#000000");
});
it("should provide an icon for mail.google.com", () => {
const site = instance.processSite({ url: "https://mail.google.com" });
assert.equal(
site.tippyTopIcon,
"chrome://activity-stream/content/data/content/tippytop/images/gmail-com.png"
);
assert.equal(
site.smallFavicon,
"chrome://activity-stream/content/data/content/tippytop/images/gmail-com.png"
);
assert.equal(site.backgroundColor, "#000000");
});
it("should handle garbage URLs gracefully", () => {
const site = instance.processSite({ url: "garbagejlfkdsa" });
assert.isUndefined(site.tippyTopIcon);
assert.isUndefined(site.backgroundColor);
});
it("should handle error when fetching and parsing manifest", async () => {
globals = new GlobalOverrider();
let fetchStub = globals.sandbox.stub();
globals.set("fetch", fetchStub);
fetchStub.rejects("whaaaa");
instance = new TippyTopProvider();
await instance.init();
instance.processSite({ url: "https://facebook.com" });
});
});
|