Bug 1369014: Do not pass explicitly pass a triggeringPrincipal within nsDocShellTreeOwner::HandleEvent. r=smaug
authorChristoph Kerschbaumer <ckerschb@christophkerschbaumer.com>
Wed, 07 Jun 2017 14:25:46 +0200
changeset 413162 de0c74d43a7ced6355c87840fda55061869a05ca
parent 413161 bad37b9f58eb9b2f4156ff35c27f4755cdedfae9
child 413163 742a51ab32ce7c35c4e3e156771768c39025c95f
push id1490
push usermtabara@mozilla.com
push dateMon, 31 Jul 2017 14:08:16 +0000
treeherdermozilla-release@70e32e6bf15e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1369014
milestone55.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 1369014: Do not pass explicitly pass a triggeringPrincipal within nsDocShellTreeOwner::HandleEvent. r=smaug
docshell/base/nsDocShellTreeOwner.cpp
dom/interfaces/base/nsIBrowser.idl
dom/interfaces/base/nsITabChild.idl
dom/ipc/PBrowser.ipdl
dom/ipc/TabChild.cpp
dom/ipc/TabParent.cpp
dom/ipc/TabParent.h
toolkit/content/widgets/browser.xml
--- a/docshell/base/nsDocShellTreeOwner.cpp
+++ b/docshell/base/nsDocShellTreeOwner.cpp
@@ -989,30 +989,18 @@ nsDocShellTreeOwner::HandleEvent(nsIDOME
       nsIDroppedLinkItem** links;
       if (webnav &&
           NS_SUCCEEDED(handler->DropLinks(dragEvent, true, &linksCount, &links))) {
         if (linksCount >= 1) {
           nsCOMPtr<nsIWebBrowserChrome> webBrowserChrome = GetWebBrowserChrome();
           if (webBrowserChrome) {
             nsCOMPtr<nsITabChild> tabChild = do_QueryInterface(webBrowserChrome);
             if (tabChild) {
-              nsCOMPtr<nsIDOMDataTransfer> domDataTransfer;
-              dragEvent->GetDataTransfer(getter_AddRefs(domDataTransfer));
-              NS_ENSURE_TRUE(domDataTransfer, NS_ERROR_UNEXPECTED);
-              nsCOMPtr<nsIDOMNode> domSourceNode;
-              domDataTransfer->GetMozSourceNode(getter_AddRefs(domSourceNode));
-              nsCOMPtr<nsINode> sourceNode = do_QueryInterface(domSourceNode);
-              nsCOMPtr<nsIPrincipal> triggeringPrincipal;
-              if (sourceNode) {
-                triggeringPrincipal = sourceNode->NodePrincipal();
-              } else {
-                triggeringPrincipal = NullPrincipal::Create();
-              }
-              nsresult rv = tabChild->RemoteDropLinks(linksCount, links,
-                                                      triggeringPrincipal);
+              // Bug 1370843 - Explicitly pass triggeringPrincipal
+              nsresult rv = tabChild->RemoteDropLinks(linksCount, links);
               for (uint32_t i = 0; i < linksCount; i++) {
                 NS_RELEASE(links[i]);
               }
               free(links);
               return rv;
             }
           }
           nsAutoString url;
--- a/dom/interfaces/base/nsIBrowser.idl
+++ b/dom/interfaces/base/nsIBrowser.idl
@@ -1,15 +1,14 @@
 /* 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 "nsISupports.idl"
 
 interface nsIFrameLoader;
-interface nsIPrincipal;
 
 [scriptable, uuid(14e5a0cb-e223-4202-95e8-fe53275193ea)]
 interface nsIBrowser : nsISupports
 {
   /**
    * Gets an optional frame loader that is "related" to this browser.
    * If this exists, then we should attempt to use the same content parent as
    * this frame loader for any new tab parents.  For example, view source
@@ -23,18 +22,17 @@ interface nsIBrowser : nsISupports
    * content area.
    *
    * @param linksCount length of links
    * @param links a flat array of url, name, and type for each link
    * @param triggeringPrincipal a principal that initiated loading
    *                            of the dropped links
    */
   void dropLinks(in unsigned long linksCount,
-                 [array, size_is(linksCount)] in wstring links,
-                 in nsIPrincipal aTriggeringPrincipal);
+                 [array, size_is(linksCount)] in wstring links);
 
   /**
    * Flags for controlling the behavior of swapBrowsers
    */
 
   /**
    * The default options. This is used for swapping browsers between windows
    */
--- a/dom/interfaces/base/nsITabChild.idl
+++ b/dom/interfaces/base/nsITabChild.idl
@@ -3,17 +3,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 
 #include "domstubs.idl"
 #include "nsIDroppedLinkHandler.idl"
 
 interface nsIContentFrameMessageManager;
 interface nsIWebBrowserChrome3;
-interface nsIPrincipal;
 
 native CommandsArray(nsTArray<nsCString>);
 [ref] native CommandsArrayRef(nsTArray<nsCString>);
 
 [scriptable, uuid(1fb79c27-e760-4088-b19c-1ce3673ec24e)]
 interface nsITabChild : nsISupports
 {
   readonly attribute nsIContentFrameMessageManager messageManager;
@@ -27,17 +26,16 @@ interface nsITabChild : nsISupports
   [noscript, notxpcom] void enableDisableCommands(in AString action,
                                                   in CommandsArrayRef enabledCommands,
                                                   in CommandsArrayRef disabledCommands);
 
   [noscript] void remoteSizeShellTo(in int32_t width, in int32_t height,
                                     in int32_t shellItemWidth, in int32_t shellItemHeight);
 
   [noscript] void remoteDropLinks(in unsigned long linksCount,
-                                  [array, size_is(linksCount)] in nsIDroppedLinkItem links,
-                                  in nsIPrincipal triggeringPrincipal);
+                                  [array, size_is(linksCount)] in nsIDroppedLinkItem links);
 
   readonly attribute uint64_t tabId;
 
   [noscript, notxpcom] void beforeUnloadAdded();
   [noscript, notxpcom] void beforeUnloadRemoved();
 };
 
--- a/dom/ipc/PBrowser.ipdl
+++ b/dom/ipc/PBrowser.ipdl
@@ -16,17 +16,16 @@ include protocol PRenderFrame;
 include protocol PPluginWidget;
 include protocol PRemotePrintJob;
 include protocol PChildToParentStream;
 include protocol PParentToChildStream;
 include protocol PFileDescriptorSet;
 include protocol PIPCBlobInputStream;
 include protocol PPaymentRequest;
 
-include PBackgroundSharedTypes;
 include DOMTypes;
 include IPCBlob;
 include IPCStream;
 include JavaScriptTypes;
 include URIParams;
 include PPrintingTypes;
 include PTabContext;
 
@@ -191,17 +190,17 @@ parent:
                       int32_t aShellItemWidth, int32_t aShellItemHeight);
 
     /**
      * Called by the child to inform the parent that links are dropped into
      * content area.
      *
      * aLinks A flat array of url, name, and type for each link
      */
-    async DropLinks(nsString[] aLinks, PrincipalInfo aTriggeringPrincipalInfo);
+    async DropLinks(nsString[] aLinks);
 
     async Event(RemoteDOMEvent aEvent);
 
     sync SyncMessage(nsString aMessage, ClonedMessageData aData,
                      CpowEntry[] aCpows, Principal aPrincipal)
       returns (StructuredCloneData[] retval);
 
     nested(inside_sync) sync RpcMessage(nsString aMessage, ClonedMessageData aData,
--- a/dom/ipc/TabChild.cpp
+++ b/dom/ipc/TabChild.cpp
@@ -744,18 +744,17 @@ TabChild::RemoteSizeShellTo(int32_t aWid
 
   bool sent = SendSizeShellTo(flags, aWidth, aHeight, aShellItemWidth, aShellItemHeight);
 
   return sent ? NS_OK : NS_ERROR_FAILURE;
 }
 
 NS_IMETHODIMP
 TabChild::RemoteDropLinks(uint32_t aLinksCount,
-                          nsIDroppedLinkItem** aLinks,
-                          nsIPrincipal* aTriggeringPrincipal)
+                          nsIDroppedLinkItem** aLinks)
 {
   nsTArray<nsString> linksArray;
   nsresult rv = NS_OK;
   for (uint32_t i = 0; i < aLinksCount; i++) {
     nsString tmp;
     rv = aLinks[i]->GetUrl(tmp);
     if (NS_FAILED(rv)) {
       return rv;
@@ -769,20 +768,17 @@ TabChild::RemoteDropLinks(uint32_t aLink
     linksArray.AppendElement(tmp);
 
     rv = aLinks[i]->GetType(tmp);
     if (NS_FAILED(rv)) {
       return rv;
     }
     linksArray.AppendElement(tmp);
   }
-
-  PrincipalInfo triggeringPrincipalInfo;
-  PrincipalToPrincipalInfo(aTriggeringPrincipal, &triggeringPrincipalInfo);
-  bool sent = SendDropLinks(linksArray, triggeringPrincipalInfo);
+  bool sent = SendDropLinks(linksArray);
 
   return sent ? NS_OK : NS_ERROR_FAILURE;
 }
 
 NS_IMETHODIMP
 TabChild::SizeBrowserTo(int32_t aWidth, int32_t aHeight)
 {
   NS_WARNING("TabChild::SizeBrowserTo not supported in TabChild");
--- a/dom/ipc/TabParent.cpp
+++ b/dom/ipc/TabParent.cpp
@@ -511,32 +511,26 @@ TabParent::RecvSizeShellTo(const uint32_
   nsCOMPtr<nsIXULWindow> xulWin(do_GetInterface(treeOwner));
   NS_ENSURE_TRUE(xulWin, IPC_OK());
   xulWin->SizeShellToWithLimit(width, height, aShellItemWidth, aShellItemHeight);
 
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
-TabParent::RecvDropLinks(nsTArray<nsString>&& aLinks,
-                         const PrincipalInfo& aTriggeringPrincipalInfo)
+TabParent::RecvDropLinks(nsTArray<nsString>&& aLinks)
 {
   nsCOMPtr<nsIBrowser> browser = do_QueryInterface(mFrameElement);
   if (browser) {
     UniquePtr<const char16_t*[]> links;
     links = MakeUnique<const char16_t*[]>(aLinks.Length());
     for (uint32_t i = 0; i < aLinks.Length(); i++) {
       links[i] = aLinks[i].get();
     }
-    nsCOMPtr<nsIPrincipal> triggeringPrincipal =
-      PrincipalInfoToPrincipal(aTriggeringPrincipalInfo);
-    if (nsContentUtils::IsSystemPrincipal(triggeringPrincipal)) {
-      return IPC_FAIL(this, "Invalid triggeringPrincipal");
-    }
-    browser->DropLinks(aLinks.Length(), links.get(), triggeringPrincipal);
+    browser->DropLinks(aLinks.Length(), links.get());
   }
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 TabParent::RecvEvent(const RemoteDOMEvent& aEvent)
 {
   nsCOMPtr<nsIDOMEvent> event = do_QueryInterface(aEvent.mEvent);
--- a/dom/ipc/TabParent.h
+++ b/dom/ipc/TabParent.h
@@ -148,18 +148,17 @@ public:
                                                 const bool& aForDocumentNavigation) override;
 
   virtual mozilla::ipc::IPCResult RecvSizeShellTo(const uint32_t& aFlags,
                                                   const int32_t& aWidth,
                                                   const int32_t& aHeight,
                                                   const int32_t& aShellItemWidth,
                                                   const int32_t& aShellItemHeight) override;
 
-  virtual mozilla::ipc::IPCResult RecvDropLinks(nsTArray<nsString>&& aLinks,
-                                                const PrincipalInfo& aTriggeringPrincipalInfo) override;
+  virtual mozilla::ipc::IPCResult RecvDropLinks(nsTArray<nsString>&& aLinks) override;
 
   virtual mozilla::ipc::IPCResult RecvEvent(const RemoteDOMEvent& aEvent) override;
 
   virtual mozilla::ipc::IPCResult RecvReplyKeyEvent(const WidgetKeyboardEvent& aEvent) override;
 
   virtual mozilla::ipc::IPCResult
   RecvAccessKeyNotHandled(const WidgetKeyboardEvent& aEvent) override;
 
--- a/toolkit/content/widgets/browser.xml
+++ b/toolkit/content/widgets/browser.xml
@@ -1473,30 +1473,29 @@
                                     aPrintProgressListener);
           ]]>
         </body>
       </method>
 
       <method name="dropLinks">
         <parameter name="aLinksCount"/>
         <parameter name="aLinks"/>
-        <parameter name="aTriggeringPrincipal"/>
         <body><![CDATA[
           if (!this.droppedLinkHandler) {
             return false;
           }
           let links = [];
           for (let i = 0; i < aLinksCount; i += 3) {
             links.push({
               url: aLinks[i],
               name: aLinks[i + 1],
               type: aLinks[i + 2],
             });
           }
-          this.droppedLinkHandler(null, links, aTriggeringPrincipal);
+          this.droppedLinkHandler(null, links);
           return true;
         ]]></body>
       </method>
     </implementation>
 
     <handlers>
       <handler event="keypress" keycode="VK_F7" group="system">
         <![CDATA[