Bug 1274685 - Part 2: Test case. r=francois.
authorHenry Chang <hchang@mozilla.com>
Thu, 02 Jun 2016 23:42:00 +0200
changeset 339337 30700073705df0f07177bc72e0d380504241e1ca
parent 339336 2df25135bcd35611c36666d69626a9e999f6a632
child 339338 86dca8a132b53174e19082ddad03ac806cb60f98
push id6249
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 13:59:36 +0000
treeherdermozilla-beta@bad9d4f5bf7e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfrancois
bugs1274685
milestone49.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1274685 - Part 2: Test case. r=francois.
toolkit/components/url-classifier/tests/unit/test_bug1274685_unowned_list.js
toolkit/components/url-classifier/tests/unit/xpcshell.ini
new file mode 100644
--- /dev/null
+++ b/toolkit/components/url-classifier/tests/unit/test_bug1274685_unowned_list.js
@@ -0,0 +1,32 @@
+Cu.import("resource://gre/modules/SafeBrowsing.jsm");
+Cu.import("resource://gre/modules/Services.jsm");
+Cu.import("resource://testing-common/AppInfo.jsm");
+
+// 'Cc["@mozilla.org/xre/app-info;1"]' for xpcshell has no nsIXULAppInfo
+// so that we have to update it to make nsURLFormatter.js happy.
+// (SafeBrowsing.init() will indirectly use nsURLFormatter.js)
+updateAppInfo();
+
+function run_test() {
+  SafeBrowsing.init();
+
+  let origList = Services.prefs.getCharPref("browser.safebrowsing.provider.google.lists");
+
+  // Remove 'goog-malware-shavar' from the original.
+  let trimmedList = origList.replace('goog-malware-shavar,', '');
+  Services.prefs.setCharPref("browser.safebrowsing.provider.google.lists", trimmedList);
+
+  try {
+    // Bug 1274685 - Unowned Safe Browsing tables break list updates
+    //
+    // If SafeBrowsing.registerTableWithURLs() doesn't check if
+    // a provider is found before registering table, an exception
+    // will be thrown while accessing a null object.
+    //
+    SafeBrowsing.registerTables();
+  } catch (e) {
+    ok(false, 'Exception thrown due to ' + e.toString());
+  }
+
+  Services.prefs.setCharPref("browser.safebrowsing.provider.google.lists", origList);
+}
--- a/toolkit/components/url-classifier/tests/unit/xpcshell.ini
+++ b/toolkit/components/url-classifier/tests/unit/xpcshell.ini
@@ -2,16 +2,17 @@
 head = head_urlclassifier.js
 tail = tail_urlclassifier.js
 skip-if = toolkit == 'android' || toolkit == 'gonk'
 support-files =
   data/digest1.chunk
   data/digest2.chunk
 
 [test_addsub.js]
+[test_bug1274685_unowned_list.js]
 [test_backoff.js]
 [test_dbservice.js]
 [test_hashcompleter.js]
 # Bug 752243: Profile cleanup frequently fails
 #skip-if = os == "mac" || os == "linux"
 [test_partial.js]
 [test_prefixset.js]
 [test_provider_url.js]