From 6f9fa4450ae59c0acdad178181c66ab46cc86861 Mon Sep 17 00:00:00 2001 From: Sebastian Hengst Date: Mon, 7 Mar 2016 16:35:14 +0100 Subject: [PATCH] Backed out changeset 05cef11d91be (bug 1249224) for bustage. r=backout on a CLOSED TREE --- embedding/components/windowwatcher/moz.build | 1 - .../windowwatcher/nsWindowWatcher.cpp | 59 ------------------- 2 files changed, 60 deletions(-) diff --git a/embedding/components/windowwatcher/moz.build b/embedding/components/windowwatcher/moz.build index 617a56bde65d..2d0766b591cb 100644 --- a/embedding/components/windowwatcher/moz.build +++ b/embedding/components/windowwatcher/moz.build @@ -37,6 +37,5 @@ if CONFIG['MOZ_XUL']: FINAL_LIBRARY = 'xul' # For nsJSUtils LOCAL_INCLUDES += [ - '/docshell/base', '/dom/base', ] diff --git a/embedding/components/windowwatcher/nsWindowWatcher.cpp b/embedding/components/windowwatcher/nsWindowWatcher.cpp index e9b0efbf20b8..b6d63da4b7e5 100644 --- a/embedding/components/windowwatcher/nsWindowWatcher.cpp +++ b/embedding/components/windowwatcher/nsWindowWatcher.cpp @@ -18,7 +18,6 @@ #include "nsJSUtils.h" #include "plstr.h" -#include "nsDocShell.h" #include "nsIBaseWindow.h" #include "nsIBrowserDOMWindow.h" #include "nsIDocShell.h" @@ -448,36 +447,6 @@ nsWindowWatcher::OpenWindow2(mozIDOMWindowProxy* aParent, aNavigate, aOpeningTab, argv, aResult); } -// This static function checks if the aDocShell uses an UserContextId equal to -// nsIScriptSecurityManager::DEFAULT_USER_CONTEXT_ID or equal to the -// userContextId of subjectPrincipal, if not null. -static bool -CheckUserContextCompatibility(nsIDocShell* aDocShell) -{ - MOZ_ASSERT(aDocShell); - - uint32_t userContextId = - static_cast(aDocShell)->GetOriginAttributes().mUserContextId; - - if (userContextId == nsIScriptSecurityManager::DEFAULT_USER_CONTEXT_ID) { - return true; - } - - nsCOMPtr subjectPrincipal = - nsContentUtils::GetCurrentJSContext() - ? nsContentUtils::SubjectPrincipal() : nullptr; - - if (!subjectPrincipal) { - return false; - } - - uint32_t principalUserContextId; - nsresult rv = subjectPrincipal->GetUserContextId(&principalUserContextId); - NS_ENSURE_SUCCESS(rv, false); - - return principalUserContextId == userContextId; -} - nsresult nsWindowWatcher::OpenWindowInternal(mozIDOMWindowProxy* aParent, const char* aUrl, @@ -712,19 +681,6 @@ nsWindowWatcher::OpenWindowInternal(mozIDOMWindowProxy* aParent, do_QueryInterface(newDocShellItem); webNav->Stop(nsIWebNavigation::STOP_NETWORK); } - - // If this is a new window, but it's incompatible with the current - // userContextId, we ignore it and we pretend that nothing has been - // returned by ProvideWindow. - if (!windowIsNew && newDocShellItem) { - nsCOMPtr docShell = do_QueryInterface(newDocShellItem); - if (!CheckUserContextCompatibility(docShell)) { - newWindow = nullptr; - newDocShellItem = nullptr; - windowIsNew = false; - } - } - } else if (rv == NS_ERROR_ABORT) { // NS_ERROR_ABORT means the window provider has flat-out rejected // the open-window call and we should bail. Don't return an error @@ -1013,17 +969,6 @@ nsWindowWatcher::OpenWindowInternal(mozIDOMWindowProxy* aParent, } } - // If this is a new window, we must set the userContextId from the - // subjectPrincipal. - if (windowIsNew && subjectPrincipal) { - uint32_t userContextId; - rv = subjectPrincipal->GetUserContextId(&userContextId); - NS_ENSURE_SUCCESS(rv, rv); - - rv = newDocShell->SetUserContextId(userContextId); - NS_ENSURE_SUCCESS(rv, rv); - } - if (isNewToplevelWindow) { // Notify observers that the window is open and ready. // The window has not yet started to load a document. @@ -1034,10 +979,6 @@ nsWindowWatcher::OpenWindowInternal(mozIDOMWindowProxy* aParent, } } - // Before loading the URI we want to be 100% sure that we use the correct - // userContextId. - MOZ_ASSERT(CheckUserContextCompatibility(newDocShell)); - if (uriToLoad && aNavigate) { newDocShell->LoadURI( uriToLoad,