summaryrefslogtreecommitdiffstats
path: root/toolkit/components/places/tests/favicons/test_getFaviconLinkForIcon.js
blob: e60a59bd8039d3566941b68cd69ca4202dfdb812 (plain)
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
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

/**
 * Test getFaviconLinkForIcon API.
 */

add_task(async function test_basic() {
  // Check these protocols are pass-through.
  for (let protocol of ["http://", "https://"]) {
    let url = PlacesUtils.favicons.getFaviconLinkForIcon(
      Services.io.newURI(protocol + "test/test.png")
    ).spec;
    Assert.equal(url, "cached-favicon:" + protocol + "test/test.png");
  }
});

add_task(async function test_directRequestProtocols() {
  // Check these protocols are pass-through.
  for (let protocol of [
    "about:",
    "cached-favicon:",
    "chrome://",
    "data:",
    "file:///",
    "moz-page-thumb://",
    "page-icon:",
    "resource://",
  ]) {
    let url = PlacesUtils.favicons.getFaviconLinkForIcon(
      Services.io.newURI(protocol + "test/test.png")
    ).spec;
    Assert.equal(url, protocol + "test/test.png");
  }
});