toolkit/components/places/tests/favicons/test_getFaviconURLForPage.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:c3cfe5174baf
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
3
4 /**
5 * This file tests getFaviconURLForPage.
6 */
7
8 ////////////////////////////////////////////////////////////////////////////////
9 /// Tests
10
11 function run_test()
12 {
13 run_next_test();
14 }
15
16 add_test(function test_normal()
17 {
18 let pageURI = NetUtil.newURI("http://example.com/normal");
19
20 promiseAddVisits(pageURI).then(function () {
21 PlacesUtils.favicons.setAndFetchFaviconForPage(
22 pageURI, SMALLPNG_DATA_URI, true,
23 PlacesUtils.favicons.FAVICON_LOAD_NON_PRIVATE,
24 function () {
25 PlacesUtils.favicons.getFaviconURLForPage(pageURI,
26 function (aURI, aDataLen, aData, aMimeType) {
27 do_check_true(aURI.equals(SMALLPNG_DATA_URI));
28
29 // Check also the expected data types.
30 do_check_true(aDataLen === 0);
31 do_check_true(aData.length === 0);
32 do_check_true(aMimeType === "");
33 run_next_test();
34 });
35 });
36 });
37 });
38
39 add_test(function test_missing()
40 {
41 let pageURI = NetUtil.newURI("http://example.com/missing");
42
43 PlacesUtils.favicons.getFaviconURLForPage(pageURI,
44 function (aURI, aDataLen, aData, aMimeType) {
45 // Check also the expected data types.
46 do_check_true(aURI === null);
47 do_check_true(aDataLen === 0);
48 do_check_true(aData.length === 0);
49 do_check_true(aMimeType === "");
50 run_next_test();
51 });
52 });

mercurial