Attachment #600577: WIP - iframe sandbox v5 for bug #341604

View | Details | Raw Unified | Return to bug 341604
Collapse All | Expand All

(-)a/content/base/public/nsContentUtils.h (-4 / +16 lines)
Line     Link Here 
 Lines 1903-1937   public: Link Here 
1903
   * from the document it comes from.
1903
   * from the document it comes from.
1904
   */
1904
   */
1905
  static nsresult URIInheritsSecurityContext(nsIURI *aURI, bool *aResult);
1905
  static nsresult URIInheritsSecurityContext(nsIURI *aURI, bool *aResult);
1906
1906
1907
  /**
1907
  /**
1908
   * Set the given principal as the owner of the given channel, if
1908
   * Set the given principal as the owner of the given channel, if
1909
   * needed.  aURI must be the URI of aChannel.  aPrincipal may be
1909
   * needed.  aURI must be the URI of aChannel.  aPrincipal may be
1910
   * null.  If aSetUpForAboutBlank is true, then about:blank will get
1910
   * null.  If aSetUpForAboutBlank is true, then about:blank will get
1911
   * the principal set up on it.
1911
   * the principal set up on it. If aForceOwner is true, the owner
1912
   *
1912
   * will be set on the channel, even if the principal can be determined
1913
   * from the channel.
1913
   * The return value is whether the principal was set up as the owner
1914
   * The return value is whether the principal was set up as the owner
1914
   * of the channel.
1915
   * of the channel.
1915
   */
1916
   */
1916
  static bool SetUpChannelOwner(nsIPrincipal* aLoadingPrincipal,
1917
  static bool SetUpChannelOwner(nsIPrincipal* aLoadingPrincipal,
1917
                                nsIChannel* aChannel,
1918
                                nsIChannel* aChannel,
1918
                                nsIURI* aURI,
1919
                                nsIURI* aURI,
1919
                                bool aSetUpForAboutBlank);
1920
                                bool aSetUpForAboutBlank,
1921
                                bool aForceOwner = false);
1920
1922
1921
  static nsresult Btoa(const nsAString& aBinaryData,
1923
  static nsresult Btoa(const nsAString& aBinaryData,
1922
                       nsAString& aAsciiBase64String);
1924
                       nsAString& aAsciiBase64String);
1923
1925
1924
  static nsresult Atob(const nsAString& aAsciiString,
1926
  static nsresult Atob(const nsAString& aAsciiString,
1925
                       nsAString& aBinaryData);
1927
                       nsAString& aBinaryData);
1926
1928
1927
  /**
1929
  /**
1928
   * Returns whether the input element passed in parameter has the autocomplete
1930
   * Returns whether the input element passed in parameter has the autocomplete
1929
   * functionnality enabled. It is taking into account the form owner.
1931
   * functionality enabled. It is taking into account the form owner.
1930
   * NOTE: the caller has to make sure autocomplete makes sense for the
1932
   * NOTE: the caller has to make sure autocomplete makes sense for the
1931
   * element's type.
1933
   * element's type.
1932
   *
1934
   *
1933
   * @param aInput the input element to check. NOTE: aInput can't be null.
1935
   * @param aInput the input element to check. NOTE: aInput can't be null.
1934
   * @return whether the input element has autocomplete enabled.
1936
   * @return whether the input element has autocomplete enabled.
1935
   */
1937
   */
1936
  static bool IsAutocompleteEnabled(nsIDOMHTMLInputElement* aInput);
1938
  static bool IsAutocompleteEnabled(nsIDOMHTMLInputElement* aInput);
1937
1939
 Lines 1942-1957   public: Link Here 
1942
   * comma-separated list of URIs.  Return true if the given URI's prepath is
1944
   * comma-separated list of URIs.  Return true if the given URI's prepath is
1943
   * in the list, and false otherwise.
1945
   * in the list, and false otherwise.
1944
   *
1946
   *
1945
   * Comparisons are case-insensitive, and whitespace between elements of the
1947
   * Comparisons are case-insensitive, and whitespace between elements of the
1946
   * comma-separated list is ignored.
1948
   * comma-separated list is ignored.
1947
   */
1949
   */
1948
  static bool URIIsChromeOrInPref(nsIURI *aURI, const char *aPref);
1950
  static bool URIIsChromeOrInPref(nsIURI *aURI, const char *aPref);
1949
1951
1952
  /**
1953
   * A helper function that parses a sandbox attribute (of an <iframe> or
1954
   * a CSP directive) and converts it to the set of flags used internally.
1955
   *
1956
   * @param aAttribute 	the value of the sandbox attribute
1957
   * @return 			the set of flags
1958
   */
1959
  static PRUint32 ParseSandboxAttributeToFlags(const nsAString&
1960
                                                 sandboxAttr);
1961
1950
private:
1962
private:
1951
  static bool InitializeEventTable();
1963
  static bool InitializeEventTable();
1952
1964
1953
  static nsresult EnsureStringBundle(PropertiesFile aFile);
1965
  static nsresult EnsureStringBundle(PropertiesFile aFile);
1954
1966
1955
  static nsIDOMScriptObjectFactory *GetDOMScriptObjectFactory();
1967
  static nsIDOMScriptObjectFactory *GetDOMScriptObjectFactory();
1956
1968
1957
  static nsresult HoldScriptObject(PRUint32 aLangID, void* aObject);
1969
  static nsresult HoldScriptObject(PRUint32 aLangID, void* aObject);
(-)a/content/base/public/nsIDocument.h (-3 / +17 lines)
Line     Link Here 
 Lines 119-136   class Loader; Link Here 
119
119
120
namespace dom {
120
namespace dom {
121
class Link;
121
class Link;
122
class Element;
122
class Element;
123
} // namespace dom
123
} // namespace dom
124
} // namespace mozilla
124
} // namespace mozilla
125
125
126
#define NS_IDOCUMENT_IID \
126
#define NS_IDOCUMENT_IID \
127
{ 0x283ec27d, 0x5b23, 0x49b2, \
127
{ 0x57fe44ae, 0x6656, 0x44b8, \
128
  { 0x94, 0xd9, 0x9, 0xb5, 0xdb, 0x45, 0x30, 0x73 } }
128
  { 0x8d, 0xc0, 0xfc, 0xa7, 0x43, 0x28, 0xbe, 0x86 } }
129
129
130
130
131
// Flag for AddStyleSheet().
131
// Flag for AddStyleSheet().
132
#define NS_STYLESHEET_FROM_CATALOG                (1 << 0)
132
#define NS_STYLESHEET_FROM_CATALOG                (1 << 0)
133
133
134
// Enum for requesting a particular type of document when creating a doc
134
// Enum for requesting a particular type of document when creating a doc
135
enum DocumentFlavor {
135
enum DocumentFlavor {
136
  DocumentFlavorLegacyGuess, // compat with old code until made HTML5-compliant
136
  DocumentFlavorLegacyGuess, // compat with old code until made HTML5-compliant
 Lines 456-472   public: Link Here 
456
   * callers are expected to take action as needed if they want this
456
   * callers are expected to take action as needed if they want this
457
   * change to actually change anything immediately.
457
   * change to actually change anything immediately.
458
   * @see nsBidiUtils.h
458
   * @see nsBidiUtils.h
459
   */
459
   */
460
  void SetBidiOptions(PRUint32 aBidiOptions)
460
  void SetBidiOptions(PRUint32 aBidiOptions)
461
  {
461
  {
462
    mBidiOptions = aBidiOptions;
462
    mBidiOptions = aBidiOptions;
463
  }
463
  }
464
  
464
465
  /**
466
   * Get the sandbox flags for this document.
467
   * @see nsIDocShell.idl for the possible flags
468
   */
469
  PRUint32 SandboxFlags() const
470
  {
471
    return mSandboxFlags;
472
  }
473
465
  /**
474
  /**
466
   * Access HTTP header data (this may also get set from other
475
   * Access HTTP header data (this may also get set from other
467
   * sources, like HTML META tags).
476
   * sources, like HTML META tags).
468
   */
477
   */
469
  virtual void GetHeaderData(nsIAtom* aHeaderField, nsAString& aData) const = 0;
478
  virtual void GetHeaderData(nsIAtom* aHeaderField, nsAString& aData) const = 0;
470
  virtual void SetHeaderData(nsIAtom* aheaderField, const nsAString& aData) = 0;
479
  virtual void SetHeaderData(nsIAtom* aheaderField, const nsAString& aData) = 0;
471
480
472
  /**
481
  /**
 Lines 1797-1812   protected: Link Here 
1797
  // If mIsStaticDocument is true, mOriginalDocument points to the original
1806
  // If mIsStaticDocument is true, mOriginalDocument points to the original
1798
  // document.
1807
  // document.
1799
  nsCOMPtr<nsIDocument> mOriginalDocument;
1808
  nsCOMPtr<nsIDocument> mOriginalDocument;
1800
1809
1801
  // The bidi options for this document.  What this bitfield means is
1810
  // The bidi options for this document.  What this bitfield means is
1802
  // defined in nsBidiUtils.h
1811
  // defined in nsBidiUtils.h
1803
  PRUint32 mBidiOptions;
1812
  PRUint32 mBidiOptions;
1804
1813
1814
  // The sandbox flags on the document. These reflect the value of the sandbox attribute of the
1815
  // associated IFRAME or CSP-protectable content, if existent. These are set at load time and
1816
  // are immutable - see nsIDocShell.idl for the possible flags.
1817
  PRUint32 mSandboxFlags;
1818
1805
  nsCString mContentLanguage;
1819
  nsCString mContentLanguage;
1806
private:
1820
private:
1807
  nsCString mContentType;
1821
  nsCString mContentType;
1808
protected:
1822
protected:
1809
1823
1810
  // The document's security info
1824
  // The document's security info
1811
  nsCOMPtr<nsISupports> mSecurityInfo;
1825
  nsCOMPtr<nsISupports> mSecurityInfo;
1812
1826
(-)a/content/base/src/nsContentUtils.cpp (-3 / +54 lines)
Line     Link Here 
 Lines 741-756   nsContentUtils::GetParserService() Link Here 
741
    nsresult rv = CallGetService(kParserServiceCID, &sParserService);
741
    nsresult rv = CallGetService(kParserServiceCID, &sParserService);
742
    if (NS_FAILED(rv)) {
742
    if (NS_FAILED(rv)) {
743
      sParserService = nsnull;
743
      sParserService = nsnull;
744
    }
744
    }
745
  }
745
  }
746
746
747
  return sParserService;
747
  return sParserService;
748
}
748
}
749
/**
750
 * A helper function that parses a sandbox attribute (of an <iframe> or
751
 * a CSP directive) and converts it to the set of flags used internally.
752
 *
753
 * @param aAttribute    the value of the sandbox attribute
754
 * @return              the set of flags
755
 */
756
PRUint32
757
nsContentUtils::ParseSandboxAttributeToFlags(const nsAString& sandboxAttrValue)
758
{
759
  // If there's a sandbox attribute at all (and there is if this is being
760
  // called), start off by setting all the restriction flags.
761
  PRUint32 out = nsIDocShell::SANDBOXED_NAVIGATION |
762
    nsIDocShell::SANDBOXED_TOPLEVEL_NAVIGATION |
763
    nsIDocShell::SANDBOXED_PLUGINS | nsIDocShell::SANDBOXED_ORIGIN |
764
    nsIDocShell::SANDBOXED_FORMS | nsIDocShell::SANDBOXED_SCRIPTS |
765
    nsIDocShell::SANDBOXED_AUTOMATIC_FEATURES;
766
767
  if (!sandboxAttrValue.IsEmpty()) {
768
    // The separator optional flag is used because the HTML5 spec says any
769
    // whitespace is ok as a separator, which is what this does.
770
    HTMLSplitOnSpacesTokenizer tokenizer(sandboxAttrValue, ' ',
771
      nsCharSeparatedTokenizerTemplate<nsContentUtils::IsHTMLWhitespace>::SEPARATOR_OPTIONAL);
772
773
    while (tokenizer.hasMoreTokens()) {
774
      nsDependentSubstring token = tokenizer.nextToken();
775
776
      if (token.LowerCaseEqualsLiteral("allow-scripts")) {
777
        out &= ~nsIDocShell::SANDBOXED_SCRIPTS;
778
      } else if (token.LowerCaseEqualsLiteral("allow-same-origin")) {
779
        out &= ~nsIDocShell::SANDBOXED_ORIGIN;
780
      } else if (token.LowerCaseEqualsLiteral("allow-forms")) {
781
        out &= ~nsIDocShell::SANDBOXED_FORMS;
782
      } else if (token.LowerCaseEqualsLiteral("allow-scripts")) {
783
        // allow-scripts removes both SANDBOXED_SCRIPTS and
784
        // SANDBOXED_AUTOMATIC_FEATURES.
785
        out &= ~nsIDocShell::SANDBOXED_SCRIPTS;
786
        out &= ~nsIDocShell::SANDBOXED_AUTOMATIC_FEATURES;
787
      } else if (token.LowerCaseEqualsLiteral("allow-top-navigation")) {
788
        out &= ~nsIDocShell::SANDBOXED_TOPLEVEL_NAVIGATION;
789
      }
790
    }
791
  }
792
793
  return out;
794
}
749
795
750
#ifdef MOZ_XTF
796
#ifdef MOZ_XTF
751
nsIXTFService*
797
nsIXTFService*
752
nsContentUtils::GetXTFService()
798
nsContentUtils::GetXTFService()
753
{
799
{
754
  if (!sXTFService) {
800
  if (!sXTFService) {
755
    nsresult rv = CallGetService(kXTFServiceCID, &sXTFService);
801
    nsresult rv = CallGetService(kXTFServiceCID, &sXTFService);
756
    if (NS_FAILED(rv)) {
802
    if (NS_FAILED(rv)) {
 Lines 6055-6071   nsContentUtils::URIInheritsSecurityConte Link Here 
6055
                             aResult);
6101
                             aResult);
6056
}
6102
}
6057
6103
6058
// static
6104
// static
6059
bool
6105
bool
6060
nsContentUtils::SetUpChannelOwner(nsIPrincipal* aLoadingPrincipal,
6106
nsContentUtils::SetUpChannelOwner(nsIPrincipal* aLoadingPrincipal,
6061
                                  nsIChannel* aChannel,
6107
                                  nsIChannel* aChannel,
6062
                                  nsIURI* aURI,
6108
                                  nsIURI* aURI,
6063
                                  bool aSetUpForAboutBlank)
6109
                                  bool aSetUpForAboutBlank,
6110
                                  bool aForceOwner)
6064
{
6111
{
6065
  //
6112
  //
6066
  // Set the owner of the channel, but only for channels that can't
6113
  // Set the owner of the channel, but only for channels that can't
6067
  // provide their own security context.
6114
  // provide their own security context.
6068
  //
6115
  //
6069
  // XXX: It seems wrong that the owner is ignored - even if one is
6116
  // XXX: It seems wrong that the owner is ignored - even if one is
6070
  //      supplied) unless the URI is javascript or data or about:blank.
6117
  //      supplied) unless the URI is javascript or data or about:blank.
6071
  // XXX: If this is ever changed, check all callers for what owners
6118
  // XXX: If this is ever changed, check all callers for what owners
 Lines 6073-6095   nsContentUtils::SetUpChannelOwner(nsIPri Link Here 
6073
  //      comments in nsDocShell::LoadURI where we fall back on
6120
  //      comments in nsDocShell::LoadURI where we fall back on
6074
  //      inheriting the owner if called from chrome.  That would be
6121
  //      inheriting the owner if called from chrome.  That would be
6075
  //      very wrong if this code changed anything but channels that
6122
  //      very wrong if this code changed anything but channels that
6076
  //      can't provide their own security context!
6123
  //      can't provide their own security context!
6077
  //
6124
  //
6078
  //      (Currently chrome URIs set the owner when they are created!
6125
  //      (Currently chrome URIs set the owner when they are created!
6079
  //      So setting a NULL owner would be bad!)
6126
  //      So setting a NULL owner would be bad!)
6080
  //
6127
  //
6128
  // If aForceOwner is true, the owner will be set, even for a channel that
6129
  // can provide its own security context. This is used for the HTML5 IFRAME
6130
  // sandbox attribute, so we can force the channel (and its document) to
6131
  // explicitly have a null principal.
6081
  bool inherit;
6132
  bool inherit;
6082
  // We expect URIInheritsSecurityContext to return success for an
6133
  // We expect URIInheritsSecurityContext to return success for an
6083
  // about:blank URI, so don't call NS_IsAboutBlank() if this call fails.
6134
  // about:blank URI, so don't call NS_IsAboutBlank() if this call fails.
6084
  // This condition needs to match the one in nsDocShell::InternalLoad where
6135
  // This condition needs to match the one in nsDocShell::InternalLoad where
6085
  // we're checking for things that will use the owner.
6136
  // we're checking for things that will use the owner.
6086
  if (NS_SUCCEEDED(URIInheritsSecurityContext(aURI, &inherit)) &&
6137
  if (aForceOwner || ((NS_SUCCEEDED(URIInheritsSecurityContext(aURI, &inherit)) &&
6087
      (inherit || (aSetUpForAboutBlank && NS_IsAboutBlank(aURI)))) {
6138
      (inherit || (aSetUpForAboutBlank && NS_IsAboutBlank(aURI)))))) {
6088
    aChannel->SetOwner(aLoadingPrincipal);
6139
    aChannel->SetOwner(aLoadingPrincipal);
6089
    return true;
6140
    return true;
6090
  }
6141
  }
6091
6142
6092
  //
6143
  //
6093
  // file: uri special-casing
6144
  // file: uri special-casing
6094
  //
6145
  //
6095
  // If this is a file: load opened from another file: then it may need
6146
  // If this is a file: load opened from another file: then it may need
(-)a/content/base/src/nsDocument.cpp (+9 lines)
Line     Link Here 
 Lines 2392-2407   nsDocument::StartDocumentLoad(const char Link Here 
2392
    FindCharInReadable(';', semicolon, end);
2392
    FindCharInReadable(';', semicolon, end);
2393
    SetContentTypeInternal(Substring(start, semicolon));
2393
    SetContentTypeInternal(Substring(start, semicolon));
2394
  }
2394
  }
2395
2395
2396
  RetrieveRelevantHeaders(aChannel);
2396
  RetrieveRelevantHeaders(aChannel);
2397
2397
2398
  mChannel = aChannel;
2398
  mChannel = aChannel;
2399
2399
2400
  // If this document is being loaded by a docshell, copy its sandbox flags
2401
  // to the document. These are immutable after being set here.
2402
  nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(aContainer);
2403
2404
  if (docShell) {
2405
    nsresult rv = docShell->GetSandboxFlags(&mSandboxFlags);
2406
    NS_ENSURE_SUCCESS(rv, rv);
2407
  }
2408
2400
  nsresult rv = InitCSP();
2409
  nsresult rv = InitCSP();
2401
  NS_ENSURE_SUCCESS(rv, rv);
2410
  NS_ENSURE_SUCCESS(rv, rv);
2402
2411
2403
  return NS_OK;
2412
  return NS_OK;
2404
}
2413
}
2405
2414
2406
nsresult
2415
nsresult
2407
nsDocument::InitCSP()
2416
nsDocument::InitCSP()
(-)a/content/base/src/nsFrameLoader.cpp (+50 lines)
Line     Link Here 
 Lines 113-128    Link Here 
113
#include "mozilla/GuardObjects.h"
113
#include "mozilla/GuardObjects.h"
114
#include "mozilla/Preferences.h"
114
#include "mozilla/Preferences.h"
115
#include "mozilla/unused.h"
115
#include "mozilla/unused.h"
116
#include "mozilla/dom/Element.h"
116
#include "mozilla/dom/Element.h"
117
#include "mozilla/layout/RenderFrameParent.h"
117
#include "mozilla/layout/RenderFrameParent.h"
118
118
119
#include "jsapi.h"
119
#include "jsapi.h"
120
120
121
#include "nsHTMLIFrameElement.h"
122
121
using namespace mozilla;
123
using namespace mozilla;
122
using namespace mozilla::dom;
124
using namespace mozilla::dom;
123
using namespace mozilla::layers;
125
using namespace mozilla::layers;
124
using namespace mozilla::layout;
126
using namespace mozilla::layout;
125
typedef FrameMetrics::ViewID ViewID;
127
typedef FrameMetrics::ViewID ViewID;
126
128
127
class nsAsyncDocShellDestroyer : public nsRunnable
129
class nsAsyncDocShellDestroyer : public nsRunnable
128
{
130
{
 Lines 468-483   nsFrameLoader::ReallyStartLoadingInterna Link Here 
468
  // Just to be safe, recheck uri.
470
  // Just to be safe, recheck uri.
469
  rv = CheckURILoad(mURIToLoad);
471
  rv = CheckURILoad(mURIToLoad);
470
  NS_ENSURE_SUCCESS(rv, rv);
472
  NS_ENSURE_SUCCESS(rv, rv);
471
473
472
  nsCOMPtr<nsIDocShellLoadInfo> loadInfo;
474
  nsCOMPtr<nsIDocShellLoadInfo> loadInfo;
473
  mDocShell->CreateLoadInfo(getter_AddRefs(loadInfo));
475
  mDocShell->CreateLoadInfo(getter_AddRefs(loadInfo));
474
  NS_ENSURE_TRUE(loadInfo, NS_ERROR_FAILURE);
476
  NS_ENSURE_TRUE(loadInfo, NS_ERROR_FAILURE);
475
477
478
  // Is this an <iframe> with a sandbox attribute or a parent which is
479
  // sandboxed ?
480
  nsHTMLIFrameElement * iframe =
481
    nsHTMLIFrameElement::FromContent(mOwnerContent);
482
483
  PRUint32 sandboxFlags = 0;
484
485
  if (iframe) {
486
    sandboxFlags = iframe->GetSandboxFlags();
487
488
    PRUint32 parentSandboxFlags = 0;
489
490
    // Get the parent's sandbox flags, they're needed to determine if the
491
    // frame being loaded needs to be sandboxed.
492
    nsCOMPtr<nsIDocShellTreeItem> parentDocShellItem;
493
    nsCOMPtr<nsIDocShellTreeItem> curDocShellItem = do_QueryInterface(mDocShell);
494
495
    if (NS_SUCCEEDED(curDocShellItem->GetParent(getter_AddRefs(parentDocShellItem)))) {
496
      nsCOMPtr<nsIDocument> parentDoc = do_GetInterface(parentDocShellItem);
497
498
      if (parentDoc) {
499
        parentSandboxFlags = parentDoc->SandboxFlags();
500
      }
501
    }
502
503
    if (sandboxFlags || parentSandboxFlags) {
504
      if (parentSandboxFlags) {
505
        // The child can only add restrictions, not remove them.
506
        sandboxFlags |= parentSandboxFlags;
507
      }
508
509
      mDocShell->SetSandboxFlags(sandboxFlags);
510
511
      // Set up the actual sandboxing for scripts and plugins as specified.
512
      if (sandboxFlags & nsIDocShell::SANDBOXED_SCRIPTS) {
513
        mDocShell->SetAllowJavascript(false);
514
      }
515
516
      if (sandboxFlags & nsIDocShell::SANDBOXED_PLUGINS) {
517
        mDocShell->SetAllowPlugins(false);
518
      }
519
    }
520
  }
521
522
  // If this is an <iframe> and it's sandboxed with respect to origin
523
  // we will set it up with a null principal later in nsDocShell::DoURILoad.
524
  // We do it there to correctly sandbox content that was loaded into
525
  // the iframe via other methods than the src attribute.
476
  // We'll use our principal, not that of the document loaded inside us.  This
526
  // We'll use our principal, not that of the document loaded inside us.  This
477
  // is very important; needed to prevent XSS attacks on documents loaded in
527
  // is very important; needed to prevent XSS attacks on documents loaded in
478
  // subframes!
528
  // subframes!
479
  loadInfo->SetOwner(mOwnerContent->NodePrincipal());
529
  loadInfo->SetOwner(mOwnerContent->NodePrincipal());
480
530
481
  nsCOMPtr<nsIURI> referrer;
531
  nsCOMPtr<nsIURI> referrer;
482
  rv = mOwnerContent->NodePrincipal()->GetURI(getter_AddRefs(referrer));
532
  rv = mOwnerContent->NodePrincipal()->GetURI(getter_AddRefs(referrer));
483
  NS_ENSURE_SUCCESS(rv, rv);
533
  NS_ENSURE_SUCCESS(rv, rv);
(-)a/content/base/src/nsGkAtomList.h (+5 lines)
Line     Link Here 
 Lines 93-109   GK_ATOM(actuate, "actuate") Link Here 
93
GK_ATOM(address, "address")
93
GK_ATOM(address, "address")
94
GK_ATOM(after, "after")
94
GK_ATOM(after, "after")
95
GK_ATOM(after_end, "after_end")
95
GK_ATOM(after_end, "after_end")
96
GK_ATOM(after_start, "after_start")
96
GK_ATOM(after_start, "after_start")
97
GK_ATOM(align, "align")
97
GK_ATOM(align, "align")
98
GK_ATOM(alink, "alink")
98
GK_ATOM(alink, "alink")
99
GK_ATOM(all, "all")
99
GK_ATOM(all, "all")
100
GK_ATOM(allowevents, "allowevents")
100
GK_ATOM(allowevents, "allowevents")
101
GK_ATOM(allowforms, "allow-forms")
101
GK_ATOM(allownegativeassertions, "allownegativeassertions")
102
GK_ATOM(allownegativeassertions, "allownegativeassertions")
103
GK_ATOM(allowsameorigin, "allow-same-origin")
104
GK_ATOM(allowscripts, "allow-scripts")
105
GK_ATOM(allowtopnavigation, "allow-top-navigation")
102
GK_ATOM(allowuntrusted, "allowuntrusted")
106
GK_ATOM(allowuntrusted, "allowuntrusted")
103
GK_ATOM(alt, "alt")
107
GK_ATOM(alt, "alt")
104
GK_ATOM(alternate, "alternate")
108
GK_ATOM(alternate, "alternate")
105
GK_ATOM(always, "always")
109
GK_ATOM(always, "always")
106
GK_ATOM(ancestor, "ancestor")
110
GK_ATOM(ancestor, "ancestor")
107
GK_ATOM(ancestorOrSelf, "ancestor-or-self")
111
GK_ATOM(ancestorOrSelf, "ancestor-or-self")
108
GK_ATOM(_and, "and")
112
GK_ATOM(_and, "and")
109
GK_ATOM(any, "any")
113
GK_ATOM(any, "any")
 Lines 875-890   GK_ATOM(rowspan, "rowspan") Link Here 
875
GK_ATOM(rp, "rp")
879
GK_ATOM(rp, "rp")
876
GK_ATOM(rt, "rt")
880
GK_ATOM(rt, "rt")
877
GK_ATOM(rtl, "rtl")
881
GK_ATOM(rtl, "rtl")
878
GK_ATOM(ruby, "ruby")
882
GK_ATOM(ruby, "ruby")
879
GK_ATOM(rule, "rule")
883
GK_ATOM(rule, "rule")
880
GK_ATOM(rules, "rules")
884
GK_ATOM(rules, "rules")
881
GK_ATOM(s, "s")
885
GK_ATOM(s, "s")
882
GK_ATOM(samp, "samp")
886
GK_ATOM(samp, "samp")
887
GK_ATOM(sandbox, "sandbox")
883
GK_ATOM(sbattr, "sbattr")
888
GK_ATOM(sbattr, "sbattr")
884
GK_ATOM(scale, "scale")
889
GK_ATOM(scale, "scale")
885
GK_ATOM(scan, "scan")
890
GK_ATOM(scan, "scan")
886
GK_ATOM(scheme, "scheme")
891
GK_ATOM(scheme, "scheme")
887
GK_ATOM(scope, "scope")
892
GK_ATOM(scope, "scope")
888
GK_ATOM(scoped, "scoped")
893
GK_ATOM(scoped, "scoped")
889
GK_ATOM(screen, "screen")
894
GK_ATOM(screen, "screen")
890
GK_ATOM(screenX, "screenX")
895
GK_ATOM(screenX, "screenX")
(-)a/content/html/content/src/nsHTMLFormElement.cpp (-1 / +9 lines)
Line     Link Here 
 Lines 684-700   nsHTMLFormElement::DoSubmitOrReset(nsEve Link Here 
684
    return DoReset();
684
    return DoReset();
685
  }
685
  }
686
686
687
  if (NS_FORM_SUBMIT == aMessage) {
687
  if (NS_FORM_SUBMIT == aMessage) {
688
    // Don't submit if we're not in a document.
688
    // Don't submit if we're not in a document.
689
    if (!doc) {
689
    if (!doc) {
690
      return NS_OK;
690
      return NS_OK;
691
    }
691
    }
692
    return DoSubmit(aEvent);
692
    // Don't submit if we're in a sandboxed frame and form submit
693
    // is disabled.
694
    PRUint32 sandboxFlags = doc->SandboxFlags();
695
696
    if (!(sandboxFlags & nsIDocShell::SANDBOXED_FORMS)) {
697
      return DoSubmit(aEvent);
698
    }
699
700
	return NS_OK;
693
  }
701
  }
694
702
695
  MOZ_ASSERT(false);
703
  MOZ_ASSERT(false);
696
  return NS_OK;
704
  return NS_OK;
697
}
705
}
698
706
699
nsresult
707
nsresult
700
nsHTMLFormElement::DoReset()
708
nsHTMLFormElement::DoReset()
(-)a/content/html/content/src/nsHTMLIFrameElement.cpp (-51 / +48 lines)
Line     Link Here 
 Lines 33-113    Link Here 
33
 * the provisions above, a recipient may use your version of this file under
33
 * the provisions above, a recipient may use your version of this file under
34
 * the terms of any one of the MPL, the GPL or the LGPL.
34
 * the terms of any one of the MPL, the GPL or the LGPL.
35
 *
35
 *
36
 * ***** END LICENSE BLOCK ***** */
36
 * ***** END LICENSE BLOCK ***** */
37
37
38
#include "mozilla/Util.h"
38
#include "mozilla/Util.h"
39
39
40
#include "nsIDOMHTMLIFrameElement.h"
40
#include "nsIDOMHTMLIFrameElement.h"
41
#include "nsGenericHTMLFrameElement.h"
41
#include "nsHTMLIFrameElement.h"
42
#include "nsIDOMDocument.h"
43
#include "nsIDOMGetSVGDocument.h"
44
#include "nsIDOMSVGDocument.h"
45
#include "nsGkAtoms.h"
46
#include "nsIDocument.h"
47
#include "nsMappedAttributes.h"
48
#include "nsDOMError.h"
49
#include "nsRuleData.h"
50
#include "nsStyleConsts.h"
51
42
52
using namespace mozilla;
43
using namespace mozilla;
53
using namespace mozilla::dom;
44
using namespace mozilla::dom;
54
45
55
class nsHTMLIFrameElement : public nsGenericHTMLFrameElement
56
                          , public nsIDOMHTMLIFrameElement
57
                          , public nsIDOMGetSVGDocument
58
{
59
public:
60
  nsHTMLIFrameElement(already_AddRefed<nsINodeInfo> aNodeInfo,
61
                      mozilla::dom::FromParser aFromParser = mozilla::dom::NOT_FROM_PARSER);
62
  virtual ~nsHTMLIFrameElement();
63
64
  // nsISupports
65
  NS_DECL_ISUPPORTS_INHERITED
66
67
  // nsIDOMNode
68
  NS_FORWARD_NSIDOMNODE(nsGenericHTMLFrameElement::)
69
70
  // nsIDOMElement
71
  NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLFrameElement::)
72
73
  // nsIDOMHTMLElement
74
  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLFrameElement::)
75
76
  // nsIDOMHTMLIFrameElement
77
  NS_DECL_NSIDOMHTMLIFRAMEELEMENT
78
79
  // nsIDOMGetSVGDocument
80
  NS_DECL_NSIDOMGETSVGDOCUMENT
81
82
  // nsIContent
83
  virtual bool ParseAttribute(PRInt32 aNamespaceID,
84
                                nsIAtom* aAttribute,
85
                                const nsAString& aValue,
86
                                nsAttrValue& aResult);
87
  NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const;
88
  virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const;
89
90
  virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
91
  virtual nsXPCClassInfo* GetClassInfo();
92
};
93
94
95
NS_IMPL_NS_NEW_HTML_ELEMENT_CHECK_PARSER(IFrame)
46
NS_IMPL_NS_NEW_HTML_ELEMENT_CHECK_PARSER(IFrame)
96
47
97
98
nsHTMLIFrameElement::nsHTMLIFrameElement(already_AddRefed<nsINodeInfo> aNodeInfo,
48
nsHTMLIFrameElement::nsHTMLIFrameElement(already_AddRefed<nsINodeInfo> aNodeInfo,
99
                                         FromParser aFromParser)
49
                                         FromParser aFromParser)
100
  : nsGenericHTMLFrameElement(aNodeInfo, aFromParser)
50
  : nsGenericHTMLFrameElement(aNodeInfo, aFromParser)
101
{
51
{
102
}
52
}
103
53
104
nsHTMLIFrameElement::~nsHTMLIFrameElement()
54
nsHTMLIFrameElement::~nsHTMLIFrameElement()
105
{
55
{
56
  if (mSandboxTokenList)
57
    mSandboxTokenList->DropReference();
106
}
58
}
107
59
108
60
109
NS_IMPL_ADDREF_INHERITED(nsHTMLIFrameElement,nsGenericElement)
61
NS_IMPL_ADDREF_INHERITED(nsHTMLIFrameElement,nsGenericElement)
110
NS_IMPL_RELEASE_INHERITED(nsHTMLIFrameElement,nsGenericElement)
62
NS_IMPL_RELEASE_INHERITED(nsHTMLIFrameElement,nsGenericElement)
111
63
112
DOMCI_NODE_DATA(HTMLIFrameElement, nsHTMLIFrameElement)
64
DOMCI_NODE_DATA(HTMLIFrameElement, nsHTMLIFrameElement)
113
65
 Lines 150-165   nsHTMLIFrameElement::GetContentWindow(ns Link Here 
150
}
102
}
151
103
152
NS_IMETHODIMP
104
NS_IMETHODIMP
153
nsHTMLIFrameElement::GetSVGDocument(nsIDOMDocument **aResult)
105
nsHTMLIFrameElement::GetSVGDocument(nsIDOMDocument **aResult)
154
{
106
{
155
  return GetContentDocument(aResult);
107
  return GetContentDocument(aResult);
156
}
108
}
157
109
110
NS_IMETHODIMP
111
nsHTMLIFrameElement::GetSandbox(nsIDOMDOMSettableTokenList** aSandbox)
112
{
113
  if (!mSandboxTokenList) {
114
    mSandboxTokenList = new nsDOMSettableTokenList(this, nsGkAtoms::sandbox);
115
  }
116
117
  NS_ADDREF(*aSandbox = mSandboxTokenList);
118
119
  return NS_OK;
120
}
121
158
bool
122
bool
159
nsHTMLIFrameElement::ParseAttribute(PRInt32 aNamespaceID,
123
nsHTMLIFrameElement::ParseAttribute(PRInt32 aNamespaceID,
160
                                    nsIAtom* aAttribute,
124
                                    nsIAtom* aAttribute,
161
                                    const nsAString& aValue,
125
                                    const nsAString& aValue,
162
                                    nsAttrValue& aResult)
126
                                    nsAttrValue& aResult)
163
{
127
{
164
  if (aNamespaceID == kNameSpaceID_None) {
128
  if (aNamespaceID == kNameSpaceID_None) {
165
    if (aAttribute == nsGkAtoms::marginwidth) {
129
    if (aAttribute == nsGkAtoms::marginwidth) {
 Lines 178-193   nsHTMLIFrameElement::ParseAttribute(PRIn Link Here 
178
      return ParseFrameborderValue(aValue, aResult);
142
      return ParseFrameborderValue(aValue, aResult);
179
    }
143
    }
180
    if (aAttribute == nsGkAtoms::scrolling) {
144
    if (aAttribute == nsGkAtoms::scrolling) {
181
      return ParseScrollingValue(aValue, aResult);
145
      return ParseScrollingValue(aValue, aResult);
182
    }
146
    }
183
    if (aAttribute == nsGkAtoms::align) {
147
    if (aAttribute == nsGkAtoms::align) {
184
      return ParseAlignValue(aValue, aResult);
148
      return ParseAlignValue(aValue, aResult);
185
    }
149
    }
150
    if (aAttribute == nsGkAtoms::sandbox) {
151
      // The sandbox attribute needs to be parsed as an atom array so
152
      // it can be exposed as a DOMSettableTokenList.
153
      aResult.ParseAtomArray(aValue);
154
      return true;
155
    }
186
  }
156
  }
187
157
188
  return nsGenericHTMLFrameElement::ParseAttribute(aNamespaceID, aAttribute,
158
  return nsGenericHTMLFrameElement::ParseAttribute(aNamespaceID, aAttribute,
189
                                                   aValue, aResult);
159
                                                   aValue, aResult);
190
}
160
}
191
161
192
static void
162
static void
193
MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
163
MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
 Lines 268-275   nsHTMLIFrameElement::IsAttributeMapped(c Link Here 
268
238
269
239
270
nsMapRuleToAttributesFunc
240
nsMapRuleToAttributesFunc
271
nsHTMLIFrameElement::GetAttributeMappingFunction() const
241
nsHTMLIFrameElement::GetAttributeMappingFunction() const
272
{
242
{
273
  return &MapAttributesIntoRule;
243
  return &MapAttributesIntoRule;
274
}
244
}
275
245
246
nsresult
247
nsHTMLIFrameElement::AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
248
                                    const nsAttrValue* aValue,
249
                                    bool aNotify)
250
{
251
  if (aName == nsGkAtoms::sandbox && aNameSpaceID == kNameSpaceID_None) {
252
    // Parse the new value of the sandbox attribute, and if we have a docshell
253
    // set its sandbox flags appropriately.
254
    if (mFrameLoader) {
255
      nsCOMPtr<nsIDocShell> docshell = mFrameLoader->GetExistingDocShell();
256
257
      if (docshell) {
258
        PRUint32 newFlags = 0;
259
        // If a NULL aValue is passed in, we want to clear the sandbox flags
260
        // which we will do by setting them to 0.
261
        if (aValue) {
262
          newFlags = nsContentUtils::ParseSandboxAttributeToFlags(
263
            aValue->GetStringValue());
264
        }
265
        docshell->SetSandboxFlags(newFlags);
266
      }
267
    }
268
  }
269
  return nsGenericHTMLElement::AfterSetAttr(aNameSpaceID, aName, aValue,
270
                                            aNotify);
271
272
}
(-)a/content/html/content/src/nsHTMLIFrameElement.h (+117 lines)
Line     Link Here 
Line 0    Link Here 
1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* ***** BEGIN LICENSE BLOCK *****
3
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4
 *
5
 * The contents of this file are subject to the Mozilla Public License Version
6
 * 1.1 (the "License"); you may not use this file except in compliance with
7
 * the License. You may obtain a copy of the License at
8
 * http://www.mozilla.org/MPL/
9
 *
10
 * Software distributed under the License is distributed on an "AS IS" basis,
11
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12
 * for the specific language governing rights and limitations under the
13
 * License.
14
 *
15
 * The Original Code is Mozilla Communicator client code.
16
 *
17
 * The Initial Developer of the Original Code is
18
 * Netscape Communications Corporation.
19
 * Portions created by the Initial Developer are Copyright (C) 1998
20
 * the Initial Developer. All Rights Reserved.
21
 *
22
 * Contributor(s):
23
 *
24
 * Alternatively, the contents of this file may be used under the terms of
25
 * either of the GNU General Public License Version 2 or later (the "GPL"),
26
 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27
 * in which case the provisions of the GPL or the LGPL are applicable instead
28
 * of those above. If you wish to allow use of your version of this file only
29
 * under the terms of either the GPL or the LGPL, and not to allow others to
30
 * use your version of this file under the terms of the MPL, indicate your
31
 * decision by deleting the provisions above and replace them with the notice
32
 * and other provisions required by the GPL or the LGPL. If you do not delete
33
 * the provisions above, a recipient may use your version of this file under
34
 * the terms of any one of the MPL, the GPL or the LGPL.
35
 *
36
 * ***** END LICENSE BLOCK ***** */
37
38
#include "mozilla/Util.h"
39
40
#include "nsIDOMHTMLIFrameElement.h"
41
#include "nsGenericHTMLElement.h"
42
#include "nsGenericHTMLFrameElement.h"
43
#include "nsIDOMDocument.h"
44
#include "nsIDOMGetSVGDocument.h"
45
#include "nsIDOMSVGDocument.h"
46
#include "nsGkAtoms.h"
47
#include "nsIDocument.h"
48
#include "nsMappedAttributes.h"
49
#include "nsDOMError.h"
50
#include "nsRuleData.h"
51
#include "nsStyleConsts.h"
52
#include "nsDOMSettableTokenList.h"
53
#include "nsContentUtils.h"
54
55
class nsHTMLIFrameElement : public nsGenericHTMLFrameElement
56
                          , public nsIDOMHTMLIFrameElement
57
                          , public nsIDOMGetSVGDocument
58
{
59
public:
60
  nsHTMLIFrameElement(already_AddRefed<nsINodeInfo> aNodeInfo,
61
                      mozilla::dom::FromParser aFromParser = mozilla::dom::NOT_FROM_PARSER);
62
  virtual ~nsHTMLIFrameElement();
63
64
  // nsISupports
65
  NS_DECL_ISUPPORTS_INHERITED
66
67
  // nsIDOMNode
68
  NS_FORWARD_NSIDOMNODE(nsGenericHTMLFrameElement::)
69
70
  // nsIDOMElement
71
  NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLFrameElement::)
72
73
  // nsIDOMHTMLElement
74
  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLFrameElement::)
75
76
  // nsIDOMHTMLIFrameElement
77
  NS_DECL_NSIDOMHTMLIFRAMEELEMENT
78
79
  // nsIDOMGetSVGDocument
80
  NS_DECL_NSIDOMGETSVGDOCUMENT
81
82
  // nsIContent
83
  virtual bool ParseAttribute(PRInt32 aNamespaceID,
84
                                nsIAtom* aAttribute,
85
                                const nsAString& aValue,
86
                                nsAttrValue& aResult);
87
  NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const;
88
  virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const;
89
90
  virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
91
  virtual nsXPCClassInfo* GetClassInfo();
92
93
  virtual nsresult AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
94
                                  const nsAttrValue* aValue,
95
                                  bool aNotify);
96
97
  PRUint32 GetSandboxFlags() {
98
    nsAutoString sandboxAttr;
99
100
    if (GetAttr(kNameSpaceID_None, nsGkAtoms::sandbox, sandboxAttr)) {
101
      return nsContentUtils::ParseSandboxAttributeToFlags(sandboxAttr);
102
    }
103
104
    // No sandbox attribute, no sandbox flags.
105
    return 0;
106
  }
107
108
  static nsHTMLIFrameElement* FromContent(nsIContent *aContent)
109
  {
110
    if (aContent->IsHTML(nsGkAtoms::iframe))
111
      return static_cast<nsHTMLIFrameElement*>(aContent);
112
    return nsnull;
113
  }
114
115
protected:
116
  nsRefPtr<nsDOMSettableTokenList>  mSandboxTokenList;
117
};
(-)a/content/html/document/src/nsHTMLDocument.cpp (+10 lines)
Line     Link Here 
 Lines 1267-1282   nsHTMLDocument::GetCookie(nsAString& aCo Link Here 
1267
{
1267
{
1268
  aCookie.Truncate(); // clear current cookie in case service fails;
1268
  aCookie.Truncate(); // clear current cookie in case service fails;
1269
                      // no cookie isn't an error condition.
1269
                      // no cookie isn't an error condition.
1270
1270
1271
  if (mDisableCookieAccess) {
1271
  if (mDisableCookieAccess) {
1272
    return NS_OK;
1272
    return NS_OK;
1273
  }
1273
  }
1274
1274
1275
  // If the document's sandboxed origin flag is set, access to read cookies
1276
  // is prohibited.
1277
  if (mSandboxFlags & nsIDocShell::SANDBOXED_ORIGIN)
1278
    return NS_ERROR_DOM_SECURITY_ERR;
1279
1275
  // not having a cookie service isn't an error
1280
  // not having a cookie service isn't an error
1276
  nsCOMPtr<nsICookieService> service = do_GetService(NS_COOKIESERVICE_CONTRACTID);
1281
  nsCOMPtr<nsICookieService> service = do_GetService(NS_COOKIESERVICE_CONTRACTID);
1277
  if (service) {
1282
  if (service) {
1278
    // Get a URI from the document principal. We use the original
1283
    // Get a URI from the document principal. We use the original
1279
    // codebase in case the codebase was changed by SetDomain
1284
    // codebase in case the codebase was changed by SetDomain
1280
    nsCOMPtr<nsIURI> codebaseURI;
1285
    nsCOMPtr<nsIURI> codebaseURI;
1281
    NodePrincipal()->GetURI(getter_AddRefs(codebaseURI));
1286
    NodePrincipal()->GetURI(getter_AddRefs(codebaseURI));
1282
1287
 Lines 1297-1312   nsHTMLDocument::GetCookie(nsAString& aCo Link Here 
1297
1302
1298
NS_IMETHODIMP
1303
NS_IMETHODIMP
1299
nsHTMLDocument::SetCookie(const nsAString& aCookie)
1304
nsHTMLDocument::SetCookie(const nsAString& aCookie)
1300
{
1305
{
1301
  if (mDisableCookieAccess) {
1306
  if (mDisableCookieAccess) {
1302
    return NS_OK;
1307
    return NS_OK;
1303
  }
1308
  }
1304
1309
1310
  // If the document's sandboxed origin flag is set, access to write cookies
1311
  // is prohibited.
1312
  if (mSandboxFlags & nsIDocShell::SANDBOXED_ORIGIN)
1313
    return NS_ERROR_DOM_SECURITY_ERR;
1314
1305
  // not having a cookie service isn't an error
1315
  // not having a cookie service isn't an error
1306
  nsCOMPtr<nsICookieService> service = do_GetService(NS_COOKIESERVICE_CONTRACTID);
1316
  nsCOMPtr<nsICookieService> service = do_GetService(NS_COOKIESERVICE_CONTRACTID);
1307
  if (service && mDocumentURI) {
1317
  if (service && mDocumentURI) {
1308
    nsCOMPtr<nsIPrompt> prompt;
1318
    nsCOMPtr<nsIPrompt> prompt;
1309
    nsCOMPtr<nsPIDOMWindow> window = GetWindow();
1319
    nsCOMPtr<nsPIDOMWindow> window = GetWindow();
1310
    if (window) {
1320
    if (window) {
1311
      window->GetPrompter(getter_AddRefs(prompt));
1321
      window->GetPrompter(getter_AddRefs(prompt));
1312
    }
1322
    }
(-)a/docshell/base/nsDocShell.cpp (-2 / +101 lines)
Line     Link Here 
 Lines 727-742   nsDocShell::nsDocShell(): Link Here 
727
    mBusyFlags(BUSY_FLAGS_NONE),
727
    mBusyFlags(BUSY_FLAGS_NONE),
728
    mAppType(nsIDocShell::APP_TYPE_UNKNOWN),
728
    mAppType(nsIDocShell::APP_TYPE_UNKNOWN),
729
    mLoadType(0),
729
    mLoadType(0),
730
    mMarginWidth(-1),
730
    mMarginWidth(-1),
731
    mMarginHeight(-1),
731
    mMarginHeight(-1),
732
    mItemType(typeContent),
732
    mItemType(typeContent),
733
    mPreviousTransIndex(-1),
733
    mPreviousTransIndex(-1),
734
    mLoadedTransIndex(-1),
734
    mLoadedTransIndex(-1),
735
    mSandboxFlags(0),
735
    mCreated(false),
736
    mCreated(false),
736
    mAllowSubframes(true),
737
    mAllowSubframes(true),
737
    mAllowPlugins(true),
738
    mAllowPlugins(true),
738
    mAllowJavascript(true),
739
    mAllowJavascript(true),
739
    mAllowMetaRedirects(true),
740
    mAllowMetaRedirects(true),
740
    mAllowImages(true),
741
    mAllowImages(true),
741
    mAllowDNSPrefetch(true),
742
    mAllowDNSPrefetch(true),
742
    mAllowWindowControl(true),
743
    mAllowWindowControl(true),
 Lines 2922-2937   nsDocShell::FindItemWithName(const PRUni Link Here 
2922
            foundItem = nsnull;
2923
            foundItem = nsnull;
2923
        }
2924
        }
2924
2925
2925
        if (foundItem) {
2926
        if (foundItem) {
2926
            // We return foundItem here even if it's not an active
2927
            // We return foundItem here even if it's not an active
2927
            // item since all the names we've dealt with so far are
2928
            // item since all the names we've dealt with so far are
2928
            // special cases that we won't bother looking for further.
2929
            // special cases that we won't bother looking for further.
2929
2930
2931
            // If our document is sandboxed, we need to do some extra checks.
2932
            PRUint32 sandboxFlags = 0;
2933
2934
            nsCOMPtr<nsIDocument> doc = do_GetInterface(aOriginalRequestor);
2935
2936
            if (doc) {
2937
              sandboxFlags = doc->SandboxFlags();
2938
            }
2939
2940
            if (sandboxFlags) {
2941
                nsCOMPtr<nsIDocShellTreeItem> root;
2942
                GetSameTypeRootTreeItem(getter_AddRefs(root));
2943
2944
                // Is the found item not a top level browsing context and not ourself ?
2945
                nsCOMPtr<nsIDocShellTreeItem> selfAsItem = static_cast<nsIDocShellTreeItem *>(this);
2946
                if (foundItem != root && foundItem != selfAsItem) {
2947
                    // Are we an ancestor of the foundItem ?
2948
                    bool isAncestor = false;
2949
2950
                    nsCOMPtr<nsIDocShellTreeItem> parentAsItem;
2951
                    GetSameTypeParent(getter_AddRefs(parentAsItem));
2952
2953
                    while (parentAsItem) {
2954
                        nsCOMPtr<nsIDocShellTreeItem> tmp;
2955
                        parentAsItem->GetParent(getter_AddRefs(tmp));
2956
2957
                        if (tmp && tmp == selfAsItem) {
2958
                            isAncestor = true;
2959
                            break;
2960
                        }
2961
                        parentAsItem = tmp;
2962
                    }
2963
2964
                    if (!isAncestor) {
2965
                        // No, we are not an ancestor and our document is
2966
                        // sandboxed, we can't allow this.
2967
                        foundItem = nsnull;
2968
                    }
2969
                } else {
2970
                    // Top level browsing context - is it an ancestor of ours ?
2971
                    nsCOMPtr<nsIDocShellTreeItem> tmp;
2972
                    GetSameTypeParent(getter_AddRefs(tmp));
2973
2974
                    while (tmp) {
2975
                        if (tmp && tmp == foundItem) {
2976
                            // This is an ancestor, and we are sandboxed.
2977
                            // Unless allow-top-navigation is set, we can't allow this.
2978
                            if (sandboxFlags & nsIDocShell::SANDBOXED_TOPLEVEL_NAVIGATION) {
2979
                              foundItem = nsnull;
2980
                            }
2981
                            break;
2982
                        }
2983
                        tmp->GetParent(getter_AddRefs(tmp));
2984
                    }
2985
                }
2986
            }
2987
2930
            foundItem.swap(*_retval);
2988
            foundItem.swap(*_retval);
2931
            return NS_OK;
2989
            return NS_OK;
2932
        }
2990
        }
2933
    }
2991
    }
2934
2992
2935
    // Keep looking
2993
    // Keep looking
2936
        
2994
        
2937
    // First we check our name.
2995
    // First we check our name.
 Lines 4958-4973   nsDocShell::SetIsAppTab(bool aIsAppTab) Link Here 
4958
NS_IMETHODIMP
5016
NS_IMETHODIMP
4959
nsDocShell::GetIsAppTab(bool *aIsAppTab)
5017
nsDocShell::GetIsAppTab(bool *aIsAppTab)
4960
{
5018
{
4961
  *aIsAppTab = mIsAppTab;
5019
  *aIsAppTab = mIsAppTab;
4962
  return NS_OK;
5020
  return NS_OK;
4963
}
5021
}
4964
5022
4965
NS_IMETHODIMP
5023
NS_IMETHODIMP
5024
nsDocShell::SetSandboxFlags(PRUint32 aSandboxFlags)
5025
{
5026
  mSandboxFlags = aSandboxFlags;
5027
  return NS_OK;
5028
}
5029
5030
NS_IMETHODIMP
5031
nsDocShell::GetSandboxFlags(PRUint32  *aSandboxFlags)
5032
{
5033
  *aSandboxFlags = mSandboxFlags;
5034
  return NS_OK;
5035
}
5036
5037
NS_IMETHODIMP
4966
nsDocShell::SetVisibility(bool aVisibility)
5038
nsDocShell::SetVisibility(bool aVisibility)
4967
{
5039
{
4968
    if (!mContentViewer)
5040
    if (!mContentViewer)
4969
        return NS_OK;
5041
        return NS_OK;
4970
    if (aVisibility) {
5042
    if (aVisibility) {
4971
        mContentViewer->Show();
5043
        mContentViewer->Show();
4972
    }
5044
    }
4973
    else {
5045
    else {
 Lines 8147-8162   nsDocShell::InternalLoad(nsIURI * aURI, Link Here 
8147
        nsCOMPtr<nsIDocShellTreeItem> targetItem;
8219
        nsCOMPtr<nsIDocShellTreeItem> targetItem;
8148
        FindItemWithName(aWindowTarget, nsnull, this,
8220
        FindItemWithName(aWindowTarget, nsnull, this,
8149
                         getter_AddRefs(targetItem));
8221
                         getter_AddRefs(targetItem));
8150
8222
8151
        nsCOMPtr<nsIDocShell> targetDocShell = do_QueryInterface(targetItem);
8223
        nsCOMPtr<nsIDocShell> targetDocShell = do_QueryInterface(targetItem);
8152
        
8224
        
8153
        bool isNewWindow = false;
8225
        bool isNewWindow = false;
8154
        if (!targetDocShell) {
8226
        if (!targetDocShell) {
8227
            // If the docshell's document is sandboxed and was trying to
8228
            // navigate/load a frame it wasn't allowed to access, the
8229
            // FindItemWithName above will have returned null for the target
8230
            // item - we don't want to actually open a new window in this case
8231
            // though. Check if we are sandboxed and bail out here if so.
8232
            NS_ENSURE_TRUE(mContentViewer, NS_ERROR_FAILURE);
8233
            nsIDocument* doc = mContentViewer->GetDocument();
8234
            PRUint32 sandboxFlags = 0;
8235
            sandboxFlags = doc->SandboxFlags();
8236
            if (sandboxFlags & nsIDocShell::SANDBOXED_NAVIGATION) {
8237
              return NS_ERROR_FAILURE;
8238
            }
8239
8155
            nsCOMPtr<nsIDOMWindow> win =
8240
            nsCOMPtr<nsIDOMWindow> win =
8156
                do_GetInterface(GetAsSupports(this));
8241
                do_GetInterface(GetAsSupports(this));
8157
            NS_ENSURE_TRUE(win, NS_ERROR_NOT_AVAILABLE);
8242
            NS_ENSURE_TRUE(win, NS_ERROR_NOT_AVAILABLE);
8158
8243
8159
            nsDependentString name(aWindowTarget);
8244
            nsDependentString name(aWindowTarget);
8160
            nsCOMPtr<nsIDOMWindow> newWin;
8245
            nsCOMPtr<nsIDOMWindow> newWin;
8161
            rv = win->Open(EmptyString(), // URL to load
8246
            rv = win->Open(EmptyString(), // URL to load
8162
                           name,          // window name
8247
                           name,          // window name
 Lines 8940-8957   nsDocShell::DoURILoad(nsIURI * aURI, Link Here 
8940
        }
9025
        }
8941
        // Set the referrer explicitly
9026
        // Set the referrer explicitly
8942
        if (aReferrerURI && aSendReferrer) {
9027
        if (aReferrerURI && aSendReferrer) {
8943
            // Referrer is currenly only set for link clicks here.
9028
            // Referrer is currenly only set for link clicks here.
8944
            httpChannel->SetReferrer(aReferrerURI);
9029
            httpChannel->SetReferrer(aReferrerURI);
8945
        }
9030
        }
8946
    }
9031
    }
8947
9032
8948
    nsCOMPtr<nsIPrincipal> ownerPrincipal(do_QueryInterface(aOwner));
9033
    nsCOMPtr<nsIPrincipal> ownerPrincipal;
8949
    nsContentUtils::SetUpChannelOwner(ownerPrincipal, channel, aURI, true);
9034
9035
    // If the content being loaded should be sandboxed with respect to origin
9036
    // we need to create a new null principal here, and then tell
9037
    // nsContentUtils::SetUpChannelOwner to force it to be set as the
9038
    // channel owner.
9039
    if (mSandboxFlags & nsIDocShell::SANDBOXED_ORIGIN) {
9040
      ownerPrincipal = do_CreateInstance("@mozilla.org/nullprincipal;1");
9041
    } else {
9042
      // Not sandboxed - we allow the content to assume its natural owner.
9043
      ownerPrincipal = do_QueryInterface(aOwner);
9044
    }
9045
9046
    nsContentUtils::SetUpChannelOwner(ownerPrincipal, channel, aURI, true,
9047
                                       (mSandboxFlags &
9048
                                        nsIDocShell::SANDBOXED_ORIGIN));
8950
9049
8951
    nsCOMPtr<nsIScriptChannel> scriptChannel = do_QueryInterface(channel);
9050
    nsCOMPtr<nsIScriptChannel> scriptChannel = do_QueryInterface(channel);
8952
    if (scriptChannel) {
9051
    if (scriptChannel) {
8953
        // Allow execution against our context if the principals match
9052
        // Allow execution against our context if the principals match
8954
        scriptChannel->
9053
        scriptChannel->
8955
            SetExecutionPolicy(nsIScriptChannel::EXECUTE_NORMAL);
9054
            SetExecutionPolicy(nsIScriptChannel::EXECUTE_NORMAL);
8956
    }
9055
    }
8957
9056
(-)a/docshell/base/nsDocShell.h (+2 lines)
Line     Link Here 
 Lines 781-796   protected: Link Here 
781
    // Create() is called, the type is not expected to change.
781
    // Create() is called, the type is not expected to change.
782
    PRInt32                    mItemType;
782
    PRInt32                    mItemType;
783
783
784
    // Index into the SHTransaction list, indicating the previous and current
784
    // Index into the SHTransaction list, indicating the previous and current
785
    // transaction at the time that this DocShell begins to load
785
    // transaction at the time that this DocShell begins to load
786
    PRInt32                    mPreviousTransIndex;
786
    PRInt32                    mPreviousTransIndex;
787
    PRInt32                    mLoadedTransIndex;
787
    PRInt32                    mLoadedTransIndex;
788
788
789
    PRUint32                   mSandboxFlags;
790
789
    bool                       mCreated;
791
    bool                       mCreated;
790
    bool                       mAllowSubframes;
792
    bool                       mAllowSubframes;
791
    bool                       mAllowPlugins;
793
    bool                       mAllowPlugins;
792
    bool                       mAllowJavascript;
794
    bool                       mAllowJavascript;
793
    bool                       mAllowMetaRedirects;
795
    bool                       mAllowMetaRedirects;
794
    bool                       mAllowImages;
796
    bool                       mAllowImages;
795
    bool                       mAllowDNSPrefetch;
797
    bool                       mAllowDNSPrefetch;
796
    bool                       mAllowWindowControl;
798
    bool                       mAllowWindowControl;
(-)a/docshell/base/nsIDocShell.idl (-1 / +59 lines)
Line     Link Here 
 Lines 67-83   interface nsIRequest; Link Here 
67
interface nsISHEntry;
67
interface nsISHEntry;
68
interface nsILayoutHistoryState;
68
interface nsILayoutHistoryState;
69
interface nsISecureBrowserUI;
69
interface nsISecureBrowserUI;
70
interface nsIDOMStorage;
70
interface nsIDOMStorage;
71
interface nsIPrincipal;
71
interface nsIPrincipal;
72
interface nsIWebBrowserPrint;
72
interface nsIWebBrowserPrint;
73
interface nsIVariant;
73
interface nsIVariant;
74
74
75
[scriptable, uuid(0615d1a6-313f-11e1-a043-6c626d69675c)]
75
[scriptable, uuid(9b283337-097d-4fa8-a2da-916318eaf828)]
76
interface nsIDocShell : nsISupports
76
interface nsIDocShell : nsISupports
77
{
77
{
78
  /**
78
  /**
79
   * Loads a given URI.  This will give priority to loading the requested URI
79
   * Loads a given URI.  This will give priority to loading the requested URI
80
   * in the object implementing	this interface.  If it can't be loaded here
80
   * in the object implementing	this interface.  If it can't be loaded here
81
   * however, the URL dispatcher will go through its normal process of content
81
   * however, the URL dispatcher will go through its normal process of content
82
   * loading.
82
   * loading.
83
   *
83
   *
 Lines 597-605   interface nsIDocShell : nsISupports Link Here 
597
   */
597
   */
598
  attribute nsIAtom parentCharset;
598
  attribute nsIAtom parentCharset;
599
599
600
  /*
600
  /*
601
   * In a child docshell, this is the source of parentCharset
601
   * In a child docshell, this is the source of parentCharset
602
   * @see nsIParser
602
   * @see nsIParser
603
   */
603
   */
604
  attribute PRInt32 parentCharsetSource;
604
  attribute PRInt32 parentCharsetSource;
605
606
  /**
607
   * The sandbox flags on the docshell. These reflect the value of the sandbox
608
   * attribute of the associated IFRAME or CSP-protectable content, if
609
   * existent. See the HTML5 spec for more details.
610
   * These flags on the docshell reflect the current state of the sandbox
611
   * attribute, which is modifiable. They are only used when loading new
612
   * content, sandbox flags are also immutably set on the document when it is
613
   * loaded.
614
   * The sandbox flags of a document depend on the sandbox flags on its
615
   * docshell and of its parent document, if any.
616
   */
617
  attribute unsigned long sandboxFlags;
618
619
  /**
620
   * This flag prevents content from navigating browsing contexts other than
621
   * the sandboxed browsing context itself (or browsing contexts further
622
   * nested inside it), and the top-level browsing context.
623
   */
624
  const unsigned long SANDBOXED_NAVIGATION  = 0x1;
625
626
  /**
627
   * This flag prevents content from navigating their top-level browsing
628
   * context.
629
   */
630
  const unsigned long SANDBOXED_TOPLEVEL_NAVIGATION = 0x2;
631
632
  /**
633
   * This flag prevents content from instantiating plugins, whether using the
634
   * embed element, the object element, the applet element, or through
635
   * navigation of a nested browsing context, unless those plugins can be
636
   * secured.
637
   */
638
  const unsigned long SANDBOXED_PLUGINS = 0x4;
639
640
  /**
641
   * This flag forces content into a unique origin, thus preventing it from
642
   * accessing other content from the same origin.
643
   * This flag also prevents script from reading from or writing to the
644
   * document.cookie IDL attribute, and blocks access to localStorage.
645
   */
646
  const unsigned long SANDBOXED_ORIGIN = 0x8;
647
648
  /**
649
   * This flag blocks form submission.
650
   */
651
  const unsigned long SANDBOXED_FORMS = 0x10;
652
653
  /**
654
   * This flag blocks script execution.
655
   */
656
  const unsigned long SANDBOXED_SCRIPTS = 0x20;
657
658
  /**
659
   * This flag blocks features that trigger automatically, such as
660
   * automatically playing a video or automatically focusing a form control.
661
   */
662
  const unsigned long SANDBOXED_AUTOMATIC_FEATURES = 0x40;
605
};
663
};
(-)a/dom/base/nsGlobalWindow.cpp (+12 lines)
Line     Link Here 
 Lines 8228-8243   nsGlobalWindow::GetSessionStorage(nsIDOM Link Here 
8228
  if (!mSessionStorage) {
8228
  if (!mSessionStorage) {
8229
    *aSessionStorage = nsnull;
8229
    *aSessionStorage = nsnull;
8230
8230
8231
    nsString documentURI;
8231
    nsString documentURI;
8232
    if (mDocument) {
8232
    if (mDocument) {
8233
      mDocument->GetDocumentURI(documentURI);
8233
      mDocument->GetDocumentURI(documentURI);
8234
    }
8234
    }
8235
8235
8236
    // If the document has the sandboxed origin flag set
8237
    // don't allow access to localStorage.
8238
    if (mDoc && (mDoc->SandboxFlags() & nsIDocShell::SANDBOXED_ORIGIN)) {
8239
      return NS_ERROR_DOM_SECURITY_ERR;
8240
    }
8241
8236
    nsresult rv = docShell->GetSessionStorageForPrincipal(principal,
8242
    nsresult rv = docShell->GetSessionStorageForPrincipal(principal,
8237
                                                          documentURI,
8243
                                                          documentURI,
8238
                                                          true,
8244
                                                          true,
8239
                                                          getter_AddRefs(mSessionStorage));
8245
                                                          getter_AddRefs(mSessionStorage));
8240
    NS_ENSURE_SUCCESS(rv, rv);
8246
    NS_ENSURE_SUCCESS(rv, rv);
8241
8247
8242
#ifdef PR_LOGGING
8248
#ifdef PR_LOGGING
8243
    if (PR_LOG_TEST(gDOMLeakPRLog, PR_LOG_DEBUG)) {
8249
    if (PR_LOG_TEST(gDOMLeakPRLog, PR_LOG_DEBUG)) {
 Lines 8315-8330   nsGlobalWindow::GetLocalStorage(nsIDOMSt Link Here 
8315
      do_GetService("@mozilla.org/dom/storagemanager;1", &rv);
8321
      do_GetService("@mozilla.org/dom/storagemanager;1", &rv);
8316
    NS_ENSURE_SUCCESS(rv, rv);
8322
    NS_ENSURE_SUCCESS(rv, rv);
8317
8323
8318
    nsString documentURI;
8324
    nsString documentURI;
8319
    if (mDocument) {
8325
    if (mDocument) {
8320
      mDocument->GetDocumentURI(documentURI);
8326
      mDocument->GetDocumentURI(documentURI);
8321
    }
8327
    }
8322
8328
8329
    // If the document has the sandboxed origin flag set
8330
    // don't allow access to localStorage.
8331
    if (mDoc && (mDoc->SandboxFlags() & nsIDocShell::SANDBOXED_ORIGIN)) {
8332
      return NS_ERROR_DOM_SECURITY_ERR;
8333
    }
8334
8323
    rv = storageManager->GetLocalStorageForPrincipal(principal,
8335
    rv = storageManager->GetLocalStorageForPrincipal(principal,
8324
                                                     documentURI,
8336
                                                     documentURI,
8325
                                                     getter_AddRefs(mLocalStorage));
8337
                                                     getter_AddRefs(mLocalStorage));
8326
    NS_ENSURE_SUCCESS(rv, rv);
8338
    NS_ENSURE_SUCCESS(rv, rv);
8327
  }
8339
  }
8328
8340
8329
  NS_ADDREF(*aLocalStorage = mLocalStorage);
8341
  NS_ADDREF(*aLocalStorage = mLocalStorage);
8330
  return NS_OK;
8342
  return NS_OK;
(-)a/dom/interfaces/html/nsIDOMHTMLIFrameElement.idl (-1 / +3 lines)
Line     Link Here 
 Lines 33-76    Link Here 
33
 * decision by deleting the provisions above and replace them with the notice
33
 * decision by deleting the provisions above and replace them with the notice
34
 * and other provisions required by the GPL or the LGPL. If you do not delete
34
 * and other provisions required by the GPL or the LGPL. If you do not delete
35
 * the provisions above, a recipient may use your version of this file under
35
 * the provisions above, a recipient may use your version of this file under
36
 * the terms of any one of the MPL, the GPL or the LGPL.
36
 * the terms of any one of the MPL, the GPL or the LGPL.
37
 *
37
 *
38
 * ***** END LICENSE BLOCK ***** */
38
 * ***** END LICENSE BLOCK ***** */
39
39
40
#include "nsIDOMHTMLElement.idl"
40
#include "nsIDOMHTMLElement.idl"
41
#include "nsIDOMDOMSettableTokenList.idl"
41
42
42
/**
43
/**
43
 * The nsIDOMHTMLIFrameElement interface is the interface to a [X]HTML
44
 * The nsIDOMHTMLIFrameElement interface is the interface to a [X]HTML
44
 * iframe element.
45
 * iframe element.
45
 *
46
 *
46
 * This interface is trying to follow the DOM Level 2 HTML specification:
47
 * This interface is trying to follow the DOM Level 2 HTML specification:
47
 * http://www.w3.org/TR/DOM-Level-2-HTML/
48
 * http://www.w3.org/TR/DOM-Level-2-HTML/
48
 *
49
 *
49
 * with changes from the work-in-progress WHATWG HTML specification:
50
 * with changes from the work-in-progress WHATWG HTML specification:
50
 * http://www.whatwg.org/specs/web-apps/current-work/
51
 * http://www.whatwg.org/specs/web-apps/current-work/
51
 */
52
 */
52
53
53
[scriptable, uuid(d4e870bd-452c-4860-b93c-f4ee00ba33f6)]
54
[scriptable, uuid(52f6244b-b1f5-4f4c-8ff3-7e146316f411)]
54
interface nsIDOMHTMLIFrameElement : nsIDOMHTMLElement
55
interface nsIDOMHTMLIFrameElement : nsIDOMHTMLElement
55
{
56
{
56
           attribute DOMString        align;
57
           attribute DOMString        align;
57
           attribute DOMString        frameBorder;
58
           attribute DOMString        frameBorder;
58
           attribute DOMString        height;
59
           attribute DOMString        height;
59
           attribute DOMString        longDesc;
60
           attribute DOMString        longDesc;
60
           attribute DOMString        marginHeight;
61
           attribute DOMString        marginHeight;
61
           attribute DOMString        marginWidth;
62
           attribute DOMString        marginWidth;
62
           attribute DOMString        name;
63
           attribute DOMString        name;
63
           attribute DOMString        scrolling;
64
           attribute DOMString        scrolling;
64
           attribute DOMString        src;
65
           attribute DOMString        src;
65
           attribute DOMString        width;
66
           attribute DOMString        width;
66
  // Introduced in DOM Level 2:
67
  // Introduced in DOM Level 2:
67
  readonly attribute nsIDOMDocument   contentDocument;
68
  readonly attribute nsIDOMDocument   contentDocument;
68
  readonly attribute nsIDOMWindow     contentWindow;
69
  readonly attribute nsIDOMWindow     contentWindow;
69
70
71
  readonly attribute nsIDOMDOMSettableTokenList sandbox;
70
72
71
  // Mozilla extensions
73
  // Mozilla extensions
72
  // iframe elements require the mozAllowFullScreen attribute to be present
74
  // iframe elements require the mozAllowFullScreen attribute to be present
73
  // if they're to allow content in the sub document to go into DOM full-screen
75
  // if they're to allow content in the sub document to go into DOM full-screen
74
  // mode. See https://wiki.mozilla.org/index.php?title=Gecko:FullScreenAPI
76
  // mode. See https://wiki.mozilla.org/index.php?title=Gecko:FullScreenAPI
75
           attribute boolean          mozAllowFullScreen;
77
           attribute boolean          mozAllowFullScreen;
76
};
78
};
(-)a/embedding/components/windowwatcher/src/nsWindowWatcher.cpp (+17 lines)
Line     Link Here 
 Lines 603-618   nsWindowWatcher::OpenWindowJSInternal(ns Link Here 
603
  }
603
  }
604
604
605
  if (!newDocShellItem) {
605
  if (!newDocShellItem) {
606
    // We're going to either open up a new window ourselves or ask a
606
    // We're going to either open up a new window ourselves or ask a
607
    // nsIWindowProvider for one.  In either case, we'll want to set the right
607
    // nsIWindowProvider for one.  In either case, we'll want to set the right
608
    // name on it.
608
    // name on it.
609
    windowNeedsName = true;
609
    windowNeedsName = true;
610
610
611
    // If the parent trying to open a new window is sandboxed,
612
    // this is not allowed and we fail here.
613
    if (aParent) {
614
      nsCOMPtr<nsIDOMDocument> domdoc;
615
      aParent->GetDocument(getter_AddRefs(domdoc));
616
      nsCOMPtr<nsIDocument> doc = do_QueryInterface(domdoc);
617
618
      if (doc) {
619
        PRUint32 sandboxFlags = 0;
620
        sandboxFlags = doc->SandboxFlags();
621
622
        if (sandboxFlags & nsIDocShell::SANDBOXED_NAVIGATION) {
623
          return NS_ERROR_FAILURE;
624
        }
625
      }
626
    }
627
611
    // Now check whether it's ok to ask a window provider for a window.  Don't
628
    // Now check whether it's ok to ask a window provider for a window.  Don't
612
    // do it if we're opening a dialog or if our parent is a chrome window or
629
    // do it if we're opening a dialog or if our parent is a chrome window or
613
    // if we're opening something that has modal, dialog, or chrome flags set.
630
    // if we're opening something that has modal, dialog, or chrome flags set.
614
    nsCOMPtr<nsIDOMChromeWindow> chromeWin = do_QueryInterface(aParent);
631
    nsCOMPtr<nsIDOMChromeWindow> chromeWin = do_QueryInterface(aParent);
615
    if (!aDialog && !chromeWin &&
632
    if (!aDialog && !chromeWin &&
616
        !(chromeFlags & (nsIWebBrowserChrome::CHROME_MODAL         |
633
        !(chromeFlags & (nsIWebBrowserChrome::CHROME_MODAL         |
617
                         nsIWebBrowserChrome::CHROME_OPENAS_DIALOG | 
634
                         nsIWebBrowserChrome::CHROME_OPENAS_DIALOG | 
618
                         nsIWebBrowserChrome::CHROME_OPENAS_CHROME))) {
635
                         nsIWebBrowserChrome::CHROME_OPENAS_CHROME))) {

Return to bug 341604