toolkit/components/search/tests/xpcshell/test_multipleIcons.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  * Tests getIcons() and getIconURLBySize() on engine with multiple icons.
     6  */
     8 "use strict";
    10 const Ci = Components.interfaces;
    11 const Cu = Components.utils;
    13 Cu.import("resource://testing-common/httpd.js");
    15   function test_multiIcon() {
    16   let engine = Services.search.getEngineByName("IconsTest");
    17   do_check_neq(engine, null);
    19   do_print("Running tests on IconsTest engine");
    21   do_print("The default should be the 16x16 icon");
    22   do_check_true(engine.iconURI.spec.contains("ico16"));
    24   do_check_true(engine.getIconURLBySize(32,32).contains("ico32"));
    25   do_check_true(engine.getIconURLBySize(74,74).contains("ico74"));
    27   do_print("Invalid dimensions should return null.");
    28   do_check_null(engine.getIconURLBySize(50,50));
    30   let allIcons = engine.getIcons();
    32   do_print("Check that allIcons contains expected icon sizes");
    33   do_check_eq(allIcons.length, 3);
    34   let expectedWidths = [16, 32, 74];
    35   do_check_true(allIcons.every((item) => {
    36     let width = item.width;
    37     do_check_neq(expectedWidths.indexOf(width), -1);
    38     do_check_eq(width, item.height);
    40     let icon = item.url.split(",").pop();
    41     do_check_eq(icon, "ico" + width);
    43     return true;
    44   }));
    46   do_test_finished();
    47 }
    49 function run_test() {
    50   removeMetadata();
    51   updateAppInfo();
    53   let httpServer = new HttpServer();
    54   httpServer.start(4444);
    55   httpServer.registerDirectory("/", do_get_cwd());
    57   do_register_cleanup(function cleanup() {
    58     httpServer.stop(function() {});
    59   });
    61   do_test_pending();
    63   let observer = function(aSubject, aTopic, aData) {
    64     if (aData == "engine-loaded") {
    65       test_multiIcon();
    66     }
    67   };
    69   Services.obs.addObserver(observer, "browser-search-engine-modified", false);
    71   do_print("Adding engine with multiple images");
    72   Services.search.addEngine("http://localhost:4444/data/engineImages.xml",
    73     Ci.nsISearchEngine.DATA_XML, null, false);
    75   do_timeout(12000, function() {
    76     do_throw("Timeout");
    77   });
    78 }

mercurial