Bug 1343843 - Remove unused chrome://global/content/url-classifier/unittests.xul. r?flo draft
authorSteve Armand <stevea1@mac.com>
Fri, 01 Sep 2017 23:31:57 -0400
changeset 658000 5ce1a0bcdf684e293ef31d9ed1d8bd2394eb6d22
parent 657815 5278dfcf5eb9f58eaf06ad1ce67e7fd4aba34772
child 729561 f313f8c47ee50ebf3998b44799c44f7edff08092
push id77666
push userbmo:stevea1@mac.com
push dateSat, 02 Sep 2017 15:00:24 +0000
reviewersflo
bugs1343843
milestone57.0a1
Bug 1343843 - Remove unused chrome://global/content/url-classifier/unittests.xul. r?flo MozReview-Commit-ID: IMiDbyPu5n9
browser/base/content/test/static/browser_all_files_referenced.js
toolkit/components/url-classifier/tests/jar.mn
toolkit/components/url-classifier/tests/moz.build
toolkit/components/url-classifier/tests/unittests.xul
--- a/browser/base/content/test/static/browser_all_files_referenced.js
+++ b/browser/base/content/test/static/browser_all_files_referenced.js
@@ -128,18 +128,16 @@ var whitelist = [
   // Starting from here, files in the whitelist are bugs that need fixing.
   // Bug 1339424 (wontfix?)
   {file: "chrome://browser/locale/taskbar.properties",
    platforms: ["linux", "macosx"]},
   // Bug 1316187
   {file: "chrome://global/content/customizeToolbar.xul"},
   // Bug 1343837
   {file: "chrome://global/content/findUtils.js"},
-  // Bug 1343843
-  {file: "chrome://global/content/url-classifier/unittests.xul"},
   // Bug 1348362
   {file: "chrome://global/skin/icons/warning-64.png", platforms: ["linux", "win"]},
   // Bug 1348525
   {file: "chrome://global/skin/splitter/grip-bottom.gif", platforms: ["linux"]},
   {file: "chrome://global/skin/splitter/grip-left.gif", platforms: ["linux"]},
   {file: "chrome://global/skin/splitter/grip-right.gif", platforms: ["linux"]},
   {file: "chrome://global/skin/splitter/grip-top.gif", platforms: ["linux"]},
   // Bug 1348526
deleted file mode 100644
--- a/toolkit/components/url-classifier/tests/jar.mn
+++ /dev/null
@@ -1,2 +0,0 @@
-toolkit.jar:
-  content/global/url-classifier/unittests.xul         (unittests.xul)
--- a/toolkit/components/url-classifier/tests/moz.build
+++ b/toolkit/components/url-classifier/tests/moz.build
@@ -4,16 +4,14 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 MOCHITEST_MANIFESTS += ['mochitest/mochitest.ini']
 MOCHITEST_CHROME_MANIFESTS += ['mochitest/chrome.ini']
 XPCSHELL_TESTS_MANIFESTS += ['unit/xpcshell.ini']
 BROWSER_CHROME_MANIFESTS += ['browser/browser.ini']
 
-JAR_MANIFESTS += ['jar.mn']
-
 TESTING_JS_MODULES += [
     'UrlClassifierTestUtils.jsm',
 ]
 
 if CONFIG['ENABLE_TESTS']:
     DIRS += ['gtest']
deleted file mode 100644
--- a/toolkit/components/url-classifier/tests/unittests.xul
+++ /dev/null
@@ -1,188 +0,0 @@
-<?xml version="1.0"?>
-<window id="PROT_unittest"
-        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" 
-        onload="onProtUnittestLoad();"
-        title="prot unittests">
-
-<script><![CDATA[
-  const Cc = Components.classes;
-  const Ci = Components.interfaces;
-
-  function G_Debug(zone, s) {
-    var label = document.createElement('label');
-    var txt = "[" + zone + "] " + s;
-    label.appendChild(document.createTextNode(txt));
-
-    document.documentElement.appendChild(label);
-  }
-  
-  function G_Assert(zone, cond, msg) {
-    if (!cond) {
-      G_Debug(zone, msg);
-      throw msg;
-    }
-  }
-
-  function ProtectionTableTests() {
-    var z = "trtable UNITTEST";
-
-    G_Debug(z, "Starting");  
-
-    var url = "http://www.yahoo.com?foo=bar";
-    var url2 = "http://168.188.99.26/.secure/www.ebay.com/";
-    var urlTable = Cc['@mozilla.org/url-classifier/table;1?type=url']
-                     .createInstance(Ci.nsIUrlClassifierTable);
-    urlTable.insert(url, "1");
-    urlTable.insert(url2, "1");
-    G_Assert(z, urlTable.exists(url), "URL lookups broken");
-    G_Assert(z, !urlTable.exists("about:config"), "about:config breaks domlook");
-    G_Assert(z, urlTable.exists(url2), "URL lookups broken");
-    G_Assert(z, urlTable.exists("http://%31%36%38%2e%31%38%38%2e%39%39%2e%32%36/%2E%73%65%63%75%72%65/%77%77%77%2E%65%62%61%79%2E%63%6F%6D/") == true,
-             "URL Canonicalization broken");
-    G_Assert(z, urlTable.count == 2, 'urlTable: wrong size');
-
-    var dom1 = "bar.com";
-    var dom2 = "amazon.co.uk";
-    var dom3 = "127.0.0.1";
-    var domainTable = Cc['@mozilla.org/url-classifier/table;1?type=domain']
-                        .createInstance(Ci.nsIUrlClassifierTable);
-    domainTable.insert(dom1, "1");
-    domainTable.insert(dom2, "1");
-    domainTable.insert(dom3, "1");
-    G_Assert(z, domainTable.exists("http://www.bar.com/?zaz=asdf#url"),
-             "Domain lookups broken (single dot)");
-    G_Assert(z, domainTable.exists("http://www.amazon.co.uk/?z=af#url"),
-             "Domain lookups broken (two dots)");
-    G_Assert(z, domainTable.exists("http://127.0.0.1/?z=af#url"),
-             "Domain lookups broken (IP)");
-    G_Assert(z, domainTable.count == 3, 'domainTable: wrong size');
-
-    var site1 = "google.com/safebrowsing/";
-    var site2 = "www.foo.bar/";
-    var site3 = "127.0.0.1/";
-    var siteTable = Cc['@mozilla.org/url-classifier/table;1?type=site']
-                      .createInstance(Ci.nsIUrlClassifierTable);
-    siteTable.insert(site1, "1");
-    siteTable.insert(site2, "1");
-    siteTable.insert(site3, "1");
-    G_Assert(z, siteTable.exists("http://www.google.com/safebrowsing/1.php"),
-             "Site lookups broken - reducing");
-    G_Assert(z, siteTable.exists("http://www.foo.bar/some/random/path"),
-             "Site lookups broken - fqdn");
-    G_Assert(z, siteTable.exists("http://127.0.0.1/something?hello=1"),
-             "Site lookups broken - IP");
-    G_Assert(z, !siteTable.exists("http://www.google.com/search/"),
-             "Site lookups broken - overreaching");
-    G_Assert(z, siteTable.count == 3, 'siteTable: wrong size');
-
-    var url1 = "http://poseidon.marinet.gr/~eleni/eBay/index.php";
-    var domainHash = "01844755C8143C4579BB28DD59C23747";
-    var enchashTable = Cc['@mozilla.org/url-classifier/table;1?type=enchash']
-                         .createInstance(Ci.nsIUrlClassifierTable);
-    enchashTable.insert(domainHash, "bGtEQWJuMl9FA3Kl5RiXMpgFU8nDJl9J0hXjUck9+"
-                                    + "mMUQwAN6llf0gJeY5DIPPc2f+a8MSBFJN17ANGJ"
-                                    + "Zl5oZVsQfSW4i12rlScsx4tweZAE");
-    G_Assert(z, enchashTable.exists(url1), 'enchash lookup failed');
-    G_Assert(z, !enchashTable.exists(url1 + '/foo'),
-             "enchash lookup broken - overreaching");
-    G_Assert(z, enchashTable.count == 1, 'enchashTable: wrong size');
-
-    // TODO: test replace
-    G_Debug(z, "PASSED");
-  }
-  
-  function ProtectionListManagerTests() {
-    var z = "listmanager UNITTEST";
-    G_Debug(z, "Starting");
-
-    // test lookup and register
-    var listManagerInst = Cc["@mozilla.org/url-classifier/listmanager;1"]
-                            .createInstance(Ci.nsIUrlListManager);
-    var listName = 'foo-bar-url';
-    listManagerInst.registerTable(listName, false);
-    listManagerInst.safeInsert(listName, 'test', '1');
-    G_Assert(z, listManagerInst.safeExists(listName, 'test'),
-                'insert/exist failed');
-
-    // test serialization
-    var baseName = (new Date().getTime()) + ".tmp";
-    var tempDir = Cc["@mozilla.org/file/directory_service;1"]
-                  .getService(Ci.nsIProperties)
-                  .get("TmpD", Ci.nsIFile);
-    tempDir.append(baseName);
-    tempDir.createUnique(tempDir.DIRECTORY_TYPE, 0744);
-
-    var listManager = Cc["@mozilla.org/url-classifier/listmanager;1"]
-                        .getService(Ci.nsIUrlListManager);
-    listManager.setAppDir(tempDir);
-    
-    var data = "";
-
-    var set1Name = "test1-foo-domain";
-    data += "[" + set1Name + " 1.2]\n";
-    var set1 = {};
-    for (var i = 0; i < 10; i++) {
-      set1["http://" + i + ".com"] = 1;
-      data += "+" + i + ".com\t1\n";
-    }
-
-    data += "\n";
-    var set2Name = "test2-foo-domain";
-    // TODO must have blank line
-    data += "\n[" + set2Name + " 1.7]\n";
-    var set2 = {};
-    for (var i = 0; i < 5; i++) {
-      set2["http://" + i + ".com"] = 1;
-      data += "+" + i + ".com\t1\n";
-    }
-
-    function deserialized(tablesKnown, tablesData) {
-      listManager.wrappedJSObject.dataReady(tablesKnown, tablesData);
-
-      var file = tempDir.clone();
-      file.append(set1Name + ".sst");
-      G_Assert(z, file.exists() && file.isFile() && file.isReadable(), 
-               "Failed to write out: " + file.path);
-      
-      file = tempDir.clone();
-      file.append(set2Name + ".sst");
-      G_Assert(z, file.exists() && file.isFile() && file.isReadable(), 
-               "Failed to write out: " + file.path);
-      
-      // now try to read them back from disk
-      listManager = Cc["@mozilla.org/url-classifier/listmanager;1"]
-                       .createInstance(Ci.nsIUrlListManager);
-      listManager.setAppDir(tempDir);
-      var tables = [ set1Name, set2Name ];
-      listManager.enableUpdate(set1Name);
-      listManager.enableUpdate(set2Name);
-      listManager.wrappedJSObject.readDataFiles();
-      
-      // assert that the values match
-      for (var prop in set1) {
-        G_Assert(z, 
-                 listManager.wrappedJSObject.tablesData[set1Name].exists(prop), 
-                 "Couldn't find member " + prop + "of set1 from disk.");
-      }
-      
-      for (var prop in set2) {
-        G_Assert(z,
-                 listManager.wrappedJSObject.tablesData[set2Name].exists(prop), 
-                 "Couldn't find member " + prop + "of set2 from disk.");
-      }
-
-      tempDir.remove(true);
-      
-      G_Debug(z, "PASSED");
-    };
-
-    // Use the unwrapped object for the unittest
-    listManager.wrappedJSObject.deserialize_(data, deserialized);
-  }
-
-  function onProtUnittestLoad() {
-    ProtectionTableTests();
-    ProtectionListManagerTests();
-  }
-]]></script>
-</window>