1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/components/places/tests/favicons/test_getFaviconURLForPage.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,52 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +/** 1.8 + * This file tests getFaviconURLForPage. 1.9 + */ 1.10 + 1.11 +//////////////////////////////////////////////////////////////////////////////// 1.12 +/// Tests 1.13 + 1.14 +function run_test() 1.15 +{ 1.16 + run_next_test(); 1.17 +} 1.18 + 1.19 +add_test(function test_normal() 1.20 +{ 1.21 + let pageURI = NetUtil.newURI("http://example.com/normal"); 1.22 + 1.23 + promiseAddVisits(pageURI).then(function () { 1.24 + PlacesUtils.favicons.setAndFetchFaviconForPage( 1.25 + pageURI, SMALLPNG_DATA_URI, true, 1.26 + PlacesUtils.favicons.FAVICON_LOAD_NON_PRIVATE, 1.27 + function () { 1.28 + PlacesUtils.favicons.getFaviconURLForPage(pageURI, 1.29 + function (aURI, aDataLen, aData, aMimeType) { 1.30 + do_check_true(aURI.equals(SMALLPNG_DATA_URI)); 1.31 + 1.32 + // Check also the expected data types. 1.33 + do_check_true(aDataLen === 0); 1.34 + do_check_true(aData.length === 0); 1.35 + do_check_true(aMimeType === ""); 1.36 + run_next_test(); 1.37 + }); 1.38 + }); 1.39 + }); 1.40 +}); 1.41 + 1.42 +add_test(function test_missing() 1.43 +{ 1.44 + let pageURI = NetUtil.newURI("http://example.com/missing"); 1.45 + 1.46 + PlacesUtils.favicons.getFaviconURLForPage(pageURI, 1.47 + function (aURI, aDataLen, aData, aMimeType) { 1.48 + // Check also the expected data types. 1.49 + do_check_true(aURI === null); 1.50 + do_check_true(aDataLen === 0); 1.51 + do_check_true(aData.length === 0); 1.52 + do_check_true(aMimeType === ""); 1.53 + run_next_test(); 1.54 + }); 1.55 +});