Bug 635673 - Content inside xul:iframe with type=content is always able to resize top chrome window. r=bz
authorJan Varga <jan.varga@gmail.com>
Sat, 25 Jun 2011 13:42:41 +0200
changeset 71743 babf3b1dfdbc36ecd23bca408691f41c2f19c93d
parent 71742 48ad4ffc4230bf90896f1ce197f332c056cb0c74
child 71744 3878e0b60ff22531ba63ddd586b1e87b5ebcfcab
push id20602
push userJan.Varga@gmail.com
push dateSat, 25 Jun 2011 11:49:47 +0000
treeherdermozilla-central@babf3b1dfdbc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs635673
milestone7.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 635673 - Content inside xul:iframe with type=content is always able to resize top chrome window. r=bz
docshell/base/nsDocShell.cpp
docshell/base/nsDocShell.h
docshell/base/nsIDocShell.idl
dom/base/nsGlobalWindow.cpp
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -732,16 +732,17 @@ nsDocShell::nsDocShell():
     mLoadedTransIndex(-1),
     mCreated(PR_FALSE),
     mAllowSubframes(PR_TRUE),
     mAllowPlugins(PR_TRUE),
     mAllowJavascript(PR_TRUE),
     mAllowMetaRedirects(PR_TRUE),
     mAllowImages(PR_TRUE),
     mAllowDNSPrefetch(PR_TRUE),
+    mAllowWindowControl(PR_TRUE),
     mCreatingDocument(PR_FALSE),
     mUseErrorPages(PR_FALSE),
     mObserveErrorPages(PR_TRUE),
     mAllowAuth(PR_TRUE),
     mAllowKeywordFixup(PR_FALSE),
     mIsOffScreenBrowser(PR_FALSE),
     mIsActive(PR_TRUE),
     mIsAppTab(PR_FALSE),
@@ -2031,16 +2032,28 @@ NS_IMETHODIMP nsDocShell::GetAllowDNSPre
 }
 
 NS_IMETHODIMP nsDocShell::SetAllowDNSPrefetch(PRBool aAllowDNSPrefetch)
 {
     mAllowDNSPrefetch = aAllowDNSPrefetch;
     return NS_OK;
 }
 
+NS_IMETHODIMP nsDocShell::GetAllowWindowControl(PRBool * aAllowWindowControl)
+{
+    *aAllowWindowControl = mAllowWindowControl;
+    return NS_OK;
+}
+
+NS_IMETHODIMP nsDocShell::SetAllowWindowControl(PRBool aAllowWindowControl)
+{
+    mAllowWindowControl = aAllowWindowControl;
+    return NS_OK;
+}
+
 NS_IMETHODIMP
 nsDocShell::GetDocShellEnumerator(PRInt32 aItemType, PRInt32 aDirection, nsISimpleEnumerator **outEnum)
 {
     NS_ENSURE_ARG_POINTER(outEnum);
     *outEnum = nsnull;
     
     nsRefPtr<nsDocShellEnumerator> docShellEnum;
     if (aDirection == ENUMERATE_FORWARDS)
@@ -2607,16 +2620,20 @@ nsDocShell::SetDocLoaderParent(nsDocLoad
         if (NS_SUCCEEDED(parentAsDocShell->GetAllowSubframes(&value)))
         {
             SetAllowSubframes(value);
         }
         if (NS_SUCCEEDED(parentAsDocShell->GetAllowImages(&value)))
         {
             SetAllowImages(value);
         }
+        if (NS_SUCCEEDED(parentAsDocShell->GetAllowWindowControl(&value)))
+        {
+            SetAllowWindowControl(value);
+        }
         if (NS_SUCCEEDED(parentAsDocShell->GetIsActive(&value)))
         {
             SetIsActive(value);
         }
         if (NS_FAILED(parentAsDocShell->GetAllowDNSPrefetch(&value))) {
             value = PR_FALSE;
         }
         SetAllowDNSPrefetch(value);
--- a/docshell/base/nsDocShell.h
+++ b/docshell/base/nsDocShell.h
@@ -791,16 +791,17 @@ protected:
 
     PRPackedBool               mCreated;
     PRPackedBool               mAllowSubframes;
     PRPackedBool               mAllowPlugins;
     PRPackedBool               mAllowJavascript;
     PRPackedBool               mAllowMetaRedirects;
     PRPackedBool               mAllowImages;
     PRPackedBool               mAllowDNSPrefetch;
+    PRPackedBool               mAllowWindowControl;
     PRPackedBool               mCreatingDocument; // (should be) debugging only
     PRPackedBool               mUseErrorPages;
     PRPackedBool               mObserveErrorPages;
     PRPackedBool               mAllowAuth;
     PRPackedBool               mAllowKeywordFixup;
     PRPackedBool               mIsOffScreenBrowser;
     PRPackedBool               mIsActive;
     PRPackedBool               mIsAppTab;
--- a/docshell/base/nsIDocShell.idl
+++ b/docshell/base/nsIDocShell.idl
@@ -67,17 +67,17 @@ interface nsIRequest;
 interface nsISHEntry;
 interface nsILayoutHistoryState;
 interface nsISecureBrowserUI;
 interface nsIDOMStorage;
 interface nsIPrincipal;
 interface nsIWebBrowserPrint;
 interface nsIVariant;
 
-[scriptable, uuid(f77271a1-0b22-4581-af6d-529125f1901d)]
+[scriptable, uuid(0666adf8-8738-4ca7-a917-0348f47d2f40)]
 interface nsIDocShell : nsISupports
 {
   /**
    * Loads a given URI.  This will give priority to loading the requested URI
    * in the object implementing	this interface.  If it can't be loaded here
    * however, the URL dispatcher will go through its normal process of content
    * loading.
    *
@@ -270,16 +270,21 @@ interface nsIDocShell : nsISupports
   /**
    * Attribute that determines whether DNS prefetch is allowed for this subtree
    * of the docshell tree.  Defaults to true.  Setting this will make it take
    * effect starting with the next document loaded in the docshell.
    */
   attribute boolean allowDNSPrefetch;
 
   /**
+   * Attribute that determines whether window control (move/resize) is allowed.
+   */
+  attribute boolean allowWindowControl;
+
+  /**
    * Get an enumerator over this docShell and its children.
    *
    * @param aItemType  - Only include docShells of this type, or if typeAll,
    *                     include all child shells.
    *                     Uses types from nsIDocShellTreeItem.
    * @param aDirection - Whether to enumerate forwards or backwards.
    */
 
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -4643,16 +4643,23 @@ nsGlobalWindow::CanMoveResizeWindows()
       PRUint32 itemCount;
       if (NS_SUCCEEDED(treeOwner->GetTargetableShellCount(&itemCount)) &&
           itemCount > 1) {
         return PR_FALSE;
       }
     }
   }
 
+  if (mDocShell) {
+    PRBool allow;
+    nsresult rv = mDocShell->GetAllowWindowControl(&allow);
+    if (NS_SUCCEEDED(rv) && !allow)
+      return PR_FALSE;
+  }
+
   if (gMouseDown && !gDragServiceDisabled) {
     nsCOMPtr<nsIDragService> ds =
       do_GetService("@mozilla.org/widget/dragservice;1");
     if (ds) {
       gDragServiceDisabled = PR_TRUE;
       ds->Suppress();
     }
   }