Bug 1552168 - Remove Pref data_uri.unique_opaque_origin r=ckerschb
☠☠ backed out by 33ed51dffab8 ☠ ☠
authorSebastian Streich <sstreich@mozilla.com>
Wed, 03 Jul 2019 10:23:29 +0000
changeset 543929 7ff83cc5d33ab32425a61824ae68800c08622e7d
parent 543928 02fa74d45af5412d2d6cf4581fd9f0c437c6c0e0
child 543930 83590619ce06e66e9be3a1593da824d53cf97415
push id2131
push userffxbld-merge
push dateMon, 26 Aug 2019 18:30:20 +0000
treeherdermozilla-release@b19ffb3ca153 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersckerschb
bugs1552168
milestone69.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
Bug 1552168 - Remove Pref data_uri.unique_opaque_origin r=ckerschb Differential Revision: https://phabricator.services.mozilla.com/D35005
docshell/base/nsDocShell.cpp
dom/base/nsObjectLoadingContent.cpp
dom/clients/manager/ClientManager.cpp
dom/clients/manager/ClientPrefs.cpp
dom/clients/manager/ClientPrefs.h
dom/clients/manager/ClientValidation.cpp
dom/clients/manager/moz.build
dom/workers/ScriptLoader.cpp
modules/libpref/init/all.js
netwerk/base/nsIOService.cpp
netwerk/base/nsIOService.h
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -9984,19 +9984,17 @@ nsresult nsDocShell::DoURILoad(nsDocShel
   bool inheritAttrs = false, inheritPrincipal = false;
 
   if (aLoadState->PrincipalToInherit()) {
     inheritAttrs = nsContentUtils::ChannelShouldInheritPrincipal(
         aLoadState->PrincipalToInherit(), aLoadState->URI(),
         true,  // aInheritForAboutBlank
         isSrcdoc);
 
-    bool isURIUniqueOrigin = nsIOService::IsDataURIUniqueOpaqueOrigin() &&
-                             SchemeIsData(aLoadState->URI());
-    inheritPrincipal = inheritAttrs && !isURIUniqueOrigin;
+    inheritPrincipal = inheritAttrs && !SchemeIsData(aLoadState->URI());
   }
 
   nsLoadFlags loadFlags = mDefaultLoadFlags;
   nsSecurityFlags securityFlags =
       nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL;
 
   if (aLoadState->FirstParty()) {
     // tag first party URL loads
--- a/dom/base/nsObjectLoadingContent.cpp
+++ b/dom/base/nsObjectLoadingContent.cpp
@@ -2286,19 +2286,18 @@ nsresult nsObjectLoadingContent::OpenCha
   bool inherit = nsContentUtils::ChannelShouldInheritPrincipal(
       thisContent->NodePrincipal(), mURI,
       true,    // aInheritForAboutBlank
       false);  // aForceInherit
   nsSecurityFlags securityFlags =
       nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL;
 
   bool isData;
-  bool isURIUniqueOrigin = nsIOService::IsDataURIUniqueOpaqueOrigin() &&
-                           NS_SUCCEEDED(mURI->SchemeIs("data", &isData)) &&
-                           isData;
+  bool isURIUniqueOrigin =
+      NS_SUCCEEDED(mURI->SchemeIs("data", &isData)) && isData;
 
   if (inherit && !isURIUniqueOrigin) {
     securityFlags |= nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL;
   }
   if (isSandBoxed) {
     securityFlags |= nsILoadInfo::SEC_SANDBOXED;
   }
 
--- a/dom/clients/manager/ClientManager.cpp
+++ b/dom/clients/manager/ClientManager.cpp
@@ -4,17 +4,16 @@
  * 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 "ClientManager.h"
 
 #include "ClientHandle.h"
 #include "ClientManagerChild.h"
 #include "ClientManagerOpChild.h"
-#include "ClientPrefs.h"
 #include "ClientSource.h"
 #include "mozilla/dom/WorkerHolderToken.h"
 #include "mozilla/dom/WorkerPrivate.h"
 #include "mozilla/ipc/BackgroundChild.h"
 #include "mozilla/ipc/PBackgroundChild.h"
 #include "nsContentUtils.h"
 #include "prthread.h"
 
@@ -236,18 +235,16 @@ void ClientManager::Startup() {
 #endif
       PR_NewThreadPrivateIndex(&sClientManagerThreadLocalIndex, nullptr);
   MOZ_DIAGNOSTIC_ASSERT(status == PR_SUCCESS);
 
   MOZ_DIAGNOSTIC_ASSERT(sClientManagerThreadLocalIndex != kBadThreadLocalIndex);
 #ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
   sClientManagerThreadLocalIndexDuplicate = sClientManagerThreadLocalIndex;
 #endif
-
-  ClientPrefsInit();
 }
 
 // static
 UniquePtr<ClientSource> ClientManager::CreateSource(
     ClientType aType, nsISerialEventTarget* aEventTarget,
     nsIPrincipal* aPrincipal) {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(aPrincipal);
deleted file mode 100644
--- a/dom/clients/manager/ClientPrefs.cpp
+++ /dev/null
@@ -1,30 +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/. */
-
-#include "ClientPrefs.h"
-
-#include "mozilla/Preferences.h"
-
-namespace mozilla {
-namespace dom {
-
-namespace {
-
-bool gDataURLUniqueOpaqueOrigin = false;
-
-}  // anonymous namespace
-
-void ClientPrefsInit() {
-  Preferences::AddBoolVarCache(&gDataURLUniqueOpaqueOrigin,
-                               "security.data_uri.unique_opaque_origin", false);
-}
-
-bool ClientPrefsGetDataURLUniqueOpaqueOrigin() {
-  return gDataURLUniqueOpaqueOrigin;
-}
-
-}  // namespace dom
-}  // namespace mozilla
deleted file mode 100644
--- a/dom/clients/manager/ClientPrefs.h
+++ /dev/null
@@ -1,19 +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 _mozilla_dom_ClientPrefs_h
-#define _mozilla_dom_ClientPrefs_h
-
-namespace mozilla {
-namespace dom {
-
-void ClientPrefsInit();
-
-bool ClientPrefsGetAllowUniqueOpaqueOrigin();
-
-}  // namespace dom
-}  // namespace mozilla
-
-#endif  // _mozilla_dom_ClientPrefs_h
--- a/dom/clients/manager/ClientValidation.cpp
+++ b/dom/clients/manager/ClientValidation.cpp
@@ -1,17 +1,16 @@
 /* -*- 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 "ClientValidation.h"
 
-#include "ClientPrefs.h"
 #include "mozilla/net/MozURL.h"
 
 namespace mozilla {
 namespace dom {
 
 using mozilla::ipc::ContentPrincipalInfo;
 using mozilla::ipc::PrincipalInfo;
 using mozilla::net::MozURL;
@@ -104,23 +103,16 @@ bool ClientIsValidCreationURL(const Prin
 
       nsDependentCSubstring scheme = url->Scheme();
 
       // Generally any origin can also open javascript: windows and workers.
       if (scheme.LowerCaseEqualsLiteral("javascript")) {
         return true;
       }
 
-      // We have some tests that use data: URL windows without an opaque
-      // origin.  This should only happen when a pref is set.
-      if (!ClientPrefsGetDataURLUniqueOpaqueOrigin() &&
-          scheme.LowerCaseEqualsLiteral("data")) {
-        return true;
-      }
-
       // Otherwise don't support this URL type in the clients sub-system for
       // now.  This will exclude a variety of internal browser clients, but
       // currently we don't need to support those.  This function can be
       // expanded to handle more cases as necessary.
       return false;
     }
     case PrincipalInfo::TSystemPrincipalInfo: {
       nsDependentCSubstring scheme = url->Scheme();
@@ -128,20 +120,17 @@ bool ClientIsValidCreationURL(const Prin
       // While many types of documents can be created with a system principal,
       // there are only a few that can reasonably become windows.  We attempt
       // to validate the list of known cases here with a simple scheme check.
       return scheme.LowerCaseEqualsLiteral("about") ||
              scheme.LowerCaseEqualsLiteral("chrome") ||
              scheme.LowerCaseEqualsLiteral("resource") ||
              scheme.LowerCaseEqualsLiteral("blob") ||
              scheme.LowerCaseEqualsLiteral("javascript") ||
-             scheme.LowerCaseEqualsLiteral("view-source") ||
-
-             (!ClientPrefsGetDataURLUniqueOpaqueOrigin() &&
-              scheme.LowerCaseEqualsLiteral("data"));
+             scheme.LowerCaseEqualsLiteral("view-source");
     }
     case PrincipalInfo::TNullPrincipalInfo: {
       // A wide variety of clients can have a null principal.  For example,
       // sandboxed iframes can have a normal content URL.  For now allow
       // any parsable URL for null principals.  This is relatively safe since
       // null principals have unique origins and won't most ClientManagerService
       // queries anyway.
       return true;
--- a/dom/clients/manager/moz.build
+++ b/dom/clients/manager/moz.build
@@ -35,17 +35,16 @@ UNIFIED_SOURCES += [
   'ClientManagerParent.cpp',
   'ClientManagerService.cpp',
   'ClientNavigateOpChild.cpp',
   'ClientNavigateOpParent.cpp',
   'ClientOpenWindowOpActors.cpp',
   'ClientOpenWindowOpChild.cpp',
   'ClientOpenWindowOpParent.cpp',
   'ClientOpenWindowUtils.cpp',
-  'ClientPrefs.cpp',
   'ClientPrincipalUtils.cpp',
   'ClientSource.cpp',
   'ClientSourceChild.cpp',
   'ClientSourceOpChild.cpp',
   'ClientSourceOpParent.cpp',
   'ClientSourceParent.cpp',
   'ClientState.cpp',
   'ClientValidation.cpp',
--- a/dom/workers/ScriptLoader.cpp
+++ b/dom/workers/ScriptLoader.cpp
@@ -156,19 +156,17 @@ nsresult ChannelFromScriptURL(
   bool inheritAttrs = nsContentUtils::ChannelShouldInheritPrincipal(
       principal, uri, true /* aInheritForAboutBlank */,
       false /* aForceInherit */);
 
   bool isData = false;
   rv = uri->SchemeIs("data", &isData);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  bool isURIUniqueOrigin =
-      net::nsIOService::IsDataURIUniqueOpaqueOrigin() && isData;
-  if (inheritAttrs && !isURIUniqueOrigin) {
+  if (inheritAttrs && !isData) {
     secFlags |= nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL;
   }
 
   if (aWorkerScriptType == DebuggerScript) {
     // A DebuggerScript needs to be a local resource like chrome: or resource:
     bool isUIResource = false;
     rv = NS_URIChainHasFlags(uri, nsIProtocolHandler::URI_IS_UI_RESOURCE,
                              &isUIResource);
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -5500,22 +5500,16 @@ pref("dom.maxHardwareConcurrency", 16);
 
 // Shutdown the osfile worker if its no longer needed.
 #if !defined(RELEASE_OR_BETA)
 pref("osfile.reset_worker_delay", 30000);
 #endif
 
 pref("media.block-autoplay-until-in-foreground", true);
 
-// TODO: Bug 1324406: Treat 'data:' documents as unique, opaque origins
-// If true, data: URIs will be treated as unique opaque origins, hence will use
-// a NullPrincipal as the security context.
-// Otherwise it will inherit the origin from parent node, this is the legacy
-// behavior of Firefox.
-pref("security.data_uri.unique_opaque_origin", true);
 
 // If true, all toplevel data: URI navigations will be blocked.
 // Please note that manually entering a data: URI in the
 // URL-Bar will not be blocked when flipping this pref.
 pref("security.data_uri.block_toplevel_data_uri_navigations", true);
 
 // If true, all FTP subresource loads will be blocked.
 pref("security.block_ftp_subresources", true);
--- a/netwerk/base/nsIOService.cpp
+++ b/netwerk/base/nsIOService.cpp
@@ -178,17 +178,16 @@ static const char kProfileChangeNetTeard
 static const char kProfileChangeNetRestoreTopic[] =
     "profile-change-net-restore";
 static const char kProfileDoChange[] = "profile-do-change";
 
 // Necko buffer defaults
 uint32_t nsIOService::gDefaultSegmentSize = 4096;
 uint32_t nsIOService::gDefaultSegmentCount = 24;
 
-bool nsIOService::sIsDataURIUniqueOpaqueOrigin = false;
 bool nsIOService::sBlockToplevelDataUriNavigations = false;
 bool nsIOService::sBlockFTPSubresources = false;
 
 ////////////////////////////////////////////////////////////////////////////////
 
 nsIOService::nsIOService()
     : mOffline(true),
       mOfflineForProfileChange(false),
@@ -255,18 +254,16 @@ nsresult nsIOService::Init() {
     observerService->AddObserver(this, kProfileDoChange, true);
     observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, true);
     observerService->AddObserver(this, NS_NETWORK_LINK_TOPIC, true);
     observerService->AddObserver(this, NS_WIDGET_WAKE_OBSERVER_TOPIC, true);
     observerService->AddObserver(this, NS_PREFSERVICE_READ_TOPIC_ID, true);
   } else
     NS_WARNING("failed to get observer service");
 
-  Preferences::AddBoolVarCache(&sIsDataURIUniqueOpaqueOrigin,
-                               "security.data_uri.unique_opaque_origin", false);
   Preferences::AddBoolVarCache(
       &sBlockToplevelDataUriNavigations,
       "security.data_uri.block_toplevel_data_uri_navigations", false);
   Preferences::AddBoolVarCache(&sBlockFTPSubresources,
                                "security.block_ftp_subresources", true);
   Preferences::AddBoolVarCache(&mOfflineMirrorsConnectivity,
                                OFFLINE_MIRRORS_CONNECTIVITY, true);
 
@@ -1799,21 +1796,16 @@ nsIOService::SpeculativeConnect(nsIURI* 
 
 NS_IMETHODIMP
 nsIOService::SpeculativeAnonymousConnect(nsIURI* aURI, nsIPrincipal* aPrincipal,
                                          nsIInterfaceRequestor* aCallbacks) {
   return SpeculativeConnectInternal(aURI, aPrincipal, aCallbacks, true);
 }
 
 /*static*/
-bool nsIOService::IsDataURIUniqueOpaqueOrigin() {
-  return sIsDataURIUniqueOpaqueOrigin;
-}
-
-/*static*/
 bool nsIOService::BlockToplevelDataUriNavigations() {
   return sBlockToplevelDataUriNavigations;
 }
 
 /*static*/
 bool nsIOService::BlockFTPSubresources() { return sBlockFTPSubresources; }
 
 NS_IMETHODIMP
--- a/netwerk/base/nsIOService.h
+++ b/netwerk/base/nsIOService.h
@@ -94,17 +94,16 @@ class nsIOService final : public nsIIOSe
   // network is in process of tearing down. Moving nsHttpConnectionMgr::Shutdown
   // to nsIOService caused problems (bug 1242755) so we doing it in this way. As
   // soon as nsIOService gets notification that it is shutdown it is going to
   // reset mHttpHandlerAlreadyShutingDown.
   void SetHttpHandlerAlreadyShutingDown();
 
   bool IsLinkUp();
 
-  static bool IsDataURIUniqueOpaqueOrigin();
   static bool BlockToplevelDataUriNavigations();
 
   static bool BlockFTPSubresources();
 
   // Used to count the total number of HTTP requests made
   void IncrementRequestNumber() { mTotalRequests++; }
   uint32_t GetTotalRequestNumber() { return mTotalRequests; }
   // Used to keep "race cache with network" stats
@@ -215,17 +214,16 @@ class nsIOService final : public nsIIOSe
 
   // cached categories
   nsCategoryCache<nsIChannelEventSink> mChannelEventSinks;
 
   nsTArray<int32_t> mRestrictedPortList;
 
   bool mNetworkNotifyChanged;
 
-  static bool sIsDataURIUniqueOpaqueOrigin;
   static bool sBlockToplevelDataUriNavigations;
 
   static bool sBlockFTPSubresources;
 
   uint32_t mTotalRequests;
   uint32_t mCacheWon;
   uint32_t mNetWon;