Merge inbound to central, a=merge
authorWes Kocher <wkocher@mozilla.com>
Wed, 30 Nov 2016 16:12:21 -0800
changeset 372078 27449c736a04eec8c9033d70697747fce3a3c13d
parent 372052 8f1e420699832d42753c6503aa31861be6f5b186 (current diff)
parent 372077 25a53a6b7aa16f57825487dbaa17302ab1a4fb21 (diff)
child 372124 a183d5c5a8f79b09be159329992ef958a55f23ed
child 372131 5245a7806885597b14805c900f41dc87dac990d7
child 372195 35fb04df942944c17756b4ed86fc61879da01ab6
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmerge
milestone53.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
Merge inbound to central, a=merge
netwerk/streamconv/test/Converters.cpp
netwerk/streamconv/test/Converters.h
netwerk/streamconv/test/TestStreamConv.cpp
netwerk/streamconv/test/moz.build
netwerk/test/PropertiesTest.cpp
netwerk/test/ReadNTLM.cpp
netwerk/test/TestBlockingSocket.cpp
netwerk/test/TestDNS.cpp
netwerk/test/TestIDN.cpp
netwerk/test/TestIOThreads.cpp
netwerk/test/TestIncrementalDownload.cpp
netwerk/test/TestOpen.cpp
netwerk/test/TestProtocols.cpp
netwerk/test/TestServ.cpp
netwerk/test/TestSocketTransport.cpp
netwerk/test/TestStreamLoader.cpp
netwerk/test/TestStreamPump.cpp
netwerk/test/TestStreamTransport.cpp
netwerk/test/TestUDPSocketProvider.cpp
netwerk/test/TestURLParser.cpp
netwerk/test/TestUpload.cpp
netwerk/test/urltest.cpp
old-configure.in
testing/mozharness/configs/builds/taskcluster_firefox_win32_debug.py
testing/mozharness/configs/builds/taskcluster_firefox_win32_opt.py
testing/mozharness/configs/builds/taskcluster_firefox_win64_debug.py
testing/mozharness/configs/builds/taskcluster_firefox_win64_opt.py
--- a/browser/extensions/pdfjs/README.mozilla
+++ b/browser/extensions/pdfjs/README.mozilla
@@ -1,3 +1,3 @@
 This is the pdf.js project output, https://github.com/mozilla/pdf.js
 
-Current extension version is: 1.6.329
+Current extension version is: 1.6.355
--- a/browser/extensions/pdfjs/content/build/pdf.js
+++ b/browser/extensions/pdfjs/content/build/pdf.js
@@ -18,18 +18,18 @@
   define('pdfjs-dist/build/pdf', ['exports'], factory);
  } else if (typeof exports !== 'undefined') {
   factory(exports);
  } else {
   factory(root['pdfjsDistBuildPdf'] = {});
  }
 }(this, function (exports) {
  'use strict';
- var pdfjsVersion = '1.6.329';
- var pdfjsBuild = '9c3419d';
+ var pdfjsVersion = '1.6.355';
+ var pdfjsBuild = '451956c';
  var pdfjsFilePath = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : null;
  var pdfjsLibs = {};
  (function pdfjsWrapper() {
   (function (root, factory) {
    factory(root.pdfjsSharedUtil = {});
   }(this, function (exports) {
    var globalScope = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : this;
    var FONT_IDENTITY_MATRIX = [
@@ -4748,17 +4748,17 @@
        current.fontDirection = 1;
       }
       this.current.font = fontObj;
       this.current.fontSize = size;
       if (fontObj.isType3Font) {
        return;
       }
       var name = fontObj.loadedName || 'sans-serif';
-      var bold = fontObj.black ? fontObj.bold ? '900' : 'bold' : fontObj.bold ? 'bold' : 'normal';
+      var bold = fontObj.black ? '900' : fontObj.bold ? 'bold' : 'normal';
       var italic = fontObj.italic ? 'italic' : 'normal';
       var typeface = '"' + name + '", ' + fontObj.fallbackName;
       var browserFontSize = size < MIN_FONT_SIZE ? MIN_FONT_SIZE : size > MAX_FONT_SIZE ? MAX_FONT_SIZE : size;
       this.current.fontSizeScale = size / browserFontSize;
       var rule = italic + ' ' + bold + ' ' + browserFontSize + 'px ' + typeface;
       this.ctx.font = rule;
      },
      setTextRenderingMode: function CanvasGraphics_setTextRenderingMode(mode) {
@@ -5838,16 +5838,19 @@
       return this.pageIndex + 1;
      },
      get rotate() {
       return this.pageInfo.rotate;
      },
      get ref() {
       return this.pageInfo.ref;
      },
+     get userUnit() {
+      return this.pageInfo.userUnit;
+     },
      get view() {
       return this.pageInfo.view;
      },
      getViewport: function PDFPageProxy_getViewport(scale, rotate) {
       if (arguments.length < 2) {
        rotate = this.rotate;
       }
       return new PageViewport(this.view, scale, rotate, 0, 0);
--- a/browser/extensions/pdfjs/content/build/pdf.worker.js
+++ b/browser/extensions/pdfjs/content/build/pdf.worker.js
@@ -18,18 +18,18 @@
   define('pdfjs-dist/build/pdf.worker', ['exports'], factory);
  } else if (typeof exports !== 'undefined') {
   factory(exports);
  } else {
   factory(root['pdfjsDistBuildPdfWorker'] = {});
  }
 }(this, function (exports) {
  'use strict';
- var pdfjsVersion = '1.6.329';
- var pdfjsBuild = '9c3419d';
+ var pdfjsVersion = '1.6.355';
+ var pdfjsBuild = '451956c';
  var pdfjsFilePath = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : null;
  var pdfjsLibs = {};
  (function pdfjsWrapper() {
   (function (root, factory) {
    factory(root.pdfjsCoreArithmeticDecoder = {});
   }(this, function (exports) {
    var ArithmeticDecoder = function ArithmeticDecoderClosure() {
     var QeTable = [
@@ -404,761 +404,16 @@
       return d;
      }
     };
     return ArithmeticDecoder;
    }();
    exports.ArithmeticDecoder = ArithmeticDecoder;
   }));
   (function (root, factory) {
-   factory(root.pdfjsCoreBidi = {});
-  }(this, function (exports) {
-   var baseTypes = [
-    'BN',
-    'BN',
-    'BN',
-    'BN',
-    'BN',
-    'BN',
-    'BN',
-    'BN',
-    'BN',
-    'S',
-    'B',
-    'S',
-    'WS',
-    'B',
-    'BN',
-    'BN',
-    'BN',
-    'BN',
-    'BN',
-    'BN',
-    'BN',
-    'BN',
-    'BN',
-    'BN',
-    'BN',
-    'BN',
-    'BN',
-    'BN',
-    'B',
-    'B',
-    'B',
-    'S',
-    'WS',
-    'ON',
-    'ON',
-    'ET',
-    'ET',
-    'ET',
-    'ON',
-    'ON',
-    'ON',
-    'ON',
-    'ON',
-    'ON',
-    'CS',
-    'ON',
-    'CS',
-    'ON',
-    'EN',
-    'EN',
-    'EN',
-    'EN',
-    'EN',
-    'EN',
-    'EN',
-    'EN',
-    'EN',
-    'EN',
-    'ON',
-    'ON',
-    'ON',
-    'ON',
-    'ON',
-    'ON',
-    'ON',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'ON',
-    'ON',
-    'ON',
-    'ON',
-    'ON',
-    'ON',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'ON',
-    'ON',
-    'ON',
-    'ON',
-    'BN',
-    'BN',
-    'BN',
-    'BN',
-    'BN',
-    'BN',
-    'B',
-    'BN',
-    'BN',
-    'BN',
-    'BN',
-    'BN',
-    'BN',
-    'BN',
-    'BN',
-    'BN',
-    'BN',
-    'BN',
-    'BN',
-    'BN',
-    'BN',
-    'BN',
-    'BN',
-    'BN',
-    'BN',
-    'BN',
-    'BN',
-    'BN',
-    'BN',
-    'BN',
-    'BN',
-    'BN',
-    'BN',
-    'CS',
-    'ON',
-    'ET',
-    'ET',
-    'ET',
-    'ET',
-    'ON',
-    'ON',
-    'ON',
-    'ON',
-    'L',
-    'ON',
-    'ON',
-    'ON',
-    'ON',
-    'ON',
-    'ET',
-    'ET',
-    'EN',
-    'EN',
-    'ON',
-    'L',
-    'ON',
-    'ON',
-    'ON',
-    'EN',
-    'L',
-    'ON',
-    'ON',
-    'ON',
-    'ON',
-    'ON',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'ON',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'ON',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L',
-    'L'
-   ];
-   var arabicTypes = [
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'CS',
-    'AL',
-    'ON',
-    'ON',
-    'NSM',
-    'NSM',
-    'NSM',
-    'NSM',
-    'NSM',
-    'NSM',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'NSM',
-    'NSM',
-    'NSM',
-    'NSM',
-    'NSM',
-    'NSM',
-    'NSM',
-    'NSM',
-    'NSM',
-    'NSM',
-    'NSM',
-    'NSM',
-    'NSM',
-    'NSM',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AN',
-    'AN',
-    'AN',
-    'AN',
-    'AN',
-    'AN',
-    'AN',
-    'AN',
-    'AN',
-    'AN',
-    'ET',
-    'AN',
-    'AN',
-    'AL',
-    'AL',
-    'AL',
-    'NSM',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'NSM',
-    'NSM',
-    'NSM',
-    'NSM',
-    'NSM',
-    'NSM',
-    'NSM',
-    'NSM',
-    'NSM',
-    'NSM',
-    'NSM',
-    'NSM',
-    'NSM',
-    'NSM',
-    'NSM',
-    'NSM',
-    'NSM',
-    'NSM',
-    'NSM',
-    'ON',
-    'NSM',
-    'NSM',
-    'NSM',
-    'NSM',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL',
-    'AL'
-   ];
-   function isOdd(i) {
-    return (i & 1) !== 0;
-   }
-   function isEven(i) {
-    return (i & 1) === 0;
-   }
-   function findUnequal(arr, start, value) {
-    for (var j = start, jj = arr.length; j < jj; ++j) {
-     if (arr[j] !== value) {
-      return j;
-     }
-    }
-    return j;
-   }
-   function setValues(arr, start, end, value) {
-    for (var j = start; j < end; ++j) {
-     arr[j] = value;
-    }
-   }
-   function reverseValues(arr, start, end) {
-    for (var i = start, j = end - 1; i < j; ++i, --j) {
-     var temp = arr[i];
-     arr[i] = arr[j];
-     arr[j] = temp;
-    }
-   }
-   function createBidiText(str, isLTR, vertical) {
-    return {
-     str: str,
-     dir: vertical ? 'ttb' : isLTR ? 'ltr' : 'rtl'
-    };
-   }
-   var chars = [];
-   var types = [];
-   function bidi(str, startLevel, vertical) {
-    var isLTR = true;
-    var strLength = str.length;
-    if (strLength === 0 || vertical) {
-     return createBidiText(str, isLTR, vertical);
-    }
-    chars.length = strLength;
-    types.length = strLength;
-    var numBidi = 0;
-    var i, ii;
-    for (i = 0; i < strLength; ++i) {
-     chars[i] = str.charAt(i);
-     var charCode = str.charCodeAt(i);
-     var charType = 'L';
-     if (charCode <= 0x00ff) {
-      charType = baseTypes[charCode];
-     } else if (0x0590 <= charCode && charCode <= 0x05f4) {
-      charType = 'R';
-     } else if (0x0600 <= charCode && charCode <= 0x06ff) {
-      charType = arabicTypes[charCode & 0xff];
-     } else if (0x0700 <= charCode && charCode <= 0x08AC) {
-      charType = 'AL';
-     }
-     if (charType === 'R' || charType === 'AL' || charType === 'AN') {
-      numBidi++;
-     }
-     types[i] = charType;
-    }
-    if (numBidi === 0) {
-     isLTR = true;
-     return createBidiText(str, isLTR);
-    }
-    if (startLevel === -1) {
-     if (strLength / numBidi < 0.3) {
-      isLTR = true;
-      startLevel = 0;
-     } else {
-      isLTR = false;
-      startLevel = 1;
-     }
-    }
-    var levels = [];
-    for (i = 0; i < strLength; ++i) {
-     levels[i] = startLevel;
-    }
-    var e = isOdd(startLevel) ? 'R' : 'L';
-    var sor = e;
-    var eor = sor;
-    var lastType = sor;
-    for (i = 0; i < strLength; ++i) {
-     if (types[i] === 'NSM') {
-      types[i] = lastType;
-     } else {
-      lastType = types[i];
-     }
-    }
-    lastType = sor;
-    var t;
-    for (i = 0; i < strLength; ++i) {
-     t = types[i];
-     if (t === 'EN') {
-      types[i] = lastType === 'AL' ? 'AN' : 'EN';
-     } else if (t === 'R' || t === 'L' || t === 'AL') {
-      lastType = t;
-     }
-    }
-    for (i = 0; i < strLength; ++i) {
-     t = types[i];
-     if (t === 'AL') {
-      types[i] = 'R';
-     }
-    }
-    for (i = 1; i < strLength - 1; ++i) {
-     if (types[i] === 'ES' && types[i - 1] === 'EN' && types[i + 1] === 'EN') {
-      types[i] = 'EN';
-     }
-     if (types[i] === 'CS' && (types[i - 1] === 'EN' || types[i - 1] === 'AN') && types[i + 1] === types[i - 1]) {
-      types[i] = types[i - 1];
-     }
-    }
-    for (i = 0; i < strLength; ++i) {
-     if (types[i] === 'EN') {
-      var j;
-      for (j = i - 1; j >= 0; --j) {
-       if (types[j] !== 'ET') {
-        break;
-       }
-       types[j] = 'EN';
-      }
-      for (j = i + 1; j < strLength; ++j) {
-       if (types[j] !== 'ET') {
-        break;
-       }
-       types[j] = 'EN';
-      }
-     }
-    }
-    for (i = 0; i < strLength; ++i) {
-     t = types[i];
-     if (t === 'WS' || t === 'ES' || t === 'ET' || t === 'CS') {
-      types[i] = 'ON';
-     }
-    }
-    lastType = sor;
-    for (i = 0; i < strLength; ++i) {
-     t = types[i];
-     if (t === 'EN') {
-      types[i] = lastType === 'L' ? 'L' : 'EN';
-     } else if (t === 'R' || t === 'L') {
-      lastType = t;
-     }
-    }
-    for (i = 0; i < strLength; ++i) {
-     if (types[i] === 'ON') {
-      var end = findUnequal(types, i + 1, 'ON');
-      var before = sor;
-      if (i > 0) {
-       before = types[i - 1];
-      }
-      var after = eor;
-      if (end + 1 < strLength) {
-       after = types[end + 1];
-      }
-      if (before !== 'L') {
-       before = 'R';
-      }
-      if (after !== 'L') {
-       after = 'R';
-      }
-      if (before === after) {
-       setValues(types, i, end, before);
-      }
-      i = end - 1;
-     }
-    }
-    for (i = 0; i < strLength; ++i) {
-     if (types[i] === 'ON') {
-      types[i] = e;
-     }
-    }
-    for (i = 0; i < strLength; ++i) {
-     t = types[i];
-     if (isEven(levels[i])) {
-      if (t === 'R') {
-       levels[i] += 1;
-      } else if (t === 'AN' || t === 'EN') {
-       levels[i] += 2;
-      }
-     } else {
-      if (t === 'L' || t === 'AN' || t === 'EN') {
-       levels[i] += 1;
-      }
-     }
-    }
-    var highestLevel = -1;
-    var lowestOddLevel = 99;
-    var level;
-    for (i = 0, ii = levels.length; i < ii; ++i) {
-     level = levels[i];
-     if (highestLevel < level) {
-      highestLevel = level;
-     }
-     if (lowestOddLevel > level && isOdd(level)) {
-      lowestOddLevel = level;
-     }
-    }
-    for (level = highestLevel; level >= lowestOddLevel; --level) {
-     var start = -1;
-     for (i = 0, ii = levels.length; i < ii; ++i) {
-      if (levels[i] < level) {
-       if (start >= 0) {
-        reverseValues(chars, start, i);
-        start = -1;
-       }
-      } else if (start < 0) {
-       start = i;
-      }
-     }
-     if (start >= 0) {
-      reverseValues(chars, start, levels.length);
-     }
-    }
-    for (i = 0, ii = chars.length; i < ii; ++i) {
-     var ch = chars[i];
-     if (ch === '<' || ch === '>') {
-      chars[i] = '';
-     }
-    }
-    return createBidiText(chars.join(''), isLTR);
-   }
-   exports.bidi = bidi;
-  }));
-  (function (root, factory) {
    factory(root.pdfjsCoreCharsets = {});
   }(this, function (exports) {
    var ISOAdobeCharset = [
     '.notdef',
     'space',
     'exclam',
     'quotedbl',
     'numbersign',
@@ -4868,16 +4123,765 @@
    exports.string32 = string32;
    exports.stringToBytes = stringToBytes;
    exports.stringToPDFString = stringToPDFString;
    exports.stringToUTF8String = stringToUTF8String;
    exports.utf8StringToString = utf8StringToString;
    exports.warn = warn;
   }));
   (function (root, factory) {
+   factory(root.pdfjsCoreBidi = {}, root.pdfjsSharedUtil);
+  }(this, function (exports, sharedUtil) {
+   var warn = sharedUtil.warn;
+   var baseTypes = [
+    'BN',
+    'BN',
+    'BN',
+    'BN',
+    'BN',
+    'BN',
+    'BN',
+    'BN',
+    'BN',
+    'S',
+    'B',
+    'S',
+    'WS',
+    'B',
+    'BN',
+    'BN',
+    'BN',
+    'BN',
+    'BN',
+    'BN',
+    'BN',
+    'BN',
+    'BN',
+    'BN',
+    'BN',
+    'BN',
+    'BN',
+    'BN',
+    'B',
+    'B',
+    'B',
+    'S',
+    'WS',
+    'ON',
+    'ON',
+    'ET',
+    'ET',
+    'ET',
+    'ON',
+    'ON',
+    'ON',
+    'ON',
+    'ON',
+    'ES',
+    'CS',
+    'ES',
+    'CS',
+    'CS',
+    'EN',
+    'EN',
+    'EN',
+    'EN',
+    'EN',
+    'EN',
+    'EN',
+    'EN',
+    'EN',
+    'EN',
+    'CS',
+    'ON',
+    'ON',
+    'ON',
+    'ON',
+    'ON',
+    'ON',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'ON',
+    'ON',
+    'ON',
+    'ON',
+    'ON',
+    'ON',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'ON',
+    'ON',
+    'ON',
+    'ON',
+    'BN',
+    'BN',
+    'BN',
+    'BN',
+    'BN',
+    'BN',
+    'B',
+    'BN',
+    'BN',
+    'BN',
+    'BN',
+    'BN',
+    'BN',
+    'BN',
+    'BN',
+    'BN',
+    'BN',
+    'BN',
+    'BN',
+    'BN',
+    'BN',
+    'BN',
+    'BN',
+    'BN',
+    'BN',
+    'BN',
+    'BN',
+    'BN',
+    'BN',
+    'BN',
+    'BN',
+    'BN',
+    'BN',
+    'CS',
+    'ON',
+    'ET',
+    'ET',
+    'ET',
+    'ET',
+    'ON',
+    'ON',
+    'ON',
+    'ON',
+    'L',
+    'ON',
+    'ON',
+    'BN',
+    'ON',
+    'ON',
+    'ET',
+    'ET',
+    'EN',
+    'EN',
+    'ON',
+    'L',
+    'ON',
+    'ON',
+    'ON',
+    'EN',
+    'L',
+    'ON',
+    'ON',
+    'ON',
+    'ON',
+    'ON',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'ON',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'ON',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L',
+    'L'
+   ];
+   var arabicTypes = [
+    'AN',
+    'AN',
+    'AN',
+    'AN',
+    'AN',
+    'AN',
+    'ON',
+    'ON',
+    'AL',
+    'ET',
+    'ET',
+    'AL',
+    'CS',
+    'AL',
+    'ON',
+    'ON',
+    'NSM',
+    'NSM',
+    'NSM',
+    'NSM',
+    'NSM',
+    'NSM',
+    'NSM',
+    'NSM',
+    'NSM',
+    'NSM',
+    'NSM',
+    'AL',
+    'AL',
+    '',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'NSM',
+    'NSM',
+    'NSM',
+    'NSM',
+    'NSM',
+    'NSM',
+    'NSM',
+    'NSM',
+    'NSM',
+    'NSM',
+    'NSM',
+    'NSM',
+    'NSM',
+    'NSM',
+    'NSM',
+    'NSM',
+    'NSM',
+    'NSM',
+    'NSM',
+    'NSM',
+    'NSM',
+    'AN',
+    'AN',
+    'AN',
+    'AN',
+    'AN',
+    'AN',
+    'AN',
+    'AN',
+    'AN',
+    'AN',
+    'ET',
+    'AN',
+    'AN',
+    'AL',
+    'AL',
+    'AL',
+    'NSM',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'NSM',
+    'NSM',
+    'NSM',
+    'NSM',
+    'NSM',
+    'NSM',
+    'NSM',
+    'AN',
+    'ON',
+    'NSM',
+    'NSM',
+    'NSM',
+    'NSM',
+    'NSM',
+    'NSM',
+    'AL',
+    'AL',
+    'NSM',
+    'NSM',
+    'ON',
+    'NSM',
+    'NSM',
+    'NSM',
+    'NSM',
+    'AL',
+    'AL',
+    'EN',
+    'EN',
+    'EN',
+    'EN',
+    'EN',
+    'EN',
+    'EN',
+    'EN',
+    'EN',
+    'EN',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL',
+    'AL'
+   ];
+   function isOdd(i) {
+    return (i & 1) !== 0;
+   }
+   function isEven(i) {
+    return (i & 1) === 0;
+   }
+   function findUnequal(arr, start, value) {
+    for (var j = start, jj = arr.length; j < jj; ++j) {
+     if (arr[j] !== value) {
+      return j;
+     }
+    }
+    return j;
+   }
+   function setValues(arr, start, end, value) {
+    for (var j = start; j < end; ++j) {
+     arr[j] = value;
+    }
+   }
+   function reverseValues(arr, start, end) {
+    for (var i = start, j = end - 1; i < j; ++i, --j) {
+     var temp = arr[i];
+     arr[i] = arr[j];
+     arr[j] = temp;
+    }
+   }
+   function createBidiText(str, isLTR, vertical) {
+    return {
+     str: str,
+     dir: vertical ? 'ttb' : isLTR ? 'ltr' : 'rtl'
+    };
+   }
+   var chars = [];
+   var types = [];
+   function bidi(str, startLevel, vertical) {
+    var isLTR = true;
+    var strLength = str.length;
+    if (strLength === 0 || vertical) {
+     return createBidiText(str, isLTR, vertical);
+    }
+    chars.length = strLength;
+    types.length = strLength;
+    var numBidi = 0;
+    var i, ii;
+    for (i = 0; i < strLength; ++i) {
+     chars[i] = str.charAt(i);
+     var charCode = str.charCodeAt(i);
+     var charType = 'L';
+     if (charCode <= 0x00ff) {
+      charType = baseTypes[charCode];
+     } else if (0x0590 <= charCode && charCode <= 0x05f4) {
+      charType = 'R';
+     } else if (0x0600 <= charCode && charCode <= 0x06ff) {
+      charType = arabicTypes[charCode & 0xff];
+      if (!charType) {
+       warn('Bidi: invalid Unicode character ' + charCode.toString(16));
+      }
+     } else if (0x0700 <= charCode && charCode <= 0x08AC) {
+      charType = 'AL';
+     }
+     if (charType === 'R' || charType === 'AL' || charType === 'AN') {
+      numBidi++;
+     }
+     types[i] = charType;
+    }
+    if (numBidi === 0) {
+     isLTR = true;
+     return createBidiText(str, isLTR);
+    }
+    if (startLevel === -1) {
+     if (strLength / numBidi < 0.3) {
+      isLTR = true;
+      startLevel = 0;
+     } else {
+      isLTR = false;
+      startLevel = 1;
+     }
+    }
+    var levels = [];
+    for (i = 0; i < strLength; ++i) {
+     levels[i] = startLevel;
+    }
+    var e = isOdd(startLevel) ? 'R' : 'L';
+    var sor = e;
+    var eor = sor;
+    var lastType = sor;
+    for (i = 0; i < strLength; ++i) {
+     if (types[i] === 'NSM') {
+      types[i] = lastType;
+     } else {
+      lastType = types[i];
+     }
+    }
+    lastType = sor;
+    var t;
+    for (i = 0; i < strLength; ++i) {
+     t = types[i];
+     if (t === 'EN') {
+      types[i] = lastType === 'AL' ? 'AN' : 'EN';
+     } else if (t === 'R' || t === 'L' || t === 'AL') {
+      lastType = t;
+     }
+    }
+    for (i = 0; i < strLength; ++i) {
+     t = types[i];
+     if (t === 'AL') {
+      types[i] = 'R';
+     }
+    }
+    for (i = 1; i < strLength - 1; ++i) {
+     if (types[i] === 'ES' && types[i - 1] === 'EN' && types[i + 1] === 'EN') {
+      types[i] = 'EN';
+     }
+     if (types[i] === 'CS' && (types[i - 1] === 'EN' || types[i - 1] === 'AN') && types[i + 1] === types[i - 1]) {
+      types[i] = types[i - 1];
+     }
+    }
+    for (i = 0; i < strLength; ++i) {
+     if (types[i] === 'EN') {
+      var j;
+      for (j = i - 1; j >= 0; --j) {
+       if (types[j] !== 'ET') {
+        break;
+       }
+       types[j] = 'EN';
+      }
+      for (j = i + 1; j < strLength; ++j) {
+       if (types[j] !== 'ET') {
+        break;
+       }
+       types[j] = 'EN';
+      }
+     }
+    }
+    for (i = 0; i < strLength; ++i) {
+     t = types[i];
+     if (t === 'WS' || t === 'ES' || t === 'ET' || t === 'CS') {
+      types[i] = 'ON';
+     }
+    }
+    lastType = sor;
+    for (i = 0; i < strLength; ++i) {
+     t = types[i];
+     if (t === 'EN') {
+      types[i] = lastType === 'L' ? 'L' : 'EN';
+     } else if (t === 'R' || t === 'L') {
+      lastType = t;
+     }
+    }
+    for (i = 0; i < strLength; ++i) {
+     if (types[i] === 'ON') {
+      var end = findUnequal(types, i + 1, 'ON');
+      var before = sor;
+      if (i > 0) {
+       before = types[i - 1];
+      }
+      var after = eor;
+      if (end + 1 < strLength) {
+       after = types[end + 1];
+      }
+      if (before !== 'L') {
+       before = 'R';
+      }
+      if (after !== 'L') {
+       after = 'R';
+      }
+      if (before === after) {
+       setValues(types, i, end, before);
+      }
+      i = end - 1;
+     }
+    }
+    for (i = 0; i < strLength; ++i) {
+     if (types[i] === 'ON') {
+      types[i] = e;
+     }
+    }
+    for (i = 0; i < strLength; ++i) {
+     t = types[i];
+     if (isEven(levels[i])) {
+      if (t === 'R') {
+       levels[i] += 1;
+      } else if (t === 'AN' || t === 'EN') {
+       levels[i] += 2;
+      }
+     } else {
+      if (t === 'L' || t === 'AN' || t === 'EN') {
+       levels[i] += 1;
+      }
+     }
+    }
+    var highestLevel = -1;
+    var lowestOddLevel = 99;
+    var level;
+    for (i = 0, ii = levels.length; i < ii; ++i) {
+     level = levels[i];
+     if (highestLevel < level) {
+      highestLevel = level;
+     }
+     if (lowestOddLevel > level && isOdd(level)) {
+      lowestOddLevel = level;
+     }
+    }
+    for (level = highestLevel; level >= lowestOddLevel; --level) {
+     var start = -1;
+     for (i = 0, ii = levels.length; i < ii; ++i) {
+      if (levels[i] < level) {
+       if (start >= 0) {
+        reverseValues(chars, start, i);
+        start = -1;
+       }
+      } else if (start < 0) {
+       start = i;
+      }
+     }
+     if (start >= 0) {
+      reverseValues(chars, start, levels.length);
+     }
+    }
+    for (i = 0, ii = chars.length; i < ii; ++i) {
+     var ch = chars[i];
+     if (ch === '<' || ch === '>') {
+      chars[i] = '';
+     }
+    }
+    return createBidiText(chars.join(''), isLTR);
+   }
+   exports.bidi = bidi;
+  }));
+  (function (root, factory) {
    factory(root.pdfjsCoreCFFParser = {}, root.pdfjsSharedUtil, root.pdfjsCoreCharsets, root.pdfjsCoreEncodings);
   }(this, function (exports, sharedUtil, coreCharsets, coreEncodings) {
    var error = sharedUtil.error;
    var info = sharedUtil.info;
    var bytesToString = sharedUtil.bytesToString;
    var warn = sharedUtil.warn;
    var isArray = sharedUtil.isArray;
    var Util = sharedUtil.Util;
@@ -19627,16 +19631,20 @@
     t['ArialNarrow'] = 'Helvetica';
     t['ArialNarrow-Bold'] = 'Helvetica-Bold';
     t['ArialNarrow-BoldItalic'] = 'Helvetica-BoldOblique';
     t['ArialNarrow-Italic'] = 'Helvetica-Oblique';
     t['ArialBlack'] = 'Helvetica';
     t['ArialBlack-Bold'] = 'Helvetica-Bold';
     t['ArialBlack-BoldItalic'] = 'Helvetica-BoldOblique';
     t['ArialBlack-Italic'] = 'Helvetica-Oblique';
+    t['Arial-Black'] = 'Helvetica';
+    t['Arial-Black-Bold'] = 'Helvetica-Bold';
+    t['Arial-Black-BoldItalic'] = 'Helvetica-BoldOblique';
+    t['Arial-Black-Italic'] = 'Helvetica-Oblique';
     t['Arial'] = 'Helvetica';
     t['Arial-Bold'] = 'Helvetica-Bold';
     t['Arial-BoldItalic'] = 'Helvetica-BoldOblique';
     t['Arial-Italic'] = 'Helvetica-Oblique';
     t['Arial-BoldItalicMT'] = 'Helvetica-BoldOblique';
     t['Arial-BoldMT'] = 'Helvetica-Bold';
     t['Arial-ItalicMT'] = 'Helvetica-Oblique';
     t['ArialMT'] = 'Helvetica';
@@ -19700,16 +19708,17 @@
     t['MS-PGothic'] = 'MS PGothic';
     t['MS-PGothic-Bold'] = 'MS PGothic-Bold';
     t['MS-PGothic-BoldItalic'] = 'MS PGothic-BoldItalic';
     t['MS-PGothic-Italic'] = 'MS PGothic-Italic';
     t['MS-PMincho'] = 'MS PMincho';
     t['MS-PMincho-Bold'] = 'MS PMincho-Bold';
     t['MS-PMincho-BoldItalic'] = 'MS PMincho-BoldItalic';
     t['MS-PMincho-Italic'] = 'MS PMincho-Italic';
+    t['NuptialScript'] = 'Times-Italic';
     t['Wingdings'] = 'ZapfDingbats';
    });
    var getSerifFonts = getLookupTableFactory(function (t) {
     t['Adobe Jenson'] = true;
     t['Adobe Text'] = true;
     t['Albertus'] = true;
     t['Aldus'] = true;
     t['Alexandria'] = true;
@@ -19800,16 +19809,17 @@
     t['Modern'] = true;
     t['Mona Lisa'] = true;
     t['Mrs Eaves'] = true;
     t['MS Serif'] = true;
     t['Museo Slab'] = true;
     t['New York'] = true;
     t['Nimbus Roman'] = true;
     t['NPS Rawlinson Roadway'] = true;
+    t['NuptialScript'] = true;
     t['Palatino'] = true;
     t['Perpetua'] = true;
     t['Plantin'] = true;
     t['Plantin Schoolbook'] = true;
     t['Playbill'] = true;
     t['Poor Richard'] = true;
     t['Rawlinson Roadway'] = true;
     t['Renault'] = true;
@@ -36786,17 +36796,17 @@
       this.black = name.search(/Black/g) !== -1;
       this.remeasure = Object.keys(this.widths).length > 0;
       if (isStandardFont && type === 'CIDFontType2' && properties.cidEncoding.indexOf('Identity-') === 0) {
        var GlyphMapForStandardFonts = getGlyphMapForStandardFonts();
        var map = [];
        for (charCode in GlyphMapForStandardFonts) {
         map[+charCode] = GlyphMapForStandardFonts[charCode];
        }
-       if (/ArialBlack/i.test(name)) {
+       if (/Arial-?Black/i.test(name)) {
         var SupplementalGlyphMapForArialBlack = getSupplementalGlyphMapForArialBlack();
         for (charCode in SupplementalGlyphMapForArialBlack) {
          map[+charCode] = SupplementalGlyphMapForArialBlack[charCode];
         }
        }
        var isIdentityUnicode = this.toUnicode instanceof IdentityToUnicodeMap;
        if (!isIdentityUnicode) {
         this.toUnicode.forEach(function (charCode, unicodeCharCode) {
@@ -45434,18 +45444,23 @@
        }
        if (baseEncodingName !== 'MacRomanEncoding' && baseEncodingName !== 'MacExpertEncoding' && baseEncodingName !== 'WinAnsiEncoding') {
         baseEncodingName = null;
        }
       }
       if (baseEncodingName) {
        properties.defaultEncoding = getEncoding(baseEncodingName).slice();
       } else {
-       encoding = properties.type === 'TrueType' ? WinAnsiEncoding : StandardEncoding;
-       if (!!(properties.flags & FontFlags.Symbolic)) {
+       var isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
+       var isNonsymbolicFont = !!(properties.flags & FontFlags.Nonsymbolic);
+       encoding = StandardEncoding;
+       if (properties.type === 'TrueType' && !isNonsymbolicFont) {
+        encoding = WinAnsiEncoding;
+       }
+       if (isSymbolicFont) {
         encoding = MacRomanEncoding;
         if (!properties.file) {
          if (/Symbol/i.test(properties.name)) {
           encoding = SymbolSetEncoding;
          } else if (/Dingbats/i.test(properties.name)) {
           encoding = ZapfDingbatsEncoding;
          }
         }
@@ -47632,16 +47647,17 @@
   }(this, function (exports, sharedUtil, corePrimitives, coreStream, coreObj, coreParser, coreCrypto, coreEvaluator, coreAnnotation) {
    var MissingDataException = sharedUtil.MissingDataException;
    var Util = sharedUtil.Util;
    var assert = sharedUtil.assert;
    var error = sharedUtil.error;
    var info = sharedUtil.info;
    var isArray = sharedUtil.isArray;
    var isArrayBuffer = sharedUtil.isArrayBuffer;
+   var isNum = sharedUtil.isNum;
    var isString = sharedUtil.isString;
    var shadow = sharedUtil.shadow;
    var stringToBytes = sharedUtil.stringToBytes;
    var stringToPDFString = sharedUtil.stringToPDFString;
    var warn = sharedUtil.warn;
    var isSpace = sharedUtil.isSpace;
    var Dict = corePrimitives.Dict;
    var isDict = corePrimitives.isDict;
@@ -47655,16 +47671,17 @@
    var XRef = coreObj.XRef;
    var Linearization = coreParser.Linearization;
    var calculateMD5 = coreCrypto.calculateMD5;
    var OperatorList = coreEvaluator.OperatorList;
    var PartialEvaluator = coreEvaluator.PartialEvaluator;
    var Annotation = coreAnnotation.Annotation;
    var AnnotationFactory = coreAnnotation.AnnotationFactory;
    var Page = function PageClosure() {
+    var DEFAULT_USER_UNIT = 1.0;
     var LETTER_SIZE_MEDIABOX = [
      0,
      0,
      612,
      792
     ];
     function Page(pdfManager, xref, pageIndex, pageDict, ref, fontCache) {
      this.pdfManager = pdfManager;
@@ -47715,16 +47732,23 @@
      },
      get mediaBox() {
       var obj = this.getInheritedPageProp('MediaBox');
       if (!isArray(obj) || obj.length !== 4) {
        obj = LETTER_SIZE_MEDIABOX;
       }
       return shadow(this, 'mediaBox', obj);
      },
+     get userUnit() {
+      var obj = this.getPageProp('UserUnit');
+      if (!isNum(obj) || obj <= 0) {
+       obj = DEFAULT_USER_UNIT;
+      }
+      return shadow(this, 'userUnit', obj);
+     },
      get view() {
       var mediaBox = this.mediaBox;
       var cropBox = this.getInheritedPageProp('CropBox');
       if (!isArray(cropBox) || cropBox.length !== 4) {
        return shadow(this, 'view', mediaBox);
       }
       cropBox = Util.intersect(cropBox, mediaBox);
       if (!cropBox) {
@@ -48798,26 +48822,29 @@
         });
        }, onFailure);
       }, onFailure);
      };
      handler.on('GetPage', function wphSetupGetPage(data) {
       return pdfManager.getPage(data.pageIndex).then(function (page) {
        var rotatePromise = pdfManager.ensure(page, 'rotate');
        var refPromise = pdfManager.ensure(page, 'ref');
+       var userUnitPromise = pdfManager.ensure(page, 'userUnit');
        var viewPromise = pdfManager.ensure(page, 'view');
        return Promise.all([
         rotatePromise,
         refPromise,
+        userUnitPromise,
         viewPromise
        ]).then(function (results) {
         return {
          rotate: results[0],
          ref: results[1],
-         view: results[2]
+         userUnit: results[2],
+         view: results[3]
         };
        });
       });
      });
      handler.on('GetPageIndex', function wphSetupGetPageIndex(data) {
       var ref = new Ref(data.ref.num, data.ref.gen);
       var catalog = pdfManager.pdfDocument.catalog;
       return catalog.getPageIndex(ref);
--- a/browser/extensions/pdfjs/content/web/viewer.css
+++ b/browser/extensions/pdfjs/content/web/viewer.css
@@ -926,21 +926,16 @@ html[dir='rtl'] .toolbarButton:first-chi
 }
 
 .toolbarButtonSpacer {
   width: 30px;
   display: inline-block;
   height: 1px;
 }
 
-.toolbarButtonFlexibleSpacer {
-  -moz-box-flex: 1;
-  min-width: 30px;
-}
-
 html[dir='ltr'] #findPrevious {
   margin-left: 3px;
 }
 html[dir='ltr'] #findNext {
   margin-right: 3px;
 }
 
 html[dir='rtl'] #findPrevious {
--- a/browser/extensions/pdfjs/content/web/viewer.js
+++ b/browser/extensions/pdfjs/content/web/viewer.js
@@ -502,23 +502,23 @@ var pdfjsWebLibs;
       this.file = database.files[index];
       this.database = database;
      }.bind(this));
     }
     ViewHistory.prototype = {
      _writeToStorage: function ViewHistory_writeToStorage() {
       return new Promise(function (resolve) {
        var databaseStr = JSON.stringify(this.database);
-       sessionStorage.setItem('pdfjsHistory', databaseStr);
+       sessionStorage.setItem('pdfjs.history', databaseStr);
        resolve();
       }.bind(this));
      },
      _readFromStorage: function ViewHistory_readFromStorage() {
       return new Promise(function (resolve) {
-       resolve(sessionStorage.getItem('pdfjsHistory'));
+       resolve(sessionStorage.getItem('pdfjs.history'));
       });
      },
      set: function ViewHistory_set(name, val) {
       if (!this.isInitializedPromiseResolved) {
        return;
       }
       this.file[name] = val;
       return this._writeToStorage();
@@ -4258,17 +4258,23 @@ var pdfjsWebLibs;
        resolveRenderPromise(undefined);
       }, function pdfPageRenderError(error) {
        showCanvas();
        rejectRenderPromise(error);
       });
       return result;
      },
      paintOnSvg: function PDFPageView_paintOnSvg(wrapper) {
-      return Promise.resolve('SVG rendering is not supported.');
+      return {
+       promise: Promise.reject(new Error('SVG rendering is not supported.')),
+       onRenderContinue: function (cont) {
+       },
+       cancel: function () {
+       }
+      };
      },
      setPageLabel: function PDFView_setPageLabel(label) {
       this.pageLabel = typeof label === 'string' ? label : null;
       if (this.pageLabel !== null) {
        this.div.setAttribute('data-page-label', this.pageLabel);
       } else {
        this.div.removeAttribute('data-page-label');
       }
--- a/caps/nsJSPrincipals.cpp
+++ b/caps/nsJSPrincipals.cpp
@@ -156,21 +156,21 @@ static bool
 ReadPrincipalInfo(JSStructuredCloneReader* aReader,
                   uint32_t aTag,
                   PrincipalInfo& aInfo)
 {
     if (aTag == SCTAG_DOM_SYSTEM_PRINCIPAL) {
         aInfo = SystemPrincipalInfo();
     } else if (aTag == SCTAG_DOM_NULL_PRINCIPAL) {
         PrincipalOriginAttributes attrs;
-        nsAutoCString dummy;
-        if (!ReadSuffixAndSpec(aReader, attrs, dummy)) {
+        nsAutoCString spec;
+        if (!ReadSuffixAndSpec(aReader, attrs, spec)) {
             return false;
         }
-        aInfo = NullPrincipalInfo(attrs);
+        aInfo = NullPrincipalInfo(attrs, spec);
     } else if (aTag == SCTAG_DOM_EXPANDED_PRINCIPAL) {
         uint32_t length, unused;
         if (!JS_ReadUint32Pair(aReader, &length, &unused)) {
             return false;
         }
 
         ExpandedPrincipalInfo expanded;
 
@@ -249,17 +249,17 @@ WriteSuffixAndSpec(JSStructuredCloneWrit
 }
 
 static bool
 WritePrincipalInfo(JSStructuredCloneWriter* aWriter, const PrincipalInfo& aInfo)
 {
     if (aInfo.type() == PrincipalInfo::TNullPrincipalInfo) {
         const NullPrincipalInfo& nullInfo = aInfo;
         return JS_WriteUint32Pair(aWriter, SCTAG_DOM_NULL_PRINCIPAL, 0) &&
-               WriteSuffixAndSpec(aWriter, nullInfo.attrs(), EmptyCString());
+               WriteSuffixAndSpec(aWriter, nullInfo.attrs(), nullInfo.spec());
     }
     if (aInfo.type() == PrincipalInfo::TSystemPrincipalInfo) {
         return JS_WriteUint32Pair(aWriter, SCTAG_DOM_SYSTEM_PRINCIPAL, 0);
     }
     if (aInfo.type() == PrincipalInfo::TExpandedPrincipalInfo) {
         const ExpandedPrincipalInfo& expanded = aInfo;
         if (!JS_WriteUint32Pair(aWriter, SCTAG_DOM_EXPANDED_PRINCIPAL, 0) ||
             !JS_WriteUint32Pair(aWriter, expanded.whitelist().Length(), 0)) {
--- a/caps/nsNullPrincipal.cpp
+++ b/caps/nsNullPrincipal.cpp
@@ -53,32 +53,45 @@ nsNullPrincipal::CreateWithInheritedAttr
 
   RefPtr<nsNullPrincipal> nullPrin = new nsNullPrincipal();
   nsresult rv = nullPrin->Init(attrs);
   MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
   return nullPrin.forget();
 }
 
 /* static */ already_AddRefed<nsNullPrincipal>
-nsNullPrincipal::Create(const PrincipalOriginAttributes& aOriginAttributes)
+nsNullPrincipal::Create(const PrincipalOriginAttributes& aOriginAttributes,
+                        nsIURI* aURI)
 {
   RefPtr<nsNullPrincipal> nullPrin = new nsNullPrincipal();
-  nsresult rv = nullPrin->Init(aOriginAttributes);
+  nsresult rv = nullPrin->Init(aOriginAttributes, aURI);
   MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
 
   return nullPrin.forget();
 }
 
 nsresult
-nsNullPrincipal::Init(const PrincipalOriginAttributes& aOriginAttributes)
+nsNullPrincipal::Init(const PrincipalOriginAttributes& aOriginAttributes,
+                      nsIURI* aURI)
 {
   mOriginAttributes = aOriginAttributes;
 
-  mURI = nsNullPrincipalURI::Create();
-  NS_ENSURE_TRUE(mURI, NS_ERROR_NOT_AVAILABLE);
+  if (aURI) {
+    nsAutoCString scheme;
+    nsresult rv = aURI->GetScheme(scheme);
+    NS_ENSURE_SUCCESS(rv, rv);
+
+    NS_ENSURE_TRUE(scheme.EqualsLiteral(NS_NULLPRINCIPAL_SCHEME),
+                   NS_ERROR_NOT_AVAILABLE);
+
+    mURI = aURI;
+  } else {
+    mURI = nsNullPrincipalURI::Create();
+    NS_ENSURE_TRUE(mURI, NS_ERROR_NOT_AVAILABLE);
+  }
 
   return NS_OK;
 }
 
 nsresult
 nsNullPrincipal::GetScriptLocation(nsACString &aStr)
 {
   return mURI->GetSpec(aStr);
--- a/caps/nsNullPrincipal.h
+++ b/caps/nsNullPrincipal.h
@@ -48,19 +48,21 @@ public:
   NS_IMETHOD GetBaseDomain(nsACString& aBaseDomain) override;
   nsresult GetOriginInternal(nsACString& aOrigin) override;
 
   static already_AddRefed<nsNullPrincipal> CreateWithInheritedAttributes(nsIPrincipal* aInheritFrom);
 
   static already_AddRefed<nsNullPrincipal> CreateWithInheritedAttributes(nsIDocShell* aDocShell);
 
   static already_AddRefed<nsNullPrincipal>
-  Create(const mozilla::PrincipalOriginAttributes& aOriginAttributes = mozilla::PrincipalOriginAttributes());
+  Create(const mozilla::PrincipalOriginAttributes& aOriginAttributes = mozilla::PrincipalOriginAttributes(),
+         nsIURI* aURI = nullptr);
 
-  nsresult Init(const mozilla::PrincipalOriginAttributes& aOriginAttributes = mozilla::PrincipalOriginAttributes());
+  nsresult Init(const mozilla::PrincipalOriginAttributes& aOriginAttributes = mozilla::PrincipalOriginAttributes(),
+                nsIURI* aURI = nullptr);
 
   virtual nsresult GetScriptLocation(nsACString &aStr) override;
 
   PrincipalKind Kind() override { return eNullPrincipal; }
 
  protected:
   virtual ~nsNullPrincipal() {}
 
--- a/db/sqlite3/src/sqlite3.c
+++ b/db/sqlite3/src/sqlite3.c
@@ -1,11 +1,11 @@
 /******************************************************************************
 ** This file is an amalgamation of many separate C source files from SQLite
-** version 3.15.1.  By combining all the individual C code files into this
+** version 3.15.2.  By combining all the individual C code files into this
 ** single large file, the entire code can be compiled as a single translation
 ** unit.  This allows many compilers to do optimizations that would not be
 ** possible if the files were compiled separately.  Performance improvements
 ** of 5% or more are commonly seen when SQLite is compiled as a single
 ** translation unit.
 **
 ** This file is all you need to compile SQLite.  To use SQLite in other
 ** programs, you need this file and the "sqlite3.h" header file that defines
@@ -376,19 +376,19 @@ extern "C" {
 ** within its configuration management system.  ^The SQLITE_SOURCE_ID
 ** string contains the date and time of the check-in (UTC) and an SHA1
 ** hash of the entire source tree.
 **
 ** See also: [sqlite3_libversion()],
 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
 ** [sqlite_version()] and [sqlite_source_id()].
 */
-#define SQLITE_VERSION        "3.15.1"
-#define SQLITE_VERSION_NUMBER 3015001
-#define SQLITE_SOURCE_ID      "2016-11-04 12:08:49 1136863c76576110e710dd5d69ab6bf347c65e36"
+#define SQLITE_VERSION        "3.15.2"
+#define SQLITE_VERSION_NUMBER 3015002
+#define SQLITE_SOURCE_ID      "2016-11-28 19:13:37 bbd85d235f7037c6a033a9690534391ffeacecc8"
 
 /*
 ** CAPI3REF: Run-Time Library Version Numbers
 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
 **
 ** These interfaces provide the same information as the [SQLITE_VERSION],
 ** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros
 ** but are associated with the library instead of the header file.  ^(Cautious
@@ -15578,25 +15578,25 @@ struct Parse {
     i16 iColumn;          /* Table column number */
     u8 tempReg;           /* iReg is a temp register that needs to be freed */
     int iLevel;           /* Nesting level */
     int iReg;             /* Reg with value of this column. 0 means none. */
     int lru;              /* Least recently used entry has the smallest value */
   } aColCache[SQLITE_N_COLCACHE];  /* One for each column cache entry */
   int aTempReg[8];        /* Holding area for temporary registers */
   Token sNameToken;       /* Token with unqualified schema object name */
-  Token sLastToken;       /* The last token parsed */
 
   /************************************************************************
   ** Above is constant between recursions.  Below is reset before and after
   ** each recursion.  The boundary between these two regions is determined
-  ** using offsetof(Parse,nVar) so the nVar field must be the first field
-  ** in the recursive region.
+  ** using offsetof(Parse,sLastToken) so the sLastToken field must be the
+  ** first field in the recursive region.
   ************************************************************************/
 
+  Token sLastToken;       /* The last token parsed */
   ynVar nVar;               /* Number of '?' variables seen in the SQL so far */
   int nzVar;                /* Number of available slots in azVar[] */
   u8 iPkSortOrder;          /* ASC or DESC for INTEGER PRIMARY KEY */
   u8 explain;               /* True if the EXPLAIN flag is found on the query */
 #ifndef SQLITE_OMIT_VIRTUALTABLE
   u8 declareVtab;           /* True if inside sqlite3_declare_vtab() */
   int nVtabLock;            /* Number of virtual tables to lock */
 #endif
@@ -15620,17 +15620,17 @@ struct Parse {
   With *pWith;              /* Current WITH clause, or NULL */
   With *pWithToFree;        /* Free this WITH object at the end of the parse */
 };
 
 /*
 ** Sizes and pointers of various parts of the Parse object.
 */
 #define PARSE_HDR_SZ offsetof(Parse,aColCache) /* Recursive part w/o aColCache*/
-#define PARSE_RECURSE_SZ offsetof(Parse,nVar)  /* Recursive part */
+#define PARSE_RECURSE_SZ offsetof(Parse,sLastToken)    /* Recursive part */
 #define PARSE_TAIL_SZ (sizeof(Parse)-PARSE_RECURSE_SZ) /* Non-recursive part */
 #define PARSE_TAIL(X) (((char*)(X))+PARSE_RECURSE_SZ)  /* Pointer to tail */
 
 /*
 ** Return true if currently inside an sqlite3_declare_vtab() call.
 */
 #ifdef SQLITE_OMIT_VIRTUALTABLE
   #define IN_DECLARE_VTAB 0
@@ -88580,16 +88580,20 @@ static int lookupName(
           assert( pExpr->pLeft==0 && pExpr->pRight==0 );
           assert( pExpr->x.pList==0 );
           assert( pExpr->x.pSelect==0 );
           pOrig = pEList->a[j].pExpr;
           if( (pNC->ncFlags&NC_AllowAgg)==0 && ExprHasProperty(pOrig, EP_Agg) ){
             sqlite3ErrorMsg(pParse, "misuse of aliased aggregate %s", zAs);
             return WRC_Abort;
           }
+          if( sqlite3ExprVectorSize(pOrig)!=1 ){
+            sqlite3ErrorMsg(pParse, "row value misused");
+            return WRC_Abort;
+          }
           resolveAlias(pParse, pEList, j, pExpr, "", nSubquery);
           cnt = 1;
           pMatch = 0;
           assert( zTab==0 && zDb==0 );
           goto lookupname_end;
         }
       } 
     }
@@ -88956,39 +88960,48 @@ static int resolveExprStep(Walker *pWalk
         }
       }
       break;
     }
     case TK_VARIABLE: {
       notValid(pParse, pNC, "parameters", NC_IsCheck|NC_PartIdx|NC_IdxExpr);
       break;
     }
+    case TK_BETWEEN:
     case TK_EQ:
     case TK_NE:
     case TK_LT:
     case TK_LE:
     case TK_GT:
     case TK_GE:
     case TK_IS:
     case TK_ISNOT: {
       int nLeft, nRight;
       if( pParse->db->mallocFailed ) break;
-      assert( pExpr->pRight!=0 );
       assert( pExpr->pLeft!=0 );
       nLeft = sqlite3ExprVectorSize(pExpr->pLeft);
-      nRight = sqlite3ExprVectorSize(pExpr->pRight);
+      if( pExpr->op==TK_BETWEEN ){
+        nRight = sqlite3ExprVectorSize(pExpr->x.pList->a[0].pExpr);
+        if( nRight==nLeft ){
+          nRight = sqlite3ExprVectorSize(pExpr->x.pList->a[1].pExpr);
+        }
+      }else{
+        assert( pExpr->pRight!=0 );
+        nRight = sqlite3ExprVectorSize(pExpr->pRight);
+      }
       if( nLeft!=nRight ){
         testcase( pExpr->op==TK_EQ );
         testcase( pExpr->op==TK_NE );
         testcase( pExpr->op==TK_LT );
         testcase( pExpr->op==TK_LE );
         testcase( pExpr->op==TK_GT );
         testcase( pExpr->op==TK_GE );
         testcase( pExpr->op==TK_IS );
         testcase( pExpr->op==TK_ISNOT );
+        testcase( pExpr->op==TK_BETWEEN );
         sqlite3ErrorMsg(pParse, "row value misused");
       }
       break; 
     }
   }
   return (pParse->nErr || pParse->db->mallocFailed) ? WRC_Abort : WRC_Continue;
 }
 
@@ -93007,17 +93020,17 @@ static int exprCodeVector(Parse *pParse,
     *piFreeable = 0;
     if( p->op==TK_SELECT ){
       iResult = sqlite3CodeSubselect(pParse, p, 0, 0);
     }else{
       int i;
       iResult = pParse->nMem+1;
       pParse->nMem += nResult;
       for(i=0; i<nResult; i++){
-        sqlite3ExprCode(pParse, p->x.pList->a[i].pExpr, i+iResult);
+        sqlite3ExprCodeFactorable(pParse, p->x.pList->a[i].pExpr, i+iResult);
       }
     }
   }
   return iResult;
 }
 
 
 /*
@@ -97759,16 +97772,17 @@ static void codeAttach(
   Expr *pKey           /* Database key for encryption extension */
 ){
   int rc;
   NameContext sName;
   Vdbe *v;
   sqlite3* db = pParse->db;
   int regArgs;
 
+  if( pParse->nErr ) goto attach_end;
   memset(&sName, 0, sizeof(NameContext));
   sName.pParse = pParse;
 
   if( 
       SQLITE_OK!=(rc = resolveAttachExpr(&sName, pFilename)) ||
       SQLITE_OK!=(rc = resolveAttachExpr(&sName, pDbname)) ||
       SQLITE_OK!=(rc = resolveAttachExpr(&sName, pKey))
   ){
@@ -104304,16 +104318,18 @@ static void instrFunc(
   if( typeHaystack==SQLITE_BLOB && typeNeedle==SQLITE_BLOB ){
     zHaystack = sqlite3_value_blob(argv[0]);
     zNeedle = sqlite3_value_blob(argv[1]);
     isText = 0;
   }else{
     zHaystack = sqlite3_value_text(argv[0]);
     zNeedle = sqlite3_value_text(argv[1]);
     isText = 1;
+    if( zNeedle==0 ) return;
+    assert( zHaystack );
   }
   while( nNeedle<=nHaystack && memcmp(zHaystack, zNeedle, nNeedle)!=0 ){
     N++;
     do{
       nHaystack--;
       zHaystack++;
     }while( isText && (zHaystack[0]&0xc0)==0x80 );
   }
@@ -124766,16 +124782,17 @@ static int codeEqualityTerm(
       if( ALWAYS(pLoop->aLTerm[i]) && pLoop->aLTerm[i]->pExpr==pX ) nEq++;
     }
 
     if( (pX->flags & EP_xIsSelect)==0 || pX->x.pSelect->pEList->nExpr==1 ){
       eType = sqlite3FindInIndex(pParse, pX, IN_INDEX_LOOP, 0, 0);
     }else{
       Select *pSelect = pX->x.pSelect;
       sqlite3 *db = pParse->db;
+      u16 savedDbOptFlags = db->dbOptFlags;
       ExprList *pOrigRhs = pSelect->pEList;
       ExprList *pOrigLhs = pX->pLeft->x.pList;
       ExprList *pRhs = 0;         /* New Select.pEList for RHS */
       ExprList *pLhs = 0;         /* New pX->pLeft vector */
 
       for(i=iEq;i<pLoop->nLTerm; i++){
         if( pLoop->aLTerm[i]->pExpr==pX ){
           int iField = pLoop->aLTerm[i]->iField - 1;
@@ -124809,17 +124826,19 @@ static int codeEqualityTerm(
         if( pLhs->nExpr==1 ){
           pX->pLeft = pLhs->a[0].pExpr;
         }else{
           pLeft->x.pList = pLhs;
           aiMap = (int*)sqlite3DbMallocZero(pParse->db, sizeof(int) * nEq);
           testcase( aiMap==0 );
         }
         pSelect->pEList = pRhs;
+        db->dbOptFlags |= SQLITE_QueryFlattener;
         eType = sqlite3FindInIndex(pParse, pX, IN_INDEX_LOOP, 0, aiMap);
+        db->dbOptFlags = savedDbOptFlags;
         testcase( aiMap!=0 && aiMap[0]!=0 );
         pSelect->pEList = pOrigRhs;
         pLeft->x.pList = pOrigLhs;
         pX->pLeft = pLeft;
       }
       sqlite3ExprListDelete(pParse->db, pLhs);
       sqlite3ExprListDelete(pParse->db, pRhs);
     }
@@ -127628,16 +127647,18 @@ static void exprAnalyze(
       pNewTerm->prereqAll = pTerm->prereqAll;
     }
   }
 #endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */
 
   /* Prevent ON clause terms of a LEFT JOIN from being used to drive
   ** an index for tables to the left of the join.
   */
+  testcase( pTerm!=&pWC->a[idxTerm] );
+  pTerm = &pWC->a[idxTerm];
   pTerm->prereqRight |= extraRight;
 }
 
 /***************************************************************************
 ** Routines with file scope above.  Interface to the rest of the where.c
 ** subsystem follows.
 ***************************************************************************/
 
@@ -165380,30 +165401,30 @@ static void icuLoadCollation(
 SQLITE_PRIVATE int sqlite3IcuInit(sqlite3 *db){
   struct IcuScalar {
     const char *zName;                        /* Function name */
     int nArg;                                 /* Number of arguments */
     int enc;                                  /* Optimal text encoding */
     void *pContext;                           /* sqlite3_user_data() context */
     void (*xFunc)(sqlite3_context*,int,sqlite3_value**);
   } scalars[] = {
-    {"regexp", 2, SQLITE_ANY,          0, icuRegexpFunc},
-
-    {"lower",  1, SQLITE_UTF16,        0, icuCaseFunc16},
-    {"lower",  2, SQLITE_UTF16,        0, icuCaseFunc16},
-    {"upper",  1, SQLITE_UTF16, (void*)1, icuCaseFunc16},
-    {"upper",  2, SQLITE_UTF16, (void*)1, icuCaseFunc16},
-
-    {"lower",  1, SQLITE_UTF8,         0, icuCaseFunc16},
-    {"lower",  2, SQLITE_UTF8,         0, icuCaseFunc16},
-    {"upper",  1, SQLITE_UTF8,  (void*)1, icuCaseFunc16},
-    {"upper",  2, SQLITE_UTF8,  (void*)1, icuCaseFunc16},
-
-    {"like",   2, SQLITE_UTF8,         0, icuLikeFunc},
-    {"like",   3, SQLITE_UTF8,         0, icuLikeFunc},
+    {"regexp", 2, SQLITE_ANY|SQLITE_DETERMINISTIC,          0, icuRegexpFunc},
+
+    {"lower",  1, SQLITE_UTF16|SQLITE_DETERMINISTIC,        0, icuCaseFunc16},
+    {"lower",  2, SQLITE_UTF16|SQLITE_DETERMINISTIC,        0, icuCaseFunc16},
+    {"upper",  1, SQLITE_UTF16|SQLITE_DETERMINISTIC, (void*)1, icuCaseFunc16},
+    {"upper",  2, SQLITE_UTF16|SQLITE_DETERMINISTIC, (void*)1, icuCaseFunc16},
+
+    {"lower",  1, SQLITE_UTF8|SQLITE_DETERMINISTIC,         0, icuCaseFunc16},
+    {"lower",  2, SQLITE_UTF8|SQLITE_DETERMINISTIC,         0, icuCaseFunc16},
+    {"upper",  1, SQLITE_UTF8|SQLITE_DETERMINISTIC,  (void*)1, icuCaseFunc16},
+    {"upper",  2, SQLITE_UTF8|SQLITE_DETERMINISTIC,  (void*)1, icuCaseFunc16},
+
+    {"like",   2, SQLITE_UTF8|SQLITE_DETERMINISTIC,         0, icuLikeFunc},
+    {"like",   3, SQLITE_UTF8|SQLITE_DETERMINISTIC,         0, icuLikeFunc},
 
     {"icu_load_collation",  2, SQLITE_UTF8, (void*)db, icuLoadCollation},
   };
 
   int rc = SQLITE_OK;
   int i;
 
   for(i=0; rc==SQLITE_OK && i<(int)(sizeof(scalars)/sizeof(scalars[0])); i++){
@@ -176411,23 +176432,25 @@ SQLITE_EXTENSION_INIT1
 
 /*
 ** Versions of isspace(), isalnum() and isdigit() to which it is safe
 ** to pass signed char values.
 */
 #ifdef sqlite3Isdigit
    /* Use the SQLite core versions if this routine is part of the
    ** SQLite amalgamation */
-#  define safe_isdigit(x) sqlite3Isdigit(x)
-#  define safe_isalnum(x) sqlite3Isalnum(x)
+#  define safe_isdigit(x)  sqlite3Isdigit(x)
+#  define safe_isalnum(x)  sqlite3Isalnum(x)
+#  define safe_isxdigit(x) sqlite3Isxdigit(x)
 #else
    /* Use the standard library for separate compilation */
 #include <ctype.h>  /* amalgamator: keep */
-#  define safe_isdigit(x) isdigit((unsigned char)(x))
-#  define safe_isalnum(x) isalnum((unsigned char)(x))
+#  define safe_isdigit(x)  isdigit((unsigned char)(x))
+#  define safe_isalnum(x)  isalnum((unsigned char)(x))
+#  define safe_isxdigit(x) isxdigit((unsigned char)(x))
 #endif
 
 /*
 ** Growing our own isspace() routine this way is twice as fast as
 ** the library isspace() function, resulting in a 7% overall performance
 ** increase for the parser.  (Ubuntu14.10 gcc 4.8.4 x64 with -Os).
 */
 static const char jsonIsSpace[] = {
@@ -177065,16 +177088,25 @@ static int jsonParseAddNode(
   p->jnFlags = 0;
   p->iVal = 0;
   p->n = n;
   p->u.zJContent = zContent;
   return pParse->nNode++;
 }
 
 /*
+** Return true if z[] begins with 4 (or more) hexadecimal digits
+*/
+static int jsonIs4Hex(const char *z){
+  int i;
+  for(i=0; i<4; i++) if( !safe_isxdigit(z[i]) ) return 0;
+  return 1;
+}
+
+/*
 ** Parse a single JSON value which begins at pParse->zJson[i].  Return the
 ** index of the first character past the end of the value parsed.
 **
 ** Return negative for a syntax error.  Special cases:  return -2 if the
 ** first non-whitespace character is '}' and return -3 if the first
 ** non-whitespace character is ']'.
 */
 static int jsonParseValue(JsonParse *pParse, u32 i){
@@ -177138,18 +177170,23 @@ static int jsonParseValue(JsonParse *pPa
     /* Parse string */
     u8 jnFlags = 0;
     j = i+1;
     for(;;){
       c = pParse->zJson[j];
       if( c==0 ) return -1;
       if( c=='\\' ){
         c = pParse->zJson[++j];
-        if( c==0 ) return -1;
-        jnFlags = JNODE_ESCAPE;
+        if( c=='"' || c=='\\' || c=='/' || c=='b' || c=='f'
+           || c=='n' || c=='r' || c=='t'
+           || (c=='u' && jsonIs4Hex(pParse->zJson+j+1)) ){
+          jnFlags = JNODE_ESCAPE;
+        }else{
+          return -1;
+        }
       }else if( c=='"' ){
         break;
       }
       j++;
     }
     jsonParseAddNode(pParse, JSON_STRING, j+1-i, &pParse->zJson[i]);
     if( !pParse->oom ) pParse->aNode[pParse->nNode-1].jnFlags = jnFlags;
     return j+1;
@@ -178007,17 +178044,17 @@ static void jsonObjectStep(
   }
 }
 static void jsonObjectFinal(sqlite3_context *ctx){
   JsonString *pStr;
   pStr = (JsonString*)sqlite3_aggregate_context(ctx, 0);
   if( pStr ){
     jsonAppendChar(pStr, '}');
     if( pStr->bErr ){
-      if( pStr->bErr==0 ) sqlite3_result_error_nomem(ctx);
+      if( pStr->bErr==1 ) sqlite3_result_error_nomem(ctx);
       assert( pStr->bStatic );
     }else{
       sqlite3_result_text(ctx, pStr->zBuf, pStr->nUsed,
                           pStr->bStatic ? SQLITE_TRANSIENT : sqlite3_free);
       pStr->bStatic = 1;
     }
   }else{
     sqlite3_result_text(ctx, "{}", 2, SQLITE_STATIC);
@@ -178285,19 +178322,19 @@ static int jsonEachColumn(
         jsonInit(&x, ctx);
         jsonEachComputePath(p, &x, p->sParse.aUp[p->i]);
         jsonResult(&x);
         break;
       }
       /* For json_each() path and root are the same so fall through
       ** into the root case */
     }
-    case JEACH_ROOT: {
+    default: {
       const char *zRoot = p->zRoot;
-       if( zRoot==0 ) zRoot = "$";
+      if( zRoot==0 ) zRoot = "$";
       sqlite3_result_text(ctx, zRoot, -1, SQLITE_STATIC);
       break;
     }
     case JEACH_JSON: {
       assert( i==JEACH_JSON );
       sqlite3_result_text(ctx, p->sParse.zJson, -1, SQLITE_STATIC);
       break;
     }
@@ -184214,17 +184251,17 @@ static int fts5ExprNodeTest_STRING(
           bMatch = 0;
           if( fts5ExprSynonymAdvanceto(pTerm, bDesc, &iLast, &rc) ){
             pNode->bNomatch = 0;
             pNode->bEof = 1;
             return rc;
           }
         }else{
           Fts5IndexIter *pIter = pPhrase->aTerm[j].pIter;
-          if( pIter->iRowid==iLast ) continue;
+          if( pIter->iRowid==iLast || pIter->bEof ) continue;
           bMatch = 0;
           if( fts5ExprAdvanceto(pIter, bDesc, &iLast, &rc, &pNode->bEof) ){
             return rc;
           }
         }
       }
     }
   }while( bMatch==0 );
@@ -189354,16 +189391,17 @@ static void fts5MultiIterSetEof(Fts5Iter
 */
 static void fts5MultiIterNext(
   Fts5Index *p, 
   Fts5Iter *pIter,
   int bFrom,                      /* True if argument iFrom is valid */
   i64 iFrom                       /* Advance at least as far as this */
 ){
   int bUseFrom = bFrom;
+  assert( pIter->base.bEof==0 );
   while( p->rc==SQLITE_OK ){
     int iFirst = pIter->aFirst[1].iFirst;
     int bNewTerm = 0;
     Fts5SegIter *pSeg = &pIter->aSeg[iFirst];
     assert( p->rc==SQLITE_OK );
     if( bUseFrom && pSeg->pDlidx ){
       fts5SegIterNextFrom(p, pSeg, iFrom);
     }else{
@@ -195618,17 +195656,17 @@ static void fts5Fts5Func(
 */
 static void fts5SourceIdFunc(
   sqlite3_context *pCtx,          /* Function call context */
   int nArg,                       /* Number of args */
   sqlite3_value **apUnused        /* Function arguments */
 ){
   assert( nArg==0 );
   UNUSED_PARAM2(nArg, apUnused);
-  sqlite3_result_text(pCtx, "fts5: 2016-11-04 12:08:49 1136863c76576110e710dd5d69ab6bf347c65e36", -1, SQLITE_TRANSIENT);
+  sqlite3_result_text(pCtx, "fts5: 2016-11-28 19:13:37 bbd85d235f7037c6a033a9690534391ffeacecc8", -1, SQLITE_TRANSIENT);
 }
 
 static int fts5Init(sqlite3 *db){
   static const sqlite3_module fts5Mod = {
     /* iVersion      */ 2,
     /* xCreate       */ fts5CreateMethod,
     /* xConnect      */ fts5ConnectMethod,
     /* xBestIndex    */ fts5BestIndexMethod,
--- a/db/sqlite3/src/sqlite3.h
+++ b/db/sqlite3/src/sqlite3.h
@@ -116,19 +116,19 @@ extern "C" {
 ** within its configuration management system.  ^The SQLITE_SOURCE_ID
 ** string contains the date and time of the check-in (UTC) and an SHA1
 ** hash of the entire source tree.
 **
 ** See also: [sqlite3_libversion()],
 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
 ** [sqlite_version()] and [sqlite_source_id()].
 */
-#define SQLITE_VERSION        "3.15.1"
-#define SQLITE_VERSION_NUMBER 3015001
-#define SQLITE_SOURCE_ID      "2016-11-04 12:08:49 1136863c76576110e710dd5d69ab6bf347c65e36"
+#define SQLITE_VERSION        "3.15.2"
+#define SQLITE_VERSION_NUMBER 3015002
+#define SQLITE_SOURCE_ID      "2016-11-28 19:13:37 bbd85d235f7037c6a033a9690534391ffeacecc8"
 
 /*
 ** CAPI3REF: Run-Time Library Version Numbers
 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
 **
 ** These interfaces provide the same information as the [SQLITE_VERSION],
 ** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros
 ** but are associated with the library instead of the header file.  ^(Cautious
--- a/dom/broadcastchannel/BroadcastChannel.cpp
+++ b/dom/broadcastchannel/BroadcastChannel.cpp
@@ -88,21 +88,16 @@ public:
     MOZ_ASSERT(NS_IsMainThread());
 
     nsIPrincipal* principal = GetPrincipalFromWorkerPrivate(mWorkerPrivate);
     if (!principal) {
       mRv.Throw(NS_ERROR_FAILURE);
       return true;
     }
 
-    if (NS_WARN_IF(principal->GetIsNullPrincipal())) {
-      mRv.Throw(NS_ERROR_FAILURE);
-      return true;
-    }
-
     mRv = PrincipalToPrincipalInfo(principal, &mPrincipalInfo);
     if (NS_WARN_IF(mRv.Failed())) {
       return true;
     }
 
     mRv = principal->GetOrigin(mOrigin);
     if (NS_WARN_IF(mRv.Failed())) {
       return true;
@@ -318,21 +313,16 @@ BroadcastChannel::Constructor(const Glob
     }
 
     nsIPrincipal* principal = incumbent->PrincipalOrNull();
     if (!principal) {
       aRv.Throw(NS_ERROR_UNEXPECTED);
       return nullptr;
     }
 
-    if (NS_WARN_IF(principal->GetIsNullPrincipal())) {
-      aRv.Throw(NS_ERROR_FAILURE);
-      return nullptr;
-    }
-
     aRv = principal->GetOrigin(origin);
     if (NS_WARN_IF(aRv.Failed())) {
       return nullptr;
     }
 
     aRv = PrincipalToPrincipalInfo(principal, &principalInfo);
     if (NS_WARN_IF(aRv.Failed())) {
       return nullptr;
--- a/dom/broadcastchannel/tests/mochitest.ini
+++ b/dom/broadcastchannel/tests/mochitest.ini
@@ -17,8 +17,9 @@ support-files =
 [test_broadcastchannel_self.html]
 [test_broadcastchannel_sharedWorker.html]
 [test_broadcastchannel_worker.html]
 [test_broadcastchannel_worker_alive.html]
 [test_bfcache.html]
 [test_invalidState.html]
 [test_ordering.html]
 [test_dataCloning.html]
+[test_dataURL.html]
new file mode 100644
--- /dev/null
+++ b/dom/broadcastchannel/tests/test_dataURL.html
@@ -0,0 +1,35 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Test for BroadcastChannel in data: URL</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<div id="dataURL">
+var a = new BroadcastChannel('a');
+var b = new BroadcastChannel('a');
+a.onmessage = function(e) { parent.postMessage(e.data, "*"); };
+b.postMessage(42);
+</div>
+
+<script>
+
+SimpleTest.waitForExplicitFinish();
+
+onmessage= function(e) {
+  ok(e.data, "42", "BroadcastChannel works with data URLs");
+  SimpleTest.finish();
+}
+
+var url = "data:text/html,<script>" + document.getElementById("dataURL").textContent + "</" + "script>";
+
+var ifr = document.createElement('iframe');
+document.body.appendChild(ifr);
+
+ifr.setAttribute('sandbox', 'allow-scripts');
+ifr.src = url;
+</script>
+</body>
+</html>
+
--- a/dom/canvas/TexUnpackBlob.cpp
+++ b/dom/canvas/TexUnpackBlob.cpp
@@ -645,17 +645,17 @@ TexUnpackImage::TexOrSubImage(bool isSub
     if (surf) {
         // WARNING: OSX can lose our MakeCurrent here.
         dataSurf = surf->GetDataSurface();
     }
     if (!dataSurf) {
         webgl->ErrorOutOfMemory("%s: GetAsSourceSurface or GetDataSurface failed after"
                                 " blit failed for TexUnpackImage.",
                                 funcName);
-        return true;
+        return false;
     }
 
     const TexUnpackSurface surfBlob(webgl, target, mWidth, mHeight, mDepth, dataSurf,
                                     mIsSrcPremult);
 
     return surfBlob.TexOrSubImage(isSubImage, needsRespec, funcName, tex, target, level,
                                   dui, xOffset, yOffset, zOffset, out_error);
 }
--- a/dom/media/MediaFormatReader.cpp
+++ b/dom/media/MediaFormatReader.cpp
@@ -259,16 +259,20 @@ public:
   const char* GetDescriptionName() const override
   {
     return mDecoder->GetDescriptionName();
   }
   void SetSeekThreshold(const media::TimeUnit& aTime) override
   {
     mDecoder->SetSeekThreshold(aTime);
   }
+  bool SupportDecoderRecycling() const override
+  {
+    return mDecoder->SupportDecoderRecycling();
+  }
   void Shutdown() override
   {
     mDecoder->Shutdown();
     mDecoder = nullptr;
     mToken = nullptr;
   }
 
 private:
@@ -1297,39 +1301,49 @@ MediaFormatReader::HandleDemuxedSamples(
     RefPtr<SharedTrackInfo> info = sample->mTrackInfo;
 
     if (info && decoder.mLastStreamSourceID != info->GetID()) {
       if (samplesPending) {
         // Let existing samples complete their decoding. We'll resume later.
         return;
       }
 
+      bool supportRecycling = MediaPrefs::MediaDecoderCheckRecycling() &&
+                              decoder.mDecoder->SupportDecoderRecycling();
       if (decoder.mNextStreamSourceID.isNothing() ||
           decoder.mNextStreamSourceID.ref() != info->GetID()) {
-        LOG("%s stream id has changed from:%d to:%d, draining decoder.",
+        if (!supportRecycling) {
+          LOG("%s stream id has changed from:%d to:%d, draining decoder.",
             TrackTypeToStr(aTrack), decoder.mLastStreamSourceID,
             info->GetID());
-        decoder.mNeedDraining = true;
-        decoder.mNextStreamSourceID = Some(info->GetID());
-        ScheduleUpdate(aTrack);
-        return;
+          decoder.mNeedDraining = true;
+          decoder.mNextStreamSourceID = Some(info->GetID());
+          ScheduleUpdate(aTrack);
+          return;
+        }
       }
 
-      LOG("%s stream id has changed from:%d to:%d, recreating decoder.",
+      LOG("%s stream id has changed from:%d to:%d.",
           TrackTypeToStr(aTrack), decoder.mLastStreamSourceID,
           info->GetID());
       decoder.mLastStreamSourceID = info->GetID();
       decoder.mNextStreamSourceID.reset();
-      // Reset will clear our array of queued samples. So make a copy now.
-      nsTArray<RefPtr<MediaRawData>> samples{decoder.mQueuedSamples};
-      Reset(aTrack);
-      decoder.ShutdownDecoder();
+      if (!supportRecycling) {
+        LOG("Decoder does not support recycling, recreate decoder.");
+        // Reset will clear our array of queued samples. So make a copy now.
+        nsTArray<RefPtr<MediaRawData>> samples{decoder.mQueuedSamples};
+        Reset(aTrack);
+        decoder.ShutdownDecoder();
+        if (sample->mKeyframe) {
+          decoder.mQueuedSamples.AppendElements(Move(samples));
+        }
+      }
+
       decoder.mInfo = info;
       if (sample->mKeyframe) {
-        decoder.mQueuedSamples.AppendElements(Move(samples));
         ScheduleUpdate(aTrack);
       } else {
         TimeInterval time =
           TimeInterval(TimeUnit::FromMicroseconds(sample->mTime),
                        TimeUnit::FromMicroseconds(sample->GetEndTime()));
         InternalSeekTarget seekTarget =
           decoder.mTimeThreshold.refOr(InternalSeekTarget(time, false));
         LOG("Stream change occurred on a non-keyframe. Seeking to:%lld",
--- a/dom/media/MediaPrefs.h
+++ b/dom/media/MediaPrefs.h
@@ -125,16 +125,17 @@ private:
   DECL_MEDIA_PREF("media.wmf.skip-blacklist",                 PDMWMFSkipBlacklist, bool, false);
   DECL_MEDIA_PREF("media.decoder-doctor.wmf-disabled-is-failure", DecoderDoctorWMFDisabledIsFailure, bool, false);
   DECL_MEDIA_PREF("media.wmf.vp9.enabled",                    PDMWMFVP9DecoderEnabled, bool, true);
   DECL_MEDIA_PREF("media.wmf.decoder.thread-count",           PDMWMFThreadCount, int32_t, -1);
 #endif
   DECL_MEDIA_PREF("media.decoder.fuzzing.enabled",            PDMFuzzingEnabled, bool, false);
   DECL_MEDIA_PREF("media.decoder.fuzzing.video-output-minimum-interval-ms", PDMFuzzingInterval, uint32_t, 0);
   DECL_MEDIA_PREF("media.decoder.fuzzing.dont-delay-inputexhausted", PDMFuzzingDelayInputExhausted, bool, true);
+  DECL_MEDIA_PREF("media.decoder.recycle.enabled",            MediaDecoderCheckRecycling, bool, false);
   DECL_MEDIA_PREF("media.gmp.decoder.enabled",                PDMGMPEnabled, bool, true);
   DECL_MEDIA_PREF("media.gmp.decoder.aac",                    GMPAACPreferred, uint32_t, 0);
   DECL_MEDIA_PREF("media.gmp.decoder.h264",                   GMPH264Preferred, uint32_t, 0);
 
   // MediaDecoderStateMachine
   DECL_MEDIA_PREF("media.suspend-bkgnd-video.enabled",        MDSMSuspendBackgroundVideoEnabled, bool, false);
   DECL_MEDIA_PREF("media.suspend-bkgnd-video.delay-ms",       MDSMSuspendBackgroundVideoDelay, AtomicUint32, SUSPEND_BACKGROUND_VIDEO_DELAY_MS);
   DECL_MEDIA_PREF("media.dormant-on-pause-timeout-ms",        DormantOnPauseTimeout, int32_t, 5000);
--- a/dom/media/platforms/PlatformDecoderModule.h
+++ b/dom/media/platforms/PlatformDecoderModule.h
@@ -292,13 +292,19 @@ public:
 
   // Set a hint of seek target time to decoder. Decoder will drop any decoded
   // data which pts is smaller than this value. This threshold needs to be clear
   // after reset decoder.
   // Decoder may not honor this value. However, it'd be better that
   // video decoder implements this API to improve seek performance.
   // Note: it should be called before Input() or after Flush().
   virtual void SetSeekThreshold(const media::TimeUnit& aTime) {}
+
+  // When playing adaptive playback, recreating an Android video decoder will
+  // cause the transition not smooth during resolution change.
+  // Reuse the decoder if the decoder support recycling.
+  // Currently, only Android video decoder will return true.
+  virtual bool SupportDecoderRecycling() const { return false; }
 };
 
 } // namespace mozilla
 
 #endif
--- a/dom/media/platforms/android/MediaCodecDataDecoder.cpp
+++ b/dom/media/platforms/android/MediaCodecDataDecoder.cpp
@@ -118,16 +118,18 @@ public:
                                  presentationTimeUs,
                                  gfx::IntRect(0, 0,
                                               mConfig.mDisplay.width,
                                               mConfig.mDisplay.height));
     INVOKE_CALLBACK(Output, v);
     return NS_OK;
   }
 
+  bool SupportDecoderRecycling() const override { return true; }
+
 protected:
   layers::ImageContainer* mImageContainer;
   const VideoInfo& mConfig;
   RefPtr<AndroidSurfaceTexture> mSurfaceTexture;
   RefPtr<SamplesWaitingForKey> mSamplesWaitingForKey;
 };
 
 
--- a/dom/media/platforms/android/RemoteDataDecoder.cpp
+++ b/dom/media/platforms/android/RemoteDataDecoder.cpp
@@ -240,16 +240,18 @@ public:
   }
 
   void Input(MediaRawData* aSample) override
   {
     RemoteDataDecoder::Input(aSample);
     mInputDurations.Put(aSample->mDuration);
   }
 
+  bool SupportDecoderRecycling() const override { return true; }
+
 private:
   class DurationQueue {
   public:
 
     void Clear()
     {
       mValues.clear();
     }
--- a/dom/media/platforms/wrappers/H264Converter.cpp
+++ b/dom/media/platforms/wrappers/H264Converter.cpp
@@ -4,16 +4,17 @@
  * 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/. */
 
 #include "mozilla/TaskQueue.h"
 
 #include "H264Converter.h"
 #include "ImageContainer.h"
 #include "MediaInfo.h"
+#include "MediaPrefs.h"
 #include "mp4_demuxer/AnnexB.h"
 #include "mp4_demuxer/H264.h"
 
 namespace mozilla
 {
 
 H264Converter::H264Converter(PlatformDecoderModule* aPDM,
                              const CreateDecoderParams& aParams)
@@ -280,16 +281,24 @@ H264Converter::CheckForSPSChange(MediaRa
 {
   RefPtr<MediaByteBuffer> extra_data =
     mp4_demuxer::AnnexB::ExtractExtraData(aSample);
   if (!mp4_demuxer::AnnexB::HasSPS(extra_data) ||
       mp4_demuxer::AnnexB::CompareExtraData(extra_data,
                                             mCurrentConfig.mExtraData)) {
         return NS_OK;
       }
+
+  if (MediaPrefs::MediaDecoderCheckRecycling() &&
+      mDecoder->SupportDecoderRecycling()) {
+    // Do not recreate the decoder, reuse it.
+    UpdateConfigFromExtraData(extra_data);
+    mNeedKeyframe = true;
+    return NS_OK;
+  }
   // The SPS has changed, signal to flush the current decoder and create a
   // new one.
   mDecoder->Flush();
   Shutdown();
   return CreateDecoderAndInit(aSample);
 }
 
 void
--- a/dom/media/platforms/wrappers/H264Converter.h
+++ b/dom/media/platforms/wrappers/H264Converter.h
@@ -34,16 +34,23 @@ public:
   const char* GetDescriptionName() const override
   {
     if (mDecoder) {
       return mDecoder->GetDescriptionName();
     }
     return "H264Converter decoder (pending)";
   }
   void SetSeekThreshold(const media::TimeUnit& aTime) override;
+  bool SupportDecoderRecycling() const override
+  {
+    if (mDecoder) {
+      return mDecoder->SupportDecoderRecycling();
+    }
+    return false;
+  }
 
   nsresult GetLastError() const { return mLastError; }
 
 private:
   // Will create the required MediaDataDecoder if need AVCC and we have a SPS NAL.
   // Returns NS_ERROR_FAILURE if error is permanent and can't be recovered and
   // will set mError accordingly.
   nsresult CreateDecoder(DecoderDoctorDiagnostics* aDiagnostics);
--- a/gfx/2d/BorrowedContext.h
+++ b/gfx/2d/BorrowedContext.h
@@ -190,18 +190,28 @@ public:
   }
 
   ~BorrowedCGContext() {
     MOZ_ASSERT(!cg);
   }
 
   CGContextRef cg;
 private:
+#ifdef USE_SKIA
   static CGContextRef BorrowCGContextFromDrawTarget(DrawTarget *aDT);
   static void ReturnCGContextToDrawTarget(DrawTarget *aDT, CGContextRef cg);
+#else
+  static CGContextRef BorrowCGContextFromDrawTarget(DrawTarget *aDT) {
+    MOZ_CRASH("Not supported without Skia");
+  }
+
+  static void ReturnCGContextToDrawTarget(DrawTarget *aDT, CGContextRef cg) {
+    MOZ_CRASH("not supported without Skia");
+  }
+#endif
   DrawTarget *mDT;
 };
 #endif
 
 } // namespace gfx
 } // namespace mozilla
 
 #endif // _MOZILLA_GFX_BORROWED_CONTEXT_H
--- a/gfx/layers/composite/LayerManagerComposite.cpp
+++ b/gfx/layers/composite/LayerManagerComposite.cpp
@@ -6,17 +6,16 @@
 #include "LayerManagerComposite.h"
 #include <stddef.h>                     // for size_t
 #include <stdint.h>                     // for uint16_t, uint32_t
 #include "CanvasLayerComposite.h"       // for CanvasLayerComposite
 #include "ColorLayerComposite.h"        // for ColorLayerComposite
 #include "CompositableHost.h"           // for CompositableHost
 #include "ContainerLayerComposite.h"    // for ContainerLayerComposite, etc
 #include "FPSCounter.h"                 // for FPSState, FPSCounter
-#include "PaintCounter.h"               // For PaintCounter
 #include "FrameMetrics.h"               // for FrameMetrics
 #include "GeckoProfiler.h"              // for profiler_set_frame_number, etc
 #include "ImageLayerComposite.h"        // for ImageLayerComposite
 #include "Layers.h"                     // for Layer, ContainerLayer, etc
 #include "LayerScope.h"                 // for LayerScope Tool
 #include "protobuf/LayerScopePacket.pb.h" // for protobuf (LayerScope)
 #include "PaintedLayerComposite.h"      // for PaintedLayerComposite
 #include "TiledContentHost.h"
@@ -64,16 +63,20 @@
 #include "GLContextProvider.h"
 #include "ScopedGLHelpers.h"
 #endif
 #include "GeckoProfiler.h"
 #include "TextRenderer.h"               // for TextRenderer
 #include "mozilla/layers/CompositorBridgeParent.h"
 #include "TreeTraversal.h"              // for ForEachNode
 
+#ifdef USE_SKIA
+#include "PaintCounter.h"               // For PaintCounter
+#endif
+
 class gfxContext;
 
 namespace mozilla {
 namespace layers {
 
 class ImageLayer;
 
 using namespace mozilla::gfx;
@@ -129,16 +132,20 @@ LayerManagerComposite::LayerManagerCompo
 , mDisabledApzWarning(false)
 , mCompositor(aCompositor)
 , mInTransaction(false)
 , mIsCompositorReady(false)
 , mGeometryChanged(true)
 {
   mTextRenderer = new TextRenderer(aCompositor);
   MOZ_ASSERT(aCompositor);
+
+#ifdef USE_SKIA
+  mPaintCounter = nullptr;
+#endif
 }
 
 LayerManagerComposite::~LayerManagerComposite()
 {
   Destroy();
 }
 
 
@@ -148,18 +155,21 @@ LayerManagerComposite::Destroy()
   if (!mDestroyed) {
     mCompositor->GetWidget()->CleanupWindowEffects();
     if (mRoot) {
       RootLayer()->Destroy();
     }
     mCompositor->CancelFrame();
     mRoot = nullptr;
     mClonedLayerTreeProperties = nullptr;
+    mDestroyed = true;
+
+#ifdef USE_SKIA
     mPaintCounter = nullptr;
-    mDestroyed = true;
+#endif
   }
 }
 
 void
 LayerManagerComposite::UpdateRenderBounds(const IntRect& aRect)
 {
   mRenderBounds = aRect;
 }
@@ -522,49 +532,53 @@ LayerManagerComposite::RootLayer() const
 #endif
 
 void
 LayerManagerComposite::InvalidateDebugOverlay(nsIntRegion& aInvalidRegion, const IntRect& aBounds)
 {
   bool drawFps = gfxPrefs::LayersDrawFPS();
   bool drawFrameCounter = gfxPrefs::DrawFrameCounter();
   bool drawFrameColorBars = gfxPrefs::CompositorDrawColorBars();
-  bool drawPaintTimes = gfxPrefs::AlwaysPaint();
 
   if (drawFps || drawFrameCounter) {
     aInvalidRegion.Or(aInvalidRegion, nsIntRect(0, 0, 256, 256));
   }
   if (drawFrameColorBars) {
     aInvalidRegion.Or(aInvalidRegion, nsIntRect(0, 0, 10, aBounds.height));
   }
+
+#ifdef USE_SKIA
+  bool drawPaintTimes = gfxPrefs::AlwaysPaint();
   if (drawPaintTimes) {
     aInvalidRegion.Or(aInvalidRegion, nsIntRect(PaintCounter::GetPaintRect()));
   }
+#endif
 }
 
+#ifdef USE_SKIA
 void
 LayerManagerComposite::DrawPaintTimes(Compositor* aCompositor)
 {
   if (!mPaintCounter) {
     mPaintCounter = new PaintCounter();
   }
 
   TimeDuration compositeTime = TimeStamp::Now() - mRenderStartTime;
   mPaintCounter->Draw(aCompositor, mLastPaintTime, compositeTime);
 }
+#endif
 
 static uint16_t sFrameCount = 0;
 void
 LayerManagerComposite::RenderDebugOverlay(const IntRect& aBounds)
 {
   bool drawFps = gfxPrefs::LayersDrawFPS();
   bool drawFrameCounter = gfxPrefs::DrawFrameCounter();
   bool drawFrameColorBars = gfxPrefs::CompositorDrawColorBars();
-  bool drawPaintTimes = gfxPrefs::AlwaysPaint();
-
+  
   TimeStamp now = TimeStamp::Now();
 
   if (drawFps) {
     if (!mFPS) {
       mFPS = MakeUnique<FPSState>();
     }
 
     float alpha = 1;
@@ -694,19 +708,22 @@ LayerManagerComposite::RenderDebugOverla
   }
 #endif
 
   if (drawFrameColorBars || drawFrameCounter) {
     // We intentionally overflow at 2^16.
     sFrameCount++;
   }
 
+#ifdef USE_SKIA
+  bool drawPaintTimes = gfxPrefs::AlwaysPaint();
   if (drawPaintTimes) {
     DrawPaintTimes(mCompositor);
   }
+#endif
 }
 
 RefPtr<CompositingRenderTarget>
 LayerManagerComposite::PushGroupForLayerEffects()
 {
   // This is currently true, so just making sure that any new use of this
   // method is flagged for investigation
   MOZ_ASSERT(gfxPrefs::LayersEffectInvert() ||
--- a/gfx/layers/composite/LayerManagerComposite.h
+++ b/gfx/layers/composite/LayerManagerComposite.h
@@ -167,17 +167,16 @@ protected:
   bool mDebugOverlayWantsNextFrame;
   nsTArray<ImageCompositeNotification> mImageCompositeNotifications;
   // Testing property. If hardware composer is supported, this will return
   // true if the last frame was deemed 'too complicated' to be rendered.
   float mWarningLevel;
   mozilla::TimeStamp mWarnTime;
 
   bool mWindowOverlayChanged;
-  RefPtr<PaintCounter> mPaintCounter;
   TimeDuration mLastPaintTime;
   TimeStamp mRenderStartTime;
 };
 
 // A layer manager implementation that uses the Compositor API
 // to render layers.
 class LayerManagerComposite final : public HostLayerManager
 {
@@ -382,21 +381,16 @@ private:
    * Render the current layer tree to the active target.
    */
   void Render(const nsIntRegion& aInvalidRegion, const nsIntRegion& aOpaqueRegion);
 #if defined(MOZ_WIDGET_ANDROID)
   void RenderToPresentationSurface();
 #endif
 
   /**
-   * Render paint and composite times above the frame.
-   */
-  void DrawPaintTimes(Compositor* aCompositor);
-
-  /**
    * We need to know our invalid region before we're ready to render.
    */
   void InvalidateDebugOverlay(nsIntRegion& aInvalidRegion, const gfx::IntRect& aBounds);
 
   /**
    * Render debug overlays such as the FPS/FrameCounter above the frame.
    */
   void RenderDebugOverlay(const gfx::IntRect& aBounds);
@@ -431,16 +425,24 @@ private:
   UniquePtr<FPSState> mFPS;
 
   bool mInTransaction;
   bool mIsCompositorReady;
 
   RefPtr<CompositingRenderTarget> mTwoPassTmpTarget;
   RefPtr<TextRenderer> mTextRenderer;
   bool mGeometryChanged;
+
+#ifdef USE_SKIA
+  /**
+   * Render paint and composite times above the frame.
+   */
+  void DrawPaintTimes(Compositor* aCompositor);
+  RefPtr<PaintCounter> mPaintCounter;
+#endif
 };
 
 /**
  * Compositor layers are for use with OMTC on the compositor thread only. There
  * must be corresponding Client layers on the content thread. For composite
  * layers, the layer manager only maintains the layer tree.
  */
 class HostLayer
--- a/gfx/layers/moz.build
+++ b/gfx/layers/moz.build
@@ -316,17 +316,16 @@ UNIFIED_SOURCES += [
     'composite/ContainerLayerComposite.cpp',
     'composite/ContentHost.cpp',
     'composite/FPSCounter.cpp',
     'composite/FrameUniformityData.cpp',
     'composite/GPUVideoTextureHost.cpp',
     'composite/ImageHost.cpp',
     'composite/ImageLayerComposite.cpp',
     'composite/LayerManagerComposite.cpp',
-    'composite/PaintCounter.cpp',
     'composite/PaintedLayerComposite.cpp',
     'composite/TextRenderer.cpp',
     'composite/TextureHost.cpp',
     'composite/TiledContentHost.cpp',
     'Compositor.cpp',
     'CopyableCanvasLayer.cpp',
     'Effects.cpp',
     'FrameMetrics.cpp',
@@ -445,8 +444,13 @@ MOCHITEST_CHROME_MANIFESTS += ['apz/test
 
 CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
 CXXFLAGS += CONFIG['TK_CFLAGS']
 
 LOCAL_INCLUDES += CONFIG['SKIA_INCLUDES']
 
 if CONFIG['GNU_CXX']:
     CXXFLAGS += ['-Wno-error=shadow']
+
+if CONFIG['MOZ_ENABLE_SKIA']:
+  UNIFIED_SOURCES += [
+    'composite/PaintCounter.cpp',
+  ]
--- a/gfx/skia/skia/include/config/SkUserConfig.h
+++ b/gfx/skia/skia/include/config/SkUserConfig.h
@@ -147,16 +147,19 @@
 
 #define SK_ALLOW_STATIC_GLOBAL_INITIALIZERS 0
 
 #define SK_SUPPORT_LEGACY_GETDEVICE
 #define SK_SUPPORT_LEGACY_GETTOPDEVICE
 
 #define SK_IGNORE_ETC1_SUPPORT
 
+// Don't use __stdcall with SkiaGLGlue - bug 1320644
+#define GR_GL_FUNCTION_TYPE
+
 #define SK_RASTERIZE_EVEN_ROUNDING
 
 #define SK_DISABLE_SCREENSPACE_TESS_AA_PATH_RENDERER
 
 #define SK_DISABLE_SLOW_DEBUG_VALIDATION 1
 
 #define MOZ_SKIA 1
 
--- a/ipc/glue/BackgroundParentImpl.cpp
+++ b/ipc/glue/BackgroundParentImpl.cpp
@@ -516,21 +516,16 @@ public:
   NS_IMETHOD Run() override
   {
     MOZ_ASSERT(NS_IsMainThread());
 
     NullifyContentParentRAII raii(mContentParent);
 
     nsCOMPtr<nsIPrincipal> principal = PrincipalInfoToPrincipal(mPrincipalInfo);
 
-    if (principal->GetIsNullPrincipal()) {
-      mContentParent->KillHard("BroadcastChannel killed: no null principal.");
-      return NS_OK;
-    }
-
     nsAutoCString origin;
     nsresult rv = principal->GetOrigin(origin);
     if (NS_FAILED(rv)) {
       mContentParent->KillHard("BroadcastChannel killed: principal::GetOrigin failed.");
       return NS_OK;
     }
 
     if (NS_WARN_IF(!mOrigin.Equals(origin))) {
@@ -633,17 +628,16 @@ BackgroundParentImpl::RecvPBroadcastChan
 {
   AssertIsInMainProcess();
   AssertIsOnBackgroundThread();
 
   RefPtr<ContentParent> parent = BackgroundParent::GetContentParent(this);
 
   // If the ContentParent is null we are dealing with a same-process actor.
   if (!parent) {
-    MOZ_ASSERT(aPrincipalInfo.type() != PrincipalInfo::TNullPrincipalInfo);
     return IPC_OK();
   }
 
   RefPtr<CheckPrincipalRunnable> runnable =
     new CheckPrincipalRunnable(parent.forget(), aPrincipalInfo, aOrigin);
   MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(runnable));
 
   return IPC_OK();
--- a/ipc/glue/BackgroundUtils.cpp
+++ b/ipc/glue/BackgroundUtils.cpp
@@ -57,18 +57,24 @@ PrincipalInfoToPrincipal(const Principal
       }
 
       return principal.forget();
     }
 
     case PrincipalInfo::TNullPrincipalInfo: {
       const NullPrincipalInfo& info =
         aPrincipalInfo.get_NullPrincipalInfo();
-      principal = nsNullPrincipal::Create(info.attrs());
 
+      nsCOMPtr<nsIURI> uri;
+      rv = NS_NewURI(getter_AddRefs(uri), info.spec());
+      if (NS_WARN_IF(NS_FAILED(rv))) {
+        return nullptr;
+      }
+
+      principal = nsNullPrincipal::Create(info.attrs(), uri);
       return principal.forget();
     }
 
     case PrincipalInfo::TContentPrincipalInfo: {
       const ContentPrincipalInfo& info =
         aPrincipalInfo.get_ContentPrincipalInfo();
 
       nsCOMPtr<nsIURI> uri;
@@ -126,17 +132,35 @@ nsresult
 PrincipalToPrincipalInfo(nsIPrincipal* aPrincipal,
                          PrincipalInfo* aPrincipalInfo)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(aPrincipal);
   MOZ_ASSERT(aPrincipalInfo);
 
   if (aPrincipal->GetIsNullPrincipal()) {
-    *aPrincipalInfo = NullPrincipalInfo(BasePrincipal::Cast(aPrincipal)->OriginAttributesRef());
+    nsCOMPtr<nsIURI> uri;
+    nsresult rv = aPrincipal->GetURI(getter_AddRefs(uri));
+    if (NS_WARN_IF(NS_FAILED(rv))) {
+      return rv;
+    }
+
+    if (NS_WARN_IF(!uri)) {
+      return NS_ERROR_FAILURE;
+    }
+
+    nsAutoCString spec;
+    rv = uri->GetSpec(spec);
+    if (NS_WARN_IF(NS_FAILED(rv))) {
+      return rv;
+    }
+
+    *aPrincipalInfo =
+      NullPrincipalInfo(BasePrincipal::Cast(aPrincipal)->OriginAttributesRef(),
+                        spec);
     return NS_OK;
   }
 
   nsresult rv;
   nsCOMPtr<nsIScriptSecurityManager> secMan =
     do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
@@ -186,17 +210,17 @@ PrincipalToPrincipalInfo(nsIPrincipal* a
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   if (NS_WARN_IF(!uri)) {
     return NS_ERROR_FAILURE;
   }
 
-  nsCString spec;
+  nsAutoCString spec;
   rv = uri->GetSpec(spec);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   *aPrincipalInfo = ContentPrincipalInfo(BasePrincipal::Cast(aPrincipal)->OriginAttributesRef(),
                                          spec);
   return NS_OK;
--- a/ipc/glue/PBackgroundSharedTypes.ipdlh
+++ b/ipc/glue/PBackgroundSharedTypes.ipdlh
@@ -15,16 +15,17 @@ struct ContentPrincipalInfo
 };
 
 struct SystemPrincipalInfo
 { };
 
 struct NullPrincipalInfo
 {
   PrincipalOriginAttributes attrs;
+  nsCString spec;
 };
 
 struct ExpandedPrincipalInfo
 {
   PrincipalOriginAttributes attrs;
   PrincipalInfo[] whitelist;
 };
 
--- a/js/src/builtin/Promise.cpp
+++ b/js/src/builtin/Promise.cpp
@@ -2237,17 +2237,17 @@ js::Promise_then(JSContext* cx, unsigned
     Rooted<PromiseObject*> promise(cx);
 
     bool isPromise = promiseObj->is<PromiseObject>();
     if (isPromise) {
         promise = &promiseObj->as<PromiseObject>();
     } else {
         RootedObject unwrappedPromiseObj(cx, CheckedUnwrap(promiseObj));
         if (!unwrappedPromiseObj) {
-            JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_UNWRAP_DENIED);
+            ReportAccessDenied(cx);
             return false;
         }
         if (!unwrappedPromiseObj->is<PromiseObject>()) {
             JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO,
                                       "Promise", "then", "value");
             return false;
         }
         promise = &unwrappedPromiseObj->as<PromiseObject>();
--- a/js/src/builtin/TestingFunctions.cpp
+++ b/js/src/builtin/TestingFunctions.cpp
@@ -2577,17 +2577,17 @@ SharedAddress(JSContext* cx, unsigned ar
         return false;
     }
 
 #ifdef JS_MORE_DETERMINISTIC
     args.rval().setString(cx->staticStrings().getUint(0));
 #else
     RootedObject obj(cx, CheckedUnwrap(&args[0].toObject()));
     if (!obj) {
-        JS_ReportErrorASCII(cx, "Permission denied to access object");
+        ReportAccessDenied(cx);
         return false;
     }
     if (!obj->is<SharedArrayBufferObject>()) {
         JS_ReportErrorASCII(cx, "Argument must be a SharedArrayBuffer");
         return false;
     }
     char buffer[64];
     uint32_t nchar =
@@ -3574,22 +3574,22 @@ GetLcovInfo(JSContext* cx, unsigned argc
         JS_ReportErrorASCII(cx, "Wrong number of arguments");
         return false;
     }
 
     RootedObject global(cx);
     if (args.hasDefined(0)) {
         global = ToObject(cx, args[0]);
         if (!global) {
-            JS_ReportErrorASCII(cx, "First argument should be an object");
+            JS_ReportErrorASCII(cx, "Permission denied to access global");
             return false;
         }
         global = CheckedUnwrap(global);
         if (!global) {
-            JS_ReportErrorASCII(cx, "Permission denied to access global");
+            ReportAccessDenied(cx);
             return false;
         }
         if (!global->is<GlobalObject>()) {
             JS_ReportErrorASCII(cx, "Argument must be a global object");
             return false;
         }
     } else {
         global = JS::CurrentGlobalOrNull(cx);
--- a/js/src/gc/GCRuntime.h
+++ b/js/src/gc/GCRuntime.h
@@ -785,24 +785,16 @@ class GCRuntime
     JS::GCSliceCallback setSliceCallback(JS::GCSliceCallback callback);
     JS::GCNurseryCollectionCallback setNurseryCollectionCallback(
         JS::GCNurseryCollectionCallback callback);
     JS::DoCycleCollectionCallback setDoCycleCollectionCallback(JS::DoCycleCollectionCallback callback);
     void callDoCycleCollectionCallback(JSContext* cx);
 
     void setFullCompartmentChecks(bool enable);
 
-    bool isManipulatingDeadZones() { return manipulatingDeadZones; }
-    void setManipulatingDeadZones(bool value) { manipulatingDeadZones = value; }
-    unsigned objectsMarkedInDeadZonesCount() { return objectsMarkedInDeadZones; }
-    void incObjectsMarkedInDeadZone() {
-        MOZ_ASSERT(manipulatingDeadZones);
-        ++objectsMarkedInDeadZones;
-    }
-
     JS::Zone* getCurrentZoneGroup() { return currentZoneGroup; }
     void setFoundBlackGrayEdges(TenuredCell& target) {
         AutoEnterOOMUnsafeRegion oomUnsafe;
         if (!foundBlackGrayEdges.append(&target))
             oomUnsafe.crash("OOM|small: failed to insert into foundBlackGrayEdges");
     }
 
     uint64_t gcNumber() const { return number; }
@@ -1282,33 +1274,16 @@ class GCRuntime
     bool compactingEnabled;
 
     /*
      * Some code cannot tolerate compacting GC so it can be disabled temporarily
      * with AutoDisableCompactingGC which uses this counter.
      */
     unsigned compactingDisabledCount;
 
-    /*
-     * This is true if we are in the middle of a brain transplant (e.g.,
-     * JS_TransplantObject) or some other operation that can manipulate
-     * dead zones.
-     */
-    bool manipulatingDeadZones;
-
-    /*
-     * This field is incremented each time we mark an object inside a
-     * zone with no incoming cross-compartment pointers. Typically if
-     * this happens it signals that an incremental GC is marking too much
-     * stuff. At various times we check this counter and, if it has changed, we
-     * run an immediate, non-incremental GC to clean up the dead
-     * zones. This should happen very rarely.
-     */
-    unsigned objectsMarkedInDeadZones;
-
     bool poked;
 
     /*
      * These options control the zealousness of the GC. At every allocation,
      * nextScheduled is decremented. When it reaches zero we do a full GC.
      *
      * At this point, if zeal_ is one of the types that trigger periodic
      * collection, then nextScheduled is reset to the value of zealFrequency.
--- a/js/src/jit/IonAnalysis.cpp
+++ b/js/src/jit/IonAnalysis.cpp
@@ -546,17 +546,17 @@ SplitCriticalEdgesForBlock(MIRGraph& gra
         return true;
     for (size_t i = 0; i < block->numSuccessors(); i++) {
         MBasicBlock* target = block->getSuccessor(i);
         if (target->numPredecessors() < 2)
             continue;
 
         // Create a simple new block which contains a goto and which split the
         // edge between block and target.
-        MBasicBlock* split = MBasicBlock::NewSplitEdge(graph, block->info(), block, i, target);
+        MBasicBlock* split = MBasicBlock::NewSplitEdge(graph, block, i, target);
         if (!split)
             return false;
     }
     return true;
 }
 
 // A critical edge is an edge which is neither its successor's only predecessor
 // nor its predecessor's only successor. Critical edges must be split to
--- a/js/src/jit/MIRGraph.cpp
+++ b/js/src/jit/MIRGraph.cpp
@@ -270,30 +270,30 @@ MBasicBlock::NewPendingLoopHeader(MIRGra
 
     if (!block->inherit(graph.alloc(), nullptr, pred, 0, stackPhiCount))
         return nullptr;
 
     return block;
 }
 
 MBasicBlock*
-MBasicBlock::NewSplitEdge(MIRGraph& graph, const CompileInfo& info, MBasicBlock* pred, size_t predEdgeIdx, MBasicBlock* succ)
+MBasicBlock::NewSplitEdge(MIRGraph& graph, MBasicBlock* pred, size_t predEdgeIdx, MBasicBlock* succ)
 {
     MBasicBlock* split = nullptr;
-    if (!pred->pc()) {
+    if (!succ->pc()) {
         // The predecessor does not have a PC, this is a Wasm compilation.
-        split = MBasicBlock::New(graph, info, pred, SPLIT_EDGE);
+        split = MBasicBlock::New(graph, succ->info(), pred, SPLIT_EDGE);
         if (!split)
             return nullptr;
     } else {
         // The predecessor has a PC, this is an IonBuilder compilation.
         MResumePoint* succEntry = succ->entryResumePoint();
 
         BytecodeSite* site = new(graph.alloc()) BytecodeSite(succ->trackedTree(), succEntry->pc());
-        split = new(graph.alloc()) MBasicBlock(graph, info, site, SPLIT_EDGE);
+        split = new(graph.alloc()) MBasicBlock(graph, succ->info(), site, SPLIT_EDGE);
 
         if (!split->init())
             return nullptr;
 
         // A split edge is used to simplify the graph to avoid having a
         // predecessor with multiple successors as well as a successor with
         // multiple predecessors.  As instructions can be moved in this
         // split-edge block, we need to give this block a resume point. To do
--- a/js/src/jit/MIRGraph.h
+++ b/js/src/jit/MIRGraph.h
@@ -112,19 +112,18 @@ class MBasicBlock : public TempObject, p
     static MBasicBlock* NewPopN(MIRGraph& graph, const CompileInfo& info,
                                 MBasicBlock* pred, BytecodeSite* site, Kind kind, uint32_t popn);
     static MBasicBlock* NewWithResumePoint(MIRGraph& graph, const CompileInfo& info,
                                            MBasicBlock* pred, BytecodeSite* site,
                                            MResumePoint* resumePoint);
     static MBasicBlock* NewPendingLoopHeader(MIRGraph& graph, const CompileInfo& info,
                                              MBasicBlock* pred, BytecodeSite* site,
                                              unsigned loopStateSlots);
-    static MBasicBlock* NewSplitEdge(MIRGraph& graph, const CompileInfo& info,
-                                     MBasicBlock* pred, size_t predEdgeIdx,
-                                     MBasicBlock* succ);
+    static MBasicBlock* NewSplitEdge(MIRGraph& graph, MBasicBlock* pred,
+                                     size_t predEdgeIdx, MBasicBlock* succ);
 
     bool dominates(const MBasicBlock* other) const {
         return other->domIndex() - domIndex() < numDominated();
     }
 
     void setId(uint32_t id) {
         id_ = id;
     }
--- a/js/src/js.msg
+++ b/js/src/js.msg
@@ -150,17 +150,18 @@ MSG_DEF(JSMSG_TOO_MANY_ARGUMENTS,      0
 
 // CSP
 MSG_DEF(JSMSG_CSP_BLOCKED_EVAL,        0, JSEXN_ERR, "call to eval() blocked by CSP")
 MSG_DEF(JSMSG_CSP_BLOCKED_FUNCTION,    0, JSEXN_ERR, "call to Function() blocked by CSP")
 
 // Wrappers
 MSG_DEF(JSMSG_ACCESSOR_DEF_DENIED,     1, JSEXN_ERR, "Permission denied to define accessor property {0}")
 MSG_DEF(JSMSG_DEAD_OBJECT,             0, JSEXN_TYPEERR, "can't access dead object")
-MSG_DEF(JSMSG_UNWRAP_DENIED,           0, JSEXN_ERR, "permission denied to unwrap object")
+MSG_DEF(JSMSG_OBJECT_ACCESS_DENIED,    0, JSEXN_ERR, "Permission denied to access object")
+MSG_DEF(JSMSG_PROPERTY_ACCESS_DENIED,  1, JSEXN_ERR, "Permission denied to access property {0}")
 
 // JSAPI-only (Not thrown as JS exceptions)
 MSG_DEF(JSMSG_BAD_CLONE_FUNOBJ_SCOPE,  0, JSEXN_TYPEERR, "bad cloned function scope chain")
 MSG_DEF(JSMSG_CANT_CLONE_OBJECT,       0, JSEXN_TYPEERR, "can't clone object")
 MSG_DEF(JSMSG_CANT_OPEN,               2, JSEXN_ERR, "can't open {0}: {1}")
 MSG_DEF(JSMSG_USER_DEFINED_ERROR,      0, JSEXN_ERR, "JS_ReportError was called")
 
 // Internal errors
@@ -407,18 +408,16 @@ MSG_DEF(JSMSG_CANT_REPORT_NC_AS_NE,    0
 MSG_DEF(JSMSG_CANT_REPORT_NEW,         0, JSEXN_TYPEERR, "proxy can't report a new property on a non-extensible object")
 MSG_DEF(JSMSG_CANT_REPORT_NE_AS_NC,    0, JSEXN_TYPEERR, "proxy can't report a non-existent property as non-configurable")
 MSG_DEF(JSMSG_CANT_SET_NW_NC,          0, JSEXN_TYPEERR, "proxy can't successfully set a non-writable, non-configurable property")
 MSG_DEF(JSMSG_CANT_SET_WO_SETTER,      0, JSEXN_TYPEERR, "proxy can't succesfully set an accessor property without a setter")
 MSG_DEF(JSMSG_CANT_SKIP_NC,            0, JSEXN_TYPEERR, "proxy can't skip a non-configurable property")
 MSG_DEF(JSMSG_ONWKEYS_STR_SYM,         0, JSEXN_TYPEERR,  "proxy [[OwnPropertyKeys]] must return an array with only string and symbol elements")
 MSG_DEF(JSMSG_MUST_REPORT_SAME_VALUE,  0, JSEXN_TYPEERR, "proxy must report the same value for a non-writable, non-configurable property")
 MSG_DEF(JSMSG_MUST_REPORT_UNDEFINED,   0, JSEXN_TYPEERR, "proxy must report undefined for a non-configurable accessor property without a getter")
-MSG_DEF(JSMSG_OBJECT_ACCESS_DENIED,    0, JSEXN_ERR, "Permission denied to access object")
-MSG_DEF(JSMSG_PROPERTY_ACCESS_DENIED,  1, JSEXN_ERR, "Permission denied to access property {0}")
 MSG_DEF(JSMSG_PROXY_CONSTRUCT_OBJECT,  0, JSEXN_TYPEERR, "proxy [[Construct]] must return an object")
 MSG_DEF(JSMSG_PROXY_EXTENSIBILITY,     0, JSEXN_TYPEERR, "proxy must report same extensiblitity as target")
 MSG_DEF(JSMSG_PROXY_GETOWN_OBJORUNDEF, 0, JSEXN_TYPEERR, "proxy [[GetOwnProperty]] must return an object or undefined")
 MSG_DEF(JSMSG_PROXY_REVOKED,           0, JSEXN_TYPEERR, "illegal operation attempted on a revoked proxy")
 MSG_DEF(JSMSG_PROXY_ARG_REVOKED,       1, JSEXN_TYPEERR, "argument {0} cannot be a revoked proxy")
 MSG_DEF(JSMSG_BAD_TRAP,                1, JSEXN_TYPEERR, "proxy handler's {0} trap wasn't undefined, null, or callable")
 
 // Structured cloning
--- a/js/src/jsarray.cpp
+++ b/js/src/jsarray.cpp
@@ -901,17 +901,17 @@ js::IsWrappedArrayConstructor(JSContext*
 {
     if (!v.isObject()) {
         *result = false;
         return true;
     }
     if (v.toObject().is<WrapperObject>()) {
         JSObject* obj = CheckedUnwrap(&v.toObject());
         if (!obj) {
-            JS_ReportErrorASCII(cx, "Permission denied to access object");
+            ReportAccessDenied(cx);
             return false;
         }
 
         *result = IsArrayConstructor(obj);
     } else {
         *result = false;
     }
     return true;
--- a/js/src/jsgc.cpp
+++ b/js/src/jsgc.cpp
@@ -852,18 +852,16 @@ GCRuntime::GCRuntime(JSRuntime* rt) :
     markingValidator(nullptr),
 #endif
     interFrameGC(false),
     defaultTimeBudget_(SliceBudget::UnlimitedTimeBudget),
     incrementalAllowed(true),
     generationalDisabled(0),
     compactingEnabled(true),
     compactingDisabledCount(0),
-    manipulatingDeadZones(false),
-    objectsMarkedInDeadZones(0),
     poked(false),
 #ifdef JS_GC_ZEAL
     zealModeBits(0),
     zealFrequency(0),
     nextScheduled(0),
     deterministicOnly(false),
     incrementalLimit(0),
 #endif
--- a/js/src/jswrapper.h
+++ b/js/src/jswrapper.h
@@ -353,16 +353,19 @@ UncheckedUnwrap(JSObject* obj, bool stop
 JS_FRIEND_API(JSObject*)
 CheckedUnwrap(JSObject* obj, bool stopAtWindowProxy = true);
 
 // Unwrap only the outermost security wrapper, with the same semantics as
 // above. This is the checked version of Wrapper::wrappedObject.
 JS_FRIEND_API(JSObject*)
 UnwrapOneChecked(JSObject* obj, bool stopAtWindowProxy = true);
 
+void
+ReportAccessDenied(JSContext* cx);
+
 JS_FRIEND_API(bool)
 IsCrossCompartmentWrapper(JSObject* obj);
 
 void
 NukeCrossCompartmentWrapper(JSContext* cx, JSObject* wrapper);
 
 void
 RemapWrapper(JSContext* cx, JSObject* wobj, JSObject* newTarget);
--- a/js/src/proxy/Proxy.cpp
+++ b/js/src/proxy/Proxy.cpp
@@ -29,17 +29,17 @@ using namespace js::gc;
 
 void
 js::AutoEnterPolicy::reportErrorIfExceptionIsNotPending(JSContext* cx, jsid id)
 {
     if (JS_IsExceptionPending(cx))
         return;
 
     if (JSID_IS_VOID(id)) {
-        JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_OBJECT_ACCESS_DENIED);
+        ReportAccessDenied(cx);
     } else {
         RootedValue idVal(cx, IdToValue(id));
         JSString* str = ValueToSource(cx, idVal);
         if (!str) {
             return;
         }
         AutoStableStringChars chars(cx);
         const char16_t* prop = nullptr;
--- a/js/src/proxy/SecurityWrapper.cpp
+++ b/js/src/proxy/SecurityWrapper.cpp
@@ -6,56 +6,50 @@
 
 #include "jsapi.h"
 #include "jswrapper.h"
 
 #include "jsatominlines.h"
 
 using namespace js;
 
-static void
-ReportUnwrapDenied(JSContext *cx)
-{
-    JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_UNWRAP_DENIED);
-}
-
 template <class Base>
 bool
 SecurityWrapper<Base>::enter(JSContext* cx, HandleObject wrapper, HandleId id,
                              Wrapper::Action act, bool* bp) const
 {
-    ReportUnwrapDenied(cx);
+    ReportAccessDenied(cx);
     *bp = false;
     return false;
 }
 
 template <class Base>
 bool
 SecurityWrapper<Base>::nativeCall(JSContext* cx, IsAcceptableThis test, NativeImpl impl,
                                   const CallArgs& args) const
 {
-    ReportUnwrapDenied(cx);
+    ReportAccessDenied(cx);
     return false;
 }
 
 template <class Base>
 bool
 SecurityWrapper<Base>::setPrototype(JSContext* cx, HandleObject wrapper, HandleObject proto,
                                     ObjectOpResult& result) const
 {
-    ReportUnwrapDenied(cx);
+    ReportAccessDenied(cx);
     return false;
 }
 
 template <class Base>
 bool
 SecurityWrapper<Base>::setImmutablePrototype(JSContext* cx, HandleObject wrapper,
                                              bool* succeeded) const
 {
-    ReportUnwrapDenied(cx);
+    ReportAccessDenied(cx);
     return false;
 }
 
 template <class Base>
 bool
 SecurityWrapper<Base>::preventExtensions(JSContext* cx, HandleObject wrapper,
                                          ObjectOpResult& result) const
 {
@@ -82,17 +76,17 @@ SecurityWrapper<Base>::getBuiltinClass(J
     *cls = ESClass::Other;
     return true;
 }
 
 template <class Base>
 bool
 SecurityWrapper<Base>::isArray(JSContext* cx, HandleObject obj, JS::IsArrayAnswer* answer) const
 {
-    // This should ReportUnwrapDenied(cx), but bug 849730 disagrees.  :-(
+    // This should ReportAccessDenied(cx), but bug 849730 disagrees.  :-(
     *answer = JS::IsArrayAnswer::NotArray;
     return true;
 }
 
 template <class Base>
 bool
 SecurityWrapper<Base>::regexp_toShared(JSContext* cx, HandleObject obj, RegExpGuard* g) const
 {
@@ -130,24 +124,24 @@ SecurityWrapper<Base>::defineProperty(JS
     return Base::defineProperty(cx, wrapper, id, desc, result);
 }
 
 template <class Base>
 bool
 SecurityWrapper<Base>::watch(JSContext* cx, HandleObject proxy,
                              HandleId id, HandleObject callable) const
 {
-    ReportUnwrapDenied(cx);
+    ReportAccessDenied(cx);
     return false;
 }
 
 template <class Base>
 bool
 SecurityWrapper<Base>::unwatch(JSContext* cx, HandleObject proxy,
                                HandleId id) const
 {
-    ReportUnwrapDenied(cx);
+    ReportAccessDenied(cx);
     return false;
 }
 
 
 template class js::SecurityWrapper<Wrapper>;
 template class js::SecurityWrapper<CrossCompartmentWrapper>;
--- a/js/src/proxy/Wrapper.cpp
+++ b/js/src/proxy/Wrapper.cpp
@@ -377,16 +377,22 @@ js::UnwrapOneChecked(JSObject* obj, bool
     {
         return obj;
     }
 
     const Wrapper* handler = Wrapper::wrapperHandler(obj);
     return handler->hasSecurityPolicy() ? nullptr : Wrapper::wrappedObject(obj);
 }
 
+void
+js::ReportAccessDenied(JSContext* cx)
+{
+    JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_OBJECT_ACCESS_DENIED);
+}
+
 const char Wrapper::family = 0;
 const Wrapper Wrapper::singleton((unsigned)0);
 const Wrapper Wrapper::singletonWithPrototype((unsigned)0, true);
 JSObject* Wrapper::defaultProto = TaggedProto::LazyProto;
 
 /* Compartments. */
 
 JSObject*
--- a/js/src/vm/Debugger.cpp
+++ b/js/src/vm/Debugger.cpp
@@ -3570,17 +3570,17 @@ Debugger::unwrapDebuggeeArgument(JSConte
         if (!unwrapDebuggeeValue(cx, &rv))
             return nullptr;
         obj = &rv.toObject();
     }
 
     /* If we have a cross-compartment wrapper, dereference as far as is secure. */
     obj = CheckedUnwrap(obj);
     if (!obj) {
-        JS_ReportErrorASCII(cx, "Permission denied to access object");
+        ReportAccessDenied(cx);
         return nullptr;
     }
 
     /* If that produced a WindowProxy, get the Window (global). */
     obj = ToWindowIfWindowProxy(obj);
 
     /* If that didn't produce a global object, it's an error. */
     if (!obj->is<GlobalObject>()) {
@@ -8496,31 +8496,31 @@ DebuggerObject_checkThis(JSContext* cx, 
     Debugger* dbg = Debugger::fromChildJSObject(obj);                         \
     obj = (JSObject*) obj->as<NativeObject>().getPrivate();                   \
     MOZ_ASSERT(obj)
 
 #define THIS_DEBUGOBJECT_PROMISE(cx, argc, vp, fnname, args, obj)                   \
    THIS_DEBUGOBJECT_REFERENT(cx, argc, vp, fnname, args, obj);                      \
    obj = CheckedUnwrap(obj);                                                        \
    if (!obj) {                                                                      \
-       JS_ReportErrorASCII(cx, "Permission denied to access object");               \
+       ReportAccessDenied(cx);                                                      \
        return false;                                                                \
    }                                                                                \
    if (!obj->is<PromiseObject>()) {                                                 \
        JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_NOT_EXPECTED_TYPE,\
                                  "Debugger", "Promise", obj->getClass()->name);     \
        return false;                                                                \
    }                                                                                \
    Rooted<PromiseObject*> promise(cx, &obj->as<PromiseObject>());
 
 #define THIS_DEBUGOBJECT_OWNER_PROMISE(cx, argc, vp, fnname, args, dbg, obj)        \
    THIS_DEBUGOBJECT_OWNER_REFERENT(cx, argc, vp, fnname, args, dbg, obj);           \
    obj = CheckedUnwrap(obj);                                                        \
    if (!obj) {                                                                      \
-       JS_ReportErrorASCII(cx, "Permission denied to access object");               \
+       ReportAccessDenied(cx);                                                      \
        return false;                                                                \
    }                                                                                \
    if (!obj->is<PromiseObject>()) {                                                 \
        JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_NOT_EXPECTED_TYPE,\
                                  "Debugger", "Promise", obj->getClass()->name);     \
        return false;                                                                \
    }                                                                                \
    Rooted<PromiseObject*> promise(cx, &obj->as<PromiseObject>());
@@ -9808,17 +9808,17 @@ DebuggerObject::getAllocationSite(JSCont
 /* static */ bool
 DebuggerObject::getErrorReport(JSContext* cx, HandleObject maybeError, JSErrorReport*& report)
 {
     JSObject* obj = maybeError;
     if (IsCrossCompartmentWrapper(obj))
         obj = CheckedUnwrap(obj);
 
     if (!obj) {
-        JS_ReportErrorASCII(cx, "Permission denied to access object");
+        ReportAccessDenied(cx);
         return false;
     }
 
     if (!obj->is<ErrorObject>()) {
         report = nullptr;
         return true;
     }
 
@@ -10382,17 +10382,17 @@ DebuggerObject::requireGlobal(JSContext*
 /* static */ bool
 DebuggerObject::requirePromise(JSContext* cx, HandleDebuggerObject object)
 {
    RootedObject referent(cx, object->referent());
 
    if (IsCrossCompartmentWrapper(referent)) {
        referent = CheckedUnwrap(referent);
        if (!referent) {
-           JS_ReportErrorASCII(cx, "Permission denied to access object");
+           ReportAccessDenied(cx);
            return false;
        }
    }
 
    if (!referent->is<PromiseObject>()) {
       JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_NOT_EXPECTED_TYPE,
                                 "Debugger", "Promise", object->getClass()->name);
       return false;
--- a/js/src/vm/ErrorObject.cpp
+++ b/js/src/vm/ErrorObject.cpp
@@ -172,17 +172,17 @@ FindErrorInstanceOrPrototype(JSContext* 
     // or
     //   function NYI() { }
     //   NYI.prototype = new Error;
     //   (new NYI).stack
     // to continue returning stacks that are useless, but at least don't throw.
 
     RootedObject target(cx, CheckedUnwrap(obj));
     if (!target) {
-        JS_ReportErrorASCII(cx, "Permission denied to access object");
+        ReportAccessDenied(cx);
         return false;
     }
 
     RootedObject proto(cx);
     while (!IsErrorProtoKey(StandardProtoKeyOrNull(target))) {
         if (!GetPrototype(cx, target, &proto))
             return false;
 
@@ -191,17 +191,17 @@ FindErrorInstanceOrPrototype(JSContext* 
             // object.
             JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO,
                                       js_Error_str, "(get stack)", obj->getClass()->name);
             return false;
         }
 
         target = CheckedUnwrap(proto);
         if (!target) {
-            JS_ReportErrorASCII(cx, "Permission denied to access object");
+            ReportAccessDenied(cx);
             return false;
         }
     }
 
     result.set(target);
     return true;
 }
 
--- a/js/src/vm/SelfHosting.cpp
+++ b/js/src/vm/SelfHosting.cpp
@@ -991,17 +991,17 @@ intrinsic_IsWrappedArrayBuffer(JSContext
     JSObject* obj = &args[0].toObject();
     if (!obj->is<WrapperObject>()) {
         args.rval().setBoolean(false);
         return true;
     }
 
     JSObject* unwrapped = CheckedUnwrap(obj);
     if (!unwrapped) {
-        JS_ReportErrorASCII(cx, "Permission denied to access object");
+        ReportAccessDenied(cx);
         return false;
     }
 
     args.rval().setBoolean(unwrapped->is<T>());
     return true;
 }
 
 template<typename T>
@@ -1022,17 +1022,17 @@ template<typename T>
 static bool
 intrinsic_PossiblyWrappedArrayBufferByteLength(JSContext* cx, unsigned argc, Value* vp)
 {
     CallArgs args = CallArgsFromVp(argc, vp);
     MOZ_ASSERT(args.length() == 1);
 
     JSObject* obj = CheckedUnwrap(&args[0].toObject());
     if (!obj) {
-        JS_ReportErrorASCII(cx, "Permission denied to access object");
+        ReportAccessDenied(cx);
         return false;
     }
 
     uint32_t length = obj->as<T>().byteLength();
     args.rval().setInt32(mozilla::AssertedCast<int32_t>(length));
     return true;
 }
 
@@ -1047,17 +1047,17 @@ intrinsic_ArrayBufferCopyData(JSContext*
     Rooted<T*> toBuffer(cx);
     if (!isWrapped) {
         toBuffer = &args[0].toObject().as<T>();
     } else {
         JSObject* wrapped = &args[0].toObject();
         MOZ_ASSERT(wrapped->is<WrapperObject>());
         RootedObject toBufferObj(cx, CheckedUnwrap(wrapped));
         if (!toBufferObj) {
-            JS_ReportErrorASCII(cx, "Permission denied to access object");
+            ReportAccessDenied(cx);
             return false;
         }
         toBuffer = toBufferObj.as<T>();
     }
     Rooted<T*> fromBuffer(cx, &args[1].toObject().as<T>());
     uint32_t fromIndex = uint32_t(args[2].toInt32());
     uint32_t count = uint32_t(args[3].toInt32());
 
@@ -1130,17 +1130,17 @@ intrinsic_IsPossiblyWrappedTypedArray(JS
 {
     CallArgs args = CallArgsFromVp(argc, vp);
     MOZ_ASSERT(args.length() == 1);
 
     bool isTypedArray = false;
     if (args[0].isObject()) {
         JSObject* obj = CheckedUnwrap(&args[0].toObject());
         if (!obj) {
-            JS_ReportErrorASCII(cx, "Permission denied to access object");
+            ReportAccessDenied(cx);
             return false;
         }
 
         isTypedArray = obj->is<TypedArrayObject>();
     }
 
     args.rval().setBoolean(isTypedArray);
     return true;
@@ -1203,17 +1203,17 @@ static bool
 intrinsic_PossiblyWrappedTypedArrayLength(JSContext* cx, unsigned argc, Value* vp)
 {
     CallArgs args = CallArgsFromVp(argc, vp);
     MOZ_ASSERT(args.length() == 1);
     MOZ_ASSERT(args[0].isObject());
 
     JSObject* obj = CheckedUnwrap(&args[0].toObject());
     if (!obj) {
-        JS_ReportErrorASCII(cx, "Permission denied to access object");
+        ReportAccessDenied(cx);
         return false;
     }
 
     MOZ_ASSERT(obj->is<TypedArrayObject>());
     uint32_t typedArrayLength = obj->as<TypedArrayObject>().length();
     args.rval().setInt32(mozilla::AssertedCast<int32_t>(typedArrayLength));
     return true;
 }
@@ -1222,17 +1222,17 @@ static bool
 intrinsic_PossiblyWrappedTypedArrayHasDetachedBuffer(JSContext* cx, unsigned argc, Value* vp)
 {
     CallArgs args = CallArgsFromVp(argc, vp);
     MOZ_ASSERT(args.length() == 1);
     MOZ_ASSERT(args[0].isObject());
 
     JSObject* obj = CheckedUnwrap(&args[0].toObject());
     if (!obj) {
-        JS_ReportErrorASCII(cx, "Permission denied to access object");
+        ReportAccessDenied(cx);
         return false;
     }
 
     MOZ_ASSERT(obj->is<TypedArrayObject>());
     bool detached = obj->as<TypedArrayObject>().hasDetachedBuffer();
     args.rval().setBoolean(detached);
     return true;
 }
--- a/js/src/vm/TypedArrayObject.cpp
+++ b/js/src/vm/TypedArrayObject.cpp
@@ -775,17 +775,17 @@ class TypedArrayObjectTemplate : public 
              * data without crossing compartment boundaries. So we use the
              * machinery underlying NonGenericMethodGuard directly to proxy the
              * native call. We will end up with a wrapper in the origin
              * compartment for a view in the target compartment referencing the
              * ArrayBufferObject in that same compartment.
              */
             JSObject* wrapped = CheckedUnwrap(bufobj);
             if (!wrapped) {
-                JS_ReportErrorASCII(cx, "Permission denied to access object");
+                ReportAccessDenied(cx);
                 return nullptr;
             }
 
             if (!IsAnyArrayBuffer(wrapped)) {
                 JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_TYPED_ARRAY_BAD_ARGS);
                 return nullptr; // must be arrayBuffer
             }
 
@@ -1161,17 +1161,17 @@ TypedArrayObjectTemplate<T>::fromTypedAr
     Rooted<TypedArrayObject*> srcArray(cx);
     if (!isWrapped) {
         srcArray = &other->as<TypedArrayObject>();
         if (!TypedArrayObject::ensureHasBuffer(cx, srcArray))
             return nullptr;
     } else {
         RootedObject unwrapped(cx, CheckedUnwrap(other));
         if (!unwrapped) {
-            JS_ReportErrorASCII(cx, "Permission denied to access object");
+            ReportAccessDenied(cx);
             return nullptr;
         }
 
         JSAutoCompartment ac(cx, unwrapped);
 
         srcArray = &unwrapped->as<TypedArrayObject>();
         if (!TypedArrayObject::ensureHasBuffer(cx, srcArray))
             return nullptr;
@@ -1820,17 +1820,17 @@ DataViewObject::constructSameCompartment
 bool
 DataViewObject::constructWrapped(JSContext* cx, HandleObject bufobj, const CallArgs& args)
 {
     MOZ_ASSERT(args.isConstructing());
     MOZ_ASSERT(bufobj->is<WrapperObject>());
 
     JSObject* unwrapped = CheckedUnwrap(bufobj);
     if (!unwrapped) {
-        JS_ReportErrorASCII(cx, "Permission denied to access object");
+        ReportAccessDenied(cx);
         return false;
     }
 
     // NB: This entails the IsArrayBuffer check
     uint32_t byteOffset, byteLength;
     if (!getAndCheckConstructorArgs(cx, unwrapped, args, &byteOffset, &byteLength))
         return false;
 
--- a/mobile/android/base/java/org/mozilla/gecko/AccountsHelper.java
+++ b/mobile/android/base/java/org/mozilla/gecko/AccountsHelper.java
@@ -47,38 +47,28 @@ public class AccountsHelper implements N
 
     protected final Context mContext;
     protected final GeckoProfile mProfile;
 
     public AccountsHelper(Context context, GeckoProfile profile) {
         mContext = context;
         mProfile = profile;
 
-        EventDispatcher dispatcher = GeckoApp.getEventDispatcher();
-        if (dispatcher == null) {
-            Log.e(LOGTAG, "Gecko event dispatcher must not be null", new RuntimeException());
-            return;
-        }
-        dispatcher.registerGeckoThreadListener(this,
+        EventDispatcher.getInstance().registerGeckoThreadListener(this,
                 "Accounts:CreateFirefoxAccountFromJSON",
                 "Accounts:UpdateFirefoxAccountFromJSON",
                 "Accounts:Create",
                 "Accounts:DeleteFirefoxAccount",
                 "Accounts:Exist",
                 "Accounts:ProfileUpdated",
                 "Accounts:ShowSyncPreferences");
     }
 
     public synchronized void uninit() {
-        EventDispatcher dispatcher = GeckoApp.getEventDispatcher();
-        if (dispatcher == null) {
-            Log.e(LOGTAG, "Gecko event dispatcher must not be null", new RuntimeException());
-            return;
-        }
-        dispatcher.unregisterGeckoThreadListener(this,
+        EventDispatcher.getInstance().unregisterGeckoThreadListener(this,
                 "Accounts:CreateFirefoxAccountFromJSON",
                 "Accounts:UpdateFirefoxAccountFromJSON",
                 "Accounts:Create",
                 "Accounts:DeleteFirefoxAccount",
                 "Accounts:Exist",
                 "Accounts:ProfileUpdated",
                 "Accounts:ShowSyncPreferences");
     }
--- a/mobile/android/base/java/org/mozilla/gecko/FindInPageBar.java
+++ b/mobile/android/base/java/org/mozilla/gecko/FindInPageBar.java
@@ -62,17 +62,17 @@ public class FindInPageBar extends Linea
                 }
                 return false;
             }
         });
 
         mStatusText = (TextView) content.findViewById(R.id.find_status);
 
         mInflated = true;
-        GeckoApp.getEventDispatcher().registerGeckoThreadListener(this,
+        EventDispatcher.getInstance().registerGeckoThreadListener(this,
             "FindInPage:MatchesCountResult",
             "TextSelection:Data");
     }
 
     public void show() {
         if (!mInflated)
             inflateContent();
 
@@ -107,17 +107,17 @@ public class FindInPageBar extends Linea
         Context context = view.getContext();
         return (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
      }
 
     public void onDestroy() {
         if (!mInflated) {
             return;
         }
-        GeckoApp.getEventDispatcher().unregisterGeckoThreadListener(this,
+        EventDispatcher.getInstance().unregisterGeckoThreadListener(this,
             "FindInPage:MatchesCountResult",
             "TextSelection:Data");
     }
 
     private void onMatchesCountResult(final int total, final int current, final int limit, final String searchString) {
         if (total == -1) {
             updateResult(Integer.toString(limit) + "+");
         } else if (total > 0) {
--- a/mobile/android/base/java/org/mozilla/gecko/MediaCastingBar.java
+++ b/mobile/android/base/java/org/mozilla/gecko/MediaCastingBar.java
@@ -27,23 +27,18 @@ public class MediaCastingBar extends Rel
     private ImageButton mMediaPlay;
     private ImageButton mMediaPause;
     private ImageButton mMediaStop;
 
     private boolean mInflated;
 
     public MediaCastingBar(Context context, AttributeSet attrs) {
         super(context, attrs);
-    }
 
-    @Override
-    public void onAttachedToWindow() {
-        super.onAttachedToWindow();
-
-        GeckoApp.getEventDispatcher().registerGeckoThreadListener(this,
+        EventDispatcher.getInstance().registerGeckoThreadListener(this,
             "Casting:Started",
             "Casting:Paused",
             "Casting:Playing",
             "Casting:Stopped");
     }
 
     public void inflateContent() {
         LayoutInflater inflater = LayoutInflater.from(getContext());
@@ -72,27 +67,21 @@ public class MediaCastingBar extends Rel
         setVisibility(VISIBLE);
     }
 
     public void hide() {
         setVisibility(GONE);
     }
 
     public void onDestroy() {
-    }
-
-    @Override
-    public void onDetachedFromWindow() {
-        GeckoApp.getEventDispatcher().unregisterGeckoThreadListener(this,
+        EventDispatcher.getInstance().unregisterGeckoThreadListener(this,
             "Casting:Started",
             "Casting:Paused",
             "Casting:Playing",
             "Casting:Stopped");
-
-        super.onDetachedFromWindow();
     }
 
     // View.OnClickListener implementation
     @Override
     public void onClick(View v) {
         final int viewId = v.getId();
 
         if (viewId == R.id.media_play) {
--- a/mobile/android/base/java/org/mozilla/gecko/MediaPlayerManager.java
+++ b/mobile/android/base/java/org/mozilla/gecko/MediaPlayerManager.java
@@ -71,47 +71,49 @@ public class MediaPlayerManager extends 
         }
     }
 
     protected MediaRouter mediaRouter = null;
     protected final Map<String, GeckoMediaPlayer> players = new HashMap<String, GeckoMediaPlayer>();
     protected final Map<String, GeckoPresentationDisplay> displays = new HashMap<String, GeckoPresentationDisplay>(); // used for Presentation API
 
     @Override
-    public void onStart() {
-        super.onStart();
-        GeckoApp.getEventDispatcher().registerGeckoThreadListener(this,
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        EventDispatcher.getInstance().registerGeckoThreadListener(this,
                                                                   "MediaPlayer:Load",
                                                                   "MediaPlayer:Start",
                                                                   "MediaPlayer:Stop",
                                                                   "MediaPlayer:Play",
                                                                   "MediaPlayer:Pause",
                                                                   "MediaPlayer:End",
                                                                   "MediaPlayer:Mirror",
                                                                   "MediaPlayer:Message",
                                                                   "AndroidCastDevice:Start",
                                                                   "AndroidCastDevice:Stop",
                                                                   "AndroidCastDevice:SyncDevice");
     }
 
     @Override
-    public void onStop() {
-        GeckoApp.getEventDispatcher().unregisterGeckoThreadListener(this,
+    public void onDestroy() {
+        EventDispatcher.getInstance().unregisterGeckoThreadListener(this,
                                                                     "MediaPlayer:Load",
                                                                     "MediaPlayer:Start",
                                                                     "MediaPlayer:Stop",
                                                                     "MediaPlayer:Play",
                                                                     "MediaPlayer:Pause",
                                                                     "MediaPlayer:End",
                                                                     "MediaPlayer:Mirror",
                                                                     "MediaPlayer:Message",
                                                                     "AndroidCastDevice:Start",
                                                                     "AndroidCastDevice:Stop",
                                                                     "AndroidCastDevice:SyncDevice");
-        super.onStop();
+
+        super.onDestroy();
     }
 
     // GeckoEventListener implementation
     @Override
     public void handleMessage(String event, final NativeJSObject message, final EventCallback callback) {
         debug(event);
         if (event.startsWith("MediaPlayer:")) {
             final GeckoMediaPlayer player = players.get(message.getString("id"));
--- a/mobile/android/base/java/org/mozilla/gecko/SharedPreferencesHelper.java
+++ b/mobile/android/base/java/org/mozilla/gecko/SharedPreferencesHelper.java
@@ -59,34 +59,24 @@ public final class SharedPreferencesHelp
     // handleObserve, which is called from Gecko serially.
     protected final Map<String, SharedPreferences.OnSharedPreferenceChangeListener> mListeners;
 
     public SharedPreferencesHelper(Context context) {
         mContext = context;
 
         mListeners = new HashMap<String, SharedPreferences.OnSharedPreferenceChangeListener>();
 
-        EventDispatcher dispatcher = GeckoApp.getEventDispatcher();
-        if (dispatcher == null) {
-            Log.e(LOGTAG, "Gecko event dispatcher must not be null", new RuntimeException());
-            return;
-        }
-        dispatcher.registerGeckoThreadListener(this,
+        EventDispatcher.getInstance().registerGeckoThreadListener(this,
             "SharedPreferences:Set",
             "SharedPreferences:Get",
             "SharedPreferences:Observe");
     }
 
     public synchronized void uninit() {
-        EventDispatcher dispatcher = GeckoApp.getEventDispatcher();
-        if (dispatcher == null) {
-            Log.e(LOGTAG, "Gecko event dispatcher must not be null", new RuntimeException());
-            return;
-        }
-        dispatcher.unregisterGeckoThreadListener(this,
+        EventDispatcher.getInstance().unregisterGeckoThreadListener(this,
             "SharedPreferences:Set",
             "SharedPreferences:Get",
             "SharedPreferences:Observe");
     }
 
     private SharedPreferences getSharedPreferences(JSONObject message) throws JSONException {
         final Scope scope = Scope.forKey(message.getString("scope"));
         switch (scope) {
--- a/mobile/android/base/java/org/mozilla/gecko/ZoomedView.java
+++ b/mobile/android/base/java/org/mozilla/gecko/ZoomedView.java
@@ -235,32 +235,42 @@ public class ZoomedView extends FrameLay
         animationStart = new PointF();
         requestRenderRunnable = new Runnable() {
             @Override
             public void run() {
                 requestZoomedViewRender();
             }
         };
         touchListener = new ZoomedViewTouchListener();
-        GeckoApp.getEventDispatcher().registerGeckoThreadListener(this,
-                "Gesture:clusteredLinksClicked", "Window:Resize", "Content:LocationChange",
-                "Gesture:CloseZoomedView", "Browser:ZoomToPageWidth", "Browser:ZoomToRect",
-                "FormAssist:AutoComplete", "FormAssist:Hide");
+        EventDispatcher.getInstance().registerGeckoThreadListener(this,
+                "Gesture:clusteredLinksClicked",
+                "Window:Resize",
+                "Content:LocationChange",
+                "Gesture:CloseZoomedView",
+                "Browser:ZoomToPageWidth",
+                "Browser:ZoomToRect",
+                "FormAssist:AutoComplete",
+                "FormAssist:Hide");
     }
 
     void destroy() {
         if (prefObserver != null) {
             PrefsHelper.removeObserver(prefObserver);
             prefObserver = null;
         }
         ThreadUtils.removeCallbacksFromUiThread(requestRenderRunnable);
-        GeckoApp.getEventDispatcher().unregisterGeckoThreadListener(this,
-                "Gesture:clusteredLinksClicked", "Window:Resize", "Content:LocationChange",
-                "Gesture:CloseZoomedView", "Browser:ZoomToPageWidth", "Browser:ZoomToRect",
-                "FormAssist:AutoComplete", "FormAssist:Hide");
+        EventDispatcher.getInstance().unregisterGeckoThreadListener(this,
+                "Gesture:clusteredLinksClicked",
+                "Window:Resize",
+                "Content:LocationChange",
+                "Gesture:CloseZoomedView",
+                "Browser:ZoomToPageWidth",
+                "Browser:ZoomToRect",
+                "FormAssist:AutoComplete",
+                "FormAssist:Hide");
     }
 
     // This method (onFinishInflate) is called only when the zoomed view class is used inside
     // an xml structure <org.mozilla.gecko.ZoomedView ...
     // It won't be called if the class is used from java code like "new  ZoomedView(context);"
     @Override
     protected void onFinishInflate() {
         super.onFinishInflate();
--- a/mobile/android/base/java/org/mozilla/gecko/home/BrowserSearch.java
+++ b/mobile/android/base/java/org/mozilla/gecko/home/BrowserSearch.java
@@ -16,17 +16,16 @@ import java.util.List;
 import java.util.Locale;
 
 import android.content.SharedPreferences;
 import org.json.JSONArray;
 import org.json.JSONException;
 import org.json.JSONObject;
 
 import org.mozilla.gecko.EventDispatcher;
-import org.mozilla.gecko.GeckoApp;
 import org.mozilla.gecko.GeckoAppShell;
 import org.mozilla.gecko.GeckoSharedPrefs;
 import org.mozilla.gecko.PrefsHelper;
 import org.mozilla.gecko.R;
 import org.mozilla.gecko.SuggestClient;
 import org.mozilla.gecko.Tab;
 import org.mozilla.gecko.Tabs;
 import org.mozilla.gecko.Telemetry;
@@ -304,17 +303,17 @@ public class BrowserSearch extends HomeF
 
         return mView;
     }
 
     @Override
     public void onDestroyView() {
         super.onDestroyView();
 
-        GeckoApp.getEventDispatcher().unregisterGeckoThreadListener(this,
+        EventDispatcher.getInstance().unregisterGeckoThreadListener(this,
             "SearchEngines:Data");
 
         mSearchEngineBar.setAdapter(null);
         mSearchEngineBar = null;
 
         mList.setAdapter(null);
         mList = null;
 
@@ -404,17 +403,17 @@ public class BrowserSearch extends HomeF
                 if (selected instanceof SearchEngineRow) {
                     return selected.onKeyDown(keyCode, event);
                 }
                 return false;
             }
         });
 
         registerForContextMenu(mList);
-        GeckoApp.getEventDispatcher().registerGeckoThreadListener(this,
+        EventDispatcher.getInstance().registerGeckoThreadListener(this,
             "SearchEngines:Data");
 
         mSearchEngineBar.setOnSearchBarClickListener(this);
     }
 
     @Override
     public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo) {
         if (!(menuInfo instanceof HomeContextMenuInfo)) {
--- a/mobile/android/base/java/org/mozilla/gecko/home/HomeBanner.java
+++ b/mobile/android/base/java/org/mozilla/gecko/home/HomeBanner.java
@@ -1,17 +1,17 @@
 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
 package org.mozilla.gecko.home;
 
 import org.json.JSONObject;
-import org.mozilla.gecko.GeckoApp;
+import org.mozilla.gecko.EventDispatcher;
 import org.mozilla.gecko.GeckoAppShell;
 import org.mozilla.gecko.R;
 import org.mozilla.gecko.animation.PropertyAnimator;
 import org.mozilla.gecko.animation.PropertyAnimator.Property;
 import org.mozilla.gecko.animation.ViewHelper;
 import org.mozilla.gecko.util.FloatUtils;
 import org.mozilla.gecko.util.ResourceDrawableUtils;
 import org.mozilla.gecko.util.GeckoEventListener;
@@ -109,24 +109,24 @@ public class HomeBanner extends LinearLa
             public void onClick(View v) {
                 HomeBanner.this.dismiss();
 
                 // Send the current message id back to JS.
                 GeckoAppShell.notifyObservers("HomeBanner:Click", (String) getTag());
             }
         });
 
-        GeckoApp.getEventDispatcher().registerGeckoThreadListener(this, "HomeBanner:Data");
+        EventDispatcher.getInstance().registerGeckoThreadListener(this, "HomeBanner:Data");
     }
 
     @Override
     public void onDetachedFromWindow() {
         super.onDetachedFromWindow();
 
-        GeckoApp.getEventDispatcher().unregisterGeckoThreadListener(this, "HomeBanner:Data");
+        EventDispatcher.getInstance().unregisterGeckoThreadListener(this, "HomeBanner:Data");
     }
 
     public void setScrollingPages(boolean scrollingPages) {
         mScrollingPages = scrollingPages;
     }
 
     public void setOnDismissListener(OnDismissListener listener) {
         mOnDismissListener = listener;
--- a/mobile/android/base/java/org/mozilla/gecko/home/PanelInfoManager.java
+++ b/mobile/android/base/java/org/mozilla/gecko/home/PanelInfoManager.java
@@ -9,17 +9,16 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Set;
 import java.util.concurrent.atomic.AtomicInteger;
 
 import org.json.JSONArray;
 import org.json.JSONException;
 import org.json.JSONObject;
 import org.mozilla.gecko.EventDispatcher;
-import org.mozilla.gecko.GeckoApp;
 import org.mozilla.gecko.GeckoAppShell;
 import org.mozilla.gecko.home.HomeConfig.PanelConfig;
 import org.mozilla.gecko.util.GeckoEventListener;
 import org.mozilla.gecko.util.ThreadUtils;
 
 import android.util.Log;
 import android.util.SparseArray;
 
@@ -73,17 +72,17 @@ public class PanelInfoManager implements
      * @param callback onComplete will be called on the UI thread.
      */
     public void requestPanelsById(Set<String> ids, RequestCallback callback) {
         final int requestId = sRequestId.getAndIncrement();
 
         synchronized (sCallbacks) {
             // If there are no pending callbacks, register the event listener.
             if (sCallbacks.size() == 0) {
-                GeckoApp.getEventDispatcher().registerGeckoThreadListener(this,
+                EventDispatcher.getInstance().registerGeckoThreadListener(this,
                     "HomePanels:Data");
             }
             sCallbacks.put(requestId, callback);
         }
 
         final JSONObject message = new JSONObject();
         try {
             message.put("requestId", requestId);
@@ -132,17 +131,17 @@ public class PanelInfoManager implements
             final int requestId = message.getInt("requestId");
 
             synchronized (sCallbacks) {
                 callback = sCallbacks.get(requestId);
                 sCallbacks.delete(requestId);
 
                 // Unregister the event listener if there are no more pending callbacks.
                 if (sCallbacks.size() == 0) {
-                    GeckoApp.getEventDispatcher().unregisterGeckoThreadListener(this,
+                    EventDispatcher.getInstance().unregisterGeckoThreadListener(this,
                         "HomePanels:Data");
                 }
             }
 
             ThreadUtils.postToUiThread(new Runnable() {
                 @Override
                 public void run() {
                     callback.onComplete(panelInfos);
--- a/mobile/android/base/java/org/mozilla/gecko/preferences/SearchPreferenceCategory.java
+++ b/mobile/android/base/java/org/mozilla/gecko/preferences/SearchPreferenceCategory.java
@@ -9,17 +9,16 @@ import android.preference.Preference;
 import android.util.AttributeSet;
 import android.util.Log;
 
 import org.json.JSONArray;
 import org.json.JSONException;
 import org.json.JSONObject;
 
 import org.mozilla.gecko.EventDispatcher;
-import org.mozilla.gecko.GeckoApp;
 import org.mozilla.gecko.GeckoAppShell;
 import org.mozilla.gecko.Telemetry;
 import org.mozilla.gecko.TelemetryContract;
 import org.mozilla.gecko.TelemetryContract.Method;
 import org.mozilla.gecko.util.GeckoEventListener;
 import org.mozilla.gecko.util.ThreadUtils;
 
 public class SearchPreferenceCategory extends CustomListCategory implements GeckoEventListener {
@@ -37,25 +36,25 @@ public class SearchPreferenceCategory ex
         super(context, attrs, defStyle);
     }
 
     @Override
     protected void onAttachedToActivity() {
         super.onAttachedToActivity();
 
         // Register for SearchEngines messages and request list of search engines from Gecko.
-        GeckoApp.getEventDispatcher().registerGeckoThreadListener(this, "SearchEngines:Data");
+        EventDispatcher.getInstance().registerGeckoThreadListener(this, "SearchEngines:Data");
         GeckoAppShell.notifyObservers("SearchEngines:GetVisible", null);
     }
 
     @Override
     protected void onPrepareForRemoval() {
         super.onPrepareForRemoval();
 
-        GeckoApp.getEventDispatcher().unregisterGeckoThreadListener(this, "SearchEngines:Data");
+        EventDispatcher.getInstance().unregisterGeckoThreadListener(this, "SearchEngines:Data");
     }
 
     @Override
     public void setDefault(CustomListPreference item) {
         super.setDefault(item);
 
         sendGeckoEngineEvent("SearchEngines:SetDefault", item.getTitle().toString());
 
--- a/mobile/android/base/java/org/mozilla/gecko/reader/ReadingListHelper.java
+++ b/mobile/android/base/java/org/mozilla/gecko/reader/ReadingListHelper.java
@@ -4,17 +4,16 @@
 
 package org.mozilla.gecko.reader;
 
 import org.json.JSONException;
 import org.json.JSONObject;
 
 import org.mozilla.gecko.AboutPages;
 import org.mozilla.gecko.EventDispatcher;
-import org.mozilla.gecko.GeckoApp;
 import org.mozilla.gecko.GeckoAppShell;
 import org.mozilla.gecko.GeckoProfile;
 import org.mozilla.gecko.db.BrowserDB;
 import org.mozilla.gecko.icons.IconRequest;
 import org.mozilla.gecko.icons.Icons;
 import org.mozilla.gecko.util.EventCallback;
 import org.mozilla.gecko.util.NativeEventListener;
 import org.mozilla.gecko.util.NativeJSObject;
@@ -31,22 +30,22 @@ public final class ReadingListHelper imp
 
     protected final Context context;
     private final BrowserDB db;
 
     public ReadingListHelper(Context context, GeckoProfile profile) {
         this.context = context;
         this.db = BrowserDB.from(profile);
 
-        GeckoApp.getEventDispatcher().registerGeckoThreadListener((NativeEventListener) this,
+        EventDispatcher.getInstance().registerGeckoThreadListener((NativeEventListener) this,
             "Reader:FaviconRequest", "Reader:AddedToCache");
     }
 
     public void uninit() {
-        GeckoApp.getEventDispatcher().unregisterGeckoThreadListener((NativeEventListener) this,
+        EventDispatcher.getInstance().unregisterGeckoThreadListener((NativeEventListener) this,
             "Reader:FaviconRequest", "Reader:AddedToCache");
     }
 
     @Override
     public void handleMessage(final String event, final NativeJSObject message,
                               final EventCallback callback) {
         switch (event) {
             case "Reader:FaviconRequest": {
--- a/mobile/android/base/java/org/mozilla/gecko/toolbar/PageActionLayout.java
+++ b/mobile/android/base/java/org/mozilla/gecko/toolbar/PageActionLayout.java
@@ -1,16 +1,16 @@
 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
 package org.mozilla.gecko.toolbar;
 
-import org.mozilla.gecko.GeckoApp;
+import org.mozilla.gecko.EventDispatcher;
 import org.mozilla.gecko.GeckoAppShell;
 import org.mozilla.gecko.R;
 import org.mozilla.gecko.util.ResourceDrawableUtils;
 import org.mozilla.gecko.util.EventCallback;
 import org.mozilla.gecko.util.NativeEventListener;
 import org.mozilla.gecko.util.NativeJSObject;
 import org.mozilla.gecko.util.ThreadUtils;
 import org.mozilla.gecko.widget.GeckoPopupMenu;
@@ -56,24 +56,24 @@ public class PageActionLayout extends Li
         setNumberShown(DEFAULT_PAGE_ACTIONS_SHOWN);
         refreshPageActionIcons();
     }
 
     @Override
     protected void onAttachedToWindow() {
         super.onAttachedToWindow();
 
-        GeckoApp.getEventDispatcher().registerGeckoThreadListener(this,
+        EventDispatcher.getInstance().registerGeckoThreadListener(this,
             "PageActions:Add",
             "PageActions:Remove");
     }
 
     @Override
     protected void onDetachedFromWindow() {
-        GeckoApp.getEventDispatcher().unregisterGeckoThreadListener(this,
+        EventDispatcher.getInstance().unregisterGeckoThreadListener(this,
             "PageActions:Add",
             "PageActions:Remove");
 
         super.onDetachedFromWindow();
     }
 
     private void setNumberShown(int count) {
         ThreadUtils.assertOnUiThread();
--- a/mobile/android/base/java/org/mozilla/gecko/toolbar/SiteIdentityPopup.java
+++ b/mobile/android/base/java/org/mozilla/gecko/toolbar/SiteIdentityPopup.java
@@ -16,17 +16,16 @@ import android.support.v4.widget.TextVie
 import android.widget.ImageView;
 import android.widget.Toast;
 import org.json.JSONException;
 import org.json.JSONArray;
 import org.mozilla.gecko.AboutPages;
 import org.mozilla.gecko.AppConstants;
 import org.mozilla.gecko.EventDispatcher;
 import org.mozilla.gecko.R;
-import org.mozilla.gecko.GeckoApp;
 import org.mozilla.gecko.GeckoAppShell;
 import org.mozilla.gecko.SiteIdentity;
 import org.mozilla.gecko.SiteIdentity.SecurityMode;
 import org.mozilla.gecko.SiteIdentity.MixedMode;
 import org.mozilla.gecko.SiteIdentity.TrackingMode;
 import org.mozilla.gecko.SnackbarBuilder;
 import org.mozilla.gecko.Tab;
 import org.mozilla.gecko.Tabs;
@@ -96,17 +95,17 @@ public class SiteIdentityPopup extends A
         super(context);
 
         mResources = mContext.getResources();
 
         mContentButtonClickListener = new ContentNotificationButtonListener();
     }
 
     void registerListeners() {
-        GeckoApp.getEventDispatcher().registerGeckoThreadListener(this,
+        EventDispatcher.getInstance().registerGeckoThreadListener(this,
                                                                   "Doorhanger:Logins",
                                                                   "Permissions:CheckResult");
     }
 
     @Override
     protected void init() {
         super.init();
 
@@ -556,17 +555,17 @@ public class SiteIdentityPopup extends A
             lastVisibleDoorHanger.hideDivider();
         }
     }
 
     void destroy() {
     }
 
     void unregisterListeners() {
-        GeckoApp.getEventDispatcher().unregisterGeckoThreadListener(this,
+        EventDispatcher.getInstance().unregisterGeckoThreadListener(this,
                                                                     "Doorhanger:Logins",
                                                                     "Permissions:CheckResult");
     }
 
     @Override
     public void dismiss() {
         super.dismiss();
         removeTrackingContentNotification();
--- a/mobile/android/config/mozconfigs/android-api-15-gradle/nightly
+++ b/mobile/android/config/mozconfigs/android-api-15-gradle/nightly
@@ -1,9 +1,10 @@
 . "$topsrcdir/mobile/android/config/mozconfigs/common"
+. "$topsrcdir/build/mozconfig.rust"
 
 ac_add_options --enable-profiling
 
 # Android
 ac_add_options --with-android-min-sdk=15
 ac_add_options --target=arm-linux-androideabi
 
 ac_add_options --with-branding=mobile/android/branding/nightly
--- a/mobile/android/config/mozconfigs/android-api-15/debug
+++ b/mobile/android/config/mozconfigs/android-api-15/debug
@@ -1,9 +1,10 @@
 . "$topsrcdir/mobile/android/config/mozconfigs/common"
+. "$topsrcdir/build/mozconfig.rust"
 
 # Global options
 ac_add_options --enable-debug
 ENABLE_MARIONETTE=1
 
 # Android
 ac_add_options --with-android-min-sdk=15
 ac_add_options --target=arm-linux-androideabi
--- a/mobile/android/config/mozconfigs/android-api-15/l10n-nightly
+++ b/mobile/android/config/mozconfigs/android-api-15/l10n-nightly
@@ -1,9 +1,10 @@
 . "$topsrcdir/mobile/android/config/mozconfigs/common"
+. "$topsrcdir/build/mozconfig.rust"
 
 # L10n
 ac_add_options --with-l10n-base=../../l10n-central
 
 # Global options
 ac_add_options --disable-tests
 
 # Android
--- a/mobile/android/config/mozconfigs/android-api-15/l10n-release
+++ b/mobile/android/config/mozconfigs/android-api-15/l10n-release
@@ -1,9 +1,10 @@
 . "$topsrcdir/mobile/android/config/mozconfigs/common"
+. "$topsrcdir/build/mozconfig.rust"
 
 # L10n
 ac_add_options --with-l10n-base=..
 
 # Global options
 ac_add_options --disable-tests
 
 # Android
--- a/mobile/android/config/mozconfigs/android-api-15/nightly
+++ b/mobile/android/config/mozconfigs/android-api-15/nightly
@@ -1,9 +1,10 @@
 . "$topsrcdir/mobile/android/config/mozconfigs/common"
+. "$topsrcdir/build/mozconfig.rust"
 
 ac_add_options --enable-profiling
 
 # Android
 ac_add_options --with-android-min-sdk=15
 ac_add_options --target=arm-linux-androideabi
 
 ac_add_options --with-branding=mobile/android/branding/nightly
--- a/mobile/android/config/mozconfigs/android-api-15/release
+++ b/mobile/android/config/mozconfigs/android-api-15/release
@@ -1,9 +1,10 @@
 . "$topsrcdir/mobile/android/config/mozconfigs/common"
+. "$topsrcdir/build/mozconfig.rust"
 
 # Android
 ac_add_options --with-android-min-sdk=15
 ac_add_options --target=arm-linux-androideabi
 
 ac_add_options --with-branding=mobile/android/branding/beta
 
 ac_add_options --enable-updater
--- a/mobile/android/config/mozconfigs/android-x86/debug
+++ b/mobile/android/config/mozconfigs/android-x86/debug
@@ -1,9 +1,10 @@
 . "$topsrcdir/mobile/android/config/mozconfigs/common"
+. "$topsrcdir/build/mozconfig.rust"
 
 # Global options
 ac_add_options --enable-debug
 
 # Android
 ac_add_options --target=i386-linux-android
 ac_add_options --with-android-min-sdk=15
 
--- a/mobile/android/config/mozconfigs/android-x86/l10n-nightly
+++ b/mobile/android/config/mozconfigs/android-x86/l10n-nightly
@@ -1,9 +1,10 @@
 . "$topsrcdir/mobile/android/config/mozconfigs/common"
+. "$topsrcdir/build/mozconfig.rust"
 
 # L10n
 ac_add_options --with-l10n-base=../../l10n-central
 
 # Global options
 ac_add_options --disable-tests
 
 # Android
--- a/mobile/android/config/mozconfigs/android-x86/l10n-release
+++ b/mobile/android/config/mozconfigs/android-x86/l10n-release
@@ -1,9 +1,10 @@
 . "$topsrcdir/mobile/android/config/mozconfigs/common"
+. "$topsrcdir/build/mozconfig.rust"
 
 # L10n
 ac_add_options --with-l10n-base=..
 
 # Global options
 ac_add_options --disable-tests
 
 # Android
--- a/mobile/android/config/mozconfigs/android-x86/nightly
+++ b/mobile/android/config/mozconfigs/android-x86/nightly
@@ -1,9 +1,10 @@
 . "$topsrcdir/mobile/android/config/mozconfigs/common"
+. "$topsrcdir/build/mozconfig.rust"
 
 ac_add_options --target=i386-linux-android
 ac_add_options --with-android-min-sdk=15
 
 ac_add_options --enable-profiling
 
 ac_add_options --with-branding=mobile/android/branding/nightly
 
--- a/mobile/android/config/mozconfigs/android-x86/release
+++ b/mobile/android/config/mozconfigs/android-x86/release
@@ -1,9 +1,10 @@
 . "$topsrcdir/mobile/android/config/mozconfigs/common"
+. "$topsrcdir/build/mozconfig.rust"
 
 # Android
 ac_add_options --target=i386-linux-android
 ac_add_options --with-android-min-sdk=15
 
 ac_add_options --enable-updater
 
 ac_add_options --with-branding=mobile/android/branding/beta
--- a/mobile/android/config/mozconfigs/public-partner/distribution_sample/mozconfig1
+++ b/mobile/android/config/mozconfigs/public-partner/distribution_sample/mozconfig1
@@ -1,10 +1,11 @@
 # currently a copy of mobile/android/config/mozconfigs/android-api-15/nightly
 . "$topsrcdir/mobile/android/config/mozconfigs/common"
+. "$topsrcdir/build/mozconfig.rust"
 
 ac_add_options --enable-profiling
 
 # Android
 ac_add_options --with-android-min-sdk=15
 ac_add_options --target=arm-linux-androideabi
 
 ac_add_options --with-branding=mobile/android/branding/nightly
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -602,16 +602,19 @@ pref("media.video-queue.default-size", 1
 
 // The maximum number of queued frames to send to the compositor.
 // By default, send all of them.
 pref("media.video-queue.send-to-compositor-size", 9999);
 
 // Whether to disable the video stats to prevent fingerprinting
 pref("media.video_stats.enabled", true);
 
+// Whether to check the decoder supports recycling.
+pref("media.decoder.recycle.enabled", false);
+
 // Weather we allow AMD switchable graphics
 pref("layers.amd-switchable-gfx.enabled", true);
 
 // Whether to use async panning and zooming
 pref("layers.async-pan-zoom.enabled", true);
 
 // Whether to enable event region building during painting
 pref("layout.event-regions.enabled", false);
--- a/netwerk/streamconv/moz.build
+++ b/netwerk/streamconv/moz.build
@@ -1,16 +1,15 @@
 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # 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/.
 
 DIRS += ['converters']
-TEST_DIRS += ['test']
 
 XPIDL_SOURCES += [
     'mozITXTToHTMLConv.idl',
     'nsIDirIndex.idl',
     'nsIDirIndexListener.idl',
     'nsIStreamConverter.idl',
     'nsIStreamConverterService.idl',
     'nsITXTToHTMLConv.idl',
deleted file mode 100644
--- a/netwerk/streamconv/test/Converters.cpp
+++ /dev/null
@@ -1,140 +0,0 @@
-#include "Converters.h"
-#include "nsIStringStream.h"
-#include "nsCOMPtr.h"
-#include "nsComponentManagerUtils.h"
-
-#include <stdio.h>
-
-//////////////////////////////////////////////////
-// TestConverter
-//////////////////////////////////////////////////
-
-#define NS_TESTCONVERTER_CID                         \
-{ /* B8A067B0-4450-11d3-A16E-0050041CAF44 */         \
-    0xb8a067b0,                                      \
-    0x4450,                                          \
-    0x11d3,                                          \
-    {0xa1, 0x6e, 0x00, 0x50, 0x04, 0x1c, 0xaf, 0x44} \
-}
-
-NS_DEFINE_CID(kTestConverterCID, NS_TESTCONVERTER_CID);
-
-NS_IMPL_ISUPPORTS(TestConverter,
-                  nsIStreamConverter,
-                  nsIStreamListener,
-                  nsIRequestObserver)
-
-TestConverter::TestConverter() {
-}
-
-// Convert aFromStream (of type aFromType), to _retval (nsIInputStream of type aToType).
-// This Convert method simply converts the stream byte-by-byte, to the first character
-// in the aToType "string".
-NS_IMETHODIMP
-TestConverter::Convert(nsIInputStream *aFromStream, 
-                       const char *aFromType, 
-                       const char *aToType, 
-                       nsISupports *ctxt, 
-                       nsIInputStream **_retval) {
-    char buf[1024+1];
-    uint32_t read;
-    nsresult rv = aFromStream->Read(buf, 1024, &read);
-    if (NS_FAILED(rv) || read == 0) return rv;
-
-    // verify that the data we're converting matches the from type
-    // if it doesn't then we're being handed the wrong data.
-    char fromChar = *aFromType;
-
-    if (fromChar != buf[0]) {
-        printf("We're receiving %c, but are supposed to have %c.\n", buf[0], fromChar);
-        return NS_ERROR_FAILURE;
-    }
-
-
-    // Get the first character 
-    char toChar = *aToType;
-
-    for (uint32_t i = 0; i < read; i++) 
-        buf[i] = toChar;
-
-    buf[read] = '\0';
-
-    nsCOMPtr<nsIStringInputStream> str
-      (do_CreateInstance("@mozilla.org/io/string-input-stream;1", &rv));
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    rv = str->SetData(buf, read);
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    NS_ADDREF(*_retval = str);
-    return NS_OK;
-}
-
-/* This method initializes any internal state before the stream converter
- * begins asynchronous conversion */
-NS_IMETHODIMP
-TestConverter::AsyncConvertData(const char *aFromType,
-                                const char *aToType, 
-                                nsIStreamListener *aListener, 
-                                nsISupports *ctxt) {
-    NS_ASSERTION(aListener, "null listener");
-
-    mListener = aListener;
-
-    // based on these types, setup internal state to handle the appropriate conversion.
-    fromType = aFromType;
-    toType = aToType;
-
-    return NS_OK; 
-}
-
-// nsIStreamListener method
-/* This method handles asyncronous conversion of data. */
-NS_IMETHODIMP
-TestConverter::OnDataAvailable(nsIRequest* request,
-                               nsISupports *ctxt, 
-                               nsIInputStream *inStr, 
-                               uint64_t sourceOffset, 
-                               uint32_t count) {
-    nsresult rv;
-    nsCOMPtr<nsIInputStream> convertedStream;
-    // just make a syncronous call to the Convert() method.
-    // Anything can happen here, I just happen to be using the sync call to 
-    // do the actual conversion.
-    rv = Convert(inStr, fromType.get(), toType.get(), ctxt, getter_AddRefs(convertedStream));
-    if (NS_FAILED(rv)) return rv;
-
-    uint64_t len = 0;
-    convertedStream->Available(&len);
-
-    uint64_t offset = sourceOffset;
-    while (len > 0) {
-        uint32_t count = saturated(len);
-        rv = mListener->OnDataAvailable(request, ctxt, convertedStream, offset, count);
-        if (NS_FAILED(rv)) return rv;
-
-        offset += count;
-        len -= count;
-    }
-    return NS_OK;
-}
-
-// nsIRequestObserver methods
-/* These methods just pass through directly to the mListener */
-NS_IMETHODIMP
-TestConverter::OnStartRequest(nsIRequest* request, nsISupports *ctxt) {
-    return mListener->OnStartRequest(request, ctxt);
-}
-
-NS_IMETHODIMP
-TestConverter::OnStopRequest(nsIRequest* request, nsISupports *ctxt, 
-                             nsresult aStatus) {
-    return mListener->OnStopRequest(request, ctxt, aStatus);
-}
-
-nsresult
-CreateTestConverter(nsISupports* aOuter, REFNSIID aIID, void** aResult)
-{
-  nsCOMPtr<nsISupports> conv = new TestConverter();
-  return conv->QueryInterface(aIID, aResult);
-}
deleted file mode 100644
--- a/netwerk/streamconv/test/Converters.h
+++ /dev/null
@@ -1,52 +0,0 @@
-#ifndef Converters_h___
-#define Converters_h___
-
-#include "nsIStreamConverter.h"
-#include "nsIFactory.h"
-#include "nsCOMPtr.h"
-#include "nsStringAPI.h"
-
-#include <algorithm>
-
-/* This file defines stream converter components, and their accompanying factory class.
- * These converters implement the nsIStreamConverter interface and support both
- * asynchronous and synchronous stream conversion.
- */
-
-///////////////////////////////////////////////
-// TestConverter
-
-extern const nsCID kTestConverterCID;
-
-class TestConverter : public nsIStreamConverter {
-    virtual ~TestConverter() {}
-public:
-    NS_DECL_ISUPPORTS
-    NS_DECL_NSIREQUESTOBSERVER
-    NS_DECL_NSISTREAMLISTENER
-
-    TestConverter();
-
-    // nsIStreamConverter methods
-    NS_IMETHOD Convert(nsIInputStream *aFromStream, const char *aFromType, 
-                       const char *aToType, nsISupports *ctxt, nsIInputStream **_retval) override;
-
-
-    NS_IMETHOD AsyncConvertData(const char *aFromType, const char *aToType, 
-                                nsIStreamListener *aListener, nsISupports *ctxt) override;
-
-    // member data
-    nsCOMPtr<nsIStreamListener> mListener;
-    nsCString fromType;
-    nsCString toType;
-};
-
-nsresult CreateTestConverter(nsISupports* aOuter, REFNSIID aIID, void** aResult);
-
-static inline uint32_t
-saturated(uint64_t aValue)
-{
-    return (uint32_t) std::min(aValue, (uint64_t) UINT32_MAX);
-}
-
-#endif /* !Converters_h___ */
deleted file mode 100644
--- a/netwerk/streamconv/test/TestStreamConv.cpp
+++ /dev/null
@@ -1,261 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * 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/. */
-
-#include "nsIServiceManager.h"
-#include "nsIStreamConverterService.h"
-#include "nsIStreamConverter.h"
-#include "nsICategoryManager.h"
-#include "mozilla/Module.h"
-#include "nsXULAppAPI.h"
-#include "nsIStringStream.h"
-#include "nsCOMPtr.h"
-#include "nsThreadUtils.h"
-#include "mozilla/Attributes.h"
-#include "nsMemory.h"
-#include "nsServiceManagerUtils.h"
-#include "nsComponentManagerUtils.h"
-#include "nsIRequest.h"
-#include "nsNetCID.h"
-#include "nsNetUtil.h"
-
-#define ASYNC_TEST // undefine this if you want to test sycnronous conversion.
-
-/////////////////////////////////
-// Event pump setup
-/////////////////////////////////
-#ifdef XP_WIN
-#include <windows.h>
-#endif
-
-static int gKeepRunning = 0;
-/////////////////////////////////
-// Event pump END
-/////////////////////////////////
-
-
-/////////////////////////////////
-// Test converters include
-/////////////////////////////////
-#include "Converters.h"
-
-// CID setup
-static NS_DEFINE_CID(kStreamConverterServiceCID, NS_STREAMCONVERTERSERVICE_CID);
-
-////////////////////////////////////////////////////////////////////////
-// EndListener - This listener is the final one in the chain. It
-//   receives the fully converted data, although it doesn't do anything with
-//   the data.
-////////////////////////////////////////////////////////////////////////
-class EndListener final : public nsIStreamListener {
-    ~EndListener() {}
-public:
-    // nsISupports declaration
-    NS_DECL_ISUPPORTS
-
-    EndListener() {}
-
-    // nsIStreamListener method
-    NS_IMETHOD OnDataAvailable(nsIRequest* request, nsISupports *ctxt, nsIInputStream *inStr, 
-                               uint64_t sourceOffset, uint32_t count) override
-    {
-        nsresult rv;
-        uint32_t read;
-        uint64_t len64;
-        rv = inStr->Available(&len64);
-        if (NS_FAILED(rv)) return rv;
-        uint32_t len = (uint32_t)std::min(len64, (uint64_t)(UINT32_MAX - 1));
-
-        char *buffer = (char*)moz_xmalloc(len + 1);
-        if (!buffer) return NS_ERROR_OUT_OF_MEMORY;
-
-        rv = inStr->Read(buffer, len, &read);
-        buffer[len] = '\0';
-        if (NS_SUCCEEDED(rv)) {
-            printf("CONTEXT %p: Received %u bytes and the following data: \n %s\n\n",
-                   static_cast<void*>(ctxt), read, buffer);
-        }
-        free(buffer);
-
-        return NS_OK;
-    }
-
-    // nsIRequestObserver methods
-    NS_IMETHOD OnStartRequest(nsIRequest* request, nsISupports *ctxt) override { return NS_OK; }
-
-    NS_IMETHOD OnStopRequest(nsIRequest* request, nsISupports *ctxt, 
-                             nsresult aStatus) override { return NS_OK; }
-};
-
-NS_IMPL_ISUPPORTS(EndListener,
-                  nsIStreamListener,
-                  nsIRequestObserver)
-
-////////////////////////////////////////////////////////////////////////
-// EndListener END
-////////////////////////////////////////////////////////////////////////
-
-nsresult SendData(const char * aData, nsIStreamListener* aListener, nsIRequest* request) {
-    nsresult rv;
-
-    nsCOMPtr<nsIStringInputStream> dataStream
-      (do_CreateInstance("@mozilla.org/io/string-input-stream;1", &rv));
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    rv = dataStream->SetData(aData, strlen(aData));
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    uint64_t avail = 0;
-    dataStream->Available(&avail);
-
-    uint64_t offset = 0;
-    while (avail > 0) {
-        uint32_t count = saturated(avail);
-        rv = aListener->OnDataAvailable(request, nullptr, dataStream,
-                                        offset, count);
-        if (NS_FAILED(rv)) return rv;
-
-        offset += count;
-        avail -= count;
-    }
-    return NS_OK;
-}
-#define SEND_DATA(x) SendData(x, converterListener, request)
-
-static const mozilla::Module::CIDEntry kTestCIDs[] = {
-    { &kTestConverterCID, false, nullptr, CreateTestConverter },
-    { nullptr }
-};
-
-static const mozilla::Module::ContractIDEntry kTestContracts[] = {
-    { NS_ISTREAMCONVERTER_KEY "?from=a/foo&to=b/foo", &kTestConverterCID },
-    { NS_ISTREAMCONVERTER_KEY "?from=b/foo&to=c/foo", &kTestConverterCID },
-    { NS_ISTREAMCONVERTER_KEY "?from=b/foo&to=d/foo", &kTestConverterCID },
-    { NS_ISTREAMCONVERTER_KEY "?from=c/foo&to=d/foo", &kTestConverterCID },
-    { NS_ISTREAMCONVERTER_KEY "?from=d/foo&to=e/foo", &kTestConverterCID },
-    { NS_ISTREAMCONVERTER_KEY "?from=d/foo&to=f/foo", &kTestConverterCID },
-    { NS_ISTREAMCONVERTER_KEY "?from=t/foo&to=k/foo", &kTestConverterCID },
-    { nullptr }
-};
-
-static const mozilla::Module::CategoryEntry kTestCategories[] = {
-    { NS_ISTREAMCONVERTER_KEY, "?from=a/foo&to=b/foo", "x" },
-    { NS_ISTREAMCONVERTER_KEY, "?from=b/foo&to=c/foo", "x" },
-    { NS_ISTREAMCONVERTER_KEY, "?from=b/foo&to=d/foo", "x" },
-    { NS_ISTREAMCONVERTER_KEY, "?from=c/foo&to=d/foo", "x" },
-    { NS_ISTREAMCONVERTER_KEY, "?from=d/foo&to=e/foo", "x" },
-    { NS_ISTREAMCONVERTER_KEY, "?from=d/foo&to=f/foo", "x" },
-    { NS_ISTREAMCONVERTER_KEY, "?from=t/foo&to=k/foo", "x" },
-    { nullptr }
-};
-
-static const mozilla::Module kTestModule = {
-    mozilla::Module::kVersion,
-    kTestCIDs,
-    kTestContracts,
-    kTestCategories
-};
-
-int
-main(int argc, char* argv[])
-{
-    nsresult rv;
-    {
-        XRE_AddStaticComponent(&kTestModule);
-
-        nsCOMPtr<nsIServiceManager> servMan;
-        NS_InitXPCOM2(getter_AddRefs(servMan), nullptr, nullptr);
-    
-        nsCOMPtr<nsIThread> thread = do_GetCurrentThread();
-
-        nsCOMPtr<nsICategoryManager> catman =
-            do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
-        if (NS_FAILED(rv)) return -1;
-        nsCString previous;
-
-        nsCOMPtr<nsIStreamConverterService> StreamConvService =
-                 do_GetService(kStreamConverterServiceCID, &rv);
-        if (NS_FAILED(rv)) return -1;
-
-        // Define the *from* content type and *to* content-type for conversion.
-        static const char fromStr[] = "a/foo";
-        static const char toStr[] = "c/foo";
-    
-#ifdef ASYNC_TEST
-        // ASYNCHRONOUS conversion
-
-        // Build up a channel that represents the content we're
-        // starting the transaction with.
-        //
-        // sample multipart mixed content-type string:
-        // "multipart/x-mixed-replacE;boundary=thisrandomstring"
-#if 0
-        nsCOMPtr<nsIChannel> channel;
-        nsCOMPtr<nsIURI> dummyURI;
-        rv = NS_NewURI(getter_AddRefs(dummyURI), "http://meaningless");
-        if (NS_FAILED(rv)) return -1;
-
-        rv = NS_NewInputStreamChannel(getter_AddRefs(channel),
-                                      dummyURI,
-                                      nullptr,   // inStr
-                                      "text/plain", // content-type
-                                      -1);      // XXX fix contentLength
-        if (NS_FAILED(rv)) return -1;
-
-        nsCOMPtr<nsIRequest> request(do_QueryInterface(channel));
-#endif
-
-        nsCOMPtr<nsIRequest> request;
-
-        // setup a listener to receive the converted data. This guy is the end
-        // listener in the chain, he wants the fully converted (toType) data.
-        // An example of this listener in mozilla would be the DocLoader.
-        nsIStreamListener *dataReceiver = new EndListener();
-        NS_ADDREF(dataReceiver);
-
-        // setup a listener to push the data into. This listener sits inbetween the
-        // unconverted data of fromType, and the final listener in the chain (in this case
-        // the dataReceiver.
-        nsIStreamListener *converterListener = nullptr;
-        rv = StreamConvService->AsyncConvertData(fromStr, toStr,
-                                                 dataReceiver, nullptr, &converterListener);
-        if (NS_FAILED(rv)) return -1;
-        NS_RELEASE(dataReceiver);
-
-        // at this point we have a stream listener to push data to, and the one
-        // that will receive the converted data. Let's mimic On*() calls and get the conversion
-        // going. Typically these On*() calls would be made inside their respective wrappers On*()
-        // methods.
-        rv = converterListener->OnStartRequest(request, nullptr);
-        if (NS_FAILED(rv)) return -1;
-
-        rv = SEND_DATA("aaa");
-        if (NS_FAILED(rv)) return -1;
-
-        rv = SEND_DATA("aaa");
-        if (NS_FAILED(rv)) return -1;
-
-        // Finish the request.
-        rv = converterListener->OnStopRequest(request, nullptr, rv);
-        if (NS_FAILED(rv)) return -1;
-
-        NS_RELEASE(converterListener);
-#else
-        // SYNCHRONOUS conversion
-        nsCOMPtr<nsIInputStream> convertedData;
-        rv = StreamConvService->Convert(inputData, fromStr, toStr,
-                                        nullptr, getter_AddRefs(convertedData));
-        if (NS_FAILED(rv)) return -1;
-#endif
-
-        // Enter the message pump to allow the URL load to proceed.
-        while ( gKeepRunning ) {
-            if (!NS_ProcessNextEvent(thread))
-                break;
-        }
-    } // this scopes the nsCOMPtrs
-    // no nsCOMPtrs are allowed to be alive when you call NS_ShutdownXPCOM
-    NS_ShutdownXPCOM(nullptr);
-    return 0;
-}
deleted file mode 100644
--- a/netwerk/streamconv/test/moz.build
+++ /dev/null
@@ -1,22 +0,0 @@
-# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
-# vim: set filetype=python:
-# This Source Code Form is subject to the terms of the Mozilla Public
-# 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/.
-
-GeckoProgram('TestStreamConv', linkage='dependent')
-
-UNIFIED_SOURCES += [
-    'Converters.cpp',
-    'TestStreamConv.cpp',
-]
-
-if CONFIG['OS_ARCH'] == 'WINNT':
-    DEFINES['NGPREFS'] = True
-    if CONFIG['GNU_CXX']:
-        LDFLAGS += ['-mconsole']
-    else:
-        LDFLAGS += ['-SUBSYSTEM:CONSOLE']
-
-if CONFIG['GNU_CXX']:
-    CXXFLAGS += ['-Wno-error=shadow']
deleted file mode 100644
--- a/netwerk/test/PropertiesTest.cpp
+++ /dev/null
@@ -1,131 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * 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/. */
-
-#include "TestCommon.h"
-#include "mozilla/Sprintf.h"
-#include "nsXPCOM.h"
-#include "nsStringAPI.h"
-#include "nsIPersistentProperties2.h"
-#include "nsIServiceManager.h"
-#include "nsIComponentRegistrar.h"
-#include "nsIURL.h"
-#include "nsNetCID.h"
-#include "nsIChannel.h"
-#include "nsIComponentManager.h"
-#include <stdio.h>
-#include "nsComponentManagerUtils.h"
-#include "nsServiceManagerUtils.h"
-#include "nsISimpleEnumerator.h"
-#include "nsIScriptSecurityManager.h"
-#include "nsILoadInfo.h"
-#include "nsNetUtil.h"
-
-#define TEST_URL "resource:/res/test.properties"
-static NS_DEFINE_CID(kPersistentPropertiesCID, NS_IPERSISTENTPROPERTIES_CID);
-
-/***************************************************************************/
-
-int
-main(int argc, char* argv[])
-{
-  if (test_common_init(&argc, &argv) != 0)
-    return -1;
-
-  nsresult ret;
-
-  nsCOMPtr<nsIServiceManager> servMan;
-  NS_InitXPCOM2(getter_AddRefs(servMan), nullptr, nullptr);
-
-  nsIInputStream* in = nullptr;
-
-  nsCOMPtr<nsIScriptSecurityManager> secman =
-    do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &ret);
-  if (NS_FAILED(ret)) return 1;
-  nsCOMPtr<nsIPrincipal> systemPrincipal;
-    ret = secman->GetSystemPrincipal(getter_AddRefs(systemPrincipal));
-   if (NS_FAILED(ret)) return 1;
-
-  nsCOMPtr<nsIURI> uri;
-  ret = NS_NewURI(getter_AddRefs(uri), NS_LITERAL_CSTRING(TEST_URL));
-  if (NS_FAILED(ret)) return 1;
-
-  nsIChannel *channel = nullptr;
-  ret = NS_NewChannel(&channel,
-                      uri,
-                      systemPrincipal,
-                      nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
-                      nsIContentPolicy::TYPE_OTHER);
-  if (NS_FAILED(ret)) return 1;
-
-  ret = channel->Open2(&in);
-  if (NS_FAILED(ret)) return 1;
-
-  nsIPersistentProperties* props;
-  ret = CallCreateInstance(kPersistentPropertiesCID, &props);
-  if (NS_FAILED(ret) || (!props)) {
-    printf("create nsIPersistentProperties failed\n");
-    return 1;
-  }
-  ret = props->Load(in);
-  if (NS_FAILED(ret)) {
-    printf("cannot load properties\n");
-    return 1;
-  }
-  int i = 1;
-  while (true) {
-    char name[16];
-    name[0] = 0;
-    SprintfLiteral(name, "%d", i);
-    nsAutoString v;
-    ret = props->GetStringProperty(nsDependentCString(name), v);
-    if (NS_FAILED(ret) || (!v.Length())) {
-      break;
-    }
-    printf("\"%d\"=\"%s\"\n", i, NS_ConvertUTF16toUTF8(v).get());
-    i++;
-  }
-
-  nsCOMPtr<nsISimpleEnumerator> propEnum;
-  ret = props->Enumerate(getter_AddRefs(propEnum));
-
-  if (NS_FAILED(ret)) {
-    printf("cannot enumerate properties\n");
-    return 1;
-  }
-  
-
-  printf("\nKey\tValue\n");
-  printf(  "---\t-----\n");
-  
-  bool hasMore;
-  while (NS_SUCCEEDED(propEnum->HasMoreElements(&hasMore)) &&
-         hasMore) {
-    nsCOMPtr<nsISupports> sup;
-    ret = propEnum->GetNext(getter_AddRefs(sup));
-    
-    nsCOMPtr<nsIPropertyElement> propElem = do_QueryInterface(sup, &ret);
-	  if (NS_FAILED(ret)) {
-      printf("failed to get current item\n");
-      return 1;
-	  }
-
-    nsAutoCString key;
-    nsAutoString value;
-
-    ret = propElem->GetKey(key);
-	  if (NS_FAILED(ret)) {
-		  printf("failed to get current element's key\n");
-		  return 1;
-	  }
-    ret = propElem->GetValue(value);
-	  if (NS_FAILED(ret)) {
-		  printf("failed to get current element's value\n");
-		  return 1;
-	  }
-
-    printf("%s\t%s\n", key.get(), NS_ConvertUTF16toUTF8(value).get());
-  }
-  return 0;
-}
deleted file mode 100644
--- a/netwerk/test/ReadNTLM.cpp
+++ /dev/null
@@ -1,325 +0,0 @@
-/* vim: set ts=2 sw=2 et cindent: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * 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/. */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <ctype.h>
-
-#include "plbase64.h"
-#include "nsStringAPI.h"
-#include "prmem.h"
-
-/*
- * ReadNTLM : reads NTLM messages.
- *
- * based on http://davenport.sourceforge.net/ntlm.html
- */
-
-#define kNegotiateUnicode               0x00000001
-#define kNegotiateOEM                   0x00000002
-#define kRequestTarget                  0x00000004
-#define kUnknown1                       0x00000008
-#define kNegotiateSign                  0x00000010
-#define kNegotiateSeal                  0x00000020
-#define kNegotiateDatagramStyle         0x00000040
-#define kNegotiateLanManagerKey         0x00000080
-#define kNegotiateNetware               0x00000100
-#define kNegotiateNTLMKey               0x00000200
-#define kUnknown2                       0x00000400
-#define kUnknown3                       0x00000800
-#define kNegotiateDomainSupplied        0x00001000
-#define kNegotiateWorkstationSupplied   0x00002000
-#define kNegotiateLocalCall             0x00004000
-#define kNegotiateAlwaysSign            0x00008000
-#define kTargetTypeDomain               0x00010000
-#define kTargetTypeServer               0x00020000
-#define kTargetTypeShare                0x00040000
-#define kNegotiateNTLM2Key              0x00080000
-#define kRequestInitResponse            0x00100000
-#define kRequestAcceptResponse          0x00200000
-#define kRequestNonNTSessionKey         0x00400000
-#define kNegotiateTargetInfo            0x00800000
-#define kUnknown4                       0x01000000
-#define kUnknown5                       0x02000000
-#define kUnknown6                       0x04000000
-#define kUnknown7                       0x08000000
-#define kUnknown8                       0x10000000
-#define kNegotiate128                   0x20000000
-#define kNegotiateKeyExchange           0x40000000
-#define kNegotiate56                    0x80000000
-
-static const char NTLM_SIGNATURE[] = "NTLMSSP";
-static const char NTLM_TYPE1_MARKER[] = { 0x01, 0x00, 0x00, 0x00 };
-static const char NTLM_TYPE2_MARKER[] = { 0x02, 0x00, 0x00, 0x00 };
-static const char NTLM_TYPE3_MARKER[] = { 0x03, 0x00, 0x00, 0x00 };
-
-#define NTLM_MARKER_LEN 4
-#define NTLM_TYPE1_HEADER_LEN 32
-#define NTLM_TYPE2_HEADER_LEN 32
-#define NTLM_TYPE3_HEADER_LEN 64
-
-#define LM_HASH_LEN 16
-#define LM_RESP_LEN 24
-
-#define NTLM_HASH_LEN 16
-#define NTLM_RESP_LEN 24
-
-static void PrintFlags(uint32_t flags)
-{
-#define TEST(_flag) \
-  if (flags & k ## _flag) \
-    printf("    0x%08x (" # _flag ")\n", k ## _flag)
-
-  TEST(NegotiateUnicode);
-  TEST(NegotiateOEM);
-  TEST(RequestTarget);
-  TEST(Unknown1);
-  TEST(NegotiateSign);
-  TEST(NegotiateSeal);
-  TEST(NegotiateDatagramStyle);
-  TEST(NegotiateLanManagerKey);
-  TEST(NegotiateNetware);
-  TEST(NegotiateNTLMKey);
-  TEST(Unknown2);
-  TEST(Unknown3);
-  TEST(NegotiateDomainSupplied);
-  TEST(NegotiateWorkstationSupplied);
-  TEST(NegotiateLocalCall);
-  TEST(NegotiateAlwaysSign);
-  TEST(TargetTypeDomain);
-  TEST(TargetTypeServer);
-  TEST(TargetTypeShare);
-  TEST(NegotiateNTLM2Key);
-  TEST(RequestInitResponse);
-  TEST(RequestAcceptResponse);
-  TEST(RequestNonNTSessionKey);
-  TEST(NegotiateTargetInfo);
-  TEST(Unknown4);
-  TEST(Unknown5);
-  TEST(Unknown6);
-  TEST(Unknown7);
-  TEST(Unknown8);
-  TEST(Negotiate128);
-  TEST(NegotiateKeyExchange);
-  TEST(Negotiate56);
-
-#undef TEST
-}
-
-static void
-PrintBuf(const char *tag, const uint8_t *buf, uint32_t bufLen)
-{
-  int i;
-
-  printf("%s =\n", tag);
-  while (bufLen > 0)
-  {
-    int count = bufLen;
-    if (count > 8)
-      count = 8;
-
-    printf("    ");
-    for (i=0; i<count; ++i)
-    {
-      printf("0x%02x ", int(buf[i]));
-    }
-    for (; i<8; ++i)
-    {
-      printf("     ");
-    }
-
-    printf("   ");
-    for (i=0; i<count; ++i)
-    {
-      if (isprint(buf[i]))
-        printf("%c", buf[i]);
-      else
-        printf(".");
-    }
-    printf("\n");
-
-    bufLen -= count;
-    buf += count;
-  }
-}
-
-static uint16_t
-ReadUint16(const uint8_t *&buf)
-{
-  uint16_t x;
-#ifdef IS_BIG_ENDIAN
-  x = ((uint16_t) buf[1]) | ((uint16_t) buf[0] << 8);
-#else
-  x = ((uint16_t) buf[0]) | ((uint16_t) buf[1] << 8);
-#endif
-  buf += sizeof(x);
-  return x;
-}
-
-static uint32_t
-ReadUint32(const uint8_t *&buf)
-{
-  uint32_t x;
-#ifdef IS_BIG_ENDIAN
-  x = ( (uint32_t) buf[3])        |
-      (((uint32_t) buf[2]) << 8)  |
-      (((uint32_t) buf[1]) << 16) |
-      (((uint32_t) buf[0]) << 24);
-#else
-  x = ( (uint32_t) buf[0])        |
-      (((uint32_t) buf[1]) << 8)  |
-      (((uint32_t) buf[2]) << 16) |
-      (((uint32_t) buf[3]) << 24);
-#endif
-  buf += sizeof(x);
-  return x;
-}
-
-typedef struct {
-  uint16_t length;
-  uint16_t capacity;
-  uint32_t offset;
-} SecBuf;
-
-static void
-ReadSecBuf(SecBuf *s, const uint8_t *&buf)
-{
-  s->length = ReadUint16(buf);
-  s->capacity = ReadUint16(buf);
-  s->offset = ReadUint32(buf);
-}
-
-static void
-ReadType1MsgBody(const uint8_t *inBuf, uint32_t start)
-{
-  const uint8_t *cursor = inBuf + start;
-  uint32_t flags;
-
-  PrintBuf("flags", cursor, 4);
-  // read flags
-  flags = ReadUint32(cursor);
-  PrintFlags(flags);
-
-  // type 1 message may not include trailing security buffers
-  if ((flags & kNegotiateDomainSupplied) | 
-      (flags & kNegotiateWorkstationSupplied))
-  {
-    SecBuf secbuf;
-    ReadSecBuf(&secbuf, cursor);
-    PrintBuf("supplied domain", inBuf + secbuf.offset, secbuf.length);
-
-    ReadSecBuf(&secbuf, cursor);
-    PrintBuf("supplied workstation", inBuf + secbuf.offset, secbuf.length);
-  }
-}
-
-static void
-ReadType2MsgBody(const uint8_t *inBuf, uint32_t start)
-{
-  uint16_t targetLen, offset;
-  uint32_t flags;
-  const uint8_t *target;
-  const uint8_t *cursor = inBuf + start;
-
-  // read target name security buffer
-  targetLen = ReadUint16(cursor);
-  ReadUint16(cursor); // discard next 16-bit value
-  offset = ReadUint32(cursor); // get offset from inBuf
-  target = inBuf + offset;
-
-  PrintBuf("target", target, targetLen);
-
-  PrintBuf("flags", cursor, 4);
-  // read flags
-  flags = ReadUint32(cursor);
-  PrintFlags(flags);
-
-  // read challenge
-  PrintBuf("challenge", cursor, 8);
-  cursor += 8;
-
-  PrintBuf("context", cursor, 8);
-  cursor += 8;
-
-  SecBuf secbuf;
-  ReadSecBuf(&secbuf, cursor);
-  PrintBuf("target information", inBuf + secbuf.offset, secbuf.length);
-}
-
-static void
-ReadType3MsgBody(const uint8_t *inBuf, uint32_t start)
-{
-  const uint8_t *cursor = inBuf + start;
-
-  SecBuf secbuf;
-
-  ReadSecBuf(&secbuf, cursor); // LM response
-  PrintBuf("LM response", inBuf + secbuf.offset, secbuf.length);
-
-  ReadSecBuf(&secbuf, cursor); // NTLM response
-  PrintBuf("NTLM response", inBuf + secbuf.offset, secbuf.length);
-
-  ReadSecBuf(&secbuf, cursor); // domain name
-  PrintBuf("domain name", inBuf + secbuf.offset, secbuf.length);
-
-  ReadSecBuf(&secbuf, cursor); // user name
-  PrintBuf("user name", inBuf + secbuf.offset, secbuf.length);
-
-  ReadSecBuf(&secbuf, cursor); // workstation name
-  PrintBuf("workstation name", inBuf + secbuf.offset, secbuf.length);
-
-  ReadSecBuf(&secbuf, cursor); // session key
-  PrintBuf("session key", inBuf + secbuf.offset, secbuf.length);
-
-  uint32_t flags = ReadUint32(cursor);
-  PrintBuf("flags", (const uint8_t *) &flags, sizeof(flags));
-  PrintFlags(flags);
-}
-
-static void
-ReadMsg(const char *base64buf, uint32_t bufLen)
-{
-  uint8_t *inBuf = (uint8_t *) PL_Base64Decode(base64buf, bufLen, nullptr);
-  if (!inBuf)
-  {
-    printf("PL_Base64Decode failed\n");
-    return;
-  }
-
-  const uint8_t *cursor = inBuf;
-
-  PrintBuf("signature", cursor, 8);
-
-  // verify NTLMSSP signature
-  if (memcmp(cursor, NTLM_SIGNATURE, sizeof(NTLM_SIGNATURE)) != 0)
-  {
-    printf("### invalid or corrupt NTLM signature\n");
-  }
-  cursor += sizeof(NTLM_SIGNATURE);
-
-  PrintBuf("message type", cursor, 4);
-
-  if (memcmp(cursor, NTLM_TYPE1_MARKER, sizeof(NTLM_MARKER_LEN)) == 0)
-    ReadType1MsgBody(inBuf, 12);
-  else if (memcmp(cursor, NTLM_TYPE2_MARKER, sizeof(NTLM_MARKER_LEN)) == 0)
-    ReadType2MsgBody(inBuf, 12);
-  else if (memcmp(cursor, NTLM_TYPE3_MARKER, sizeof(NTLM_MARKER_LEN)) == 0)
-    ReadType3MsgBody(inBuf, 12);
-  else
-    printf("### invalid or unknown message type\n"); 
-
-  PR_Free(inBuf);
-}
-
-int main(int argc, char **argv)
-{
-  if (argc == 1)
-  {
-    printf("usage: ntlmread <msg>\n");
-    return -1;
-  }
-  ReadMsg(argv[1], (uint32_t) strlen(argv[1]));
-  return 0;
-}
--- a/netwerk/test/TestBind.cpp
+++ b/netwerk/test/TestBind.cpp
@@ -1,210 +1,186 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
 #include "TestCommon.h"
-#include "TestHarness.h"
+#include "gtest/gtest.h"
 #include "nsISocketTransportService.h"
 #include "nsISocketTransport.h"
 #include "nsIServerSocket.h"
 #include "nsIAsyncInputStream.h"
 #include "nsINetAddr.h"
 #include "mozilla/net/DNS.h"
 #include "prerror.h"
+#include "nsComponentManagerUtils.h"
+#include "nsServiceManagerUtils.h"
 
 using namespace mozilla::net;
 using namespace mozilla;
 
 class ServerListener: public nsIServerSocketListener
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSISERVERSOCKETLISTENER
 
-  ServerListener();
+  explicit ServerListener(WaitForCondition* waiter);
 
   // Port that is got from server side will be store here.
   uint32_t mClientPort;
   bool mFailed;
+  RefPtr<WaitForCondition> mWaiter;
 private:
   virtual ~ServerListener();
 };
 
 NS_IMPL_ISUPPORTS(ServerListener, nsIServerSocketListener)
 
-ServerListener::ServerListener()
+ServerListener::ServerListener(WaitForCondition* waiter)
   : mClientPort(-1)
   , mFailed(false)
+  , mWaiter(waiter)
 {
 }
 
 ServerListener::~ServerListener() = default;
 
 NS_IMETHODIMP
 ServerListener::OnSocketAccepted(nsIServerSocket *aServ,
                                  nsISocketTransport *aTransport)
 {
   // Run on STS thread.
   NetAddr peerAddr;
   nsresult rv = aTransport->GetPeerAddr(&peerAddr);
   if (NS_FAILED(rv)) {
     mFailed = true;
-    fail("Server: not able to get peer address.");
-    QuitPumpingEvents();
+    mWaiter->Notify();
     return NS_OK;
   }
   mClientPort = PR_ntohs(peerAddr.inet.port);
-  passed("Server: received connection");
-  QuitPumpingEvents();
+  mWaiter->Notify();
   return NS_OK;
 }
 
 NS_IMETHODIMP
 ServerListener::OnStopListening(nsIServerSocket *aServ,
                                 nsresult aStatus)
 {
   return NS_OK;
 }
 
 class ClientInputCallback : public nsIInputStreamCallback
 {
 public:
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSIINPUTSTREAMCALLBACK
 
-  ClientInputCallback();
+  explicit ClientInputCallback(WaitForCondition* waiter);
 
   bool mFailed;
+  RefPtr<WaitForCondition> mWaiter;
 private:
   virtual ~ClientInputCallback();
 };
 
 NS_IMPL_ISUPPORTS(ClientInputCallback, nsIInputStreamCallback)
 
-ClientInputCallback::ClientInputCallback()
+ClientInputCallback::ClientInputCallback(WaitForCondition* waiter)
   : mFailed(false)
+  , mWaiter(waiter)
 {
 }
 
 ClientInputCallback::~ClientInputCallback() = default;
 
 NS_IMETHODIMP
 ClientInputCallback::OnInputStreamReady(nsIAsyncInputStream *aStream)
 {
   // Server doesn't send. That means if we are here, we probably have run into
   // an error.
   uint64_t avail;
   nsresult rv = aStream->Available(&avail);
   if (NS_FAILED(rv)) {
     mFailed = true;
   }
-  QuitPumpingEvents();
+  mWaiter->Notify();
   return NS_OK;
 }
 
-int
-main(int32_t argc, char *argv[])
+TEST(TestBind, MainTest)
 {
-  ScopedXPCOM xpcom("SocketTransport");
-  if (xpcom.failed()) {
-    fail("Unable to initalize XPCOM.");
-    return -1;
-  }
-
   //
   // Server side.
   //
   nsCOMPtr<nsIServerSocket> server = do_CreateInstance("@mozilla.org/network/server-socket;1");
-  if (!server) {
-    fail("Failed to create server socket.");
-    return -1;
-  }
+  ASSERT_TRUE(server);
 
   nsresult rv = server->Init(-1, true, -1);
-  if (NS_FAILED(rv)) {
-    fail("Failed to initialize server.");
-    return -1;
-  }
+  ASSERT_TRUE(NS_SUCCEEDED(rv));
 
   int32_t serverPort;
   rv = server->GetPort(&serverPort);
-  if (NS_FAILED(rv)) {
-    fail("Unable to get server port.");
-    return -1;
-  }
+  ASSERT_TRUE(NS_SUCCEEDED(rv));
+
+  RefPtr<WaitForCondition> waiter = new WaitForCondition();
 
   // Listening.
-  RefPtr<ServerListener> serverListener = new ServerListener();
+  RefPtr<ServerListener> serverListener = new ServerListener(waiter);
   rv = server->AsyncListen(serverListener);
-  if (NS_FAILED(rv)) {
-    fail("Server fail to start listening.");
-    return -1;
-  }
+  ASSERT_TRUE(NS_SUCCEEDED(rv));
 
   //
   // Client side
   //
   uint32_t bindingPort = 20000;
   nsCOMPtr<nsISocketTransportService> sts =
     do_GetService("@mozilla.org/network/socket-transport-service;1", &rv);
-  if (NS_FAILED(rv)) {
-    fail("Unable to get socket transport service.");
-    return -1;
-  }
+  ASSERT_TRUE(NS_SUCCEEDED(rv));
+
+  nsCOMPtr<nsIInputStream> inputStream;
+  RefPtr<ClientInputCallback> clientCallback;
 
   for (int32_t tried = 0; tried < 100; tried++) {
     nsCOMPtr<nsISocketTransport> client;
     rv = sts->CreateTransport(nullptr, 0, NS_LITERAL_CSTRING("127.0.0.1"),
                               serverPort, nullptr, getter_AddRefs(client));
-    if (NS_FAILED(rv)) {
-      fail("Unable to create transport.");
-      return -1;
-    }
+    ASSERT_TRUE(NS_SUCCEEDED(rv));
 
     // Bind to a port. It's possible that we are binding to a port that is
     // currently in use. If we failed to bind, we try next port.
     NetAddr bindingAddr;
     bindingAddr.inet.family = AF_INET;
     bindingAddr.inet.ip = 0;
     bindingAddr.inet.port = PR_htons(bindingPort);
     rv = client->Bind(&bindingAddr);
-    if (NS_FAILED(rv)) {
-      fail("Unable to bind a port.");
-      return -1;
-    }
+    ASSERT_TRUE(NS_SUCCEEDED(rv));
 
     // Open IO streams, to make client SocketTransport connect to server.
-    RefPtr<ClientInputCallback> clientCallback = new ClientInputCallback();
-    nsCOMPtr<nsIInputStream> inputStream;
+    clientCallback = new ClientInputCallback(waiter);
     rv = client->OpenInputStream(nsITransport::OPEN_UNBUFFERED,
                                  0, 0, getter_AddRefs(inputStream));
-    if (NS_FAILED(rv)) {
-      fail("Failed to open an input stream.");
-      return -1;
-    }
+    ASSERT_TRUE(NS_SUCCEEDED(rv));
+
     nsCOMPtr<nsIAsyncInputStream> asyncInputStream = do_QueryInterface(inputStream);
     rv = asyncInputStream->AsyncWait(clientCallback, 0, 0, nullptr);
 
     // Wait for server's response or callback of input stream.
-    PumpEvents();
+    waiter->Wait(1);
     if (clientCallback->mFailed) {
       // if client received error, we likely have bound a port that is in use.
       // we can try another port.
       bindingPort++;
     } else {
       // We are unlocked by server side, leave the loop and check result.
       break;
     }
   }
 
-  if (serverListener->mFailed) {
-    fail("Server failure.");
-    return -1;
-  }
-  if (serverListener->mClientPort != bindingPort) {
-    fail("Port that server got doesn't match what we are expecting.");
-    return -1;
-  }
-  passed("Port matched");
-  return 0;
+  ASSERT_FALSE(serverListener->mFailed);
+  ASSERT_EQ(serverListener->mClientPort, bindingPort);
+
+  inputStream->Close();
+  waiter->Wait(1);
+  ASSERT_TRUE(clientCallback->mFailed);
+
+  server->Close();
 }
deleted file mode 100644
--- a/netwerk/test/TestBlockingSocket.cpp
+++ /dev/null
@@ -1,127 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * 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/. */
-
-#include "TestCommon.h"
-#include "nsIComponentRegistrar.h"
-#include "nsISocketTransportService.h"
-#include "nsISocketTransport.h"
-#include "nsIServiceManager.h"
-#include "nsIComponentManager.h"
-#include "nsCOMPtr.h"
-#include "nsStringAPI.h"
-#include "nsIFile.h"
-#include "nsNetUtil.h"
-#include "nsIInputStream.h"
-#include "nsServiceManagerUtils.h"
-#include "nsIOutputStream.h"
-#include "NetwerkTestLogging.h"
-#include "prenv.h"
-#include "prthread.h"
-#include <stdlib.h>
-
-////////////////////////////////////////////////////////////////////////////////
-
-//
-// set NSPR_LOG_MODULES=Test:5
-//
-static PRLogModuleInfo *gTestLog = nullptr;
-#define LOG(args) MOZ_LOG(gTestLog, mozilla::LogLevel::Debug, args)
-
-////////////////////////////////////////////////////////////////////////////////
-
-static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID);
-
-////////////////////////////////////////////////////////////////////////////////
-
-static nsresult
-RunBlockingTest(const nsACString &host, int32_t port, nsIFile *file)
-{
-    nsresult rv;
-
-    LOG(("RunBlockingTest\n"));
-
-    nsCOMPtr<nsISocketTransportService> sts =
-        do_GetService(kSocketTransportServiceCID, &rv);
-    if (NS_FAILED(rv)) return rv;
-
-    nsCOMPtr<nsIInputStream> input;
-    rv = NS_NewLocalFileInputStream(getter_AddRefs(input), file);
-    if (NS_FAILED(rv)) return rv;
-
-    nsCOMPtr<nsISocketTransport> trans;
-    rv = sts->CreateTransport(nullptr, 0, host, port, nullptr, getter_AddRefs(trans));
-    if (NS_FAILED(rv)) return rv;
-
-    nsCOMPtr<nsIOutputStream> output;
-    rv = trans->OpenOutputStream(nsITransport::OPEN_BLOCKING, 100, 10, getter_AddRefs(output));
-    if (NS_FAILED(rv)) return rv;
-
-    char buf[120];
-    uint32_t nr, nw;
-    for (;;) {
-        rv = input->Read(buf, sizeof(buf), &nr);
-        if (NS_FAILED(rv) || (nr == 0)) return rv;
-
-/*
-        const char *p = buf;
-        while (nr) {
-            rv = output->Write(p, nr, &nw);
-            if (NS_FAILED(rv)) return rv;
-
-            nr -= nw;
-            p  += nw;
-        }
-*/
-        
-        rv = output->Write(buf, nr, &nw);
-        if (NS_FAILED(rv)) return rv;
-
-        NS_ASSERTION(nr == nw, "not all written");
-    }
-
-    LOG(("  done copying data.\n"));
-    return NS_OK;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-
-int
-main(int argc, char* argv[])
-{
-    if (test_common_init(&argc, &argv) != 0)
-        return -1;
-
-    nsresult rv;
-
-    if (argc < 4) {
-        printf("usage: %s <host> <port> <file-to-read>\n", argv[0]);
-        return -1;
-    }
-    char* hostName = argv[1];
-    int32_t port = atoi(argv[2]);
-    char* fileName = argv[3];
-    {
-        nsCOMPtr<nsIServiceManager> servMan;
-        NS_InitXPCOM2(getter_AddRefs(servMan), nullptr, nullptr);
-
-        gTestLog = PR_NewLogModule("Test");
-
-        nsCOMPtr<nsIFile> file;
-        rv = NS_NewNativeLocalFile(nsDependentCString(fileName), false, getter_AddRefs(file));
-        if (NS_FAILED(rv)) return -1;
-
-        rv = RunBlockingTest(nsDependentCString(hostName), port, file);
-        if (NS_FAILED(rv))
-            LOG(("RunBlockingTest failed [rv=%x]\n", rv));
-
-        // give background threads a chance to finish whatever work they may
-        // be doing.
-        LOG(("sleeping for 5 seconds...\n"));
-        PR_Sleep(PR_SecondsToInterval(5));
-    } // this scopes the nsCOMPtrs
-    // no nsCOMPtrs are allowed to be alive when you call NS_ShutdownXPCOM
-    rv = NS_ShutdownXPCOM(nullptr);
-    NS_ASSERTION(NS_SUCCEEDED(rv), "NS_ShutdownXPCOM failed");
-    return 0;
-}
--- a/netwerk/test/TestCommon.h
+++ b/netwerk/test/TestCommon.h
@@ -4,48 +4,47 @@
 
 #ifndef TestCommon_h__
 #define TestCommon_h__
 
 #include <stdlib.h>
 #include "nsThreadUtils.h"
 #include "mozilla/Attributes.h"
 
-inline int test_common_init(int *argc, char ***argv)
-{
-  return 0;
-}
-
 //-----------------------------------------------------------------------------
 
-static bool gKeepPumpingEvents = false;
-
-class nsQuitPumpingEvent final : public nsIRunnable {
-  ~nsQuitPumpingEvent() {}
+class WaitForCondition : public nsIRunnable
+{
 public:
   NS_DECL_THREADSAFE_ISUPPORTS
+
+  void Wait(int pending)
+  {
+    MOZ_ASSERT(NS_IsMainThread());
+    MOZ_ASSERT(mPending == 0);
+
+    mPending = pending;
+    while (mPending) {
+      NS_ProcessNextEvent();
+    }
+    NS_ProcessPendingEvents(nullptr);
+  }
+
+  void Notify() {
+    NS_DispatchToMainThread(this);
+  }
+
+private:
+  virtual ~WaitForCondition() { }
+
   NS_IMETHOD Run() override {
-    gKeepPumpingEvents = false;
+    MOZ_ASSERT(NS_IsMainThread());
+    MOZ_ASSERT(mPending);
+
+    --mPending;
     return NS_OK;
   }
+
+  uint32_t mPending = 0;
 };
-NS_IMPL_ISUPPORTS(nsQuitPumpingEvent, nsIRunnable)
-
-static inline void PumpEvents()
-{
-  nsCOMPtr<nsIThread> thread = do_GetCurrentThread();
-
-  gKeepPumpingEvents = true;
-  while (gKeepPumpingEvents)
-    NS_ProcessNextEvent(thread);
-
-  NS_ProcessPendingEvents(thread);
-}
-
-static inline void QuitPumpingEvents()
-{
-  // Dispatch a task that toggles gKeepPumpingEvents so that we flush all
-  // of the pending tasks before exiting from PumpEvents.
-  nsCOMPtr<nsIRunnable> event = new nsQuitPumpingEvent();
-  NS_DispatchToMainThread(event);
-}
+NS_IMPL_ISUPPORTS(WaitForCondition, nsIRunnable)
 
 #endif
--- a/netwerk/test/TestCookie.cpp
+++ b/netwerk/test/TestCookie.cpp
@@ -1,44 +1,45 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
 #include "TestCommon.h"
-#include "TestHarness.h"
+#include "gtest/gtest.h"
 #include "nsIServiceManager.h"
 #include "nsICookieService.h"
 #include "nsICookieManager.h"
 #include "nsICookieManager2.h"
 #include "nsICookie2.h"
 #include <stdio.h>
 #include "plstr.h"
 #include "prprf.h"
 #include "nsNetUtil.h"
 #include "nsISimpleEnumerator.h"
 #include "nsServiceManagerUtils.h"
 #include "nsNetCID.h"
-#include "nsStringAPI.h"
 #include "nsIPrefBranch.h"
 #include "nsIPrefService.h"
+#include "mozilla/Unused.h"
+#include "nsIURI.h"
+
+using mozilla::Unused;
 
 static NS_DEFINE_CID(kCookieServiceCID, NS_COOKIESERVICE_CID);
 static NS_DEFINE_CID(kPrefServiceCID,   NS_PREFSERVICE_CID);
 
 // various pref strings
 static const char kCookiesPermissions[] = "network.cookie.cookieBehavior";
 static const char kCookiesLifetimeEnabled[] = "network.cookie.lifetime.enabled";
 static const char kCookiesLifetimeDays[] = "network.cookie.lifetime.days";
 static const char kCookiesLifetimeCurrentSession[] = "network.cookie.lifetime.behavior";
 static const char kCookiesMaxPerHost[] = "network.cookie.maxPerHost";
 static const char kCookieLeaveSecurityAlone[] = "network.cookie.leave-secure-alone";
 
-static char *sBuffer;
-
 #define OFFSET_ONE_WEEK int64_t(604800) * PR_USEC_PER_SEC
 #define OFFSET_ONE_DAY int64_t(86400) * PR_USEC_PER_SEC
 
 //Set server time or expiry time
 void
 SetTime(PRTime offsetTime,nsAutoCString& serverString,nsAutoCString& cookieString,bool expiry)
 {
     char timeStringPreset[40];
@@ -59,97 +60,61 @@ SetTime(PRTime offsetTime,nsAutoCString&
 
     // Set cookie string
     PR_ExplodeTime(SetExpiryTime , PR_GMTParameters, &explodedTime);
     PR_FormatTimeUSEnglish(timeStringPreset, 40, "%c GMT", &explodedTime);
     cookieString.Replace(0, strlen("test=expiry; expires=") + strlen(timeStringPreset) + 1, "test=expiry; expires=");
     cookieString.Append(timeStringPreset);
 }
 
-nsresult
+void
 SetACookie(nsICookieService *aCookieService, const char *aSpec1, const char *aSpec2, const char* aCookieString, const char *aServerTime)
 {
     nsCOMPtr<nsIURI> uri1, uri2;
     NS_NewURI(getter_AddRefs(uri1), aSpec1);
     if (aSpec2)
         NS_NewURI(getter_AddRefs(uri2), aSpec2);
 
-    sBuffer = PR_sprintf_append(sBuffer, R"(    for host "%s": SET )", aSpec1);
     nsresult rv = aCookieService->SetCookieStringFromHttp(uri1, uri2, nullptr, (char *)aCookieString, aServerTime, nullptr);
-    // the following code is useless. the cookieservice blindly returns NS_OK
-    // from SetCookieString. we have to call GetCookie to see if the cookie was
-    // set correctly...
-    if (NS_FAILED(rv)) {
-        sBuffer = PR_sprintf_append(sBuffer, "nothing\n");
-    } else {
-        sBuffer = PR_sprintf_append(sBuffer, "\"%s\"\n", aCookieString);
-    }
-    return rv;
+    EXPECT_TRUE(NS_SUCCEEDED(rv));
 }
 
-nsresult
+void
 SetACookieNoHttp(nsICookieService *aCookieService, const char *aSpec, const char* aCookieString)
 {
     nsCOMPtr<nsIURI> uri;
     NS_NewURI(getter_AddRefs(uri), aSpec);
 
-    sBuffer = PR_sprintf_append(sBuffer, R"(    for host "%s": SET )", aSpec);
     nsresult rv = aCookieService->SetCookieString(uri, nullptr, (char *)aCookieString, nullptr);
-    // the following code is useless. the cookieservice blindly returns NS_OK
-    // from SetCookieString. we have to call GetCookie to see if the cookie was
-    // set correctly...
-    if (NS_FAILED(rv)) {
-        sBuffer = PR_sprintf_append(sBuffer, "nothing\n");
-    } else {
-        sBuffer = PR_sprintf_append(sBuffer, "\"%s\"\n", aCookieString);
-    }
-    return rv;
+    EXPECT_TRUE(NS_SUCCEEDED(rv));
 }
 
 // returns true if cookie(s) for the given host were found; else false.
 // the cookie string is returned via aCookie.
 bool
 GetACookie(nsICookieService *aCookieService, const char *aSpec1, const char *aSpec2, char **aCookie)
 {
     nsCOMPtr<nsIURI> uri1, uri2;
     NS_NewURI(getter_AddRefs(uri1), aSpec1);
     if (aSpec2)
         NS_NewURI(getter_AddRefs(uri2), aSpec2);
 
-    sBuffer = PR_sprintf_append(sBuffer, R"(             "%s": GOT )", aSpec1);
-    nsresult rv = aCookieService->GetCookieStringFromHttp(uri1, uri2, nullptr, aCookie);
-    if (NS_FAILED(rv)) {
-      sBuffer = PR_sprintf_append(sBuffer, "XXX GetCookieString() failed!\n");
-    }
-    if (!*aCookie) {
-        sBuffer = PR_sprintf_append(sBuffer, "nothing\n");
-    } else {
-        sBuffer = PR_sprintf_append(sBuffer, "\"%s\"\n", *aCookie);
-    }
+    Unused << aCookieService->GetCookieStringFromHttp(uri1, uri2, nullptr, aCookie);
     return *aCookie != nullptr;
 }
 
 // returns true if cookie(s) for the given host were found; else false.
 // the cookie string is returned via aCookie.
 bool
 GetACookieNoHttp(nsICookieService *aCookieService, const char *aSpec, char **aCookie)
 {
     nsCOMPtr<nsIURI> uri;
     NS_NewURI(getter_AddRefs(uri), aSpec);
 
-    sBuffer = PR_sprintf_append(sBuffer, R"(             "%s": GOT )", aSpec);
-    nsresult rv = aCookieService->GetCookieString(uri, nullptr, aCookie);
-    if (NS_FAILED(rv)) {
-      sBuffer = PR_sprintf_append(sBuffer, "XXX GetCookieString() failed!\n");
-    }
-    if (!*aCookie) {
-        sBuffer = PR_sprintf_append(sBuffer, "nothing\n");
-    } else {
-        sBuffer = PR_sprintf_append(sBuffer, "\"%s\"\n", *aCookie);
-    }
+    Unused << aCookieService->GetCookieString(uri, nullptr, aCookie);
     return *aCookie != nullptr;
 }
 
 // some #defines for comparison rules
 #define MUST_BE_NULL     0
 #define MUST_EQUAL       1
 #define MUST_CONTAIN     2
 #define MUST_NOT_CONTAIN 3
@@ -177,745 +142,633 @@ CheckResult(const char *aLhs, uint32_t a
         case MUST_NOT_CONTAIN:
             return PL_strstr(aLhs, aRhs) == nullptr;
 
         default:
             return false; // failure
     }
 }
 
-// helper function that ensures the first aSize elements of aResult are
-// true (i.e. all tests succeeded). prints the result of the tests (if any
-// tests failed, it prints the zero-based index of each failed test).
-bool
-PrintResult(const bool aResult[], uint32_t aSize)
-{
-    bool failed = false;
-    sBuffer = PR_sprintf_append(sBuffer, "*** tests ");
-    for (uint32_t i = 0; i < aSize; ++i) {
-        if (!aResult[i]) {
-            failed = true;
-            sBuffer = PR_sprintf_append(sBuffer, "%d ", i);
-        }
-    }
-    if (failed) {
-        sBuffer = PR_sprintf_append(sBuffer, "FAILED!\a\n");
-    } else {
-        sBuffer = PR_sprintf_append(sBuffer, "passed.\n");
-    }
-    return !failed;
-}
-
 void
 InitPrefs(nsIPrefBranch *aPrefBranch)
 {
     // init some relevant prefs, so the tests don't go awry.
     // we use the most restrictive set of prefs we can;
     // however, we don't test third party blocking here.
     aPrefBranch->SetIntPref(kCookiesPermissions, 0); // accept all
     aPrefBranch->SetBoolPref(kCookiesLifetimeEnabled, true);
     aPrefBranch->SetIntPref(kCookiesLifetimeCurrentSession, 0);
     aPrefBranch->SetIntPref(kCookiesLifetimeDays, 1);
     aPrefBranch->SetBoolPref(kCookieLeaveSecurityAlone, true);
     // Set the base domain limit to 50 so we have a known value.
     aPrefBranch->SetIntPref(kCookiesMaxPerHost, 50);
 }
 
 
-int
-main(int32_t argc, char *argv[])
+TEST(TestCookie,TestCookieMain)
 {
-    if (test_common_init(&argc, &argv) != 0)
-        return -1;
+    nsresult rv0;
+
+    nsCOMPtr<nsICookieService> cookieService =
+        do_GetService(kCookieServiceCID, &rv0);
+    ASSERT_TRUE(NS_SUCCEEDED(rv0));
 
-    bool allTestsPassed = true;
+    nsCOMPtr<nsIPrefBranch> prefBranch =
+        do_GetService(kPrefServiceCID, &rv0);
+    ASSERT_TRUE(NS_SUCCEEDED(rv0));
 
-    ScopedXPCOM xpcom("TestCookie");
+    InitPrefs(prefBranch);
 
-    {
-      nsresult rv0;
+    nsCString cookie;
 
-      nsCOMPtr<nsICookieService> cookieService =
-        do_GetService(kCookieServiceCID, &rv0);
-      if (NS_FAILED(rv0)) return -1;
-
-      nsCOMPtr<nsIPrefBranch> prefBranch =
-        do_GetService(kPrefServiceCID, &rv0);
-      if (NS_FAILED(rv0)) return -1;
-
-      InitPrefs(prefBranch);
-
-      bool rv[20];
-      nsCString cookie;
+    /* The basic idea behind these tests is the following:
+     *
+     * we set() some cookie, then try to get() it in various ways. we have
+     * several possible tests we perform on the cookie string returned from
+     * get():
+     *
+     * a) check whether the returned string is null (i.e. we got no cookies
+     *    back). this is used e.g. to ensure a given cookie was deleted
+     *    correctly, or to ensure a certain cookie wasn't returned to a given
+     *    host.
+     * b) check whether the returned string exactly matches a given string.
+     *    this is used where we want to make sure our cookie service adheres to
+     *    some strict spec (e.g. ordering of multiple cookies), or where we
+     *    just know exactly what the returned string should be.
+     * c) check whether the returned string contains/does not contain a given
+     *    string. this is used where we don't know/don't care about the
+     *    ordering of multiple cookies - we just want to make sure the cookie
+     *    string contains them all, in some order.
+     *
+     * NOTE: this testsuite is not yet comprehensive or complete, and is
+     * somewhat contrived - still under development, and needs improving!
+     */
 
-      /* The basic idea behind these tests is the following:
-       *
-       * we set() some cookie, then try to get() it in various ways. we have
-       * several possible tests we perform on the cookie string returned from
-       * get():
-       *
-       * a) check whether the returned string is null (i.e. we got no cookies
-       *    back). this is used e.g. to ensure a given cookie was deleted
-       *    correctly, or to ensure a certain cookie wasn't returned to a given
-       *    host.
-       * b) check whether the returned string exactly matches a given string.
-       *    this is used where we want to make sure our cookie service adheres to
-       *    some strict spec (e.g. ordering of multiple cookies), or where we
-       *    just know exactly what the returned string should be.
-       * c) check whether the returned string contains/does not contain a given
-       *    string. this is used where we don't know/don't care about the
-       *    ordering of multiple cookies - we just want to make sure the cookie
-       *    string contains them all, in some order.
-       *
-       * the results of each individual testing operation from CheckResult() is
-       * stored in an array of bools, which is then checked against the expected
-       * outcomes (all successes), by PrintResult(). the overall result of all
-       * tests to date is kept in |allTestsPassed|, for convenient display at the
-       * end.
-       *
-       * Interpreting the output:
-       * each setting/getting operation will print output saying exactly what
-       * it's doing and the outcome, respectively. this information is only
-       * useful for debugging purposes; the actual result of the tests is
-       * printed at the end of each block of tests. this will either be "all
-       * tests passed" or "tests X Y Z failed", where X, Y, Z are the indexes
-       * of rv (i.e. zero-based). at the conclusion of all tests, the overall
-       * passed/failed result is printed.
-       *
-       * NOTE: this testsuite is not yet comprehensive or complete, and is
-       * somewhat contrived - still under development, and needs improving!
-       */
+    // test some basic variations of the domain & path
+    SetACookie(cookieService, "http://www.basic.com", nullptr, "test=basic", nullptr);
+    GetACookie(cookieService, "http://www.basic.com", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test=basic"));
+    GetACookie(cookieService, "http://www.basic.com/testPath/testfile.txt", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test=basic"));
+    GetACookie(cookieService, "http://www.basic.com./", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
+    GetACookie(cookieService, "http://www.basic.com.", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
+    GetACookie(cookieService, "http://www.basic.com./testPath/testfile.txt", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
+    GetACookie(cookieService, "http://www.basic2.com/", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
+    SetACookie(cookieService, "http://www.basic.com", nullptr, "test=basic; max-age=-1", nullptr);
+    GetACookie(cookieService, "http://www.basic.com/", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
+
+    // *** domain tests
 
-      // *** basic tests
-      sBuffer = PR_sprintf_append(sBuffer, "*** Beginning basic tests...\n");
-
-      // test some basic variations of the domain & path
-      SetACookie(cookieService, "http://www.basic.com", nullptr, "test=basic", nullptr);
-      GetACookie(cookieService, "http://www.basic.com", nullptr, getter_Copies(cookie));
-      rv[0] = CheckResult(cookie.get(), MUST_EQUAL, "test=basic");
-      GetACookie(cookieService, "http://www.basic.com/testPath/testfile.txt", nullptr, getter_Copies(cookie));
-      rv[1] = CheckResult(cookie.get(), MUST_EQUAL, "test=basic");
-      GetACookie(cookieService, "http://www.basic.com./", nullptr, getter_Copies(cookie));
-      rv[2] = CheckResult(cookie.get(), MUST_BE_NULL);
-      GetACookie(cookieService, "http://www.basic.com.", nullptr, getter_Copies(cookie));
-      rv[3] = CheckResult(cookie.get(), MUST_BE_NULL);
-      GetACookie(cookieService, "http://www.basic.com./testPath/testfile.txt", nullptr, getter_Copies(cookie));
-      rv[4] = CheckResult(cookie.get(), MUST_BE_NULL);
-      GetACookie(cookieService, "http://www.basic2.com/", nullptr, getter_Copies(cookie));
-      rv[5] = CheckResult(cookie.get(), MUST_BE_NULL);
-      SetACookie(cookieService, "http://www.basic.com", nullptr, "test=basic; max-age=-1", nullptr);
-      GetACookie(cookieService, "http://www.basic.com/", nullptr, getter_Copies(cookie));
-      rv[6] = CheckResult(cookie.get(), MUST_BE_NULL);
+    // test some variations of the domain & path, for different domains of
+    // a domain cookie
+    SetACookie(cookieService, "http://www.domain.com", nullptr, "test=domain; domain=domain.com", nullptr);
+    GetACookie(cookieService, "http://domain.com", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test=domain"));
+    GetACookie(cookieService, "http://domain.com.", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
+    GetACookie(cookieService, "http://www.domain.com", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test=domain"));
+    GetACookie(cookieService, "http://foo.domain.com", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test=domain"));
+    SetACookie(cookieService, "http://www.domain.com", nullptr, "test=domain; domain=domain.com; max-age=-1", nullptr);
+    GetACookie(cookieService, "http://domain.com", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
 
-      allTestsPassed = PrintResult(rv, 7) && allTestsPassed;
-
-
-      // *** domain tests
-      sBuffer = PR_sprintf_append(sBuffer, "*** Beginning domain tests...\n");
+    SetACookie(cookieService, "http://www.domain.com", nullptr, "test=domain; domain=.domain.com", nullptr);
+    GetACookie(cookieService, "http://domain.com", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test=domain"));
+    GetACookie(cookieService, "http://www.domain.com", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test=domain"));
+    GetACookie(cookieService, "http://bah.domain.com", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test=domain"));
+    SetACookie(cookieService, "http://www.domain.com", nullptr, "test=domain; domain=.domain.com; max-age=-1", nullptr);
+    GetACookie(cookieService, "http://domain.com", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
 
-      // test some variations of the domain & path, for different domains of
-      // a domain cookie
-      SetACookie(cookieService, "http://www.domain.com", nullptr, "test=domain; domain=domain.com", nullptr);
-      GetACookie(cookieService, "http://domain.com", nullptr, getter_Copies(cookie));
-      rv[0] = CheckResult(cookie.get(), MUST_EQUAL, "test=domain");
-      GetACookie(cookieService, "http://domain.com.", nullptr, getter_Copies(cookie));
-      rv[1] = CheckResult(cookie.get(), MUST_BE_NULL);
-      GetACookie(cookieService, "http://www.domain.com", nullptr, getter_Copies(cookie));
-      rv[2] = CheckResult(cookie.get(), MUST_EQUAL, "test=domain");
-      GetACookie(cookieService, "http://foo.domain.com", nullptr, getter_Copies(cookie));
-      rv[3] = CheckResult(cookie.get(), MUST_EQUAL, "test=domain");
-      SetACookie(cookieService, "http://www.domain.com", nullptr, "test=domain; domain=domain.com; max-age=-1", nullptr);
-      GetACookie(cookieService, "http://domain.com", nullptr, getter_Copies(cookie));
-      rv[4] = CheckResult(cookie.get(), MUST_BE_NULL);
+    SetACookie(cookieService, "http://www.domain.com", nullptr, "test=domain; domain=.foo.domain.com", nullptr);
+    GetACookie(cookieService, "http://foo.domain.com", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
 
-      SetACookie(cookieService, "http://www.domain.com", nullptr, "test=domain; domain=.domain.com", nullptr);
-      GetACookie(cookieService, "http://domain.com", nullptr, getter_Copies(cookie));
-      rv[5] = CheckResult(cookie.get(), MUST_EQUAL, "test=domain");
-      GetACookie(cookieService, "http://www.domain.com", nullptr, getter_Copies(cookie));
-      rv[6] = CheckResult(cookie.get(), MUST_EQUAL, "test=domain");
-      GetACookie(cookieService, "http://bah.domain.com", nullptr, getter_Copies(cookie));
-      rv[7] = CheckResult(cookie.get(), MUST_EQUAL, "test=domain");
-      SetACookie(cookieService, "http://www.domain.com", nullptr, "test=domain; domain=.domain.com; max-age=-1", nullptr);
-      GetACookie(cookieService, "http://domain.com", nullptr, getter_Copies(cookie));
-      rv[8] = CheckResult(cookie.get(), MUST_BE_NULL);
+    SetACookie(cookieService, "http://www.domain.com", nullptr, "test=domain; domain=moose.com", nullptr);
+    GetACookie(cookieService, "http://foo.domain.com", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
+
+    SetACookie(cookieService, "http://www.domain.com", nullptr, "test=domain; domain=domain.com.", nullptr);
+    GetACookie(cookieService, "http://foo.domain.com", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
 
-      SetACookie(cookieService, "http://www.domain.com", nullptr, "test=domain; domain=.foo.domain.com", nullptr);
-      GetACookie(cookieService, "http://foo.domain.com", nullptr, getter_Copies(cookie));
-      rv[9] = CheckResult(cookie.get(), MUST_BE_NULL);
+    SetACookie(cookieService, "http://www.domain.com", nullptr, "test=domain; domain=..domain.com", nullptr);
+    GetACookie(cookieService, "http://foo.domain.com", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
 
-      SetACookie(cookieService, "http://www.domain.com", nullptr, "test=domain; domain=moose.com", nullptr);
-      GetACookie(cookieService, "http://foo.domain.com", nullptr, getter_Copies(cookie));
-      rv[10] = CheckResult(cookie.get(), MUST_BE_NULL);
+    SetACookie(cookieService, "http://www.domain.com", nullptr, "test=domain; domain=..domain.com.", nullptr);
+    GetACookie(cookieService, "http://foo.domain.com", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
 
-      SetACookie(cookieService, "http://www.domain.com", nullptr, "test=domain; domain=domain.com.", nullptr);
-      GetACookie(cookieService, "http://foo.domain.com", nullptr, getter_Copies(cookie));
-      rv[11] = CheckResult(cookie.get(), MUST_BE_NULL);
+    SetACookie(cookieService, "http://path.net/path/file", nullptr, R"(test=taco; path="/bogus")", nullptr);
+    GetACookie(cookieService, "http://path.net/path/file", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test=taco"));
+    SetACookie(cookieService, "http://path.net/path/file", nullptr, "test=taco; max-age=-1", nullptr);
+    GetACookie(cookieService, "http://path.net/path/file", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
 
-      SetACookie(cookieService, "http://www.domain.com", nullptr, "test=domain; domain=..domain.com", nullptr);
-      GetACookie(cookieService, "http://foo.domain.com", nullptr, getter_Copies(cookie));
-      rv[12] = CheckResult(cookie.get(), MUST_BE_NULL);
-
-      SetACookie(cookieService, "http://www.domain.com", nullptr, "test=domain; domain=..domain.com.", nullptr);
-      GetACookie(cookieService, "http://foo.domain.com", nullptr, getter_Copies(cookie));
-      rv[13] = CheckResult(cookie.get(), MUST_BE_NULL);
+    // *** path tests
 
-      SetACookie(cookieService, "http://path.net/path/file", nullptr, R"(test=taco; path="/bogus")", nullptr);
-      GetACookie(cookieService, "http://path.net/path/file", nullptr, getter_Copies(cookie));
-      rv[14] = CheckResult(cookie.get(), MUST_EQUAL, "test=taco");
-      SetACookie(cookieService, "http://path.net/path/file", nullptr, "test=taco; max-age=-1", nullptr);
-      GetACookie(cookieService, "http://path.net/path/file", nullptr, getter_Copies(cookie));
-      rv[15] = CheckResult(cookie.get(), MUST_BE_NULL);
-
-      allTestsPassed = PrintResult(rv, 16) && allTestsPassed;
-
-
-      // *** path tests
-      sBuffer = PR_sprintf_append(sBuffer, "*** Beginning path tests...\n");
+    // test some variations of the domain & path, for different paths of
+    // a path cookie
+    SetACookie(cookieService, "http://path.net/path/file", nullptr, "test=path; path=/path", nullptr);
+    GetACookie(cookieService, "http://path.net/path", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test=path"));
+    GetACookie(cookieService, "http://path.net/path/", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test=path"));
+    GetACookie(cookieService, "http://path.net/path/hithere.foo", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test=path"));
+    GetACookie(cookieService, "http://path.net/path?hithere/foo", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test=path"));
+    GetACookie(cookieService, "http://path.net/path2", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
+    GetACookie(cookieService, "http://path.net/path2/", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
+    SetACookie(cookieService, "http://path.net/path/file", nullptr, "test=path; path=/path; max-age=-1", nullptr);
+    GetACookie(cookieService, "http://path.net/path/", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
 
-      // test some variations of the domain & path, for different paths of
-      // a path cookie
-      SetACookie(cookieService, "http://path.net/path/file", nullptr, "test=path; path=/path", nullptr);
-      GetACookie(cookieService, "http://path.net/path", nullptr, getter_Copies(cookie));
-      rv[0] = CheckResult(cookie.get(), MUST_EQUAL, "test=path");
-      GetACookie(cookieService, "http://path.net/path/", nullptr, getter_Copies(cookie));
-      rv[1] = CheckResult(cookie.get(), MUST_EQUAL, "test=path");
-      GetACookie(cookieService, "http://path.net/path/hithere.foo", nullptr, getter_Copies(cookie));
-      rv[2] = CheckResult(cookie.get(), MUST_EQUAL, "test=path");
-      GetACookie(cookieService, "http://path.net/path?hithere/foo", nullptr, getter_Copies(cookie));
-      rv[3] = CheckResult(cookie.get(), MUST_EQUAL, "test=path");
-      GetACookie(cookieService, "http://path.net/path2", nullptr, getter_Copies(cookie));
-      rv[4] = CheckResult(cookie.get(), MUST_BE_NULL);
-      GetACookie(cookieService, "http://path.net/path2/", nullptr, getter_Copies(cookie));
-      rv[5] = CheckResult(cookie.get(), MUST_BE_NULL);
-      SetACookie(cookieService, "http://path.net/path/file", nullptr, "test=path; path=/path; max-age=-1", nullptr);
-      GetACookie(cookieService, "http://path.net/path/", nullptr, getter_Copies(cookie));
-      rv[6] = CheckResult(cookie.get(), MUST_BE_NULL);
+    SetACookie(cookieService, "http://path.net/path/file", nullptr, "test=path; path=/path/", nullptr);
+    GetACookie(cookieService, "http://path.net/path", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test=path"));
+    GetACookie(cookieService, "http://path.net/path/", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test=path"));
+    SetACookie(cookieService, "http://path.net/path/file", nullptr, "test=path; path=/path/; max-age=-1", nullptr);
+    GetACookie(cookieService, "http://path.net/path/", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
 
-      SetACookie(cookieService, "http://path.net/path/file", nullptr, "test=path; path=/path/", nullptr);
-      GetACookie(cookieService, "http://path.net/path", nullptr, getter_Copies(cookie));
-      rv[7] = CheckResult(cookie.get(), MUST_EQUAL, "test=path");
-      GetACookie(cookieService, "http://path.net/path/", nullptr, getter_Copies(cookie));
-      rv[8] = CheckResult(cookie.get(), MUST_EQUAL, "test=path");
-      SetACookie(cookieService, "http://path.net/path/file", nullptr, "test=path; path=/path/; max-age=-1", nullptr);
-      GetACookie(cookieService, "http://path.net/path/", nullptr, getter_Copies(cookie));
-      rv[9] = CheckResult(cookie.get(), MUST_BE_NULL);
+    // note that a site can set a cookie for a path it's not on.
+    // this is an intentional deviation from spec (see comments in
+    // nsCookieService::CheckPath()), so we test this functionality too
+    SetACookie(cookieService, "http://path.net/path/file", nullptr, "test=path; path=/foo/", nullptr);
+    GetACookie(cookieService, "http://path.net/path", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
+    GetACookie(cookieService, "http://path.net/foo", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test=path"));
+    SetACookie(cookieService, "http://path.net/path/file", nullptr, "test=path; path=/foo/; max-age=-1", nullptr);
+    GetACookie(cookieService, "http://path.net/foo/", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
 
-      // note that a site can set a cookie for a path it's not on.
-      // this is an intentional deviation from spec (see comments in
-      // nsCookieService::CheckPath()), so we test this functionality too
-      SetACookie(cookieService, "http://path.net/path/file", nullptr, "test=path; path=/foo/", nullptr);
-      GetACookie(cookieService, "http://path.net/path", nullptr, getter_Copies(cookie));
-      rv[10] = CheckResult(cookie.get(), MUST_BE_NULL);
-      GetACookie(cookieService, "http://path.net/foo", nullptr, getter_Copies(cookie));
-      rv[11] = CheckResult(cookie.get(), MUST_EQUAL, "test=path");
-      SetACookie(cookieService, "http://path.net/path/file", nullptr, "test=path; path=/foo/; max-age=-1", nullptr);
-      GetACookie(cookieService, "http://path.net/foo/", nullptr, getter_Copies(cookie));
-      rv[12] = CheckResult(cookie.get(), MUST_BE_NULL);
-
-      // bug 373228: make sure cookies with paths longer than 1024 bytes,
-      // and cookies with paths or names containing tabs, are rejected.
-      // the following cookie has a path > 1024 bytes explicitly specified in the cookie
-      SetACookie(cookieService, "http://path.net/", nullptr, "test=path; path=/1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890/", nullptr);
-      GetACookie(cookieService, "http://path.net/1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", nullptr, getter_Copies(cookie));
-      rv[13] = CheckResult(cookie.get(), MUST_BE_NULL);
-      // the following cookie has a path > 1024 bytes implicitly specified by the uri path
-      SetACookie(cookieService, "http://path.net/1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890/", nullptr, "test=path", nullptr);
-      GetACookie(cookieService, "http://path.net/1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890/", nullptr, getter_Copies(cookie));
-      rv[14] = CheckResult(cookie.get(), MUST_BE_NULL);
-      // the following cookie includes a tab in the path
-      SetACookie(cookieService, "http://path.net/", nullptr, "test=path; path=/foo\tbar/", nullptr);
-      GetACookie(cookieService, "http://path.net/foo\tbar/", nullptr, getter_Copies(cookie));
-      rv[15] = CheckResult(cookie.get(), MUST_BE_NULL);
-      // the following cookie includes a tab in the name
-      SetACookie(cookieService, "http://path.net/", nullptr, "test\ttabs=tab", nullptr);
-      GetACookie(cookieService, "http://path.net/", nullptr, getter_Copies(cookie));
-      rv[16] = CheckResult(cookie.get(), MUST_BE_NULL);
-      // the following cookie includes a tab in the value - allowed
-      SetACookie(cookieService, "http://path.net/", nullptr, "test=tab\ttest", nullptr);
-      GetACookie(cookieService, "http://path.net/", nullptr, getter_Copies(cookie));
-      rv[17] = CheckResult(cookie.get(), MUST_EQUAL, "test=tab\ttest");
-      SetACookie(cookieService, "http://path.net/", nullptr, "test=tab\ttest; max-age=-1", nullptr);
-      GetACookie(cookieService, "http://path.net/", nullptr, getter_Copies(cookie));
-      rv[18] = CheckResult(cookie.get(), MUST_BE_NULL);
-
-      allTestsPassed = PrintResult(rv, 19) && allTestsPassed;
+    // bug 373228: make sure cookies with paths longer than 1024 bytes,
+    // and cookies with paths or names containing tabs, are rejected.
+    // the following cookie has a path > 1024 bytes explicitly specified in the cookie
+    SetACookie(cookieService, "http://path.net/", nullptr, "test=path; path=/1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890/", nullptr);
+    GetACookie(cookieService, "http://path.net/1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
+    // the following cookie has a path > 1024 bytes implicitly specified by the uri path
+    SetACookie(cookieService, "http://path.net/1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890/", nullptr, "test=path", nullptr);
+    GetACookie(cookieService, "http://path.net/1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890/", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
+    // the following cookie includes a tab in the path
+    SetACookie(cookieService, "http://path.net/", nullptr, "test=path; path=/foo\tbar/", nullptr);
+    GetACookie(cookieService, "http://path.net/foo\tbar/", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
+    // the following cookie includes a tab in the name
+    SetACookie(cookieService, "http://path.net/", nullptr, "test\ttabs=tab", nullptr);
+    GetACookie(cookieService, "http://path.net/", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
+    // the following cookie includes a tab in the value - allowed
+    SetACookie(cookieService, "http://path.net/", nullptr, "test=tab\ttest", nullptr);
+    GetACookie(cookieService, "http://path.net/", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test=tab\ttest"));
+    SetACookie(cookieService, "http://path.net/", nullptr, "test=tab\ttest; max-age=-1", nullptr);
+    GetACookie(cookieService, "http://path.net/", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
 
 
-      // *** expiry & deletion tests
-      // XXX add server time str parsing tests here
-      sBuffer = PR_sprintf_append(sBuffer, "*** Beginning expiry & deletion tests...\n");
+    // *** expiry & deletion tests
+    // XXX add server time str parsing tests here
+
+    // test some variations of the expiry time,
+    // and test deletion of previously set cookies
+    SetACookie(cookieService, "http://expireme.org/", nullptr, "test=expiry; max-age=-1", nullptr);
+    GetACookie(cookieService, "http://expireme.org/", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
+    SetACookie(cookieService, "http://expireme.org/", nullptr, "test=expiry; max-age=0", nullptr);
+    GetACookie(cookieService, "http://expireme.org/", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
+    SetACookie(cookieService, "http://expireme.org/", nullptr, "test=expiry; expires=bad", nullptr);
+    GetACookie(cookieService, "http://expireme.org/", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test=expiry"));
+    SetACookie(cookieService, "http://expireme.org/", nullptr, "test=expiry; expires=Thu, 10 Apr 1980 16:33:12 GMT", nullptr);
+    GetACookie(cookieService, "http://expireme.org/", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
+    SetACookie(cookieService, "http://expireme.org/", nullptr, R"(test=expiry; expires="Thu, 10 Apr 1980 16:33:12 GMT)", nullptr);
+    GetACookie(cookieService, "http://expireme.org/", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
+    SetACookie(cookieService, "http://expireme.org/", nullptr, R"(test=expiry; expires="Thu, 10 Apr 1980 16:33:12 GMT")", nullptr);
+    GetACookie(cookieService, "http://expireme.org/", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
 
-      // test some variations of the expiry time,
-      // and test deletion of previously set cookies
-      SetACookie(cookieService, "http://expireme.org/", nullptr, "test=expiry; max-age=-1", nullptr);
-      GetACookie(cookieService, "http://expireme.org/", nullptr, getter_Copies(cookie));
-      rv[0] = CheckResult(cookie.get(), MUST_BE_NULL);
-      SetACookie(cookieService, "http://expireme.org/", nullptr, "test=expiry; max-age=0", nullptr);
-      GetACookie(cookieService, "http://expireme.org/", nullptr, getter_Copies(cookie));
-      rv[1] = CheckResult(cookie.get(), MUST_BE_NULL);
-      SetACookie(cookieService, "http://expireme.org/", nullptr, "test=expiry; expires=bad", nullptr);
-      GetACookie(cookieService, "http://expireme.org/", nullptr, getter_Copies(cookie));
-      rv[2] = CheckResult(cookie.get(), MUST_EQUAL, "test=expiry");
-      SetACookie(cookieService, "http://expireme.org/", nullptr, "test=expiry; expires=Thu, 10 Apr 1980 16:33:12 GMT", nullptr);
-      GetACookie(cookieService, "http://expireme.org/", nullptr, getter_Copies(cookie));
-      rv[3] = CheckResult(cookie.get(), MUST_BE_NULL);
-      SetACookie(cookieService, "http://expireme.org/", nullptr, R"(test=expiry; expires="Thu, 10 Apr 1980 16:33:12 GMT)", nullptr);
-      GetACookie(cookieService, "http://expireme.org/", nullptr, getter_Copies(cookie));
-      rv[4] = CheckResult(cookie.get(), MUST_BE_NULL);
-      SetACookie(cookieService, "http://expireme.org/", nullptr, R"(test=expiry; expires="Thu, 10 Apr 1980 16:33:12 GMT")", nullptr);
-      GetACookie(cookieService, "http://expireme.org/", nullptr, getter_Copies(cookie));
-      rv[5] = CheckResult(cookie.get(), MUST_BE_NULL);
-
-      SetACookie(cookieService, "http://expireme.org/", nullptr, "test=expiry; max-age=60", nullptr);
-      GetACookie(cookieService, "http://expireme.org/", nullptr, getter_Copies(cookie));
-      rv[6] = CheckResult(cookie.get(), MUST_EQUAL, "test=expiry");
-      SetACookie(cookieService, "http://expireme.org/", nullptr, "test=expiry; max-age=-20", nullptr);
-      GetACookie(cookieService, "http://expireme.org/", nullptr, getter_Copies(cookie));
-      rv[7] = CheckResult(cookie.get(), MUST_BE_NULL);
-      SetACookie(cookieService, "http://expireme.org/", nullptr, "test=expiry; max-age=60", nullptr);
-      GetACookie(cookieService, "http://expireme.org/", nullptr, getter_Copies(cookie));
-      rv[8] = CheckResult(cookie.get(), MUST_EQUAL, "test=expiry");
-      SetACookie(cookieService, "http://expireme.org/", nullptr, "test=expiry; expires=Thu, 10 Apr 1980 16:33:12 GMT", nullptr);
-      GetACookie(cookieService, "http://expireme.org/", nullptr, getter_Copies(cookie));
-      rv[9] = CheckResult(cookie.get(), MUST_BE_NULL);
-      SetACookie(cookieService, "http://expireme.org/", nullptr, "test=expiry; max-age=60", nullptr);
-      SetACookie(cookieService, "http://expireme.org/", nullptr, "newtest=expiry; max-age=60", nullptr);
-      GetACookie(cookieService, "http://expireme.org/", nullptr, getter_Copies(cookie));
-      rv[10] = CheckResult(cookie.get(), MUST_CONTAIN, "test=expiry");
-      rv[11] = CheckResult(cookie.get(), MUST_CONTAIN, "newtest=expiry");
-      SetACookie(cookieService, "http://expireme.org/", nullptr, "test=differentvalue; max-age=0", nullptr);
-      GetACookie(cookieService, "http://expireme.org/", nullptr, getter_Copies(cookie));
-      rv[12] = CheckResult(cookie.get(), MUST_EQUAL, "newtest=expiry");
-      SetACookie(cookieService, "http://expireme.org/", nullptr, "newtest=evendifferentvalue; max-age=0", nullptr);
-      GetACookie(cookieService, "http://expireme.org/", nullptr, getter_Copies(cookie));
-      rv[13] = CheckResult(cookie.get(), MUST_BE_NULL);
+    SetACookie(cookieService, "http://expireme.org/", nullptr, "test=expiry; max-age=60", nullptr);
+    GetACookie(cookieService, "http://expireme.org/", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test=expiry"));
+    SetACookie(cookieService, "http://expireme.org/", nullptr, "test=expiry; max-age=-20", nullptr);
+    GetACookie(cookieService, "http://expireme.org/", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
+    SetACookie(cookieService, "http://expireme.org/", nullptr, "test=expiry; max-age=60", nullptr);
+    GetACookie(cookieService, "http://expireme.org/", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test=expiry"));
+    SetACookie(cookieService, "http://expireme.org/", nullptr, "test=expiry; expires=Thu, 10 Apr 1980 16:33:12 GMT", nullptr);
+    GetACookie(cookieService, "http://expireme.org/", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
+    SetACookie(cookieService, "http://expireme.org/", nullptr, "test=expiry; max-age=60", nullptr);
+    SetACookie(cookieService, "http://expireme.org/", nullptr, "newtest=expiry; max-age=60", nullptr);
+    GetACookie(cookieService, "http://expireme.org/", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_CONTAIN, "test=expiry"));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_CONTAIN, "newtest=expiry"));
+    SetACookie(cookieService, "http://expireme.org/", nullptr, "test=differentvalue; max-age=0", nullptr);
+    GetACookie(cookieService, "http://expireme.org/", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "newtest=expiry"));
+    SetACookie(cookieService, "http://expireme.org/", nullptr, "newtest=evendifferentvalue; max-age=0", nullptr);
+    GetACookie(cookieService, "http://expireme.org/", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
 
-      SetACookie(cookieService, "http://foo.expireme.org/", nullptr, "test=expiry; domain=.expireme.org; max-age=60", nullptr);
-      GetACookie(cookieService, "http://expireme.org/", nullptr, getter_Copies(cookie));
-      rv[14] = CheckResult(cookie.get(), MUST_EQUAL, "test=expiry");
-      SetACookie(cookieService, "http://bar.expireme.org/", nullptr, "test=differentvalue; domain=.expireme.org; max-age=0", nullptr);
-      GetACookie(cookieService, "http://expireme.org/", nullptr, getter_Copies(cookie));
-      rv[15] = CheckResult(cookie.get(), MUST_BE_NULL);
+    SetACookie(cookieService, "http://foo.expireme.org/", nullptr, "test=expiry; domain=.expireme.org; max-age=60", nullptr);
+    GetACookie(cookieService, "http://expireme.org/", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test=expiry"));
+    SetACookie(cookieService, "http://bar.expireme.org/", nullptr, "test=differentvalue; domain=.expireme.org; max-age=0", nullptr);
+    GetACookie(cookieService, "http://expireme.org/", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
 
-      nsAutoCString ServerTime;
-      nsAutoCString CookieString;
+    nsAutoCString ServerTime;
+    nsAutoCString CookieString;
 
-      SetTime(-OFFSET_ONE_WEEK, ServerTime, CookieString, true);
-      SetACookie(cookieService, "http://expireme.org/", nullptr, CookieString.get(), ServerTime.get());
-      GetACookie(cookieService, "http://expireme.org/", nullptr, getter_Copies(cookie));
-      rv[16] = CheckResult(cookie.get(), MUST_BE_NULL);
-      // Set server time earlier than client time for one year + one day, and expirty time earlier than server time for one day.
-      SetTime(-(OFFSET_ONE_DAY + OFFSET_ONE_WEEK), ServerTime, CookieString, false);
-      SetACookie(cookieService, "http://expireme.org/", nullptr, CookieString.get(), ServerTime.get());
-      GetACookie(cookieService, "http://expireme.org/", nullptr, getter_Copies(cookie));
-      rv[17] = CheckResult(cookie.get(), MUST_BE_NULL);
-      // Set server time later than client time for one year, and expiry time later than server time for one day.
-      SetTime(OFFSET_ONE_WEEK, ServerTime, CookieString, false);
-      SetACookie(cookieService, "http://expireme.org/", nullptr, CookieString.get(), ServerTime.get());
-      GetACookie(cookieService, "http://expireme.org/", nullptr, getter_Copies(cookie));
-      rv[18] = CheckResult(cookie.get(), MUST_EQUAL, "test=expiry");
-      // Set server time later than client time for one year + one day, and expiry time earlier than server time for one day.
-      SetTime((OFFSET_ONE_DAY + OFFSET_ONE_WEEK), ServerTime, CookieString, true);
-      SetACookie(cookieService, "http://expireme.org/", nullptr, CookieString.get(), ServerTime.get());
-      GetACookie(cookieService, "http://expireme.org/", nullptr, getter_Copies(cookie));
-      rv[19] = CheckResult(cookie.get(), MUST_EQUAL, "test=expiry");
-      allTestsPassed = PrintResult(rv, 20) && allTestsPassed;
+    SetTime(-OFFSET_ONE_WEEK, ServerTime, CookieString, true);
+    SetACookie(cookieService, "http://expireme.org/", nullptr, CookieString.get(), ServerTime.get());
+    GetACookie(cookieService, "http://expireme.org/", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
+    // Set server time earlier than client time for one year + one day, and expirty time earlier than server time for one day.
+    SetTime(-(OFFSET_ONE_DAY + OFFSET_ONE_WEEK), ServerTime, CookieString, false);
+    SetACookie(cookieService, "http://expireme.org/", nullptr, CookieString.get(), ServerTime.get());
+    GetACookie(cookieService, "http://expireme.org/", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
+    // Set server time later than client time for one year, and expiry time later than server time for one day.
+    SetTime(OFFSET_ONE_WEEK, ServerTime, CookieString, false);
+    SetACookie(cookieService, "http://expireme.org/", nullptr, CookieString.get(), ServerTime.get());
+    GetACookie(cookieService, "http://expireme.org/", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test=expiry"));
+    // Set server time later than client time for one year + one day, and expiry time earlier than server time for one day.
+    SetTime((OFFSET_ONE_DAY + OFFSET_ONE_WEEK), ServerTime, CookieString, true);
+    SetACookie(cookieService, "http://expireme.org/", nullptr, CookieString.get(), ServerTime.get());
+    GetACookie(cookieService, "http://expireme.org/", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test=expiry"));
 
-      // *** multiple cookie tests
-      sBuffer = PR_sprintf_append(sBuffer, "*** Beginning multiple cookie tests...\n");
+    // *** multiple cookie tests
 
-      // test the setting of multiple cookies, and test the order of precedence
-      // (a later cookie overwriting an earlier one, in the same header string)
-      SetACookie(cookieService, "http://multiple.cookies/", nullptr, "test=multiple; domain=.multiple.cookies \n test=different \n test=same; domain=.multiple.cookies \n newtest=ciao \n newtest=foo; max-age=-6 \n newtest=reincarnated", nullptr);
-      GetACookie(cookieService, "http://multiple.cookies/", nullptr, getter_Copies(cookie));
-      rv[0] = CheckResult(cookie.get(), MUST_NOT_CONTAIN, "test=multiple");
-      rv[1] = CheckResult(cookie.get(), MUST_CONTAIN, "test=different");
-      rv[2] = CheckResult(cookie.get(), MUST_CONTAIN, "test=same");
-      rv[3] = CheckResult(cookie.get(), MUST_NOT_CONTAIN, "newtest=ciao");
-      rv[4] = CheckResult(cookie.get(), MUST_NOT_CONTAIN, "newtest=foo");
-      rv[5] = CheckResult(cookie.get(), MUST_CONTAIN, "newtest=reincarnated");
-      SetACookie(cookieService, "http://multiple.cookies/", nullptr, "test=expiry; domain=.multiple.cookies; max-age=0", nullptr);
-      GetACookie(cookieService, "http://multiple.cookies/", nullptr, getter_Copies(cookie));
-      rv[6] = CheckResult(cookie.get(), MUST_NOT_CONTAIN, "test=same");
-      SetACookie(cookieService, "http://multiple.cookies/", nullptr,  "\n test=different; max-age=0 \n", nullptr);
-      GetACookie(cookieService, "http://multiple.cookies/", nullptr, getter_Copies(cookie));
-      rv[7] = CheckResult(cookie.get(), MUST_NOT_CONTAIN, "test=different");
-      SetACookie(cookieService, "http://multiple.cookies/", nullptr,  "newtest=dead; max-age=0", nullptr);
-      GetACookie(cookieService, "http://multiple.cookies/", nullptr, getter_Copies(cookie));
-      rv[8] = CheckResult(cookie.get(), MUST_BE_NULL);
-
-      allTestsPassed = PrintResult(rv, 9) && allTestsPassed;
+    // test the setting of multiple cookies, and test the order of precedence
+    // (a later cookie overwriting an earlier one, in the same header string)
+    SetACookie(cookieService, "http://multiple.cookies/", nullptr, "test=multiple; domain=.multiple.cookies \n test=different \n test=same; domain=.multiple.cookies \n newtest=ciao \n newtest=foo; max-age=-6 \n newtest=reincarnated", nullptr);
+    GetACookie(cookieService, "http://multiple.cookies/", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_NOT_CONTAIN, "test=multiple"));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_CONTAIN, "test=different"));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_CONTAIN, "test=same"));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_NOT_CONTAIN, "newtest=ciao"));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_NOT_CONTAIN, "newtest=foo"));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_CONTAIN, "newtest=reincarnated"));
+    SetACookie(cookieService, "http://multiple.cookies/", nullptr, "test=expiry; domain=.multiple.cookies; max-age=0", nullptr);
+    GetACookie(cookieService, "http://multiple.cookies/", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_NOT_CONTAIN, "test=same"));
+    SetACookie(cookieService, "http://multiple.cookies/", nullptr,  "\n test=different; max-age=0 \n", nullptr);
+    GetACookie(cookieService, "http://multiple.cookies/", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_NOT_CONTAIN, "test=different"));
+    SetACookie(cookieService, "http://multiple.cookies/", nullptr,  "newtest=dead; max-age=0", nullptr);
+    GetACookie(cookieService, "http://multiple.cookies/", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
 
 
-      // *** parser tests
-      sBuffer = PR_sprintf_append(sBuffer, "*** Beginning parser tests...\n");
+    // *** parser tests
 
-      // test the cookie header parser, under various circumstances.
-      SetACookie(cookieService, "http://parser.test/", nullptr, "test=parser; domain=.parser.test; ;; ;=; ,,, ===,abc,=; abracadabra! max-age=20;=;;", nullptr);
-      GetACookie(cookieService, "http://parser.test/", nullptr, getter_Copies(cookie));
-      rv[0] = CheckResult(cookie.get(), MUST_EQUAL, "test=parser");
-      SetACookie(cookieService, "http://parser.test/", nullptr, "test=parser; domain=.parser.test; max-age=0", nullptr);
-      GetACookie(cookieService, "http://parser.test/", nullptr, getter_Copies(cookie));
-      rv[1] = CheckResult(cookie.get(), MUST_BE_NULL);
-      SetACookie(cookieService, "http://parser.test/", nullptr, "test=\"fubar! = foo;bar\\\";\" parser; domain=.parser.test; max-age=6\nfive; max-age=2.63,", nullptr);
-      GetACookie(cookieService, "http://parser.test/", nullptr, getter_Copies(cookie));
-      rv[2] = CheckResult(cookie.get(), MUST_CONTAIN, R"(test="fubar! = foo)");
-      rv[3] = CheckResult(cookie.get(), MUST_CONTAIN, "five");
-      SetACookie(cookieService, "http://parser.test/", nullptr, "test=kill; domain=.parser.test; max-age=0 \n five; max-age=0", nullptr);
-      GetACookie(cookieService, "http://parser.test/", nullptr, getter_Copies(cookie));
-      rv[4] = CheckResult(cookie.get(), MUST_BE_NULL);
+    // test the cookie header parser, under various circumstances.
+    SetACookie(cookieService, "http://parser.test/", nullptr, "test=parser; domain=.parser.test; ;; ;=; ,,, ===,abc,=; abracadabra! max-age=20;=;;", nullptr);
+    GetACookie(cookieService, "http://parser.test/", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test=parser"));
+    SetACookie(cookieService, "http://parser.test/", nullptr, "test=parser; domain=.parser.test; max-age=0", nullptr);
+    GetACookie(cookieService, "http://parser.test/", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
+    SetACookie(cookieService, "http://parser.test/", nullptr, "test=\"fubar! = foo;bar\\\";\" parser; domain=.parser.test; max-age=6\nfive; max-age=2.63,", nullptr);
+    GetACookie(cookieService, "http://parser.test/", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_CONTAIN, R"(test="fubar! = foo)"));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_CONTAIN, "five"));
+    SetACookie(cookieService, "http://parser.test/", nullptr, "test=kill; domain=.parser.test; max-age=0 \n five; max-age=0", nullptr);
+    GetACookie(cookieService, "http://parser.test/", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
 
-      // test the handling of VALUE-only cookies (see bug 169091),
-      // i.e. "six" should assume an empty NAME, which allows other VALUE-only
-      // cookies to overwrite it
-      SetACookie(cookieService, "http://parser.test/", nullptr, "six", nullptr);
-      GetACookie(cookieService, "http://parser.test/", nullptr, getter_Copies(cookie));
-      rv[5] = CheckResult(cookie.get(), MUST_EQUAL, "six");
-      SetACookie(cookieService, "http://parser.test/", nullptr, "seven", nullptr);
-      GetACookie(cookieService, "http://parser.test/", nullptr, getter_Copies(cookie));
-      rv[6] = CheckResult(cookie.get(), MUST_EQUAL, "seven");
-      SetACookie(cookieService, "http://parser.test/", nullptr, " =eight", nullptr);
-      GetACookie(cookieService, "http://parser.test/", nullptr, getter_Copies(cookie));
-      rv[7] = CheckResult(cookie.get(), MUST_EQUAL, "eight");
-      SetACookie(cookieService, "http://parser.test/", nullptr, "test=six", nullptr);
-      GetACookie(cookieService, "http://parser.test/", nullptr, getter_Copies(cookie));
-      rv[9] = CheckResult(cookie.get(), MUST_CONTAIN, "test=six");
+    // test the handling of VALUE-only cookies (see bug 169091),
+    // i.e. "six" should assume an empty NAME, which allows other VALUE-only
+    // cookies to overwrite it
+    SetACookie(cookieService, "http://parser.test/", nullptr, "six", nullptr);
+    GetACookie(cookieService, "http://parser.test/", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "six"));
+    SetACookie(cookieService, "http://parser.test/", nullptr, "seven", nullptr);
+    GetACookie(cookieService, "http://parser.test/", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "seven"));
+    SetACookie(cookieService, "http://parser.test/", nullptr, " =eight", nullptr);
+    GetACookie(cookieService, "http://parser.test/", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "eight"));
+    SetACookie(cookieService, "http://parser.test/", nullptr, "test=six", nullptr);
+    GetACookie(cookieService, "http://parser.test/", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_CONTAIN, "test=six"));
 
-      allTestsPassed = PrintResult(rv, 10) && allTestsPassed;
-
-
-      // *** path ordering tests
-      sBuffer = PR_sprintf_append(sBuffer, "*** Beginning path ordering tests...\n");
+    // *** path ordering tests
 
-      // test that cookies are returned in path order - longest to shortest.
-      // if the header doesn't specify a path, it's taken from the host URI.
-      SetACookie(cookieService, "http://multi.path.tests/", nullptr, "test1=path; path=/one/two/three", nullptr);
-      SetACookie(cookieService, "http://multi.path.tests/", nullptr, "test2=path; path=/one \n test3=path; path=/one/two/three/four \n test4=path; path=/one/two \n test5=path; path=/one/two/", nullptr);
-      SetACookie(cookieService, "http://multi.path.tests/one/two/three/four/five/", nullptr, "test6=path", nullptr);
-      SetACookie(cookieService, "http://multi.path.tests/one/two/three/four/five/six/", nullptr, "test7=path; path=", nullptr);
-      SetACookie(cookieService, "http://multi.path.tests/", nullptr, "test8=path; path=/", nullptr);
-      GetACookie(cookieService, "http://multi.path.tests/one/two/three/four/five/six/", nullptr, getter_Copies(cookie));
-      rv[0] = CheckResult(cookie.get(), MUST_EQUAL, "test7=path; test6=path; test3=path; test1=path; test5=path; test4=path; test2=path; test8=path");
-
-      allTestsPassed = PrintResult(rv, 1) && allTestsPassed;
+    // test that cookies are returned in path order - longest to shortest.
+    // if the header doesn't specify a path, it's taken from the host URI.
+    SetACookie(cookieService, "http://multi.path.tests/", nullptr, "test1=path; path=/one/two/three", nullptr);
+    SetACookie(cookieService, "http://multi.path.tests/", nullptr, "test2=path; path=/one \n test3=path; path=/one/two/three/four \n test4=path; path=/one/two \n test5=path; path=/one/two/", nullptr);
+    SetACookie(cookieService, "http://multi.path.tests/one/two/three/four/five/", nullptr, "test6=path", nullptr);
+    SetACookie(cookieService, "http://multi.path.tests/one/two/three/four/five/six/", nullptr, "test7=path; path=", nullptr);
+    SetACookie(cookieService, "http://multi.path.tests/", nullptr, "test8=path; path=/", nullptr);
+    GetACookie(cookieService, "http://multi.path.tests/one/two/three/four/five/six/", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test7=path; test6=path; test3=path; test1=path; test5=path; test4=path; test2=path; test8=path"));
 
 
-      // *** httponly tests
-      sBuffer = PR_sprintf_append(sBuffer, "*** Beginning httponly tests...\n");
+    // *** httponly tests
 
-      // Since this cookie is NOT set via http, setting it fails
-      SetACookieNoHttp(cookieService, "http://httponly.test/", "test=httponly; httponly");
-      GetACookie(cookieService, "http://httponly.test/", nullptr, getter_Copies(cookie));
-      rv[0] = CheckResult(cookie.get(), MUST_BE_NULL);
-      // Since this cookie is set via http, it can be retrieved
-      SetACookie(cookieService, "http://httponly.test/", nullptr, "test=httponly; httponly", nullptr);
-      GetACookie(cookieService, "http://httponly.test/", nullptr, getter_Copies(cookie));
-      rv[1] = CheckResult(cookie.get(), MUST_EQUAL, "test=httponly");
-      // ... but not by web content
-      GetACookieNoHttp(cookieService, "http://httponly.test/", getter_Copies(cookie));
-      rv[2] = CheckResult(cookie.get(), MUST_BE_NULL);
-      // Non-Http cookies should not replace HttpOnly cookies
-      SetACookie(cookieService, "http://httponly.test/", nullptr, "test=httponly; httponly", nullptr);
-      SetACookieNoHttp(cookieService, "http://httponly.test/", "test=not-httponly");
-      GetACookie(cookieService, "http://httponly.test/", nullptr, getter_Copies(cookie));
-      rv[3] = CheckResult(cookie.get(), MUST_EQUAL, "test=httponly");
-      // ... and, if an HttpOnly cookie already exists, should not be set at all
-      GetACookieNoHttp(cookieService, "http://httponly.test/", getter_Copies(cookie));
-      rv[4] = CheckResult(cookie.get(), MUST_BE_NULL);
-      // Non-Http cookies should not delete HttpOnly cookies
-      SetACookie(cookieService, "http://httponly.test/", nullptr, "test=httponly; httponly", nullptr);
-      SetACookieNoHttp(cookieService, "http://httponly.test/", "test=httponly; max-age=-1");
-      GetACookie(cookieService, "http://httponly.test/", nullptr, getter_Copies(cookie));
-      rv[5] = CheckResult(cookie.get(), MUST_EQUAL, "test=httponly");
-      // ... but HttpOnly cookies should
-      SetACookie(cookieService, "http://httponly.test/", nullptr, "test=httponly; httponly; max-age=-1", nullptr);
-      GetACookie(cookieService, "http://httponly.test/", nullptr, getter_Copies(cookie));
-      rv[6] = CheckResult(cookie.get(), MUST_BE_NULL);
-      // Non-Httponly cookies can replace HttpOnly cookies when set over http
-      SetACookie(cookieService, "http://httponly.test/", nullptr, "test=httponly; httponly", nullptr);
-      SetACookie(cookieService, "http://httponly.test/", nullptr, "test=not-httponly", nullptr);
-      GetACookieNoHttp(cookieService, "http://httponly.test/", getter_Copies(cookie));
-      rv[7] = CheckResult(cookie.get(), MUST_EQUAL, "test=not-httponly");
-      // scripts should not be able to set httponly cookies by replacing an existing non-httponly cookie
-      SetACookie(cookieService, "http://httponly.test/", nullptr, "test=not-httponly", nullptr);
-      SetACookieNoHttp(cookieService, "http://httponly.test/", "test=httponly; httponly");
-      GetACookieNoHttp(cookieService, "http://httponly.test/", getter_Copies(cookie));
-      rv[8] = CheckResult(cookie.get(), MUST_EQUAL, "test=not-httponly");
-
-      allTestsPassed = PrintResult(rv, 9) && allTestsPassed;
-
+    // Since this cookie is NOT set via http, setting it fails
+    SetACookieNoHttp(cookieService, "http://httponly.test/", "test=httponly; httponly");
+    GetACookie(cookieService, "http://httponly.test/", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
+    // Since this cookie is set via http, it can be retrieved
+    SetACookie(cookieService, "http://httponly.test/", nullptr, "test=httponly; httponly", nullptr);
+    GetACookie(cookieService, "http://httponly.test/", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test=httponly"));
+    // ... but not by web content
+    GetACookieNoHttp(cookieService, "http://httponly.test/", getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
+    // Non-Http cookies should not replace HttpOnly cookies
+    SetACookie(cookieService, "http://httponly.test/", nullptr, "test=httponly; httponly", nullptr);
+    SetACookieNoHttp(cookieService, "http://httponly.test/", "test=not-httponly");
+    GetACookie(cookieService, "http://httponly.test/", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test=httponly"));
+    // ... and, if an HttpOnly cookie already exists, should not be set at all
+    GetACookieNoHttp(cookieService, "http://httponly.test/", getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
+    // Non-Http cookies should not delete HttpOnly cookies
+    SetACookie(cookieService, "http://httponly.test/", nullptr, "test=httponly; httponly", nullptr);
+    SetACookieNoHttp(cookieService, "http://httponly.test/", "test=httponly; max-age=-1");
+    GetACookie(cookieService, "http://httponly.test/", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test=httponly"));
+    // ... but HttpOnly cookies should
+    SetACookie(cookieService, "http://httponly.test/", nullptr, "test=httponly; httponly; max-age=-1", nullptr);
+    GetACookie(cookieService, "http://httponly.test/", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
+    // Non-Httponly cookies can replace HttpOnly cookies when set over http
+    SetACookie(cookieService, "http://httponly.test/", nullptr, "test=httponly; httponly", nullptr);
+    SetACookie(cookieService, "http://httponly.test/", nullptr, "test=not-httponly", nullptr);
+    GetACookieNoHttp(cookieService, "http://httponly.test/", getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test=not-httponly"));
+    // scripts should not be able to set httponly cookies by replacing an existing non-httponly cookie
+    SetACookie(cookieService, "http://httponly.test/", nullptr, "test=not-httponly", nullptr);
+    SetACookieNoHttp(cookieService, "http://httponly.test/", "test=httponly; httponly");
+    GetACookieNoHttp(cookieService, "http://httponly.test/", getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test=not-httponly"));
 
-      // *** Cookie prefix tests
-      sBuffer = PR_sprintf_append(sBuffer, "*** Beginning cookie prefix tests...\n");
+    // *** Cookie prefix tests
 
-      // prefixed cookies can't be set from insecure HTTP
-      SetACookie(cookieService, "http://prefixed.test/", nullptr, "__Secure-test1=test", nullptr);
-      SetACookie(cookieService, "http://prefixed.test/", nullptr, "__Secure-test2=test; secure", nullptr);
-      SetACookie(cookieService, "http://prefixed.test/", nullptr, "__Host-test1=test", nullptr);
-      SetACookie(cookieService, "http://prefixed.test/", nullptr, "__Host-test2=test; secure", nullptr);
-      GetACookie(cookieService, "http://prefixed.test/", nullptr, getter_Copies(cookie));
-      rv[0] = CheckResult(cookie.get(), MUST_BE_NULL);
+    // prefixed cookies can't be set from insecure HTTP
+    SetACookie(cookieService, "http://prefixed.test/", nullptr, "__Secure-test1=test", nullptr);
+    SetACookie(cookieService, "http://prefixed.test/", nullptr, "__Secure-test2=test; secure", nullptr);
+    SetACookie(cookieService, "http://prefixed.test/", nullptr, "__Host-test1=test", nullptr);
+    SetACookie(cookieService, "http://prefixed.test/", nullptr, "__Host-test2=test; secure", nullptr);
+    GetACookie(cookieService, "http://prefixed.test/", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
 
-      // prefixed cookies won't be set without the secure flag
-      SetACookie(cookieService, "https://prefixed.test/", nullptr, "__Secure-test=test", nullptr);
-      SetACookie(cookieService, "https://prefixed.test/", nullptr, "__Host-test=test", nullptr);
-      GetACookie(cookieService, "https://prefixed.test/", nullptr, getter_Copies(cookie));
-      rv[1] = CheckResult(cookie.get(), MUST_BE_NULL);
+    // prefixed cookies won't be set without the secure flag
+    SetACookie(cookieService, "https://prefixed.test/", nullptr, "__Secure-test=test", nullptr);
+    SetACookie(cookieService, "https://prefixed.test/", nullptr, "__Host-test=test", nullptr);
+    GetACookie(cookieService, "https://prefixed.test/", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
 
-      // prefixed cookies can be set when done correctly
-      SetACookie(cookieService, "https://prefixed.test/", nullptr, "__Secure-test=test; secure", nullptr);
-      SetACookie(cookieService, "https://prefixed.test/", nullptr, "__Host-test=test; secure", nullptr);
-      GetACookie(cookieService, "https://prefixed.test/", nullptr, getter_Copies(cookie));
-      rv[2] = CheckResult(cookie.get(), MUST_CONTAIN, "__Secure-test=test");
-      rv[3] = CheckResult(cookie.get(), MUST_CONTAIN, "__Host-test=test");
+    // prefixed cookies can be set when done correctly
+    SetACookie(cookieService, "https://prefixed.test/", nullptr, "__Secure-test=test; secure", nullptr);
+    SetACookie(cookieService, "https://prefixed.test/", nullptr, "__Host-test=test; secure", nullptr);
+    GetACookie(cookieService, "https://prefixed.test/", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_CONTAIN, "__Secure-test=test"));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_CONTAIN, "__Host-test=test"));
 
-      // but when set must not be returned to the host insecurely
-      GetACookie(cookieService, "http://prefixed.test/", nullptr, getter_Copies(cookie));
-      rv[4] = CheckResult(cookie.get(), MUST_BE_NULL);
+    // but when set must not be returned to the host insecurely
+    GetACookie(cookieService, "http://prefixed.test/", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
 
-      // Host-prefixed cookies cannot specify a domain
-      SetACookie(cookieService, "https://host.prefixed.test/", nullptr, "__Host-a=test; secure; domain=prefixed.test", nullptr);
-      SetACookie(cookieService, "https://host.prefixed.test/", nullptr, "__Host-b=test; secure; domain=.prefixed.test", nullptr);
-      SetACookie(cookieService, "https://host.prefixed.test/", nullptr, "__Host-c=test; secure; domain=host.prefixed.test", nullptr);
-      SetACookie(cookieService, "https://host.prefixed.test/", nullptr, "__Host-d=test; secure; domain=.host.prefixed.test", nullptr);
-      GetACookie(cookieService, "https://host.prefixed.test/", nullptr, getter_Copies(cookie));
-      rv[5] = CheckResult(cookie.get(), MUST_BE_NULL);
+    // Host-prefixed cookies cannot specify a domain
+    SetACookie(cookieService, "https://host.prefixed.test/", nullptr, "__Host-a=test; secure; domain=prefixed.test", nullptr);
+    SetACookie(cookieService, "https://host.prefixed.test/", nullptr, "__Host-b=test; secure; domain=.prefixed.test", nullptr);
+    SetACookie(cookieService, "https://host.prefixed.test/", nullptr, "__Host-c=test; secure; domain=host.prefixed.test", nullptr);
+    SetACookie(cookieService, "https://host.prefixed.test/", nullptr, "__Host-d=test; secure; domain=.host.prefixed.test", nullptr);
+    GetACookie(cookieService, "https://host.prefixed.test/", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
 
-      // Host-prefixed cookies can only have a path of "/"
-      SetACookie(cookieService, "https://host.prefixed.test/some/path", nullptr, "__Host-e=test; secure", nullptr);
-      SetACookie(cookieService, "https://host.prefixed.test/some/path", nullptr, "__Host-f=test; secure; path=/", nullptr);
-      SetACookie(cookieService, "https://host.prefixed.test/some/path", nullptr, "__Host-g=test; secure; path=/some", nullptr);
-      GetACookie(cookieService, "https://host.prefixed.test/", nullptr, getter_Copies(cookie));
-      rv[6] = CheckResult(cookie.get(), MUST_EQUAL, "__Host-f=test");
+    // Host-prefixed cookies can only have a path of "/"
+    SetACookie(cookieService, "https://host.prefixed.test/some/path", nullptr, "__Host-e=test; secure", nullptr);
+    SetACookie(cookieService, "https://host.prefixed.test/some/path", nullptr, "__Host-f=test; secure; path=/", nullptr);
+    SetACookie(cookieService, "https://host.prefixed.test/some/path", nullptr, "__Host-g=test; secure; path=/some", nullptr);
+    GetACookie(cookieService, "https://host.prefixed.test/", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "__Host-f=test"));
 
-      allTestsPassed = PrintResult(rv, 7) && allTestsPassed;
+    // *** leave-secure-alone tests
 
-      // *** leave-secure-alone tests
-      sBuffer = PR_sprintf_append(sBuffer, "*** Beginning leave-secure-alone tests...\n");
+    // testing items 0 & 1 for 3.1 of spec Deprecate modification of ’secure’
+    // cookies from non-secure origins
+    SetACookie(cookieService, "http://www.security.test/", nullptr, "test=non-security; secure", nullptr);
+    GetACookieNoHttp(cookieService, "https://www.security.test/", getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
+    SetACookie(cookieService, "https://www.security.test/path/", nullptr, "test=security; secure; path=/path/", nullptr);
+    GetACookieNoHttp(cookieService, "https://www.security.test/path/", getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test=security"));
+    // testing items 2 & 3 & 4 for 3.2 of spec Deprecate modification of ’secure’
+    // cookies from non-secure origins
+    // Secure site can modify cookie value
+    SetACookie(cookieService, "https://www.security.test/path/", nullptr, "test=security2; secure; path=/path/", nullptr);
+    GetACookieNoHttp(cookieService, "https://www.security.test/path/", getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test=security2"));
+    // If new cookie contains same name, same host and partially matching path with
+    // an existing security cookie on non-security site, it can't modify an existing
+    // security cookie.
+    SetACookie(cookieService, "http://www.security.test/path/foo/", nullptr, "test=non-security; path=/path/foo", nullptr);
+    GetACookieNoHttp(cookieService, "https://www.security.test/path/foo/", getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test=security2"));
+    // Non-secure cookie can set by same name, same host and non-matching path.
+    SetACookie(cookieService, "http://www.security.test/bar/", nullptr, "test=non-security; path=/bar", nullptr);
+    GetACookieNoHttp(cookieService, "http://www.security.test/bar/", getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test=non-security"));
+    // Modify value and downgrade secure level.
+    SetACookie(cookieService, "https://www.security.test/", nullptr, "test_modify_cookie=security-cookie; secure; domain=.security.test", nullptr);
+    GetACookieNoHttp(cookieService, "https://www.security.test/", getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test_modify_cookie=security-cookie"));
+    SetACookie(cookieService, "https://www.security.test/", nullptr, "test_modify_cookie=non-security-cookie; domain=.security.test", nullptr);
+    GetACookieNoHttp(cookieService, "https://www.security.test/", getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test_modify_cookie=non-security-cookie"));
+    // Test the non-security cookie can set when domain or path not same to secure cookie of same name.
+    SetACookie(cookieService, "https://www.security.test/", nullptr, "test=security3", nullptr);
+    GetACookieNoHttp(cookieService, "http://www.security.test/", getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_CONTAIN, "test=security3"));
+    SetACookie(cookieService, "http://www.security.test/", nullptr, "test=non-security2; domain=security.test", nullptr);
+    GetACookieNoHttp(cookieService, "http://www.security.test/", getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_CONTAIN, "test=non-security2"));
 
-      // testing items 0 & 1 for 3.1 of spec Deprecate modification of ’secure’
-      // cookies from non-secure origins
-      SetACookie(cookieService, "http://www.security.test/", nullptr, "test=non-security; secure", nullptr);
-      GetACookieNoHttp(cookieService, "https://www.security.test/", getter_Copies(cookie));
-      rv[0] = CheckResult(cookie.get(), MUST_BE_NULL);
-      SetACookie(cookieService, "https://www.security.test/path/", nullptr, "test=security; secure; path=/path/", nullptr);
-      GetACookieNoHttp(cookieService, "https://www.security.test/path/", getter_Copies(cookie));
-      rv[1] = CheckResult(cookie.get(), MUST_EQUAL, "test=security");
-      // testing items 2 & 3 & 4 for 3.2 of spec Deprecate modification of ’secure’
-      // cookies from non-secure origins
-      // Secure site can modify cookie value
-      SetACookie(cookieService, "https://www.security.test/path/", nullptr, "test=security2; secure; path=/path/", nullptr);
-      GetACookieNoHttp(cookieService, "https://www.security.test/path/", getter_Copies(cookie));
-      rv[2] = CheckResult(cookie.get(), MUST_EQUAL, "test=security2");
-      // If new cookie contains same name, same host and partially matching path with
-      // an existing security cookie on non-security site, it can't modify an existing
-      // security cookie.
-      SetACookie(cookieService, "http://www.security.test/path/foo/", nullptr, "test=non-security; path=/path/foo", nullptr);
-      GetACookieNoHttp(cookieService, "https://www.security.test/path/foo/", getter_Copies(cookie));
-      rv[3] = CheckResult(cookie.get(), MUST_EQUAL, "test=security2");
-      // Non-secure cookie can set by same name, same host and non-matching path.
-      SetACookie(cookieService, "http://www.security.test/bar/", nullptr, "test=non-security; path=/bar", nullptr);
-      GetACookieNoHttp(cookieService, "http://www.security.test/bar/", getter_Copies(cookie));
-      rv[4] = CheckResult(cookie.get(), MUST_EQUAL, "test=non-security");
-      // Modify value and downgrade secure level.
-      SetACookie(cookieService, "https://www.security.test/", nullptr, "test_modify_cookie=security-cookie; secure; domain=.security.test", nullptr);
-      GetACookieNoHttp(cookieService, "https://www.security.test/", getter_Copies(cookie));
-      rv[5] = CheckResult(cookie.get(), MUST_EQUAL, "test_modify_cookie=security-cookie");
-      SetACookie(cookieService, "https://www.security.test/", nullptr, "test_modify_cookie=non-security-cookie; domain=.security.test", nullptr);
-      GetACookieNoHttp(cookieService, "https://www.security.test/", getter_Copies(cookie));
-      rv[6] = CheckResult(cookie.get(), MUST_EQUAL, "test_modify_cookie=non-security-cookie");
-      // Test the non-security cookie can set when domain or path not same to secure cookie of same name.
-      SetACookie(cookieService, "https://www.security.test/", nullptr, "test=security3", nullptr);
-      GetACookieNoHttp(cookieService, "http://www.security.test/", getter_Copies(cookie));
-      rv[7] = CheckResult(cookie.get(), MUST_CONTAIN, "test=security3");
-      SetACookie(cookieService, "http://www.security.test/", nullptr, "test=non-security2; domain=security.test", nullptr);
-      GetACookieNoHttp(cookieService, "http://www.security.test/", getter_Copies(cookie));
-      rv[8] = CheckResult(cookie.get(), MUST_CONTAIN, "test=non-security2");
-
-      allTestsPassed = PrintResult(rv, 9) && allTestsPassed;
+    // *** nsICookieManager{2} interface tests
+    nsCOMPtr<nsICookieManager> cookieMgr = do_GetService(NS_COOKIEMANAGER_CONTRACTID, &rv0);
+    ASSERT_TRUE(NS_SUCCEEDED(rv0));
 
-      // *** nsICookieManager{2} interface tests
-      sBuffer = PR_sprintf_append(sBuffer, "*** Beginning nsICookieManager{2} interface tests...\n");
-      nsCOMPtr<nsICookieManager> cookieMgr = do_GetService(NS_COOKIEMANAGER_CONTRACTID, &rv0);
-      if (NS_FAILED(rv0)) return -1;
-      nsCOMPtr<nsICookieManager2> cookieMgr2 = do_QueryInterface(cookieMgr);
-      if (!cookieMgr2) return -1;
+    nsCOMPtr<nsICookieManager2> cookieMgr2 = do_QueryInterface(cookieMgr);
+    ASSERT_TRUE(cookieMgr2);
 
-      mozilla::NeckoOriginAttributes attrs;
+    mozilla::NeckoOriginAttributes attrs;
 
-      // first, ensure a clean slate
-      rv[0] = NS_SUCCEEDED(cookieMgr->RemoveAll());
-      // add some cookies
-      rv[1] = NS_SUCCEEDED(cookieMgr2->AddNative(NS_LITERAL_CSTRING("cookiemgr.test"), // domain
-                                           NS_LITERAL_CSTRING("/foo"),           // path
-                                           NS_LITERAL_CSTRING("test1"),          // name
-                                           NS_LITERAL_CSTRING("yes"),            // value
-                                           false,                             // is secure
-                                           false,                             // is httponly
-                                           true,                              // is session
-                                           INT64_MAX,                            // expiry time
-                                           &attrs));                         // originAttributes
-      rv[2] = NS_SUCCEEDED(cookieMgr2->AddNative(NS_LITERAL_CSTRING("cookiemgr.test"), // domain
-                                           NS_LITERAL_CSTRING("/foo"),           // path
-                                           NS_LITERAL_CSTRING("test2"),          // name
-                                           NS_LITERAL_CSTRING("yes"),            // value
-                                           false,                             // is secure
-                                           true,                              // is httponly
-                                           true,                              // is session
-                                           PR_Now() / PR_USEC_PER_SEC + 2,       // expiry time
-                                           &attrs));                         // originAttributes
-      rv[3] = NS_SUCCEEDED(cookieMgr2->AddNative(NS_LITERAL_CSTRING("new.domain"),     // domain
-                                           NS_LITERAL_CSTRING("/rabbit"),        // path
-                                           NS_LITERAL_CSTRING("test3"),          // name
-                                           NS_LITERAL_CSTRING("yes"),            // value
-                                           false,                             // is secure
-                                           false,                             // is httponly
-                                           true,                              // is session
-                                           INT64_MAX,                            // expiry time
-                                           &attrs));                         // originAttributes
-      // confirm using enumerator
-      nsCOMPtr<nsISimpleEnumerator> enumerator;
-      rv[4] = NS_SUCCEEDED(cookieMgr->GetEnumerator(getter_AddRefs(enumerator)));
-      int32_t i = 0;
-      bool more;
-      nsCOMPtr<nsICookie2> expiredCookie, newDomainCookie;
-      while (NS_SUCCEEDED(enumerator->HasMoreElements(&more)) && more) {
+    // first, ensure a clean slate
+    EXPECT_TRUE(NS_SUCCEEDED(cookieMgr->RemoveAll()));
+    // add some cookies
+    EXPECT_TRUE(NS_SUCCEEDED(cookieMgr2->AddNative(NS_LITERAL_CSTRING("cookiemgr.test"), // domain
+                                                   NS_LITERAL_CSTRING("/foo"),           // path
+                                                   NS_LITERAL_CSTRING("test1"),          // name
+                                                   NS_LITERAL_CSTRING("yes"),            // value
+                                                   false,                             // is secure
+                                                   false,                             // is httponly
+                                                   true,                              // is session
+                                                   INT64_MAX,                            // expiry time
+                                                   &attrs)));                         // originAttributes
+    EXPECT_TRUE(NS_SUCCEEDED(cookieMgr2->AddNative(NS_LITERAL_CSTRING("cookiemgr.test"), // domain
+                                                   NS_LITERAL_CSTRING("/foo"),           // path
+                                                   NS_LITERAL_CSTRING("test2"),          // name
+                                                   NS_LITERAL_CSTRING("yes"),            // value
+                                                   false,                             // is secure
+                                                   true,                              // is httponly
+                                                   true,                              // is session
+                                                   PR_Now() / PR_USEC_PER_SEC + 2,       // expiry time
+                                                   &attrs)));                         // originAttributes
+    EXPECT_TRUE(NS_SUCCEEDED(cookieMgr2->AddNative(NS_LITERAL_CSTRING("new.domain"),     // domain
+                                                   NS_LITERAL_CSTRING("/rabbit"),        // path
+                                                   NS_LITERAL_CSTRING("test3"),          // name
+                                                   NS_LITERAL_CSTRING("yes"),            // value
+                                                   false,                             // is secure
+                                                   false,                             // is httponly
+                                                   true,                              // is session
+                                                   INT64_MAX,                            // expiry time
+                                                   &attrs)));                         // originAttributes
+    // confirm using enumerator
+    nsCOMPtr<nsISimpleEnumerator> enumerator;
+    EXPECT_TRUE(NS_SUCCEEDED(cookieMgr->GetEnumerator(getter_AddRefs(enumerator))));
+    int32_t i = 0;
+    bool more;
+    nsCOMPtr<nsICookie2> expiredCookie, newDomainCookie;
+    while (NS_SUCCEEDED(enumerator->HasMoreElements(&more)) && more) {
         nsCOMPtr<nsISupports> cookie;
         if (NS_FAILED(enumerator->GetNext(getter_AddRefs(cookie)))) break;
         ++i;
 
         // keep tabs on the second and third cookies, so we can check them later
         nsCOMPtr<nsICookie2> cookie2(do_QueryInterface(cookie));
         if (!cookie2) break;
         nsAutoCString name;
         cookie2->GetName(name);
         if (name.EqualsLiteral("test2"))
-          expiredCookie = cookie2;
+            expiredCookie = cookie2;
         else if (name.EqualsLiteral("test3"))
-          newDomainCookie = cookie2;
-      }
-      rv[5] = i == 3;
-      // check the httpOnly attribute of the second cookie is honored
-      GetACookie(cookieService, "http://cookiemgr.test/foo/", nullptr, getter_Copies(cookie));
-      rv[6] = CheckResult(cookie.get(), MUST_CONTAIN, "test2=yes");
-      GetACookieNoHttp(cookieService, "http://cookiemgr.test/foo/", getter_Copies(cookie));
-      rv[7] = CheckResult(cookie.get(), MUST_NOT_CONTAIN, "test2=yes");
-      // check CountCookiesFromHost()
-      uint32_t hostCookies = 0;
-      rv[8] = NS_SUCCEEDED(cookieMgr2->CountCookiesFromHost(NS_LITERAL_CSTRING("cookiemgr.test"), &hostCookies)) &&
-              hostCookies == 2;
-      // check CookieExistsNative() using the third cookie
-      bool found;
-      rv[9] = NS_SUCCEEDED(cookieMgr2->CookieExistsNative(newDomainCookie, &attrs,  &found)) && found;
+            newDomainCookie = cookie2;
+    }
+    EXPECT_EQ(i, 3);
+    // check the httpOnly attribute of the second cookie is honored
+    GetACookie(cookieService, "http://cookiemgr.test/foo/", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_CONTAIN, "test2=yes"));
+    GetACookieNoHttp(cookieService, "http://cookiemgr.test/foo/", getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_NOT_CONTAIN, "test2=yes"));
+    // check CountCookiesFromHost()
+    uint32_t hostCookies = 0;
+    EXPECT_TRUE(NS_SUCCEEDED(cookieMgr2->CountCookiesFromHost(NS_LITERAL_CSTRING("cookiemgr.test"), &hostCookies)));
+    EXPECT_EQ(hostCookies, 2u);
+    // check CookieExistsNative() using the third cookie
+    bool found;
+    EXPECT_TRUE(NS_SUCCEEDED(cookieMgr2->CookieExistsNative(newDomainCookie, &attrs,  &found)));
+    EXPECT_TRUE(found);
 
 
-      // remove the cookie, block it, and ensure it can't be added again
-      rv[10] = NS_SUCCEEDED(cookieMgr->RemoveNative(NS_LITERAL_CSTRING("new.domain"), // domain
-                                                    NS_LITERAL_CSTRING("test3"),      // name
-                                                    NS_LITERAL_CSTRING("/rabbit"),    // path
-                                                    true,                             // is blocked
-                                                    &attrs));                         // originAttributes
-      rv[11] = NS_SUCCEEDED(cookieMgr2->CookieExistsNative(newDomainCookie, &attrs, &found)) && !found;
-      rv[12] = NS_SUCCEEDED(cookieMgr2->AddNative(NS_LITERAL_CSTRING("new.domain"),     // domain
-                                            NS_LITERAL_CSTRING("/rabbit"),        // path
-                                            NS_LITERAL_CSTRING("test3"),          // name
-                                            NS_LITERAL_CSTRING("yes"),            // value
-                                            false,                             // is secure
-                                            false,                             // is httponly
-                                            true,                              // is session
-                                            INT64_MIN,                            // expiry time
-                                            &attrs));                         // originAttributes
-      rv[13] = NS_SUCCEEDED(cookieMgr2->CookieExistsNative(newDomainCookie, &attrs, &found)) && !found;
-      // sleep four seconds, to make sure the second cookie has expired
-      PR_Sleep(4 * PR_TicksPerSecond());
-      // check that both CountCookiesFromHost() and CookieExistsNative() count the
-      // expired cookie
-      rv[14] = NS_SUCCEEDED(cookieMgr2->CountCookiesFromHost(NS_LITERAL_CSTRING("cookiemgr.test"), &hostCookies)) &&
-              hostCookies == 2;
-      rv[15] = NS_SUCCEEDED(cookieMgr2->CookieExistsNative(expiredCookie, &attrs, &found)) && found;
-      // double-check RemoveAll() using the enumerator
-      rv[16] = NS_SUCCEEDED(cookieMgr->RemoveAll());
-      rv[17] = NS_SUCCEEDED(cookieMgr->GetEnumerator(getter_AddRefs(enumerator))) &&
-               NS_SUCCEEDED(enumerator->HasMoreElements(&more)) &&
-               !more;
+    // remove the cookie, block it, and ensure it can't be added again
+    EXPECT_TRUE(NS_SUCCEEDED(cookieMgr->RemoveNative(NS_LITERAL_CSTRING("new.domain"), // domain
+                                                     NS_LITERAL_CSTRING("test3"),      // name
+                                                     NS_LITERAL_CSTRING("/rabbit"),    // path
+                                                     true,                             // is blocked
+                                                     &attrs)));                         // originAttributes
+    EXPECT_TRUE(NS_SUCCEEDED(cookieMgr2->CookieExistsNative(newDomainCookie, &attrs, &found)));
+    EXPECT_FALSE(found);
+    EXPECT_TRUE(NS_SUCCEEDED(cookieMgr2->AddNative(NS_LITERAL_CSTRING("new.domain"),     // domain
+                                                   NS_LITERAL_CSTRING("/rabbit"),        // path
+                                                   NS_LITERAL_CSTRING("test3"),          // name
+                                                   NS_LITERAL_CSTRING("yes"),            // value
+                                                   false,                             // is secure
+                                                   false,                             // is httponly
+                                                   true,                              // is session
+                                                   INT64_MIN,                            // expiry time
+                                                   &attrs)));                         // originAttributes
+    EXPECT_TRUE(NS_SUCCEEDED(cookieMgr2->CookieExistsNative(newDomainCookie, &attrs, &found)));
+    EXPECT_FALSE(found);
+    // sleep four seconds, to make sure the second cookie has expired
+    PR_Sleep(4 * PR_TicksPerSecond());
+    // check that both CountCookiesFromHost() and CookieExistsNative() count the
+    // expired cookie
+    EXPECT_TRUE(NS_SUCCEEDED(cookieMgr2->CountCookiesFromHost(NS_LITERAL_CSTRING("cookiemgr.test"), &hostCookies)));
+    EXPECT_EQ(hostCookies, 2u);
+    EXPECT_TRUE(NS_SUCCEEDED(cookieMgr2->CookieExistsNative(expiredCookie, &attrs, &found)));
+    EXPECT_TRUE(found);
+    // double-check RemoveAll() using the enumerator
+    EXPECT_TRUE(NS_SUCCEEDED(cookieMgr->RemoveAll()));
+    EXPECT_TRUE(NS_SUCCEEDED(cookieMgr->GetEnumerator(getter_AddRefs(enumerator))) &&
+                NS_SUCCEEDED(enumerator->HasMoreElements(&more)) &&
+                !more);
 
-      allTestsPassed = PrintResult(rv, 18) && allTestsPassed;
-
-
-      // *** eviction and creation ordering tests
-      sBuffer = PR_sprintf_append(sBuffer, "*** Beginning eviction and creation ordering tests...\n");
+    // *** eviction and creation ordering tests
 
-      // test that cookies are
-      // a) returned by order of creation time (oldest first, newest last)
-      // b) evicted by order of lastAccessed time, if the limit on cookies per host (50) is reached
-      nsAutoCString name;
-      nsAutoCString expected;
-      for (int32_t i = 0; i < 60; ++i) {
+    // test that cookies are
+    // a) returned by order of creation time (oldest first, newest last)
+    // b) evicted by order of lastAccessed time, if the limit on cookies per host (50) is reached
+    nsAutoCString name;
+    nsAutoCString expected;
+    for (int32_t i = 0; i < 60; ++i) {
         name = NS_LITERAL_CSTRING("test");
         name.AppendInt(i);
         name += NS_LITERAL_CSTRING("=creation");
         SetACookie(cookieService, "http://creation.ordering.tests/", nullptr, name.get(), nullptr);
 
         if (i >= 10) {
-          expected += name;
-          if (i < 59)
-            expected += NS_LITERAL_CSTRING("; ");
+            expected += name;
+            if (i < 59)
+                expected += NS_LITERAL_CSTRING("; ");
         }
-      }
-      GetACookie(cookieService, "http://creation.ordering.tests/", nullptr, getter_Copies(cookie));
-      rv[0] = CheckResult(cookie.get(), MUST_EQUAL, expected.get());
-
-      allTestsPassed = PrintResult(rv, 1) && allTestsPassed;
-
-      // *** eviction and creation ordering tests after enable network.cookie.leave-secure-alone
-      sBuffer = PR_sprintf_append(sBuffer, "*** Beginning eviction and creation tests after enable nework.cookie.leave-secure-alone...\n");
-      // reset cookie
-      cookieMgr->RemoveAll();
+    }
+    GetACookie(cookieService, "http://creation.ordering.tests/", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, expected.get()));
 
-      for (int32_t i = 0; i < 60; ++i) {
-        name = NS_LITERAL_CSTRING("test");
-        name.AppendInt(i);
-        name += NS_LITERAL_CSTRING("=delete_non_security");
+    // *** eviction and creation ordering tests after enable network.cookie.leave-secure-alone
+    // reset cookie
+    cookieMgr->RemoveAll();
 
-        // Create 50 cookies that include the secure flag.
-        if (i < 50) {
-          name += NS_LITERAL_CSTRING("; secure");
-          SetACookie(cookieService, "https://creation.ordering.tests/", nullptr, name.get(), nullptr);
-        } else {
-          // non-security cookies will be removed beside the latest cookie that be created.
-          SetACookie(cookieService, "http://creation.ordering.tests/", nullptr, name.get(), nullptr);
-        }
-      }
-      GetACookie(cookieService, "http://creation.ordering.tests/", nullptr, getter_Copies(cookie));
-      rv[0] = CheckResult(cookie.get(), MUST_BE_NULL);
+    for (int32_t i = 0; i < 60; ++i) {
+      name = NS_LITERAL_CSTRING("test");
+      name.AppendInt(i);
+      name += NS_LITERAL_CSTRING("=delete_non_security");
 
-      allTestsPassed = PrintResult(rv, 1) && allTestsPassed;
-
-
-      // XXX the following are placeholders: add these tests please!
-      // *** "noncompliant cookie" tests
-      // *** IP address tests
-      // *** speed tests
-
-
-      sBuffer = PR_sprintf_append(sBuffer, "\n*** Result: %s!\n\n", allTestsPassed ? "all tests passed" : "TEST(S) FAILED");
+      // Create 50 cookies that include the secure flag.
+      if (i < 50) {
+        name += NS_LITERAL_CSTRING("; secure");
+        SetACookie(cookieService, "https://creation.ordering.tests/", nullptr, name.get(), nullptr);
+      } else {
+        // non-security cookies will be removed beside the latest cookie that be created.
+        SetACookie(cookieService, "http://creation.ordering.tests/", nullptr, name.get(), nullptr);
+      }
     }
+    GetACookie(cookieService, "http://creation.ordering.tests/", nullptr, getter_Copies(cookie));
+    EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
 
-    if (!allTestsPassed) {
-      // print the entire log
-      printf("%s", sBuffer);
-      return 1;
-    }
-
-    PR_smprintf_free(sBuffer);
-    sBuffer = nullptr;
-
-    return 0;
+    // XXX the following are placeholders: add these tests please!
+    // *** "noncompliant cookie" tests
+    // *** IP address tests
+    // *** speed tests
 }
-
-// Stubs to make this test happy
-
-mozilla::dom::OriginAttributesDictionary::OriginAttributesDictionary()
-  : mAppId(0),
-    mInIsolatedMozBrowser(false),
-    mPrivateBrowsingId(0),
-    mUserContextId(0)
-{}
deleted file mode 100644
--- a/netwerk/test/TestDNS.cpp
+++ /dev/null
@@ -1,130 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * 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/. */
-
-#include "TestCommon.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include "nsIServiceManager.h"
-#include "nsPIDNSService.h"
-#include "nsIDNSListener.h"
-#include "nsIDNSRecord.h"
-#include "nsICancelable.h"
-#include "nsCOMPtr.h"
-#include "nsStringAPI.h"
-#include "nsNetCID.h"
-#include "prinrval.h"
-#include "prthread.h"
-#include "prnetdb.h"
-#include "nsXPCOM.h"
-#include "nsServiceManagerUtils.h"
-
-class myDNSListener : public nsIDNSListener
-{
-public:
-    NS_DECL_THREADSAFE_ISUPPORTS
-
-    myDNSListener(const char *host, int32_t index)
-        : mHost(host)
-        , mIndex(index) {}
-
-    NS_IMETHOD OnLookupComplete(nsICancelable *request,
-                                nsIDNSRecord  *rec,
-                                nsresult       status) override
-    {
-        printf("%d: OnLookupComplete called [host=%s status=%x rec=%p]\n",
-            mIndex, mHost.get(), static_cast<uint32_t>(status), (void*)rec);
-
-        if (NS_SUCCEEDED(status)) {
-            nsAutoCString buf;
-
-            rec->GetCanonicalName(buf);
-            printf("%d: canonname=%s\n", mIndex, buf.get());
-
-            bool hasMore;
-            while (NS_SUCCEEDED(rec->HasMore(&hasMore)) && hasMore) {
-                rec->GetNextAddrAsString(buf);
-                printf("%d: => %s\n", mIndex, buf.get());
-            }
-        }
-
-        return NS_OK;
-    }
-
-private:
-    virtual ~myDNSListener() = default;
-
-    nsCString mHost;
-    int32_t   mIndex;
-};
-
-
-NS_IMPL_ISUPPORTS(myDNSListener, nsIDNSListener)
-
-static bool IsAscii(const char *s)
-{
-  for (; *s; ++s) {
-    if (*s & 0x80)
-      return false;
-  }
-
-  return true;
-}
-
-int main(int argc, char **argv)
-{
-    if (test_common_init(&argc, &argv) != 0)
-        return -1;
-
-    int sleepLen = 10; // default: 10 seconds
-
-    if (argc == 1) {
-        printf("usage: TestDNS [-N] hostname1 [hostname2 ...]\n");
-        return -1;
-    }
-
-    {
-        nsCOMPtr<nsIServiceManager> servMan;
-        NS_InitXPCOM2(getter_AddRefs(servMan), nullptr, nullptr);
-
-        nsCOMPtr<nsPIDNSService> dns = do_GetService(NS_DNSSERVICE_CONTRACTID);
-        if (!dns)
-            return -1;
-
-        if (argv[1][0] == '-') {
-            sleepLen = atoi(argv[1]+1);
-            argv++;
-            argc--;
-        }
-
-        for (int j=0; j<2; ++j) {
-            for (int i=1; i<argc; ++i) {
-                // assume non-ASCII input is given in the native charset 
-                nsAutoCString hostBuf;
-                if (IsAscii(argv[i]))
-                    hostBuf.Assign(argv[i]);
-                else
-                    hostBuf = NS_ConvertUTF16toUTF8(NS_ConvertASCIItoUTF16(argv[i]));
-
-                nsCOMPtr<nsIDNSListener> listener = new myDNSListener(argv[i], i);
-
-                nsCOMPtr<nsICancelable> req;
-                nsresult rv = dns->AsyncResolve(hostBuf,
-                                                nsIDNSService::RESOLVE_CANONICAL_NAME,
-                                                listener, nullptr, getter_AddRefs(req));
-                if (NS_FAILED(rv))
-                    printf("### AsyncResolve failed [rv=%x]\n",
-                           static_cast<uint32_t>(rv));
-            }
-
-            printf("main thread sleeping for %d seconds...\n", sleepLen);
-            PR_Sleep(PR_SecondsToInterval(sleepLen));
-        }
-
-        printf("shutting down main thread...\n");
-        dns->Shutdown();
-    }
-
-    NS_ShutdownXPCOM(nullptr);
-    return 0;
-}
deleted file mode 100644
--- a/netwerk/test/TestIDN.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * 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/. */
-
-#include "TestCommon.h"
-#include <stdio.h>
-#include "nsIIDNService.h"
-#include "nsCOMPtr.h"
-#include "nsIServiceManager.h"
-#include "nsServiceManagerUtils.h"
-#include "nsNetCID.h"
-#include "nsStringAPI.h"
-
-int main(int argc, char **argv) {
-    if (test_common_init(&argc, &argv) != 0)
-        return -1;
-
-    // Test case from RFC 3492 (7.1 - Simplified Chinese)
-    const char plain[] =
-         "\xE4\xBB\x96\xE4\xBB\xAC\xE4\xB8\xBA\xE4\xBB\x80\xE4\xB9\x88\xE4\xB8\x8D\xE8\xAF\xB4\xE4\xB8\xAD\xE6\x96\x87";
-    const char encoded[] = "xn--ihqwcrb4cv8a8dqg056pqjye";
-
-    nsCOMPtr<nsIIDNService> converter = do_GetService(NS_IDNSERVICE_CONTRACTID);
-    NS_ASSERTION(converter, "idnSDK not installed!");
-    if (converter) {
-        nsAutoCString buf;
-        nsresult rv = converter->ConvertUTF8toACE(NS_LITERAL_CSTRING(plain), buf);
-        NS_ASSERTION(NS_SUCCEEDED(rv), "error ConvertUTF8toACE");
-        NS_ASSERTION(buf.Equals(NS_LITERAL_CSTRING(encoded)), 
-                     "encode result incorrect");
-        printf("encoded = %s\n", buf.get());
-
-        buf.Truncate();
-        rv = converter->ConvertACEtoUTF8(NS_LITERAL_CSTRING(encoded), buf);
-        NS_ASSERTION(NS_SUCCEEDED(rv), "error ConvertACEtoUTF8");
-        NS_ASSERTION(buf.Equals(NS_LITERAL_CSTRING(plain)), 
-                     "decode result incorrect");
-        printf("decoded = ");
-        NS_ConvertUTF8toUTF16 utf(buf);
-        const char16_t *u = utf.get();
-        for (int i = 0; u[i]; i++) {
-          printf("U+%.4X ", u[i]);
-        }
-        printf("\n");
-
-        bool isAce;
-        rv = converter->IsACE(NS_LITERAL_CSTRING("www.xn--ihqwcrb4cv8a8dqg056pqjye.com"), &isAce);
-        NS_ASSERTION(NS_SUCCEEDED(rv), "error IsACE");
-        NS_ASSERTION(isAce, "IsACE incorrect result");
-    }
-    return 0;
-}
deleted file mode 100644
--- a/netwerk/test/TestIOThreads.cpp
+++ /dev/null
@@ -1,75 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * 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/. */
-
-#include "TestCommon.h"
-#include "nsXPCOM.h"
-#include "nsIServiceManager.h"
-#include "nsServiceManagerUtils.h"
-#include "nsIEventTarget.h"
-#include "nsCOMPtr.h"
-#include "nsNetCID.h"
-#include "mozilla/Logging.h"
-
-//
-// set NSPR_LOG_MODULES=Test:5
-//
-static PRLogModuleInfo *gTestLog = nullptr;
-#define LOG(args) MOZ_LOG(gTestLog, mozilla::LogLevel::Debug, args)
-
-class nsIOEvent : public nsIRunnable {
-public:
-    NS_DECL_THREADSAFE_ISUPPORTS
-
-    nsIOEvent(int i) : mIndex(i) {}
-
-    NS_IMETHOD Run() override {
-        LOG(("Run [%d]\n", mIndex));
-        return NS_OK;
-    }
-
-private:
-    int mIndex;
-};
-NS_IMPL_ISUPPORTS(nsIOEvent, nsIRunnable)
-
-static nsresult RunTest()
-{
-    nsresult rv;
-    nsCOMPtr<nsIEventTarget> target =
-        do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID, &rv);
-    if (NS_FAILED(rv))
-        return rv;
-
-    for (int i=0; i<10; ++i) {
-        nsCOMPtr<nsIRunnable> event = new nsIOEvent(i); 
-        LOG(("Dispatch %d\n", i));
-        target->Dispatch(event, NS_DISPATCH_NORMAL);
-    }
-
-    return NS_OK;
-}
-
-int main(int argc, char **argv)
-{
-    if (test_common_init(&argc, &argv) != 0)
-        return -1;
-
-    nsresult rv;
-
-    gTestLog = PR_NewLogModule("Test");
-
-    rv = NS_InitXPCOM2(nullptr, nullptr, nullptr);
-    if (NS_FAILED(rv))
-        return rv;
-
-    rv = RunTest();
-    if (NS_FAILED(rv))
-        LOG(("RunTest failed [rv=%x]\n", rv));
-
-    LOG(("sleeping main thread for 2 seconds...\n"));
-    PR_Sleep(PR_SecondsToInterval(2));
-    
-    NS_ShutdownXPCOM(nullptr);
-    return 0;
-}
deleted file mode 100644
--- a/netwerk/test/TestIncrementalDownload.cpp
+++ /dev/null
@@ -1,133 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim:set ts=2 sw=2 sts=2 cin et: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * 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/. */
-
-#include <inttypes.h>
-#include <stdlib.h>
-#include "TestCommon.h"
-#include "nsNetUtil.h"
-#include "nsComponentManagerUtils.h"
-#include "nsIIncrementalDownload.h"
-#include "nsIRequestObserver.h"
-#include "nsIProgressEventSink.h"
-#include "nsThreadUtils.h"
-#include "nsAutoPtr.h"
-#include "prprf.h"
-#include "prenv.h"
-#include "mozilla/Attributes.h"
-
-//-----------------------------------------------------------------------------
-
-class FetchObserver final : public nsIRequestObserver
-                          , public nsIProgressEventSink
-{
-  ~FetchObserver() = default;
-public:
-  NS_DECL_ISUPPORTS
-  NS_DECL_NSIREQUESTOBSERVER
-  NS_DECL_NSIPROGRESSEVENTSINK
-};
-
-NS_IMPL_ISUPPORTS(FetchObserver, nsIRequestObserver,
-                  nsIProgressEventSink)
-
-NS_IMETHODIMP
-FetchObserver::OnStartRequest(nsIRequest *request, nsISupports *context)
-{
-  printf("FetchObserver::OnStartRequest\n");
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-FetchObserver::OnProgress(nsIRequest *request, nsISupports *context,
-                          int64_t progress, int64_t progressMax)
-{
-  printf("FetchObserver::OnProgress [%" PRId64 "/%" PRId64 "]\n",
-         progress, progressMax);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-FetchObserver::OnStatus(nsIRequest *request, nsISupports *context,
-                        nsresult status, const char16_t *statusText)
-{
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-FetchObserver::OnStopRequest(nsIRequest *request, nsISupports *context,
-                             nsresult status)
-{
-  printf("FetchObserver::OnStopRequest [status=%x]\n",
-         static_cast<uint32_t>(status));
-
-  QuitPumpingEvents();
-  return NS_OK;
-}
-
-//-----------------------------------------------------------------------------
-
-static nsresult
-DoIncrementalFetch(const char *uriSpec, const char *resultPath, int32_t chunkSize,
-                   int32_t interval)
-{
-  nsCOMPtr<nsIFile> resultFile;
-  nsresult rv = NS_NewNativeLocalFile(nsDependentCString(resultPath),
-                                      false, getter_AddRefs(resultFile));
-  if (NS_FAILED(rv))
-    return rv;
-
-  nsCOMPtr<nsIURI> uri;
-  rv = NS_NewURI(getter_AddRefs(uri), uriSpec);
-  if (NS_FAILED(rv))
-    return rv;
-
-  nsCOMPtr<nsIRequestObserver> observer = new FetchObserver();
-  if (!observer)
-    return NS_ERROR_OUT_OF_MEMORY;
-  
-  nsCOMPtr<nsIIncrementalDownload> download =
-      do_CreateInstance(NS_INCREMENTALDOWNLOAD_CONTRACTID, &rv);
-  if (NS_FAILED(rv))
-    return rv;
-
-  rv = download->Init(uri, resultFile, chunkSize, interval);
-  if (NS_FAILED(rv))
-    return rv;
-
-  rv = download->Start(observer, nullptr);
-  if (NS_FAILED(rv))
-    return rv;
-
-  PumpEvents();
-  return NS_OK;
-}
-
-int
-main(int argc, char **argv)
-{
-  if (PR_GetEnv("MOZ_BREAK_ON_MAIN"))
-    NS_BREAK();
-
-  if (argc < 5) {
-    fprintf(stderr, "USAGE: TestIncrementalDownload <url> <file> <chunksize> <interval-in-seconds>\n");
-    return -1;
-  }
-
-  nsresult rv = NS_InitXPCOM2(nullptr, nullptr, nullptr);
-  if (NS_FAILED(rv))
-    return -1;
-
-  int32_t chunkSize = atoi(argv[3]);
-  int32_t interval = atoi(argv[4]);
-
-  rv = DoIncrementalFetch(argv[1], argv[2], chunkSize, interval);
-  if (NS_FAILED(rv))
-    fprintf(stderr, "ERROR: DoIncrementalFetch failed [%x]\n",
-            static_cast<uint32_t>(rv));
-
-  NS_ShutdownXPCOM(nullptr);
-  return 0;
-}
--- a/netwerk/test/TestNamedPipeService.cpp
+++ b/netwerk/test/TestNamedPipeService.cpp
@@ -1,15 +1,15 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
 #include "TestCommon.h"
-#include "TestHarness.h"
+#include "gtest/gtest.h"
 
 #include <Windows.h>
 
 #include "mozilla/Atomics.h"
 #include "mozilla/Monitor.h"
 #include "nsINamedPipeService.h"
 #include "nsNetCID.h"
 
@@ -58,106 +58,104 @@ nsNamedPipeDataObserver::Read(void* aBuf
   if (!ReadFile(mPipe, aBuffer, aSize, &bytesRead, &mOverlapped)) {
     switch(GetLastError()) {
       case ERROR_IO_PENDING:
         {
           MonitorAutoLock lock(mMonitor);
           mMonitor.Wait();
         }
         if (!GetOverlappedResult(mPipe, &mOverlapped, &bytesRead, FALSE)) {
-          fail("GetOverlappedResult failed");
+          ADD_FAILURE() << "GetOverlappedResult failed";
           return -1;
         }
         if (mBytesTransferred != bytesRead) {
-          fail("GetOverlappedResult mismatch");
+          ADD_FAILURE() << "GetOverlappedResult mismatch";
           return -1;
         }
 
         break;
       default:
-        fail("ReadFile error %d", GetLastError());
+        ADD_FAILURE() << "ReadFile error " << GetLastError();
         return -1;
     }
   } else {
     MonitorAutoLock lock(mMonitor);
     mMonitor.Wait();
 
     if (mBytesTransferred != bytesRead) {
-      fail("GetOverlappedResult mismatch");
+      ADD_FAILURE() << "GetOverlappedResult mismatch";
       return -1;
     }
   }
 
   mBytesTransferred = 0;
-  passed("[read] match");
   return bytesRead;
 }
 
 int
 nsNamedPipeDataObserver::Write(const void* aBuffer, uint32_t aSize)
 {
   DWORD bytesWritten = 0;
   if (!WriteFile(mPipe, aBuffer, aSize, &bytesWritten, &mOverlapped)) {
     switch(GetLastError()) {
       case ERROR_IO_PENDING:
         {
           MonitorAutoLock lock(mMonitor);
           mMonitor.Wait();
         }
         if (!GetOverlappedResult(mPipe, &mOverlapped, &bytesWritten, FALSE)) {
-          fail("GetOverlappedResult failed");
+          ADD_FAILURE() << "GetOverlappedResult failed";
           return -1;
         }
         if (mBytesTransferred != bytesWritten) {
-          fail("GetOverlappedResult mismatch");
+          ADD_FAILURE() << "GetOverlappedResult mismatch";
           return -1;
         }
 
         break;
       default:
-        fail("WriteFile error %d", GetLastError());
+        ADD_FAILURE() << "WriteFile error " << GetLastError();
         return -1;
     }
   } else {
     MonitorAutoLock lock(mMonitor);
     mMonitor.Wait();
 
     if (mBytesTransferred != bytesWritten) {
-      fail("GetOverlappedResult mismatch");
+      ADD_FAILURE() << "GetOverlappedResult mismatch";
       return -1;
     }
   }
 
   mBytesTransferred = 0;
-  passed("[write] match");
   return bytesWritten;
 }
 
 NS_IMETHODIMP
 nsNamedPipeDataObserver::OnDataAvailable(uint32_t aBytesTransferred,
                                          void *aOverlapped)
 {
   if (aOverlapped != &mOverlapped) {
-    fail("invalid overlapped object");
+    ADD_FAILURE() << "invalid overlapped object";
     return NS_ERROR_FAILURE;
   }
 
   DWORD bytesTransferred = 0;
   BOOL ret = GetOverlappedResult(mPipe,
                                  reinterpret_cast<LPOVERLAPPED>(aOverlapped),
                                  &bytesTransferred,
                                  FALSE);
 
   if (!ret) {
-    fail("GetOverlappedResult failed");
+    ADD_FAILURE() << "GetOverlappedResult failed";
     return NS_ERROR_FAILURE;
   }
 
   if (bytesTransferred != aBytesTransferred) {
-    fail("GetOverlappedResult mismatch");
+    ADD_FAILURE() << "GetOverlappedResult mismatch";
     return NS_ERROR_FAILURE;
   }
 
   mBytesTransferred += aBytesTransferred;
   MonitorAutoLock lock(mMonitor);
   mMonitor.Notify();
 
   return NS_OK;
@@ -169,166 +167,121 @@ nsNamedPipeDataObserver::OnError(uint32_
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 BOOL CreateAndConnectInstance(LPOVERLAPPED aOverlapped, LPHANDLE aPipe);
 BOOL ConnectToNewClient(HANDLE aPipe, LPOVERLAPPED aOverlapped);
 
 BOOL CreateAndConnectInstance(LPOVERLAPPED aOverlapped, LPHANDLE aPipe)
 {
-  if (!aPipe) {
-    fail("Parameter aPipe is NULL\n");
-    return FALSE;
-  }
-
   // FIXME: adjust parameters
   *aPipe = CreateNamedPipeA(
     PIPE_NAME,
     PIPE_ACCESS_DUPLEX |
     FILE_FLAG_OVERLAPPED,
     PIPE_TYPE_MESSAGE |
     PIPE_READMODE_MESSAGE |
     PIPE_WAIT,
     1,
     65536,
     65536,
     3000,
     NULL);
 
   if (*aPipe == INVALID_HANDLE_VALUE) {
-    fail("CreateNamedPipe failed [%d]\n", GetLastError());
+    ADD_FAILURE() << "CreateNamedPipe failed " << GetLastError();
     return FALSE;
   }
 
   return ConnectToNewClient(*aPipe, aOverlapped);
 }
 
 BOOL ConnectToNewClient(HANDLE aPipe, LPOVERLAPPED aOverlapped)
 {
   if (ConnectNamedPipe(aPipe, aOverlapped)) {
-    fail("Unexpected, overlapped ConnectNamedPipe() always returns 0.\n");
+    ADD_FAILURE() << "Unexpected, overlapped ConnectNamedPipe() always returns 0.";
     return FALSE;
   }
 
   switch (GetLastError())
   {
   case ERROR_IO_PENDING:
     return TRUE;
 
   case ERROR_PIPE_CONNECTED:
     if (SetEvent(aOverlapped->hEvent))
       break;
 
   default: // error
-    fail("ConnectNamedPipe failed [%d]\n", GetLastError());
+    ADD_FAILURE() << "ConnectNamedPipe failed " << GetLastError();
     break;
   }
 
   return FALSE;
 }
 
 static nsresult
 CreateNamedPipe(LPHANDLE aServer, LPHANDLE aClient)
 {
   OVERLAPPED overlapped;
   overlapped.hEvent = CreateEvent(NULL, TRUE, TRUE, NULL);
   BOOL ret;
 
   ret = CreateAndConnectInstance(&overlapped, aServer);
   if (!ret) {
-    fail("pipe server should be pending");
+    ADD_FAILURE() << "pipe server should be pending";
     return NS_ERROR_FAILURE;
   }
 
   *aClient = CreateFileA(PIPE_NAME,
                          GENERIC_READ | GENERIC_WRITE,
                          FILE_SHARE_READ | FILE_SHARE_WRITE,
                          nullptr,
                          OPEN_EXISTING,
                          FILE_FLAG_OVERLAPPED,
                          nullptr);
 
   if (*aClient == INVALID_HANDLE_VALUE) {
-    fail("Unable to create pipe client");
+    ADD_FAILURE() << "Unable to create pipe client";
     CloseHandle(*aServer);
     return NS_ERROR_FAILURE;
   }
 
   DWORD pipeMode = PIPE_READMODE_MESSAGE;
   if (!SetNamedPipeHandleState(*aClient, &pipeMode, nullptr, nullptr)) {
-    fail("SetNamedPipeHandleState error (%d)", GetLastError());
+    ADD_FAILURE() << "SetNamedPipeHandleState error " << GetLastError();
     CloseHandle(*aServer);
     CloseHandle(*aClient);
     return NS_ERROR_FAILURE;
   }
 
   WaitForSingleObjectEx(overlapped.hEvent, INFINITE, TRUE);
 
   return NS_OK;
 }
 
-int
-main(int32_t argc, char* argv[])
+TEST(TestNamedPipeService,Test)
 {
-  ScopedXPCOM xpcom("NamedPipeService");
-  if (xpcom.failed()) {
-    fail("Unable to initalize XPCOM.");
-    return -1;
-  }
-
   nsresult rv;
   nsCOMPtr<nsINamedPipeService> svc =
     do_GetService(NS_NAMEDPIPESERVICE_CONTRACTID, &rv);
-  if (NS_FAILED(rv)) {
-    fail("Unable to create named pipe service");
-    return -1;
-  }
+  ASSERT_TRUE(NS_SUCCEEDED(rv));
 
   HANDLE readPipe, writePipe;
-  if (NS_FAILED(rv = CreateNamedPipe(&readPipe, &writePipe))) {
-    fail("Unable to create pipes %d", GetLastError());
-    return -1;
-  }
+  rv = CreateNamedPipe(&readPipe, &writePipe);
+  ASSERT_TRUE(NS_SUCCEEDED(rv));
 
   RefPtr<nsNamedPipeDataObserver> readObserver =
     new nsNamedPipeDataObserver(readPipe);
   RefPtr<nsNamedPipeDataObserver> writeObserver =
     new nsNamedPipeDataObserver(writePipe);
 
-  if (NS_WARN_IF(NS_FAILED(svc->AddDataObserver(readPipe, readObserver)))) {
-    fail("Unable to add read data observer");
-    return -1;
-  }
-
-  if (NS_WARN_IF(NS_FAILED(svc->AddDataObserver(writePipe, writeObserver)))) {
-    fail("Unable to add read data observer");
-    return -1;
-  }
-
-  if (writeObserver->Write(TEST_STR, sizeof(TEST_STR)) != sizeof(TEST_STR)) {
-    fail("write error");
-    return -1;
-  }
+  ASSERT_TRUE(NS_SUCCEEDED(svc->AddDataObserver(readPipe, readObserver)));
+  ASSERT_TRUE(NS_SUCCEEDED(svc->AddDataObserver(writePipe, writeObserver)));
+  ASSERT_EQ(writeObserver->Write(TEST_STR, sizeof(TEST_STR)), sizeof(TEST_STR));
 
   char buffer[sizeof(TEST_STR)];
-  if (readObserver->Read(buffer, sizeof(buffer)) != sizeof(TEST_STR)) {
-    fail("read error");
-    return -1;
-  }
-
-  if (strcmp(buffer, TEST_STR) != 0) {
-    fail("I/O mismatch");
-    return -1;
-  }
+  ASSERT_EQ(readObserver->Read(buffer, sizeof(buffer)), sizeof(TEST_STR));
+  ASSERT_STREQ(buffer, TEST_STR) << "I/O mismatch";
 
-  if (NS_WARN_IF(NS_FAILED(svc->RemoveDataObserver(readPipe, readObserver)))) {
-    fail("Unable to remove read data observer");
-    return -1;
-  }
-
-  if (NS_WARN_IF(NS_FAILED(svc->RemoveDataObserver(writePipe, writeObserver)))) {
-    fail("Unable to remove read data observer");
-    return -1;
-  }
-
-  passed("Finish");
-  return 0;
-}
\ No newline at end of file
+  ASSERT_TRUE(NS_SUCCEEDED(svc->RemoveDataObserver(readPipe, readObserver)));
+  ASSERT_TRUE(NS_SUCCEEDED(svc->RemoveDataObserver(writePipe, writeObserver)));
+}
deleted file mode 100644
--- a/netwerk/test/TestOpen.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * 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/. */
-
-#include "TestCommon.h"
-#include "nsCOMPtr.h"
-#include "nsStringAPI.h"
-#include "nsIURI.h"
-#include "nsIChannel.h"
-#include "nsIHttpChannel.h"
-#include "nsIInputStream.h"
-#include "nsNetUtil.h"
-#include "nsServiceManagerUtils.h"
-#include "mozilla/Unused.h"
-#include "nsIScriptSecurityManager.h"
-
-#include <stdio.h>
-
-using namespace mozilla;
-
-/*
- * Test synchronous Open.
- */
-
-#define RETURN_IF_FAILED(rv, what) \
-    PR_BEGIN_MACRO \
-    if (NS_FAILED(rv)) { \
-        printf(what ": failed - %08x\n", static_cast<uint32_t>(rv)); \
-        return -1; \
-    } \
-    PR_END_MACRO
-
-int
-main(int argc, char **argv)
-{
-    if (test_common_init(&argc, &argv) != 0)
-        return -1;
-
-    nsresult rv = NS_InitXPCOM2(nullptr, nullptr, nullptr);
-    if (NS_FAILED(rv)) return -1;
-
-    char buf[256];
-
-    if (argc != 3) {
-        printf("Usage: TestOpen url filename\nLoads a URL using ::Open, writing it to a file\n");
-        return -1;
-    }
-
-    nsCOMPtr<nsIURI> uri;
-    nsCOMPtr<nsIInputStream> stream;
-
-    rv = NS_NewURI(getter_AddRefs(uri), argv[1]);
-    RETURN_IF_FAILED(rv, "NS_NewURI");
-
-    nsCOMPtr<nsIScriptSecurityManager> secman =
-      do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
-    RETURN_IF_FAILED(rv, "Couldn't get script security manager!");
-       nsCOMPtr<nsIPrincipal> systemPrincipal;
-    rv = secman->GetSystemPrincipal(getter_AddRefs(systemPrincipal));
-    RETURN_IF_FAILED(rv, "Couldn't get system principal!");
-
-    nsCOMPtr<nsIChannel> channel;
-    rv = NS_NewChannel(getter_AddRefs(channel),
-                       uri,
-                       systemPrincipal,
-                       nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
-                       nsIContentPolicy::TYPE_OTHER);
-    RETURN_IF_FAILED(rv, "NS_NewChannel");
-
-    rv = channel->Open2(getter_AddRefs(stream));
-    RETURN_IF_FAILED(rv, "channel->Open2()");
-
-    FILE* outfile = fopen(argv[2], "wb");
-    if (!outfile) {
-      printf("error opening %s\n", argv[2]);
-      return 1;
-    }
-
-    uint32_t read;
-    while (NS_SUCCEEDED(stream->Read(buf, sizeof(buf), &read)) && read) {
-      Unused << fwrite(buf, 1, read, outfile);
-    }
-    printf("Done\n");
-
-    fclose(outfile);
-
-    NS_ShutdownXPCOM(nullptr);
-    return 0;
-}
deleted file mode 100644
--- a/netwerk/test/TestProtocols.cpp
+++ /dev/null
@@ -1,890 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=2 sw=2 et cindent: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * 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/. */
-
-/* 
-    The TestProtocols tests the basic protocols architecture and can 
-    be used to test individual protocols as well. If this grows too
-    big then we should split it to individual protocols. 
-
-    -Gagan Saksena 04/29/99
-*/
-
-#include "TestCommon.h"
-#include <algorithm>
-
-#include <stdio.h>
-#ifdef WIN32 
-#include <windows.h>
-#endif
-#ifdef XP_UNIX
-#include <unistd.h>
-#endif
-#include "nspr.h"
-#include "nscore.h"
-#include "nsCOMPtr.h"
-#include "nsIIOService.h"
-#include "nsIServiceManager.h"
-#include "nsIStreamListener.h"
-#include "nsIInputStream.h"
-#include "nsIInputStream.h"
-#include "nsCRT.h"
-#include "nsIChannel.h"
-#include "nsIResumableChannel.h"
-#include "nsIURL.h"
-#include "nsIHttpChannel.h"
-#include "nsIHttpChannelInternal.h"
-#include "nsIHttpHeaderVisitor.h"
-#include "nsIChannelEventSink.h" 
-#include "nsIAsyncVerifyRedirectCallback.h"
-#include "nsIInterfaceRequestor.h" 
-#include "nsIInterfaceRequestorUtils.h"
-#include "nsIDNSService.h" 
-#include "nsIAuthPrompt.h"
-#include "nsIPrefService.h"
-#include "nsIPrefBranch.h"
-#include "nsIPropertyBag2.h"
-#include "nsIWritablePropertyBag2.h"
-#include "nsITimedChannel.h"
-#include "mozilla/Attributes.h"
-#include "mozilla/Unused.h"
-#include "nsIScriptSecurityManager.h"
-
-#include "nsISimpleEnumerator.h"
-#include "nsStringAPI.h"
-#include "nsNetUtil.h"
-#include "nsServiceManagerUtils.h"
-#include "NetwerkTestLogging.h"
-
-using namespace mozilla;
-
-namespace TestProtocols {
-
-//
-// set NSPR_LOG_MODULES=Test:5
-//
-static PRLogModuleInfo *gTestLog = nullptr;
-#define LOG(args) MOZ_LOG(gTestLog, mozilla::LogLevel::Debug, args)
-
-static NS_DEFINE_CID(kIOServiceCID,              NS_IOSERVICE_CID);
-
-//static PRTime gElapsedTime; // enable when we time it...
-static int gKeepRunning = 0;
-static bool gVerbose = false;
-static bool gAskUserForInput = false;
-static bool gResume = false;
-static uint64_t gStartAt = 0;
-
-static const char* gEntityID;
-
-//-----------------------------------------------------------------------------
-// Set proxy preferences for testing
-//-----------------------------------------------------------------------------
-
-static nsresult
-SetHttpProxy(const char *proxy)
-{
-  const char *colon = strchr(proxy, ':');
-  if (!colon)
-  {
-    NS_WARNING("invalid proxy token; use host:port");
-    return NS_ERROR_UNEXPECTED;
-  }
-  int port = atoi(colon + 1);
-  if (port == 0)
-  {
-    NS_WARNING("invalid proxy port; must be an integer");
-    return NS_ERROR_UNEXPECTED;
-  }
-  nsAutoCString proxyHost;
-  proxyHost = Substring(proxy, colon);
-
-  nsCOMPtr<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
-  if (prefs)
-  {
-    prefs->SetCharPref("network.proxy.http", proxyHost.get());
-    prefs->SetIntPref("network.proxy.http_port", port);
-    prefs->SetIntPref("network.proxy.type", 1); // manual proxy config
-  }
-  LOG(("connecting via proxy=%s:%d\n", proxyHost.get(), port));
-  return NS_OK;
-}
-
-static nsresult
-SetPACFile(const char* pacURL)
-{
-  nsCOMPtr<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
-  if (prefs)
-  {
-    prefs->SetCharPref("network.proxy.autoconfig_url", pacURL);
-    prefs->SetIntPref("network.proxy.type", 2); // PAC file
-  }
-  LOG(("connecting using PAC file %s\n", pacURL));
-  return NS_OK;
-}
-
-//-----------------------------------------------------------------------------
-// Timing information
-//-----------------------------------------------------------------------------
-
-void PrintTimingInformation(nsITimedChannel* channel) {
-#define PRINT_VALUE(property)                                              \
-    {                                                                      \
-        PRTime value;                                                      \
-        channel->Get##property(&value);                                    \
-        if (value) {                                                       \
-          PRExplodedTime exploded;                                         \
-          PR_ExplodeTime(value, PR_LocalTimeParameters, &exploded);        \
-          char buf[256];                                                   \
-          PR_FormatTime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", &exploded); \
-          LOG(("  " #property ":\t%s (%i usec)", buf, exploded.tm_usec));  \
-        } else {                                                           \
-          LOG(("  " #property ":\t0"));                                    \
-        }                                                                  \
-    }
-    LOG(("Timing data:"));
-    PRINT_VALUE(ChannelCreationTime)
-    PRINT_VALUE(AsyncOpenTime)
-    PRINT_VALUE(DomainLookupStartTime)
-    PRINT_VALUE(DomainLookupEndTime)
-    PRINT_VALUE(ConnectStartTime)
-    PRINT_VALUE(ConnectEndTime)
-    PRINT_VALUE(RequestStartTime)
-    PRINT_VALUE(ResponseStartTime)
-    PRINT_VALUE(ResponseEndTime)
-    PRINT_VALUE(CacheReadStartTime)
-    PRINT_VALUE(CacheReadEndTime)
-}
-
-//-----------------------------------------------------------------------------
-// HeaderVisitor
-//-----------------------------------------------------------------------------
-
-class HeaderVisitor : public nsIHttpHeaderVisitor
-{
-  virtual ~HeaderVisitor() = default;
-public:
-  NS_DECL_ISUPPORTS
-  NS_DECL_NSIHTTPHEADERVISITOR
-
-  HeaderVisitor() { }
-};
-NS_IMPL_ISUPPORTS(HeaderVisitor, nsIHttpHeaderVisitor)
-
-NS_IMETHODIMP
-HeaderVisitor::VisitHeader(const nsACString &header, const nsACString &value)
-{
-  LOG(("  %s: %s\n",
-    PromiseFlatCString(header).get(),
-    PromiseFlatCString(value).get()));
-  return NS_OK;
-}
-
-//-----------------------------------------------------------------------------
-// URLLoadInfo
-//-----------------------------------------------------------------------------
-
-class URLLoadInfo : public nsISupports
-{
-  virtual ~URLLoadInfo();
-
-public:
-
-  explicit URLLoadInfo(const char* aUrl);
-
-  // ISupports interface...
-  NS_DECL_THREADSAFE_ISUPPORTS
-
-  const char* Name() { return mURLString.get(); }
-  int64_t   mBytesRead;
-  PRTime    mTotalTime;
-  PRTime    mConnectTime;
-  nsCString mURLString;
-};
-
-URLLoadInfo::URLLoadInfo(const char *aUrl) : mURLString(aUrl)
-{
-  mBytesRead = 0;
-  mConnectTime = mTotalTime = PR_Now();
-}
-
-URLLoadInfo::~URLLoadInfo() = default;
-
-
-NS_IMPL_ISUPPORTS0(URLLoadInfo)
-
-//-----------------------------------------------------------------------------
-// TestChannelEventSink
-//-----------------------------------------------------------------------------
-
-class TestChannelEventSink : public nsIChannelEventSink
-{
-  virtual ~TestChannelEventSink();
-
-public:
-  NS_DECL_ISUPPORTS
-  NS_DECL_NSICHANNELEVENTSINK
-
-  TestChannelEventSink();
-};
-
-TestChannelEventSink::TestChannelEventSink()
-{
-}
-
-TestChannelEventSink::~TestChannelEventSink() = default;
-
-
-NS_IMPL_ISUPPORTS(TestChannelEventSink, nsIChannelEventSink)
-
-NS_IMETHODIMP
-TestChannelEventSink::AsyncOnChannelRedirect(nsIChannel *channel,
-                                             nsIChannel *newChannel,
-                                             uint32_t flags,
-                                             nsIAsyncVerifyRedirectCallback *callback)
-{
-    LOG(("\n+++ TestChannelEventSink::OnChannelRedirect (with flags %x) +++\n",
-         flags));
-    callback->OnRedirectVerifyCallback(NS_OK);
-    return NS_OK;
-}
-
-//-----------------------------------------------------------------------------
-// TestAuthPrompt
-//-----------------------------------------------------------------------------
-
-class TestAuthPrompt : public nsIAuthPrompt
-{
-  virtual ~TestAuthPrompt();
-
-public:
-  NS_DECL_ISUPPORTS
-  NS_DECL_NSIAUTHPROMPT
-
-  TestAuthPrompt();
-};
-
-NS_IMPL_ISUPPORTS(TestAuthPrompt, nsIAuthPrompt)
-
-TestAuthPrompt::TestAuthPrompt()
-{
-}
-
-TestAuthPrompt::~TestAuthPrompt() = default;
-
-NS_IMETHODIMP
-TestAuthPrompt::Prompt(const char16_t *dialogTitle,
-                       const char16_t *text,
-                       const char16_t *passwordRealm,
-                       uint32_t savePassword,
-                       const char16_t *defaultText,
-                       char16_t **result,
-                       bool *_retval)
-{
-    *_retval = false;
-    return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP
-TestAuthPrompt::PromptUsernameAndPassword(const char16_t *dialogTitle,
-                                          const char16_t *dialogText,
-                                          const char16_t *passwordRealm,
-                                          uint32_t savePassword,
-                                          char16_t **user,
-                                          char16_t **pwd,
-                                          bool *_retval)
-{
-    NS_ConvertUTF16toUTF8 text(passwordRealm);
-    printf("* --------------------------------------------------------------------------- *\n");
-    printf("* Authentication Required [%s]\n", text.get());
-    printf("* --------------------------------------------------------------------------- *\n");
-
-    char buf[256];
-    int n;
-
-    printf("Enter username: ");
-    Unused << fgets(buf, sizeof(buf), stdin);
-    n = strlen(buf);
-    buf[n-1] = '\0'; // trim trailing newline
-    *user = NS_StringCloneData(NS_ConvertUTF8toUTF16(buf));
-
-    const char *p;
-#if defined(XP_UNIX) && !defined(ANDROID)
-    p = getpass("Enter password: ");
-#else
-    printf("Enter password: ");
-    fgets(buf, sizeof(buf), stdin);
-    n = strlen(buf);
-    buf[n-1] = '\0'; // trim trailing newline
-    p = buf;
-#endif
-    *pwd = NS_StringCloneData(NS_ConvertUTF8toUTF16(p));
-
-    // zap buf 
-    memset(buf, 0, sizeof(buf));
-
-    *_retval = true;
-    return NS_OK;
-}
-
-NS_IMETHODIMP
-TestAuthPrompt::PromptPassword(const char16_t *dialogTitle,
-                               const char16_t *text,
-                               const char16_t *passwordRealm,
-                               uint32_t savePassword,
-                               char16_t **pwd,
-                               bool *_retval)
-{
-    *_retval = false;
-    return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-//-----------------------------------------------------------------------------
-// InputTestConsumer
-//-----------------------------------------------------------------------------
-
-class InputTestConsumer : public nsIStreamListener
-{
-  virtual ~InputTestConsumer();
-
-public:
-
-  explicit InputTestConsumer(URLLoadInfo* aURLLoadInfo);
-
-  NS_DECL_ISUPPORTS
-  NS_DECL_NSIREQUESTOBSERVER
-  NS_DECL_NSISTREAMLISTENER
-private:
-  URLLoadInfo* mURLLoadInfo;
-};
-
-InputTestConsumer::InputTestConsumer(URLLoadInfo* aURLLoadInfo)
-: mURLLoadInfo(aURLLoadInfo)
-{
-  NS_IF_ADDREF(mURLLoadInfo);
-}
-
-InputTestConsumer::~InputTestConsumer()
-{
-  NS_RELEASE(mURLLoadInfo);
-}
-
-NS_IMPL_ISUPPORTS(InputTestConsumer, nsIStreamListener, nsIRequestObserver)
-
-NS_IMETHODIMP
-InputTestConsumer::OnStartRequest(nsIRequest *request, nsISupports* context)
-{
-  LOG(("InputTestConsumer::OnStartRequest\n"));
-
-  NS_ASSERTION(!context, "context needs to be null when calling asyncOpen2");
-
-  if (mURLLoadInfo)
-    mURLLoadInfo->mConnectTime = PR_Now() - mURLLoadInfo->mConnectTime;
-
-  if (gVerbose) {
-    LOG(("\nStarted loading: %s\n", mURLLoadInfo ? mURLLoadInfo->Name() : "UNKNOWN URL"));
-  }
-
-  nsAutoCString value;
-
-  nsCOMPtr<nsIChannel> channel = do_QueryInterface(request);
-  if (channel) {
-    nsresult status;
-    channel->GetStatus(&status);
-    LOG(("Channel Status: %08x\n", status));
-    if (NS_SUCCEEDED(status)) {
-      LOG(("Channel Info:\n"));
-
-      channel->GetName(value);
-      LOG(("\tName: %s\n", value.get()));
-
-      channel->GetContentType(value);
-      LOG(("\tContent-Type: %s\n", value.get()));
-
-      channel->GetContentCharset(value);
-      LOG(("\tContent-Charset: %s\n", value.get()));
-
-      int64_t length = -1;
-      if (NS_SUCCEEDED(channel->GetContentLength(&length))) {
-        LOG(("\tContent-Length: %lld\n", length));
-      } else {
-        LOG(("\tContent-Length: Unknown\n"));
-      }
-    }
-
-    nsCOMPtr<nsISupports> owner;
-    channel->GetOwner(getter_AddRefs(owner));
-    LOG(("\tChannel Owner: %x\n", owner.get()));
-  }
-
-  nsCOMPtr<nsIPropertyBag2> props = do_QueryInterface(request);
-  if (props) {
-      nsCOMPtr<nsIURI> foo;
-      props->GetPropertyAsInterface(NS_LITERAL_STRING("test.foo"),
-                                    NS_GET_IID(nsIURI),
-                                    getter_AddRefs(foo));
-      if (foo) {
-          LOG(("\ttest.foo: %s\n", foo->GetSpecOrDefault().get()));
-      }
-  }
-
-  nsCOMPtr<nsIHttpChannelInternal> httpChannelInt(do_QueryInterface(request));
-  if (httpChannelInt) {
-      uint32_t majorVer, minorVer;
-      nsresult rv = httpChannelInt->GetResponseVersion(&majorVer, &minorVer);
-      if (NS_SUCCEEDED(rv)) {
-          LOG(("HTTP Response version: %u.%u\n", majorVer, minorVer));
-      }
-  }
-  nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(request));
-  if (httpChannel) {
-    auto *visitor = new HeaderVisitor();
-    if (!visitor)
-      return NS_ERROR_OUT_OF_MEMORY;
-    NS_ADDREF(visitor);
-
-    LOG(("HTTP request headers:\n"));
-    httpChannel->VisitRequestHeaders(visitor);
-
-    LOG(("HTTP response headers:\n"));
-    httpChannel->VisitResponseHeaders(visitor);
-
-    NS_RELEASE(visitor);
-  }
-
-  nsCOMPtr<nsIResumableChannel> resChannel = do_QueryInterface(request);
-  if (resChannel) {
-      LOG(("Resumable entity identification:\n"));
-      nsAutoCString entityID;
-      nsresult rv = resChannel->GetEntityID(entityID);
-      if (NS_SUCCEEDED(rv)) {
-          LOG(("\t|%s|\n", entityID.get()));
-      }
-      else {
-          LOG(("\t<none>\n"));
-      }
-  }
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-InputTestConsumer::OnDataAvailable(nsIRequest *request, 
-                                   nsISupports* context,
-                                   nsIInputStream *aIStream, 
-                                   uint64_t aSourceOffset,
-                                   uint32_t aLength)
-{
-  NS_ASSERTION(!context, "context needs to be null when calling asyncOpen2");
-
-  char buf[1025];
-  uint32_t amt, size;
-  nsresult rv;
-
-  while (aLength) {
-    size = std::min<uint32_t>(aLength, sizeof(buf));
-
-    rv = aIStream->Read(buf, size, &amt);
-    if (NS_FAILED(rv)) {
-      NS_ASSERTION((NS_BASE_STREAM_WOULD_BLOCK != rv), 
-                   "The stream should never block.");
-      return rv;
-    }
-    if (gVerbose) {
-      buf[amt] = '\0';
-      puts(buf);
-    }
-    if (mURLLoadInfo) {
-      mURLLoadInfo->mBytesRead += amt;
-    }
-
-    aLength -= amt;
-  }
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-InputTestConsumer::OnStopRequest(nsIRequest *request, nsISupports* context,
-                                 nsresult aStatus)
-{
-  LOG(("InputTestConsumer::OnStopRequest [status=%x]\n", aStatus));
-
-  if (mURLLoadInfo) {
-    uint32_t httpStatus;
-    bool bHTTPURL = false;
-
-    mURLLoadInfo->mTotalTime = PR_Now() - mURLLoadInfo->mTotalTime;
-
-    double readTime = ((mURLLoadInfo->mTotalTime-mURLLoadInfo->mConnectTime)/1000.0)/1000.0;
-
-    nsCOMPtr<nsIHttpChannel> pHTTPCon(do_QueryInterface(request));
-    if (pHTTPCon) {
-        pHTTPCon->GetResponseStatus(&httpStatus);
-        bHTTPURL = true;
-    }
-
-    LOG(("\nFinished loading: %s  Status Code: %x\n", mURLLoadInfo->Name(), aStatus));
-    if (bHTTPURL) {
-      LOG(("\tHTTP Status: %u\n", httpStatus));
-    }
-    if (NS_ERROR_UNKNOWN_HOST == aStatus ||
-        NS_ERROR_UNKNOWN_PROXY_HOST == aStatus) {
-      LOG(("\tDNS lookup failed.\n"));
-    }
-    LOG(("\tTime to connect: %.3f seconds\n", (mURLLoadInfo->mConnectTime/1000.0)/1000.0));
-    LOG(("\tTime to read: %.3f seconds.\n", readTime));
-    LOG(("\tRead: %lld bytes.\n", mURLLoadInfo->mBytesRead));
-    if (mURLLoadInfo->mBytesRead == int64_t(0)) {
-    } else if (readTime > 0.0) {
-      LOG(("\tThroughput: %.0f bps.\n", (double)(mURLLoadInfo->mBytesRead*int64_t(8))/readTime));
-    } else {
-      LOG(("\tThroughput: REAL FAST!!\n"));
-    }
-
-    nsCOMPtr<nsITimedChannel> timed(do_QueryInterface(request));
-    if (timed)
-        PrintTimingInformation(timed);
-  } else {
-    LOG(("\nFinished loading: UNKNOWN URL. Status Code: %x\n", aStatus));
-  }
-
-  if (--gKeepRunning == 0)
-    QuitPumpingEvents();
-  return NS_OK;
-}
-
-//-----------------------------------------------------------------------------
-// NotificationCallbacks
-//-----------------------------------------------------------------------------
-
-class NotificationCallbacks final : public nsIInterfaceRequestor {
-
-    ~NotificationCallbacks() = default;
-
-public:
-    NS_DECL_ISUPPORTS
-
-    NotificationCallbacks() {
-    }
-
-    NS_IMETHOD GetInterface(const nsIID& iid, void* *result) override {
-        nsresult rv = NS_ERROR_FAILURE;
-
-        if (iid.Equals(NS_GET_IID(nsIChannelEventSink))) {
-          TestChannelEventSink *sink;
-
-          sink = new TestChannelEventSink();
-          if (sink == nullptr)
-            return NS_ERROR_OUT_OF_MEMORY;
-          NS_ADDREF(sink);
-          rv = sink->QueryInterface(iid, result);
-          NS_RELEASE(sink);
-        }
-
-        if (iid.Equals(NS_GET_IID(nsIAuthPrompt))) {
-          TestAuthPrompt *prompt;
-
-          prompt = new TestAuthPrompt();
-          if (prompt == nullptr)
-            return NS_ERROR_OUT_OF_MEMORY;
-          NS_ADDREF(prompt);
-          rv = prompt->QueryInterface(iid, result);
-          NS_RELEASE(prompt);
-        }
-        return rv;
-    }
-};
-
-NS_IMPL_ISUPPORTS(NotificationCallbacks, nsIInterfaceRequestor)
-
-//-----------------------------------------------------------------------------
-// helpers...
-//-----------------------------------------------------------------------------
-
-nsresult StartLoadingURL(const char* aUrlString)
-{
-    nsresult rv;
-
-    nsCOMPtr<nsIIOService> pService(do_GetService(kIOServiceCID, &rv));
-    if (pService) {
-        nsCOMPtr<nsIURI> pURL;
-
-        rv = pService->NewURI(nsDependentCString(aUrlString), nullptr, nullptr, getter_AddRefs(pURL));
-        if (NS_FAILED(rv)) {
-            LOG(("ERROR: NewURI failed for %s [rv=%x]\n", aUrlString));
-            return rv;
-        }
-        nsCOMPtr<nsIChannel> pChannel;
-
-        auto* callbacks = new NotificationCallbacks();
-        if (!callbacks) {
-            LOG(("Failed to create a new consumer!"));
-            return NS_ERROR_OUT_OF_MEMORY;;
-        }
-        NS_ADDREF(callbacks);
-
-        nsCOMPtr<nsIScriptSecurityManager> secman =
-          do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
-        NS_ENSURE_SUCCESS(rv, rv);
-           nsCOMPtr<nsIPrincipal> systemPrincipal;
-        rv = secman->GetSystemPrincipal(getter_AddRefs(systemPrincipal));
-        NS_ENSURE_SUCCESS(rv, rv);
-
-        // Async reading thru the calls of the event sink interface
-        rv = NS_NewChannel(getter_AddRefs(pChannel),
-                           pURL,
-                           systemPrincipal,
-                           nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
-                           nsIContentPolicy::TYPE_OTHER,
-                           nullptr,  // loadGroup
-                           callbacks,
-                           nsIRequest::LOAD_NORMAL,
-                           pService);
-
-        NS_RELEASE(callbacks);
-        if (NS_FAILED(rv)) {
-            LOG(("ERROR: NS_NewChannel failed for %s [rv=%x]\n", aUrlString, rv));
-            return rv;
-        }
-
-        nsCOMPtr<nsITimedChannel> timed(do_QueryInterface(pChannel));
-        if (timed)
-            timed->SetTimingEnabled(true);
-
-        nsCOMPtr<nsIWritablePropertyBag2> props = do_QueryInterface(pChannel);
-        if (props) {
-            rv = props->SetPropertyAsInterface(NS_LITERAL_STRING("test.foo"),
-                                               pURL);
-            if (NS_SUCCEEDED(rv)) {
-                LOG(("set prop 'test.foo'\n"));
-            }
-        }
-
-        /* 
-           You may optionally add/set other headers on this
-           request object. This is done by QI for the specific
-           protocolConnection.
-        */
-        nsCOMPtr<nsIHttpChannel> pHTTPCon(do_QueryInterface(pChannel));
-
-        if (pHTTPCon) {
-            // Setting a sample header.
-            rv = pHTTPCon->SetRequestHeader(NS_LITERAL_CSTRING("sample-header"),
-                                            NS_LITERAL_CSTRING("Sample-Value"),
-                                            false);
-            if (NS_FAILED(rv)) return rv;
-        }            
-        auto* info = new URLLoadInfo(aUrlString);
-        if (!info) {
-            NS_ERROR("Failed to create a load info!");
-            return NS_ERROR_OUT_OF_MEMORY;
-        }
-
-        auto* listener = new InputTestConsumer(info);
-        NS_IF_ADDREF(listener);
-        if (!listener) {
-            NS_ERROR("Failed to create a new stream listener!");
-            return NS_ERROR_OUT_OF_MEMORY;;
-        }
-
-
-        if (gResume) {
-            nsCOMPtr<nsIResumableChannel> res = do_QueryInterface(pChannel);
-            if (!res) {
-                NS_ERROR("Channel is not resumable!");
-                return NS_ERROR_UNEXPECTED;
-            }
-            nsAutoCString id;
-            if (gEntityID)
-                id = gEntityID;
-            LOG(("* resuming at %llu bytes, with entity id |%s|\n", gStartAt, id.get()));
-            res->ResumeAt(gStartAt, id);
-        }
-        rv = pChannel->AsyncOpen2(listener);
-
-        if (NS_SUCCEEDED(rv)) {
-            gKeepRunning++;
-        }
-        else {
-            LOG(("ERROR: AsyncOpen failed [rv=%x]\n", rv));
-        }
-        NS_RELEASE(listener);
-    }
-
-    return rv;
-}
-
-static int32_t
-FindChar(nsCString& buffer, char c)
-{
-    const char *b;
-    int32_t len = NS_CStringGetData(buffer, &b);
-
-    for (int32_t offset = 0; offset < len; ++offset) {
-        if (b[offset] == c)
-            return offset;
-    }
-
-    return -1;
-}
-        
-
-static void
-StripChar(nsCString& buffer, char c)
-{
-    const char *b;
-    uint32_t len = NS_CStringGetData(buffer, &b) - 1;
-
-    for (; len > 0; --len) {
-        if (b[len] == c) {
-            buffer.Cut(len, 1);
-            NS_CStringGetData(buffer, &b);
-        }
-    }
-}
-
-nsresult LoadURLsFromFile(char *aFileName)
-{
-    nsresult rv = NS_OK;
-    int32_t len, offset;
-    PRFileDesc* fd;
-    char buffer[1024];
-    nsCString fileBuffer;
-    nsCString urlString;
-
-    fd = PR_Open(aFileName, PR_RDONLY, 777);
-    if (!fd) {
-        return NS_ERROR_FAILURE;
-    }
-
-    // Keep reading the file until EOF (or an error) is reached...        
-    do {
-        len = PR_Read(fd, buffer, sizeof(buffer));
-        if (len>0) {
-            fileBuffer.Append(buffer, len);
-            // Treat each line as a URL...
-            while ((offset = FindChar(fileBuffer, '\n')) != -1) {
-                urlString = StringHead(fileBuffer, offset);
-                fileBuffer.Cut(0, offset+1);
-
-                StripChar(urlString, '\r');
-                if (urlString.Length()) {
-                    LOG(("\t%s\n", urlString.get()));
-                    rv = StartLoadingURL(urlString.get());
-                    if (NS_FAILED(rv)) {
-                        // No need to log an error -- StartLoadingURL already
-                        // did that for us, probably.
-                        PR_Close(fd);
-                        return rv;
-                    }
-                }
-            }
-        }
-    } while (len>0);
-
-    // If anything is left in the fileBuffer, treat it as a URL...
-    StripChar(fileBuffer, '\r');
-    if (fileBuffer.Length()) {
-        LOG(("\t%s\n", fileBuffer.get()));
-        StartLoadingURL(fileBuffer.get());
-    }
-
-    PR_Close(fd);
-    return NS_OK;
-}
-
-
-nsresult LoadURLFromConsole()
-{
-    char buffer[1024];
-    printf(R"(Enter URL ("q" to start): )");
-    Unused << scanf("%s", buffer);
-    if (buffer[0]=='q') 
-        gAskUserForInput = false;
-    else
-        StartLoadingURL(buffer);
-    return NS_OK;
-}
-
-} // namespace TestProtocols
-
-using namespace TestProtocols;
-
-int
-main(int argc, char* argv[])
-{
-    if (test_common_init(&argc, &argv) != 0)
-        return -1;
-
-    nsresult rv= (nsresult)-1;
-    if (argc < 2) {
-        printf("usage: %s [-verbose] [-file <name>] [-resume <startoffset>"
-               "[-entityid <entityid>]] [-proxy <proxy>] [-pac <pacURL>]"
-               "[-console] <url> <url> ... \n", argv[0]);
-        return -1;
-    }
-
-    gTestLog = PR_NewLogModule("Test");
-
-    /* 
-      The following code only deals with XPCOM registration stuff. and setting
-      up the event queues. Copied from TestSocketIO.cpp
-    */
-
-    rv = NS_InitXPCOM2(nullptr, nullptr, nullptr);
-    if (NS_FAILED(rv)) return -1;
-
-    {
-        int i;
-        LOG(("Trying to load:\n"));
-        for (i=1; i<argc; i++) {
-            // Turn on verbose printing...
-            if (PL_strcasecmp(argv[i], "-verbose") == 0) {
-                gVerbose = true;
-                continue;
-            }
-
-            // Turn on netlib tracing...
-            if (PL_strcasecmp(argv[i], "-file") == 0) {
-                LoadURLsFromFile(argv[++i]);
-                continue;
-            }
-
-            if (PL_strcasecmp(argv[i], "-console") == 0) {
-                gAskUserForInput = true;
-                continue;
-            }
-
-            if (PL_strcasecmp(argv[i], "-resume") == 0) {
-                gResume = true;
-                PR_sscanf(argv[++i], "%llu", &gStartAt);
-                continue;
-            }
-
-            if (PL_strcasecmp(argv[i], "-entityid") == 0) {
-                gEntityID = argv[++i];
-                continue;
-            }
-
-            if (PL_strcasecmp(argv[i], "-proxy") == 0) {
-                SetHttpProxy(argv[++i]);
-                continue;
-            }
-
-            if (PL_strcasecmp(argv[i], "-pac") == 0) {
-                SetPACFile(argv[++i]);
-                continue;
-            }
-
-            LOG(("\t%s\n", argv[i]));
-            rv = StartLoadingURL(argv[i]);
-        }
-        // Enter the message pump to allow the URL load to proceed.
-        PumpEvents();
-    } // this scopes the nsCOMPtrs
-    // no nsCOMPtrs are allowed to be alive when you call NS_ShutdownXPCOM
-    NS_ShutdownXPCOM(nullptr);
-    return NS_FAILED(rv) ? -1 : 0;
-}
deleted file mode 100644
--- a/netwerk/test/TestServ.cpp
+++ /dev/null
@@ -1,146 +0,0 @@
-/* vim:set ts=4 sw=4 et cindent: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * 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/. */
-
-#include "TestCommon.h"
-#include <stdlib.h>
-#include "nsIServiceManager.h"
-#include "nsIServerSocket.h"
-#include "nsISocketTransport.h"
-#include "nsIInputStream.h"
-#include "nsIOutputStream.h"
-#include "nsNetCID.h"
-#include "nsComponentManagerUtils.h"
-#include "nsStringAPI.h"
-#include "nsCOMPtr.h"
-#include "NetwerkTestLogging.h"
-
-//
-// set NSPR_LOG_MODULES=Test:5
-//
-static PRLogModuleInfo *gTestLog = nullptr;
-#define LOG(args) MOZ_LOG(gTestLog, mozilla::LogLevel::Debug, args)
-
-class MySocketListener : public nsIServerSocketListener
-{
-protected:
-    virtual ~MySocketListener() = default;
-
-public:
-    NS_DECL_THREADSAFE_ISUPPORTS
-    NS_DECL_NSISERVERSOCKETLISTENER
-
-    MySocketListener() {}
-};
-
-NS_IMPL_ISUPPORTS(MySocketListener, nsIServerSocketListener)
-
-NS_IMETHODIMP
-MySocketListener::OnSocketAccepted(nsIServerSocket *serv,
-                                   nsISocketTransport *trans)
-{
-    LOG(("MySocketListener::OnSocketAccepted [serv=%p trans=%p]\n", serv, trans));
-
-    nsAutoCString host;
-    int32_t port;
-
-    trans->GetHost(host);
-    trans->GetPort(&port);
-
-    LOG(("  -> %s:%d\n", host.get(), port));
-
-    nsCOMPtr<nsIInputStream> input;
-    nsCOMPtr<nsIOutputStream> output;
-    nsresult rv;
-
-    rv = trans->OpenInputStream(nsITransport::OPEN_BLOCKING, 0, 0, getter_AddRefs(input));
-    if (NS_FAILED(rv))
-        return rv;
-
-    rv = trans->OpenOutputStream(nsITransport::OPEN_BLOCKING, 0, 0, getter_AddRefs(output));
-    if (NS_FAILED(rv))
-        return rv;
-
-    char buf[256];
-    uint32_t n;
-
-    rv = input->Read(buf, sizeof(buf), &n);
-    if (NS_FAILED(rv))
-        return rv;
-
-    const char response[] = "HTTP/1.0 200 OK\r\nContent-Type: text/plain\r\n\r\nFooooopy!!\r\n";
-    rv = output->Write(response, sizeof(response) - 1, &n);
-    if (NS_FAILED(rv))
-        return rv;
-
-    input->Close();
-    output->Close();
-    return NS_OK;
-}
-
-NS_IMETHODIMP
-MySocketListener::OnStopListening(nsIServerSocket *serv, nsresult status)
-{
-    LOG(("MySocketListener::OnStopListening [serv=%p status=%x]\n", serv, status));
-    QuitPumpingEvents();
-    return NS_OK;
-}
-
-static nsresult
-MakeServer(int32_t port)
-{
-    nsresult rv;
-    nsCOMPtr<nsIServerSocket> serv = do_CreateInstance(NS_SERVERSOCKET_CONTRACTID, &rv);
-    if (NS_FAILED(rv))
-        return rv;
-
-    rv = serv->Init(port, true, 5);
-    if (NS_FAILED(rv))
-        return rv;
-
-    rv = serv->GetPort(&port);
-    if (NS_FAILED(rv))
-        return rv;
-    LOG(("  listening on port %d\n", port));
-
-    rv = serv->AsyncListen(new MySocketListener());
-    return rv;
-}
-
-int
-main(int argc, char* argv[])
-{
-    if (test_common_init(&argc, &argv) != 0)
-        return -1;
-
-    nsresult rv= (nsresult)-1;
-    if (argc < 2) {
-        printf("usage: %s <port>\n", argv[0]);
-        return -1;
-    }
-
-    gTestLog = PR_NewLogModule("Test");
-
-    /* 
-     * The following code only deals with XPCOM registration stuff. and setting
-     * up the event queues. Copied from TestSocketIO.cpp
-     */
-
-    rv = NS_InitXPCOM2(nullptr, nullptr, nullptr);
-    if (NS_FAILED(rv)) return -1;
-
-    {
-        rv = MakeServer(atoi(argv[1]));
-        if (NS_FAILED(rv)) {
-            LOG(("MakeServer failed [rv=%x]\n", rv));
-            return -1;
-        }
-
-        // Enter the message pump to allow the URL load to proceed.
-        PumpEvents();
-    } // this scopes the nsCOMPtrs
-    // no nsCOMPtrs are allowed to be alive when you call NS_ShutdownXPCOM
-    NS_ShutdownXPCOM(nullptr);
-    return 0;
-}
deleted file mode 100644
--- a/netwerk/test/TestSocketTransport.cpp
+++ /dev/null
@@ -1,307 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * 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/. */
-
-#include "TestCommon.h"
-#include "nsIComponentRegistrar.h"
-#include "nsPISocketTransportService.h"
-#include "nsISocketTransport.h"
-#include "nsIAsyncInputStream.h"
-#include "nsIAsyncOutputStream.h"
-#include "nsIProgressEventSink.h"
-#include "nsIInterfaceRequestor.h"
-#include "nsIInterfaceRequestorUtils.h"
-#include "nsIRequest.h"
-#include "nsIServiceManager.h"
-#include "nsIComponentManager.h"
-#include "nsCOMPtr.h"
-#include "nsMemory.h"
-#include "nsStringAPI.h"
-#include "nsIDNSService.h"
-#include "nsIFileStreams.h"
-#include "nsIStreamListener.h"
-#include "nsIFile.h"
-#include "nsAutoLock.h"
-#include "mozilla/Logging.h"
-
-////////////////////////////////////////////////////////////////////////////////
-
-//
-// set NSPR_LOG_MODULES=Test:5
-//
-static PRLogModuleInfo *gTestLog = nullptr;
-#define LOG(args) MOZ_LOG(gTestLog, mozilla::LogLevel::Debug, args)
-
-////////////////////////////////////////////////////////////////////////////////
-
-static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID);
-
-////////////////////////////////////////////////////////////////////////////////
-
-class MyHandler : public nsIOutputStreamCallback
-                , public nsIInputStreamCallback
-{
-public:
-    NS_DECL_THREADSAFE_ISUPPORTS
-
-    MyHandler(const char *path,
-              nsIAsyncInputStream *in,
-              nsIAsyncOutputStream *out)
-        : mInput(in)
-        , mOutput(out)
-        , mWriteOffset(0)
-        {
-            mBuf.AssignLiteral("GET ");
-            mBuf.Append(path);
-            mBuf.AppendLiteral(" HTTP/1.0\r\n\r\n");
-        }
-    virtual ~MyHandler() {}
-
-    // called on any thread
-    NS_IMETHOD OnOutputStreamReady(nsIAsyncOutputStream *out)
-    {
-        LOG(("OnOutputStreamReady\n"));
-
-        nsresult rv;
-        uint32_t n, count = mBuf.Length() - mWriteOffset;
-
-        rv = out->Write(mBuf.get() + mWriteOffset, count, &n);
-
-        LOG(("  write returned [rv=%x count=%u]\n", rv, n));
-
-        if (NS_FAILED(rv) || (n == 0)) {
-            if (rv != NS_BASE_STREAM_WOULD_BLOCK) {
-                LOG(("  done writing; starting to read\n"));
-                mInput->AsyncWait(this, 0, 0, nullptr);
-                return NS_OK;
-            }
-        }
-
-        mWriteOffset += n;
-
-        return out->AsyncWait(this, 0, 0, nullptr);
-    }
-
-    // called on any thread
-    NS_IMETHOD OnInputStreamReady(nsIAsyncInputStream *in)
-    {
-        LOG(("OnInputStreamReady\n"));
-
-        nsresult rv;
-        uint32_t n;
-        char buf[500];
-
-        rv = in->Read(buf, sizeof(buf), &n);
-
-        LOG(("  read returned [rv=%x count=%u]\n", rv, n));
-
-        if (NS_FAILED(rv) || (n == 0)) {
-            if (rv != NS_BASE_STREAM_WOULD_BLOCK) {
-                QuitPumpingEvents();
-                return NS_OK;
-            }
-        }
-
-        return in->AsyncWait(this, 0, 0, nullptr);
-    }
-
-private:
-    nsCOMPtr<nsIAsyncInputStream>  mInput;
-    nsCOMPtr<nsIAsyncOutputStream> mOutput;
-    nsCString mBuf;
-    uint32_t  mWriteOffset;
-};
-
-NS_IMPL_ISUPPORTS(MyHandler,
-                  nsIOutputStreamCallback,
-                  nsIInputStreamCallback)
-
-////////////////////////////////////////////////////////////////////////////////
-
-/**
- * create transport, open streams, and close
- */
-static nsresult
-RunCloseTest(nsISocketTransportService *sts,
-             const char *host, int port,
-             uint32_t inFlags, uint32_t outFlags)
-{
-    nsresult rv;
-
-    LOG(("RunCloseTest\n"));
-
-    nsCOMPtr<nsISocketTransport> transport;
-    rv = sts->CreateTransport(nullptr, 0,
-                              nsDependentCString(host), port, nullptr,
-                              getter_AddRefs(transport));
-    if (NS_FAILED(rv)) return rv;
-
-    nsCOMPtr<nsIInputStream> in;
-    rv = transport->OpenInputStream(inFlags, 0, 0, getter_AddRefs(in));
-    nsCOMPtr<nsIAsyncInputStream> asyncIn = do_QueryInterface(in, &rv);
-    if (NS_FAILED(rv)) return rv;
-
-    nsCOMPtr<nsIOutputStream> out;
-    rv = transport->OpenOutputStream(outFlags, 0, 0, getter_AddRefs(out));
-    nsCOMPtr<nsIAsyncOutputStream> asyncOut = do_QueryInterface(out, &rv);
-    if (NS_FAILED(rv)) return rv;
-
-    LOG(("waiting 1 second before closing transport and streams...\n"));
-    PR_Sleep(PR_SecondsToInterval(1));
-    
-    // let nsCOMPtr destructors close everything...
-    return NS_OK;
-}
-
-
-/**
- * asynchronously read socket stream
- */
-static nsresult
-RunTest(nsISocketTransportService *sts,
-        const char *host, int port, const char *path,
-        uint32_t inFlags, uint32_t outFlags)
-{
-    nsresult rv;
-
-    LOG(("RunTest\n"));
-
-    nsCOMPtr<nsISocketTransport> transport;
-    rv = sts->CreateTransport(nullptr, 0,
-                              nsDependentCString(host), port, nullptr,
-                              getter_AddRefs(transport));
-    if (NS_FAILED(rv)) return rv;
-
-    nsCOMPtr<nsIInputStream> in;
-    rv = transport->OpenInputStream(inFlags, 0, 0, getter_AddRefs(in));
-    nsCOMPtr<nsIAsyncInputStream> asyncIn = do_QueryInterface(in, &rv);
-    if (NS_FAILED(rv)) return rv;
-
-    nsCOMPtr<nsIOutputStream> out;
-    rv = transport->OpenOutputStream(outFlags, 0, 0, getter_AddRefs(out));
-    nsCOMPtr<nsIAsyncOutputStream> asyncOut = do_QueryInterface(out, &rv);
-    if (NS_FAILED(rv)) return rv;
-
-    MyHandler *handler = new MyHandler(path, asyncIn, asyncOut);
-    if (handler == nullptr)
-        return NS_ERROR_OUT_OF_MEMORY;
-    NS_ADDREF(handler);
-
-    rv = asyncOut->AsyncWait(handler, 0, 0, nullptr);
-
-    if (NS_SUCCEEDED(rv))
-        PumpEvents();
-
-    NS_RELEASE(handler);
-
-    return NS_OK;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-
-int
-main(int argc, char* argv[])
-{
-    if (test_common_init(&argc, &argv) != 0)
-        return -1;
-
-    nsresult rv;
-
-    if (argc < 4) {
-        printf("usage: TestSocketTransport <host> <port> <path>\n");
-        return -1;
-    }
-
-    {
-        nsCOMPtr<nsIServiceManager> servMan;
-        NS_InitXPCOM2(getter_AddRefs(servMan), nullptr, nullptr);
-        nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan);
-        NS_ASSERTION(registrar, "Null nsIComponentRegistrar");
-        if (registrar)
-            registrar->AutoRegister(nullptr);
-
-        gTestLog = PR_NewLogModule("Test");
-
-        // Make sure the DNS service is initialized on the main thread
-        nsCOMPtr<nsIDNSService> dns =
-                 do_GetService(NS_DNSSERVICE_CONTRACTID, &rv);
-        if (NS_FAILED(rv)) return rv;
-
-        nsCOMPtr<nsPISocketTransportService> sts =
-            do_GetService(kSocketTransportServiceCID, &rv);
-        if (NS_FAILED(rv)) return rv;
-
-        LOG(("phase 1 tests...\n"));
-
-        LOG(("flags = { OPEN_UNBUFFERED, OPEN_UNBUFFERED }\n"));
-        rv = RunCloseTest(sts, argv[1], atoi(argv[2]),
-                          nsITransport::OPEN_UNBUFFERED,
-                          nsITransport::OPEN_UNBUFFERED);
-        NS_ASSERTION(NS_SUCCEEDED(rv), "RunCloseTest failed");
-
-        LOG(("flags = { OPEN_BUFFERED, OPEN_UNBUFFERED }\n"));
-        rv = RunCloseTest(sts, argv[1], atoi(argv[2]),
-                          0 /* nsITransport::OPEN_BUFFERED */,
-                          nsITransport::OPEN_UNBUFFERED);
-        NS_ASSERTION(NS_SUCCEEDED(rv), "RunCloseTest failed");
-
-        LOG(("flags = { OPEN_UNBUFFERED, OPEN_BUFFERED }\n"));
-        rv = RunCloseTest(sts, argv[1], atoi(argv[2]),
-                          nsITransport::OPEN_UNBUFFERED,
-                          0 /*nsITransport::OPEN_BUFFERED */);
-        NS_ASSERTION(NS_SUCCEEDED(rv), "RunCloseTest failed");
-
-        LOG(("flags = { OPEN_BUFFERED, OPEN_BUFFERED }\n"));
-        rv = RunCloseTest(sts, argv[1], atoi(argv[2]),
-                          0 /*nsITransport::OPEN_BUFFERED */,
-                          0 /*nsITransport::OPEN_BUFFERED */);
-        NS_ASSERTION(NS_SUCCEEDED(rv), "RunCloseTest failed");
-
-        LOG(("calling Shutdown on socket transport service:\n"));
-        sts->Shutdown();
-
-        LOG(("calling Init on socket transport service:\n"));
-        sts->Init();
-
-        LOG(("phase 2 tests...\n"));
-
-        LOG(("flags = { OPEN_UNBUFFERED, OPEN_UNBUFFERED }\n"));
-        rv = RunTest(sts, argv[1], atoi(argv[2]), argv[3],
-                     nsITransport::OPEN_UNBUFFERED,
-                     nsITransport::OPEN_UNBUFFERED);
-        NS_ASSERTION(NS_SUCCEEDED(rv), "RunTest failed");
-
-        LOG(("flags = { OPEN_BUFFERED, OPEN_UNBUFFERED }\n"));
-        rv = RunTest(sts, argv[1], atoi(argv[2]), argv[3],
-                     0 /* nsITransport::OPEN_BUFFERED */,
-                     nsITransport::OPEN_UNBUFFERED);
-        NS_ASSERTION(NS_SUCCEEDED(rv), "RunTest failed");
-
-        LOG(("flags = { OPEN_UNBUFFERED, OPEN_BUFFERED }\n"));
-        rv = RunTest(sts, argv[1], atoi(argv[2]), argv[3],
-                     nsITransport::OPEN_UNBUFFERED,
-                     0 /*nsITransport::OPEN_BUFFERED */);
-        NS_ASSERTION(NS_SUCCEEDED(rv), "RunTest failed");
-
-        LOG(("flags = { OPEN_BUFFERED, OPEN_BUFFERED }\n"));
-        rv = RunTest(sts, argv[1], atoi(argv[2]), argv[3],
-                     0 /*nsITransport::OPEN_BUFFERED */,
-                     0 /*nsITransport::OPEN_BUFFERED */);
-        NS_ASSERTION(NS_SUCCEEDED(rv), "RunTest failed");
-
-        LOG(("waiting 1 second before calling Shutdown...\n"));
-        PR_Sleep(PR_SecondsToInterval(1));
-
-        LOG(("calling Shutdown on socket transport service:\n"));
-        sts->Shutdown();
-
-        // give background threads a chance to finish whatever work they may
-        // be doing.
-        LOG(("waiting 1 second before exiting...\n"));
-        PR_Sleep(PR_SecondsToInterval(1));
-    } // this scopes the nsCOMPtrs
-    // no nsCOMPtrs are allowed to be alive when you call NS_ShutdownXPCOM
-    rv = NS_ShutdownXPCOM(nullptr);
-    NS_ASSERTION(NS_SUCCEEDED(rv), "NS_ShutdownXPCOM failed");
-    return 0;
-}
deleted file mode 100644
--- a/netwerk/test/TestStreamLoader.cpp
+++ /dev/null