toolkit/components/url-classifier/tests/mochitest/test_classifier.html

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 <!DOCTYPE HTML>
     2 <html>
     3 <head>
     4   <title>Test the URI Classifier</title>
     5   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     6   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
     7 </head>
     9 <p id="display"></p>
    10 <div id="content" style="display: none">
    11 </div>
    12 <pre id="test">
    14 <script class="testbody" type="text/javascript">
    16 var Cc = SpecialPowers.Cc;
    17 var Ci = SpecialPowers.Ci;
    19 // Add some URLs to the malware database.
    20 var testData = "malware.example.com/";
    21 var testUpdate =
    22   "n:1000\ni:test-malware-simple\nad:1\n" +
    23   "a:524:32:" + testData.length + "\n" +
    24   testData;
    26 var dbService = Cc["@mozilla.org/url-classifier/dbservice;1"]
    27                 .getService(Ci.nsIUrlClassifierDBService);
    29 function doUpdate(update) {
    30   var listener = {
    31     QueryInterface: function(iid)
    32     {
    33       if (iid.equals(Ci.nsISupports) ||
    34           iid.equals(Ci.nsIUrlClassifierUpdateObserver))
    35         return this;
    37       throw Cr.NS_ERROR_NO_INTERFACE;
    38     },
    39     updateUrlRequested: function(url) { },
    40     streamFinished: function(status) { },
    41     updateError: function(errorCode) {
    42       ok(false, "Couldn't update classifier.");
    43       // Abort test.
    44       SimpleTest.finish();
    45     },
    46     updateSuccess: function(requestedTimeout) {
    47       SpecialPowers.pushPrefEnv(
    48         {"set" : [["browser.safebrowsing.malware.enabled", true]]},
    49         function loadTestFrame() {
    50           document.getElementById("testFrame").src = "classifierFrame.html";
    51         }
    52       );
    53     }
    54   };
    56   dbService.beginUpdate(listener, "test-malware-simple", "");
    57   dbService.beginStream("", "");
    58   dbService.updateStream(update);
    59   dbService.finishStream();
    60   dbService.finishUpdate();
    61 }
    63 SpecialPowers.pushPrefEnv(
    64   {"set" : [["urlclassifier.malware_table", "test-malware-simple"],
    65             ["urlclassifier.phish_table", "test-phish-simple"]]},
    66   function() { doUpdate(testUpdate); });
    68 // Expected finish() call is in "classifierFrame.html".
    69 SimpleTest.waitForExplicitFinish();
    71 </script>
    73 </pre>
    74 <iframe id="testFrame" onload=""></iframe>
    75 </body>
    76 </html>

mercurial