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

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 /* Any copyright is dedicated to the Public Domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     4 /**
     5  * This file tests getFaviconDataForPage.
     6  */
     8 ////////////////////////////////////////////////////////////////////////////////
     9 /// Globals
    11 const FAVICON_URI = NetUtil.newURI(do_get_file("favicon-normal32.png"));
    12 const FAVICON_DATA = readFileData(do_get_file("favicon-normal32.png"));
    13 const FAVICON_MIMETYPE = "image/png";
    15 ////////////////////////////////////////////////////////////////////////////////
    16 /// Tests
    18 function run_test()
    19 {
    20   // Check that the favicon loaded correctly before starting the actual tests.
    21   do_check_eq(FAVICON_DATA.length, 344);
    22   run_next_test();
    23 }
    25 add_test(function test_normal()
    26 {
    27   let pageURI = NetUtil.newURI("http://example.com/normal");
    29   promiseAddVisits(pageURI).then(function () {
    30     PlacesUtils.favicons.setAndFetchFaviconForPage(
    31       pageURI, FAVICON_URI, true,
    32         PlacesUtils.favicons.FAVICON_LOAD_NON_PRIVATE,
    33         function () {
    34         PlacesUtils.favicons.getFaviconDataForPage(pageURI,
    35           function (aURI, aDataLen, aData, aMimeType) {
    36             do_check_true(aURI.equals(FAVICON_URI));
    37             do_check_eq(FAVICON_DATA.length, aDataLen);
    38             do_check_true(compareArrays(FAVICON_DATA, aData));
    39             do_check_eq(FAVICON_MIMETYPE, aMimeType);
    40             run_next_test();
    41           });
    42       });
    43   });
    44 });
    46 add_test(function test_missing()
    47 {
    48   let pageURI = NetUtil.newURI("http://example.com/missing");
    50   PlacesUtils.favicons.getFaviconDataForPage(pageURI,
    51     function (aURI, aDataLen, aData, aMimeType) {
    52       // Check also the expected data types.
    53       do_check_true(aURI === null);
    54       do_check_true(aDataLen === 0);
    55       do_check_true(aData.length === 0);
    56       do_check_true(aMimeType === "");
    57       run_next_test();
    58     });
    59 });

mercurial