DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (777e60ca8853)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
<!DOCTYPE HTML>
<html>
<head>
  <title>Test the URI Classifier</title>
  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>

<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">

<script class="testbody" type="text/javascript">

var Cc = SpecialPowers.Cc;
var Ci = SpecialPowers.Ci;

// Add some URLs to the malware database.
var testData = "malware.example.com/";
var testUpdate =
  "n:1000\ni:test-malware-simple\nad:1\n" +
  "a:524:32:" + testData.length + "\n" +
  testData;

var dbService = Cc["@mozilla.org/url-classifier/dbservice;1"]
                .getService(Ci.nsIUrlClassifierDBService);

function doUpdate(update) {
  var listener = {
    QueryInterface: function(iid)
    {
      if (iid.equals(Ci.nsISupports) ||
          iid.equals(Ci.nsIUrlClassifierUpdateObserver))
        return this;

      throw Cr.NS_ERROR_NO_INTERFACE;
    },
    updateUrlRequested: function(url) { },
    streamFinished: function(status) { },
    updateError: function(errorCode) {
      ok(false, "Couldn't update classifier.");
      // Abort test.
      SimpleTest.finish();
    },
    updateSuccess: function(requestedTimeout) {
      SpecialPowers.pushPrefEnv(
        {"set" : [["browser.safebrowsing.malware.enabled", true]]},
        function loadTestFrame() {
          document.getElementById("testFrame").src = "classifierFrame.html";
        }
      );
    }
  };

  dbService.beginUpdate(listener, "test-malware-simple", "");
  dbService.beginStream("", "");
  dbService.updateStream(update);
  dbService.finishStream();
  dbService.finishUpdate();
}

SpecialPowers.pushPrefEnv(
  {"set" : [["urlclassifier.malware_table", "test-malware-simple"],
            ["urlclassifier.phish_table", "test-phish-simple"]]},
  function() { doUpdate(testUpdate); });

// Expected finish() call is in "classifierFrame.html".
SimpleTest.waitForExplicitFinish();

</script>

</pre>
<iframe id="testFrame" onload=""></iframe>
</body>
</html>