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

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     1 /* Any copyright is dedicated to the Public Domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     4 /**
     5  * This file tests getFaviconURLForPage.
     6  */
     8 ////////////////////////////////////////////////////////////////////////////////
     9 /// Tests
    11 function run_test()
    12 {
    13   run_next_test();
    14 }
    16 add_test(function test_normal()
    17 {
    18   let pageURI = NetUtil.newURI("http://example.com/normal");
    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));
    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 });
    39 add_test(function test_missing()
    40 {
    41   let pageURI = NetUtil.newURI("http://example.com/missing");
    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