Attachment #612372: WIP - iframe sandbox v9 for bug #341604

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

(-)a/content/base/public/nsContentUtils.h (-4 / +17 lines)
Line     Link Here 
 Lines 840-855   public: Link Here 
840
  /**
840
  /**
841
   * Get the localized string named |aKey| in properties file |aFile|.
841
   * Get the localized string named |aKey| in properties file |aFile|.
842
   */
842
   */
843
  static nsresult GetLocalizedString(PropertiesFile aFile,
843
  static nsresult GetLocalizedString(PropertiesFile aFile,
844
                                     const char* aKey,
844
                                     const char* aKey,
845
                                     nsXPIDLString& aResult);
845
                                     nsXPIDLString& aResult);
846
846
847
  /**
847
  /**
848
   * A helper function that parses a sandbox attribute (of an <iframe> or
849
   * a CSP directive) and converts it to the set of flags used internally.
850
   *
851
   * @param aAttribute 	the value of the sandbox attribute
852
   * @return 			the set of flags
853
   */
854
  static PRUint32 ParseSandboxAttributeToFlags(const nsAString&
855
                                                 sandboxAttr);
856
857
858
  /**
848
   * Fill (with the parameters given) the localized string named |aKey| in
859
   * Fill (with the parameters given) the localized string named |aKey| in
849
   * properties file |aFile|.
860
   * properties file |aFile|.
850
   */
861
   */
851
private:
862
private:
852
  static nsresult FormatLocalizedString(PropertiesFile aFile,
863
  static nsresult FormatLocalizedString(PropertiesFile aFile,
853
                                        const char* aKey,
864
                                        const char* aKey,
854
                                        const PRUnichar** aParams,
865
                                        const PRUnichar** aParams,
855
                                        PRUint32 aParamsLength,
866
                                        PRUint32 aParamsLength,
 Lines 1987-2021   public: Link Here 
1987
   * from the document it comes from.
1998
   * from the document it comes from.
1988
   */
1999
   */
1989
  static nsresult URIInheritsSecurityContext(nsIURI *aURI, bool *aResult);
2000
  static nsresult URIInheritsSecurityContext(nsIURI *aURI, bool *aResult);
1990
2001
1991
  /**
2002
  /**
1992
   * Set the given principal as the owner of the given channel, if
2003
   * Set the given principal as the owner of the given channel, if
1993
   * needed.  aURI must be the URI of aChannel.  aPrincipal may be
2004
   * needed.  aURI must be the URI of aChannel.  aPrincipal may be
1994
   * null.  If aSetUpForAboutBlank is true, then about:blank will get
2005
   * null.  If aSetUpForAboutBlank is true, then about:blank will get
1995
   * the principal set up on it.
2006
   * the principal set up on it. If aForceOwner is true, the owner
1996
   *
2007
   * will be set on the channel, even if the principal can be determined
2008
   * from the channel.
1997
   * The return value is whether the principal was set up as the owner
2009
   * The return value is whether the principal was set up as the owner
1998
   * of the channel.
2010
   * of the channel.
1999
   */
2011
   */
2000
  static bool SetUpChannelOwner(nsIPrincipal* aLoadingPrincipal,
2012
  static bool SetUpChannelOwner(nsIPrincipal* aLoadingPrincipal,
2001
                                nsIChannel* aChannel,
2013
                                nsIChannel* aChannel,
2002
                                nsIURI* aURI,
2014
                                nsIURI* aURI,
2003
                                bool aSetUpForAboutBlank);
2015
                                bool aSetUpForAboutBlank,
2016
                                bool aForceOwner = false);
2004
2017
2005
  static nsresult Btoa(const nsAString& aBinaryData,
2018
  static nsresult Btoa(const nsAString& aBinaryData,
2006
                       nsAString& aAsciiBase64String);
2019
                       nsAString& aAsciiBase64String);
2007
2020
2008
  static nsresult Atob(const nsAString& aAsciiString,
2021
  static nsresult Atob(const nsAString& aAsciiString,
2009
                       nsAString& aBinaryData);
2022
                       nsAString& aBinaryData);
2010
2023
2011
  /**
2024
  /**
2012
   * Returns whether the input element passed in parameter has the autocomplete
2025
   * Returns whether the input element passed in parameter has the autocomplete
2013
   * functionnality enabled. It is taking into account the form owner.
2026
   * functionality enabled. It is taking into account the form owner.
2014
   * NOTE: the caller has to make sure autocomplete makes sense for the
2027
   * NOTE: the caller has to make sure autocomplete makes sense for the
2015
   * element's type.
2028
   * element's type.
2016
   *
2029
   *
2017
   * @param aInput the input element to check. NOTE: aInput can't be null.
2030
   * @param aInput the input element to check. NOTE: aInput can't be null.
2018
   * @return whether the input element has autocomplete enabled.
2031
   * @return whether the input element has autocomplete enabled.
2019
   */
2032
   */
2020
  static bool IsAutocompleteEnabled(nsIDOMHTMLInputElement* aInput);
2033
  static bool IsAutocompleteEnabled(nsIDOMHTMLInputElement* aInput);
2021
2034
(-)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 455-471   public: Link Here 
455
   * callers are expected to take action as needed if they want this
455
   * callers are expected to take action as needed if they want this
456
   * change to actually change anything immediately.
456
   * change to actually change anything immediately.
457
   * @see nsBidiUtils.h
457
   * @see nsBidiUtils.h
458
   */
458
   */
459
  void SetBidiOptions(PRUint32 aBidiOptions)
459
  void SetBidiOptions(PRUint32 aBidiOptions)
460
  {
460
  {
461
    mBidiOptions = aBidiOptions;
461
    mBidiOptions = aBidiOptions;
462
  }
462
  }
463
  
463
464
  /**
465
   * Get the sandbox flags for this document.
466
   * @see nsSandboxFlags.h for the possible flags
467
   */
468
  PRUint32 SandboxFlags() const
469
  {
470
    return mSandboxFlags;
471
  }
472
464
  /**
473
  /**
465
   * Access HTTP header data (this may also get set from other
474
   * Access HTTP header data (this may also get set from other
466
   * sources, like HTML META tags).
475
   * sources, like HTML META tags).
467
   */
476
   */
468
  virtual void GetHeaderData(nsIAtom* aHeaderField, nsAString& aData) const = 0;
477
  virtual void GetHeaderData(nsIAtom* aHeaderField, nsAString& aData) const = 0;
469
  virtual void SetHeaderData(nsIAtom* aheaderField, const nsAString& aData) = 0;
478
  virtual void SetHeaderData(nsIAtom* aheaderField, const nsAString& aData) = 0;
470
479
471
  /**
480
  /**
 Lines 1812-1827   protected: Link Here 
1812
  // If mIsStaticDocument is true, mOriginalDocument points to the original
1821
  // If mIsStaticDocument is true, mOriginalDocument points to the original
1813
  // document.
1822
  // document.
1814
  nsCOMPtr<nsIDocument> mOriginalDocument;
1823
  nsCOMPtr<nsIDocument> mOriginalDocument;
1815
1824
1816
  // The bidi options for this document.  What this bitfield means is
1825
  // The bidi options for this document.  What this bitfield means is
1817
  // defined in nsBidiUtils.h
1826
  // defined in nsBidiUtils.h
1818
  PRUint32 mBidiOptions;
1827
  PRUint32 mBidiOptions;
1819
1828
1829
  // The sandbox flags on the document. These reflect the value of the sandbox attribute of the
1830
  // associated IFRAME or CSP-protectable content, if existent. These are set at load time and
1831
  // are immutable - see nsSandboxFlags.h for the possible flags.
1832
  PRUint32 mSandboxFlags;
1833
1820
  nsCString mContentLanguage;
1834
  nsCString mContentLanguage;
1821
private:
1835
private:
1822
  nsCString mContentType;
1836
  nsCString mContentType;
1823
protected:
1837
protected:
1824
1838
1825
  // The document's security info
1839
  // The document's security info
1826
  nsCOMPtr<nsISupports> mSecurityInfo;
1840
  nsCOMPtr<nsISupports> mSecurityInfo;
1827
1841
(-)a/content/base/src/nsContentUtils.cpp (-3 / +55 lines)
Line     Link Here 
 Lines 208-223   static NS_DEFINE_CID(kXTFServiceCID, NS_ Link Here 
208
#include "nsCCUncollectableMarker.h"
208
#include "nsCCUncollectableMarker.h"
209
#include "mozilla/Base64.h"
209
#include "mozilla/Base64.h"
210
#include "mozilla/Preferences.h"
210
#include "mozilla/Preferences.h"
211
211
212
#include "nsWrapperCacheInlines.h"
212
#include "nsWrapperCacheInlines.h"
213
#include "nsIDOMDocumentType.h"
213
#include "nsIDOMDocumentType.h"
214
#include "nsIDOMWindowUtils.h"
214
#include "nsIDOMWindowUtils.h"
215
#include "nsCharSeparatedTokenizer.h"
215
#include "nsCharSeparatedTokenizer.h"
216
#include "nsSandboxFlags.h"
216
217
217
extern "C" int MOZ_XMLTranslateEntity(const char* ptr, const char* end,
218
extern "C" int MOZ_XMLTranslateEntity(const char* ptr, const char* end,
218
                                      const char** next, PRUnichar* result);
219
                                      const char** next, PRUnichar* result);
219
220
220
using namespace mozilla::dom;
221
using namespace mozilla::dom;
221
using namespace mozilla::layers;
222
using namespace mozilla::layers;
222
using namespace mozilla::widget;
223
using namespace mozilla::widget;
223
using namespace mozilla;
224
using namespace mozilla;
 Lines 915-930   nsContentUtils::GetParserService() Link Here 
915
    nsresult rv = CallGetService(kParserServiceCID, &sParserService);
916
    nsresult rv = CallGetService(kParserServiceCID, &sParserService);
916
    if (NS_FAILED(rv)) {
917
    if (NS_FAILED(rv)) {
917
      sParserService = nsnull;
918
      sParserService = nsnull;
918
    }
919
    }
919
  }
920
  }
920
921
921
  return sParserService;
922
  return sParserService;
922
}
923
}
924
/**
925
 * A helper function that parses a sandbox attribute (of an <iframe> or
926
 * a CSP directive) and converts it to the set of flags used internally.
927
 *
928
 * @param aAttribute    the value of the sandbox attribute
929
 * @return              the set of flags
930
 */
931
PRUint32
932
nsContentUtils::ParseSandboxAttributeToFlags(const nsAString& sandboxAttrValue)
933
{
934
  // If there's a sandbox attribute at all (and there is if this is being
935
  // called), start off by setting all the restriction flags.
936
  PRUint32 out = SANDBOXED_NAVIGATION |
937
    SANDBOXED_TOPLEVEL_NAVIGATION |
938
    SANDBOXED_PLUGINS | SANDBOXED_ORIGIN |
939
    SANDBOXED_FORMS | SANDBOXED_SCRIPTS |
940
    SANDBOXED_AUTOMATIC_FEATURES;
941
942
  if (!sandboxAttrValue.IsEmpty()) {
943
    // The separator optional flag is used because the HTML5 spec says any
944
    // whitespace is ok as a separator, which is what this does.
945
    HTMLSplitOnSpacesTokenizer tokenizer(sandboxAttrValue, ' ',
946
      nsCharSeparatedTokenizerTemplate<nsContentUtils::IsHTMLWhitespace>::SEPARATOR_OPTIONAL);
947
948
    while (tokenizer.hasMoreTokens()) {
949
      nsDependentSubstring token = tokenizer.nextToken();
950
951
      if (token.LowerCaseEqualsLiteral("allow-scripts")) {
952
        out &= ~SANDBOXED_SCRIPTS;
953
      } else if (token.LowerCaseEqualsLiteral("allow-same-origin")) {
954
        out &= ~SANDBOXED_ORIGIN;
955
      } else if (token.LowerCaseEqualsLiteral("allow-forms")) {
956
        out &= ~SANDBOXED_FORMS;
957
      } else if (token.LowerCaseEqualsLiteral("allow-scripts")) {
958
        // allow-scripts removes both SANDBOXED_SCRIPTS and
959
        // SANDBOXED_AUTOMATIC_FEATURES.
960
        out &= ~SANDBOXED_SCRIPTS;
961
        out &= ~SANDBOXED_AUTOMATIC_FEATURES;
962
      } else if (token.LowerCaseEqualsLiteral("allow-top-navigation")) {
963
        out &= ~SANDBOXED_TOPLEVEL_NAVIGATION;
964
      }
965
    }
966
  }
967
968
  return out;
969
}
923
970
924
#ifdef MOZ_XTF
971
#ifdef MOZ_XTF
925
nsIXTFService*
972
nsIXTFService*
926
nsContentUtils::GetXTFService()
973
nsContentUtils::GetXTFService()
927
{
974
{
928
  if (!sXTFService) {
975
  if (!sXTFService) {
929
    nsresult rv = CallGetService(kXTFServiceCID, &sXTFService);
976
    nsresult rv = CallGetService(kXTFServiceCID, &sXTFService);
930
    if (NS_FAILED(rv)) {
977
    if (NS_FAILED(rv)) {
 Lines 6450-6466   nsContentUtils::URIInheritsSecurityConte Link Here 
6450
                             aResult);
6497
                             aResult);
6451
}
6498
}
6452
6499
6453
// static
6500
// static
6454
bool
6501
bool
6455
nsContentUtils::SetUpChannelOwner(nsIPrincipal* aLoadingPrincipal,
6502
nsContentUtils::SetUpChannelOwner(nsIPrincipal* aLoadingPrincipal,
6456
                                  nsIChannel* aChannel,
6503
                                  nsIChannel* aChannel,
6457
                                  nsIURI* aURI,
6504
                                  nsIURI* aURI,
6458
                                  bool aSetUpForAboutBlank)
6505
                                  bool aSetUpForAboutBlank,
6506
                                  bool aForceOwner)
6459
{
6507
{
6460
  //
6508
  //
6461
  // Set the owner of the channel, but only for channels that can't
6509
  // Set the owner of the channel, but only for channels that can't
6462
  // provide their own security context.
6510
  // provide their own security context.
6463
  //
6511
  //
6464
  // XXX: It seems wrong that the owner is ignored - even if one is
6512
  // XXX: It seems wrong that the owner is ignored - even if one is
6465
  //      supplied) unless the URI is javascript or data or about:blank.
6513
  //      supplied) unless the URI is javascript or data or about:blank.
6466
  // XXX: If this is ever changed, check all callers for what owners
6514
  // XXX: If this is ever changed, check all callers for what owners
 Lines 6468-6490   nsContentUtils::SetUpChannelOwner(nsIPri Link Here 
6468
  //      comments in nsDocShell::LoadURI where we fall back on
6516
  //      comments in nsDocShell::LoadURI where we fall back on
6469
  //      inheriting the owner if called from chrome.  That would be
6517
  //      inheriting the owner if called from chrome.  That would be
6470
  //      very wrong if this code changed anything but channels that
6518
  //      very wrong if this code changed anything but channels that
6471
  //      can't provide their own security context!
6519
  //      can't provide their own security context!
6472
  //
6520
  //
6473
  //      (Currently chrome URIs set the owner when they are created!
6521
  //      (Currently chrome URIs set the owner when they are created!
6474
  //      So setting a NULL owner would be bad!)
6522
  //      So setting a NULL owner would be bad!)
6475
  //
6523
  //
6524
  // If aForceOwner is true, the owner will be set, even for a channel that
6525
  // can provide its own security context. This is used for the HTML5 IFRAME
6526
  // sandbox attribute, so we can force the channel (and its document) to
6527
  // explicitly have a null principal.
6476
  bool inherit;
6528
  bool inherit;
6477
  // We expect URIInheritsSecurityContext to return success for an
6529
  // We expect URIInheritsSecurityContext to return success for an
6478
  // about:blank URI, so don't call NS_IsAboutBlank() if this call fails.
6530
  // about:blank URI, so don't call NS_IsAboutBlank() if this call fails.
6479
  // This condition needs to match the one in nsDocShell::InternalLoad where
6531
  // This condition needs to match the one in nsDocShell::InternalLoad where
6480
  // we're checking for things that will use the owner.
6532
  // we're checking for things that will use the owner.
6481
  if (NS_SUCCEEDED(URIInheritsSecurityContext(aURI, &inherit)) &&
6533
  if (aForceOwner || ((NS_SUCCEEDED(URIInheritsSecurityContext(aURI, &inherit)) &&
6482
      (inherit || (aSetUpForAboutBlank && NS_IsAboutBlank(aURI)))) {
6534
      (inherit || (aSetUpForAboutBlank && NS_IsAboutBlank(aURI)))))) {
6483
    aChannel->SetOwner(aLoadingPrincipal);
6535
    aChannel->SetOwner(aLoadingPrincipal);
6484
    return true;
6536
    return true;
6485
  }
6537
  }
6486
6538
6487
  //
6539
  //
6488
  // file: uri special-casing
6540
  // file: uri special-casing
6489
  //
6541
  //
6490
  // If this is a file: load opened from another file: then it may need
6542
  // 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 2396-2411   nsDocument::StartDocumentLoad(const char Link Here 
2396
    FindCharInReadable(';', semicolon, end);
2396
    FindCharInReadable(';', semicolon, end);
2397
    SetContentTypeInternal(Substring(start, semicolon));
2397
    SetContentTypeInternal(Substring(start, semicolon));
2398
  }
2398
  }
2399
2399
2400
  RetrieveRelevantHeaders(aChannel);
2400
  RetrieveRelevantHeaders(aChannel);
2401
2401
2402
  mChannel = aChannel;
2402
  mChannel = aChannel;
2403
2403
2404
  // If this document is being loaded by a docshell, copy its sandbox flags
2405
  // to the document. These are immutable after being set here.
2406
  nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(aContainer);
2407
2408
  if (docShell) {
2409
    nsresult rv = docShell->GetSandboxFlags(&mSandboxFlags);
2410
    NS_ENSURE_SUCCESS(rv, rv);
2411
  }
2412
2404
  nsresult rv = InitCSP();
2413
  nsresult rv = InitCSP();
2405
  NS_ENSURE_SUCCESS(rv, rv);
2414
  NS_ENSURE_SUCCESS(rv, rv);
2406
2415
2407
  return NS_OK;
2416
  return NS_OK;
2408
}
2417
}
2409
2418
2410
nsresult
2419
nsresult
2411
nsDocument::InitCSP()
2420
nsDocument::InitCSP()
(-)a/content/base/src/nsFrameLoader.cpp (+47 lines)
Line     Link Here 
 Lines 112-127    Link Here 
112
#include "mozilla/GuardObjects.h"
112
#include "mozilla/GuardObjects.h"
113
#include "mozilla/Preferences.h"
113
#include "mozilla/Preferences.h"
114
#include "mozilla/unused.h"
114
#include "mozilla/unused.h"
115
#include "mozilla/dom/Element.h"
115
#include "mozilla/dom/Element.h"
116
#include "mozilla/layout/RenderFrameParent.h"
116
#include "mozilla/layout/RenderFrameParent.h"
117
117
118
#include "jsapi.h"
118
#include "jsapi.h"
119
119
120
#include "nsHTMLIFrameElement.h"
121
#include "nsSandboxFlags.h"
122
120
using namespace mozilla;
123
using namespace mozilla;
121
using namespace mozilla::dom;
124
using namespace mozilla::dom;
122
using namespace mozilla::layers;
125
using namespace mozilla::layers;
123
using namespace mozilla::layout;
126
using namespace mozilla::layout;
124
typedef FrameMetrics::ViewID ViewID;
127
typedef FrameMetrics::ViewID ViewID;
125
128
126
class nsAsyncDocShellDestroyer : public nsRunnable
129
class nsAsyncDocShellDestroyer : public nsRunnable
127
{
130
{
 Lines 468-483   nsFrameLoader::ReallyStartLoadingInterna Link Here 
468
  // Just to be safe, recheck uri.
471
  // Just to be safe, recheck uri.
469
  rv = CheckURILoad(mURIToLoad);
472
  rv = CheckURILoad(mURIToLoad);
470
  NS_ENSURE_SUCCESS(rv, rv);
473
  NS_ENSURE_SUCCESS(rv, rv);
471
474
472
  nsCOMPtr<nsIDocShellLoadInfo> loadInfo;
475
  nsCOMPtr<nsIDocShellLoadInfo> loadInfo;
473
  mDocShell->CreateLoadInfo(getter_AddRefs(loadInfo));
476
  mDocShell->CreateLoadInfo(getter_AddRefs(loadInfo));
474
  NS_ENSURE_TRUE(loadInfo, NS_ERROR_FAILURE);
477
  NS_ENSURE_TRUE(loadInfo, NS_ERROR_FAILURE);
475
478
479
  // Is this an <iframe> with a sandbox attribute or a parent which is
480
  // sandboxed ?
481
  nsHTMLIFrameElement * iframe =
482
    nsHTMLIFrameElement::FromContent(mOwnerContent);
483
484
  PRUint32 sandboxFlags = 0;
485
486
  if (iframe) {
487
    sandboxFlags = iframe->GetSandboxFlags();
488
489
    PRUint32 parentSandboxFlags = 0;
490
491
    // Get the parent's sandbox flags, they're needed to determine if the
492
    // frame being loaded needs to be sandboxed.
493
    nsCOMPtr<nsIDocShellTreeItem> parentDocShellItem;
494
    nsCOMPtr<nsIDocShellTreeItem> curDocShellItem = do_QueryInterface(mDocShell);
495
496
    if (NS_SUCCEEDED(curDocShellItem->GetParent(getter_AddRefs(parentDocShellItem)))) {
497
      nsCOMPtr<nsIDocument> parentDoc = do_GetInterface(parentDocShellItem);
498
499
      if (parentDoc) {
500
        parentSandboxFlags = parentDoc->SandboxFlags();
501
      }
502
    }
503
504
    if (sandboxFlags || parentSandboxFlags) {
505
      if (parentSandboxFlags) {
506
        // The child can only add restrictions, not remove them.
507
        sandboxFlags |= parentSandboxFlags;
508
      }
509
510
      mDocShell->SetSandboxFlags(sandboxFlags);
511
512
      // Set up the actual sandboxing for plugins as specified.
513
      if (sandboxFlags & SANDBOXED_PLUGINS) {
514
        mDocShell->SetAllowPlugins(false);
515
      }
516
    }
517
  }
518
519
  // If this is an <iframe> and it's sandboxed with respect to origin
520
  // we will set it up with a null principal later in nsDocShell::DoURILoad.
521
  // We do it there to correctly sandbox content that was loaded into
522
  // the iframe via other methods than the src attribute.
476
  // We'll use our principal, not that of the document loaded inside us.  This
523
  // 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
524
  // is very important; needed to prevent XSS attacks on documents loaded in
478
  // subframes!
525
  // subframes!
479
  loadInfo->SetOwner(mOwnerContent->NodePrincipal());
526
  loadInfo->SetOwner(mOwnerContent->NodePrincipal());
480
527
481
  nsCOMPtr<nsIURI> referrer;
528
  nsCOMPtr<nsIURI> referrer;
482
  rv = mOwnerContent->NodePrincipal()->GetURI(getter_AddRefs(referrer));
529
  rv = mOwnerContent->NodePrincipal()->GetURI(getter_AddRefs(referrer));
483
  NS_ENSURE_SUCCESS(rv, rv);
530
  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 877-892   GK_ATOM(rowspan, "rowspan") Link Here 
877
GK_ATOM(rp, "rp")
881
GK_ATOM(rp, "rp")
878
GK_ATOM(rt, "rt")
882
GK_ATOM(rt, "rt")
879
GK_ATOM(rtl, "rtl")
883
GK_ATOM(rtl, "rtl")
880
GK_ATOM(ruby, "ruby")
884
GK_ATOM(ruby, "ruby")
881
GK_ATOM(rule, "rule")
885
GK_ATOM(rule, "rule")
882
GK_ATOM(rules, "rules")
886
GK_ATOM(rules, "rules")
883
GK_ATOM(s, "s")
887
GK_ATOM(s, "s")
884
GK_ATOM(samp, "samp")
888
GK_ATOM(samp, "samp")
889
GK_ATOM(sandbox, "sandbox")
885
GK_ATOM(sbattr, "sbattr")
890
GK_ATOM(sbattr, "sbattr")
886
GK_ATOM(scale, "scale")
891
GK_ATOM(scale, "scale")
887
GK_ATOM(scan, "scan")
892
GK_ATOM(scan, "scan")
888
GK_ATOM(scheme, "scheme")
893
GK_ATOM(scheme, "scheme")
889
GK_ATOM(scope, "scope")
894
GK_ATOM(scope, "scope")
890
GK_ATOM(scoped, "scoped")
895
GK_ATOM(scoped, "scoped")
891
GK_ATOM(screen, "screen")
896
GK_ATOM(screen, "screen")
892
GK_ATOM(screenX, "screenX")
897
GK_ATOM(screenX, "screenX")
(-)a/content/base/src/nsSandboxFlags.h (+58 lines)
Line     Link Here 
Line 0    Link Here 
1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* This Source Code Form is subject to the terms of the Mozilla Public
3
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
4
 * You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6
/*
7
 * Constant flags that describe how a document is sandboxed according to the
8
 * HTML5 spec.
9
 */
10
11
#ifndef nsSandboxFlags_h___
12
#define nsSandboxFlags_h___
13
14
/**
15
 * This flag prevents content from navigating browsing contexts other than
16
 * the sandboxed browsing context itself (or browsing contexts further
17
 * nested inside it), and the top-level browsing context.
18
 */
19
const unsigned long SANDBOXED_NAVIGATION  = 0x1;
20
21
/**
22
 * This flag prevents content from navigating their top-level browsing
23
 * context.
24
 */
25
const unsigned long SANDBOXED_TOPLEVEL_NAVIGATION = 0x2;
26
27
/**
28
 * This flag prevents content from instantiating plugins, whether using the
29
 * embed element, the object element, the applet element, or through
30
 * navigation of a nested browsing context, unless those plugins can be
31
 * secured.
32
 */
33
const unsigned long SANDBOXED_PLUGINS = 0x4;
34
35
/**
36
 * This flag forces content into a unique origin, thus preventing it from
37
 * accessing other content from the same origin.
38
 * This flag also prevents script from reading from or writing to the
39
 * document.cookie IDL attribute, and blocks access to localStorage.
40
 */
41
const unsigned long SANDBOXED_ORIGIN = 0x8;
42
43
/**
44
 * This flag blocks form submission.
45
 */
46
const unsigned long SANDBOXED_FORMS = 0x10;
47
48
/**
49
 * This flag blocks script execution.
50
 */
51
const unsigned long SANDBOXED_SCRIPTS = 0x20;
52
53
/**
54
 * This flag blocks features that trigger automatically, such as
55
 * automatically playing a video or automatically focusing a form control.
56
 */
57
const unsigned long SANDBOXED_AUTOMATIC_FEATURES = 0x40;
58
#endif
(-)a/content/base/src/nsScriptLoader.cpp (+12 lines)
Line     Link Here 
 Lines 70-85    Link Here 
70
#include "nsIContentSecurityPolicy.h"
70
#include "nsIContentSecurityPolicy.h"
71
#include "prlog.h"
71
#include "prlog.h"
72
#include "nsIChannelPolicy.h"
72
#include "nsIChannelPolicy.h"
73
#include "nsChannelPolicy.h"
73
#include "nsChannelPolicy.h"
74
#include "nsCRT.h"
74
#include "nsCRT.h"
75
#include "nsContentCreatorFunctions.h"
75
#include "nsContentCreatorFunctions.h"
76
#include "nsGenericElement.h"
76
#include "nsGenericElement.h"
77
#include "nsCrossSiteListenerProxy.h"
77
#include "nsCrossSiteListenerProxy.h"
78
#include "nsSandboxFlags.h"
78
79
79
#include "mozilla/FunctionTimer.h"
80
#include "mozilla/FunctionTimer.h"
80
#include "mozilla/CORSMode.h"
81
#include "mozilla/CORSMode.h"
81
82
82
#ifdef PR_LOGGING
83
#ifdef PR_LOGGING
83
static PRLogModuleInfo* gCspPRLog;
84
static PRLogModuleInfo* gCspPRLog;
84
#endif
85
#endif
85
86
 Lines 305-320   nsScriptLoader::StartLoad(nsScriptLoadRe Link Here 
305
  if (!window) {
306
  if (!window) {
306
    return NS_ERROR_NULL_POINTER;
307
    return NS_ERROR_NULL_POINTER;
307
  }
308
  }
308
309
309
  nsIDocShell *docshell = window->GetDocShell();
310
  nsIDocShell *docshell = window->GetDocShell();
310
311
311
  nsCOMPtr<nsIInterfaceRequestor> prompter(do_QueryInterface(docshell));
312
  nsCOMPtr<nsIInterfaceRequestor> prompter(do_QueryInterface(docshell));
312
313
314
  // If this document is sandboxed without 'allow-scripts', abort.
315
  if (mDocument->SandboxFlags() & SANDBOXED_SCRIPTS) { 
316
    // REVIEW : this probably isn't the right error..
317
    return NS_ERROR_DOM_SECURITY_ERR;
318
  }
319
313
  // check for a Content Security Policy to pass down to the channel
320
  // check for a Content Security Policy to pass down to the channel
314
  // that will be created to load the script
321
  // that will be created to load the script
315
  nsCOMPtr<nsIChannelPolicy> channelPolicy;
322
  nsCOMPtr<nsIChannelPolicy> channelPolicy;
316
  nsCOMPtr<nsIContentSecurityPolicy> csp;
323
  nsCOMPtr<nsIContentSecurityPolicy> csp;
317
  rv = mDocument->NodePrincipal()->GetCsp(getter_AddRefs(csp));
324
  rv = mDocument->NodePrincipal()->GetCsp(getter_AddRefs(csp));
318
  NS_ENSURE_SUCCESS(rv, rv);
325
  NS_ENSURE_SUCCESS(rv, rv);
319
  if (csp) {
326
  if (csp) {
320
    channelPolicy = do_CreateInstance("@mozilla.org/nschannelpolicy;1");
327
    channelPolicy = do_CreateInstance("@mozilla.org/nschannelpolicy;1");
 Lines 677-692   nsScriptLoader::ProcessScriptElement(nsI Link Here 
677
        "There can be only one parser-blocking script at a time");
684
        "There can be only one parser-blocking script at a time");
678
    NS_ASSERTION(mXSLTRequests.IsEmpty(),
685
    NS_ASSERTION(mXSLTRequests.IsEmpty(),
679
        "Parser-blocking scripts and XSLT scripts in the same doc!");
686
        "Parser-blocking scripts and XSLT scripts in the same doc!");
680
    mParserBlockingRequest = request;
687
    mParserBlockingRequest = request;
681
    return true;
688
    return true;
682
  }
689
  }
683
690
684
  // inline script
691
  // inline script
692
  // Is this document sandboxed without 'allow-scripts'?
693
  if (mDocument->SandboxFlags() & SANDBOXED_SCRIPTS) {
694
    return false;
695
  }
696
685
  nsCOMPtr<nsIContentSecurityPolicy> csp;
697
  nsCOMPtr<nsIContentSecurityPolicy> csp;
686
  rv = mDocument->NodePrincipal()->GetCsp(getter_AddRefs(csp));
698
  rv = mDocument->NodePrincipal()->GetCsp(getter_AddRefs(csp));
687
  NS_ENSURE_SUCCESS(rv, false);
699
  NS_ENSURE_SUCCESS(rv, false);
688
700
689
  if (csp) {
701
  if (csp) {
690
    PR_LOG(gCspPRLog, PR_LOG_DEBUG, ("New ScriptLoader i ****with CSP****"));
702
    PR_LOG(gCspPRLog, PR_LOG_DEBUG, ("New ScriptLoader i ****with CSP****"));
691
    bool inlineOK;
703
    bool inlineOK;
692
    rv = csp->GetAllowsInlineScript(&inlineOK);
704
    rv = csp->GetAllowsInlineScript(&inlineOK);
(-)a/content/events/src/nsEventListenerManager.cpp (+7 lines)
Line     Link Here 
 Lines 84-99    Link Here 
84
#include "nsDOMScriptObjectHolder.h"
84
#include "nsDOMScriptObjectHolder.h"
85
#include "nsDataHashtable.h"
85
#include "nsDataHashtable.h"
86
#include "nsCOMArray.h"
86
#include "nsCOMArray.h"
87
#include "nsEventListenerService.h"
87
#include "nsEventListenerService.h"
88
#include "nsIContentSecurityPolicy.h"
88
#include "nsIContentSecurityPolicy.h"
89
#include "nsJSEnvironment.h"
89
#include "nsJSEnvironment.h"
90
#include "xpcpublic.h"
90
#include "xpcpublic.h"
91
#include "sampler.h"
91
#include "sampler.h"
92
#include "nsSandboxFlags.h"
92
93
93
using namespace mozilla::dom;
94
using namespace mozilla::dom;
94
using namespace mozilla::hal;
95
using namespace mozilla::hal;
95
96
96
#define EVENT_TYPE_EQUALS( ls, type, userType ) \
97
#define EVENT_TYPE_EQUALS( ls, type, userType ) \
97
  (ls->mEventType == type && \
98
  (ls->mEventType == type && \
98
  (ls->mEventType != NS_USER_DEFINED_EVENT || ls->mTypeAtom == userType))
99
  (ls->mEventType != NS_USER_DEFINED_EVENT || ls->mTypeAtom == userType))
99
100
 Lines 511-526   nsEventListenerManager::AddScriptEventLi Link Here 
511
    // loaded as data.
512
    // loaded as data.
512
    return NS_OK;
513
    return NS_OK;
513
  }
514
  }
514
515
515
  nsresult rv = NS_OK;
516
  nsresult rv = NS_OK;
516
  // return early preventing the event listener from being added
517
  // return early preventing the event listener from being added
517
  // 'doc' is fetched above
518
  // 'doc' is fetched above
518
  if (doc) {
519
  if (doc) {
520
    // Don't allow adding an event listener if the document is sandboxed
521
    // without 'allow-scripts'.
522
    if (doc->SandboxFlags() & SANDBOXED_SCRIPTS) {
523
      return NS_ERROR_DOM_SECURITY_ERR;
524
    }
525
519
    nsCOMPtr<nsIContentSecurityPolicy> csp;
526
    nsCOMPtr<nsIContentSecurityPolicy> csp;
520
    rv = doc->NodePrincipal()->GetCsp(getter_AddRefs(csp));
527
    rv = doc->NodePrincipal()->GetCsp(getter_AddRefs(csp));
521
    NS_ENSURE_SUCCESS(rv, rv);
528
    NS_ENSURE_SUCCESS(rv, rv);
522
529
523
    if (csp) {
530
    if (csp) {
524
      bool inlineOK;
531
      bool inlineOK;
525
      rv = csp->GetAllowsInlineScript(&inlineOK);
532
      rv = csp->GetAllowsInlineScript(&inlineOK);
526
      NS_ENSURE_SUCCESS(rv, rv);
533
      NS_ENSURE_SUCCESS(rv, rv);
(-)a/content/html/content/src/nsHTMLFormElement.cpp (-1 / +22 lines)
Line     Link Here 
 Lines 80-95    Link Here 
80
80
81
#include "mozAutoDocUpdate.h"
81
#include "mozAutoDocUpdate.h"
82
#include "nsIHTMLCollection.h"
82
#include "nsIHTMLCollection.h"
83
83
84
#include "nsIConstraintValidation.h"
84
#include "nsIConstraintValidation.h"
85
85
86
#include "nsIDOMHTMLButtonElement.h"
86
#include "nsIDOMHTMLButtonElement.h"
87
#include "dombindings.h"
87
#include "dombindings.h"
88
#include "nsSandboxFlags.h"
88
89
89
using namespace mozilla::dom;
90
using namespace mozilla::dom;
90
91
91
static const int NS_FORM_CONTROL_LIST_HASHTABLE_SIZE = 16;
92
static const int NS_FORM_CONTROL_LIST_HASHTABLE_SIZE = 16;
92
93
93
static const PRUint8 NS_FORM_AUTOCOMPLETE_ON  = 1;
94
static const PRUint8 NS_FORM_AUTOCOMPLETE_ON  = 1;
94
static const PRUint8 NS_FORM_AUTOCOMPLETE_OFF = 0;
95
static const PRUint8 NS_FORM_AUTOCOMPLETE_OFF = 0;
95
96
 Lines 684-700   nsHTMLFormElement::DoSubmitOrReset(nsEve Link Here 
684
    return DoReset();
685
    return DoReset();
685
  }
686
  }
686
687
687
  if (NS_FORM_SUBMIT == aMessage) {
688
  if (NS_FORM_SUBMIT == aMessage) {
688
    // Don't submit if we're not in a document.
689
    // Don't submit if we're not in a document.
689
    if (!doc) {
690
    if (!doc) {
690
      return NS_OK;
691
      return NS_OK;
691
    }
692
    }
692
    return DoSubmit(aEvent);
693
    // Don't submit if we're in a sandboxed frame and form submit
694
    // is disabled.
695
    PRUint32 sandboxFlags = doc->SandboxFlags();
696
697
    if (!(sandboxFlags & SANDBOXED_FORMS)) {
698
      return DoSubmit(aEvent);
699
    }
700
701
    return NS_OK;
693
  }
702
  }
694
703
695
  MOZ_ASSERT(false);
704
  MOZ_ASSERT(false);
696
  return NS_OK;
705
  return NS_OK;
697
}
706
}
698
707
699
nsresult
708
nsresult
700
nsHTMLFormElement::DoReset()
709
nsHTMLFormElement::DoReset()
 Lines 1685-1700   nsHTMLFormElement::CheckValidFormSubmiss Link Here 
1685
   * TODO: the check for observer should be removed later when HTML5 Forms will
1694
   * TODO: the check for observer should be removed later when HTML5 Forms will
1686
   * be spread enough and authors will assume forms can't be submitted when
1695
   * be spread enough and authors will assume forms can't be submitted when
1687
   * invalid. See bug 587671.
1696
   * invalid. See bug 587671.
1688
   */
1697
   */
1689
1698
1690
  NS_ASSERTION(!HasAttr(kNameSpaceID_None, nsGkAtoms::novalidate),
1699
  NS_ASSERTION(!HasAttr(kNameSpaceID_None, nsGkAtoms::novalidate),
1691
               "We shouldn't be there if novalidate is set!");
1700
               "We shouldn't be there if novalidate is set!");
1692
1701
1702
  // Don't do validation for a form submit done by a sandboxed document that
1703
  // doesn't have 'allow-forms', the submit will have been blocked and the
1704
  // HTML5 spec says we shouldn't validate in this case.
1705
  nsIDocument* doc = GetCurrentDoc();
1706
  if (doc) {
1707
    PRUint32 sandboxFlags = doc->SandboxFlags();
1708
1709
    if (sandboxFlags & SANDBOXED_FORMS) {
1710
      return true;
1711
    }
1712
  }
1713
               
1693
  // When .submit() is called aEvent = nsnull so we can rely on that to know if
1714
  // When .submit() is called aEvent = nsnull so we can rely on that to know if
1694
  // we have to check the validity of the form.
1715
  // we have to check the validity of the form.
1695
  nsCOMPtr<nsIObserverService> service =
1716
  nsCOMPtr<nsIObserverService> service =
1696
    mozilla::services::GetObserverService();
1717
    mozilla::services::GetObserverService();
1697
  if (!service) {
1718
  if (!service) {
1698
    NS_WARNING("No observer service available!");
1719
    NS_WARNING("No observer service available!");
1699
    return true;
1720
    return true;
1700
  }
1721
  }
(-)a/content/html/content/src/nsHTMLIFrameElement.cpp (-51 / +50 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
          nsAutoString strValue;
263
          aValue->ToString(strValue);
264
          newFlags = nsContentUtils::ParseSandboxAttributeToFlags(
265
            strValue);
266
        }
267
        docshell->SetSandboxFlags(newFlags);
268
      }
269
    }
270
  }
271
  return nsGenericHTMLElement::AfterSetAttr(aNameSpaceID, aName, aValue,
272
                                            aNotify);
273
274
}
(-)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 (+11 lines)
Line     Link Here 
 Lines 130-145    Link Here 
130
#include "nsHtml5Module.h"
130
#include "nsHtml5Module.h"
131
#include "prprf.h"
131
#include "prprf.h"
132
#include "mozilla/dom/Element.h"
132
#include "mozilla/dom/Element.h"
133
#include "mozilla/Preferences.h"
133
#include "mozilla/Preferences.h"
134
#include "nsMimeTypes.h"
134
#include "nsMimeTypes.h"
135
#include "nsIRequest.h"
135
#include "nsIRequest.h"
136
#include "nsHtml5TreeOpExecutor.h"
136
#include "nsHtml5TreeOpExecutor.h"
137
#include "nsHtml5Parser.h"
137
#include "nsHtml5Parser.h"
138
#include "nsSandboxFlags.h"
138
139
139
using namespace mozilla;
140
using namespace mozilla;
140
using namespace mozilla::dom;
141
using namespace mozilla::dom;
141
142
142
#define NS_MAX_DOCUMENT_WRITE_DEPTH 20
143
#define NS_MAX_DOCUMENT_WRITE_DEPTH 20
143
144
144
#include "prmem.h"
145
#include "prmem.h"
145
#include "prtime.h"
146
#include "prtime.h"
 Lines 1271-1286   nsHTMLDocument::GetCookie(nsAString& aCo Link Here 
1271
{
1272
{
1272
  aCookie.Truncate(); // clear current cookie in case service fails;
1273
  aCookie.Truncate(); // clear current cookie in case service fails;
1273
                      // no cookie isn't an error condition.
1274
                      // no cookie isn't an error condition.
1274
1275
1275
  if (mDisableCookieAccess) {
1276
  if (mDisableCookieAccess) {
1276
    return NS_OK;
1277
    return NS_OK;
1277
  }
1278
  }
1278
1279
1280
  // If the document's sandboxed origin flag is set, access to read cookies
1281
  // is prohibited.
1282
  if (mSandboxFlags & SANDBOXED_ORIGIN)
1283
    return NS_ERROR_DOM_SECURITY_ERR;
1284
1279
  // not having a cookie service isn't an error
1285
  // not having a cookie service isn't an error
1280
  nsCOMPtr<nsICookieService> service = do_GetService(NS_COOKIESERVICE_CONTRACTID);
1286
  nsCOMPtr<nsICookieService> service = do_GetService(NS_COOKIESERVICE_CONTRACTID);
1281
  if (service) {
1287
  if (service) {
1282
    // Get a URI from the document principal. We use the original
1288
    // Get a URI from the document principal. We use the original
1283
    // codebase in case the codebase was changed by SetDomain
1289
    // codebase in case the codebase was changed by SetDomain
1284
    nsCOMPtr<nsIURI> codebaseURI;
1290
    nsCOMPtr<nsIURI> codebaseURI;
1285
    NodePrincipal()->GetURI(getter_AddRefs(codebaseURI));
1291
    NodePrincipal()->GetURI(getter_AddRefs(codebaseURI));
1286
1292
 Lines 1301-1316   nsHTMLDocument::GetCookie(nsAString& aCo Link Here 
1301
1307
1302
NS_IMETHODIMP
1308
NS_IMETHODIMP
1303
nsHTMLDocument::SetCookie(const nsAString& aCookie)
1309
nsHTMLDocument::SetCookie(const nsAString& aCookie)
1304
{
1310
{
1305
  if (mDisableCookieAccess) {
1311
  if (mDisableCookieAccess) {
1306
    return NS_OK;
1312
    return NS_OK;
1307
  }
1313
  }
1308
1314
1315
  // If the document's sandboxed origin flag is set, access to write cookies
1316
  // is prohibited.
1317
  if (mSandboxFlags & SANDBOXED_ORIGIN)
1318
    return NS_ERROR_DOM_SECURITY_ERR;
1319
1309
  // not having a cookie service isn't an error
1320
  // not having a cookie service isn't an error
1310
  nsCOMPtr<nsICookieService> service = do_GetService(NS_COOKIESERVICE_CONTRACTID);
1321
  nsCOMPtr<nsICookieService> service = do_GetService(NS_COOKIESERVICE_CONTRACTID);
1311
  if (service && mDocumentURI) {
1322
  if (service && mDocumentURI) {
1312
    nsCOMPtr<nsIPrompt> prompt;
1323
    nsCOMPtr<nsIPrompt> prompt;
1313
    nsCOMPtr<nsPIDOMWindow> window = GetWindow();
1324
    nsCOMPtr<nsPIDOMWindow> window = GetWindow();
1314
    if (window) {
1325
    if (window) {
1315
      window->GetPrompter(getter_AddRefs(prompt));
1326
      window->GetPrompter(getter_AddRefs(prompt));
1316
    }
1327
    }
(-)a/docshell/base/Makefile.in (+1 lines)
Line     Link Here 
 Lines 116-124   FORCE_STATIC_LIB = 1 Link Here 
116
116
117
include $(topsrcdir)/config/rules.mk
117
include $(topsrcdir)/config/rules.mk
118
118
119
LOCAL_INCLUDES += \
119
LOCAL_INCLUDES += \
120
  -I$(srcdir)/../shistory/src \
120
  -I$(srcdir)/../shistory/src \
121
  -I$(topsrcdir)/dom/base \
121
  -I$(topsrcdir)/dom/base \
122
  -I$(topsrcdir)/layout/base \
122
  -I$(topsrcdir)/layout/base \
123
  -I$(topsrcdir)/xpcom/ds \
123
  -I$(topsrcdir)/xpcom/ds \
124
  -I$(topsrcdir)/content/base/src \
124
  $(NULL)
125
  $(NULL)
(-)a/docshell/base/nsDocShell.cpp (-2 / +101 lines)
Line     Link Here 
 Lines 213-228    Link Here 
213
#include "nsIWebBrowserPrint.h"
213
#include "nsIWebBrowserPrint.h"
214
#endif
214
#endif
215
215
216
#include "nsPluginError.h"
216
#include "nsPluginError.h"
217
#include "nsContentUtils.h"
217
#include "nsContentUtils.h"
218
#include "nsContentErrors.h"
218
#include "nsContentErrors.h"
219
#include "nsIChannelPolicy.h"
219
#include "nsIChannelPolicy.h"
220
#include "nsIContentSecurityPolicy.h"
220
#include "nsIContentSecurityPolicy.h"
221
#include "nsSandboxFlags.h"
221
222
222
#include "nsXULAppAPI.h"
223
#include "nsXULAppAPI.h"
223
224
224
#include "nsDOMNavigationTiming.h"
225
#include "nsDOMNavigationTiming.h"
225
#include "nsITimedChannel.h"
226
#include "nsITimedChannel.h"
226
#include "mozilla/StartupTimeline.h"
227
#include "mozilla/StartupTimeline.h"
227
228
228
static NS_DEFINE_CID(kDOMScriptObjectFactoryCID,
229
static NS_DEFINE_CID(kDOMScriptObjectFactoryCID,
 Lines 727-742   nsDocShell::nsDocShell(): Link Here 
727
    mBusyFlags(BUSY_FLAGS_NONE),
728
    mBusyFlags(BUSY_FLAGS_NONE),
728
    mAppType(nsIDocShell::APP_TYPE_UNKNOWN),
729
    mAppType(nsIDocShell::APP_TYPE_UNKNOWN),
729
    mLoadType(0),
730
    mLoadType(0),
730
    mMarginWidth(-1),
731
    mMarginWidth(-1),
731
    mMarginHeight(-1),
732
    mMarginHeight(-1),
732
    mItemType(typeContent),
733
    mItemType(typeContent),
733
    mPreviousTransIndex(-1),
734
    mPreviousTransIndex(-1),
734
    mLoadedTransIndex(-1),
735
    mLoadedTransIndex(-1),
736
    mSandboxFlags(0),
735
    mCreated(false),
737
    mCreated(false),
736
    mAllowSubframes(true),
738
    mAllowSubframes(true),
737
    mAllowPlugins(true),
739
    mAllowPlugins(true),
738
    mAllowJavascript(true),
740
    mAllowJavascript(true),
739
    mAllowMetaRedirects(true),
741
    mAllowMetaRedirects(true),
740
    mAllowImages(true),
742
    mAllowImages(true),
741
    mAllowDNSPrefetch(true),
743
    mAllowDNSPrefetch(true),
742
    mAllowWindowControl(true),
744
    mAllowWindowControl(true),
 Lines 2907-2922   nsDocShell::FindItemWithName(const PRUni Link Here 
2907
            foundItem = nsnull;
2909
            foundItem = nsnull;
2908
        }
2910
        }
2909
2911
2910
        if (foundItem) {
2912
        if (foundItem) {
2911
            // We return foundItem here even if it's not an active
2913
            // We return foundItem here even if it's not an active
2912
            // item since all the names we've dealt with so far are
2914
            // item since all the names we've dealt with so far are
2913
            // special cases that we won't bother looking for further.
2915
            // special cases that we won't bother looking for further.
2914
2916
2917
            // If our document is sandboxed, we need to do some extra checks.
2918
            PRUint32 sandboxFlags = 0;
2919
2920
            nsCOMPtr<nsIDocument> doc = do_GetInterface(aOriginalRequestor);
2921
2922
            if (doc) {
2923
              sandboxFlags = doc->SandboxFlags();
2924
            }
2925
2926
            if (sandboxFlags) {
2927
                nsCOMPtr<nsIDocShellTreeItem> root;
2928
                GetSameTypeRootTreeItem(getter_AddRefs(root));
2929
2930
                // Is the found item not a top level browsing context and not ourself ?
2931
                nsCOMPtr<nsIDocShellTreeItem> selfAsItem = static_cast<nsIDocShellTreeItem *>(this);
2932
                if (foundItem != root && foundItem != selfAsItem) {
2933
                    // Are we an ancestor of the foundItem ?
2934
                    bool isAncestor = false;
2935
2936
                    nsCOMPtr<nsIDocShellTreeItem> parentAsItem;
2937
                    GetSameTypeParent(getter_AddRefs(parentAsItem));
2938
2939
                    while (parentAsItem) {
2940
                        nsCOMPtr<nsIDocShellTreeItem> tmp;
2941
                        parentAsItem->GetParent(getter_AddRefs(tmp));
2942
2943
                        if (tmp && tmp == selfAsItem) {
2944
                            isAncestor = true;
2945
                            break;
2946
                        }
2947
                        parentAsItem = tmp;
2948
                    }
2949
2950
                    if (!isAncestor) {
2951
                        // No, we are not an ancestor and our document is
2952
                        // sandboxed, we can't allow this.
2953
                        foundItem = nsnull;
2954
                    }
2955
                } else {
2956
                    // Top level browsing context - is it an ancestor of ours ?
2957
                    nsCOMPtr<nsIDocShellTreeItem> tmp;
2958
                    GetSameTypeParent(getter_AddRefs(tmp));
2959
2960
                    while (tmp) {
2961
                        if (tmp && tmp == foundItem) {
2962
                            // This is an ancestor, and we are sandboxed.
2963
                            // Unless allow-top-navigation is set, we can't allow this.
2964
                            if (sandboxFlags & SANDBOXED_TOPLEVEL_NAVIGATION) {
2965
                              foundItem = nsnull;
2966
                            }
2967
                            break;
2968
                        }
2969
                        tmp->GetParent(getter_AddRefs(tmp));
2970
                    }
2971
                }
2972
            }
2973
2915
            foundItem.swap(*_retval);
2974
            foundItem.swap(*_retval);
2916
            return NS_OK;
2975
            return NS_OK;
2917
        }
2976
        }
2918
    }
2977
    }
2919
2978
2920
    // Keep looking
2979
    // Keep looking
2921
        
2980
        
2922
    // First we check our name.
2981
    // First we check our name.
 Lines 4943-4958   nsDocShell::SetIsAppTab(bool aIsAppTab) Link Here 
4943
NS_IMETHODIMP
5002
NS_IMETHODIMP
4944
nsDocShell::GetIsAppTab(bool *aIsAppTab)
5003
nsDocShell::GetIsAppTab(bool *aIsAppTab)
4945
{
5004
{
4946
  *aIsAppTab = mIsAppTab;
5005
  *aIsAppTab = mIsAppTab;
4947
  return NS_OK;
5006
  return NS_OK;
4948
}
5007
}
4949
5008
4950
NS_IMETHODIMP
5009
NS_IMETHODIMP
5010
nsDocShell::SetSandboxFlags(PRUint32 aSandboxFlags)
5011
{
5012
  mSandboxFlags = aSandboxFlags;
5013
  return NS_OK;
5014
}
5015
5016
NS_IMETHODIMP
5017
nsDocShell::GetSandboxFlags(PRUint32  *aSandboxFlags)
5018
{
5019
  *aSandboxFlags = mSandboxFlags;
5020
  return NS_OK;
5021
}
5022
5023
NS_IMETHODIMP
4951
nsDocShell::SetVisibility(bool aVisibility)
5024
nsDocShell::SetVisibility(bool aVisibility)
4952
{
5025
{
4953
    if (!mContentViewer)
5026
    if (!mContentViewer)
4954
        return NS_OK;
5027
        return NS_OK;
4955
    if (aVisibility) {
5028
    if (aVisibility) {
4956
        mContentViewer->Show();
5029
        mContentViewer->Show();
4957
    }
5030
    }
4958
    else {
5031
    else {
 Lines 8132-8147   nsDocShell::InternalLoad(nsIURI * aURI, Link Here 
8132
        nsCOMPtr<nsIDocShellTreeItem> targetItem;
8205
        nsCOMPtr<nsIDocShellTreeItem> targetItem;
8133
        FindItemWithName(aWindowTarget, nsnull, this,
8206
        FindItemWithName(aWindowTarget, nsnull, this,
8134
                         getter_AddRefs(targetItem));
8207
                         getter_AddRefs(targetItem));
8135
8208
8136
        nsCOMPtr<nsIDocShell> targetDocShell = do_QueryInterface(targetItem);
8209
        nsCOMPtr<nsIDocShell> targetDocShell = do_QueryInterface(targetItem);
8137
        
8210
        
8138
        bool isNewWindow = false;
8211
        bool isNewWindow = false;
8139
        if (!targetDocShell) {
8212
        if (!targetDocShell) {
8213
            // If the docshell's document is sandboxed and was trying to
8214
            // navigate/load a frame it wasn't allowed to access, the
8215
            // FindItemWithName above will have returned null for the target
8216
            // item - we don't want to actually open a new window in this case
8217
            // though. Check if we are sandboxed and bail out here if so.
8218
            NS_ENSURE_TRUE(mContentViewer, NS_ERROR_FAILURE);
8219
            nsIDocument* doc = mContentViewer->GetDocument();
8220
            PRUint32 sandboxFlags = 0;
8221
            sandboxFlags = doc->SandboxFlags();
8222
            if (sandboxFlags & SANDBOXED_NAVIGATION) {
8223
              return NS_ERROR_FAILURE;
8224
            }
8225
8140
            nsCOMPtr<nsIDOMWindow> win =
8226
            nsCOMPtr<nsIDOMWindow> win =
8141
                do_GetInterface(GetAsSupports(this));
8227
                do_GetInterface(GetAsSupports(this));
8142
            NS_ENSURE_TRUE(win, NS_ERROR_NOT_AVAILABLE);
8228
            NS_ENSURE_TRUE(win, NS_ERROR_NOT_AVAILABLE);
8143
8229
8144
            nsDependentString name(aWindowTarget);
8230
            nsDependentString name(aWindowTarget);
8145
            nsCOMPtr<nsIDOMWindow> newWin;
8231
            nsCOMPtr<nsIDOMWindow> newWin;
8146
            rv = win->Open(EmptyString(), // URL to load
8232
            rv = win->Open(EmptyString(), // URL to load
8147
                           name,          // window name
8233
                           name,          // window name
 Lines 8913-8930   nsDocShell::DoURILoad(nsIURI * aURI, Link Here 
8913
        }
8999
        }
8914
        // Set the referrer explicitly
9000
        // Set the referrer explicitly
8915
        if (aReferrerURI && aSendReferrer) {
9001
        if (aReferrerURI && aSendReferrer) {
8916
            // Referrer is currenly only set for link clicks here.
9002
            // Referrer is currenly only set for link clicks here.
8917
            httpChannel->SetReferrer(aReferrerURI);
9003
            httpChannel->SetReferrer(aReferrerURI);
8918
        }
9004
        }
8919
    }
9005
    }
8920
9006
8921
    nsCOMPtr<nsIPrincipal> ownerPrincipal(do_QueryInterface(aOwner));
9007
    nsCOMPtr<nsIPrincipal> ownerPrincipal;
8922
    nsContentUtils::SetUpChannelOwner(ownerPrincipal, channel, aURI, true);
9008
9009
    // If the content being loaded should be sandboxed with respect to origin
9010
    // we need to create a new null principal here, and then tell
9011
    // nsContentUtils::SetUpChannelOwner to force it to be set as the
9012
    // channel owner.
9013
    if (mSandboxFlags & SANDBOXED_ORIGIN) {
9014
      ownerPrincipal = do_CreateInstance("@mozilla.org/nullprincipal;1");
9015
    } else {
9016
      // Not sandboxed - we allow the content to assume its natural owner.
9017
      ownerPrincipal = do_QueryInterface(aOwner);
9018
    }
9019
9020
    nsContentUtils::SetUpChannelOwner(ownerPrincipal, channel, aURI, true,
9021
                                       (mSandboxFlags & SANDBOXED_ORIGIN));
8923
9022
8924
    nsCOMPtr<nsIScriptChannel> scriptChannel = do_QueryInterface(channel);
9023
    nsCOMPtr<nsIScriptChannel> scriptChannel = do_QueryInterface(channel);
8925
    if (scriptChannel) {
9024
    if (scriptChannel) {
8926
        // Allow execution against our context if the principals match
9025
        // Allow execution against our context if the principals match
8927
        scriptChannel->
9026
        scriptChannel->
8928
            SetExecutionPolicy(nsIScriptChannel::EXECUTE_NORMAL);
9027
            SetExecutionPolicy(nsIScriptChannel::EXECUTE_NORMAL);
8929
    }
9028
    }
8930
9029
(-)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 / +15 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(DBD39C21-5788-4C68-9D97-0FCEE289BCE1)]
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 609-617   interface nsIDocShell : nsISupports Link Here 
609
   * when it initializes the docshell.
609
   * when it initializes the docshell.
610
   *
610
   *
611
   * If so, this docshell should act like a chrome/content boundary for the
611
   * If so, this docshell should act like a chrome/content boundary for the
612
   * purposes of window.top and window.parent.
612
   * purposes of window.top and window.parent.
613
   *
613
   *
614
   * See also nsIMozBrowserFrame.
614
   * See also nsIMozBrowserFrame.
615
   */
615
   */
616
  attribute bool isBrowserFrame;
616
  attribute bool isBrowserFrame;
617
618
  /**
619
   * The sandbox flags on the docshell. These reflect the value of the sandbox
620
   * attribute of the associated IFRAME or CSP-protectable content, if
621
   * existent. See the HTML5 spec for more details.
622
   * These flags on the docshell reflect the current state of the sandbox
623
   * attribute, which is modifiable. They are only used when loading new
624
   * content, sandbox flags are also immutably set on the document when it is
625
   * loaded.
626
   * The sandbox flags of a document depend on the sandbox flags on its
627
   * docshell and of its parent document, if any.
628
   * See nsSandboxFlags.h for the possible flags.
629
   */
630
  attribute unsigned long sandboxFlags;
617
};
631
};
(-)a/dom/base/nsGlobalWindow.cpp (+13 lines)
Line     Link Here 
 Lines 256-271    Link Here 
256
256
257
#include "nsRefreshDriver.h"
257
#include "nsRefreshDriver.h"
258
#include "mozAutoDocUpdate.h"
258
#include "mozAutoDocUpdate.h"
259
259
260
#include "mozilla/Telemetry.h"
260
#include "mozilla/Telemetry.h"
261
#include "nsLocation.h"
261
#include "nsLocation.h"
262
#include "nsWrapperCacheInlines.h"
262
#include "nsWrapperCacheInlines.h"
263
#include "nsDOMEventTargetHelper.h"
263
#include "nsDOMEventTargetHelper.h"
264
#include "nsSandboxFlags.h"
264
265
265
#ifdef ANDROID
266
#ifdef ANDROID
266
#include <android/log.h>
267
#include <android/log.h>
267
#endif
268
#endif
268
269
269
#ifdef PR_LOGGING
270
#ifdef PR_LOGGING
270
static PRLogModuleInfo* gDOMLeakPRLog;
271
static PRLogModuleInfo* gDOMLeakPRLog;
271
#endif
272
#endif
 Lines 8330-8345   nsGlobalWindow::GetSessionStorage(nsIDOM Link Here 
8330
  if (!mSessionStorage) {
8331
  if (!mSessionStorage) {
8331
    *aSessionStorage = nsnull;
8332
    *aSessionStorage = nsnull;
8332
8333
8333
    nsString documentURI;
8334
    nsString documentURI;
8334
    if (mDocument) {
8335
    if (mDocument) {
8335
      mDocument->GetDocumentURI(documentURI);
8336
      mDocument->GetDocumentURI(documentURI);
8336
    }
8337
    }
8337
8338
8339
    // If the document has the sandboxed origin flag set
8340
    // don't allow access to localStorage.
8341
    if (mDoc && (mDoc->SandboxFlags() & SANDBOXED_ORIGIN)) {
8342
      return NS_ERROR_DOM_SECURITY_ERR;
8343
    }
8344
8338
    nsresult rv = docShell->GetSessionStorageForPrincipal(principal,
8345
    nsresult rv = docShell->GetSessionStorageForPrincipal(principal,
8339
                                                          documentURI,
8346
                                                          documentURI,
8340
                                                          true,
8347
                                                          true,
8341
                                                          getter_AddRefs(mSessionStorage));
8348
                                                          getter_AddRefs(mSessionStorage));
8342
    NS_ENSURE_SUCCESS(rv, rv);
8349
    NS_ENSURE_SUCCESS(rv, rv);
8343
8350
8344
#ifdef PR_LOGGING
8351
#ifdef PR_LOGGING
8345
    if (PR_LOG_TEST(gDOMLeakPRLog, PR_LOG_DEBUG)) {
8352
    if (PR_LOG_TEST(gDOMLeakPRLog, PR_LOG_DEBUG)) {
 Lines 8391-8406   nsGlobalWindow::GetLocalStorage(nsIDOMSt Link Here 
8391
      do_GetService("@mozilla.org/dom/storagemanager;1", &rv);
8398
      do_GetService("@mozilla.org/dom/storagemanager;1", &rv);
8392
    NS_ENSURE_SUCCESS(rv, rv);
8399
    NS_ENSURE_SUCCESS(rv, rv);
8393
8400
8394
    nsString documentURI;
8401
    nsString documentURI;
8395
    if (mDocument) {
8402
    if (mDocument) {
8396
      mDocument->GetDocumentURI(documentURI);
8403
      mDocument->GetDocumentURI(documentURI);
8397
    }
8404
    }
8398
8405
8406
    // If the document has the sandboxed origin flag set
8407
    // don't allow access to localStorage.
8408
    if (mDoc && (mDoc->SandboxFlags() & SANDBOXED_ORIGIN)) {
8409
      return NS_ERROR_DOM_SECURITY_ERR;
8410
    }
8411
8399
    rv = storageManager->GetLocalStorageForPrincipal(principal,
8412
    rv = storageManager->GetLocalStorageForPrincipal(principal,
8400
                                                     documentURI,
8413
                                                     documentURI,
8401
                                                     getter_AddRefs(mLocalStorage));
8414
                                                     getter_AddRefs(mLocalStorage));
8402
    NS_ENSURE_SUCCESS(rv, rv);
8415
    NS_ENSURE_SUCCESS(rv, rv);
8403
  }
8416
  }
8404
8417
8405
  NS_ADDREF(*aLocalStorage = mLocalStorage);
8418
  NS_ADDREF(*aLocalStorage = mLocalStorage);
8406
  return NS_OK;
8419
  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(0ead5a5c-e4d3-4e4d-88b8-7c9dc9d2665c)]
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/dom/src/jsurl/Makefile.in (+1 lines)
Line     Link Here 
 Lines 57-72   XPIDLSRCS = \ Link Here 
57
CPPSRCS		= nsJSProtocolHandler.cpp
57
CPPSRCS		= nsJSProtocolHandler.cpp
58
58
59
EXPORTS		= $(srcdir)/nsJSProtocolHandler.h
59
EXPORTS		= $(srcdir)/nsJSProtocolHandler.h
60
60
61
LOCAL_INCLUDES += \
61
LOCAL_INCLUDES += \
62
		-I$(srcdir) \
62
		-I$(srcdir) \
63
		-I$(topsrcdir)/dom/base \
63
		-I$(topsrcdir)/dom/base \
64
		-I$(topsrcdir)/netwerk/base/src \
64
		-I$(topsrcdir)/netwerk/base/src \
65
		-I$(topsrcdir)/content/base/src \
65
66
66
ifdef BUILD_DEBUG_GC
67
ifdef BUILD_DEBUG_GC
67
DEFINES		+= -DDEBUG_GC
68
DEFINES		+= -DDEBUG_GC
68
endif
69
endif
69
70
70
DIRS            = $(NULL)
71
DIRS            = $(NULL)
71
TEST_DIRS += test
72
TEST_DIRS += test
72
73
(-)a/dom/src/jsurl/nsJSProtocolHandler.cpp (+13 lines)
Line     Link Here 
 Lines 74-89    Link Here 
74
#include "nsThreadUtils.h"
74
#include "nsThreadUtils.h"
75
#include "nsIJSContextStack.h"
75
#include "nsIJSContextStack.h"
76
#include "nsIScriptChannel.h"
76
#include "nsIScriptChannel.h"
77
#include "nsIDocument.h"
77
#include "nsIDocument.h"
78
#include "nsIObjectInputStream.h"
78
#include "nsIObjectInputStream.h"
79
#include "nsIObjectOutputStream.h"
79
#include "nsIObjectOutputStream.h"
80
#include "nsIWritablePropertyBag2.h"
80
#include "nsIWritablePropertyBag2.h"
81
#include "nsIContentSecurityPolicy.h"
81
#include "nsIContentSecurityPolicy.h"
82
#include "nsSandboxFlags.h"
82
83
83
static NS_DEFINE_CID(kJSURICID, NS_JSURI_CID);
84
static NS_DEFINE_CID(kJSURICID, NS_JSURI_CID);
84
85
85
class nsJSThunk : public nsIInputStream
86
class nsJSThunk : public nsIInputStream
86
{
87
{
87
public:
88
public:
88
    nsJSThunk();
89
    nsJSThunk();
89
90
 Lines 220-235   nsresult nsJSThunk::EvaluateScript(nsICh Link Here 
220
    // Get the global object we should be running on.
221
    // Get the global object we should be running on.
221
    nsIScriptGlobalObject* global = GetGlobalObject(aChannel);
222
    nsIScriptGlobalObject* global = GetGlobalObject(aChannel);
222
    if (!global) {
223
    if (!global) {
223
        return NS_ERROR_FAILURE;
224
        return NS_ERROR_FAILURE;
224
    }
225
    }
225
226
226
    nsCOMPtr<nsPIDOMWindow> win(do_QueryInterface(global));
227
    nsCOMPtr<nsPIDOMWindow> win(do_QueryInterface(global));
227
228
229
    // Sandboxed document check: javascript: URI's are disabled 
230
    // in a sandboxed document unless 'allow-scripts' was specified
231
232
    // REVIEW - it seems like the original inner window would be the one
233
    // that will execute the javascript with its principal - is this 
234
    // assumption correct ?? (and is GetExtantDocument() the right way
235
    // to get the right document ??
236
    nsCOMPtr<nsIDocument> doc = do_QueryInterface(aOriginalInnerWindow->GetExtantDocument());
237
    if (doc && (doc->SandboxFlags() & SANDBOXED_SCRIPTS)) {
238
      return NS_ERROR_DOM_RETVAL_UNDEFINED;
239
    }
240
228
    // Push our popup control state
241
    // Push our popup control state
229
    nsAutoPopupStatePusher popupStatePusher(win, aPopupState);
242
    nsAutoPopupStatePusher popupStatePusher(win, aPopupState);
230
243
231
    // Make sure we still have the same inner window as we used to.
244
    // Make sure we still have the same inner window as we used to.
232
    nsPIDOMWindow *innerWin = win->GetCurrentInnerWindow();
245
    nsPIDOMWindow *innerWin = win->GetCurrentInnerWindow();
233
246
234
    if (innerWin != aOriginalInnerWindow) {
247
    if (innerWin != aOriginalInnerWindow) {
235
        return NS_ERROR_UNEXPECTED;
248
        return NS_ERROR_UNEXPECTED;
(-)a/embedding/components/windowwatcher/src/Makefile.in (-1 / +2 lines)
Line     Link Here 
 Lines 56-66   CPPSRCS += nsDialogParamBlock.cpp \ Link Here 
56
		   $(NULL)
56
		   $(NULL)
57
endif
57
endif
58
58
59
# we don't want the shared lib, but we want to force the creation of a
59
# we don't want the shared lib, but we want to force the creation of a
60
# static lib.
60
# static lib.
61
FORCE_STATIC_LIB = 1
61
FORCE_STATIC_LIB = 1
62
62
63
# For nsJSUtils
63
# For nsJSUtils
64
LOCAL_INCLUDES += -I$(topsrcdir)/dom/base
64
LOCAL_INCLUDES += -I$(topsrcdir)/dom/base \
65
		  -I$(topsrcdir)/content/base/src \
65
66
66
include $(topsrcdir)/config/rules.mk
67
include $(topsrcdir)/config/rules.mk
(-)a/embedding/components/windowwatcher/src/nsWindowWatcher.cpp (+18 lines)
Line     Link Here 
 Lines 86-101    Link Here 
86
#include "nsPIDOMStorage.h"
86
#include "nsPIDOMStorage.h"
87
#include "nsIWidget.h"
87
#include "nsIWidget.h"
88
#include "nsFocusManager.h"
88
#include "nsFocusManager.h"
89
#include "nsIPresShell.h"
89
#include "nsIPresShell.h"
90
#include "nsPresContext.h"
90
#include "nsPresContext.h"
91
#include "nsContentUtils.h"
91
#include "nsContentUtils.h"
92
#include "nsIPrefBranch.h"
92
#include "nsIPrefBranch.h"
93
#include "nsIPrefService.h"
93
#include "nsIPrefService.h"
94
#include "nsSandboxFlags.h"
94
95
95
#ifdef USEWEAKREFS
96
#ifdef USEWEAKREFS
96
#include "nsIWeakReference.h"
97
#include "nsIWeakReference.h"
97
#endif
98
#endif
98
99
99
using namespace mozilla;
100
using namespace mozilla;
100
101
101
static const char *sJSStackContractID="@mozilla.org/js/xpc/ContextStack;1";
102
static const char *sJSStackContractID="@mozilla.org/js/xpc/ContextStack;1";
 Lines 603-618   nsWindowWatcher::OpenWindowJSInternal(ns Link Here 
603
  }
604
  }
604
605
605
  if (!newDocShellItem) {
606
  if (!newDocShellItem) {
606
    // We're going to either open up a new window ourselves or ask a
607
    // 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
608
    // nsIWindowProvider for one.  In either case, we'll want to set the right
608
    // name on it.
609
    // name on it.
609
    windowNeedsName = true;
610
    windowNeedsName = true;
610
611
612
    // If the parent trying to open a new window is sandboxed,
613
    // this is not allowed and we fail here.
614
    if (aParent) {
615
      nsCOMPtr<nsIDOMDocument> domdoc;
616
      aParent->GetDocument(getter_AddRefs(domdoc));
617
      nsCOMPtr<nsIDocument> doc = do_QueryInterface(domdoc);
618
619
      if (doc) {
620
        PRUint32 sandboxFlags = 0;
621
        sandboxFlags = doc->SandboxFlags();
622
623
        if (sandboxFlags & SANDBOXED_NAVIGATION) {
624
          return NS_ERROR_FAILURE;
625
        }
626
      }
627
    }
628
611
    // Now check whether it's ok to ask a window provider for a window.  Don't
629
    // 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
630
    // 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.
631
    // if we're opening something that has modal, dialog, or chrome flags set.
614
    nsCOMPtr<nsIDOMChromeWindow> chromeWin = do_QueryInterface(aParent);
632
    nsCOMPtr<nsIDOMChromeWindow> chromeWin = do_QueryInterface(aParent);
615
    if (!aDialog && !chromeWin &&
633
    if (!aDialog && !chromeWin &&
616
        !(chromeFlags & (nsIWebBrowserChrome::CHROME_MODAL         |
634
        !(chromeFlags & (nsIWebBrowserChrome::CHROME_MODAL         |
617
                         nsIWebBrowserChrome::CHROME_OPENAS_DIALOG | 
635
                         nsIWebBrowserChrome::CHROME_OPENAS_DIALOG | 
618
                         nsIWebBrowserChrome::CHROME_OPENAS_CHROME))) {
636
                         nsIWebBrowserChrome::CHROME_OPENAS_CHROME))) {

Return to bug 341604