Bug 728174 - Replace old synchronous favicons calls in the bookmarks HTML import. r=mak
authorPaolo Amadini <paolo.mozmail@amadzone.org>
Thu, 12 Apr 2012 12:27:36 +0200
changeset 26418 2a6b78cf29293cb7f471e7bdc3eb93ae1718aec4
parent 26417 06f48f69a7496a6a56fcd03220761a2c920b3d41
child 26419 372cd2338fd1486d00dbaac072d202ac662fc73e
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
bugs728174
Bug 728174 - Replace old synchronous favicons calls in the bookmarks HTML import. 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
@@ -196,16 +196,36 @@ function readFileData(aFile) {
 function readFileOfLength(aFileName, aExpectedLength) {
   let data = readFileData(do_get_file(aFileName));
   do_check_eq(data.length, aExpectedLength);
   return data;
 }
 
 
 /**
+ * Returns the base64-encoded version of the given string.  This function is
+ * similar to window.btoa, but is available to xpcshell tests also.
+ *
+ * @param aString
+ *        Each character in this string corresponds to a byte, and must be a
+ *        code point in the range 0-255.
+ *
+ * @return The base64-encoded string.
+ */
+function base64EncodeString(aString) {
+  var stream = Cc["@mozilla.org/io/string-input-stream;1"]
+               .createInstance(Ci.nsIStringInputStream);
+  stream.setData(aString, aString.length);
+  var encoder = Cc["@mozilla.org/scriptablebase64encoder;1"]
+                .createInstance(Ci.nsIScriptableBase64Encoder);
+  return encoder.encodeToString(stream, aString.length);
+}
+
+
+/**
  * Compares two arrays, and returns true if they are equal.
  *
  * @param aArray1
  *        First array to compare.
  * @param aArray2
  *        Second array to compare.
  */
 function compareArrays(aArray1, aArray2) {