Bug 1416094 - Test draft
authorDimiL <dlee@mozilla.com>
Tue, 19 Dec 2017 15:33:56 +0800
changeset 712940 fe28ce53f03dd1b3b8d318e9143ab037c038d566
parent 712870 7c4579e705c4a3a3610183fe6f44affff3ad57ef
child 744204 51673d6a128f640be475d7b629e13756672a516b
push id93502
push userbmo:dlee@mozilla.com
push dateTue, 19 Dec 2017 07:34:33 +0000
bugs1416094
milestone59.0a1
Bug 1416094 - Test MozReview-Commit-ID: 8YoZwxiLWoH
toolkit/components/url-classifier/tests/mochitest/test_threathit_report.html
toolkit/components/url-classifier/tests/unit/test_hashcompleter_v4.js
--- a/toolkit/components/url-classifier/tests/mochitest/test_threathit_report.html
+++ b/toolkit/components/url-classifier/tests/mochitest/test_threathit_report.html
@@ -132,17 +132,17 @@ function checkResults(aTestdata, aExpect
   let url = "http://" + SJS + "?" + params.toString();
 
   xhr.open("GET", url, true);
   xhr.setRequestHeader("Content-Type", "text/plain");
   xhr.send();
 }
 
 function waitForUpdate(data) {
-  listmanager.checkForUpdates(data.updateUrl);
+  listmanager.forceUpdates(data.list);
   return new Promise(resolve => {
     Services.obs.addObserver(function observer(aSubject, aTopic) {
       Services.obs.removeObserver(observer, aTopic);
       resolve();
     }, "safebrowsing-update-finished");
   });
 }
 
--- a/toolkit/components/url-classifier/tests/unit/test_hashcompleter_v4.js
+++ b/toolkit/components/url-classifier/tests/unit/test_hashcompleter_v4.js
@@ -1,19 +1,18 @@
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 
 // These tables have a different update URL (for v4).
 const TEST_TABLE_DATA_V4 = {
   tableName: "test-phish-proto",
-  providerName: "google4",
+  providerName: "test",
   updateUrl: "http://localhost:5555/safebrowsing/update?",
   gethashUrl: "http://localhost:5555/safebrowsing/gethash-v4?",
 };
 
-const PREF_NEXTUPDATETIME_V4 = "browser.safebrowsing.provider.google4.nextupdatetime";
 const GETHASH_PATH = "/safebrowsing/gethash-v4";
 
 // The protobuf binary represention of gethash response:
 // minimumWaitDuration : 12 secs 10 nanosecs
 // negativeCacheDuration : 120 secs 9 nanosecs
 //
 // { CompleteHash, ThreatType, CacheDuration { secs, nanos } };
 // { nsCString("01234567890123456789012345678901"), SOCIAL_ENGINEERING_PUBLIC, { 8, 500 } },
@@ -66,22 +65,22 @@ gListManager.registerTable(TEST_TABLE_DA
                            TEST_TABLE_DATA_V4.updateUrl,
                            TEST_TABLE_DATA_V4.gethashUrl);
 
 // This is unfortunately needed since v4 gethash request
 // requires the threat type (table name) as well as the
 // state it's associated with. We have to run the update once
 // to have the state written.
 add_test(function test_update_v4() {
-  gListManager.disableUpdate(TEST_TABLE_DATA_V4.tableName);
-  gListManager.enableUpdate(TEST_TABLE_DATA_V4.tableName);
-
   // Force table update.
-  Services.prefs.setCharPref(PREF_NEXTUPDATETIME_V4, "1");
-  gListManager.maybeToggleUpdateChecking();
+  gListManager.forceUpdates(TEST_TABLE_DATA_V4.tableName);
+  Services.obs.addObserver(function observer(aSubject, aTopic) {
+    Services.obs.removeObserver(observer, aTopic);
+      run_next_test();
+  }, "safebrowsing-update-finished");
 });
 
 add_test(function test_getHashRequestV4() {
   let request = gUrlUtil.makeFindFullHashRequestV4([TEST_TABLE_DATA_V4.tableName],
                                                    [btoa(NEW_CLIENT_STATE)],
                                                    [btoa("0123"), btoa("1234567"), btoa("1111")].sort(),
                                                    1,
                                                    3);