Bug 728143 - Replace old synchronous favicons calls in Places tests. r=mak
authorPaolo Amadini <paolo.mozmail@amadzone.org>
Mon, 19 Mar 2012 20:24:21 +0100
changeset 26413 18bdca83f0373277586500bf86aa1ab57aa98e75
parent 26412 eaf5c49552156b4db7ad25c1ae0b7e8de72d5be4
child 26414 402bd042872310b6cd5f943f3d631a8e17826cf7
push id1834
push userclokep@gmail.com
push dateMon, 23 Jan 2017 21:48:40 +0000
treeherdercomm-beta@293cffe83e59 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs728143
Bug 728143 - Replace old synchronous favicons calls in Places tests. r=mak
suite/common/places/tests/head_common.js
--- a/suite/common/places/tests/head_common.js
+++ b/suite/common/places/tests/head_common.js
@@ -46,20 +46,16 @@ const TRANSITION_LINK = Ci.nsINavHistory
 const TRANSITION_TYPED = Ci.nsINavHistoryService.TRANSITION_TYPED;
 const TRANSITION_BOOKMARK = Ci.nsINavHistoryService.TRANSITION_BOOKMARK;
 const TRANSITION_EMBED = Ci.nsINavHistoryService.TRANSITION_EMBED;
 const TRANSITION_FRAMED_LINK = Ci.nsINavHistoryService.TRANSITION_FRAMED_LINK;
 const TRANSITION_REDIRECT_PERMANENT = Ci.nsINavHistoryService.TRANSITION_REDIRECT_PERMANENT;
 const TRANSITION_REDIRECT_TEMPORARY = Ci.nsINavHistoryService.TRANSITION_REDIRECT_TEMPORARY;
 const TRANSITION_DOWNLOAD = Ci.nsINavHistoryService.TRANSITION_DOWNLOAD;
 
-// This error icon must stay in sync with FAVICON_ERRORPAGE_URL in
-// nsIFaviconService.idl, aboutCertError.xhtml and netError.xhtml.
-const FAVICON_ERRORPAGE_URL = "chrome://global/skin/icons/warning-16.png";
-
 const TITLE_LENGTH_MAX = 4096;
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 
 XPCOMUtils.defineLazyGetter(this, "Services", function() {
   Cu.import("resource://gre/modules/Services.jsm");
   return Services;
 });
@@ -70,16 +66,21 @@ XPCOMUtils.defineLazyGetter(this, "NetUt
 });
 
 XPCOMUtils.defineLazyGetter(this, "FileUtils", function() {
   Cu.import("resource://gre/modules/FileUtils.jsm");
   return FileUtils;
 });
 
 Cu.import("resource://gre/modules/PlacesUtils.jsm");
+XPCOMUtils.defineLazyGetter(this, "SMALLPNG_DATA_URI", function() {
+  return NetUtil.newURI(
+         "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAA" +
+         "AAAA6fptVAAAACklEQVQI12NgAAAAAgAB4iG8MwAAAABJRU5ErkJggg==");
+});
 
 function LOG(aMsg) {
   aMsg = ("*** PLACES TESTS: " + aMsg);
   Services.console.logStringMessage(aMsg);
   print(aMsg);
 }
 
 let gTestDir = do_get_cwd();
@@ -177,16 +178,32 @@ function readFileData(aFile) {
   let size  = inputStream.available();
   let bytes = readInputStreamData(inputStream);
   if (size != bytes.length) {
     throw "Didn't read expected number of bytes";
   }
   return bytes;
 }
 
+/**
+ * Reads the data from the named file, verifying the expected file length.
+ *
+ * @param aFileName
+ *        This file should be located in the same folder as the test.
+ * @param aExpectedLength
+ *        Expected length of the file.
+ *
+ * @return The array of bytes read from the file.
+ */
+function readFileOfLength(aFileName, aExpectedLength) {
+  let data = readFileData(do_get_file(aFileName));
+  do_check_eq(data.length, aExpectedLength);
+  return data;
+}
+
 
 /**
  * Compares two arrays, and returns true if they are equal.
  *
  * @param aArray1
  *        First array to compare.
  * @param aArray2
  *        Second array to compare.
@@ -816,8 +833,40 @@ NavHistoryObserver.prototype = {
   onDeleteURI: function () {},
   onClearHistory: function () {},
   onPageChanged: function () {},
   onDeleteVisits: function () {},
   QueryInterface: XPCOMUtils.generateQI([
     Ci.nsINavHistoryObserver,
   ])
 };
+
+/**
+ * Generic nsINavHistoryResultObserver that doesn't implement anything, but
+ * provides dummy methods to prevent errors about an object not having a certain
+ * method.
+ */
+function NavHistoryResultObserver() {}
+
+NavHistoryResultObserver.prototype = {
+  batching: function () {},
+  containerClosed: function () {},
+  containerOpened: function () {},
+  containerStateChanged: function () {},
+  invalidateContainer: function () {},
+  nodeAnnotationChanged: function () {},
+  nodeDateAddedChanged: function () {},
+  nodeHistoryDetailsChanged: function () {},
+  nodeIconChanged: function () {},
+  nodeInserted: function () {},
+  nodeKeywordChanged: function () {},
+  nodeLastModifiedChanged: function () {},
+  nodeMoved: function () {},
+  nodeRemoved: function () {},
+  nodeReplaced: function () {},
+  nodeTagsChanged: function () {},
+  nodeTitleChanged: function () {},
+  nodeURIChanged: function () {},
+  sortingChanged: function () {},
+  QueryInterface: XPCOMUtils.generateQI([
+    Ci.nsINavHistoryResultObserver,
+  ])
+};