toolkit/components/search/tests/xpcshell/test_rel_searchform.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 that <Url rel="searchform"/> is properly recognized as a searchForm.
     6  */
     8 "use strict";
    10 const Ci = Components.interfaces;
    12 Components.utils.import("resource://testing-common/httpd.js");
    14 let engines = [
    15   "engine-rel-searchform.xml",
    16   "engine-rel-searchform-post.xml",
    17 ];
    19 function search_observer(aSubject, aTopic, aData) {
    20   let engine = aSubject.QueryInterface(Ci.nsISearchEngine);
    21   do_print("Observer: " + aData + " for " + engine.name);
    23   if (aData != "engine-added")
    24     return;
    26   let idx = engines.indexOf(engine.name);
    27   if (idx < 0)
    28     // The engine is some other engine unrelated to the test, so ignore it.
    29     return;
    31   // The final searchForm of the engine should be a URL whose domain is the
    32   // <ShortName> in the engine's XML and that has a ?search parameter.  The
    33   // point of the ?search parameter is to avoid accidentally matching the value
    34   // returned as a last resort by Engine's searchForm getter, which is simply
    35   // the prePath of the engine's first HTML <Url>.
    36   do_check_eq(engine.searchForm, "http://" + engine.name + "/?search");
    38   engines.splice(idx, 1);
    39   if (!engines.length)
    40     do_test_finished();
    41 }
    43 function run_test() {
    44   removeMetadata();
    45   updateAppInfo();
    47   let httpServer = new HttpServer();
    48   httpServer.start(-1);
    49   httpServer.registerDirectory("/", do_get_cwd());
    51   do_register_cleanup(function cleanup() {
    52     httpServer.stop(function() {});
    53     Services.obs.removeObserver(search_observer, "browser-search-engine-modified");
    54   });
    56   do_test_pending();
    57   Services.obs.addObserver(search_observer, "browser-search-engine-modified", false);
    59   for (let basename of engines) {
    60     Services.search.addEngine("http://localhost:" +
    61                               httpServer.identity.primaryPort +
    62                               "/data/" + basename,
    63                               Ci.nsISearchEngine.DATA_XML,
    64                               null, false);
    65   }
    66 }

mercurial