Backed out 3 changesets (bug 1488973) for causing TV failures on browser_resource_uri.js
authorNarcis Beleuzu <nbeleuzu@mozilla.com>
Wed, 24 Oct 2018 10:49:10 +0300
changeset 491076 deb666fd309c96f986823290ffbb55f6dc4ca492
parent 491075 506fe32bb763e18d7981378c79d59c5b214a2f3e
child 491077 daf8a3b98eee4a27c5691ecea4d4699dfc33cd31
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
bugs1488973
milestone65.0a1
backs out6eab8a1b17ce4f7b2986d2863f889257240ca836
c06b2c594294b667b6e9cfc05e6fa7dbb69eb41d
819df51e30836ba46efe72d91654a3c6b9365f02
Backed out 3 changesets (bug 1488973) for causing TV failures on browser_resource_uri.js Backed out changeset 6eab8a1b17ce (bug 1488973) Backed out changeset c06b2c594294 (bug 1488973) Backed out changeset 819df51e3083 (bug 1488973)
dom/base/nsDocument.cpp
dom/base/nsINode.cpp
intl/l10n/DocumentL10n.cpp
intl/l10n/DocumentL10n.h
intl/l10n/L10nRegistry.jsm
intl/l10n/moz.build
intl/l10n/test/browser.ini
intl/l10n/test/document_l10n/README.txt
intl/l10n/test/document_l10n/non-system-principal/README.txt
intl/l10n/test/document_l10n/non-system-principal/browser_resource_uri.js
intl/l10n/test/document_l10n/non-system-principal/localization/test.ftl
intl/l10n/test/document_l10n/non-system-principal/test.html
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -2227,45 +2227,30 @@ nsIDocument::Reset(nsIChannel* aChannel,
       mChromeXHRDocBaseURI = nullptr;
     }
   }
 
   mChannel = aChannel;
 }
 
 /**
- * Determine whether the principal is allowed access to the localization system.
- * We don't want the web to ever see this but all our UI including in content
- * pages should pass this test.
+ * DocumentL10n is currently allowed for system
+ * principal.
+ *
+ * In the future we'll want to expose it to non-web-exposed
+ * about:* pages.
  */
 bool
 PrincipalAllowsL10n(nsIPrincipal* principal)
 {
-  // The system principal is always allowed.
   if (nsContentUtils::IsSystemPrincipal(principal)) {
     return true;
   }
 
-  nsCOMPtr<nsIURI> uri;
-  nsresult rv = principal->GetURI(getter_AddRefs(uri));
-  NS_ENSURE_SUCCESS(rv, false);
-
-  bool hasFlags;
-
-  // Allow access to uris that cannot be loaded by web content.
-  rv = NS_URIChainHasFlags(uri, nsIProtocolHandler::URI_DANGEROUS_TO_LOAD, &hasFlags);
-  NS_ENSURE_SUCCESS(rv, false);
-  if (hasFlags) {
-    return true;
-  }
-
-  // UI resources also get access.
-  rv = NS_URIChainHasFlags(uri, nsIProtocolHandler::URI_IS_UI_RESOURCE, &hasFlags);
-  NS_ENSURE_SUCCESS(rv, false);
-  return hasFlags;
+  return false;
 }
 
 void
 nsIDocument::ResetToURI(nsIURI* aURI,
                         nsILoadGroup* aLoadGroup,
                         nsIPrincipal* aPrincipal)
 {
   MOZ_ASSERT(aURI, "Null URI passed to ResetToURI");
@@ -3410,18 +3395,17 @@ DocumentL10n*
 nsIDocument::GetL10n()
 {
   return mDocumentL10n;
 }
 
 bool
 nsDocument::DocumentSupportsL10n(JSContext* aCx, JSObject* aObject)
 {
-  nsCOMPtr<nsIPrincipal> callerPrincipal = nsContentUtils::SubjectPrincipal(aCx);
-  return PrincipalAllowsL10n(callerPrincipal);
+  return PrincipalAllowsL10n(nsContentUtils::SubjectPrincipal(aCx));
 }
 
 void
 nsIDocument::LocalizationLinkAdded(Element* aLinkElement)
 {
   if (!PrincipalAllowsL10n(NodePrincipal())) {
     return;
   }
--- a/dom/base/nsINode.cpp
+++ b/dom/base/nsINode.cpp
@@ -102,17 +102,16 @@
 #include <algorithm>
 #include "nsGlobalWindow.h"
 #include "nsDOMMutationObserver.h"
 #include "GeometryUtils.h"
 #include "nsIAnimationObserver.h"
 #include "nsChildContentList.h"
 #include "mozilla/dom/NodeBinding.h"
 #include "mozilla/dom/BindingDeclarations.h"
-#include "xpcprivate.h"
 
 #include "XPathGenerator.h"
 
 #ifdef ACCESSIBILITY
 #include "mozilla/dom/AccessibleNode.h"
 #endif
 
 using namespace mozilla;
@@ -3140,28 +3139,17 @@ public:
         }
 
         if (!JS_DefineElement(aCx, untranslatedElements, i, wrappedElem, JSPROP_ENUMERATE)) {
           mReturnValuePromise->MaybeRejectWithUndefined();
           return;
         }
       }
     }
-
-    JS::RootedObject sourceScope(aCx, JS::CurrentGlobalOrNull(aCx));
-
-    AutoEntryScript aes(mReturnValuePromise->GetParentObject(), "Promise resolution");
-    JSContext* cx = aes.cx();
-    JS::Rooted<JS::Value> result(cx, JS::ObjectValue(*untranslatedElements));
-
-    xpc::StackScopedCloneOptions options;
-    options.wrapReflectors = true;
-    StackScopedClone(cx, options, sourceScope, &result);
-
-    mReturnValuePromise->MaybeResolve(result);
+    mReturnValuePromise->MaybeResolve(untranslatedElements);
   }
 
   virtual void
   RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override
   {
     mReturnValuePromise->MaybeRejectWithUndefined();
   }
 
--- a/intl/l10n/DocumentL10n.cpp
+++ b/intl/l10n/DocumentL10n.cpp
@@ -9,70 +9,20 @@
 #include "mozilla/dom/DocumentL10nBinding.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/Event.h"
 #include "mozilla/dom/Promise.h"
 #include "mozilla/dom/PromiseNativeHandler.h"
 #include "nsQueryObject.h"
 #include "nsISupports.h"
 #include "nsContentUtils.h"
-#include "xpcprivate.h"
 
 namespace mozilla {
 namespace dom {
 
-NS_INTERFACE_MAP_BEGIN(PromiseResolver)
-  NS_INTERFACE_MAP_ENTRY(nsISupports)
-NS_INTERFACE_MAP_END
-
-NS_IMPL_ADDREF(PromiseResolver)
-NS_IMPL_RELEASE(PromiseResolver)
-
-PromiseResolver::PromiseResolver(Promise* aPromise)
-{
-  mPromise = aPromise;
-}
-
-void
-PromiseResolver::ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue)
-{
-  JS::RootedObject sourceScope(aCx, JS::CurrentGlobalOrNull(aCx));
-
-  AutoEntryScript aes(mPromise->GetParentObject(), "Promise resolution");
-  JSContext* cx = aes.cx();
-  JS::Rooted<JS::Value> value(cx, aValue);
-
-  xpc::StackScopedCloneOptions options;
-  StackScopedClone(cx, options, sourceScope, &value);
-
-  mPromise->MaybeResolve(cx, value);
-  mPromise = nullptr;
-}
-
-void
-PromiseResolver::RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue)
-{
-  JS::RootedObject sourceScope(aCx, JS::CurrentGlobalOrNull(aCx));
-
-  AutoEntryScript aes(mPromise->GetParentObject(), "Promise rejection");
-  JSContext* cx = aes.cx();
-  JS::Rooted<JS::Value> value(cx, aValue);
-
-  xpc::StackScopedCloneOptions options;
-  StackScopedClone(cx, options, sourceScope, &value);
-
-  mPromise->MaybeReject(cx, value);
-  mPromise = nullptr;
-}
-
-PromiseResolver::~PromiseResolver()
-{
-  mPromise = nullptr;
-}
-
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DocumentL10n)
   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
   NS_INTERFACE_MAP_ENTRY(nsISupports)
   NS_INTERFACE_MAP_ENTRY(nsIDOMEventListener)
 NS_INTERFACE_MAP_END
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(DocumentL10n)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(DocumentL10n)
@@ -125,41 +75,16 @@ DocumentL10n::Init(nsTArray<nsString>& a
 }
 
 JSObject*
 DocumentL10n::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
 {
   return DocumentL10n_Binding::Wrap(aCx, this, aGivenProto);
 }
 
-already_AddRefed<Promise>
-DocumentL10n::MaybeWrapPromise(Promise* aInnerPromise)
-{
-  // For system principal we don't need to wrap the
-  // result promise at all.
-  if (nsContentUtils::IsSystemPrincipal(mDocument->NodePrincipal())) {
-    return RefPtr<Promise>(aInnerPromise).forget();
-  }
-
-  nsIGlobalObject* global = mDocument->GetScopeObject();
-  if (!global) {
-    return nullptr;
-  }
-
-  ErrorResult result;
-  RefPtr<Promise> docPromise = Promise::Create(global, result);
-  if (result.Failed()) {
-    return nullptr;
-  }
-
-  RefPtr<PromiseResolver> resolver = new PromiseResolver(docPromise);
-  aInnerPromise->AppendNativeHandler(resolver);
-  return docPromise.forget();
-}
-
 NS_IMETHODIMP
 DocumentL10n::HandleEvent(Event* aEvent)
 {
 #ifdef DEBUG
   nsAutoString eventType;
   aEvent->GetType(eventType);
   MOZ_ASSERT(eventType.EqualsLiteral("MozBeforeInitialXULLayout"));
 #endif
@@ -206,17 +131,17 @@ DocumentL10n::FormatMessages(JSContext* 
   }
 
   RefPtr<Promise> promise;
   aRv = mDOMLocalization->FormatMessages(jsKeys, getter_AddRefs(promise));
   if (aRv.Failed()) {
     return nullptr;
   }
 
-  return MaybeWrapPromise(promise);
+  return promise.forget();
 }
 
 already_AddRefed<Promise>
 DocumentL10n::FormatValues(JSContext* aCx, const Sequence<L10nKey>& aKeys, ErrorResult& aRv)
 {
   nsTArray<JS::Value> jsKeys;
   SequenceRooter<JS::Value> rooter(aCx, &jsKeys);
   for (auto& key : aKeys) {
@@ -229,17 +154,17 @@ DocumentL10n::FormatValues(JSContext* aC
   }
 
   RefPtr<Promise> promise;
   aRv = mDOMLocalization->FormatValues(jsKeys, getter_AddRefs(promise));
   if (aRv.Failed()) {
     return nullptr;
   }
 
-  return MaybeWrapPromise(promise);
+  return promise.forget();
 }
 
 already_AddRefed<Promise>
 DocumentL10n::FormatValue(JSContext* aCx, const nsAString& aId, const Optional<JS::Handle<JSObject*>>& aArgs, ErrorResult& aRv)
 {
   JS::Rooted<JS::Value> args(aCx);
 
   if (aArgs.WasPassed()) {
@@ -249,17 +174,17 @@ DocumentL10n::FormatValue(JSContext* aCx
   }
 
   RefPtr<Promise> promise;
   nsresult rv = mDOMLocalization->FormatValue(aId, args, getter_AddRefs(promise));
   if (NS_FAILED(rv)) {
     aRv.Throw(rv);
     return nullptr;
   }
-  return MaybeWrapPromise(promise);
+  return promise.forget();
 }
 
 void
 DocumentL10n::SetAttributes(JSContext* aCx, Element& aElement, const nsAString& aId, const Optional<JS::Handle<JSObject*>>& aArgs, ErrorResult& aRv)
 {
   aElement.SetAttribute(NS_LITERAL_STRING("data-l10n-id"), aId, aRv);
   if (aRv.Failed()) {
     return;
@@ -305,34 +230,34 @@ already_AddRefed<Promise>
 DocumentL10n::TranslateFragment(nsINode& aNode, ErrorResult& aRv)
 {
   RefPtr<Promise> promise;
   nsresult rv = mDOMLocalization->TranslateFragment(&aNode, getter_AddRefs(promise));
   if (NS_FAILED(rv)) {
     aRv.Throw(rv);
     return nullptr;
   }
-  return MaybeWrapPromise(promise);
+  return promise.forget();
 }
 
 already_AddRefed<Promise>
 DocumentL10n::TranslateElements(const Sequence<OwningNonNull<Element>>& aElements, ErrorResult& aRv)
 {
   AutoTArray<RefPtr<Element>, 10> elements;
   elements.SetCapacity(aElements.Length());
   for (auto& element : aElements) {
     elements.AppendElement(element);
   }
   RefPtr<Promise> promise;
   aRv = mDOMLocalization->TranslateElements(
       elements, getter_AddRefs(promise));
   if (aRv.Failed()) {
     return nullptr;
   }
-  return MaybeWrapPromise(promise);
+  return promise.forget();
 }
 
 class L10nReadyHandler final : public PromiseNativeHandler
 {
 public:
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_CLASS(L10nReadyHandler)
 
--- a/intl/l10n/DocumentL10n.h
+++ b/intl/l10n/DocumentL10n.h
@@ -12,40 +12,24 @@
 #include "mozilla/ErrorResult.h"
 #include "mozilla/dom/BindingDeclarations.h"
 #include "nsIDOMEventListener.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsWrapperCache.h"
 #include "nsIDocument.h"
 #include "nsINode.h"
 #include "mozIDOMLocalization.h"
-#include "mozilla/dom/Promise.h"
-#include "mozilla/dom/PromiseNativeHandler.h"
 
 namespace mozilla {
 namespace dom {
 
 class Element;
+class Promise;
 struct L10nKey;
 
-class PromiseResolver final : public PromiseNativeHandler
-{
-public:
-  NS_DECL_ISUPPORTS
-
-  explicit PromiseResolver(Promise* aPromise);
-  void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override;
-  void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override;
-
-protected:
-  virtual ~PromiseResolver();
-
-  RefPtr<Promise> mPromise;
-};
-
 enum class DocumentL10nState
 {
   Initialized = 0,
   InitialTranslationTriggered
 };
 
 /**
  * This class maintains localization status of the nsDocument.
@@ -72,18 +56,16 @@ public:
 protected:
   virtual ~DocumentL10n();
 
   nsCOMPtr<nsIDocument> mDocument;
   RefPtr<Promise> mReady;
   DocumentL10nState mState;
   nsCOMPtr<mozIDOMLocalization> mDOMLocalization;
 
-  already_AddRefed<Promise> MaybeWrapPromise(Promise* aPromise);
-
 public:
   nsIDocument* GetParentObject() const { return mDocument; };
 
   virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
 
   /**
    * A method for adding resources to the localization context.
    *
--- a/intl/l10n/L10nRegistry.jsm
+++ b/intl/l10n/L10nRegistry.jsm
@@ -1,16 +1,14 @@
 const { AppConstants } = ChromeUtils.import("resource://gre/modules/AppConstants.jsm", {});
 const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm", {});
 const { FluentBundle, FluentResource } = ChromeUtils.import("resource://gre/modules/Fluent.jsm", {});
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 XPCOMUtils.defineLazyGlobalGetters(this, ["fetch"]);
 
-const isParentProcess =
-  Services.appinfo.processType === Services.appinfo.PROCESS_TYPE_DEFAULT;
 /**
  * L10nRegistry is a localization resource management system for Gecko.
  *
  * It manages the list of resource sources provided with the app and allows
  * for additional sources to be added and updated.
  *
  * It's primary purpose is to allow for building an iterator over FluentBundle objects
  * that will be utilized by a localization API.
@@ -73,43 +71,32 @@ const isParentProcess =
  *
  * This allows the localization API to consume the FluentBundle and lazily fallback
  * on the next in case of a missing string or error.
  *
  * If during the life-cycle of the app a new source is added, the generator can be called again
  * and will produce a new set of permutations placing the language pack provided resources
  * at the top.
  */
-class L10nRegistryService {
-  constructor() {
-    this.sources = new Map();
-
-    if (!isParentProcess) {
-      this._setSourcesFromSharedData();
-      Services.cpmm.sharedData.addEventListener("change", this);
-    }
-  }
-
-  handleEvent(event) {
-    if (event.type === "change") {
-      if (event.changedKeys.includes("L10nRegistry:Sources")) {
-        this._setSourcesFromSharedData();
-      }
-    }
-  }
+const L10nRegistry = {
+  sources: new Map(),
+  bootstrap: null,
 
   /**
    * Based on the list of requested languages and resource Ids,
    * this function returns an lazy iterator over message context permutations.
    *
    * @param {Array} requestedLangs
    * @param {Array} resourceIds
    * @returns {AsyncIterator<FluentBundle>}
    */
   async* generateBundles(requestedLangs, resourceIds) {
+    if (this.bootstrap !== null) {
+      await this.bootstrap;
+    }
     const sourcesOrder = Array.from(this.sources.keys()).reverse();
     const pseudoNameFromPref = Services.prefs.getStringPref("intl.l10n.pseudo", "");
     for (const locale of requestedLangs) {
       for await (const dataSets of generateResourceSetsForLocale(locale, sourcesOrder, resourceIds)) {
         const bundle = new FluentBundle(locale, {
           ...MSG_CONTEXT_OPTIONS,
           transform: PSEUDO_STRATEGIES[pseudoNameFromPref],
         });
@@ -117,114 +104,74 @@ class L10nRegistryService {
           if (data === null) {
             return;
           }
           bundle.addResource(data);
         }
         yield bundle;
       }
     }
-  }
+  },
 
   /**
    * Adds a new resource source to the L10nRegistry.
    *
    * @param {FileSource} source
    */
   registerSource(source) {
     if (this.sources.has(source.name)) {
       throw new Error(`Source with name "${source.name}" already registered.`);
     }
     this.sources.set(source.name, source);
-
-    if (isParentProcess) {
-      this._synchronizeSharedData();
-      Services.locale.availableLocales = this.getAvailableLocales();
-    }
-  }
+    Services.locale.availableLocales = this.getAvailableLocales();
+  },
 
   /**
    * Updates an existing source in the L10nRegistry
    *
    * That will usually happen when a new version of a source becomes
    * available (for example, an updated version of a language pack).
    *
    * @param {FileSource} source
    */
   updateSource(source) {
     if (!this.sources.has(source.name)) {
       throw new Error(`Source with name "${source.name}" is not registered.`);
     }
     this.sources.set(source.name, source);
-    if (isParentProcess) {
-      this._synchronizeSharedData();
-      Services.locale.availableLocales = this.getAvailableLocales();
-    }
-  }
+    Services.locale.availableLocales = this.getAvailableLocales();
+  },
 
   /**
    * Removes a source from the L10nRegistry.
    *
    * @param {String} sourceId
    */
   removeSource(sourceName) {
     this.sources.delete(sourceName);
-    if (isParentProcess) {
-      this._synchronizeSharedData();
-      Services.locale.availableLocales = this.getAvailableLocales();
-    }
-  }
-
-  _synchronizeSharedData() {
-    const sources = new Map();
-    for (const [name, source] of this.sources.entries()) {
-      if (source.indexed) {
-        continue;
-      }
-      sources.set(name, {
-        locales: source.locales,
-        prePath: source.prePath,
-      });
-    }
-    Services.ppmm.sharedData.set("L10nRegistry:Sources", sources);
-    Services.ppmm.sharedData.flush();
-  }
-
-  _setSourcesFromSharedData() {
-    let sources = Services.cpmm.sharedData.get("L10nRegistry:Sources");
-    for (let [name, data] of sources.entries()) {
-      if (!this.sources.has(name)) {
-        const source = new FileSource(name, data.locales, data.prePath);
-        this.registerSource(source);
-      }
-    }
-    for (let name of this.sources.keys()) {
-      if (!sources.has(name)) {
-        this.removeSource(name);
-      }
-    }
-  }
+    Services.locale.availableLocales = this.getAvailableLocales();
+  },
 
   /**
    * Returns a list of locales for which at least one source
    * has resources.
    *
    * @returns {Array<String>}
    */
   getAvailableLocales() {
     const locales = new Set();
 
     for (const source of this.sources.values()) {
       for (const locale of source.locales) {
         locales.add(locale);
       }
     }
     return Array.from(locales);
-  }
-}
+  },
+};
 
 /**
  * This function generates an iterator over FluentBundles for a single locale
  * for a given list of resourceIds for all possible combinations of sources.
  *
  * This function is called recursively to generate all possible permutations
  * and uses the last, optional parameter, to pass the already resolved
  * sources order.
@@ -532,33 +479,32 @@ class IndexedFileSource extends FileSour
     super(name, locales, prePath);
     this.indexed = true;
     for (const path of paths) {
       this.cache[path] = true;
     }
   }
 }
 
-this.L10nRegistry = new L10nRegistryService();
-
 /**
  * The low level wrapper around Fetch API. It unifies the error scenarios to
  * always produce a promise rejection.
  *
  * We keep it as a method to make it easier to override for testing purposes.
  *
  * @param {string} url
  *
  * @returns {Promise<string>}
  */
-this.L10nRegistry.load = function(url) {
+L10nRegistry.load = function(url) {
   return fetch(url).then(response => {
     if (!response.ok) {
       return Promise.reject(response.statusText);
     }
     return response.text();
   });
 };
 
+this.L10nRegistry = L10nRegistry;
 this.FileSource = FileSource;
 this.IndexedFileSource = IndexedFileSource;
 
 var EXPORTED_SYMBOLS = ["L10nRegistry", "FileSource", "IndexedFileSource"];
--- a/intl/l10n/moz.build
+++ b/intl/l10n/moz.build
@@ -27,20 +27,18 @@ EXPORTS.mozilla.dom += [
 ]
 
 UNIFIED_SOURCES += [
     'DocumentL10n.cpp',
 ]
 
 LOCAL_INCLUDES += [
     '/dom/base',
-    '/js/xpconnect/src',
 ]
 
 XPCSHELL_TESTS_MANIFESTS += ['test/xpcshell.ini']
 
 MOCHITEST_MANIFESTS += ['test/mochitest.ini']
 MOCHITEST_CHROME_MANIFESTS += ['test/chrome.ini']
-BROWSER_CHROME_MANIFESTS += ['test/browser.ini']
 
 SPHINX_TREES['l10n'] = 'docs'
 
 FINAL_LIBRARY = 'xul'
deleted file mode 100644
--- a/intl/l10n/test/browser.ini
+++ /dev/null
@@ -1,4 +0,0 @@
-[document_l10n/non-system-principal/browser_resource_uri.js]
-support-files =
-  document_l10n/non-system-principal/test.html
-  document_l10n/non-system-principal/localization/test.ftl
deleted file mode 100644
--- a/intl/l10n/test/document_l10n/README.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-Tests in this directory cover support for DocumentL10n
-WebIDL API across different use cases such as
-processes, principals and so on.
deleted file mode 100644
--- a/intl/l10n/test/document_l10n/non-system-principal/README.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-Tests in this directory cover the functionality
-of DocumentL10n WebIDL API in non-system-principal
-scenario.
deleted file mode 100644
--- a/intl/l10n/test/document_l10n/non-system-principal/browser_resource_uri.js
+++ /dev/null
@@ -1,68 +0,0 @@
-const { L10nRegistry, FileSource } = ChromeUtils.import("resource://gre/modules/L10nRegistry.jsm", {});
-
-let uri = "chrome://mochitests/content/browser/intl/l10n/test/document_l10n/non-system-principal/";
-let protocol = Services.io.getProtocolHandler("resource")
-                          .QueryInterface(Ci.nsIResProtocolHandler);
-
-protocol.setSubstitution("l10n-test", Services.io.newURI(uri));
-
-// Since we want the mock source to work with all locales, we're going
-// to register it for currently used locales, and we'll put the path that
-// doesn't use the `{locale}` component to make it work irrelevant of
-// what locale the mochitest is running in.
-//
-// Notice: we're using a `chrome://` protocol here only for convenience reasons.
-// Real sources should use `resource://` protocol.
-let locales = Services.locale.appLocalesAsBCP47;
-let mockSource = new FileSource("test", locales, `${uri}localization/`);
-L10nRegistry.registerSource(mockSource);
-
-registerCleanupFunction(() => {
-  protocol.setSubstitution("l10n-test", null);
-  L10nRegistry.removeSource("test");
-});
-
-
-add_task(async () => {
-  await BrowserTestUtils.withNewTab("resource://l10n-test/test.html", async (browser) => {
-    await ContentTask.spawn(browser, null, async function() {
-      let document = content.document;
-      let window = document.defaultView;
-
-      let {customMsg, l10nArgs} = await document.testsReadyPromise;
-
-      let desc = document.getElementById("main-desc");
-
-      // We can test here for a particular value because we're
-      // using a mock file source which is locale independent.
-      //
-      // If you're writing a test that verifies that a UI
-      // widget got real localization, you should not rely on
-      // the particular value, but rather on the content not
-      // being empty (to keep the test pass in non-en-US locales).
-      is(desc.textContent, "This is a mock page title");
-
-      // Test for l10n.getAttributes
-      let label = document.getElementById("label1");
-      is(l10nArgs.id, "subtitle");
-      is(l10nArgs.args.name, "Firefox");
-
-      // Test for manual value formatting
-      is(customMsg, "This is a custom message formatted from JS.");
-
-      // Since we applied the `data-l10n-id` attribute
-      // on `label` in this microtask, we have to wait for
-      // the next paint to verify that the MutationObserver
-      // applied the translation.
-      await new Promise((resolve) => {
-        let verifyL10n = () => {
-          is(label.textContent.includes("Firefox"), true);
-          resolve();
-        };
-        window.addEventListener("MozAfterPaint", verifyL10n, {
-          once: true,
-        });
-      });
-    });
-  });
-});
deleted file mode 100644
--- a/intl/l10n/test/document_l10n/non-system-principal/localization/test.ftl
+++ /dev/null
@@ -1,4 +0,0 @@
-page-title = This is a mock page title
-subtitle = This is a label for { $name }
-
-custom-message = This is a custom message formatted from JS.
deleted file mode 100644
--- a/intl/l10n/test/document_l10n/non-system-principal/test.html
+++ /dev/null
@@ -1,36 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <meta charset="utf-8">
-  <title>Test DocumentL10n in HTML environment</title>
-  <link rel="localization" href="test.ftl"/>
-  <script type="text/javascript">
-    document.testsReadyPromise = new Promise(async (resolve) => {
-      // The test is in this file to ensure that we're testing
-      // the behavior in a non-system principal.
-      document.addEventListener("DOMContentLoaded", async () => {
-        await document.l10n.ready;
-
-        // Assign the localization from JS
-        let label = document.getElementById("label1");
-        document.l10n.setAttributes(
-          label,
-          "subtitle",
-          {
-            name: "Firefox",
-          }
-        );
-
-        const customMsg = await document.l10n.formatValue("custom-message");
-        const l10nArgs = document.l10n.getAttributes(label);
-        resolve({customMsg, l10nArgs});
-      }, {once: true});
-    });
-  </script>
-</head>
-<body>
-  <h1 id="main-desc" data-l10n-id="page-title"></h1>
-
-  <p id="label1"></p>
-</body>
-</html>