Merge autoland to m-c, a=merge
authorPhil Ringnalda <philringnalda@gmail.com>
Sat, 14 Jan 2017 08:56:07 -0800
changeset 374404 a5fd4e171cf7db1851a9a4d7b26995aaceb25b2d
parent 374367 8a43d22ed38e343a63edec572ac9a299e50712df (current diff)
parent 374403 3b0cc40ebbbfeaeced16edb7365ea58c8ea26613 (diff)
child 374460 5ce3882eec21be3a70e4afc050959ca2f76bfa76
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [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 autoland to m-c, a=merge MozReview-Commit-ID: 1NoQxmEjpqA
netwerk/test/NetwerkTestLogging.h
netwerk/test/TestCacheBlockFiles.cpp
netwerk/test/TestCachePrefixKeyParser.cpp
netwerk/test/TestDNSDaemon.cpp
netwerk/test/TestFileInput2.cpp
netwerk/test/TestMakeAbs.cpp
netwerk/test/TestOverlappedIO.cpp
netwerk/test/TestServ.js
netwerk/test/TestSocketIO.cpp
netwerk/test/TestSocketInput.cpp
netwerk/test/TestURLManipulation.html
netwerk/test/TestWriteSpeed.cpp
netwerk/test/sites.txt
netwerk/test/urlparse.dat
netwerk/test/urlparse_mac.dat
netwerk/test/urlparse_unx.dat
netwerk/test/urlparse_win.dat
netwerk/test/urltests.dat
--- a/b2g/confvars.sh
+++ b/b2g/confvars.sh
@@ -13,17 +13,16 @@ MOZ_UA_OS_AGNOSTIC=1
 MOZ_B2G_VERSION=2.6.0.0-prerelease
 MOZ_B2G_OS_NAME=Boot2Gecko
 
 MOZ_BRANDING_DIRECTORY=b2g/branding/unofficial
 MOZ_OFFICIAL_BRANDING_DIRECTORY=b2g/branding/official
 # MOZ_APP_DISPLAYNAME is set by branding/configure.sh
 
 MOZ_NO_SMART_CARDS=1
-MOZ_APP_STATIC_INI=1
 
 if test "$OS_TARGET" = "Android"; then
 MOZ_CAPTURE=1
 MOZ_RAW=1
 MOZ_AUDIO_CHANNEL_MANAGER=1
 fi
 
 # use custom widget for html:select
--- a/b2g/graphene/confvars.sh
+++ b/b2g/graphene/confvars.sh
@@ -22,17 +22,16 @@ MOZ_B2G_OS_NAME=Boot2Gecko
 
 MOZ_BRANDING_DIRECTORY=b2g/branding/unofficial
 MOZ_OFFICIAL_BRANDING_DIRECTORY=b2g/branding/official
 # MOZ_APP_DISPLAYNAME is set by branding/configure.sh
 
 MOZ_CAPTIVEDETECT=1
 
 MOZ_NO_SMART_CARDS=1
-MOZ_APP_STATIC_INI=1
 NSS_NO_LIBPKIX=1
 
 if test "$OS_TARGET" = "Android"; then
 MOZ_CAPTURE=1
 MOZ_RAW=1
 MOZ_AUDIO_CHANNEL_MANAGER=1
 fi
 
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -60,16 +60,19 @@ pref("extensions.hotfix.certs.2.sha1Fing
 
 // Check AUS for system add-on updates.
 pref("extensions.systemAddon.update.url", "https://aus5.mozilla.org/update/3/SystemAddons/%VERSION%/%BUILD_ID%/%BUILD_TARGET%/%LOCALE%/%CHANNEL%/%OS_VERSION%/%DISTRIBUTION%/%DISTRIBUTION_VERSION%/update.xml");
 
 // Disable add-ons that are not installed by the user in all scopes by default.
 // See the SCOPE constants in AddonManager.jsm for values to use here.
 pref("extensions.autoDisableScopes", 15);
 
+// Whether or not webextension themes are supported.
+pref("extensions.webextensions.themes.enabled", false);
+
 // Add-on content security policies.
 pref("extensions.webextensions.base-content-security-policy", "script-src 'self' https://* moz-extension: blob: filesystem: 'unsafe-eval' 'unsafe-inline'; object-src 'self' https://* moz-extension: blob: filesystem:;");
 pref("extensions.webextensions.default-content-security-policy", "script-src 'self'; object-src 'self';");
 
 // Require signed add-ons by default
 pref("xpinstall.signatures.required", true);
 pref("xpinstall.signatures.devInfoURL", "https://wiki.mozilla.org/Addons/Extension_Signing");
 
new file mode 100644
--- /dev/null
+++ b/browser/components/extensions/ext-theme.js
@@ -0,0 +1,19 @@
+"use strict";
+
+XPCOMUtils.defineLazyModuleGetter(this, "Preferences",
+                                  "resource://gre/modules/Preferences.jsm");
+
+/* eslint-disable mozilla/balanced-listeners */
+extensions.on("manifest_theme", (type, directive, extension, manifest) => {
+  let enabled = Preferences.get("extensions.webextensions.themes.enabled");
+  extension.emit("test-message", "themes-enabled", enabled);
+
+  if (enabled) {
+    // Apply theme only if themes are enabled.
+  }
+});
+
+extensions.on("shutdown", (type, extension) => {
+  // Remove theme only if it has been applied.
+});
+/* eslint-enable mozilla/balanced-listeners */
--- a/browser/components/extensions/extensions-browser.manifest
+++ b/browser/components/extensions/extensions-browser.manifest
@@ -5,16 +5,17 @@ category webextension-scripts browsingDa
 category webextension-scripts commands chrome://browser/content/ext-commands.js
 category webextension-scripts contextMenus chrome://browser/content/ext-contextMenus.js
 category webextension-scripts desktop-runtime chrome://browser/content/ext-desktop-runtime.js
 category webextension-scripts history chrome://browser/content/ext-history.js
 category webextension-scripts omnibox chrome://browser/content/ext-omnibox.js
 category webextension-scripts pageAction chrome://browser/content/ext-pageAction.js
 category webextension-scripts sessions chrome://browser/content/ext-sessions.js
 category webextension-scripts tabs chrome://browser/content/ext-tabs.js
+category webextension-scripts theme chrome://browser/content/ext-theme.js
 category webextension-scripts utils chrome://browser/content/ext-utils.js
 category webextension-scripts windows chrome://browser/content/ext-windows.js
 
 # scripts that must run in the same process as addon code.
 category webextension-scripts-addon contextMenus chrome://browser/content/ext-c-contextMenus.js
 category webextension-scripts-addon omnibox chrome://browser/content/ext-c-omnibox.js
 category webextension-scripts-addon tabs chrome://browser/content/ext-c-tabs.js
 
@@ -25,9 +26,10 @@ category webextension-schemas browsing_d
 category webextension-schemas commands chrome://browser/content/schemas/commands.json
 category webextension-schemas context_menus chrome://browser/content/schemas/context_menus.json
 category webextension-schemas context_menus_internal chrome://browser/content/schemas/context_menus_internal.json
 category webextension-schemas history chrome://browser/content/schemas/history.json
 category webextension-schemas omnibox chrome://browser/content/schemas/omnibox.json
 category webextension-schemas page_action chrome://browser/content/schemas/page_action.json
 category webextension-schemas sessions chrome://browser/content/schemas/sessions.json
 category webextension-schemas tabs chrome://browser/content/schemas/tabs.json
+category webextension-schemas theme chrome://browser/content/schemas/theme.json
 category webextension-schemas windows chrome://browser/content/schemas/windows.json
--- a/browser/components/extensions/jar.mn
+++ b/browser/components/extensions/jar.mn
@@ -18,13 +18,14 @@ browser.jar:
     content/browser/ext-commands.js
     content/browser/ext-contextMenus.js
     content/browser/ext-desktop-runtime.js
     content/browser/ext-history.js
     content/browser/ext-omnibox.js
     content/browser/ext-pageAction.js
     content/browser/ext-sessions.js
     content/browser/ext-tabs.js
+    content/browser/ext-theme.js
     content/browser/ext-utils.js
     content/browser/ext-windows.js
     content/browser/ext-c-contextMenus.js
     content/browser/ext-c-omnibox.js
     content/browser/ext-c-tabs.js
--- a/browser/components/extensions/schemas/jar.mn
+++ b/browser/components/extensions/schemas/jar.mn
@@ -9,9 +9,10 @@ browser.jar:
     content/browser/schemas/commands.json
     content/browser/schemas/context_menus.json
     content/browser/schemas/context_menus_internal.json
     content/browser/schemas/history.json
     content/browser/schemas/omnibox.json
     content/browser/schemas/page_action.json
     content/browser/schemas/sessions.json
     content/browser/schemas/tabs.json
+    content/browser/schemas/theme.json
     content/browser/schemas/windows.json
new file mode 100644
--- /dev/null
+++ b/browser/components/extensions/schemas/theme.json
@@ -0,0 +1,24 @@
+// 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/.
+
+[
+  {
+    "namespace": "manifest",
+    "types": [
+      {
+        "id": "ThemeType",
+        "type": "object"
+      },
+      {
+        "$extend": "WebExtensionManifest",
+        "properties": {
+          "theme": {
+            "optional": true,
+            "$ref": "ThemeType"
+          }
+        }
+      }
+    ]
+  }
+]
--- a/browser/components/extensions/test/browser/browser-common.ini
+++ b/browser/components/extensions/test/browser/browser-common.ini
@@ -91,16 +91,17 @@ support-files =
 [browser_ext_tabs_query.js]
 [browser_ext_tabs_reload.js]
 [browser_ext_tabs_reload_bypass_cache.js]
 [browser_ext_tabs_sendMessage.js]
 [browser_ext_tabs_cookieStoreId.js]
 [browser_ext_tabs_update.js]
 [browser_ext_tabs_zoom.js]
 [browser_ext_tabs_update_url.js]
+[browser_ext_themes.js]
 [browser_ext_topwindowid.js]
 [browser_ext_webRequest.js]
 [browser_ext_webNavigation_frameId0.js]
 [browser_ext_webNavigation_getFrames.js]
 [browser_ext_webNavigation_urlbar_transitions.js]
 [browser_ext_windows.js]
 [browser_ext_windows_create.js]
 tags = fullscreen
new file mode 100644
--- /dev/null
+++ b/browser/components/extensions/test/browser/browser_ext_themes.js
@@ -0,0 +1,23 @@
+"use strict";
+
+add_task(function* test_themes_disabled_by_default() {
+  let manifest = {"theme": {}};
+  let extension = ExtensionTestUtils.loadExtension({manifest});
+
+  yield extension.startup();
+  let enabled = yield extension.awaitMessage("themes-enabled");
+  is(enabled, false, "Themes should be disabled");
+  yield extension.unload();
+});
+
+add_task(function* test_themes_enabled_with_preference() {
+  Services.prefs.setBoolPref("extensions.webextensions.themes.enabled", true);
+
+  let manifest = {"theme": {}};
+  let extension = ExtensionTestUtils.loadExtension({manifest});
+
+  yield extension.startup();
+  let enabled = yield extension.awaitMessage("themes-enabled");
+  is(enabled, true, "Themes should be enabled");
+  yield extension.unload();
+});
--- a/browser/confvars.sh
+++ b/browser/confvars.sh
@@ -50,17 +50,16 @@ MOZ_OFFICIAL_BRANDING_DIRECTORY=browser/
 MOZ_APP_ID={ec8030f7-c20a-464f-9b0e-13a3a9e97384}
 # This should usually be the same as the value MAR_CHANNEL_ID.
 # If more than one ID is needed, then you should use a comma separated list
 # of values.
 ACCEPTED_MAR_CHANNEL_IDS=firefox-mozilla-central
 # The MAR_CHANNEL_ID must not contain the following 3 characters: ",\t "
 MAR_CHANNEL_ID=firefox-mozilla-central
 MOZ_PROFILE_MIGRATOR=1
-MOZ_APP_STATIC_INI=1
 MOZ_WEBGL_CONFORMANT=1
 MOZ_JSDOWNLOADS=1
 MOZ_RUST_MP4PARSE=1
 
 # Enable checking that add-ons are signed by the trusted root
 MOZ_ADDON_SIGNING=1
 
 # Include the DevTools client, not just the server (which is the default)
--- a/build/application.ini.in
+++ b/build/application.ini.in
@@ -1,19 +1,17 @@
-#if MOZ_APP_STATIC_INI
 #ifdef MOZ_BUILD_APP_IS_BROWSER
 ; This file is not used. If you modify it and want the application to use
 ; your modifications, move it under the browser/ subdirectory and start with
 ; the "-app /path/to/browser/application.ini" argument.
 #else
 ; This file is not used. If you modify it and want the application to use
 ; your modifications, start with the "-app /path/to/application.ini"
 ; argument.
 #endif
-#endif
 #if 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/.
 #endif
 #filter substitution
 #include @TOPOBJDIR@/buildid.h
 #include @TOPOBJDIR@/source-repo.h
--- a/build/mach_bootstrap.py
+++ b/build/mach_bootstrap.py
@@ -48,16 +48,17 @@ SEARCH_PATHS = [
     'python/pylru',
     'python/which',
     'python/pystache',
     'python/pyyaml/lib',
     'python/requests',
     'python/slugid',
     'python/py',
     'python/pytest',
+    'python/pytoml',
     'python/redo',
     'python/voluptuous',
     'build',
     'build/pymake',
     'config',
     'dom/bindings',
     'dom/bindings/parser',
     'dom/media/test/external',
--- a/build/moz.build
+++ b/build/moz.build
@@ -59,37 +59,35 @@ if CONFIG['MOZ_APP_BASENAME']:
         appini_defines['MOZ_APP_DISPLAYNAME'] = CONFIG['MOZ_APP_DISPLAYNAME']
 
     if CONFIG['MOZ_BUILD_APP'] == 'browser':
         appini_defines['MOZ_BUILD_APP_IS_BROWSER'] = True
 
     if CONFIG['MOZ_APP_PROFILE']:
         appini_defines['MOZ_APP_PROFILE'] = CONFIG['MOZ_APP_PROFILE']
 
-    for var in ('MOZ_CRASHREPORTER', 'MOZ_PROFILE_MIGRATOR',
-                'MOZ_APP_STATIC_INI'):
+    for var in ('MOZ_CRASHREPORTER', 'MOZ_PROFILE_MIGRATOR'):
         if CONFIG[var]:
             appini_defines[var] = True
 
     GENERATED_FILES += ['application.ini']
 
     appini = GENERATED_FILES['application.ini']
     appini.script = '../python/mozbuild/mozbuild/action/preprocessor.py:generate'
     appini.inputs = ['application.ini.in']
     appini.flags = ['-D%s=%s' % (k, '1' if v is True else v)
                     for k, v in appini_defines.iteritems()]
     FINAL_TARGET_FILES += ['!application.ini']
     if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'android' and CONFIG['MOZ_UPDATER']:
         FINAL_TARGET_PP_FILES += ['update-settings.ini']
 
-    if CONFIG['MOZ_APP_STATIC_INI']:
-        GENERATED_FILES += ['application.ini.h']
-        appini = GENERATED_FILES['application.ini.h']
-        appini.script = 'appini_header.py'
-        appini.inputs = ['!application.ini']
+    GENERATED_FILES += ['application.ini.h']
+    appini = GENERATED_FILES['application.ini.h']
+    appini.script = 'appini_header.py'
+    appini.inputs = ['!application.ini']
 
 # NOTE: Keep .gdbinit in the topsrcdir for people who run gdb from the topsrcdir.
 OBJDIR_FILES += ['/.gdbinit']
 
 # Put a .lldbinit in the bin directory and the objdir, to be picked up
 # automatically by LLDB when we debug executables using either of those two
 # directories as the current working directory.  The .lldbinit file will
 # load $(topsrcdir)/.lldbinit, which is where the actual debugging commands are.
--- a/dom/media/DecoderTraits.cpp
+++ b/dom/media/DecoderTraits.cpp
@@ -192,83 +192,94 @@ IsFlacSupportedType(const nsACString& aT
 }
 
 static
 CanPlayStatus
 CanHandleCodecsType(const MediaContentType& aType,
                     DecoderDoctorDiagnostics* aDiagnostics)
 {
   // We should have been given a codecs string, though it may be empty.
-  MOZ_ASSERT(aType.HaveCodecs());
+  MOZ_ASSERT(aType.ExtendedType().HaveCodecs());
+
+  // Content type with the the MIME type, no codecs.
+  const MediaContentType mimeType(aType.Type());
 
   char const* const* codecList = nullptr;
-  if (IsOggTypeAndEnabled(aType.GetMIMEType())) {
-    if (IsOggSupportedType(aType.GetMIMEType(), aType.GetCodecs())) {
+  if (IsOggTypeAndEnabled(mimeType.Type().AsString())) {
+    if (IsOggSupportedType(aType.Type().AsString(),
+                           aType.ExtendedType().Codecs().AsString())) {
       return CANPLAY_YES;
     } else {
       // We can only reach this position if a particular codec was requested,
       // ogg is supported and working: the codec must be invalid.
       return CANPLAY_NO;
     }
   }
-  if (IsWaveSupportedType(aType.GetMIMEType())) {
-    if (IsWaveSupportedType(aType.GetMIMEType(), aType.GetCodecs())) {
+  if (IsWaveSupportedType(mimeType.Type().AsString())) {
+    if (IsWaveSupportedType(aType.Type().AsString(),
+                            aType.ExtendedType().Codecs().AsString())) {
       return CANPLAY_YES;
     } else {
       // We can only reach this position if a particular codec was requested,
       // ogg is supported and working: the codec must be invalid.
       return CANPLAY_NO;
     }
   }
 #if !defined(MOZ_OMX_WEBM_DECODER)
-  if (DecoderTraits::IsWebMTypeAndEnabled(aType.GetMIMEType())) {
-    if (IsWebMSupportedType(aType.GetMIMEType(), aType.GetCodecs())) {
+  if (DecoderTraits::IsWebMTypeAndEnabled(mimeType.Type().AsString())) {
+    if (IsWebMSupportedType(aType.Type().AsString(),
+                            aType.ExtendedType().Codecs().AsString())) {
       return CANPLAY_YES;
     } else {
       // We can only reach this position if a particular codec was requested,
       // webm is supported and working: the codec must be invalid.
       return CANPLAY_NO;
     }
   }
 #endif
 #ifdef MOZ_FMP4
-  if (DecoderTraits::IsMP4TypeAndEnabled(aType.GetMIMEType(), aDiagnostics)) {
+  if (DecoderTraits::IsMP4TypeAndEnabled(mimeType.Type().AsString(), aDiagnostics)) {
     if (IsMP4SupportedType(aType, aDiagnostics)) {
       return CANPLAY_YES;
     } else {
       // We can only reach this position if a particular codec was requested,
       // fmp4 is supported and working: the codec must be invalid.
       return CANPLAY_NO;
     }
   }
 #endif
-  if (IsMP3SupportedType(aType.GetMIMEType(), aType.GetCodecs())) {
+  if (IsMP3SupportedType(mimeType.Type().AsString(),
+                         aType.ExtendedType().Codecs().AsString())) {
     return CANPLAY_YES;
   }
-  if (IsAACSupportedType(aType.GetMIMEType(), aType.GetCodecs())) {
+  if (IsAACSupportedType(mimeType.Type().AsString(),
+                         aType.ExtendedType().Codecs().AsString())) {
     return CANPLAY_YES;
   }
-  if (IsFlacSupportedType(aType.GetMIMEType(), aType.GetCodecs())) {
+  if (IsFlacSupportedType(mimeType.Type().AsString(),
+                          aType.ExtendedType().Codecs().AsString())) {
     return CANPLAY_YES;
   }
 #ifdef MOZ_DIRECTSHOW
-  DirectShowDecoder::GetSupportedCodecs(aType.GetMIMEType(), &codecList);
+  DirectShowDecoder::GetSupportedCodecs(aType.Type().AsString(), &codecList);
 #endif
 #ifdef MOZ_ANDROID_OMX
   if (MediaDecoder::IsAndroidMediaPluginEnabled()) {
-    EnsureAndroidMediaPluginHost()->FindDecoder(aType.GetMIMEType(), &codecList);
+    EnsureAndroidMediaPluginHost()->FindDecoder(aType.Type().AsString(),
+                                                &codecList);
   }
 #endif
   if (!codecList) {
     return CANPLAY_MAYBE;
   }
 
   // See http://www.rfc-editor.org/rfc/rfc4281.txt for the description
   // of the 'codecs' parameter
-  nsCharSeparatedTokenizer tokenizer(aType.GetCodecs(), ',');
+  nsCharSeparatedTokenizer
+    tokenizer(aType.ExtendedType().Codecs().AsString(), ',');
   bool expectMoreTokens = false;
   while (tokenizer.hasMoreTokens()) {
     const nsSubstring& token = tokenizer.nextToken();
 
     if (!CodecListContains(codecList, token)) {
       // Totally unsupported codec
       return CANPLAY_NO;
     }
@@ -284,57 +295,61 @@ CanHandleCodecsType(const MediaContentTy
 
 static
 CanPlayStatus
 CanHandleMediaType(const MediaContentType& aType,
                    DecoderDoctorDiagnostics* aDiagnostics)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
-  if (IsHttpLiveStreamingType(aType.GetMIMEType())) {
+  if (IsHttpLiveStreamingType(aType.Type().AsString())) {
     Telemetry::Accumulate(Telemetry::MEDIA_HLS_CANPLAY_REQUESTED, true);
   }
 
-  if (aType.HaveCodecs()) {
+  if (aType.ExtendedType().HaveCodecs()) {
     CanPlayStatus result = CanHandleCodecsType(aType, aDiagnostics);
     if (result == CANPLAY_NO || result == CANPLAY_YES) {
       return result;
     }
   }
-  if (IsOggTypeAndEnabled(aType.GetMIMEType())) {
+
+  // Content type with just the MIME type/subtype, no codecs.
+  const MediaContentType mimeType(aType.Type());
+
+  if (IsOggTypeAndEnabled(mimeType.Type().AsString())) {
     return CANPLAY_MAYBE;
   }
-  if (IsWaveSupportedType(aType.GetMIMEType())) {
+  if (IsWaveSupportedType(mimeType.Type().AsString())) {
     return CANPLAY_MAYBE;
   }
-  if (DecoderTraits::IsMP4TypeAndEnabled(aType.GetMIMEType(), aDiagnostics)) {
+  if (DecoderTraits::IsMP4TypeAndEnabled(mimeType.Type().AsString(), aDiagnostics)) {
     return CANPLAY_MAYBE;
   }
 #if !defined(MOZ_OMX_WEBM_DECODER)
-  if (DecoderTraits::IsWebMTypeAndEnabled(aType.GetMIMEType())) {
+  if (DecoderTraits::IsWebMTypeAndEnabled(mimeType.Type().AsString())) {
     return CANPLAY_MAYBE;
   }
 #endif
-  if (IsMP3SupportedType(aType.GetMIMEType())) {
+  if (IsMP3SupportedType(mimeType.Type().AsString())) {
     return CANPLAY_MAYBE;
   }
-  if (IsAACSupportedType(aType.GetMIMEType())) {
+  if (IsAACSupportedType(mimeType.Type().AsString())) {
     return CANPLAY_MAYBE;
   }
-  if (IsFlacSupportedType(aType.GetMIMEType())) {
+  if (IsFlacSupportedType(mimeType.Type().AsString())) {
     return CANPLAY_MAYBE;
   }
 #ifdef MOZ_DIRECTSHOW
-  if (DirectShowDecoder::GetSupportedCodecs(aType.GetMIMEType(), nullptr)) {
+  if (DirectShowDecoder::GetSupportedCodecs(mimeType.Type().AsString(), nullptr)) {
     return CANPLAY_MAYBE;
   }
 #endif
 #ifdef MOZ_ANDROID_OMX
   if (MediaDecoder::IsAndroidMediaPluginEnabled() &&
-      EnsureAndroidMediaPluginHost()->FindDecoder(aType.GetMIMEType(), nullptr)) {
+      EnsureAndroidMediaPluginHost()->FindDecoder(mimeType.Type().AsString(), nullptr)) {
     return CANPLAY_MAYBE;
   }
 #endif
   return CANPLAY_NO;
 }
 
 /* static */
 CanPlayStatus
--- a/dom/media/MediaContentType.cpp
+++ b/dom/media/MediaContentType.cpp
@@ -5,66 +5,30 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "MediaContentType.h"
 
 #include "nsContentTypeParser.h"
 
 namespace mozilla {
 
-static int32_t
-GetParameterAsNumber(const nsContentTypeParser& aParser,
-                     const char* aParameter,
-                     const int32_t aErrorReturn)
-{
-  nsAutoString parameterString;
-  nsresult rv = aParser.GetParameter(aParameter, parameterString);
-  if (NS_FAILED_impl(rv)) {
-    return aErrorReturn;
-  }
-  int32_t number = parameterString.ToInteger(&rv);
-  if (MOZ_UNLIKELY(NS_FAILED_impl(rv))) {
-    return aErrorReturn;
-  }
-  return number;
-}
-
-bool
-MediaContentType::Populate(const nsAString& aType)
+size_t
+MediaContentType::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
 {
-  MOZ_ASSERT(NS_IsMainThread());
-
-  nsContentTypeParser parser(aType);
-  nsAutoString mime;
-  nsresult rv = parser.GetType(mime);
-  if (!NS_SUCCEEDED(rv) || mime.IsEmpty()) {
-    return false;
-  }
-
-  mMIMEType = NS_ConvertUTF16toUTF8(mime);
-
-  rv = parser.GetParameter("codecs", mCodecs);
-  mHaveCodecs = NS_SUCCEEDED(rv);
-
-  mWidth = GetParameterAsNumber(parser, "width", -1);
-  mHeight = GetParameterAsNumber(parser, "height", -1);
-  mFramerate = GetParameterAsNumber(parser, "framerate", -1);
-  mBitrate = GetParameterAsNumber(parser, "bitrate", -1);
-
-  return true;
+  return mExtendedMIMEType.SizeOfExcludingThis(aMallocSizeOf);
 }
 
 Maybe<MediaContentType>
 MakeMediaContentType(const nsAString& aType)
 {
-  Maybe<MediaContentType> type{Some(MediaContentType{})};
-  if (!type->Populate(aType)) {
-    type.reset();
+  Maybe<MediaExtendedMIMEType> mime = MakeMediaExtendedMIMEType(aType);
+  if (mime) {
+    return Some(MediaContentType(Move(*mime)));
   }
-  return type;
+  return Nothing();
 }
 
 Maybe<MediaContentType>
 MakeMediaContentType(const nsACString& aType)
 {
   return MakeMediaContentType(NS_ConvertUTF8toUTF16(aType));
 }
 
--- a/dom/media/MediaContentType.h
+++ b/dom/media/MediaContentType.h
@@ -2,56 +2,52 @@
 /* vim:set ts=2 sw=2 sts=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/. */
 
 #ifndef MediaContentType_h_
 #define MediaContentType_h_
 
+#include "MediaMIMETypes.h"
 #include "mozilla/Maybe.h"
 #include "nsString.h"
 
 namespace mozilla {
 
-// Structure containing pre-parsed content type parameters, e.g.:
-// MIME type, optional codecs, etc.
+// Class containing media type information for containers.
 class MediaContentType
 {
 public:
-  // MIME type. Guaranteed not to be empty.
-  const nsACString& GetMIMEType() const { return mMIMEType; }
+  explicit MediaContentType(const MediaMIMEType& aType)
+    : mExtendedMIMEType(aType)
+  {}
+  explicit MediaContentType(MediaMIMEType&& aType)
+    : mExtendedMIMEType(Move(aType))
+  {}
+  explicit MediaContentType(const MediaExtendedMIMEType& aType)
+    : mExtendedMIMEType(aType)
+  {
+  }
+  explicit MediaContentType(MediaExtendedMIMEType&& aType)
+    : mExtendedMIMEType(Move(aType))
+  {
+  }
 
-  // Was there an explicit 'codecs' parameter provided?
-  bool HaveCodecs() const { return mHaveCodecs; }
-  // Codecs. May be empty if not provided or explicitly provided as empty.
-  const nsAString& GetCodecs() const { return mCodecs; }
+  const MediaMIMEType& Type() const { return mExtendedMIMEType.Type(); }
+  const MediaExtendedMIMEType& ExtendedType() const { return mExtendedMIMEType; }
 
-  // Sizes and rates.
-  Maybe<int32_t> GetWidth() const { return GetMaybeNumber(mWidth); }
-  Maybe<int32_t> GetHeight() const { return GetMaybeNumber(mHeight); }
-  Maybe<int32_t> GetFramerate() const { return GetMaybeNumber(mFramerate); }
-  Maybe<int32_t> GetBitrate() const { return GetMaybeNumber(mBitrate); }
+  // Original string. Note that "type/subtype" may not be lowercase,
+  // use Type().AsString() instead to get the normalized "type/subtype".
+  const nsACString& OriginalString() const { return mExtendedMIMEType.OriginalString(); }
+
+  size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
 
 private:
-  friend Maybe<MediaContentType> MakeMediaContentType(const nsAString& aType);
-  bool Populate(const nsAString& aType);
-
-  Maybe<int32_t> GetMaybeNumber(int32_t aNumber) const
-  {
-    return (aNumber < 0) ? Maybe<int32_t>(Nothing()) : Some(int32_t(aNumber));
-  }
-
-  nsCString mMIMEType; // UTF8 MIME type.
-  bool mHaveCodecs; // If false, mCodecs must be empty.
-  nsString mCodecs;
-  int32_t mWidth; // -1 if not provided.
-  int32_t mHeight; // -1 if not provided.
-  int32_t mFramerate; // -1 if not provided.
-  int32_t mBitrate; // -1 if not provided.
+  MediaExtendedMIMEType mExtendedMIMEType;
 };
 
 Maybe<MediaContentType> MakeMediaContentType(const nsAString& aType);
 Maybe<MediaContentType> MakeMediaContentType(const nsACString& aType);
 Maybe<MediaContentType> MakeMediaContentType(const char* aType);
 
 } // namespace mozilla
 
copy from dom/media/MediaContentType.cpp
copy to dom/media/MediaMIMETypes.cpp
--- a/dom/media/MediaContentType.cpp
+++ b/dom/media/MediaMIMETypes.cpp
@@ -1,20 +1,124 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* 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 "MediaContentType.h"
+#include "MediaMIMETypes.h"
 
 #include "nsContentTypeParser.h"
 
 namespace mozilla {
 
+template <int N>
+static bool
+StartsWith(const nsACString& string, const char (&prefix)[N])
+{
+    if (N - 1 > string.Length()) {
+      return false;
+    }
+    return memcmp(string.Data(), prefix, N - 1) == 0;
+}
+
+bool
+MediaMIMEType::HasApplicationMajorType() const
+{
+  return StartsWith(mMIMEType, "application/");
+}
+
+bool
+MediaMIMEType::HasAudioMajorType() const
+{
+  return StartsWith(mMIMEType, "audio/");
+}
+
+bool
+MediaMIMEType::HasVideoMajorType() const
+{
+  return StartsWith(mMIMEType, "video/");
+}
+
+size_t
+MediaMIMEType::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
+{
+  return mMIMEType.SizeOfExcludingThisIfUnshared(aMallocSizeOf);
+}
+
+MediaMIMEType::MediaMIMEType(const nsACString& aType)
+  : mMIMEType(aType)
+{
+}
+
+Maybe<MediaMIMEType>
+MakeMediaMIMEType(const nsAString& aType)
+{
+  MOZ_ASSERT(NS_IsMainThread());
+
+  nsContentTypeParser parser(aType);
+  nsAutoString mime;
+  nsresult rv = parser.GetType(mime);
+  if (!NS_SUCCEEDED(rv) || mime.IsEmpty()) {
+    return Nothing();
+  }
+
+  NS_ConvertUTF16toUTF8 mime8{mime};
+  if (!IsMediaMIMEType(mime8)) {
+    return Nothing();
+  }
+
+  return Some(MediaMIMEType(mime8));
+}
+
+Maybe<MediaMIMEType>
+MakeMediaMIMEType(const nsACString& aType)
+{
+  return MakeMediaMIMEType(NS_ConvertUTF8toUTF16(aType));
+}
+
+Maybe<MediaMIMEType>
+MakeMediaMIMEType(const char* aType)
+{
+  if (!aType) {
+    return Nothing();
+  }
+  return MakeMediaMIMEType(nsDependentCString(aType));
+}
+
+bool
+MediaCodecs::Contains(const nsAString& aCodec) const
+{
+  for (const auto& myCodec : Range()) {
+    if (myCodec == aCodec) {
+      return true;
+    }
+  }
+  return false;
+}
+
+bool
+MediaCodecs::ContainsAll(const MediaCodecs& aCodecs) const
+{
+  const auto& codecsToTest = aCodecs.Range();
+  for (const auto& codecToTest : codecsToTest) {
+    if (!Contains(codecToTest)) {
+      return false;
+    }
+  }
+  return true;
+}
+
+size_t
+MediaCodecs::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
+{
+  return mCodecs.SizeOfExcludingThisIfUnshared(aMallocSizeOf);
+}
+
+
 static int32_t
 GetParameterAsNumber(const nsContentTypeParser& aParser,
                      const char* aParameter,
                      const int32_t aErrorReturn)
 {
   nsAutoString parameterString;
   nsresult rv = aParser.GetParameter(aParameter, parameterString);
   if (NS_FAILED_impl(rv)) {
@@ -22,59 +126,94 @@ GetParameterAsNumber(const nsContentType
   }
   int32_t number = parameterString.ToInteger(&rv);
   if (MOZ_UNLIKELY(NS_FAILED_impl(rv))) {
     return aErrorReturn;
   }
   return number;
 }
 
-bool
-MediaContentType::Populate(const nsAString& aType)
+MediaExtendedMIMEType::MediaExtendedMIMEType(const nsACString& aOriginalString,
+                                             const nsACString& aMIMEType,
+                                             bool aHaveCodecs,
+                                             const nsAString& aCodecs,
+                                             int32_t aWidth, int32_t aHeight,
+                                             int32_t aFramerate, int32_t aBitrate)
+  : mOriginalString(aOriginalString)
+  , mMIMEType(aMIMEType)
+  , mHaveCodecs(aHaveCodecs)
+  , mCodecs(aCodecs)
+  , mWidth(aWidth)
+  , mHeight(aHeight)
+  , mFramerate(aFramerate)
+  , mBitrate(aBitrate)
+{
+}
+
+MediaExtendedMIMEType::MediaExtendedMIMEType(const MediaMIMEType& aType)
+  : mOriginalString(aType.AsString())
+  , mMIMEType(aType)
+{
+}
+
+MediaExtendedMIMEType::MediaExtendedMIMEType(MediaMIMEType&& aType)
+  : mOriginalString(aType.AsString())
+  , mMIMEType(Move(aType))
+{
+}
+
+Maybe<MediaExtendedMIMEType>
+MakeMediaExtendedMIMEType(const nsAString& aType)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   nsContentTypeParser parser(aType);
   nsAutoString mime;
   nsresult rv = parser.GetType(mime);
   if (!NS_SUCCEEDED(rv) || mime.IsEmpty()) {
-    return false;
+    return Nothing();
+  }
+
+  NS_ConvertUTF16toUTF8 mime8{mime};
+  if (!IsMediaMIMEType(mime8)) {
+    return Nothing();
   }
 
-  mMIMEType = NS_ConvertUTF16toUTF8(mime);
-
-  rv = parser.GetParameter("codecs", mCodecs);
-  mHaveCodecs = NS_SUCCEEDED(rv);
+  nsAutoString codecs;
+  rv = parser.GetParameter("codecs", codecs);
+  bool haveCodecs = NS_SUCCEEDED(rv);
 
-  mWidth = GetParameterAsNumber(parser, "width", -1);
-  mHeight = GetParameterAsNumber(parser, "height", -1);
-  mFramerate = GetParameterAsNumber(parser, "framerate", -1);
-  mBitrate = GetParameterAsNumber(parser, "bitrate", -1);
+  int32_t width = GetParameterAsNumber(parser, "width", -1);
+  int32_t height = GetParameterAsNumber(parser, "height", -1);
+  int32_t framerate = GetParameterAsNumber(parser, "framerate", -1);
+  int32_t bitrate = GetParameterAsNumber(parser, "bitrate", -1);
 
-  return true;
+  return Some(MediaExtendedMIMEType(NS_ConvertUTF16toUTF8(aType),
+                                    mime8,
+                                    haveCodecs, codecs,
+                                    width, height,
+                                    framerate, bitrate));
 }
 
-Maybe<MediaContentType>
-MakeMediaContentType(const nsAString& aType)
+size_t
+MediaExtendedMIMEType::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
 {
-  Maybe<MediaContentType> type{Some(MediaContentType{})};
-  if (!type->Populate(aType)) {
-    type.reset();
-  }
-  return type;
+  return mOriginalString.SizeOfExcludingThisIfUnshared(aMallocSizeOf)
+         + mMIMEType.SizeOfExcludingThis(aMallocSizeOf)
+         + mCodecs.SizeOfExcludingThis(aMallocSizeOf);
 }
 
-Maybe<MediaContentType>
-MakeMediaContentType(const nsACString& aType)
+Maybe<MediaExtendedMIMEType>
+MakeMediaExtendedMIMEType(const nsACString& aType)
 {
-  return MakeMediaContentType(NS_ConvertUTF8toUTF16(aType));
+  return MakeMediaExtendedMIMEType(NS_ConvertUTF8toUTF16(aType));
 }
 
-Maybe<MediaContentType>
-MakeMediaContentType(const char* aType)
+Maybe<MediaExtendedMIMEType>
+MakeMediaExtendedMIMEType(const char* aType)
 {
   if (!aType) {
     return Nothing();
   }
-  return MakeMediaContentType(nsDependentCString(aType));
+  return MakeMediaExtendedMIMEType(nsDependentCString(aType));
 }
 
 } // namespace mozilla
copy from dom/media/MediaContentType.h
copy to dom/media/MediaMIMETypes.h
--- a/dom/media/MediaContentType.h
+++ b/dom/media/MediaMIMETypes.h
@@ -1,58 +1,205 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim:set ts=2 sw=2 sts=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/. */
 
-#ifndef MediaContentType_h_
-#define MediaContentType_h_
+#ifndef MediaMIMETypes_h_
+#define MediaMIMETypes_h_
 
 #include "mozilla/Maybe.h"
 #include "nsString.h"
+#include "VideoUtils.h"
 
 namespace mozilla {
 
-// Structure containing pre-parsed content type parameters, e.g.:
-// MIME type, optional codecs, etc.
-class MediaContentType
+// Class containing pointing at a media MIME "type/subtype" string literal.
+// See IsMediaMIMEType for restrictions.
+// Mainly used to help construct a MediaMIMEType through the statically-checked
+// MEDIAMIMETYPE macro, or to compare a MediaMIMEType to a literal.
+class DependentMediaMIMEType
+{
+public:
+  // Construction from a literal. Checked in debug builds.
+  // Use MEDIAMIMETYPE macro instead, for static checking.
+  template <size_t N>
+  explicit DependentMediaMIMEType(const char (&aType)[N])
+    : mMIMEType(aType, N - 1)
+  {
+    MOZ_ASSERT(IsMediaMIMEType(aType, N - 1), "Invalid media MIME type");
+  }
+
+  // MIME "type/subtype".
+  const nsDependentCString& AsDependentString() const { return mMIMEType; }
+
+private:
+  nsDependentCString mMIMEType;
+};
+
+// Instantiate a DependentMediaMIMEType from a literal. Statically checked.
+#define MEDIAMIMETYPE(LIT)                                            \
+  static_cast<const DependentMediaMIMEType&>(                         \
+    []() {                                                            \
+      static_assert(IsMediaMIMEType(LIT), "Invalid media MIME type"); \
+      return DependentMediaMIMEType(LIT);                             \
+    }())
+
+// Class containing only pre-parsed lowercase media MIME type/subtype.
+class MediaMIMEType
 {
 public:
-  // MIME type. Guaranteed not to be empty.
-  const nsACString& GetMIMEType() const { return mMIMEType; }
+  // Construction from a DependentMediaMIMEType, with its inherent checks.
+  // Implicit so MEDIAMIMETYPE can be used wherever a MediaMIMEType is expected.
+  MOZ_IMPLICIT MediaMIMEType(const DependentMediaMIMEType& aType)
+    : mMIMEType(aType.AsDependentString())
+  {}
+
+  // MIME "type/subtype", always lowercase.
+  const nsACString& AsString() const { return mMIMEType; }
+
+  // Comparison with DependentMediaMIMEType.
+  // Useful to compare to MEDIAMIMETYPE literals.
+  bool operator==(const DependentMediaMIMEType& aOther) const
+  {
+    return mMIMEType.Equals(aOther.AsDependentString());
+  }
+  bool operator!=(const DependentMediaMIMEType& aOther) const
+  {
+    return !mMIMEType.Equals(aOther.AsDependentString());
+  }
+
+  bool operator==(const MediaMIMEType& aOther) const
+  {
+    return mMIMEType.Equals(aOther.mMIMEType);
+  }
+  bool operator!=(const MediaMIMEType& aOther) const
+  {
+    return !mMIMEType.Equals(aOther.mMIMEType);
+  }
+
+  // True if type starts with "application/".
+  bool HasApplicationMajorType() const;
+  // True if type starts with "audio/".
+  // Note that some audio content could be stored in a "video/..." container!
+  bool HasAudioMajorType() const;
+  // True if type starts with "video/".
+  // Note that this does not guarantee 100% that the content is actually video!
+  // (e.g., "video/webm" could contain a vorbis audio track.)
+  bool HasVideoMajorType() const;
+
+  size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
+
+private:
+  friend Maybe<MediaMIMEType> MakeMediaMIMEType(const nsAString& aType);
+  friend class MediaExtendedMIMEType;
+  explicit MediaMIMEType(const nsACString& aType);
+
+  nsCString mMIMEType; // UTF8 MIME "type/subtype".
+};
+
+Maybe<MediaMIMEType> MakeMediaMIMEType(const nsAString& aType);
+Maybe<MediaMIMEType> MakeMediaMIMEType(const nsACString& aType);
+Maybe<MediaMIMEType> MakeMediaMIMEType(const char* aType);
+
+
+// A list of codecs attached to a MediaExtendedMIMEType.
+class MediaCodecs
+{
+public:
+  MediaCodecs() {}
+  // Construction from a comma-separated list of codecs. Unchecked.
+  explicit MediaCodecs(const nsAString& aCodecs)
+    : mCodecs(aCodecs)
+  {}
+  // Construction from a literal comma-separated list of codecs. Unchecked.
+  template <size_t N>
+  explicit MediaCodecs(const char (&aCodecs)[N])
+    : mCodecs(NS_ConvertUTF8toUTF16(aCodecs, N - 1))
+  {}
+
+  bool IsEmpty() const { return mCodecs.IsEmpty(); }
+  const nsAString& AsString() const { return mCodecs; }
+
+  using RangeType =
+    const StringListRange<nsString, StringListRangeEmptyItems::ProcessEmptyItems>;
+
+  // Produces a range object with begin()&end(), can be used in range-for loops.
+  // This will iterate through all codecs, even empty ones (except if the
+  // original list was an empty string). Iterators dereference to
+  // 'const nsDependentString', valid for as long as this MediaCodecs object.
+  RangeType Range() const
+  {
+    return RangeType(mCodecs);
+  };
+
+  bool Contains(const nsAString& aCodec) const;
+  bool ContainsAll(const MediaCodecs& aCodecs) const;
+
+  size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
+
+private:
+  // UTF16 comma-separated list of codecs.
+  // See http://www.rfc-editor.org/rfc/rfc4281.txt for the description
+  // of the 'codecs' parameter.
+  nsString mCodecs;
+};
+
+
+// Class containing pre-parsed media MIME type parameters, e.g.:
+// MIME type/subtype, optional codecs, etc.
+class MediaExtendedMIMEType
+{
+public:
+  explicit MediaExtendedMIMEType(const MediaMIMEType& aType);
+  explicit MediaExtendedMIMEType(MediaMIMEType&& aType);
+
+  // MIME "type/subtype".
+  const MediaMIMEType& Type() const { return mMIMEType; }
 
   // Was there an explicit 'codecs' parameter provided?
   bool HaveCodecs() const { return mHaveCodecs; }
   // Codecs. May be empty if not provided or explicitly provided as empty.
-  const nsAString& GetCodecs() const { return mCodecs; }
+  const MediaCodecs& Codecs() const { return mCodecs; }
 
   // Sizes and rates.
   Maybe<int32_t> GetWidth() const { return GetMaybeNumber(mWidth); }
   Maybe<int32_t> GetHeight() const { return GetMaybeNumber(mHeight); }
   Maybe<int32_t> GetFramerate() const { return GetMaybeNumber(mFramerate); }
   Maybe<int32_t> GetBitrate() const { return GetMaybeNumber(mBitrate); }
 
+  // Original string. Note that "type/subtype" may not be lowercase,
+  // use Type().AsString() instead to get the normalized "type/subtype".
+  const nsACString& OriginalString() const { return mOriginalString; }
+
+  size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
+
 private:
-  friend Maybe<MediaContentType> MakeMediaContentType(const nsAString& aType);
-  bool Populate(const nsAString& aType);
+  friend Maybe<MediaExtendedMIMEType> MakeMediaExtendedMIMEType(const nsAString& aType);
+  MediaExtendedMIMEType(const nsACString& aOriginalString,
+                        const nsACString& aMIMEType,
+                        bool aHaveCodecs, const nsAString& aCodecs,
+                        int32_t aWidth, int32_t aHeight,
+                        int32_t aFramerate, int32_t aBitrate);
 
   Maybe<int32_t> GetMaybeNumber(int32_t aNumber) const
   {
     return (aNumber < 0) ? Maybe<int32_t>(Nothing()) : Some(int32_t(aNumber));
   }
 
-  nsCString mMIMEType; // UTF8 MIME type.
-  bool mHaveCodecs; // If false, mCodecs must be empty.
-  nsString mCodecs;
-  int32_t mWidth; // -1 if not provided.
-  int32_t mHeight; // -1 if not provided.
-  int32_t mFramerate; // -1 if not provided.
-  int32_t mBitrate; // -1 if not provided.
+  nsCString mOriginalString; // Original full string.
+  MediaMIMEType mMIMEType; // MIME type/subtype.
+  bool mHaveCodecs = false; // If false, mCodecs must be empty.
+  MediaCodecs mCodecs;
+  int32_t mWidth = -1; // -1 if not provided.
+  int32_t mHeight = -1; // -1 if not provided.
+  int32_t mFramerate = -1; // -1 if not provided.
+  int32_t mBitrate = -1; // -1 if not provided.
 };
 
-Maybe<MediaContentType> MakeMediaContentType(const nsAString& aType);
-Maybe<MediaContentType> MakeMediaContentType(const nsACString& aType);
-Maybe<MediaContentType> MakeMediaContentType(const char* aType);
+Maybe<MediaExtendedMIMEType> MakeMediaExtendedMIMEType(const nsAString& aType);
+Maybe<MediaExtendedMIMEType> MakeMediaExtendedMIMEType(const nsACString& aType);
+Maybe<MediaExtendedMIMEType> MakeMediaExtendedMIMEType(const char* aType);
 
 } // namespace mozilla
 
-#endif // MediaContentType_h_
+#endif // MediaMIMETypes_h_
--- a/dom/media/MediaStreamListener.h
+++ b/dom/media/MediaStreamListener.h
@@ -4,16 +4,18 @@
  * 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/. */
 
 #ifndef MOZILLA_MEDIASTREAMLISTENER_h_
 #define MOZILLA_MEDIASTREAMLISTENER_h_
 
 #include "StreamTracks.h"
 
+#include "MediaStreamGraph.h"
+
 namespace mozilla {
 
 class AudioSegment;
 class MediaStream;
 class MediaStreamGraph;
 class MediaStreamVideoSink;
 class VideoSegment;
 
--- a/dom/media/VideoUtils.cpp
+++ b/dom/media/VideoUtils.cpp
@@ -505,21 +505,21 @@ UniquePtr<TrackInfo>
 CreateTrackInfoWithMIMETypeAndContentTypeExtraParameters(
   const nsACString& aCodecMIMEType,
   const MediaContentType& aContentType)
 {
   UniquePtr<TrackInfo> trackInfo = CreateTrackInfoWithMIMEType(aCodecMIMEType);
   if (trackInfo) {
     VideoInfo* videoInfo = trackInfo->GetAsVideoInfo();
     if (videoInfo) {
-      Maybe<int32_t> maybeWidth = aContentType.GetWidth();
+      Maybe<int32_t> maybeWidth = aContentType.ExtendedType().GetWidth();
       if (maybeWidth && *maybeWidth > 0) {
         videoInfo->mImage.width = *maybeWidth;
       }
-      Maybe<int32_t> maybeHeight = aContentType.GetHeight();
+      Maybe<int32_t> maybeHeight = aContentType.ExtendedType().GetHeight();
       if (maybeHeight && *maybeHeight > 0) {
         videoInfo->mImage.height = *maybeHeight;
       }
     }
   }
   return trackInfo;
 }
 
--- a/dom/media/VideoUtils.h
+++ b/dom/media/VideoUtils.h
@@ -357,16 +357,86 @@ CreateTrackInfoWithMIMEType(const nsACSt
 
 // Try and create a TrackInfo with a given codec MIME type, and optional extra
 // parameters from a content type (its MIME type and codecs are ignored).
 UniquePtr<TrackInfo>
 CreateTrackInfoWithMIMETypeAndContentTypeExtraParameters(
   const nsACString& aCodecMIMEType,
   const MediaContentType& aContentType);
 
+namespace detail {
+
+// aString should start with aMajor + '/'.
+constexpr bool
+StartsWithMIMETypeMajor(const char* aString,
+                        const char* aMajor, size_t aMajorRemaining)
+{
+  return (aMajorRemaining == 0 && *aString == '/')
+         || (*aString == *aMajor
+             && StartsWithMIMETypeMajor(aString + 1,
+                                        aMajor + 1, aMajorRemaining - 1));
+}
+
+// aString should only contain [a-z0-9\-\.] and a final '\0'.
+constexpr bool
+EndsWithMIMESubtype(const char* aString, size_t aRemaining)
+{
+  return aRemaining == 0
+         || (((*aString >= 'a' && *aString <= 'z')
+              || (*aString >= '0' && *aString <= '9')
+              || *aString == '-'
+              || *aString == '.')
+             && EndsWithMIMESubtype(aString + 1, aRemaining - 1));
+}
+
+// Simple MIME-type literal string checker with a given (major) type.
+// Only accepts "{aMajor}/[a-z0-9\-\.]+".
+template <size_t MajorLengthPlus1>
+constexpr bool
+IsMIMETypeWithMajor(const char* aString, size_t aLength,
+                    const char (&aMajor)[MajorLengthPlus1])
+{
+  return aLength > MajorLengthPlus1 // Major + '/' + at least 1 char
+         && StartsWithMIMETypeMajor(aString, aMajor, MajorLengthPlus1 - 1)
+         && EndsWithMIMESubtype(aString + MajorLengthPlus1,
+                                aLength - MajorLengthPlus1);
+}
+
+} // namespace detail
+
+// Simple MIME-type string checker.
+// Only accepts lowercase "{application,audio,video}/[a-z0-9\-\.]+".
+// Add more if necessary.
+constexpr bool
+IsMediaMIMEType(const char* aString, size_t aLength)
+{
+  return detail::IsMIMETypeWithMajor(aString, aLength, "application")
+         || detail::IsMIMETypeWithMajor(aString, aLength, "audio")
+         || detail::IsMIMETypeWithMajor(aString, aLength, "video");
+}
+
+// Simple MIME-type string literal checker.
+// Only accepts lowercase "{application,audio,video}/[a-z0-9\-\.]+".
+// Add more if necessary.
+template <size_t LengthPlus1>
+constexpr bool
+IsMediaMIMEType(const char (&aString)[LengthPlus1])
+{
+  return IsMediaMIMEType(aString, LengthPlus1 - 1);
+}
+
+// Simple MIME-type string checker.
+// Only accepts lowercase "{application,audio,video}/[a-z0-9\-\.]+".
+// Add more if necessary.
+inline bool
+IsMediaMIMEType(const nsACString& aString)
+{
+  return IsMediaMIMEType(aString.Data(), aString.Length());
+}
+
 enum class StringListRangeEmptyItems
 {
   // Skip all empty items (empty string will process nothing)
   // E.g.: "a,,b" -> ["a", "b"], "" -> nothing
   Skip,
   // Process all, except if string is empty
   // E.g.: "a,,b" -> ["a", "", "b"], "" -> nothing
   ProcessEmptyItems,
--- a/dom/media/fmp4/MP4Decoder.cpp
+++ b/dom/media/fmp4/MP4Decoder.cpp
@@ -72,48 +72,48 @@ MP4Decoder::CanHandleMediaType(const Med
 {
   if (!IsEnabled()) {
     return false;
   }
 
   // Whitelist MP4 types, so they explicitly match what we encounter on
   // the web, as opposed to what we use internally (i.e. what our demuxers
   // etc output).
-  const bool isMP4Audio = aType.GetMIMEType().EqualsASCII("audio/mp4") ||
-                          aType.GetMIMEType().EqualsASCII("audio/x-m4a");
+  const bool isMP4Audio = aType.Type() == MEDIAMIMETYPE("audio/mp4") ||
+                          aType.Type() == MEDIAMIMETYPE("audio/x-m4a");
   const bool isMP4Video =
   // On B2G, treat 3GPP as MP4 when Gonk PDM is available.
 #ifdef MOZ_GONK_MEDIACODEC
-      aType.GetMIMEType().EqualsASCII(VIDEO_3GPP) ||
+      aType.Type() == MEDIAMIMETYPE(VIDEO_3GPP) ||
 #endif
-      aType.GetMIMEType().EqualsASCII("video/mp4") ||
-      aType.GetMIMEType().EqualsASCII("video/quicktime") ||
-      aType.GetMIMEType().EqualsASCII("video/x-m4v");
+      aType.Type() == MEDIAMIMETYPE("video/mp4") ||
+      aType.Type() == MEDIAMIMETYPE("video/quicktime") ||
+      aType.Type() == MEDIAMIMETYPE("video/x-m4v");
   if (!isMP4Audio && !isMP4Video) {
     return false;
   }
 
   nsTArray<UniquePtr<TrackInfo>> trackInfos;
-  if (aType.GetCodecs().IsEmpty()) {
+  if (aType.ExtendedType().Codecs().IsEmpty()) {
     // No codecs specified. Assume H.264
     if (isMP4Audio) {
       trackInfos.AppendElement(
         CreateTrackInfoWithMIMETypeAndContentTypeExtraParameters(
           NS_LITERAL_CSTRING("audio/mp4a-latm"), aType));
     } else {
       MOZ_ASSERT(isMP4Video);
       trackInfos.AppendElement(
         CreateTrackInfoWithMIMETypeAndContentTypeExtraParameters(
           NS_LITERAL_CSTRING("video/avc"), aType));
     }
   } else {
     // Verify that all the codecs specified are ones that we expect that
     // we can play.
     nsTArray<nsString> codecs;
-    if (!ParseCodecsString(aType.GetCodecs(), codecs)) {
+    if (!ParseCodecsString(aType.ExtendedType().Codecs().AsString(), codecs)) {
       return false;
     }
     for (const nsString& codec : codecs) {
       if (IsAACCodecString(codec)) {
         trackInfos.AppendElement(
           CreateTrackInfoWithMIMETypeAndContentTypeExtraParameters(
             NS_LITERAL_CSTRING("audio/mp4a-latm"), aType));
         continue;
new file mode 100644
--- /dev/null
+++ b/dom/media/gtest/TestMediaMIMETypes.cpp
@@ -0,0 +1,237 @@
+/* -*- 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 "gtest/gtest.h"
+#include "MediaContentType.h"
+
+using namespace mozilla;
+
+TEST(MediaMIMETypes, DependentMIMEType)
+{
+  static const struct
+  {
+    const char* mString;
+    DependentMediaMIMEType mDependentMediaMIMEType;
+  }
+  tests[] =
+  {
+    { "audio/mp4",         MEDIAMIMETYPE("audio/mp4")         },
+    { "video/mp4",         MEDIAMIMETYPE("video/mp4")         },
+    { "application/x-mp4", MEDIAMIMETYPE("application/x-mp4") }
+  };
+  for (const auto& test : tests) {
+    EXPECT_TRUE(test.mDependentMediaMIMEType.AsDependentString().EqualsASCII(test.mString));
+    MediaMIMEType mimetype(test.mDependentMediaMIMEType);
+    EXPECT_TRUE(mimetype.AsString().Equals(test.mDependentMediaMIMEType.AsDependentString()));
+    EXPECT_EQ(mimetype, test.mDependentMediaMIMEType);
+    EXPECT_EQ(mimetype, MediaMIMEType(test.mDependentMediaMIMEType));
+  }
+}
+
+TEST(MediaMIMETypes, MakeMediaMIMEType_bad)
+{
+  static const char* tests[] =
+  {
+    "",
+    " ",
+    "/",
+    "audio",
+    "audio/",
+    "mp4",
+    "/mp4",
+    "a/b"
+  };
+
+  for (const auto& test : tests) {
+    Maybe<MediaMIMEType> type = MakeMediaMIMEType(test);
+    EXPECT_TRUE(type.isNothing())
+      << "MakeMediaMIMEType(\"" << test << "\").isNothing()";
+  }
+}
+
+TEST(MediaMIMETypes, MediaMIMEType)
+{
+  static const struct
+  {
+    const char* mTypeString;
+    const char* mAsString;
+    bool mApplication;
+    bool mAudio;
+    bool mVideo;
+    bool mEqualsLiteralVideoSlashMp4; // tests `== "video/mp4"`
+  } tests[] =
+  { // in                    AsString         app    audio  video  ==v/mp4
+    { "video/mp4",           "video/mp4",     false, false, true,  true  },
+    { "video/mp4; codecs=0", "video/mp4",     false, false, true,  true  },
+    { "VIDEO/MP4",           "video/mp4",     false, false, true,  true  },
+    { "audio/mp4",           "audio/mp4",     false, true,  false, false },
+    { "application/x",       "application/x", true, false,  false, false }
+  };
+
+  for (const auto& test : tests) {
+    Maybe<MediaMIMEType> type = MakeMediaMIMEType(test.mTypeString);
+    EXPECT_TRUE(type.isSome())
+      << "MakeMediaMIMEType(\"" << test.mTypeString << "\").isSome()";
+    EXPECT_TRUE(type->AsString().EqualsASCII(test.mAsString))
+      << "MakeMediaMIMEType(\"" << test.mTypeString << "\")->AsString() == \"" << test.mAsString << "\"";
+    EXPECT_EQ(test.mApplication, type->HasApplicationMajorType())
+      << "MakeMediaMIMEType(\"" << test.mTypeString << "\")->HasApplicationMajorType() == " << (test.mApplication ? "true" : "false");
+    EXPECT_EQ(test.mAudio, type->HasAudioMajorType())
+      << "MakeMediaMIMEType(\"" << test.mTypeString << "\")->HasAudioMajorType() == " << (test.mAudio ? "true" : "false");
+    EXPECT_EQ(test.mVideo, type->HasVideoMajorType())
+      << "MakeMediaMIMEType(\"" << test.mTypeString << "\")->HasVideoMajorType() == " << (test.mVideo ? "true" : "false");
+    EXPECT_EQ(test.mEqualsLiteralVideoSlashMp4, *type == MEDIAMIMETYPE("video/mp4"))
+      << "*MakeMediaMIMEType(\"" << test.mTypeString << "\") == MEDIAMIMETYPE(\"video/mp4\")";
+  }
+}
+
+TEST(MediaMIMETypes, MediaCodecs)
+{
+  MediaCodecs empty("");
+  EXPECT_TRUE(empty.IsEmpty());
+  EXPECT_TRUE(empty.AsString().EqualsLiteral(""));
+  EXPECT_FALSE(empty.Contains(NS_LITERAL_STRING("")));
+  EXPECT_FALSE(empty.Contains(NS_LITERAL_STRING("c1")));
+  int iterations = 0;
+  for (const auto& codec : empty.Range()) {
+    ++iterations;
+    Unused << codec;
+  }
+  EXPECT_EQ(0, iterations);
+
+  MediaCodecs space(" ");
+  EXPECT_FALSE(space.IsEmpty());
+  EXPECT_TRUE(space.AsString().EqualsLiteral(" "));
+  EXPECT_TRUE(space.Contains(NS_LITERAL_STRING("")));
+  EXPECT_FALSE(space.Contains(NS_LITERAL_STRING("c1")));
+  iterations = 0;
+  for (const auto& codec : space.Range()) {
+    ++iterations;
+    EXPECT_TRUE(codec.IsEmpty());
+  }
+  EXPECT_EQ(1, iterations);
+
+  MediaCodecs one(" c1 ");
+  EXPECT_FALSE(one.IsEmpty());
+  EXPECT_TRUE(one.AsString().EqualsLiteral(" c1 "));
+  EXPECT_FALSE(one.Contains(NS_LITERAL_STRING("")));
+  EXPECT_TRUE(one.Contains(NS_LITERAL_STRING("c1")));
+  iterations = 0;
+  for (const auto& codec : one.Range()) {
+    ++iterations;
+    EXPECT_TRUE(codec.EqualsLiteral("c1"));
+  }
+  EXPECT_EQ(1, iterations);
+
+  MediaCodecs two(" c1 , c2 ");
+  EXPECT_FALSE(two.IsEmpty());
+  EXPECT_TRUE(two.AsString().EqualsLiteral(" c1 , c2 "));
+  EXPECT_FALSE(two.Contains(NS_LITERAL_STRING("")));
+  EXPECT_TRUE(two.Contains(NS_LITERAL_STRING("c1")));
+  EXPECT_TRUE(two.Contains(NS_LITERAL_STRING("c2")));
+  iterations = 0;
+  for (const auto& codec : two.Range()) {
+    ++iterations;
+    char buffer[] = "c0";
+    buffer[1] += iterations;
+    EXPECT_TRUE(codec.EqualsASCII(buffer));
+  }
+  EXPECT_EQ(2, iterations);
+
+  EXPECT_TRUE(two.ContainsAll(two));
+  EXPECT_TRUE(two.ContainsAll(one));
+  EXPECT_FALSE(one.ContainsAll(two));
+}
+
+TEST(MediaMIMETypes, MakeMediaExtendedMIMEType_bad)
+{
+  static const char* tests[] =
+  {
+    "",
+    " ",
+    "/",
+    "audio",
+    "audio/",
+    "mp4",
+    "/mp4",
+    "a/b"
+  };
+
+  for (const auto& test : tests) {
+    Maybe<MediaExtendedMIMEType> type = MakeMediaExtendedMIMEType(test);
+    EXPECT_TRUE(type.isNothing())
+      << "MakeMediaExtendedMIMEType(\"" << test << "\").isNothing()";
+  }
+}
+
+TEST(MediaMIMETypes, MediaExtendedMIMEType)
+{
+  // Some generic tests first.
+  static const struct
+  {
+    const char* mTypeString;
+    const char* mTypeAsString;
+    bool mApplication;
+    bool mAudio;
+    bool mVideo;
+    bool mEqualsLiteralVideoSlashMp4; // tests `== "video/mp4"`
+    bool mHaveCodecs;
+  } tests[] =
+  { // in                    Type().AsString  app    audio  video ==v/mp4 codecs
+    { "video/mp4",           "video/mp4",     false, false, true,  true,  false },
+    { "video/mp4; codecs=0", "video/mp4",     false, false, true,  true,  true  },
+    { "VIDEO/MP4",           "video/mp4",     false, false, true,  true,  false },
+    { "audio/mp4",           "audio/mp4",     false, true,  false, false, false },
+    { "application/x",       "application/x", true, false,  false, false, false }
+  };
+
+  for (const auto& test : tests) {
+    Maybe<MediaExtendedMIMEType> type = MakeMediaExtendedMIMEType(test.mTypeString);
+    EXPECT_TRUE(type.isSome())
+      << "MakeMediaExtendedMIMEType(\"" << test.mTypeString << "\").isSome()";
+    EXPECT_TRUE(type->OriginalString().EqualsASCII(test.mTypeString))
+      << "MakeMediaExtendedMIMEType(\"" << test.mTypeString << "\")->AsString() == \"" << test.mTypeAsString << "\"";
+    EXPECT_TRUE(type->Type().AsString().EqualsASCII(test.mTypeAsString))
+      << "MakeMediaExtendedMIMEType(\"" << test.mTypeString << "\")->AsString() == \"" << test.mTypeAsString << "\"";
+    EXPECT_EQ(test.mApplication, type->Type().HasApplicationMajorType())
+      << "MakeMediaExtendedMIMEType(\"" << test.mTypeString << "\")->Type().HasApplicationMajorType() == " << (test.mApplication ? "true" : "false");
+    EXPECT_EQ(test.mAudio, type->Type().HasAudioMajorType())
+      << "MakeMediaExtendedMIMEType(\"" << test.mTypeString << "\")->Type().HasAudioMajorType() == " << (test.mAudio ? "true" : "false");
+    EXPECT_EQ(test.mVideo, type->Type().HasVideoMajorType())
+      << "MakeMediaExtendedMIMEType(\"" << test.mTypeString << "\")->Type().HasVideoMajorType() == " << (test.mVideo ? "true" : "false");
+    EXPECT_EQ(test.mEqualsLiteralVideoSlashMp4, type->Type() == MEDIAMIMETYPE("video/mp4"))
+      << "*MakeMediaExtendedMIMEType(\"" << test.mTypeString << "\")->Type() == MEDIAMIMETYPE(\"video/mp4\")";
+    EXPECT_EQ(test.mHaveCodecs, type->HaveCodecs())
+      << "MakeMediaExtendedMIMEType(\"" << test.mTypeString << "\")->HaveCodecs() == " << (test.mHaveCodecs ? "true" : "false");
+    EXPECT_NE(test.mHaveCodecs, type->Codecs().IsEmpty())
+      << "MakeMediaExtendedMIMEType(\"" << test.mTypeString << "\")->Codecs.IsEmpty() != " << (test.mHaveCodecs ? "true" : "false");
+    EXPECT_FALSE(type->GetWidth())
+      << "MakeMediaExtendedMIMEType(\"" << test.mTypeString << "\")->GetWidth()";
+    EXPECT_FALSE(type->GetHeight())
+      << "MakeMediaExtendedMIMEType(\"" << test.mTypeString << "\")->GetHeight()";
+    EXPECT_FALSE(type->GetFramerate())
+      << "MakeMediaExtendedMIMEType(\"" << test.mTypeString << "\")->GetFramerate()";
+    EXPECT_FALSE(type->GetBitrate())
+      << "MakeMediaExtendedMIMEType(\"" << test.mTypeString << "\")->GetBitrate()";
+  }
+
+  // Test all extra parameters.
+  Maybe<MediaExtendedMIMEType> type =
+    MakeMediaExtendedMIMEType(
+      "video/mp4; codecs=\"a,b\"; width=1024; Height=768; FrameRate=60; BITRATE=100000");
+  EXPECT_TRUE(type->HaveCodecs());
+  EXPECT_FALSE(type->Codecs().IsEmpty());
+  EXPECT_TRUE(type->Codecs().AsString().EqualsASCII("a,b"));
+  EXPECT_TRUE(type->Codecs().Contains(NS_LITERAL_STRING("a")));
+  EXPECT_TRUE(type->Codecs().Contains(NS_LITERAL_STRING("b")));
+  EXPECT_TRUE(!!type->GetWidth());
+  EXPECT_EQ(1024, *type->GetWidth());
+  EXPECT_TRUE(!!type->GetHeight());
+  EXPECT_EQ(768, *type->GetHeight());
+  EXPECT_TRUE(!!type->GetFramerate());
+  EXPECT_EQ(60, *type->GetFramerate());
+  EXPECT_TRUE(!!type->GetBitrate());
+  EXPECT_EQ(100000, *type->GetBitrate());
+}
--- a/dom/media/gtest/TestVideoUtils.cpp
+++ b/dom/media/gtest/TestVideoUtils.cpp
@@ -4,16 +4,32 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "gtest/gtest.h"
 #include "nsString.h"
 #include "VideoUtils.h"
 
 using namespace mozilla;
 
+TEST(MediaMIMETypes, IsMediaMIMEType)
+{
+  EXPECT_TRUE(IsMediaMIMEType("audio/mp4"));
+  EXPECT_TRUE(IsMediaMIMEType("video/mp4"));
+  EXPECT_TRUE(IsMediaMIMEType("application/x-mp4"));
+
+  EXPECT_TRUE(IsMediaMIMEType("audio/m"));
+  EXPECT_FALSE(IsMediaMIMEType("audio/"));
+
+  EXPECT_FALSE(IsMediaMIMEType("vide/mp4"));
+  EXPECT_FALSE(IsMediaMIMEType("videos/mp4"));
+
+  // Expect lowercase only.
+  EXPECT_FALSE(IsMediaMIMEType("Video/mp4"));
+}
+
 TEST(StringListRange, MakeStringListRange)
 {
   static const struct
   {
     const char* mList;
     const char* mExpectedSkipEmpties;
     const char* mExpectedProcessAll;
     const char* mExpectedProcessEmpties;
--- a/dom/media/gtest/moz.build
+++ b/dom/media/gtest/moz.build
@@ -12,16 +12,17 @@ UNIFIED_SOURCES += [
     'TestAudioPacketizer.cpp',
     'TestAudioSegment.cpp',
     'TestGMPCrossOrigin.cpp',
     'TestGMPRemoveAndDelete.cpp',
     'TestGMPUtils.cpp',
     'TestIntervalSet.cpp',
     'TestMediaDataDecoder.cpp',
     'TestMediaEventSource.cpp',
+    'TestMediaMIMETypes.cpp',
     'TestMozPromise.cpp',
     'TestMP3Demuxer.cpp',
     'TestMP4Demuxer.cpp',
     # 'TestMP4Reader.cpp', disabled so we can turn check tests back on (bug 1175752)
     'TestTrackEncoder.cpp',
     'TestVideoSegment.cpp',
     'TestVideoUtils.cpp',
     'TestVPXDecoding.cpp',
--- a/dom/media/mediasource/MediaSource.cpp
+++ b/dom/media/mediasource/MediaSource.cpp
@@ -90,41 +90,42 @@ nsresult
 MediaSource::IsTypeSupported(const nsAString& aType, DecoderDoctorDiagnostics* aDiagnostics)
 {
   if (aType.IsEmpty()) {
     return NS_ERROR_DOM_TYPE_ERR;
   }
 
   Maybe<MediaContentType> contentType = MakeMediaContentType(aType);
   if (!contentType) {
-    return NS_ERROR_DOM_TYPE_ERR;
+    return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
   }
 
   if (DecoderTraits::CanHandleContentType(*contentType, aDiagnostics)
       == CANPLAY_NO) {
     return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
   }
 
   // Now we know that this media type could be played.
   // MediaSource imposes extra restrictions, and some prefs.
-  const nsACString& mimeType = contentType->GetMIMEType();
-  if (mimeType.EqualsASCII("video/mp4") || mimeType.EqualsASCII("audio/mp4")) {
+  const MediaMIMEType& mimeType = contentType->Type();
+  if (mimeType == MEDIAMIMETYPE("video/mp4") ||
+      mimeType == MEDIAMIMETYPE("audio/mp4")) {
     if (!Preferences::GetBool("media.mediasource.mp4.enabled", false)) {
       return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
     }
     return NS_OK;
   }
-  if (mimeType.EqualsASCII("video/webm")) {
+  if (mimeType == MEDIAMIMETYPE("video/webm")) {
     if (!(Preferences::GetBool("media.mediasource.webm.enabled", false) ||
           IsWebMForced(aDiagnostics))) {
       return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
     }
     return NS_OK;
   }
-  if (mimeType.EqualsASCII("audio/webm")) {
+  if (mimeType == MEDIAMIMETYPE("audio/webm")) {
     if (!(Preferences::GetBool("media.mediasource.webm.enabled", false) ||
           Preferences::GetBool("media.mediasource.webm.audio.enabled", true))) {
       return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
     }
     return NS_OK;
   }
 
   return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
@@ -237,17 +238,17 @@ MediaSource::AddSourceBuffer(const nsASt
     aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
     return nullptr;
   }
   Maybe<MediaContentType> contentType = MakeMediaContentType(aType);
   if (!contentType) {
     aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
     return nullptr;
   }
-  const nsACString& mimeType = contentType->GetMIMEType();
+  const nsACString& mimeType = contentType->Type().AsString();
   RefPtr<SourceBuffer> sourceBuffer = new SourceBuffer(this, mimeType);
   if (!sourceBuffer) {
     aRv.Throw(NS_ERROR_FAILURE); // XXX need a better error here
     return nullptr;
   }
   mSourceBuffers->Append(sourceBuffer);
   MSE_DEBUG("sourceBuffer=%p", sourceBuffer.get());
   return sourceBuffer.forget();
--- a/dom/media/moz.build
+++ b/dom/media/moz.build
@@ -106,16 +106,17 @@ EXPORTS += [
     'MediaDecoder.h',
     'MediaDecoderOwner.h',
     'MediaDecoderReader.h',
     'MediaDecoderStateMachine.h',
     'MediaEventSource.h',
     'MediaFormatReader.h',
     'MediaInfo.h',
     'MediaMetadataManager.h',
+    'MediaMIMETypes.h',
     'MediaPrefs.h',
     'MediaQueue.h',
     'MediaRecorder.h',
     'MediaResource.h',
     'MediaResourceCallback.h',
     'MediaResult.h',
     'MediaSegment.h',
     'MediaStatistics.h',
@@ -213,16 +214,17 @@ UNIFIED_SOURCES += [
     'MediaDecoderReader.cpp',
     'MediaDecoderReaderWrapper.cpp',
     'MediaDecoderStateMachine.cpp',
     'MediaDeviceInfo.cpp',
     'MediaDevices.cpp',
     'MediaFormatReader.cpp',
     'MediaInfo.cpp',
     'MediaManager.cpp',
+    'MediaMIMETypes.cpp',
     'MediaPrefs.cpp',
     'MediaRecorder.cpp',
     'MediaResource.cpp',
     'MediaShutdownManager.cpp',
     'MediaStreamError.cpp',
     'MediaStreamGraph.cpp',
     'MediaStreamListener.cpp',
     'MediaStreamTrack.cpp',
--- a/js/ipc/JavaScriptParent.cpp
+++ b/js/ipc/JavaScriptParent.cpp
@@ -160,17 +160,17 @@ JavaScriptParent::trace(JSTracer* trc)
     objects_.trace(trc);
     unwaivedObjectIds_.trace(trc);
     waivedObjectIds_.trace(trc);
 }
 
 JSObject*
 JavaScriptParent::scopeForTargetObjects()
 {
-    // CPWOWs from the child need to point into the parent's unprivileged junk
+    // CPOWs from the child need to point into the parent's unprivileged junk
     // scope so that a compromised child cannot compromise the parent. In
     // practice, this means that a child process can only (a) hold parent
     // objects alive and (b) invoke them if they are callable.
     return xpc::UnprivilegedJunkScope();
 }
 
 void
 JavaScriptParent::afterProcessTask()
--- a/js/ipc/JavaScriptShared.cpp
+++ b/js/ipc/JavaScriptShared.cpp
@@ -28,20 +28,20 @@ bool
 IdToObjectMap::init()
 {
     if (table_.initialized())
         return true;
     return table_.init(32);
 }
 
 void
-IdToObjectMap::trace(JSTracer* trc, uint64_t minimimId)
+IdToObjectMap::trace(JSTracer* trc, uint64_t minimumId)
 {
     for (Table::Range r(table_.all()); !r.empty(); r.popFront()) {
-        if (r.front().key().serialNumber() >= minimimId)
+        if (r.front().key().serialNumber() >= minimumId)
             JS::TraceEdge(trc, &r.front().value(), "ipc-object");
     }
 }
 
 void
 IdToObjectMap::sweep()
 {
     for (Table::Enum e(table_); !e.empty(); e.popFront()) {
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/debug/bug1330339.js
@@ -0,0 +1,36 @@
+// |jit-test| test-also-wasm-baseline; error: TestComplete
+
+if (!wasmIsSupported())
+     throw "TestComplete";
+
+let module = new WebAssembly.Module(wasmTextToBinary(`
+    (module
+        (import "global" "func")
+        (func (export "test")
+         call 0 ;; calls the import, which is func #0
+        )
+    )
+`));
+
+let imports = {
+  global: {
+    func: function () {
+        let g = newGlobal();
+        let dbg = new Debugger(g);
+        dbg.onExceptionUnwind = function (frame) {
+            frame.older;
+        };
+        g.eval("throw new Error();");
+    }
+  }
+};
+let instance = new WebAssembly.Instance(module, imports);
+
+try {
+    instance.exports.test();
+    assertEq(false, true);
+} catch (e) {
+    assertEq(e.constructor.name, 'Error');
+}
+
+throw "TestComplete";
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/debug/bug1330491.js
@@ -0,0 +1,21 @@
+// |jit-test| test-also-wasm-baseline; error: TestComplete
+
+if (!wasmIsSupported())
+     throw "TestComplete";
+
+(function createShortLivedDebugger() {
+    var g = newGlobal();
+    g.debuggeeGlobal = this;
+    g.eval("(" + function () {
+        dbg = new Debugger(debuggeeGlobal);
+    } + ")();");
+})();
+
+let module = new WebAssembly.Module(wasmTextToBinary('(module (func))'));
+new WebAssembly.Instance(module);
+
+gcslice(1000000);
+
+new WebAssembly.Instance(module);
+
+throw "TestComplete";
\ No newline at end of file
--- a/js/src/jit/AtomicOperations.h
+++ b/js/src/jit/AtomicOperations.h
@@ -336,16 +336,18 @@ AtomicOperations::isLockfree(int32_t siz
   // When the JIT is disabled the operations are simply safe-for-races
   // C++ realizations of atomics.  These operations cannot be written
   // in portable C++, hence the default here is to crash.  See the
   // top of the file for more guidance.
 # if defined(__ppc64__) || defined(__PPC64__) || defined(__ppc64le__) || defined(__PPC64LE__)
 #  include "jit/none/AtomicOperations-ppc.h"
 # elif defined(__aarch64__)
 #  include "jit/arm64/AtomicOperations-arm64.h"
+# elif defined(__alpha__)
+#  include "jit/none/AtomicOperations-ppc.h"
 # elif defined(__hppa__)
 #  include "jit/none/AtomicOperations-ppc.h"
 # else
 #  include "jit/none/AtomicOperations-none.h" // These MOZ_CRASH() always
 # endif
 #elif defined(JS_CODEGEN_X86) || defined(JS_CODEGEN_X64)
 # include "jit/x86-shared/AtomicOperations-x86-shared.h"
 #else
--- a/js/src/vm/Debugger.cpp
+++ b/js/src/vm/Debugger.cpp
@@ -6292,18 +6292,22 @@ bool
 Debugger::observesFrame(const FrameIter& iter) const
 {
     // Skip frames not yet fully initialized during their prologue.
     if (iter.isInterp() && iter.isFunctionFrame()) {
         const Value& thisVal = iter.interpFrame()->thisArgument();
         if (thisVal.isMagic() && thisVal.whyMagic() == JS_IS_CONSTRUCTING)
             return false;
     }
-    if (iter.isWasm())
+    if (iter.isWasm()) {
+        // Skip frame of wasm instances we cannot observe.
+        if (!iter.wasmDebugEnabled())
+            return false;
         return observesWasm(iter.wasmInstance());
+    }
     return observesScript(iter.script());
 }
 
 bool
 Debugger::observesScript(JSScript* script) const
 {
     if (!enabled)
         return false;
--- a/js/src/vm/Stack.h
+++ b/js/src/vm/Stack.h
@@ -1806,16 +1806,18 @@ class FrameIter
     JSAtom* functionDisplayAtom() const;
     bool mutedErrors() const;
 
     bool hasScript() const { return !isWasm(); }
 
     // -----------------------------------------------------------
     //  The following functions can only be called when isWasm()
     // -----------------------------------------------------------
+
+    inline bool wasmDebugEnabled() const;
     inline wasm::Instance* wasmInstance() const;
 
     // -----------------------------------------------------------
     // The following functions can only be called when hasScript()
     // -----------------------------------------------------------
 
     inline JSScript* script() const;
 
@@ -2051,21 +2053,29 @@ FrameIter::script() const
     if (data_.state_ == INTERP)
         return interpFrame()->script();
     MOZ_ASSERT(data_.state_ == JIT);
     if (data_.jitFrames_.isIonJS())
         return ionInlineFrames_.script();
     return data_.jitFrames_.script();
 }
 
+inline bool
+FrameIter::wasmDebugEnabled() const
+{
+    MOZ_ASSERT(!done());
+    MOZ_ASSERT(data_.state_ == WASM);
+    return data_.wasmFrames_.debugEnabled();
+}
+
 inline wasm::Instance*
 FrameIter::wasmInstance() const
 {
     MOZ_ASSERT(!done());
-    MOZ_ASSERT(data_.state_ == WASM);
+    MOZ_ASSERT(data_.state_ == WASM && wasmDebugEnabled());
     return data_.wasmFrames_.instance();
 }
 
 inline bool
 FrameIter::isIon() const
 {
     return isJit() && data_.jitFrames_.isIonJS();
 }
--- a/js/src/wasm/WasmModule.cpp
+++ b/js/src/wasm/WasmModule.cpp
@@ -888,22 +888,26 @@ Module::instantiate(JSContext* cx,
     SharedTableVector tables;
     if (!instantiateTable(cx, &table, &tables))
         return false;
 
     // To support viewing the source of an instance (Instance::createText), the
     // instance must hold onto a ref of the bytecode (keeping it alive). This
     // wastes memory for most users, so we try to only save the source when a
     // developer actually cares: when the compartment is debuggable (which is
-    // true when the web console is open) or a names section is present (since
-    // this going to be stripped for non-developer builds).
+    // true when the web console is open), has code compiled with debug flag
+    // enabled or a names section is present (since this going to be stripped
+    // for non-developer builds).
 
     const ShareableBytes* maybeBytecode = nullptr;
-    if (cx->compartment()->isDebuggee() || !metadata_->funcNames.empty())
+    if (cx->compartment()->isDebuggee() || metadata_->debugEnabled ||
+        !metadata_->funcNames.empty())
+    {
         maybeBytecode = bytecode_.get();
+    }
 
     auto codeSegment = CodeSegment::create(cx, code_, linkData_, *metadata_, memory);
     if (!codeSegment)
         return false;
 
     auto code = cx->make_unique<Code>(Move(codeSegment), *metadata_, maybeBytecode);
     if (!code)
         return false;
--- a/layout/style/ServoBindings.cpp
+++ b/layout/style/ServoBindings.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/ServoBindings.h"
 
 #include "ChildIterator.h"
 #include "gfxFontFamilyList.h"
 #include "nsAttrValueInlines.h"
+#include "nsCSSProps.h"
 #include "nsCSSParser.h"
 #include "nsCSSRuleProcessor.h"
 #include "nsContentUtils.h"
 #include "nsDOMTokenList.h"
 #include "nsIContentInlines.h"
 #include "nsIDOMNode.h"
 #include "nsIDocument.h"
 #include "nsIFrame.h"
@@ -1042,16 +1043,23 @@ Gecko_CSSValue_SetFunction(nsCSSValueBor
 }
 
 nsCSSValueBorrowedMut
 Gecko_CSSValue_GetArrayItem(nsCSSValueBorrowedMut aCSSValue, int32_t aIndex)
 {
   return &aCSSValue->GetArrayValue()->Item(aIndex);
 }
 
+
+bool
+Gecko_PropertyId_IsPrefEnabled(nsCSSPropertyID id)
+{
+  return nsCSSProps::IsEnabled(id);
+}
+
 void
 Gecko_LoadStyleSheet(css::Loader* aLoader,
                      ServoStyleSheet* aParent,
                      RawServoImportRuleBorrowed aImportRule,
                      const uint8_t* aURLString,
                      uint32_t aURLStringLength,
                      const uint8_t* aMediaString,
                      uint32_t aMediaStringLength)
--- a/layout/style/ServoBindings.h
+++ b/layout/style/ServoBindings.h
@@ -288,16 +288,17 @@ void Gecko_CSSValue_SetAbsoluteLength(ns
 void Gecko_CSSValue_SetNumber(nsCSSValueBorrowedMut css_value, float number);
 void Gecko_CSSValue_SetKeyword(nsCSSValueBorrowedMut css_value, nsCSSKeyword keyword);
 void Gecko_CSSValue_SetPercentage(nsCSSValueBorrowedMut css_value, float percent);
 void Gecko_CSSValue_SetAngle(nsCSSValueBorrowedMut css_value, float radians);
 void Gecko_CSSValue_SetCalc(nsCSSValueBorrowedMut css_value, nsStyleCoord::CalcValue calc);
 void Gecko_CSSValue_SetFunction(nsCSSValueBorrowedMut css_value, int32_t len);
 nsCSSValueBorrowedMut Gecko_CSSValue_GetArrayItem(nsCSSValueBorrowedMut css_value, int32_t index);
 NS_DECL_THREADSAFE_FFI_REFCOUNTING(nsCSSValueSharedList, CSSValueSharedList);
+bool Gecko_PropertyId_IsPrefEnabled(nsCSSPropertyID id);
 
 // Style-struct management.
 #define STYLE_STRUCT(name, checkdata_cb)                                       \
   void Gecko_Construct_Default_nsStyle##name(                                  \
     nsStyle##name* ptr,                                                        \
     RawGeckoPresContextBorrowed pres_context);                                 \
   void Gecko_CopyConstruct_nsStyle##name(nsStyle##name* ptr,                   \
                                          const nsStyle##name* other);          \
new file mode 100644
--- /dev/null
+++ b/layout/style/ServoPropPrefList.h
@@ -0,0 +1,25 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* 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/. */
+
+#ifndef mozilla_ServoPropPrefList_h
+#define mozilla_ServoPropPrefList_h
+
+namespace mozilla {
+
+#define CSS_PROP(name_, id_, method_, flags_, pref_, parsevariant_, kwtable_, \
+                 stylestruct_, stylestructoffset_, animtype_)                 \
+    const bool SERVO_PREF_ENABLED_##id_ = !(sizeof(pref_) == 1);
+#define CSS_PROP_SHORTHAND(name_, id_, method_, flags_, pref_)  \
+    const bool SERVO_PREF_ENABLED_##id_ = !(sizeof(pref_) == 1);
+#define CSS_PROP_LIST_INCLUDE_LOGICAL
+#include "nsCSSPropList.h"
+#undef CSS_PROP_LIST_INCLUDE_LOGICAL
+#undef CSS_PROP
+#undef CSS_PROP_SHORTHAND
+
+}
+
+#endif // mozilla_ServoPropPrefList_h
--- a/layout/style/moz.build
+++ b/layout/style/moz.build
@@ -97,16 +97,17 @@ EXPORTS.mozilla += [
     'RuleProcessorCache.h',
     'ServoArcTypeList.h',
     'ServoBindingList.h',
     'ServoBindings.h',
     'ServoBindingTypes.h',
     'ServoCSSRuleList.h',
     'ServoDeclarationBlock.h',
     'ServoElementSnapshot.h',
+    'ServoPropPrefList.h',
     'ServoStyleRule.h',
     'ServoStyleSet.h',
     'ServoStyleSheet.h',
     'ServoTypes.h',
     'ServoUtils.h',
     'SheetType.h',
     'StyleAnimationValue.h',
     'StyleBackendType.h',
--- a/media/libvpx/moz.build
+++ b/media/libvpx/moz.build
@@ -11,37 +11,37 @@ include('sources.mozbuild')
 
 if CONFIG['VPX_USE_YASM']:
     USE_YASM = True
 
 # Linux, Mac and Win share file lists for x86* but not configurations.
 if CONFIG['CPU_ARCH'] == 'x86_64':
     EXPORTS.vpx += files['X64_EXPORTS']
     SOURCES += files['X64_SOURCES']
-    if CONFIG['OS_TARGET'] == 'Linux':
-        ASFLAGS += [ '-I%s/media/libvpx/config/linux/x64/' % TOPSRCDIR ]
-        CFLAGS += [ '-I%s/media/libvpx/config/linux/x64/' % TOPSRCDIR ]
-    elif CONFIG['OS_TARGET'] == 'WINNT':
+    if CONFIG['OS_TARGET'] == 'WINNT':
         ASFLAGS += [ '-I%s/media/libvpx/config/win/x64/' % TOPSRCDIR ]
         CFLAGS += [ '-I%s/media/libvpx/config/win/x64/' % TOPSRCDIR ]
     elif CONFIG['OS_TARGET'] == 'Darwin':
         ASFLAGS += [ '-I%s/media/libvpx/config/mac/x64/' % TOPSRCDIR ]
         CFLAGS += [ '-I%s/media/libvpx/config/mac/x64/' % TOPSRCDIR ]
+    else: # Android, Linux, BSDs, etc.
+        ASFLAGS += [ '-I%s/media/libvpx/config/linux/x64/' % TOPSRCDIR ]
+        CFLAGS += [ '-I%s/media/libvpx/config/linux/x64/' % TOPSRCDIR ]
 elif CONFIG['CPU_ARCH'] == 'x86':
     EXPORTS.vpx += files['IA32_EXPORTS']
     SOURCES += files['IA32_SOURCES']
-    if CONFIG['OS_TARGET'] == 'Linux' or CONFIG['OS_TARGET'] == 'Android':
-        ASFLAGS += [ '-I%s/media/libvpx/config/linux/ia32/' % TOPSRCDIR ]
-        CFLAGS += [ '-I%s/media/libvpx/config/linux/ia32/' % TOPSRCDIR ]
-    elif CONFIG['OS_TARGET'] == 'WINNT':
+    if CONFIG['OS_TARGET'] == 'WINNT':
         ASFLAGS += [ '-I%s/media/libvpx/config/win/ia32/' % TOPSRCDIR ]
         CFLAGS += [ '-I%s/media/libvpx/config/win/ia32/' % TOPSRCDIR ]
     elif CONFIG['OS_TARGET'] == 'Darwin':
         ASFLAGS += [ '-I%s/media/libvpx/config/mac/ia32/' % TOPSRCDIR ]
         CFLAGS += [ '-I%s/media/libvpx/config/mac/ia32/' % TOPSRCDIR ]
+    else: # Android, Linux, BSDs, etc.
+        ASFLAGS += [ '-I%s/media/libvpx/config/linux/ia32/' % TOPSRCDIR ]
+        CFLAGS += [ '-I%s/media/libvpx/config/linux/ia32/' % TOPSRCDIR ]
 elif CONFIG['CPU_ARCH'] == 'arm':
     EXPORTS.vpx += files['ARM_EXPORTS']
     ASFLAGS += [ '-I%s/media/libvpx/config/linux/arm/' % TOPSRCDIR ]
     CFLAGS += [ '-I%s/media/libvpx/config/linux/arm/' % TOPSRCDIR ]
 
     arm_asm_files = files['ARM_SOURCES']
 
     if CONFIG['VPX_AS_CONVERSION']:
--- a/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
@@ -80,16 +80,17 @@ import android.provider.MediaStore.Image
 import android.support.annotation.NonNull;
 import android.support.annotation.WorkerThread;
 import android.support.design.widget.Snackbar;
 import android.text.TextUtils;
 import android.util.AttributeSet;
 import android.util.Base64;
 import android.util.Log;
 import android.util.SparseBooleanArray;
+import android.util.SparseIntArray;
 import android.view.Gravity;
 import android.view.KeyEvent;
 import android.view.Menu;
 import android.view.MenuInflater;
 import android.view.MenuItem;
 import android.view.MotionEvent;
 import android.view.OrientationEventListener;
 import android.view.SurfaceView;
@@ -214,26 +215,34 @@ public abstract class GeckoApp
         private JSONArray tabs;
         private JSONObject windowObject;
         private boolean isExternalURL;
 
         private boolean selectNextTab;
         private boolean tabsWereSkipped;
         private boolean tabsWereProcessed;
 
+        private SparseIntArray tabIdMap;
+
         public LastSessionParser(JSONArray tabs, JSONObject windowObject, boolean isExternalURL) {
             this.tabs = tabs;
             this.windowObject = windowObject;
             this.isExternalURL = isExternalURL;
+
+            tabIdMap = new SparseIntArray();
         }
 
         public boolean allTabsSkipped() {
             return tabsWereSkipped && !tabsWereProcessed;
         }
 
+        public int getNewTabId(int oldTabId) {
+            return tabIdMap.get(oldTabId, -1);
+        }
+
         @Override
         public void onTabRead(final SessionTab sessionTab) {
             if (sessionTab.isAboutHomeWithoutHistory()) {
                 // This is a tab pointing to about:home with no history. We won't restore
                 // this tab. If we end up restoring no tabs then the browser will decide
                 // whether it needs to open about:home or a different 'homepage'. If we'd
                 // always restore about:home only tabs then we'd never open the homepage.
                 // See bug 1261008.
@@ -273,27 +282,58 @@ public abstract class GeckoApp
             ThreadUtils.postToUiThread(new Runnable() {
                 @Override
                 public void run() {
                     tab.updateTitle(sessionTab.getTitle());
                 }
             });
 
             try {
-                tabObject.put("tabId", tab.getId());
+                int oldTabId = tabObject.optInt("tabId", -1);
+                int newTabId = tab.getId();
+                tabObject.put("tabId", newTabId);
+                if  (oldTabId >= 0) {
+                    tabIdMap.put(oldTabId, newTabId);
+                }
             } catch (JSONException e) {
                 Log.e(LOGTAG, "JSON error", e);
             }
             tabs.put(tabObject);
         }
 
         @Override
         public void onClosedTabsRead(final JSONArray closedTabData) throws JSONException {
             windowObject.put("closedTabs", closedTabData);
         }
+
+        /**
+         * Updates stored parent tab IDs in the session store data to match the new tab IDs
+         * that have been allocated during startup session restore.
+         *
+         * @param tabData A JSONArray containg stored session store tabs.
+         */
+        public void updateParentId(final JSONArray tabData) {
+            if (tabData == null) {
+                return;
+            }
+
+            for (int i = 0; i < tabData.length(); i++) {
+                try {
+                    JSONObject tabObject = tabData.getJSONObject(i);
+
+                    int parentId = tabObject.getInt("parentId");
+                    int newParentId = getNewTabId(parentId);
+
+                    tabObject.put("parentId", newParentId);
+                } catch (JSONException ex) {
+                    // Tabs are not guaranteed to have a parentId,
+                    // so just skip the tab and try the next one.
+                }
+            }
+        }
     };
 
     protected boolean mInitialized;
     protected boolean mWindowFocusInitialized;
     private Telemetry.Timer mJavaUiStartupTimer;
     private Telemetry.Timer mGeckoReadyStartupTimer;
 
     private String mPrivateBrowsingSession;
@@ -1722,17 +1762,24 @@ public abstract class GeckoApp
 
             if (mPrivateBrowsingSession == null) {
                 sessionDataValid = parser.parse(sessionString);
             } else {
                 sessionDataValid = parser.parse(sessionString, mPrivateBrowsingSession);
             }
 
             if (tabs.length() > 0) {
+                // Update all parent tab IDs ...
+                parser.updateParentId(tabs);
                 windowObject.put("tabs", tabs);
+                // ... and for recently closed tabs as well (if we've got any).
+                JSONArray closedTabs = windowObject.optJSONArray("closedTabs");
+                parser.updateParentId(closedTabs);
+                windowObject.putOpt("closedTabs", closedTabs);
+
                 sessionString = new JSONObject().put("windows", new JSONArray().put(windowObject)).toString();
             } else {
                 if (parser.allTabsSkipped() || sessionDataValid) {
                     // If we intentionally skipped all tabs we've read from the session file, we
                     // set mShouldRestore back to false at this point already, so the calling code
                     // can infer that the exception wasn't due to a damaged session store file.
                     // The same applies if the session file was syntactically valid and
                     // simply didn't contain any tabs.
@@ -2310,17 +2357,17 @@ public abstract class GeckoApp
         }
 
         super.onDestroy();
 
         Tabs.unregisterOnTabsChangedListener(this);
     }
 
     public void showSDKVersionError() {
-        final String message = getString(R.string.unsupported_sdk_version, Build.CPU_ABI, Build.VERSION.SDK_INT);
+        final String message = getString(R.string.unsupported_sdk_version, Build.CPU_ABI, Integer.toString(Build.VERSION.SDK_INT));
         Toast.makeText(this, message, Toast.LENGTH_LONG).show();
     }
 
     // Get a temporary directory, may return null
     public static File getTempDirectory(@NonNull Context context) {
         return context.getApplicationContext().getExternalFilesDir("temp");
     }
 
--- a/mobile/android/base/java/org/mozilla/gecko/Tab.java
+++ b/mobile/android/base/java/org/mozilla/gecko/Tab.java
@@ -59,17 +59,17 @@ public class Tab {
     private IconRequestBuilder mIconRequestBuilder;
     private Future<IconResponse> mRunningIconRequest;
 
     private boolean mHasFeeds;
     private boolean mHasOpenSearch;
     private final SiteIdentity mSiteIdentity;
     private SiteLogins mSiteLogins;
     private BitmapDrawable mThumbnail;
-    private final int mParentId;
+    private volatile int mParentId;
     // Indicates the url was loaded from a source external to the app. This will be cleared
     // when the user explicitly loads a new url (e.g. clicking a link is not explicit).
     private final boolean mExternal;
     private boolean mBookmark;
     private int mFaviconLoadId;
     private String mContentType;
     private boolean mHasTouchListeners;
     private final ArrayList<View> mPluginViews;
@@ -163,16 +163,27 @@ public class Tab {
     public synchronized long getLastUsed() {
         return mLastUsed;
     }
 
     public int getParentId() {
         return mParentId;
     }
 
+    /**
+     * Updates the stored parent tab ID to a new value.
+     * Note: Calling this directly from Java currently won't update the parent ID value
+     * held by Gecko and the session store.
+     *
+     * @param parentId The ID of the tab to be set as new parent, or -1 for no parent.
+     */
+    public void setParentId(int parentId) {
+        mParentId = parentId;
+    }
+
     // may be null if user-entered query hasn't yet been resolved to a URI
     public synchronized String getURL() {
         return mUrl;
     }
 
     // mUserRequested should never be null, but it may be an empty string
     public synchronized String getUserRequested() {
         return mUserRequested;
--- a/mobile/android/base/java/org/mozilla/gecko/Tabs.java
+++ b/mobile/android/base/java/org/mozilla/gecko/Tabs.java
@@ -124,17 +124,19 @@ public class Tabs implements BundleEvent
             "Link:Favicon",
             "Link:Touchicon",
             "Link:Feed",
             "Link:OpenSearch",
             "DesktopMode:Changed",
             "Tab:StreamStart",
             "Tab:StreamStop",
             "Tab:AudioPlayingChange",
-            "Tab:MediaPlaybackChange");
+            "Tab:MediaPlaybackChange",
+            "Tab:SetParentId",
+            null);
 
         mPrivateClearColor = Color.RED;
 
     }
 
     public synchronized void attachToContext(Context context, LayerView layerView) {
         final Context appContext = context.getApplicationContext();
         if (mAppContext == appContext) {
@@ -600,16 +602,19 @@ public class Tabs implements BundleEvent
             } else if (event.equals("Tab:MediaPlaybackChange")) {
                 final String status = message.getString("status");
                 if (status.equals("resume")) {
                     notifyListeners(tab, TabEvents.MEDIA_PLAYING_RESUME);
                 } else {
                     tab.setIsMediaPlaying(status.equals("start"));
                     notifyListeners(tab, TabEvents.MEDIA_PLAYING_CHANGE);
                 }
+            } else if (event.equals("Tab:SetParentId")) {
+                int newParentId = message.getInt("parentID");
+                tab.setParentId(newParentId);
             }
 
         } catch (Exception e) {
             Log.w(LOGTAG, "handleMessage threw for " + event, e);
         }
     }
 
     public void refreshThumbnails() {
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -3478,22 +3478,24 @@ Tab.prototype = {
             { name: "getNextTabId", sig: "()I" }
           ],
         });
         this.id = jTabs.getNextTabId();
         JNI.UnloadClasses(jenv);
       }
 
       this.desktopMode = ("desktopMode" in aParams) ? aParams.desktopMode : false;
+      this.parentId = ("parentId" in aParams && typeof aParams.parentId == "number")
+                      ? aParams.parentId : -1;
 
       let message = {
         type: "Tab:Added",
         tabID: this.id,
         uri: truncate(uri, MAX_URI_LENGTH),
-        parentId: ("parentId" in aParams) ? aParams.parentId : -1,
+        parentId: this.parentId,
         tabIndex: ("tabIndex" in aParams) ? aParams.tabIndex : -1,
         external: ("external" in aParams) ? aParams.external : false,
         selected: ("selected" in aParams || aParams.cancelEditMode === true)
                   ? aParams.selected !== false || aParams.cancelEditMode === true : true,
         cancelEditMode: aParams.cancelEditMode === true,
         title: truncate(title, MAX_TITLE_LENGTH),
         delayLoad: aParams.delayLoad || false,
         desktopMode: this.desktopMode,
@@ -3533,26 +3535,28 @@ Tab.prototype = {
     this.browser.addEventListener("PluginBindingAttached", this, true, true);
     this.browser.addEventListener("VideoBindingAttached", this, true, true);
     this.browser.addEventListener("VideoBindingCast", this, true, true);
 
     Services.obs.addObserver(this, "before-first-paint", false);
     Services.obs.addObserver(this, "media-playback", false);
     Services.obs.addObserver(this, "media-playback-resumed", false);
 
-    // Always intialise new tabs with basic session store data to avoid
+    // Always initialise new tabs with basic session store data to avoid
     // problems with functions that always expect it to be present
     this.browser.__SS_data = {
       entries: [{
         url: aURL,
         title: truncate(title, MAX_TITLE_LENGTH)
       }],
       index: 1,
       desktopMode: this.desktopMode,
-      isPrivate: isPrivate
+      isPrivate: isPrivate,
+      tabId: this.id,
+      parentId: this.parentId
     };
 
     if (aParams.delayLoad) {
       // If this is a zombie tab, mark the browser for delay loading, which will
       // restore the tab when selected using the session data added above
       this.browser.__SS_restore = true;
     } else {
       let flags = "flags" in aParams ? aParams.flags : Ci.nsIWebNavigation.LOAD_FLAGS_NONE;
@@ -3826,16 +3830,26 @@ Tab.prototype = {
           type: "Link:OpenSearch",
           tabID: this.id,
           visible: true
         });
       });
     }
   },
 
+  setParentId: function(aParentId) {
+    let newParentId = (typeof aParentId == "number") ? aParentId : -1;
+    this.parentId = newParentId;
+    Messaging.sendRequest({
+      type: "Tab:SetParentId",
+      tabID: this.id,
+      parentID: newParentId
+    });
+  },
+
   handleEvent: function(aEvent) {
     switch (aEvent.type) {
       case "DOMContentLoaded": {
         let target = aEvent.originalTarget;
 
         // ignore on frames and other documents
         if (target != this.browser.contentDocument)
           return;
--- a/mobile/android/components/SessionStore.js
+++ b/mobile/android/components/SessionStore.js
@@ -1018,21 +1018,24 @@ SessionStore.prototype = {
     // If this browser is being restored, skip any session save activity
     if (aBrowser.__SS_restore) {
       return;
     }
 
     aHistory = aHistory || { entries: [{ url: aBrowser.currentURI.spec, title: aBrowser.contentTitle }], index: 1 };
 
     let tabData = {};
+    let tab = aWindow.BrowserApp.getTabForBrowser(aBrowser);
     tabData.entries = aHistory.entries;
     tabData.index = aHistory.index;
     tabData.attributes = { image: aBrowser.mIconURL };
-    tabData.desktopMode = aWindow.BrowserApp.getTabForBrowser(aBrowser).desktopMode;
+    tabData.desktopMode = tab.desktopMode;
     tabData.isPrivate = aBrowser.docShell.QueryInterface(Ci.nsILoadContext).usePrivateBrowsing;
+    tabData.tabId = tab.id;
+    tabData.parentId = tab.parentId;
 
     aBrowser.__SS_data = tabData;
   },
 
   _collectWindowData: function ss__collectWindowData(aWindow) {
     // Ignore windows not tracked by SessionStore
     if (!aWindow.__SSID || !this._windows[aWindow.__SSID]) {
       return;
@@ -1476,17 +1479,18 @@ SessionStore.prototype = {
     let window = Services.wm.getMostRecentWindow("navigator:browser");
     for (let i = 0; i < aData.tabs.length; i++) {
       let tabData = JSON.parse(aData.tabs[i]);
       let isSelectedTab = (i == aData.tabs.length - 1);
       let params = {
         selected: isSelectedTab,
         isPrivate: tabData.isPrivate,
         desktopMode: tabData.desktopMode,
-        cancelEditMode: isSelectedTab
+        cancelEditMode: isSelectedTab,
+        parentId: tabData.parentId
       };
 
       let tab = window.BrowserApp.addTab(tabData.entries[tabData.index - 1].url, params);
       tab.browser.__SS_data = tabData;
       tab.browser.__SS_extdata = tabData.extData;
       this._restoreTab(tabData, tab.browser);
     }
   },
@@ -1628,33 +1632,38 @@ SessionStore.prototype = {
     log("restoreWindow() window.BrowserApp.selectedTab is " + window.BrowserApp.selectedTab.id);
 
     for (let i = 0; i < tabs.length; i++) {
       let tabData = tabs[i];
       let entry = tabData.entries[tabData.index - 1];
 
       // Use stubbed tab if we've already created it; otherwise, make a new tab
       let tab;
+      let parentId = tabData.parentId;
       if (tabData.tabId == null) {
         let params = {
           selected: (selected == i+1),
           delayLoad: true,
           title: entry.title,
           desktopMode: (tabData.desktopMode == true),
-          isPrivate: (tabData.isPrivate == true)
+          isPrivate: (tabData.isPrivate == true),
+          parentId: parentId
         };
         tab = window.BrowserApp.addTab(entry.url, params);
       } else {
         tab = window.BrowserApp.getTabForId(tabData.tabId);
-        delete tabData.tabId;
 
         // Don't restore tab if user has closed it
         if (tab == null) {
+          delete tabData.tabId;
           continue;
         }
+        if (parentId > -1) {
+          tab.setParentId(parentId);
+        }
       }
 
       tab.browser.__SS_data = tabData;
       tab.browser.__SS_extdata = tabData.extData;
 
       if (window.BrowserApp.selectedTab == tab) {
         this._restoreTab(tabData, tab.browser);
 
@@ -1715,17 +1724,18 @@ SessionStore.prototype = {
       }
     });
 
     // create a new tab and bring to front
     let params = {
       selected: true,
       isPrivate: aCloseTabData.isPrivate,
       desktopMode: aCloseTabData.desktopMode,
-      tabIndex: this._lastClosedTabIndex
+      tabIndex: this._lastClosedTabIndex,
+      parentId: aCloseTabData.parentId
     };
     let tab = aWindow.BrowserApp.addTab(aCloseTabData.entries[aCloseTabData.index - 1].url, params);
     tab.browser.__SS_data = aCloseTabData;
     tab.browser.__SS_extdata = aCloseTabData.extData;
     this._restoreTab(aCloseTabData, tab.browser);
 
     this._lastClosedTabIndex = -1;
 
--- a/mobile/android/confvars.sh
+++ b/mobile/android/confvars.sh
@@ -32,18 +32,16 @@ MOZ_RAW=1
 
 MOZ_RUST_MP4PARSE=1
 
 # use custom widget for html:select
 MOZ_USE_NATIVE_POPUP_WINDOWS=1
 
 MOZ_APP_ID={aa3c5121-dab2-40e2-81ca-7ea25febc110}
 
-MOZ_APP_STATIC_INI=1
-
 # Enable second screen using native Android libraries.
 MOZ_NATIVE_DEVICES=1
 
 # Enable install tracking SDK if we have Google Play support; MOZ_NATIVE_DEVICES
 # is a proxy flag for that support.
 if test "$RELEASE_OR_BETA"; then
 if test "$MOZ_NATIVE_DEVICES"; then
   MOZ_INSTALL_TRACKING=1
--- a/mobile/android/tests/browser/chrome/chrome.ini
+++ b/mobile/android/tests/browser/chrome/chrome.ini
@@ -36,14 +36,15 @@ skip-if = debug
 [test_offline_page.html]
 skip-if = true # Bug 1241478
 [test_reader_view.html]
 [test_resource_substitutions.html]
 [test_restricted_profiles.html]
 [test_select_disabled.html]
 [test_selectoraddtab.html]
 [test_session_form_data.html]
+[test_session_parentid.html]
 [test_session_scroll_position.html]
 [test_session_zombification.html]
 [test_shared_preferences.html]
 [test_simple_discovery.html]
 [test_video_discovery.html]
 [test_web_channel.html]
new file mode 100644
--- /dev/null
+++ b/mobile/android/tests/browser/chrome/test_session_parentid.html
@@ -0,0 +1,126 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1301160
+-->
+<head>
+  <meta charset="utf-8">
+  <title>Test for Bug 1044556</title>
+  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script>
+  <link rel="stylesheet" type="text/css" href="chrome://global/skin"/>
+  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
+  <script type="application/javascript" src="head.js"></script>
+  <script type="application/javascript">
+
+  /** Test for Bug 1301160 **/
+
+  "use strict";
+
+  const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
+
+  Cu.import("resource://gre/modules/XPCOMUtils.jsm");
+  Cu.import("resource://gre/modules/Services.jsm");
+  Cu.import("resource://gre/modules/Messaging.jsm");
+  Cu.import("resource://gre/modules/Task.jsm");
+
+  // The chrome window and related services
+  let chromeWin = Services.wm.getMostRecentWindow("navigator:browser");
+  let BrowserApp = chromeWin.BrowserApp;
+  let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
+
+  // Track the tabs where the tests are happening
+  let tabParent;
+  let tabChild1;
+  let tabChild2;
+
+  function cleanupTabs() {
+    if (tabParent) {
+      BrowserApp.closeTab(tabParent);
+      tabParent = null;
+    }
+
+    if (tabChild1) {
+      BrowserApp.closeTab(tabChild1);
+      tabChild1 = null;
+    }
+
+    if (tabChild2) {
+      BrowserApp.closeTab(tabChild2);
+      tabChild2 = null;
+    }
+  }
+
+  const url = "data:text/html;charset=utf-8,It%20was%20a%20dark%20and%20stormy%20night.";
+
+  add_task(function* test_sessionStoreParentId() {
+    SimpleTest.registerCleanupFunction(function() {
+      cleanupTabs();
+    });
+
+    // First, check that passing a parent tab ID works as expected
+    tabParent = BrowserApp.addTab(url , { selected: true });
+    yield promiseBrowserEvent(tabParent.browser, "DOMContentLoaded");
+
+    // Open tabs without passing a parent tab ID
+    tabChild1 = BrowserApp.addTab(url , { selected: false });
+    tabChild2 = BrowserApp.addTab(url , { selected: true });
+    yield promiseTabEvent(BrowserApp.deck, "TabSelect");
+    is(BrowserApp.selectedTab, tabChild2, "2nd child tab is selected");
+
+    // After closing that tab, its neighbour should be selected
+    BrowserApp.closeTab(tabChild2);
+    tabChild2 = null;
+    yield promiseTabEvent(BrowserApp.deck, "TabSelect");
+    is(BrowserApp.selectedTab, tabChild1, "1st child tab is selected");
+
+    // Add a new tab and pass a parent tab ID this time
+    tabChild2 = BrowserApp.addTab(url , { selected: true, parentId: tabParent.id });
+    yield promiseTabEvent(BrowserApp.deck, "TabSelect");
+    is(BrowserApp.selectedTab, tabChild2, "2nd child tab is selected");
+
+    // After closing that tab, its parent should be selected
+    BrowserApp.closeTab(tabChild2);
+    tabChild2 = null;
+    yield promiseTabEvent(BrowserApp.deck, "TabSelect");
+    is(BrowserApp.selectedTab, tabParent, "parent tab is selected");
+
+    // Reset selection and switch to the other child tab
+    BrowserApp.selectTab(tabChild1);
+    yield promiseTabEvent(BrowserApp.deck, "TabSelect");
+    is(BrowserApp.selectedTab, tabChild1, "1st child tab is selected");
+
+    // Now check that this works even if the child tab is closed and subsequently restored
+    tabChild2 = BrowserApp.addTab(url , { selected: false, parentId: tabParent.id });
+    yield promiseTabEvent(tabChild2.browser, "SSTabDataUpdated");
+    BrowserApp.closeTab(tabChild2);
+    yield promiseTabEvent(tabChild2.browser, "SSTabCloseProcessed");
+
+    // Restore the tab
+    let closedTabData = ss.getClosedTabs(chromeWin)[0];
+    let browser = ss.undoCloseTab(chromeWin, closedTabData);
+    yield promiseTabEvent(BrowserApp.deck, "TabSelect");
+    tabChild2 = BrowserApp.getTabForBrowser(browser);
+    is(BrowserApp.selectedTab, tabChild2, "restored 2nd child tab is selected");
+
+    // After closing that tab, its parent should be selected
+    BrowserApp.closeTab(tabChild2);
+    tabChild2 = null;
+    yield promiseTabEvent(BrowserApp.deck, "TabSelect");
+    is(BrowserApp.selectedTab, tabParent, "parent tab is selected after restoring");
+
+    cleanupTabs();
+  });
+
+  </script>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1301160">Mozilla Bug 1301160</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+</pre>
+</body>
+</html>
--- a/netwerk/base/nsServerSocket.cpp
+++ b/netwerk/base/nsServerSocket.cpp
@@ -15,18 +15,16 @@
 #include "mozilla/Attributes.h"
 #include "mozilla/EndianUtils.h"
 #include "mozilla/net/DNS.h"
 #include "nsServiceManagerUtils.h"
 #include "nsIFile.h"
 
 namespace mozilla { namespace net {
 
-static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID);
-
 //-----------------------------------------------------------------------------
 
 typedef void (nsServerSocket:: *nsServerSocketFunc)(void);
 
 static nsresult
 PostEvent(nsServerSocket *s, nsServerSocketFunc func)
 {
   nsCOMPtr<nsIRunnable> ev = NewRunnableMethod(s, func);
@@ -47,17 +45,17 @@ nsServerSocket::nsServerSocket()
   , mKeepWhenOffline(false)
 {
   // we want to be able to access the STS directly, and it may not have been
   // constructed yet.  the STS constructor sets gSocketTransportService.
   if (!gSocketTransportService)
   {
     // This call can fail if we're offline, for example.
     nsCOMPtr<nsISocketTransportService> sts =
-        do_GetService(kSocketTransportServiceCID);
+        do_GetService(NS_SOCKETTRANSPORTSERVICE_CONTRACTID);
   }
   // make sure the STS sticks around as long as we do
   NS_IF_ADDREF(gSocketTransportService);
 }
 
 nsServerSocket::~nsServerSocket()
 {
   Close(); // just in case :)
--- a/netwerk/base/nsUDPSocket.cpp
+++ b/netwerk/base/nsUDPSocket.cpp
@@ -34,17 +34,16 @@
 #ifdef MOZ_WIDGET_GONK
 #include "NetStatistics.h"
 #endif
 
 namespace mozilla {
 namespace net {
 
 static const uint32_t UDP_PACKET_CHUNK_SIZE = 1400;
-static NS_DEFINE_CID(kSocketTransportServiceCID2, NS_SOCKETTRANSPORTSERVICE_CID);
 
 //-----------------------------------------------------------------------------
 
 typedef void (nsUDPSocket:: *nsUDPSocketFunc)(void);
 
 static nsresult
 PostEvent(nsUDPSocket *s, nsUDPSocketFunc func)
 {
@@ -270,17 +269,17 @@ nsUDPSocket::nsUDPSocket()
 {
   mAddr.raw.family = PR_AF_UNSPEC;
   // we want to be able to access the STS directly, and it may not have been
   // constructed yet.  the STS constructor sets gSocketTransportService.
   if (!gSocketTransportService)
   {
     // This call can fail if we're offline, for example.
     nsCOMPtr<nsISocketTransportService> sts =
-        do_GetService(kSocketTransportServiceCID2);
+        do_GetService(NS_SOCKETTRANSPORTSERVICE_CONTRACTID);
   }
 
   mSts = gSocketTransportService;
 }
 
 nsUDPSocket::~nsUDPSocket()
 {
   CloseSocket();
deleted file mode 100644
--- a/netwerk/test/NetwerkTestLogging.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* 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/. */
-
-#ifndef NetwerkTestLogging_h
-#define NetwerkTestLogging_h
-
-#include "mozilla/Logging.h"
-
-// The netwerk standalone cpp unit tests will just use PR_LogPrint as they don't
-// have access to mozilla::detail::log_print. To support that MOZ_LOG is
-// redefined.
-#undef MOZ_LOG
-#define MOZ_LOG(_module,_level,_args) \
-  PR_BEGIN_MACRO \
-    if (MOZ_LOG_TEST(_module,_level)) { \
-      PR_LogPrint _args; \
-    } \
-  PR_END_MACRO
-
-#endif
deleted file mode 100644
--- a/netwerk/test/TestCacheBlockFiles.cpp
+++ /dev/null
@@ -1,873 +0,0 @@
-/*
-    TestCacheBlockFiles.cpp
-*/
-
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <utime.h>
-
-#include <Files.h>
-#include <Strings.h>
-#include <Errors.h>
-#include <Resources.h>
-#include <Aliases.h>
-
-#include "nsCOMPtr.h"
-#include "nsCRT.h"
-#include "nsDirectoryServiceDefs.h"
-#include "nsError.h"
-#include "nsIComponentManager.h"
-#include "nsIComponentRegistrar.h"
-#include "nsIFile.h"
-#include "nsIFileStreams.h"
-#include "nsMemory.h"
-#include "nsIComponentRegistrar.h"
-#include "nsANSIFileStreams.h"
-#include "nsDiskCacheBlockFile.h"
-
-#include "prclist.h"
-
-/**
- *  StressTest()
- */
-
-typedef struct Allocation {
-    int32_t     start;
-    int32_t     count;
-} Allocation;
-
-nsresult
-StressTest(nsIFile *  localFile, int32_t  testNumber, bool readWrite)
-{
-    nsresult  rv = NS_OK;
-
-#define ITERATIONS      1024
-#define MAX_ALLOCATIONS 256
-    Allocation  block[MAX_ALLOCATIONS];
-    int32_t     currentAllocations = 0;
-    int32_t     i;
-    uint32_t    a;
-
-    char * writeBuf[4];
-    char   readBuf[256 * 4];
-
-
-    if (readWrite) {
-        for (i = 0; i < 4; i++) {
-            writeBuf[i] = new char[256 * i];
-            if (!writeBuf[i]) {
-                printf("Test %d: failed - out of memory\n", testNumber);
-                rv = NS_ERROR_OUT_OF_MEMORY;
-                goto exit;
-            }
-
-            memset(writeBuf[i], i, 256 * i);
-        }
-    }
-
-    nsDiskCacheBlockFile * blockFile = new nsDiskCacheBlockFile;
-    if (!blockFile) {
-        printf("Test %d failed (unable to allocate nsDiskCacheBlockFile", testNumber);
-        rv = NS_ERROR_OUT_OF_MEMORY;
-        goto exit;
-    }
-
-    rv = blockFile->Open(localFile, 256);
-    if (NS_FAILED(rv)) {
-        printf("Test %d: failed (Open returned: 0x%.8x)\n", testNumber, rv);
-        goto exit;
-    }
-
-    i = ITERATIONS;
-    while (i > 0) {
-        if ((currentAllocations >= MAX_ALLOCATIONS) ||
-            ((currentAllocations > 0) && (rand() % 4 == 0))) {
-            // deallocate if we've reached the limit, or 25% of the time we have allocations
-            a = rand() % currentAllocations;
-
-            if (readWrite) {
-                // read verify deallocation
-                rv = blockFile->ReadBlocks(readBuf, block[a].start, block[a].count);
-                if (NS_FAILED(rv)) {
-                    printf("Test %d: failed (ReadBlocks() returned 0x%.8x)\n", testNumber, rv);
-                    goto exit;
-                }
-
-                // Verify buffer
-                for (i = 0; i < 256 * block[a].count; i++) {
-                    if (readBuf[i] != block[a].count) {
-                        printf("Test %d: failed (verifying buffer 1)\n", testNumber);
-                        rv = NS_ERROR_FAILURE;
-                        goto exit;
-                    }
-                }
-            }
-
-            rv = blockFile->DeallocateBlocks(block[a].start, block[a].count);
-            if (NS_FAILED(rv)) {
-                printf("Test %d: failed (DeallocateBlocks() returned %d)\n", testNumber, rv);
-                goto exit;
-            }
-
-            --currentAllocations;
-            if (currentAllocations > 0)
-                block[a] = block[currentAllocations];
-
-        } else {
-            // allocate blocks
-            --i;
-            a = currentAllocations++;
-            block[a].count = rand() % 4 + 1; // allocate 1 to 4 blocks
-            block[a].start = blockFile->AllocateBlocks(block[a].count);
-            if (block[a].start < 0) {
-                printf("Test %d: failed (AllocateBlocks() failed.)\n", testNumber);
-                goto exit;
-            }
-
-            if (readWrite) {
-                // write buffer
-                rv = blockFile->WriteBlocks(writeBuf[block[a].count], block[a].start, block[a].count);
-                if (NS_FAILED(rv)) {
-                    printf("Test %d: failed (WriteBlocks() returned 0x%.8x)\n",testNumber, rv);
-                    goto exit;
-                }
-            }
-        }
-    }
-
-    // now deallocate remaining allocations
-    i = currentAllocations;
-    while (i--) {
-
-        if (readWrite) {
-            // read verify deallocation
-            rv = blockFile->ReadBlocks(readBuf, block[a].start, block[a].count);
-            if (NS_FAILED(rv)) {
-                printf("Test %d: failed (ReadBlocks(1) returned 0x%.8x)\n", testNumber, rv);
-                goto exit;
-            }
-
-            // Verify buffer
-            for (i = 0; i < 256 * block[a].count; i++) {
-                if (readBuf[i] != block[a].count) {
-                    printf("Test %d: failed (verifying buffer 1)\n", testNumber);
-                    rv = NS_ERROR_FAILURE;
-                    goto exit;
-                }
-            }
-        }
-
-        rv = blockFile->DeallocateBlocks(block[i].start, block[i].count);
-        if (NS_FAILED(rv)) {
-            printf("Test %d: failed (DeallocateBlocks() returned %d)\n", testNumber, rv);
-            goto exit;
-        }
-    }
-
-
-
-exit:
-    nsresult rv2 = blockFile->Close();
-    if (NS_FAILED(rv2)) {
-        printf("Test %d: failed (Close returned: 0x%.8x)\n", testNumber, rv2);
-    }
-
-    return rv ? rv : rv2;
-}    
-
-/**
- *  main()
- */
-
-int
-main(void)
-{
-//	OSErr	err;
-    printf("hello world\n");
-
-    unsigned long now = time(0);
-    srand(now);
-
-    nsCOMPtr<nsIFile>       file;
-    nsCOMPtr<nsIFile>  localFile;
-    nsresult  rv = NS_OK;
-    {
-        // Start up XPCOM
-        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);
-
-        // Get default directory
-        rv = NS_GetSpecialDirectory(NS_XPCOM_CURRENT_PROCESS_DIR,
-                                    getter_AddRefs(file));
-        if (NS_FAILED(rv)) {
-            printf("NS_GetSpecialDirectory() failed : 0x%.8x\n", rv);
-            goto exit;
-        }
-        char * currentDirPath;
-        rv = file->GetPath(&currentDirPath);
-        if (NS_FAILED(rv)) {
-            printf("currentProcessDir->GetPath() failed : 0x%.8x\n", rv);
-            goto exit;
-        }
-
-        printf("Current Process Directory: %s\n", currentDirPath);
-
-
-        // Generate name for cache block file
-	rv = file->Append("_CACHE_001_");
-        if (NS_FAILED(rv)) goto exit;
-
-        // Delete existing file
-        rv = file->Delete(false);
-        if (NS_FAILED(rv) && rv != NS_ERROR_FILE_NOT_FOUND) goto exit;
-
-        // Need nsIFile to open
-	localFile = do_QueryInterface(file, &rv);
-        if (NS_FAILED(rv)) {
-            printf("do_QueryInterface(file) failed : 0x%.8x\n", rv);
-            goto exit;
-        }
-
-        nsDiskCacheBlockFile * blockFile = new nsDiskCacheBlockFile;
-        if (!blockFile) {
-            rv = NS_ERROR_OUT_OF_MEMORY;
-            goto exit;
-        }
-
-        //----------------------------------------------------------------
-        //  local variables used in tests
-        //----------------------------------------------------------------
-        uint32_t bytesWritten = 0;
-        int32_t  startBlock;
-        int32_t  i = 0;
-
-
-        //----------------------------------------------------------------
-        //  Test 1: Open nonexistent file
-        //----------------------------------------------------------------
-        rv = blockFile->Open(localFile, 256);
-        if (NS_FAILED(rv)) {
-            printf("Test 1: failed (Open returned: 0x%.8x)\n", rv);
-            goto exit;
-        }
-
-        rv = blockFile->Close();
-        if (NS_FAILED(rv)) {
-            printf("Test 1: failed (Close returned: 0x%.8x)\n", rv);
-            goto exit;
-        }
-
-        printf("Test 1: passed\n");
-
-
-        //----------------------------------------------------------------
-        //  Test 2: Open existing file (with no allocation)
-        //----------------------------------------------------------------
-        rv = blockFile->Open(localFile, 256);
-        if (NS_FAILED(rv)) {
-            printf("Test 2: failed (Open returned: 0x%.8x)\n", rv);
-            goto exit;
-        }
-
-        rv = blockFile->Close();
-        if (NS_FAILED(rv)) {
-            printf("Test 2: failed (Close returned: 0x%.8x)\n", rv);
-            goto exit;
-        }
-
-        printf("Test 2: passed\n");
-
-
-        //----------------------------------------------------------------
-        //  Test 3: Open existing file (bad format) size < kBitMapBytes
-        //----------------------------------------------------------------
-
-        // Delete existing file
-        rv = localFile->Delete(false);
-        if (NS_FAILED(rv)) {
-            printf("Test 3 failed (Delete returned: 0x%.8x)\n", rv);
-            goto exit;
-        }
-
-        // write < kBitMapBytes to file
-        nsANSIFileStream * stream = new nsANSIFileStream;
-        if (!stream) {
-            printf("Test 3 failed (unable to allocate stream\n", rv);
-            goto exit;
-        }
-        NS_ADDREF(stream);
-        rv = stream->Open(localFile);
-        if (NS_FAILED(rv)) {
-            NS_RELEASE(stream);
-            printf("Test 3 failed (stream->Open returned: 0x%.8x)\n", rv);
-            goto exit;
-        }
-
-        bytesWritten = 0;
-        rv = stream->Write("Tell me something good.\n", 24, &bytesWritten);
-        if (NS_FAILED(rv)) {
-            NS_RELEASE(stream);
-            printf("Test 3 failed (stream->Write returned: 0x%.8x)\n", rv);
-            goto exit;
-        }
-
-        rv = stream->Close();
-        if (NS_FAILED(rv)) {
-            NS_RELEASE(stream);
-            printf("Test 3 failed (stream->Close returned: 0x%.8x)\n", rv);
-            goto exit;
-        }
-        NS_RELEASE(stream);
-
-        rv = blockFile->Open(localFile, 256);
-        if (NS_SUCCEEDED(rv)) {
-            printf("Test 3: failed (Open erroneously succeeded)\n", rv);
-
-            (void) blockFile->Close();
-            goto exit;
-        }
-
-        printf("Test 3: passed\n");
-
-
-        //----------------------------------------------------------------
-        //  Test 4: Open nonexistent file (again)
-        //----------------------------------------------------------------
-
-        // Delete existing file
-        rv = localFile->Delete(false);
-        if (NS_FAILED(rv)) {
-            printf("Test 4 failed (Delete returned: 0x%.8x)\n", rv);
-            goto exit;
-        }
-
-        rv = blockFile->Open(localFile, 256);
-        if (NS_FAILED(rv)) {
-            printf("Test 4: failed (Open returned: 0x%.8x)\n", rv);
-            goto exit;
-        }
-
-        printf("Test 4: passed\n");
-
-
-        //----------------------------------------------------------------
-        //  Test 5: AllocateBlocks: invalid block count (0, 5)
-        //----------------------------------------------------------------
-
-
-        startBlock = blockFile->AllocateBlocks(0);
-        if (startBlock > -1) {
-            printf("Test 5: failed (AllocateBlocks(0) erroneously succeeded)\n");
-            goto exit;
-        }
-
-        startBlock = blockFile->AllocateBlocks(5);
-        if (startBlock > -1) {
-            printf("Test 5: failed (AllocateBlocks(5) erroneously succeeded)\n");
-            goto exit;
-        }
-        printf("Test 5: passed\n");
-
-
-        //----------------------------------------------------------------
-        //  Test 6: AllocateBlocks: valid block count (1, 2, 3, 4)
-        //----------------------------------------------------------------
-        startBlock = blockFile->AllocateBlocks(1);
-        if (startBlock != 0) {
-            printf("Test 6: failed (AllocateBlocks(1) failed)\n");
-            goto exit;
-        }
-
-        startBlock = blockFile->AllocateBlocks(2);
-        if (startBlock != 1) {
-            printf("Test 6: failed (AllocateBlocks(2) failed)\n");
-            goto exit;
-        }
-
-        startBlock = blockFile->AllocateBlocks(3);
-        if (startBlock != 4) {
-            printf("Test 6: failed (AllocateBlocks(3) failed)\n");
-            goto exit;
-        }
-
-        startBlock = blockFile->AllocateBlocks(4);
-        if (startBlock != 8) {
-            printf("Test 6: failed (AllocateBlocks(4) failed)\n");
-            goto exit;
-        }
-
-        // blocks allocated should be 1220 3330 4444
-        printf("Test 6: passed\n");  // but bits could be mis-allocated
-
-
-
-        //----------------------------------------------------------------
-        //  Test 7: VerifyAllocation
-        //----------------------------------------------------------------
-        rv = blockFile->VerifyAllocation(0,1);
-        if (NS_FAILED(rv)) {
-            printf("Test 7: failed (VerifyAllocation(0,1) returned: 0x%.8x)\n", rv);
-            goto exit;
-        }
-
-        rv = blockFile->VerifyAllocation(1,2);
-        if (NS_FAILED(rv)) {
-            printf("Test 7: failed (VerifyAllocation(1,2) returned: 0x%.8x)\n", rv);
-            goto exit;
-        }
-
-        rv = blockFile->VerifyAllocation(4,3);
-        if (NS_FAILED(rv)) {
-            printf("Test 7: failed (VerifyAllocation(4,3) returned: 0x%.8x)\n", rv);
-            goto exit;
-        }
-
-        rv = blockFile->VerifyAllocation(8,4);
-        if (NS_FAILED(rv)) {
-            printf("Test 7: failed (VerifyAllocation(8,4) returned: 0x%.8x)\n", rv);
-            goto exit;
-        }
-        printf("Test 7: passed\n");
-
-
-        //----------------------------------------------------------------
-        //  Test 8: LastBlock
-        //----------------------------------------------------------------
-        int32_t  lastBlock = blockFile->LastBlock();
-        if (lastBlock != 11) {
-            printf("Test 8: failed (LastBlock() returned: %d)\n", lastBlock);
-            goto exit;
-        }
-        printf("Test 8: passed\n");
-
-
-        //----------------------------------------------------------------
-        //  Test 9: DeallocateBlocks: bad startBlock ( < 0)
-        //----------------------------------------------------------------
-        rv = blockFile->DeallocateBlocks(-1, 4);
-        if (NS_SUCCEEDED(rv)) {
-            printf("Test 9: failed (DeallocateBlocks(-1, 4) erroneously succeeded)\n");
-            goto exit;
-        }
-        printf("Test 9: passed\n");
-
-
-        //----------------------------------------------------------------
-        //  Test 10: DeallocateBlocks: bad numBlocks (0, 5)
-        //----------------------------------------------------------------
-        rv = blockFile->DeallocateBlocks(0, 0);
-        if (NS_SUCCEEDED(rv)) {
-            printf("Test 10: failed (DeallocateBlocks(0, 0) erroneously succeeded)\n");
-            goto exit;
-        }
-
-        rv = blockFile->DeallocateBlocks(0, 5);
-        if (NS_SUCCEEDED(rv)) {
-            printf("Test 10: failed (DeallocateBlocks(0, 5) erroneously succeeded)\n");
-            goto exit;
-        }
-
-        printf("Test 10: passed\n");
-
-
-        //----------------------------------------------------------------
-        //  Test 11: DeallocateBlocks: unallocated blocks
-        //----------------------------------------------------------------
-        rv = blockFile->DeallocateBlocks(12, 1);
-        if (NS_SUCCEEDED(rv)) {
-            printf("Test 11: failed (DeallocateBlocks(12, 1) erroneously succeeded)\n");
-            goto exit;
-        }
-
-        printf("Test 11: passed\n");
-
-
-        //----------------------------------------------------------------
-        //  Test 12: DeallocateBlocks: 1, 2, 3, 4 (allocated in Test 6)
-        //----------------------------------------------------------------
-        rv = blockFile->DeallocateBlocks(0, 1);
-        if (NS_FAILED(rv)) {
-            printf("Test 12: failed (DeallocateBlocks(12, 1) returned: 0x%.8x)\n", rv);
-            goto exit;
-        }
-
-        rv = blockFile->DeallocateBlocks(1, 2);
-        if (NS_FAILED(rv)) {
-            printf("Test 12: failed (DeallocateBlocks(1, 2) returned: 0x%.8x)\n", rv);
-            goto exit;
-        }
-
-        rv = blockFile->DeallocateBlocks(4, 3);
-        if (NS_FAILED(rv)) {
-            printf("Test 12: failed (DeallocateBlocks(4, 3) returned: 0x%.8x)\n", rv);
-            goto exit;
-        }
-
-        rv = blockFile->DeallocateBlocks(8, 4);
-        if (NS_FAILED(rv)) {
-            printf("Test 12: failed (DeallocateBlocks(8, 4) returned: 0x%.8x)\n", rv);
-            goto exit;
-        }
-
-        // zero blocks should be allocated
-        rv = blockFile->Close();
-        if (NS_FAILED(rv)) {
-            printf("Test 12: failed (Close returned: 0x%.8x)\n", rv);
-            goto exit;
-        }
-
-        printf("Test 12: passed\n");
-
-
-        //----------------------------------------------------------------
-        //  Test 13: Allocate/Deallocate boundary test
-        //----------------------------------------------------------------
-
-        rv = blockFile->Open(localFile, 256);
-        if (NS_FAILED(rv)) {
-            printf("Test 13: failed (Open returned: 0x%.8x)\n", rv);
-            goto exit;
-        }
-
-        // fully allocate, 1 block at a time
-        for (i=0; i< kBitMapBytes * 8; ++i) {
-            startBlock = blockFile->AllocateBlocks(1);
-            if (startBlock < 0) {
-                printf("Test 13: failed (AllocateBlocks(1) failed on i=%d)\n", i);
-                goto exit;
-            }
-        }
-
-        // attempt allocation with full bit map
-        startBlock = blockFile->AllocateBlocks(1);
-        if (startBlock >= 0) {
-            printf("Test 13: failed (AllocateBlocks(1) erroneously succeeded i=%d)\n", i);
-            goto exit;
-        }
-
-        // deallocate all the bits
-        for (i=0; i< kBitMapBytes * 8; ++i) {
-            rv = blockFile->DeallocateBlocks(i,1);
-            if (NS_FAILED(rv)) {
-                printf("Test 13: failed (DeallocateBlocks(%d,1) returned: 0x%.8x)\n", i,rv);
-                goto exit;
-            }
-        }
-
-        // attempt deallocation beyond end of bit map
-        rv = blockFile->DeallocateBlocks(i,1);
-        if (NS_SUCCEEDED(rv)) {
-            printf("Test 13: failed (DeallocateBlocks(%d,1) erroneously succeeded)\n", i);
-            goto exit;
-        }
-
-        // bit map should be empty
-
-        // fully allocate, 2 block at a time
-        for (i=0; i< kBitMapBytes * 8; i+=2) {
-            startBlock = blockFile->AllocateBlocks(2);
-            if (startBlock < 0) {
-                printf("Test 13: failed (AllocateBlocks(2) failed on i=%d)\n", i);
-                goto exit;
-            }
-        }
-
-        // attempt allocation with full bit map
-        startBlock = blockFile->AllocateBlocks(2);
-        if (startBlock >= 0) {
-            printf("Test 13: failed (AllocateBlocks(2) erroneously succeeded i=%d)\n", i);
-            goto exit;
-        }
-
-        // deallocate all the bits
-        for (i=0; i< kBitMapBytes * 8; i+=2) {
-            rv = blockFile->DeallocateBlocks(i,2);
-            if (NS_FAILED(rv)) {
-                printf("Test 13: failed (DeallocateBlocks(%d,2) returned: 0x%.8x)\n", i,rv);
-                goto exit;
-            }
-        }
-
-        // bit map should be empty
-
-        // fully allocate, 4 block at a time
-        for (i=0; i< kBitMapBytes * 8; i+=4) {
-            startBlock = blockFile->AllocateBlocks(4);
-            if (startBlock < 0) {
-                printf("Test 13: failed (AllocateBlocks(4) failed on i=%d)\n", i);
-                goto exit;
-            }
-        }
-
-        // attempt allocation with full bit map
-        startBlock = blockFile->AllocateBlocks(4);
-        if (startBlock >= 0) {
-            printf("Test 13: failed (AllocateBlocks(4) erroneously succeeded i=%d)\n", i);
-            goto exit;
-        }
-
-        // deallocate all the bits
-        for (i=0; i< kBitMapBytes * 8; i+=4) {
-            rv = blockFile->DeallocateBlocks(i,4);
-            if (NS_FAILED(rv)) {
-                printf("Test 13: failed (DeallocateBlocks(%d,4) returned: 0x%.8x)\n", i,rv);
-                goto exit;
-            }
-        }
-
-        // bit map should be empty
-
-        // allocate as many triple-blocks as possible
-        for (i=0; i< kBitMapBytes * 8; i+=4) {
-            startBlock = blockFile->AllocateBlocks(3);
-            if (startBlock < 0) {
-                printf("Test 13: failed (AllocateBlocks(3) failed on i=%d)\n", i);
-                goto exit;
-            }
-        }
-
-        // attempt allocation with "full" bit map
-        startBlock = blockFile->AllocateBlocks(3);
-        if (startBlock >= 0) {
-            printf("Test 13: failed (AllocateBlocks(3) erroneously succeeded i=%d)\n", i);
-            goto exit;
-        }
-
-        // leave some blocks allocated
-
-        rv = blockFile->Close();
-        if (NS_FAILED(rv)) {
-            printf("Test 13: failed (Close returned: 0x%.8x)\n", rv);
-            goto exit;
-        }
-
-        printf("Test 13: passed\n");
-
-
-        //----------------------------------------------------------------
-        //  Test 14: ValidateFile (open existing file w/size < allocated blocks
-        //----------------------------------------------------------------
-        rv = blockFile->Open(localFile, 256);
-        if (NS_SUCCEEDED(rv)) {
-            printf("Test 14: failed (Open erroneously succeeded)\n");
-            goto exit;
-        }
-
-        // Delete existing file
-        rv = localFile->Delete(false);
-        if (NS_FAILED(rv)) {
-            printf("Test 14 failed (Delete returned: 0x%.8x)\n", rv);
-            goto exit;
-        }
-        printf("Test 14: passed\n");
-
-
-        //----------------------------------------------------------------
-        //  Test 15: Allocate/Deallocate stress test
-        //----------------------------------------------------------------
-
-        rv = StressTest(localFile, 15, false);
-        if (NS_FAILED(rv))
-            goto exit;
-
-        printf("Test 15: passed\n");
-
-
-        //----------------------------------------------------------------
-        //  Test 16: WriteBlocks
-        //----------------------------------------------------------------
-
-        rv = blockFile->Open(localFile, 256);
-        if (NS_FAILED(rv)) {
-            printf("Test 16: failed (Open returned: 0x%.8x)\n", rv);
-            goto exit;
-        }
-
-        char * one   = new char[256 * 1];
-        char * two   = new char[256 * 2];
-        char * three = new char[256 * 3];
-        char * four  = new char[256 * 4];
-        if (!one || !two || !three || !four) {
-            printf("Test 16: failed - out of memory\n");
-            rv = NS_ERROR_OUT_OF_MEMORY;
-            goto exit;
-        }
-
-        memset(one,   1, 256);
-        memset(two,   2, 256 * 2);
-        memset(three, 3, 256 * 3);
-        memset(four,  4, 256 * 4);
-
-        startBlock = blockFile->AllocateBlocks(1);
-        if (startBlock != 0) {
-            printf("Test 16: failed (AllocateBlocks(1) failed)\n");
-            goto exit;
-        }
-
-        rv = blockFile->WriteBlocks(one, startBlock, 1);
-        if (NS_FAILED(rv)) {
-            printf("Test 16: failed (WriteBlocks(1) returned 0x%.8x)\n", rv);
-            goto exit;
-        }
-
-        startBlock = blockFile->AllocateBlocks(2);
-        if (startBlock != 1) {  // starting with empy map, this allocation should begin at block 1
-            printf("Test 16: failed (AllocateBlocks(2) failed)\n");
-            goto exit;
-        }
-
-        rv = blockFile->WriteBlocks(two, startBlock, 2);
-        if (NS_FAILED(rv)) {
-            printf("Test 16: failed (WriteBlocks(2) returned 0x%.8x)\n", rv);
-            goto exit;
-        }
-
-        startBlock = blockFile->AllocateBlocks(3);
-        if (startBlock != 4) {  // starting with empy map, this allocation should begin at block 4
-            printf("Test 16: failed (AllocateBlocks(3) failed)\n");
-            goto exit;
-        }
-
-        rv = blockFile->WriteBlocks(three, startBlock, 3);
-        if (NS_FAILED(rv)) {
-            printf("Test 16: failed (WriteBlocks(3) returned 0x%.8x)\n", rv);
-            goto exit;
-        }
-
-        startBlock = blockFile->AllocateBlocks(4);
-        if (startBlock != 8) {  // starting with empy map, this allocation should begin at block 8
-            printf("Test 16: failed (AllocateBlocks(4) failed)\n");
-            goto exit;
-        }
-
-        rv = blockFile->WriteBlocks(four, startBlock, 4);
-        if (NS_FAILED(rv)) {
-            printf("Test 16: failed (WriteBlocks(4) returned 0x%.8x)\n", rv);
-            goto exit;
-        }
-
-        printf("Test 16: passed\n");
-
-
-        //----------------------------------------------------------------
-        //  Test 17: ReadBlocks
-        //----------------------------------------------------------------
-
-        rv = blockFile->ReadBlocks(one, 0, 1);
-        if (NS_FAILED(rv)) {
-            printf("Test 17: failed (ReadBlocks(1) returned 0x%.8x)\n", rv);
-            goto exit;
-        }
-
-        // Verify buffer
-        for (i = 0; i < 256; i++) {
-            if (one[i] != 1) {
-                printf("Test 17: failed (verifying buffer 1)\n");
-                rv = NS_ERROR_FAILURE;
-                goto exit;
-            }
-        }
-
-        rv = blockFile->ReadBlocks(two, 1, 2);
-        if (NS_FAILED(rv)) {
-            printf("Test 17: failed (ReadBlocks(2) returned 0x%.8x)\n", rv);
-            goto exit;
-        }
-
-        // Verify buffer
-        for (i = 0; i < 256 * 2; i++) {
-            if (two[i] != 2) {
-                printf("Test 17: failed (verifying buffer 2)\n");
-                rv = NS_ERROR_FAILURE;
-                goto exit;
-            }
-        }
-
-        rv = blockFile->ReadBlocks(three, 4, 3);
-        if (NS_FAILED(rv)) {
-            printf("Test 17: failed (ReadBlocks(3) returned 0x%.8x)\n", rv);
-            goto exit;
-        }
-
-        // Verify buffer
-        for (i = 0; i < 256 * 3; i++) {
-            if (three[i] != 3) {
-                printf("Test 17: failed (verifying buffer 3)\n");
-                rv = NS_ERROR_FAILURE;
-                goto exit;
-            }
-        }
-
-        rv = blockFile->ReadBlocks(four, 8, 4);
-        if (NS_FAILED(rv)) {
-            printf("Test 17: failed (ReadBlocks(4) returned 0x%.8x)\n", rv);
-            goto exit;
-        }
-
-        // Verify buffer
-        for (i = 0; i < 256 * 4; i++) {
-            if (four[i] != 4) {
-                printf("Test 17: failed (verifying buffer 4)\n");
-                rv = NS_ERROR_FAILURE;
-                goto exit;
-            }
-        }
-
-        rv = blockFile->Close();
-        if (NS_FAILED(rv)) {
-            printf("Test 17: failed (Close returned: 0x%.8x)\n", rv);
-            goto exit;
-        }
-
-        printf("Test 17: passed\n");
-
-
-        //----------------------------------------------------------------
-        //  Test 18: ValidateFile (open existing file with blocks allocated)
-        //----------------------------------------------------------------
-        rv = blockFile->Open(localFile, 256);
-        if (NS_FAILED(rv)) {
-            printf("Test 18: failed (Open returned: 0x%.8x)\n", rv);
-            goto exit;
-        }
-
-        rv = blockFile->Close();
-        if (NS_FAILED(rv)) {
-            printf("Test 18: failed (Close returned: 0x%.8x)\n", rv);
-            goto exit;
-        }
-
-        printf("Test 18: passed\n");
-
-        //----------------------------------------------------------------
-        //  Test 19: WriteBlocks/ReadBlocks stress
-        //----------------------------------------------------------------
-
-        rv = StressTest(localFile, 19, false);
-        if (NS_FAILED(rv))
-            goto exit;
-
-        printf("Test 19: passed\n");
-
-
-exit:
-
-        if (currentDirPath)
-            free(currentDirPath);
-    } // this scopes the nsCOMPtrs
-    // no nsCOMPtrs are allowed to be alive when you call NS_ShutdownXPCOM
-    if (NS_FAILED(rv))
-        printf("Test failed: 0x%.8x\n", rv);
-
-    rv = NS_ShutdownXPCOM(nullptr);
-    NS_ASSERTION(NS_SUCCEEDED(rv), "NS_ShutdownXPCOM failed");
-
-    printf("XPCOM shut down.\n\n");
-    return 0;
-}
-
deleted file mode 100644
--- a/netwerk/test/TestCachePrefixKeyParser.cpp
+++ /dev/null
@@ -1,78 +0,0 @@
-/* -*- 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 "TestHarness.h"
-#include "nsILoadContextInfo.h"
-#include "../cache2/CacheFileUtils.h"
-
-int
-main(int32_t argc, char *argv[])
-{
-  nsCOMPtr<nsILoadContextInfo> info;
-  nsAutoCString key, enh;
-
-#define CHECK(a) MOZ_ASSERT(a)
-
-  info = ParseKey(NS_LITERAL_CSTRING(""));
-  CHECK(info && !info->IsPrivate() && !info->IsAnonymous() && !info->IsInBrowserElement() && info->AppId() == 0);
-  info = ParseKey(NS_LITERAL_CSTRING(":"));
-  CHECK(info && !info->IsPrivate() && !info->IsAnonymous() && !info->IsInBrowserElement() && info->AppId() == 0);
-  info = ParseKey(NS_LITERAL_CSTRING("a,"));
-  CHECK(info && !info->IsPrivate() && info->IsAnonymous() && !info->IsInBrowserElement() && info->AppId() == 0);
-  info = ParseKey(NS_LITERAL_CSTRING("a,:"));
-  CHECK(info && !info->IsPrivate() && info->IsAnonymous() && !info->IsInBrowserElement() && info->AppId() == 0);
-  info = ParseKey(NS_LITERAL_CSTRING("a,:xxx"), &enh, &key);
-  CHECK(info && !info->IsPrivate() && info->IsAnonymous() && !info->IsInBrowserElement() && info->AppId() == 0);
-  CHECK(NS_LITERAL_CSTRING("xxx").Equals(key));
-  info = ParseKey(NS_LITERAL_CSTRING("b,:xxx"));
-  CHECK(info && !info->IsPrivate() && !info->IsAnonymous() && info->IsInBrowserElement() && info->AppId() == 0);
-  info = ParseKey(NS_LITERAL_CSTRING("a,b,:xxx"), &enh, &key);
-  CHECK(info && !info->IsPrivate() && info->IsAnonymous() && info->IsInBrowserElement() && info->AppId() == 0);
-  CHECK(NS_LITERAL_CSTRING("xxx").Equals(key));
-  CHECK(enh.IsEmpty());
-  info = ParseKey(NS_LITERAL_CSTRING("a,b,i123,:xxx"));
-  CHECK(info && !info->IsPrivate() && info->IsAnonymous() && info->IsInBrowserElement() && info->AppId() == 123);
-  info = ParseKey(NS_LITERAL_CSTRING("a,b,c,h***,i123,:xxx"), &enh, &key);
-  CHECK(info && !info->IsPrivate() && info->IsAnonymous() && info->IsInBrowserElement() && info->AppId() == 123);
-  CHECK(NS_LITERAL_CSTRING("xxx").Equals(key));
-  info = ParseKey(NS_LITERAL_CSTRING("a,b,c,h***,i123,~enh,:xxx"), &enh, &key);
-  CHECK(info && !info->IsPrivate() && info->IsAnonymous() && info->IsInBrowserElement() && info->AppId() == 123);
-  CHECK(NS_LITERAL_CSTRING("xxx").Equals(key));
-  CHECK(NS_LITERAL_CSTRING("enh").Equals(enh));
-  info = ParseKey(NS_LITERAL_CSTRING("0x,1,a,b,i123,:xxx"));
-  CHECK(info && !info->IsPrivate() && info->IsAnonymous() && info->IsInBrowserElement() && info->AppId() == 123);
-
-  nsAutoCString test;
-  AppendTagWithValue(test, '~', NS_LITERAL_CSTRING("e,nh,"));
-  info = ParseKey(test, &enh, &key);
-  CHECK(info && !info->IsPrivate() && !info->IsAnonymous() && !info->IsInBrowserElement() && info->AppId() == 0);
-  CHECK(NS_LITERAL_CSTRING("e,nh,").Equals(enh));
-
-  info = ParseKey(NS_LITERAL_CSTRING("a,i123,b,:xxx"));
-  CHECK(!info);
-  info = ParseKey(NS_LITERAL_CSTRING("a"));
-  CHECK(!info);
-  info = ParseKey(NS_LITERAL_CSTRING("a:"));
-  CHECK(!info);
-  info = ParseKey(NS_LITERAL_CSTRING("a:xxx"));
-  CHECK(!info);
-  info = ParseKey(NS_LITERAL_CSTRING("i123"));
-  CHECK(!info);
-  info = ParseKey(NS_LITERAL_CSTRING("i123:"));
-  CHECK(!info);
-  info = ParseKey(NS_LITERAL_CSTRING("i123:xxx"));
-  CHECK(!info);
-  info = ParseKey(NS_LITERAL_CSTRING("i123,x:"));
-  CHECK(!info);
-  info = ParseKey(NS_LITERAL_CSTRING("i,x,:"));
-  CHECK(!info);
-  info = ParseKey(NS_LITERAL_CSTRING("i:"));
-  CHECK(!info);
-
-#undef CHECK
-
-  passed("ok");
-  return 0;
-}
deleted file mode 100644
--- a/netwerk/test/TestDNSDaemon.cpp
+++ /dev/null
@@ -1,274 +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 <stdio.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <unistd.h>
-#include <errno.h>
-
-#if defined(AIX) || defined(__linux)
-#include <sys/select.h>         // for fd_set
-#endif
-
-#if defined(__linux)
-// Didn't find gettdtablehi() or gettdtablesize() on linux. Using FD_SETSIZE
-#define getdtablehi() FD_SETSIZE
-#else
-#define getdtablehi() getdtablesize()
-
-//  If you find a system doesn't have getdtablesize try #define getdtablesize
-//  to FD_SETSIZE.  And if you encounter a system that doesn't even have 
-//  FD_SETSIZE, just grab your ankles and use 255.
-#endif
-
-
-#include "nspr.h"
-#include "nsCRT.h"
-#include "unix_dns.h"
-
-struct sockaddr_un  unix_addr;
-
-int async_dns_lookup(char* hostName)
-{
-  fprintf(stderr, "start async_dns_lookup\n");
-  int socket_fd = socket(PF_UNIX, SOCK_STREAM, 0);
-  if (socket_fd == -1) {
-    fprintf(stderr, "socket returned error.\n");
-    return -1;
-  }
-
-  unix_addr.sun_family = AF_UNIX;
-  strcpy(unix_addr.sun_path, DNS_SOCK_NAME);
-
-  int err = connect(socket_fd,(struct sockaddr*)&unix_addr, sizeof(unix_addr));
-  if (err == -1) {
-    fprintf(stderr, "connect failed (errno = %d).\n",errno);
-    close(socket_fd);
-    return -1;
-  }
-
-  char buf[256];
-  strcpy(buf, "lookup: ");
-  strcpy(&buf[8], hostName);
-
-  err = send(socket_fd, buf, strlen(buf)+1, 0);
-  if (err < 0)
-    fprintf(stderr, "send(%s) returned error (errno=%d).\n",buf, errno);
-
-  // receive 4 byte ID
-  err = recv(socket_fd, buf, 256, 0);
-  if (err < 0)
-    fprintf(stderr, "recv() returned error (errno=%d).\n", errno);
-  else
-    {
-      //  printf("recv() returned %d bytes.");
-      int id = *(int *)buf;
-      fprintf(stderr, "id: %d\n", id);
-    }
-
-  return socket_fd;
-}
-
-static char *
-string_trim(char *s)
-{
-  char *s2;
-  if (!s) return 0;
-  s2 = s + strlen(s) - 1;
-  while (s2 > s && (*s2 == '\n' || *s2 == '\r' || *s2 == ' ' || *s2 == '\t'))
-    *s2-- = 0;
-  while (*s == ' ' || *s == '\t' || *s == '\n' || *s == '\r')
-    s++;
-  return s;
-}
-
-hostent *
-bytesToHostent(char *buf)
-{
-  int i;
-  // int size = 0;
-  int len, aliasCount, addressCount;
-  int addrtype, addrlength;
-  char* p = buf;
-  char s[1024];
-
-  len = *(int *)p;            // length of name
-  p += sizeof(int);           // advance past name length
-
-  memcpy(s, p, len); s[len] = 0;
-  fprintf(stderr, "hostname: %s\n", s);
-
-  p += len;                   // advance past name
-  aliasCount  = *(int *)p;    // number of aliases
-  p += sizeof(int);           // advance past alias count
-
-  for (i=0; i<aliasCount; i++) {
-    len = *(int *)p;          // length of alias name
-    p += sizeof(int);         // advance past alias name length
-
-    memcpy(s, p, len); s[len] = 0;
-    fprintf(stderr, "alias: %s\n", s);
-
-    p += len;                 // advance past alias name
-  }
-
-  addrtype = *(int *)p;
-
-  fprintf(stderr, "addrtype: %d\n", addrtype);
-
-  p += sizeof(int);
-  addrlength = *(int *)p;
-
-  fprintf(stderr, "addrlength: %d\n", addrlength);
-
-  p += sizeof(int);
-  addressCount = *(int *)p;
-  p += sizeof(int);
-
-  for (i=0; i<addressCount; i++) {
-    len = *(int *)p;    
-    p += sizeof(int);
-
-    fprintf(stderr, "addr len: %d\n", len);
-    fprintf(stderr, "addr    : %x\n", *(int *)p);
-
-    p += len;
-  }
-
-  // size = p - buf;
-  // size += 1 + aliasCount;
-  return 0;
-}
-
-int
-main(int argc, char* argv[])
-{
-  PRStatus status;
-
-  // launch daemon
-  printf("### launch daemon...\n");
-
-  PRProcessAttr *attributes = PR_NewProcessAttr();
-  if (attributes == nullptr) {
-    printf("PR_NewProcessAttr() failed.\n");
-    return -1;
-  }
-
-  PRProcess *daemon = PR_CreateProcess("nsDnsAsyncLookup", nullptr, nullptr, attributes);
-  if (daemon == nullptr) {
-    printf("PR_CreateProcess failed.\n");
-  } else {
-    //    status = PR_DetachProcess(daemon);
-    //if (status != 0)
-    //  printf("PR_DetachProcess returned %d\n", status);
-    //daemon = nullptr;
-  }
-
-  PR_DestroyProcessAttr(attributes);
-
-  // create socket and connect to daemon
-  int socket_fd = 0;
-
-
-  bool notDone = true;
-  char buf[1024];
-
-  while(notDone) {
-    int status = 0;
-    fd_set fdset;
-
-    FD_ZERO(&fdset);
-    FD_SET(fileno(stdin), &fdset);
-    if (socket_fd > 0)
-      FD_SET(socket_fd, &fdset);
-	   
-    status = select(getdtablehi(), &fdset, 0, 0, 0);
-    if (status <= 0)
-      {
-	fprintf(stderr, "%s: select() returned %d\n", argv[0], status);
-	exit(-1);
-      }
-
-    // which fd is set?
-
-    if (FD_ISSET(fileno(stdin), &fdset))
-      {
-	char *line = fgets(buf, sizeof(buf)-1, stdin);
-	line = string_trim(line);
-	
-	if(!strcmp(line, "quit") || !strcmp(line, "exit"))
-	  {
-	    fprintf(stderr, "bye now.\n");
-	    notDone = false;
-	  }
-	else if (!strncmp(line, "abort ", 6))
-	  {
-	    // abort id
-	  }
-	else if (strchr(line, ' ') || strchr(line, '\t'))
-	  {
-	    fprintf(stderr, "%s: unrecognized command %s.\n", argv[0], line);
-	  }
-	else
-	  {
-	    fprintf(stderr, "%s: looking up %s...\n", argv[0], line);
-	    // initiate dns lookup
-	    socket_fd = async_dns_lookup(line);
-	  }
-      }
-
-    if (socket_fd && FD_ISSET(socket_fd, &fdset))
-      {
-	// read from socket, parse results
-	int size = read(socket_fd, buf, 1024);
-	if (size > 0)
-	  {
-	    // parse buffer into hostent
-	    char *p = buf;
-	    fprintf(stderr, "bytes read: %d\n", size);
-	    fprintf(stderr, "response code: %d\n", *(int *)p);
-	    p += sizeof(int);
-
-	    for (int i=0; i < size; i++) {
-	      if (!(i%8))
-		fprintf(stderr, "\n");
-	      fprintf(stderr, "%2.2x ",(unsigned char)buf[i]);
-	    }
-	    fprintf(stderr, "\n");
-	    hostent *h;
-	    h = bytesToHostent(p);
-	  }
-	close(socket_fd);
-	socket_fd = 0;
-      }
-  }
-
-  return 0;
-}
-
-/*
-buffer
-
-int nameLen;
-
-if (nameLen > 0)
-  char [nameLen+1] name
-
-int aliasCount
-for each alias
-  int aliasNameLen
-  char [aliasNameLen+1] aliasName
-
-int h_addrtype
-int h_length
-int addrCount
-for each addr
-  char[h_length] addr
-
-
-
-*/
deleted file mode 100644
--- a/netwerk/test/TestFileInput2.cpp
+++ /dev/null
@@ -1,483 +0,0 @@
-/* -*- 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 "nsIServiceManager.h"
-#include "nsIComponentRegistrar.h"
-#include "nsIInputStream.h"
-#include "nsIOutputStream.h"
-#include "nsIRunnable.h"
-#include "nsIThread.h"
-#include "nsCOMArray.h"
-#include "nsISimpleEnumerator.h"
-#include "prinrval.h"
-#include "nsIFileStreams.h"
-#include "nsIFileChannel.h"
-#include "nsIFile.h"
-#include "nsNetUtil.h"
-#include <stdio.h>
-
-////////////////////////////////////////////////////////////////////////////////
-
-#include <math.h>
-#include "prprf.h"
-#include "nsAutoLock.h"
-
-class nsTimeSampler {
-public:
-    nsTimeSampler();
-    void Reset();
-    void StartTime();
-    void EndTime();
-    void AddTime(PRIntervalTime time);
-    PRIntervalTime LastInterval() { return mLastInterval; }
-    char* PrintStats();
-protected:
-    PRIntervalTime      mStartTime;
-    double              mSquares;
-    double              mTotalTime;
-    uint32_t            mCount;
-    PRIntervalTime      mLastInterval;
-};
-
-nsTimeSampler::nsTimeSampler()
-{
-    Reset();
-}
-
-void
-nsTimeSampler::Reset()
-{
-    mStartTime = 0;
-    mSquares = 0;
-    mTotalTime = 0;
-    mCount = 0;
-    mLastInterval = 0;
-}
-
-void
-nsTimeSampler::StartTime()
-{
-    mStartTime = PR_IntervalNow();
-}
-
-void
-nsTimeSampler::EndTime()
-{
-    NS_ASSERTION(mStartTime != 0, "Forgot to call StartTime");
-    PRIntervalTime endTime = PR_IntervalNow();
-    mLastInterval = endTime - mStartTime;
-    AddTime(mLastInterval);
-    mStartTime = 0;
-}
-
-void
-nsTimeSampler::AddTime(PRIntervalTime time)
-{
-    nsAutoCMonitor mon(this);
-    mTotalTime += time;
-    mSquares += (double)time * (double)time;
-    mCount++;
-}
-
-char*
-nsTimeSampler::PrintStats()
-{
-    double mean = mTotalTime / mCount;
-    double variance = fabs(mSquares / mCount - mean * mean);
-    double stddev = sqrt(variance);
-    uint32_t imean = (uint32_t)mean;
-    uint32_t istddev = (uint32_t)stddev;
-    return PR_smprintf("%d +/- %d ms", 
-                       PR_IntervalToMilliseconds(imean),
-                       PR_IntervalToMilliseconds(istddev));
-}
-
-////////////////////////////////////////////////////////////////////////////////
-
-nsTimeSampler gTimeSampler;
-
-typedef nsresult (*CreateFun)(nsIRunnable* *result,
-                              nsIFile* inPath, 
-                              nsIFile* outPath, 
-                              uint32_t bufferSize);
-
-////////////////////////////////////////////////////////////////////////////////
-
-nsresult
-Copy(nsIInputStream* inStr, nsIOutputStream* outStr, 
-     char* buf, uint32_t bufSize, uint32_t *copyCount)
-{
-    nsresult rv;
-    while (true) {
-        uint32_t count;
-        rv = inStr->Read(buf, bufSize, &count);
-        if (NS_FAILED(rv)) return rv;
-        if (count == 0) break;
-
-        uint32_t writeCount;
-        rv = outStr->Write(buf, count, &writeCount);
-        if (NS_FAILED(rv)) return rv;
-        NS_ASSERTION(writeCount == count, "didn't write all the data");
-        *copyCount += writeCount;
-    }
-    rv = outStr->Flush();
-    return rv;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-
-class FileSpecWorker : public nsIRunnable {
-public:
-
-    NS_IMETHOD Run() override {
-        nsresult rv;
-
-        PRIntervalTime startTime = PR_IntervalNow();
-        PRIntervalTime endTime;
-        nsCOMPtr<nsIInputStream> inStr;
-        nsCOMPtr<nsIOutputStream> outStr;
-        uint32_t copyCount = 0;
-
-        // Open the input stream:
-        nsCOMPtr<nsIInputStream> fileIn;
-        rv = NS_NewLocalFileInputStream(getter_AddRefs(fileIn), mInPath);
-        if (NS_FAILED(rv)) return rv;
-
-        rv = NS_NewBufferedInputStream(getter_AddRefs(inStr), fileIn, 65535);
-        if (NS_FAILED(rv)) return rv;
-
-        // Open the output stream:
-        nsCOMPtr<nsIOutputStream> fileOut;
-        rv = NS_NewLocalFileOutputStream(getter_AddRefs(fileOut),
-                                         mOutPath, 
-                                         PR_CREATE_FILE | PR_WRONLY | PR_TRUNCATE,
-                                         0664);
-        if (NS_FAILED(rv)) return rv;
-
-        rv = NS_NewBufferedOutputStream(getter_AddRefs(outStr), fileOut, 65535);
-        if (NS_FAILED(rv)) return rv;
-
-        // Copy from one to the other
-        rv = Copy(inStr, outStr, mBuffer, mBufferSize, &copyCount);
-        if (NS_FAILED(rv)) return rv;
-
-        endTime = PR_IntervalNow();
-        gTimeSampler.AddTime(endTime - startTime);
-
-        return rv;
-    }
-
-    NS_DECL_ISUPPORTS
-
-    FileSpecWorker()
-        : mInPath(nullptr), mOutPath(nullptr), mBuffer(nullptr),
-          mBufferSize(0)
-    {
-    }
-
-    nsresult Init(nsIFile* inPath, nsIFile* outPath,
-                  uint32_t bufferSize)
-    {
-        mInPath = inPath;
-        mOutPath = outPath;
-        mBuffer = new char[bufferSize];
-        mBufferSize = bufferSize;
-        return (mInPath && mOutPath && mBuffer)
-            ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
-    }
-
-    static nsresult Create(nsIRunnable* *result,
-                           nsIFile* inPath, 
-                           nsIFile* outPath, 
-                           uint32_t bufferSize)
-    {
-        FileSpecWorker* worker = new FileSpecWorker();
-        if (worker == nullptr)
-            return NS_ERROR_OUT_OF_MEMORY;
-        NS_ADDREF(worker);
-
-        nsresult rv = worker->Init(inPath, outPath, bufferSize);
-        if (NS_FAILED(rv)) {
-            NS_RELEASE(worker);
-            return rv;
-        }
-        *result = worker;
-        return NS_OK;
-    }
-
-    virtual ~FileSpecWorker() {
-        delete[] mBuffer;
-    }
-
-protected:
-    nsCOMPtr<nsIFile>   mInPath;
-    nsCOMPtr<nsIFile>   mOutPath;
-    char*               mBuffer;
-    uint32_t            mBufferSize;
-};
-
-NS_IMPL_ISUPPORTS(FileSpecWorker, nsIRunnable)
-
-////////////////////////////////////////////////////////////////////////////////
-
-#include "nsIIOService.h"
-#include "nsIChannel.h"
-
-class FileChannelWorker : public nsIRunnable {
-public:
-
-    NS_IMETHOD Run() override {
-        nsresult rv;
-
-        PRIntervalTime startTime = PR_IntervalNow();
-        PRIntervalTime endTime;
-        uint32_t copyCount = 0;
-        nsCOMPtr<nsIFileChannel> inCh;
-        nsCOMPtr<nsIFileChannel> outCh;
-        nsCOMPtr<nsIInputStream> inStr;
-        nsCOMPtr<nsIOutputStream> outStr;
-
-        rv = NS_NewLocalFileChannel(getter_AddRefs(inCh), mInPath);
-        if (NS_FAILED(rv)) return rv;
-
-        rv = inCh->Open(getter_AddRefs(inStr));
-        if (NS_FAILED(rv)) return rv;
-
-        //rv = NS_NewLocalFileChannel(getter_AddRefs(outCh), mOutPath);
-        //if (NS_FAILED(rv)) return rv;
-
-        //rv = outCh->OpenOutputStream(0, -1, 0, getter_AddRefs(outStr));
-        //if (NS_FAILED(rv)) return rv;
-
-        // Copy from one to the other
-        rv = Copy(inStr, outStr, mBuffer, mBufferSize, &copyCount);
-        if (NS_FAILED(rv)) return rv;
-
-        endTime = PR_IntervalNow();
-        gTimeSampler.AddTime(endTime - startTime);
-
-        return rv;
-    }
-
-    NS_DECL_ISUPPORTS
-
-    FileChannelWorker()
-        : mInPath(nullptr), mOutPath(nullptr), mBuffer(nullptr),
-          mBufferSize(0)
-    {
-    }
-
-    nsresult Init(nsIFile* inPath, nsIFile* outPath,
-                  uint32_t bufferSize)
-    {
-        mInPath = inPath;
-        mOutPath = outPath;
-        mBuffer = new char[bufferSize];
-        mBufferSize = bufferSize;
-        return (mInPath && mOutPath && mBuffer)
-            ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
-    }
-
-    static nsresult Create(nsIRunnable* *result,
-                           nsIFile* inPath, 
-                           nsIFile* outPath, 
-                           uint32_t bufferSize)
-    {
-        FileChannelWorker* worker = new FileChannelWorker();
-        if (worker == nullptr)
-            return NS_ERROR_OUT_OF_MEMORY;
-        NS_ADDREF(worker);
-
-        nsresult rv = worker->Init(inPath, outPath, bufferSize);
-        if (NS_FAILED(rv)) {
-            NS_RELEASE(worker);
-            return rv;
-        }
-        *result = worker;
-        return NS_OK;
-    }
-
-    virtual ~FileChannelWorker() {
-        delete[] mBuffer;
-    }
-
-protected:
-    nsCOMPtr<nsIFile>   mInPath;
-    nsCOMPtr<nsIFile>   mOutPath;
-    char*               mBuffer;
-    uint32_t            mBufferSize;
-};
-
-NS_IMPL_ISUPPORTS(FileChannelWorker, nsIRunnable)
-
-////////////////////////////////////////////////////////////////////////////////
-
-void
-Test(CreateFun create, const char* name, uint32_t count,
-     nsIFile* inDirSpec, nsIFile* outDirSpec, uint32_t bufSize)
-{
-    nsresult rv;
-    uint32_t i;
-
-    nsAutoCString inDir;
-    nsAutoCString outDir;
-    (void)inDirSpec->GetNativePath(inDir);
-    (void)outDirSpec->GetNativePath(outDir);
-    printf("###########\nTest: from %s to %s, bufSize = %d\n",
-           inDir.get(), outDir.get(), bufSize);
-    gTimeSampler.Reset();
-    nsTimeSampler testTime;
-    testTime.StartTime();
-
-    nsCOMArray<nsIThread> threads;
-
-    nsCOMPtr<nsISimpleEnumerator> entries;
-    rv = inDirSpec->GetDirectoryEntries(getter_AddRefs(entries));
-    NS_ASSERTION(NS_SUCCEEDED(rv), "GetDirectoryEntries failed");
-
-    i = 0;
-    bool hasMore;
-    while (i < count && NS_SUCCEEDED(entries->HasMoreElements(&hasMore)) && hasMore) {
-        nsCOMPtr<nsISupports> next;
-        rv = entries->GetNext(getter_AddRefs(next));
-        if (NS_FAILED(rv)) goto done;
-
-        nsCOMPtr<nsIFile> inSpec = do_QueryInterface(next, &rv);
-        if (NS_FAILED(rv)) goto done;
-
-        nsCOMPtr<nsIFile> outSpec;
-        rv = outDirSpec->Clone(getter_AddRefs(outSpec)); // don't munge the original
-        if (NS_FAILED(rv)) goto done;
-
-        nsAutoCString leafName;
-        rv = inSpec->GetNativeLeafName(leafName);
-        if (NS_FAILED(rv)) goto done;
-
-        rv = outSpec->AppendNative(leafName);
-        if (NS_FAILED(rv)) goto done;
-
-        bool exists;
-        rv = outSpec->Exists(&exists);
-        if (NS_FAILED(rv)) goto done;
-
-        if (exists) {
-            rv = outSpec->Remove(false);
-            if (NS_FAILED(rv)) goto done;
-        }
-
-        nsCOMPtr<nsIThread> thread;
-        nsCOMPtr<nsIRunnable> worker;
-        rv = create(getter_AddRefs(worker), 
-                    inSpec,
-                    outSpec,
-                    bufSize);
-        if (NS_FAILED(rv)) goto done;
-
-        rv = NS_NewNamedThread(name, getter_AddRefs(thread),
-                               worker, 0, PR_JOINABLE_THREAD);
-        if (NS_FAILED(rv)) goto done;
-
-        bool inserted = threads.InsertObjectAt(thread, i);
-        NS_ASSERTION(inserted, "not inserted");
-
-        i++;
-    }
-
-    uint32_t j;
-    for (j = 0; j < i; j++) {
-        nsIThread* thread = threads.ObjectAt(j);
-        thread->Join();
-    }
-
-  done:
-    NS_ASSERTION(rv == NS_OK, "failed");
-
-    testTime.EndTime();
-    char* testStats = testTime.PrintStats();
-    char* workerStats = gTimeSampler.PrintStats();
-    printf("  threads = %d\n  work time = %s,\n  test time = %s\n",
-           i, workerStats, testStats);
-    PR_smprintf_free(workerStats);
-    PR_smprintf_free(testStats);
-}
-
-////////////////////////////////////////////////////////////////////////////////
-
-int
-main(int argc, char* argv[])
-{
-    nsresult rv;
-
-    if (argc < 2) {
-        printf("usage: %s <in-dir> <out-dir>\n", argv[0]);
-        return -1;
-    }
-    char* inDir = argv[1];
-    char* outDir = argv[2];
-
-    {
-        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);
-
-        nsCOMPtr<nsIFile> inDirFile;
-        rv = NS_NewNativeLocalFile(nsDependentCString(inDir), false, getter_AddRefs(inDirFile));
-        if (NS_FAILED(rv)) return rv;
-
-        nsCOMPtr<nsIFile> outDirFile;
-        rv = NS_NewNativeLocalFile(nsDependentCString(outDir), false, getter_AddRefs(outDirFile));
-        if (NS_FAILED(rv)) return rv;
-
-        CreateFun create = FileChannelWorker::Create;
-        const char* name = "FileChannelWorker";
-        Test(create, 1, inDirFile, outDirFile, 16 * 1024);
-#if 1
-        printf("FileChannelWorker *****************************\n");
-        Test(create, name, 20, inDirFile, outDirFile, 16 * 1024);
-        Test(create, name, 20, inDirFile, outDirFile, 16 * 1024);
-        Test(create, name, 20, inDirFile, outDirFile, 16 * 1024);
-        Test(create, name, 20, inDirFile, outDirFile, 16 * 1024);
-        Test(create, name, 20, inDirFile, outDirFile, 16 * 1024);
-        Test(create, name, 20, inDirFile, outDirFile, 16 * 1024);
-        Test(create, name, 20, inDirFile, outDirFile, 16 * 1024);
-        Test(create, name, 20, inDirFile, outDirFile, 16 * 1024);
-        Test(create, name, 20, inDirFile, outDirFile, 16 * 1024);
-#endif
-        create = FileSpecWorker::Create;
-        name = "FileSpecWorker";
-        printf("FileSpecWorker ********************************\n");
-#if 1
-        Test(create, name, 20, inDirFile, outDirFile, 16 * 1024);
-        Test(create, name, 20, inDirFile, outDirFile, 16 * 1024);
-        Test(create, name, 20, inDirFile, outDirFile, 16 * 1024);
-        Test(create, name, 20, inDirFile, outDirFile, 16 * 1024);
-        Test(create, name, 20, inDirFile, outDirFile, 16 * 1024);
-        Test(create, name, 20, inDirFile, outDirFile, 16 * 1024);
-        Test(create, name, 20, inDirFile, outDirFile, 16 * 1024);
-        Test(create, name, 20, inDirFile, outDirFile, 16 * 1024);
-        Test(create, name, 20, inDirFile, outDirFile, 16 * 1024);
-#endif
-#if 1
-        Test(create, name, 20, inDirFile, outDirFile, 4 * 1024);
-        Test(create, name, 20, inDirFile, outDirFile, 4 * 1024);
-        Test(create, name, 20, inDirFile, outDirFile, 4 * 1024);
-        Test(create, name, 20, inDirFile, outDirFile, 4 * 1024);
-        Test(create, name, 20, inDirFile, outDirFile, 4 * 1024);
-        Test(create, name, 20, inDirFile, outDirFile, 4 * 1024);
-        Test(create, name, 20, inDirFile, outDirFile, 4 * 1024);
-        Test(create, name, 20, inDirFile, outDirFile, 4 * 1024);
-        Test(create, name, 20, inDirFile, outDirFile, 4 * 1024);
-#endif
-    } // 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/TestMakeAbs.cpp
+++ /dev/null
@@ -1,69 +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 "nspr.h"
-#include "nscore.h"
-#include "nsCOMPtr.h"
-#include "nsIIOService.h"
-#include "nsIServiceManager.h"
-#include "nsIComponentRegistrar.h"
-#include "nsIURI.h"
-
-static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
-
-nsresult ServiceMakeAbsolute(nsIURI *baseURI, char *relativeInfo, char **_retval) {
-    nsresult rv;
-    nsCOMPtr<nsIIOService> serv(do_GetService(kIOServiceCID, &rv));
-    if (NS_FAILED(rv)) return rv;
-
-    return serv->MakeAbsolute(relativeInfo, baseURI, _retval);
-}
-
-nsresult URLMakeAbsolute(nsIURI *baseURI, char *relativeInfo, char **_retval) {
-    return baseURI->MakeAbsolute(relativeInfo, _retval);
-}
-
-int
-main(int argc, char* argv[])
-{
-    nsresult rv = NS_OK;
-    if (argc < 4) {
-        printf("usage: %s int (loop count) baseURL relativeSpec\n", argv[0]);
-        return -1;
-    }
-
-    uint32_t cycles = atoi(argv[1]);
-    char *base = argv[2];
-    char *rel  = argv[3];
-    {
-        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);
-
-        nsCOMPtr<nsIIOService> serv(do_GetService(kIOServiceCID, &rv));
-        if (NS_FAILED(rv)) return rv;
-
-        nsCOMPtr<nsIURI> uri;
-        rv = serv->NewURI(base, nullptr, getter_AddRefs(uri));
-        if (NS_FAILED(rv)) return rv;
-
-        char *absURLString;
-        uint32_t i = 0;
-        while (i++ < cycles) {
-            rv = ServiceMakeAbsolute(uri, rel, &absURLString);
-            if (NS_FAILED(rv)) return rv;
-            free(absURLString);
-
-            rv = URLMakeAbsolute(uri, rel, &absURLString);
-            free(absURLString);
-        }
-    } // this scopes the nsCOMPtrs
-    // no nsCOMPtrs are allowed to be alive when you call NS_ShutdownXPCOM
-    NS_ShutdownXPCOM(nullptr);
-    return rv;
-}
deleted file mode 100644
--- a/netwerk/test/TestOverlappedIO.cpp
+++ /dev/null
@@ -1,313 +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 <stdio.h>
-#include <signal.h>
-#include <algorithm>
-
-#ifdef WIN32
-#include <windows.h>
-#endif
-
-#include "nspr.h"
-#include "nscore.h"
-#include "nsISocketTransportService.h"
-#include "nsIEventQueueService.h"
-#include "nsIServiceManager.h"
-#include "nsITransport.h"
-#include "nsIRequest.h"
-#include "nsIStreamProvider.h"
-#include "nsIStreamListener.h"
-#include "nsIPipe.h"
-#include "nsIOutputStream.h"
-#include "nsIInputStream.h"
-#include "nsCRT.h"
-#include "nsCOMPtr.h"
-#include "nsIByteArrayInputStream.h"
-
-static PRLogModuleInfo *gTestSocketIOLog;
-#define LOG(args) MOZ_LOG(gTestSocketIOLog, mozilla::LogLevel::Debug, args)
-
-static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID);
-static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
-
-static PRTime gElapsedTime;
-static int gKeepRunning = 1;
-static nsIEventQueue* gEventQ = nullptr;
-
-//
-//----------------------------------------------------------------------------
-// Test Listener
-//----------------------------------------------------------------------------
-//
-
-class TestListener : public nsIStreamListener
-{
-public:
-    TestListener() { }
-    virtual ~TestListener() {}
-
-    NS_DECL_ISUPPORTS
-    NS_DECL_NSIREQUESTOBSERVER
-    NS_DECL_NSISTREAMLISTENER
-};
-
-NS_IMPL_ISUPPORTS(TestListener,
-                  nsIRequestObserver,
-                  nsIStreamListener);
-
-NS_IMETHODIMP
-TestListener::OnStartRequest(nsIRequest* request, nsISupports* context)
-{
-    LOG(("TestListener::OnStartRequest\n"));
-    return NS_OK;
-}
-
-NS_IMETHODIMP
-TestListener::OnDataAvailable(nsIRequest* request,
-                              nsISupports* context,
-                              nsIInputStream *aIStream, 
-                              uint64_t aSourceOffset,
-                              uint32_t aLength)
-{
-    LOG(("TestListener::OnDataAvailable [offset=%llu length=%u]\n",
-        aSourceOffset, aLength));
-    char buf[1025];
-    uint32_t amt;
-    while (1) {
-        aIStream->Read(buf, 1024, &amt);
-        if (amt == 0)
-            break;
-        buf[amt] = '\0';
-        //puts(buf);
-        printf("read %d bytes\n", amt);
-    }
-    return NS_OK;
-}
-
-NS_IMETHODIMP
-TestListener::OnStopRequest(nsIRequest* request, nsISupports* context,
-                            nsresult aStatus)
-{
-    LOG(("TestListener::OnStopRequest [aStatus=%x]\n", aStatus));
-    //gKeepRunning = 0;
-    return NS_OK;
-}
-
-//
-//----------------------------------------------------------------------------
-// Test Provider
-//----------------------------------------------------------------------------
-//
-
-class TestProvider : public nsIStreamProvider
-{
-public:
-    TestProvider(char *data);
-    virtual ~TestProvider();
-
-    NS_DECL_ISUPPORTS
-    NS_DECL_NSIREQUESTOBSERVER
-    NS_DECL_NSISTREAMPROVIDER
-
-protected:
-    char    *mData;
-    uint32_t mOffset;
-    uint32_t mDataLen;   
-    uint32_t mRequestCount;
-};
-
-NS_IMPL_ISUPPORTS(TestProvider,
-                  nsIStreamProvider,
-                  nsIRequestObserver)
-
-TestProvider::TestProvider(char *data)
-{
-    mData = data;
-    mDataLen = strlen(data);
-    mOffset = 0;
-    mRequestCount = 0;
-    LOG(("Constructing TestProvider [this=%p]\n", this));
-}
-
-TestProvider::~TestProvider()
-{
-    LOG(("Destroying TestProvider [this=%p]\n", this));
-}
-
-NS_IMETHODIMP
-TestProvider::OnStartRequest(nsIRequest* request, nsISupports* context)
-{
-    LOG(("TestProvider::OnStartRequest [this=%p]\n", this));
-    return NS_OK;
-}
-
-NS_IMETHODIMP
-TestProvider::OnStopRequest(nsIRequest* request, nsISupports* context,
-                            nsresult aStatus)
-{
-    LOG(("TestProvider::OnStopRequest [status=%x]\n", aStatus));
-    return NS_OK;
-}
-
-NS_IMETHODIMP
-TestProvider::OnDataWritable(nsIRequest *request, nsISupports *context,
-                             nsIOutputStream *output, uint32_t offset, uint32_t count)
-{
-    LOG(("TestProvider::OnDataWritable [offset=%u, count=%u]\n", offset, count));
-
-    // Stop at 5 requests
-    if (mRequestCount == 5)
-        return NS_BASE_STREAM_CLOSED;
-
-    uint32_t writeCount, amount;
-    amount = std::min(count, mDataLen - mOffset);
-    nsresult rv = output->Write(mData + mOffset, amount, &writeCount);
-    if (NS_SUCCEEDED(rv)) {
-        printf("wrote %u bytes\n", writeCount);
-        mOffset += writeCount;
-        if (mOffset == mDataLen) {
-            printf("done sending packet %u\n", mRequestCount);
-            mOffset = 0;
-            mRequestCount++;
-        }
-    }
-    return NS_OK;
-}
-
-//
-//----------------------------------------------------------------------------
-// Synchronous IO
-//----------------------------------------------------------------------------
-//
-nsresult
-WriteRequest(nsIOutputStream *os, const char *request)
-{
-    LOG(("WriteRequest [request=%s]\n", request));
-    uint32_t n;
-    return os->Write(request, strlen(request), &n);
-}
-
-nsresult
-ReadResponse(nsIInputStream *is)
-{
-    uint32_t bytesRead;
-    char buf[2048];
-    do {
-        is->Read(buf, sizeof(buf), &bytesRead);
-        if (bytesRead > 0)
-            fwrite(buf, 1, bytesRead, stdout);
-    } while (bytesRead > 0);
-    return NS_OK;
-}
-
-//
-//----------------------------------------------------------------------------
-// Startup...
-//----------------------------------------------------------------------------
-//
-
-void
-sighandler(int sig)
-{
-    LOG(("got signal: %d\n", sig));
-    NS_BREAK();
-}
-
-void
-usage(char **argv)
-{
-    printf("usage: %s <host> <path>\n", argv[0]);
-    exit(1);
-}
-
-int
-main(int argc, char* argv[])
-{
-    nsresult rv;
-
-    signal(SIGSEGV, sighandler);
-
-    gTestSocketIOLog = PR_NewLogModule("TestSocketIO");
-
-    if (argc < 3)
-        usage(argv);
-
-    char *hostName = argv[1];
-    char *fileName = argv[2];
-    int port = 80;
-
-    // Create the Event Queue for this thread...
-    nsCOMPtr<nsIEventQueueService> eventQService = 
-             do_GetService(kEventQueueServiceCID, &rv);
-    if (NS_FAILED(rv)) {
-        NS_WARNING("failed to create: event queue service!");
-        return rv;
-    }
-
-    rv = eventQService->CreateMonitoredThreadEventQueue();
-    if (NS_FAILED(rv)) {
-        NS_WARNING("failed to create: thread event queue!");
-        return rv;
-    }
-
-    eventQService->GetThreadEventQueue(NS_CURRENT_THREAD, &gEventQ);
-
-    // Create the Socket transport service...
-    nsCOMPtr<nsISocketTransportService> sts = 
-             do_GetService(kSocketTransportServiceCID, &rv);
-    if (NS_FAILED(rv)) {
-        NS_WARNING("failed to create: socket transport service!");
-        return rv;
-    }
-
-    char *buffer = PR_smprintf("GET %s HTTP/1.1" CRLF
-                               "host: %s" CRLF
-                               "user-agent: Mozilla/5.0 (X11; N; Linux 2.2.16-22smp i686; en-US; m18) Gecko/20001220" CRLF
-                               "accept: */*" CRLF
-                               "accept-language: en" CRLF
-                               "accept-encoding: gzip,deflate,compress,identity" CRLF
-                               "keep-alive: 300" CRLF
-                               "connection: keep-alive" CRLF
-                                CRLF,
-                                fileName, hostName);
-    LOG(("Request [\n%s]\n", buffer));
-
-    // Create the socket transport...
-    nsCOMPtr<nsITransport> transport;
-    rv = sts->CreateTransport(hostName, port, nullptr, -1, 0, 0, getter_AddRefs(transport));
-    if (NS_FAILED(rv)) {
-        NS_WARNING("failed to create: socket transport!");
-        return rv;
-    }
-
-    gElapsedTime = PR_Now();
-
-    nsCOMPtr<nsIRequest> writeRequest, readRequest;
-
-    rv = transport->AsyncWrite(new TestProvider(buffer), nullptr, 0, 0, 0, getter_AddRefs(writeRequest));
-    if (NS_FAILED(rv)) {
-        NS_WARNING("failed calling: AsyncWrite!");
-        return rv;
-    }
-    rv = transport->AsyncRead(new TestListener(), nullptr, 0, 0, 0, getter_AddRefs(readRequest));
-    if (NS_FAILED(rv)) {
-        NS_WARNING("failed calling: AsyncWrite!");
-        return rv;
-    }
-
-    // Enter the message pump
-    while ( gKeepRunning ) {
-        PLEvent *gEvent;
-        gEventQ->WaitForEvent(&gEvent);
-        gEventQ->HandleEvent(gEvent);
-    }
-
-    PRTime endTime; 
-    endTime = PR_Now();
-    LOG(("Elapsed time: %d\n", (int32_t)(endTime/1000UL - gElapsedTime/1000UL)));
-
-    sts->Shutdown();
-    return 0;
-}
deleted file mode 100644
--- a/netwerk/test/TestServ.js
+++ /dev/null
@@ -1,164 +0,0 @@
-/* vim:set ts=2 sw=2 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/. */
-
-/*
- * To use try out this JS server socket implementation, just copy this file
- * into the "components" directory of a Mozilla build.  Then load the URL
- * http://localhost:4444/ in the browser.  You should see a page get loaded
- * that was served up by this component :-)
- *
- * This code requires Mozilla 1.6 or better.
- */
-
-const kTESTSERV_CONTRACTID = "@mozilla.org/network/test-serv;1";
-const kTESTSERV_CID = Components.ID("{a741fcd5-9695-42e8-a7f7-14f9a29f8200}");
-const nsISupports = Components.interfaces.nsISupports;
-const nsIObserver = Components.interfaces.nsIObserver;
-const nsIServerSocket = Components.interfaces.nsIServerSocket;
-const nsIServerSocketListener = Components.interfaces.nsIServerSocketListener;
-const nsITransport = Components.interfaces.nsITransport;
-const nsIScriptableInputStream = Components.interfaces.nsIScriptableInputStream;
-
-/** we'll listen on this port for HTTP requests **/
-const kPORT = 4444;
-
-function nsTestServ() { dump(">>> creating nsTestServ instance\n"); };
-
-nsTestServ.prototype =
-{
-  QueryInterface: function(iid)
-  {
-    if (iid.equals(nsIObserver) ||
-        iid.equals(nsIServerSocketListener) ||
-        iid.equals(nsISupports))
-      return this;
-
-    throw Components.results.NS_ERROR_NO_INTERFACE;
-  },
-
-  observe: function(subject, topic, data)
-  {
-    dump(">>> observe [" + topic + "]\n");
-    this.startListening();
-  },
-
-  /* this function is called when we receive a new connection */
-  onSocketAccepted: function(serverSocket, clientSocket)
-  {
-    dump(">>> accepted connection on "+clientSocket.host+":"+clientSocket.port+"\n");
-
-    var input = clientSocket.openInputStream(nsITransport.OPEN_BLOCKING, 0, 0);
-    var output = clientSocket.openOutputStream(nsITransport.OPEN_BLOCKING, 0, 0);
-
-    this.consumeInput(input);
-
-    const fixedResponse =
-      "HTTP/1.0 200 OK\r\nContent-Type: text/plain\r\n\r\nFooooopy!!\r\n";
-    var response = fixedResponse + "\r\n" + new Date().toString() + "\r\n";
-    var n = output.write(response, response.length);
-    dump(">>> wrote "+n+" bytes\n");
-
-    input.close();
-    output.close();
-  },
-
-  onStopListening: function(serverSocket, status)
-  {
-    dump(">>> shutting down server socket\n");
-  },
-
-  startListening: function()
-  {
-    const SERVERSOCKET_CONTRACTID = "@mozilla.org/network/server-socket;1";
-    var socket = Components.classes[SERVERSOCKET_CONTRACTID].createInstance(nsIServerSocket);
-    socket.init(kPORT, true /* loopback only */, 5);
-    dump(">>> listening on port "+socket.port+"\n");
-    socket.asyncListen(this);
-  },
-
-  consumeInput: function(input)
-  {
-    /* use nsIScriptableInputStream to consume all of the data on the stream */
-
-    var sin = Components.classes["@mozilla.org/scriptableinputstream;1"]
-                        .createInstance(nsIScriptableInputStream);
-    sin.init(input);
-
-    /* discard all data */
-    while (sin.available() > 0)
-      sin.read(512);
-  }
-}
-
-/**
- * JS XPCOM component registration goop:
- *
- * We set ourselves up to observe the xpcom-startup category.  This provides
- * us with a starting point.
- */
-
-var servModule = new Object();
-
-servModule.registerSelf =
-function (compMgr, fileSpec, location, type)
-{
-  compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
-  compMgr.registerFactoryLocation(kTESTSERV_CID,
-                                  "nsTestServ",
-                                  kTESTSERV_CONTRACTID,
-                                  fileSpec,
-                                  location,
-                                  type);
-
-  const CATMAN_CONTRACTID = "@mozilla.org/categorymanager;1";
-  const nsICategoryManager = Components.interfaces.nsICategoryManager;
-  var catman = Components.classes[CATMAN_CONTRACTID].getService(nsICategoryManager);
-  catman.addCategoryEntry("xpcom-startup",
-                          "TestServ",
-                          kTESTSERV_CONTRACTID,
-                          true,
-                          true);
-}
-
-servModule.getClassObject =
-function (compMgr, cid, iid)
-{
-  if (!cid.equals(kTESTSERV_CID))
-    throw Components.results.NS_ERROR_NO_INTERFACE;
-
-  if (!iid.equals(Components.interfaces.nsIFactory))
-    throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
-
-  return servFactory;
-}
-
-servModule.canUnload =
-function (compMgr)
-{
-  dump(">>> unloading test serv.\n");
-  return true;
-}
-
-var servFactory = new Object();
-
-servFactory.createInstance =
-function (outer, iid)
-{
-  if (outer != null)
-    throw Components.results.NS_ERROR_NO_AGGREGATION;
-
-  if (!iid.equals(nsIObserver) &&
-      !iid.equals(nsISupports))
-    throw Components.results.NS_ERROR_NO_INTERFACE;
-
-  return TestServ;
-}
-
-function NSGetModule(compMgr, fileSpec)
-{
-  return servModule;
-}
-
-var TestServ = new nsTestServ();
deleted file mode 100644
--- a/netwerk/test/TestSocketIO.cpp
+++ /dev/null
@@ -1,343 +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 <stdio.h>
-#include <signal.h>
-
-#ifdef WIN32
-#include <windows.h>
-#endif
-
-#include "nspr.h"
-#include "nscore.h"
-#include "nsISocketTransportService.h"
-#include "nsIEventQueueService.h"
-#include "nsIServiceManager.h"
-#include "nsITransport.h"
-#include "nsIRequest.h"
-#include "nsIStreamProvider.h"
-#include "nsIStreamListener.h"
-#include "nsIPipe.h"
-#include "nsIOutputStream.h"
-#include "nsIInputStream.h"
-#include "nsCRT.h"
-#include "nsCOMPtr.h"
-#include "nsIByteArrayInputStream.h"
-
-static PRLogModuleInfo *gTestSocketIOLog;
-#define LOG(args) MOZ_LOG(gTestSocketIOLog, mozilla::LogLevel::Debug, args)
-
-static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID);
-static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
-
-static PRTime gElapsedTime;
-static int gKeepRunning = 1;
-static nsIEventQueue* gEventQ = nullptr;
-
-//
-//----------------------------------------------------------------------------
-// Test Listener
-//----------------------------------------------------------------------------
-//
-
-class TestListener : public nsIStreamListener
-{
-public:
-    TestListener() {}
-    virtual ~TestListener() {}
-
-    NS_DECL_ISUPPORTS
-    NS_DECL_NSIREQUESTOBSERVER
-    NS_DECL_NSISTREAMLISTENER
-};
-
-NS_IMPL_ISUPPORTS(TestListener,
-                  nsIRequestObserver,
-                  nsIStreamListener);
-
-NS_IMETHODIMP
-TestListener::OnStartRequest(nsIRequest* request, nsISupports* context)
-{
-    LOG(("TestListener::OnStartRequest\n"));
-    return NS_OK;
-}
-
-NS_IMETHODIMP
-TestListener::OnDataAvailable(nsIRequest* request,
-                              nsISupports* context,
-                              nsIInputStream *aIStream, 
-                              uint32_t aSourceOffset,
-                              uint32_t aLength)
-{
-    LOG(("TestListener::OnDataAvailable [offset=%u length=%u]\n",
-        aSourceOffset, aLength));
-    char buf[1025];
-    uint32_t amt;
-    while (1) {
-        aIStream->Read(buf, 1024, &amt);
-        if (amt == 0)
-            break;
-        buf[amt] = '\0';
-        puts(buf);
-    }
-    return NS_OK;
-}
-
-NS_IMETHODIMP
-TestListener::OnStopRequest(nsIRequest* request, nsISupports* context,
-                            nsresult aStatus)
-{
-    LOG(("TestListener::OnStopRequest [aStatus=%x]\n", aStatus));
-    gKeepRunning = 0;
-    return NS_OK;
-}
-
-//
-//----------------------------------------------------------------------------
-// Test Provider
-//----------------------------------------------------------------------------
-//
-
-class TestProvider : public nsIStreamProvider
-{
-public:
-    TestProvider(char *data);
-    virtual ~TestProvider();
-
-    NS_DECL_ISUPPORTS
-    NS_DECL_NSIREQUESTOBSERVER
-    NS_DECL_NSISTREAMPROVIDER
-
-protected:
-    nsCOMPtr<nsIByteArrayInputStream> mData;
-};
-
-NS_IMPL_ISUPPORTS(TestProvider,
-                  nsIStreamProvider,
-                  nsIRequestObserver)
-
-TestProvider::TestProvider(char *data)
-{
-    NS_NewByteArrayInputStream(getter_AddRefs(mData), data, strlen(data));
-    LOG(("Constructing TestProvider [this=%p]\n", this));
-}
-
-TestProvider::~TestProvider()
-{
-    LOG(("Destroying TestProvider [this=%p]\n", this));
-}
-
-NS_IMETHODIMP
-TestProvider::OnStartRequest(nsIRequest* request, nsISupports* context)
-{
-    LOG(("TestProvider::OnStartRequest [this=%p]\n", this));
-    return NS_OK;
-}
-
-NS_IMETHODIMP
-TestProvider::OnStopRequest(nsIRequest* request, nsISupports* context,
-                            nsresult aStatus)
-{
-    LOG(("TestProvider::OnStopRequest [status=%x]\n", aStatus));
-
-    nsCOMPtr<nsIStreamListener> listener = do_QueryInterface(new TestListener());
-
-    if (NS_SUCCEEDED(aStatus)) {
-        nsCOMPtr<nsITransportRequest> treq = do_QueryInterface(request);
-        nsCOMPtr<nsITransport> transport;
-        treq->GetTransport(getter_AddRefs(transport));
-        if (transport) {
-            nsCOMPtr<nsIRequest> readRequest;
-            transport->AsyncRead(listener, nullptr, 0, 0, 0, getter_AddRefs(readRequest));
-        }
-    } else
-        gKeepRunning = 0;
-
-    return NS_OK;
-}
-
-NS_IMETHODIMP
-TestProvider::OnDataWritable(nsIRequest *request, nsISupports *context,
-                             nsIOutputStream *output, uint32_t offset, uint32_t count)
-{
-    LOG(("TestProvider::OnDataWritable [offset=%u, count=%u]\n", offset, count));
-    uint32_t writeCount;
-    nsresult rv = output->WriteFrom(mData, count, &writeCount);
-    // Zero bytes written on success indicates EOF
-    if (NS_SUCCEEDED(rv) && (writeCount == 0))
-        return NS_BASE_STREAM_CLOSED;
-    return rv;
-}
-
-//
-//----------------------------------------------------------------------------
-// Synchronous IO
-//----------------------------------------------------------------------------
-//
-nsresult
-WriteRequest(nsIOutputStream *os, const char *request)
-{
-    LOG(("WriteRequest [request=%s]\n", request));
-    uint32_t n;
-    return os->Write(request, strlen(request), &n);
-}
-
-nsresult
-ReadResponse(nsIInputStream *is)
-{
-    uint32_t bytesRead;
-    char buf[2048];
-    do {
-        is->Read(buf, sizeof(buf), &bytesRead);
-        if (bytesRead > 0)
-            fwrite(buf, 1, bytesRead, stdout);
-    } while (bytesRead > 0);
-    return NS_OK;
-}
-
-//
-//----------------------------------------------------------------------------
-// Startup...
-//----------------------------------------------------------------------------
-//
-
-void
-sighandler(int sig)
-{
-    LOG(("got signal: %d\n", sig));
-    NS_BREAK();
-}
-
-void
-usage(char **argv)
-{
-    printf("usage: %s [-sync] <host> <path>\n", argv[0]);
-    exit(1);
-}
-
-int
-main(int argc, char* argv[])
-{
-    nsresult rv;
-
-    signal(SIGSEGV, sighandler);
-
-    gTestSocketIOLog = PR_NewLogModule("TestSocketIO");
-
-    if (argc < 3)
-        usage(argv);
-
-    int i=0;
-    bool sync = false;
-    if (nsCRT::strcasecmp(argv[1], "-sync") == 0) {
-        if (argc < 4)
-            usage(argv);
-        sync = true;
-        i = 1;
-    }
-
-    char *hostName = argv[1+i];
-    char *fileName = argv[2+i];
-    int port = 80;
-
-    // Create the Event Queue for this thread...
-    nsCOMPtr<nsIEventQueueService> eventQService = 
-             do_GetService(kEventQueueServiceCID, &rv);
-    if (NS_FAILED(rv)) {
-        NS_WARNING("failed to create: event queue service!");
-        return rv;
-    }
-
-    rv = eventQService->CreateMonitoredThreadEventQueue();
-    if (NS_FAILED(rv)) {
-        NS_WARNING("failed to create: thread event queue!");
-        return rv;
-    }
-
-    eventQService->GetThreadEventQueue(NS_CURRENT_THREAD, &gEventQ);
-
-    // Create the Socket transport service...
-    nsCOMPtr<nsISocketTransportService> sts = 
-             do_GetService(kSocketTransportServiceCID, &rv);
-    if (NS_FAILED(rv)) {
-        NS_WARNING("failed to create: socket transport service!");
-        return rv;
-    }
-
-    char *buffer = PR_smprintf("GET %s HTTP/1.1" CRLF
-                               "host: %s" CRLF
-                               "user-agent: Mozilla/5.0 (X11; N; Linux 2.2.16-22smp i686; en-US; m18) Gecko/20001220" CRLF
-                               "accept: */*" CRLF
-                               "accept-language: en" CRLF
-                               "accept-encoding: gzip,deflate,compress,identity" CRLF
-                               "keep-alive: 300" CRLF
-                               "connection: keep-alive" CRLF
-                                CRLF,
-                                fileName, hostName);
-    LOG(("Request [\n%s]\n", buffer));
-
-    // Create the socket transport...
-    nsCOMPtr<nsITransport> transport;
-    rv = sts->CreateTransport(hostName, port, nullptr, 0, 0, getter_AddRefs(transport));
-    if (NS_FAILED(rv)) {
-        NS_WARNING("failed to create: socket transport!");
-        return rv;
-    }
-
-    gElapsedTime = PR_Now();
-
-    if (!sync) {
-        nsCOMPtr<nsIRequest> request;
-        rv = transport->AsyncWrite(new TestProvider(buffer), nullptr, 0, 0, 0, getter_AddRefs(request));
-        if (NS_FAILED(rv)) {
-            NS_WARNING("failed calling: AsyncWrite!");
-            return rv;
-        }
-
-        // Enter the message pump to allow the URL load to proceed.
-        while ( gKeepRunning ) {
-            PLEvent *gEvent;
-            gEventQ->WaitForEvent(&gEvent);
-            gEventQ->HandleEvent(gEvent);
-        }
-    }
-    else {
-        // synchronous write
-        {
-            nsCOMPtr<nsIOutputStream> os;
-            rv = transport->OpenOutputStream(0, 0, 0, getter_AddRefs(os));
-            if (NS_FAILED(rv)) {
-                LOG(("OpenOutputStream failed [rv=%x]\n", rv));
-                return rv;
-            }
-            rv = WriteRequest(os, buffer);
-            if (NS_FAILED(rv)) {
-                LOG(("WriteRequest failed [rv=%x]\n", rv));
-                return rv;
-            }
-        }
-        // synchronous read
-        {
-            nsCOMPtr<nsIInputStream> is;
-            rv = transport->OpenInputStream(0, 0, 0, getter_AddRefs(is));
-            if (NS_FAILED(rv)) {
-                LOG(("OpenInputStream failed [rv=%x]\n", rv));
-                return rv;
-            }
-            rv = ReadResponse(is);
-            if (NS_FAILED(rv)) {
-                LOG(("ReadResponse failed [rv=%x]\n", rv));
-                return rv;
-            }
-        }
-    }
-
-    PRTime endTime; 
-    endTime = PR_Now();
-    LOG(("Elapsed time: %d\n", (int32_t)(endTime/1000UL - gElapsedTime/1000UL)));
-
-    sts->Shutdown();
-    return 0;
-}
-
deleted file mode 100644
--- a/netwerk/test/TestSocketInput.cpp
+++ /dev/null
@@ -1,154 +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 <stdio.h>
-
-#ifdef WIN32
-#include <windows.h>
-#endif
-
-#include "nscore.h"
-#include "nsCOMPtr.h"
-#include "nsISocketTransportService.h"
-#include "nsIEventQueueService.h"
-#include "nsIServiceManager.h"
-#include "nsIComponentRegistrar.h"
-#include "nsITransport.h"
-#include "nsIRequest.h"
-#include "nsIStreamListener.h"
-#include "nsIInputStream.h"
-
-static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID);
-static NS_DEFINE_CID(kEventQueueServiceCID,      NS_EVENTQUEUESERVICE_CID);
-
-static int gKeepRunning = 1;
-
-class InputTestConsumer : public nsIStreamListener
-{
-public:
-
-  InputTestConsumer();
-  virtual ~InputTestConsumer();
-
-  // ISupports interface...
-  NS_DECL_ISUPPORTS
-
-  // IStreamListener interface...
-  NS_DECL_NSIREQUESTOBSERVER
-  NS_DECL_NSISTREAMLISTENER
-};
-
-
-InputTestConsumer::InputTestConsumer()
-{
-}
-
-InputTestConsumer::~InputTestConsumer()
-{
-}
-
-
-NS_IMPL_ISUPPORTS(InputTestConsumer, nsIRequestObserver, nsIStreamListener)
-
-
-NS_IMETHODIMP
-InputTestConsumer::OnStartRequest(nsIRequest *request, nsISupports* context)
-{
-  printf("+++ OnStartRequest +++\n");
-  return NS_OK;
-}
-
-
-NS_IMETHODIMP
-InputTestConsumer::OnDataAvailable(nsIRequest *request, 
-                                   nsISupports* context,
-                                   nsIInputStream *aIStream, 
-                                   uint64_t aSourceOffset,
-                                   uint32_t aLength)
-{
-  char buf[1025];
-  while (aLength > 0) {
-    uint32_t amt;
-    aIStream->Read(buf, 1024, &amt);
-    if (amt == 0) break;
-    buf[amt] = '\0';
-    printf(buf);
-    aLength -= amt;
-  }
-
-  return NS_OK;
-}
-
-
-NS_IMETHODIMP
-InputTestConsumer::OnStopRequest(nsIRequest *request, nsISupports* context,
-                                 nsresult aStatus)
-{
-  gKeepRunning = 0;
-  printf("+++ OnStopRequest status %x +++\n", aStatus);
-  return NS_OK;
-}
-
-
-int
-main(int argc, char* argv[])
-{
-  nsresult rv;
-
-  if (argc < 2) {
-      printf("usage: %s <host>\n", argv[0]);
-      return -1;
-  }
-
-  int port;
-  char* hostName = argv[1];
-//nsString portString(argv[2]);
-
-//port = portString.ToInteger(&rv);
-  port = 13;
-  {
-    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);
-
-    // Create the Event Queue for this thread...
-    nsCOMPtr<nsIEventQueueService> eventQService =
-             do_GetService(kEventQueueServiceCID, &rv);
-    if (NS_FAILED(rv)) return rv;
-
-    nsCOMPtr<nsIEventQueue> eventQ;
-    rv = eventQService->GetThreadEventQueue(NS_CURRENT_THREAD, getter_AddRefs(eventQ));
-    if (NS_FAILED(rv)) return rv;
-
-    nsCOMPtr<nsISocketTransportService> sts =
-             do_GetService(kSocketTransportServiceCID, &rv);
-    if (NS_FAILED(rv)) return rv;
-
-    nsITransport* transport;
-
-    rv = sts->CreateTransport(hostName, port, nullptr, 0, 0, &transport);
-    if (NS_SUCCEEDED(rv)) {
-      nsCOMPtr<nsIRequest> request;
-      transport->AsyncRead(new InputTestConsumer, nullptr, 0, -1, 0, getter_AddRefs(request));
-
-      NS_RELEASE(transport);
-    }
-
-    // Enter the message pump to allow the URL load to proceed.
-    while ( gKeepRunning ) {
-      PLEvent *gEvent;
-      eventQ->WaitForEvent(&gEvent);
-      eventQ->HandleEvent(gEvent);
-    }
-
-  } // 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/TestURLManipulation.html
+++ /dev/null
@@ -1,130 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
-<head>
-  <title>URL manipulation</title>
-  <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
-
-  <script type="text/javascript">
-    var gIOService = null;
-    function getIOService()
-    {
-      if (gIOService)
-        return gIOService;
-
-      try {
-        gIOService = Components.classes["@mozilla.org/network/io-service;1"]
-                            .getService(Components.interfaces.nsIIOService);
-      } catch(e) { dump("problem creating nsIURL for: "+inURLString+"\n"); }
-
-      return gIOService;
-   }
-
-    function getnsIURL(inURLString)
-    {
-      var URL = null;
-      var ioserv = getIOService();
-      try {
-        var URI = ioserv.newURI(inURLString, "", null);
-        URL = URI.QueryInterface(Components.interfaces.nsIURL);
-      } catch(e) { dump("problem creating nsIURL for: "+inURLString+"\n"); }
-      return URL;
-    }
-
-    function getCommonSpec()
-    {
-      var URL1 = getnsIURL(document.foo.baseEdit.value);
-      var URL2 = getnsIURL(document.foo.compareEdit.value);
-      var result = "";
-      try {
-        result = URL1.getCommonBaseSpec(URL2);
-      } catch(e) { dump("problem with getCommonSpec ("+e+")\n"); }
-      document.foo.resultEdit.value = result;
-    }
-
-    function getRelativeSpec()
-    {
-      var URL1 = getnsIURL(document.foo.baseEdit.value);
-      var URL2 = getnsIURL(document.foo.compareEdit.value);
-      var result = "";
-      try {
-        result = URL1.getRelativeSpec(URL2);
-      } catch(e) { dump("problem with getRelativeSpec ("+e+")\n"); }
-      document.foo.resultEdit.value = result;
-    }
-
-    function doResolve()
-    {
-      var URL = getnsIURL(document.foo.baseEdit.value);
-      var result = "";
-      try {
-        result = URL.resolve(document.foo.resultEdit.value);
-      } catch(e) { dump("problem with getRelativeSpec ("+e+")\n"); }
-      document.foo.compareEdit.value = result;
-    }
-  </script>
-</head>
-<body>
-<h1>testing of URL manipulation:</h1>
-<p>
-  <form name="foo"> 
-    <p>
-    <label for="baseEdit">base url (absolute)</label><br>
-    <input type="input" name="baseEdit" size="80" value="http://www.mozilla.org/">
-
-    <p>
-    <label for="compareEdit">comparison uri (absolute)</label><br>
-    <input type="input" name="compareEdit" size="80">
-
-    <p>
-    <label for="resultEdit">resolved url</label><br>
-    <input type="input" name="resultEdit" size="80">
-
-    <p>
-    <input type="button" onclick="getCommonSpec();" value="Get Common Spec">
-    <input type="button" onclick="getRelativeSpec();" value="Get Relative Spec">
-    <input type="button" onclick="doResolve();" value="Resolve">
-    <h5> note: results from "resolve" are placed in "comparison uri" edit field</h5>
-  </form>
-<p>
-<br>
-
-<h3>notes for testing</h3>
-different types of uris:<br>
-<ul>
-  <li>about:</li>
-  <li>about:blank</li>
-  <li>mailbox://nsmail-2.mcom.com/xxx</li>
-  <li>mailto:brade@netscape.com)</li>
-  <li>junk</li>
-  <li>http://foo/</li>
-  <li>http://foo.com/</li>
-  <li>https://foo.com/</li>
-  <li>ftp://ftp.mozilla.org/</li>
-  <li>http://foo.com:8080/</li>
-  <li>http://brade@foo.com/</li>
-  <li>http://brade:password@foo.com/</li>
-  <li>http://brade:@foo.com:8080/</li>
-  <li>file:///</li>
-  <li>file:///Quest/Desktop%20Folder/test.html</li>
-</ul>
-other variations:<br>
-<ul>
-  <li>sub-directories on above list</li>
-  <li>files on above list</li>
-  <li>sub-directories and files on above list<br>
-  </li>
-  <li>directories which don't end in a '/'</li>
-  <li>files with queries</li>
-  <li>files with no extension</li>
-  <li>files with references</li>
-  <li>files with params</li>
-  <li>other schemes (chrome, ldap, news, finger, etc.)<br>
-  </li>
-</ul>
-<br>
-This should be true:<br>
-&nbsp; resultString = baseURL.getRelativeSpec(URL);<br>
-&lt;==&gt;<br>
-&nbsp; baseURL.resolve(resultString) == URL.spec;<br>
-</body>
-</html>
deleted file mode 100644
--- a/netwerk/test/TestWriteSpeed.cpp
+++ /dev/null
@@ -1,116 +0,0 @@
-/* -*- 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 "prio.h"
-#include "prinrval.h"
-#include "prmem.h"
-#include <stdio.h>
-#include <math.h>
-
-void 
-NS_MeanAndStdDev(double n, double sumOfValues, double sumOfSquaredValues,
-                 double *meanResult, double *stdDevResult)
-{
-  double mean = 0.0, var = 0.0, stdDev = 0.0;
-  if (n > 0.0 && sumOfValues >= 0) {
-    mean = sumOfValues / n;
-    double temp = (n * sumOfSquaredValues) - (sumOfValues * sumOfValues);
-    if (temp < 0.0 || n <= 1)
-      var = 0.0;
-    else
-      var = temp / (n * (n - 1));
-    // for some reason, Windows says sqrt(0.0) is "-1.#J" (?!) so do this:
-    stdDev = var != 0.0 ? sqrt(var) : 0.0;
-  }
-  *meanResult = mean;
-  *stdDevResult = stdDev;
-}
-
-int
-Test(const char* filename, int32_t minSize, int32_t maxSize, 
-     int32_t sizeIncrement, int32_t iterations)
-{
-    fprintf(stdout, "      size  write:    mean     stddev      iters  total:    mean     stddev      iters\n");
-    for (int32_t size = minSize; size <= maxSize; size += sizeIncrement) {
-        // create a buffer of stuff to write
-        char* buf = (char*)PR_Malloc(size);
-        if (buf == nullptr)
-            return -1;
-
-        // initialize it with a pattern
-        int32_t i;
-        char hex[] = "0123456789ABCDEF";
-        for (i = 0; i < size; i++) {
-            buf[i] = hex[i & 0xF];
-        }
-
-        double writeCount = 0, writeRate = 0, writeRateSquared = 0;
-        double totalCount = 0, totalRate = 0, totalRateSquared = 0;
-        for (i = 0; i < iterations; i++) {
-            PRIntervalTime start = PR_IntervalNow();
-
-            char name[1024];
-            sprintf(name, "%s_%d", filename, i);
-            PRFileDesc* fd = PR_Open(name, PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE, 0664);
-            if (fd == nullptr)
-                return -1;
-
-            PRIntervalTime writeStart = PR_IntervalNow();
-            int32_t rv = PR_Write(fd, buf, size);
-            if (rv < 0) return rv;
-            if (rv != size) return -1;
-            PRIntervalTime writeStop = PR_IntervalNow();
-
-            PRStatus st = PR_Close(fd);
-            if (st == PR_FAILURE) return -1; 
-
-            PRIntervalTime stop = PR_IntervalNow();
-
-            PRIntervalTime writeTime = PR_IntervalToMilliseconds(writeStop - writeStart);
-            if (writeTime > 0) {
-                double wr = size / writeTime;
-                writeRate += wr;
-                writeRateSquared += wr * wr;
-                writeCount++;
-            }
-
-            PRIntervalTime totalTime = PR_IntervalToMilliseconds(stop - start);
-            if (totalTime > 0) {
-                double t = size / totalTime;
-                totalRate += t;
-                totalRateSquared += t * t;
-                totalCount++;
-            }
-        }
-
-        PR_Free(buf);
-
-        double writeMean, writeStddev;
-        double totalMean, totalStddev;
-        NS_MeanAndStdDev(writeCount, writeRate, writeRateSquared,
-                         &writeMean, &writeStddev);
-        NS_MeanAndStdDev(totalCount, totalRate, totalRateSquared,
-                         &totalMean, &totalStddev);
-        fprintf(stdout, "%10d      %10.2f %10.2f %10d      %10.2f %10.2f %10d\n",
-                size, writeMean, writeStddev, (int32_t)writeCount, 
-                totalMean, totalStddev, (int32_t)totalCount);
-    }
-    return 0;
-}
-
-int
-main(int argc, char* argv[])
-{
-    if (argc != 5) {
-        printf("usage: %s <min buf size (K)> <max buf size (K)> <size increment (K)> <iterations>\n", argv[0]);
-        return -1;
-    }
-    Test("y:\\foo",
-         atoi(argv[1]) * 1024,
-         atoi(argv[2]) * 1024,
-         atoi(argv[3]) * 1024,
-         atoi(argv[4]));
-    return 0;
-}
--- a/netwerk/test/moz.build
+++ b/netwerk/test/moz.build
@@ -21,17 +21,12 @@ UNIFIED_SOURCES += [
     'TestUDPSocket.cpp',
 ]
 
 if CONFIG['OS_TARGET'] == 'WINNT':
     UNIFIED_SOURCES += [
         'TestNamedPipeService.cpp',
     ]
 
-RESOURCE_FILES += [
-    'urlparse.dat',
-    'urlparse_unx.dat',
-]
-
 include('/ipc/chromium/chromium-config.mozbuild')
 
 if CONFIG['GNU_CXX']:
     CXXFLAGS += ['-Wno-shadow']
deleted file mode 100644
--- a/netwerk/test/sites.txt
+++ /dev/null
@@ -1,257 +0,0 @@
-http://www.yahoo.com/
-http://www.netscape.com/
-http://www.microsoft.com/
-http://www.excite.com/
-http://www.mckinley.com/
-http://www.city.net/
-http://www.webcrawler.com/
-http://www.mirabilis.com/
-http://www.infoseek.com/
-http://www.pathfinder.com/
-http://www.warnerbros.com/
-http://www.cnn.com/
-http://www.altavista.digital.com/
-http://www.altavista.com/
-http://www.usatoday.com/
-http://www.disney.com/
-http://www.starwave.com/
-http://www.hotwired.com/
-http://www.hotbot.com/
-http://www.lycos.com/
-http://www.pointcom.com/
-http://www.cnet.com/
-http://www.search.com/
-http://www.news.com/
-http://www.download.com/
-http://www.geocities.com/
-http://www.aol.com/
-http://members.aol.com/
-http://www.imdb.com/
-http://uk.imdb.com/
-http://www.macromedia.com/
-http://www.infobeat.com/
-http://www.fxweb.com/
-http://www.whowhere.com/
-http://www.real.com/
-http://www.sportsline.com/
-http://www.dejanews.com/
-http://www.the-park.com/
-http://www.cmpnet.com/
-http://www.go2net.com/
-http://www.metacrawler.com/
-http://www.playsite.com/
-http://www.stocksite.com/
-http://www.sony.com/
-http://www.music.sony.com/
-http://www.station.sony.com/
-http://www.scea.sony.com/
-http://www.infospace.com/
-http://www.zdnet.com/
-http://www.hotfiles.com/
-http://www.chathouse.com/
-http://www.looksmart.com/
-http://www.iamginegames.com/
-http://www.macaddict.com/
-http://www.rsac.org/
-http://www.apple.com/
-http://www.beseen.com/
-http://www.dogpile.com/
-http://www.xoom.com/
-http://www.tucows.com/
-http://www.freethemes.com/
-http://www.winfiles.com/
-http://www.vservers.com/
-http://www.mtv.com/
-http://www.the-xfiles.com/
-http://www.datek.com/
-http://www.cyberthrill.com/
-http://www.surplusdirect.com/
-http://www.tomshardware.com/
-http://www.bigyellow.com/
-http://www.100hot.com/
-http://www.messagemates.com/
-http://www.onelist.com/
-http://www.bluemountain.com/
-http://www.ea.com/
-http://www.bullfrog.co.uk/
-http://www.travelocity.com/
-http://www.ibm.com/
-http://www.bigcharts.com/
-http://www.davesclassics.com/
-http://www.goto.com/
-http://www.weather.com/
-http://www.gamespot.com/
-http://www.bloomberg.com/
-http://www.winzip.com/
-http://www.filez.com/
-http://www.westwood.com/
-http://www.internet.com/
-http://www.cardmaster.com/
-http://www.creaf.com/
-http://netaddress.usa.net/
-http://www.occ.com/
-http://www.as.org/
-http://www.amazon.com/
-http://www.drudgereport.com/
-http://www.hardradio.com/
-http://www.intel.com/
-http://www.mp3.com/
-http://www.ebay.com/
-http://www.msn.com/
-http://www.fifa.com/
-http://www.attitude.com/
-http://www.happypuppy.com/
-http://www.gamesdomain.com/
-http://www.onsale.com/
-http://www.tm.com/
-http://www.xlnc1.com/
-http://www.greatsports.com/
-http://www.discovery.com/
-http://www.nai.com/
-http://www.nasa.gov/
-http://www.ogr.com/
-http://www.warzone.com/
-http://www.gamestats.com/
-http://www.winamp.com/
-http://java.sun.com/
-http://www.hp.com/
-http://www.cdnow.com/
-http://www.nytimes.com/
-http://www.majorleaguebaseball.com/
-http://www.washingtonpost.com/
-http://www.planetquake.com/
-http://www.wsj.com/
-http://www.slashdot.org/
-http://www.adobe.com/
-http://www.quicken.com/
-http://www.talkcity.com/
-http://www.developer.com/
-http://www.mapquest.com/
-http://www.yahoo.com/
-http://www.pathfinder.com/
-http://www.msn.com/
-http://www.fifa.com/
-http://www.attitude.com/
-http://www.happypuppy.com/
-http://www.gamesdomain.com/
-http://www.onsale.com/
-http://www.tm.com/
-http://www.xlnc1.com/
-http://www.greatsports.com/
-http://www.discovery.com/
-http://www.warnerbros.com/
-http://www.nai.com/
-http://www.nasa.gov/
-http://www.ogr.com/
-http://www.warzone.com/
-http://www.gamestats.com/
-http://www.winamp.com/
-http://java.sun.com/
-http://www.hp.com/
-http://www.cdnow.com/
-http://www.nytimes.com/
-http://www.majorleaguebaseball.com/
-http://www.planetquake.com/
-http://www.wsj.com/
-http://www.slashdot.org/
-http://www.adobe.com/
-http://www.quicken.com/
-http://www.talkcity.com/
-http://www.developer.com/
-http://www.mapquest.com/
-http://www.altavista.digital.com/
-http://www.altavista.com/
-http://www.usatoday.com/
-http://www.disney.com/
-http://www.starwave.com/
-http://www.hotwired.com/
-http://www.hotbot.com/
-http://www.netscape.com/
-http://www.lycos.com/
-http://www.pointcom.com/
-http://www.cnet.com/
-http://www.search.com/
-http://www.news.com/
-http://www.download.com/
-http://www.geocities.com/
-http://www.imdb.com/
-http://www.microsoft.com/
-http://uk.imdb.com/
-http://www.macromedia.com/
-http://www.infobeat.com/
-http://www.fxweb.com/
-http://www.whowhere.com/
-http://www.real.com/
-http://www.sportsline.com/
-http://www.dejanews.com/
-http://www.the-park.com/
-http://www.cmpnet.com/
-http://www.excite.com/
-http://www.go2net.com/
-http://www.metacrawler.com/
-http://www.playsite.com/
-http://www.stocksite.com/
-http://www.infospace.com/
-http://www.zdnet.com/
-http://www.mckinley.com/
-http://www.hotfiles.com/
-http://www.chathouse.com/
-http://www.looksmart.com/
-http://www.iamginegames.com/
-http://www.macaddict.com/
-http://www.rsac.org/
-http://www.apple.com/
-http://www.beseen.com/
-http://www.dogpile.com/
-http://www.xoom.com/
-http://www.city.net/
-http://www.tucows.com/
-http://www.freethemes.com/
-http://www.winfiles.com/
-http://www.vservers.com/
-http://www.mtv.com/
-http://www.the-xfiles.com/
-http://www.datek.com/
-http://www.cyberthrill.com/
-http://www.surplusdirect.com/
-http://www.tomshardware.com/
-http://www.webcrawler.com/
-http://www.bigyellow.com/
-http://www.100hot.com/
-http://www.messagemates.com/
-http://www.onelist.com/
-http://www.bluemountain.com/
-http://www.ea.com/
-http://www.bullfrog.co.uk/
-http://www.travelocity.com/
-http://www.ibm.com/
-http://www.bigcharts.com/
-http://www.mirabilis.com/
-http://www.davesclassics.com/
-http://www.goto.com/
-http://www.weather.com/
-http://www.gamespot.com/
-http://www.bloomberg.com/
-http://www.winzip.com/
-http://www.filez.com/
-http://www.westwood.com/
-http://www.internet.com/
-http://www.cardmaster.com/
-http://www.infoseek.com/
-http://www.creaf.com/
-http://netaddress.usa.net/
-http://www.occ.com/
-http://www.as.org/
-http://www.amazon.com/
-http://www.drudgereport.com/
-http://www.hardradio.com/
-http://www.intel.com/
-http://www.mp3.com/
-http://www.ebay.com/
-http://www.aol.com/
-http://www.cnn.com/
-http://www.music.sony.com/
-http://www.scea.sony.com/
-http://www.sony.com/
-http://www.station.sony.com/
-http://www.washingtonpost.com/
deleted file mode 100644
--- a/netwerk/test/urlparse.dat
+++ /dev/null
@@ -1,103 +0,0 @@
-# Any blank lines and those beginning with # are comments and 
-# ignored. To add additional test cases that could potentially 
-# break URL parsing in mozilla add the input URL on a new line 
-# and follow it with the expected output for the standard URL 
-# parser and one line for the case when the URL is really 
-# created. Then run urltest with the -std option and without it 
-# on this file and hopefully the expected output should match 
-# the one from the program. 
-#   - Gagan Saksena 03/28/00
-#
-
-http://username:password@hostname.com:80/pathname/./more/stuff/../path
-http,username,password,hostname.com,80,/pathname/more/,path,,,,,http://username:password@hostname.com:80/pathname/more/path
-http,username,password,hostname.com,80,/pathname/more/,path,,,,,http://username:password@hostname.com/pathname/more/path
-
-username@host:8080/path
-,username,,host,8080,/,path,,,,,username@host:8080/path
-Can not create URL
-
-http://gagan/
-http,,,gagan,-1,/,,,,,,http://gagan/
-http,,,gagan,-1,/,,,,,,http://gagan/
-
-scheme:host/netlib
-scheme,,,host,-1,/,netlib,,,,,scheme://host/netlib
-Can not create URL
-
-mailbox:///foo
-mailbox,,,,-1,/,foo,,,,,mailbox:///foo
-mailbox,,,,-1,/,foo,,,,,mailbox:///foo
-
-scheme:user@hostname.edu:80/pathname
-scheme,user,,hostname.edu,80,/,pathname,,,,,scheme://user@hostname.edu:80/pathname
-Can not create URL
-
-http://username:password@hostname:80/pathname
-http,username,password,hostname,80,/,pathname,,,,,http://username:password@hostname:80/pathname
-http,username,password,hostname,80,/,pathname,,,,,http://username:password@hostname/pathname
-
-http://username:password@hostname:8080/path/filebasename.fileextension;param?query#ref
-http,username,password,hostname,8080,/path/,filebasename,fileextension,param,query,ref,http://username:password@hostname:8080/path/filebasename.fileextension;param?query#ref
-http,username,password,hostname,8080,/path/,filebasename,fileextension,param,query,ref,http://username:password@hostname:8080/path/filebasename.fileextension;param?query#ref
-
-resource:/pathname
-resource,,,,-1,/,pathname,,,,,resource:///pathname
-resource,,,,-1,/,pathname,,,,,resource:///pathname
-
-ftp://uname%here.com:pwd@there.com/aPath/a.html
-ftp,uname%here.com,pwd,there.com,-1,/aPath/,a,html,,,,ftp://uname%here.com:pwd@there.com/aPath/a.html
-ftp,uname%here.com,pwd,there.com,-1,/aPath/,a,html,,,,ftp://uname%here.com:pwd@there.com/aPath/a.html
-
-http://www.inf.bme.hu?foo=bar
-http,,,www.inf.bme.hu,-1,/,,,,foo=bar,,http://www.inf.bme.hu/?foo=bar
-http,,,www.inf.bme.hu,-1,/,,,,foo=bar,,http://www.inf.bme.hu/?foo=bar
-
-http://test.com/aPath/a.html#/1/2
-http,,,test.com,-1,/aPath/,a,html,,,/1/2,http://test.com/aPath/a.html#/1/2
-http,,,test.com,-1,/aPath/,a,html,,,/1/2,http://test.com/aPath/a.html#/1/2
-
-http://user:pass@ipaddres:2/get?foo/something
-http,user,pass,ipaddres,2,/,get,,,foo/something,,http://user:pass@ipaddres:2/get?foo/something
-http,user,pass,ipaddres,2,/,get,,,foo/something,,http://user:pass@ipaddres:2/get?foo/something
-
-# testing different versions of http urls
-http:www.mozilla.org
-http,,,www.mozilla.org,-1,/,,,,,,http://www.mozilla.org/
-http,,,www.mozilla.org,-1,/,,,,,,http://www.mozilla.org/
-
-http:/www.mozilla.org
-http,,,,-1,/,www.mozilla,org,,,,http:///www.mozilla.org
-http,,,www.mozilla.org,-1,/,,,,,,http://www.mozilla.org/
-
-# testing cap letters (23927)
-HtTp://wWw.mozilLa.org
-http,,,www.mozilla.org,-1,/,,,,,,http://www.mozilla.org/
-http,,,www.mozilla.org,-1,/,,,,,,http://www.mozilla.org/
-
-# testing spaces (15150)
-go.com.au?mozilla bug reports
-,,,go.com.au,-1,/,,,,mozilla%20bug%20reports,,go.com.au/?mozilla%20bug%20reports
-Can not create URL
-
-http://go.com.au?mozilla bug reports
-http,,,go.com.au,-1,/,,,,mozilla%20bug%20reports,,http://go.com.au/?mozilla%20bug%20reports
-http,,,go.com.au,-1,/,,,,mozilla%20bug%20reports,,http://go.com.au/?mozilla%20bug%20reports
-
-# testing for multiple params (14801)
-http://ad.doubleclick.net/ad/cbsmw.button.com/SIDEBAR_BUTTONS;sz=88x31;kw=DBCC;tile=4;ord=1864641213378545414
-http,,,ad.doubleclick.net,-1,/ad/cbsmw.button.com/,SIDEBAR_BUTTONS,,sz=88x31;kw=DBCC;tile=4;ord=1864641213378545414,,,http://ad.doubleclick.net/ad/cbsmw.button.com/SIDEBAR_BUTTONS;sz=88x31;kw=DBCC;tile=4;ord=1864641213378545414
-http,,,ad.doubleclick.net,-1,/ad/cbsmw.button.com/,SIDEBAR_BUTTONS,,sz=88x31;kw=DBCC;tile=4;ord=1864641213378545414,,,http://ad.doubleclick.net/ad/cbsmw.button.com/SIDEBAR_BUTTONS;sz=88x31;kw=DBCC;tile=4;ord=1864641213378545414
-
-fxqn:/us/va/reston/cnri/ietf/24/asdf%*.fred
-fxqn,,,,-1,/us/va/reston/cnri/ietf/24/,asdf%*,fred,,,,fxqn:///us/va/reston/cnri/ietf/24/asdf%*.fred
-Can not create URL
-
-news:3B5C133C.2080505@foobar.net
-news,3B5C133C.2080505,,foobar.net,-1,/,,,,,,news://3B5C133C.2080505@foobar.net/
-news,3B5C133C.2080505,,foobar.net,-1,/,,,,,,news://3B5C133C.2080505@foobar.net/
-
-http://host/path/%2E%2E/file%2Ehtml
-http,,,host,-1,/,file%2Ehtml,,,,,http://host/file%2Ehtml
-http,,,host,-1,/,file%2Ehtml,,,,,http://host/file%2Ehtml
-
deleted file mode 100644
--- a/netwerk/test/urlparse_mac.dat
+++ /dev/null
@@ -1,14 +0,0 @@
-# Any blank lines and those beginning with # are comments and 
-# ignored. To add additional test cases that could potentially 
-# break URL parsing in mozilla add the input URL on a new line 
-# and follow it with the expected output for the standard URL 
-# parser and one line for the case when the URL is really 
-# created. Then run urltest with the -std option and without it 
-# on this file and hopefully the expected output should match 
-# the one from the program. 
-#   - Gagan Saksena 03/28/00
-# 
-# This version is specifically for the Mac platform.
-#
-
-# testing different versions of file urls
deleted file mode 100644
--- a/netwerk/test/urlparse_unx.dat
+++ /dev/null
@@ -1,34 +0,0 @@
-# Any blank lines and those beginning with # are comments and 
-# ignored. To add additional test cases that could potentially 
-# break URL parsing in mozilla add the input URL on a new line 
-# and follow it with the expected output for the standard URL 
-# parser and one line for the case when the URL is really 
-# created. Then run urltest with the -std option and without it 
-# on this file and hopefully the expected output should match 
-# the one from the program. 
-#   - Gagan Saksena 03/28/00
-#
-# This version is specifically *not* for PC platforms like Windows or OS/2.
-# It's testcases for the file protocol target a unix-like filesystem.
-
-# testing different versions of file urls
-file:home
-file,,,home,-1,/,,,,,,file://home/
-file,,,,-1,/,home,,,,,file:///home
-
-file:/home
-file,,,,-1,/,home,,,,,file:///home
-file,,,,-1,/,home,,,,,file:///home
-
-file://home
-file,,,home,-1,/,,,,,,file://home/
-file,,,home,-1,/,,,,,,file://home/
-
-file:///home
-file,,,,-1,/,home,,,,,file:///home
-file,,,,-1,/,home,,,,,file:///home
-
-# testing UNC filepaths
-file:////server/path
-file,,,,-1,//server/,path,,,,,file:////server/path
-file,,,,-1,//server/,path,,,,,file:////server/path
deleted file mode 100644
--- a/netwerk/test/urlparse_win.dat
+++ /dev/null
@@ -1,60 +0,0 @@
-# Any blank lines and those beginning with # are comments and 
-# ignored. To add additional test cases that could potentially 
-# break URL parsing in mozilla add the input URL on a new line 
-# and follow it with the expected output for the standard URL 
-# parser and one line for the case when the URL is really 
-# created. Then run urltest with the -std option and without it 
-# on this file and hopefully the expected output should match 
-# the one from the program. 
-#   - Gagan Saksena 03/28/00
-# 
-# This version is specifically for PC platforms like Windows or OS/2.
-# It has testcases for the file protocol targeting typical 
-# drive:/path filesystems
-#
-
-# testing different versions of file urls
-file:c:
-file,,,,-1,/,c:,,,,,file:///c%3A
-file,,,,-1,/c:/,,,,,,file:///c:/
-
-file:c:/
-file,,,,-1,/c:/,,,,,,file:///c:/
-file,,,,-1,/c:/,,,,,,file:///c:/
-
-file:/c:/
-file,,,,-1,/c:/,,,,,,file:///c:/
-file,,,,-1,/c:/,,,,,,file:///c:/
-
-file://c:/
-file,,,,-1,/c:/,,,,,,file:///c:/
-file,,,,-1,/c:/,,,,,,file:///c:/
-
-file:///c:/
-file,,,,-1,/c:/,,,,,,file:///c:/
-file,,,,-1,/c:/,,,,,,file:///c:/
-
-# testing UNC filepaths
-file:server/path
-file,,,server,-1,/,path,,,,,file://server/path
-file,,,,-1,///server/,path,,,,,file://///server/path
-
-file:/server/path
-file,,,,-1,/server/,path,,,,,file:///server/path
-file,,,,-1,///server/,path,,,,,file://///server/path
-
-file://server/path
-file,,,server,-1,/,path,,,,,file://server/path
-file,,,server,-1,///,path,,,,,file://server///path
-
-file:///server/path
-file,,,,-1,/server/,path,,,,,file:///server/path
-file,,,,-1,///server/,path,,,,,file://///server/path
-
-file:////server/path
-file,,,,-1,//server/,path,,,,,file:////server/path
-file,,,,-1,///server/,path,,,,,file://///server/path
-
-file://///server/path
-file,,,,-1,///server/,path,,,,,file://///server/path
-file,,,,-1,///server/,path,,,,,file://///server/path
deleted file mode 100644
--- a/netwerk/test/urltests.dat
+++ /dev/null
@@ -1,43 +0,0 @@
-# Any blank lines and those beginning with # are comments and 
-# ignored. To add additional test cases that could potentially 
-# break URL parsing in mozilla add the input URL on a new line 
-# and follow it with the expected output. Then run urltest on 
-# this file and hopefully the expected output should match the 
-# one from the program. 
-#   - Gagan Saksena 03/28/00
-
-http://username:password@hostname.com:80/pathname/./more/stuff/../path
-http,username:password,hostname.com,80,,/pathname/more/path
-
-username@host:8080/path
-,username,host,8080,,/path
-
-http://gagan/
-http,,gagan,-1,,/
-
-scheme:host/netlib
-scheme,,host,-1,,/netlib
-
-mailbox:///foo
-mailbox,,,-1,,/foo
-
-scheme:user@hostname.edu:80/pathname
-scheme,user,hostname.edu,80,,/pathname
-
-http://username:password@hostname:80/pathname
-http,username:password,hostname,80,,/pathname
-
-resource:/pathname
-resource,,,-1,,/pathname
-
-ftp://uname%here.com:pwd@there.com/aPath/a.html
-ftp,uname%here.com:pwd,there.com,-1,,/aPath/a.html
-
-http://www.inf.bme.hu?foo=bar
-http,,www.inf.bme.hu,-1,foo=bar,/?foo=bar
-
-http://test.com/aPath/a.html#/1/2
-http,,test.com,-1,,/aPath/a.html#/1/2
-
-http://user:pass@ipaddres:2/get?foo/something
-http,user:pass,ipaddres,2,foo/something,/get?foo/something
--- a/old-configure.in
+++ b/old-configure.in
@@ -5313,18 +5313,16 @@ AC_SUBST(MOZ_APP_VERSION_DISPLAY)
 AC_SUBST(MOZ_APP_MAXVERSION)
 AC_DEFINE_UNQUOTED(FIREFOX_VERSION,$FIREFOX_VERSION)
 AC_SUBST(FIREFOX_VERSION)
 AC_SUBST(MOZ_UA_OS_AGNOSTIC)
 if test -n "$MOZ_UA_OS_AGNOSTIC"; then
   AC_DEFINE(MOZ_UA_OS_AGNOSTIC)
 fi
 
-AC_SUBST(MOZ_APP_STATIC_INI)
-
 AC_SUBST(MOZ_PKG_SPECIAL)
 AC_SUBST(MOZ_SIMPLE_PACKAGE_NAME)
 
 AC_SUBST(MOZILLA_OFFICIAL)
 if test "$MOZILLA_OFFICIAL"; then
     AC_DEFINE(MOZILLA_OFFICIAL)
     # Build revisions should always be present in official builds
     MOZ_INCLUDE_SOURCE_INFO=1
--- a/python/mozbuild/mozbuild/configure/constants.py
+++ b/python/mozbuild/mozbuild/configure/constants.py
@@ -35,17 +35,17 @@ Kernel = EnumString.subclass(
     'Linux',
     'NetBSD',
     'OpenBSD',
     'WINNT',
 )
 
 CPU_bitness = {
     'aarch64': 64,
-    'Alpha': 32,
+    'Alpha': 64,
     'arm': 32,
     'hppa': 32,
     'ia64': 64,
     'mips32': 32,
     'mips64': 64,
     'ppc': 32,
     'ppc64': 64,
     's390': 32,
--- a/testing/mochitest/runtests.py
+++ b/testing/mochitest/runtests.py
@@ -32,16 +32,17 @@ import sys
 import tempfile
 import time
 import traceback
 import urllib2
 import uuid
 import zipfile
 import bisection
 
+from ctypes.util import find_library
 from datetime import datetime
 from manifestparser import TestManifest
 from manifestparser.filters import (
     chunk_by_dir,
     chunk_by_runtime,
     chunk_by_slice,
     pathprefix,
     subsuite,
@@ -622,17 +623,17 @@ def checkAndConfigureV4l2loopback(device
     Determine if a given device path is a v4l2loopback device, and if so
     toggle a few settings on it via fcntl. Very linux-specific.
 
     Returns (status, device name) where status is a boolean.
     '''
     if not mozinfo.isLinux:
         return False, ''
 
-    libc = ctypes.cdll.LoadLibrary('libc.so.6')
+    libc = ctypes.cdll.LoadLibrary(find_library("c"))
     O_RDWR = 2
     # These are from linux/videodev2.h
 
     class v4l2_capability(ctypes.Structure):
         _fields_ = [
             ('driver', ctypes.c_char * 16),
             ('card', ctypes.c_char * 32),
             ('bus_info', ctypes.c_char * 32),
--- a/testing/mozbase/mozinfo/mozinfo/mozinfo.py
+++ b/testing/mozbase/mozinfo/mozinfo/mozinfo.py
@@ -10,17 +10,17 @@
 
 from __future__ import absolute_import
 
 import os
 import platform
 import re
 import sys
 from .string_version import StringVersion
-
+from ctypes.util import find_library
 
 # keep a copy of the os module since updating globals overrides this
 _os = os
 
 
 class unknown(object):
     """marker class for unknown information"""
 
@@ -145,17 +145,17 @@ info.update({'processor': processor,
              'bits': int(bits),
              })
 
 if info['os'] == 'linux':
     import ctypes
     import errno
     PR_SET_SECCOMP = 22
     SECCOMP_MODE_FILTER = 2
-    ctypes.CDLL("libc.so.6", use_errno=True).prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, 0)
+    ctypes.CDLL(find_library("c"), use_errno=True).prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, 0)
     info['has_sandbox'] = ctypes.get_errno() == errno.EFAULT
 else:
     info['has_sandbox'] = True
 
 # standard value of choices, for easy inspection
 choices = {'os': ['linux', 'bsd', 'win', 'mac', 'unix'],
            'bits': [32, 64],
            'processor': ['x86', 'x86_64', 'ppc']}
--- a/toolkit/components/extensions/ext-webRequest.js
+++ b/toolkit/components/extensions/ext-webRequest.js
@@ -39,17 +39,17 @@ function WebRequestEventManager(context,
       let data2 = {
         requestId: data.requestId,
         url: data.url,
         originUrl: data.originUrl,
         method: data.method,
         tabId: browserData.tabId,
         type: data.type,
         timeStamp: Date.now(),
-        frameId: ExtensionManagement.getFrameId(data.windowId),
+        frameId: data.type == "main_frame" ? 0 : ExtensionManagement.getFrameId(data.windowId),
         parentFrameId: ExtensionManagement.getParentFrameId(data.parentWindowId, data.windowId),
       };
 
       const maybeCached = ["onResponseStarted", "onBeforeRedirect", "onCompleted", "onErrorOccurred"];
       if (maybeCached.includes(eventName)) {
         data2.fromCache = !!data.fromCache;
       }
 
--- a/toolkit/components/extensions/test/mochitest/head_webrequest.js
+++ b/toolkit/components/extensions/test/mochitest/head_webrequest.js
@@ -183,16 +183,19 @@ function background(events) {
           browser.test.assertEq(expected.test.requestId, details.requestId, "redirects will keep the same requestId");
         } else {
           // Save any values we want to validate in later events.
           expected.test.requestId = details.requestId;
           expected.test.tabId = details.tabId;
         }
         // Tests we don't need to do every event.
         browser.test.assertTrue(details.type.toUpperCase() in browser.webRequest.ResourceType, `valid resource type ${details.type}`);
+        if (details.type == "main_frame") {
+          browser.test.assertEq(0, details.frameId, "frameId is zero when type is main_frame bug 1329299");
+        }
       } else {
         // On events after onBeforeRequest, check the previous values.
         browser.test.assertEq(expected.test.requestId, details.requestId, "correct requestId");
         browser.test.assertEq(expected.test.tabId, details.tabId, "correct tabId");
       }
       if (name == "onBeforeSendHeaders") {
         if (expected.headers && expected.headers.request) {
           result.requestHeaders = processHeaders("request", expected, details);