mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-04 21:18:35 +00:00
Bug 845057 - Part 1: Use DOMSettableTokenList for iframe.sandbox; r=bz
This commit is contained in:
parent
db5fce1d3a
commit
e9ca3cadd2
@ -43,7 +43,6 @@ NS_IMPL_STRING_ATTR(HTMLIFrameElement, Scrolling, scrolling)
|
||||
NS_IMPL_URI_ATTR(HTMLIFrameElement, Src, src)
|
||||
NS_IMPL_STRING_ATTR(HTMLIFrameElement, Width, width)
|
||||
NS_IMPL_BOOL_ATTR(HTMLIFrameElement, AllowFullscreen, allowfullscreen)
|
||||
NS_IMPL_STRING_ATTR(HTMLIFrameElement, Sandbox, sandbox)
|
||||
NS_IMPL_STRING_ATTR(HTMLIFrameElement, Srcdoc, srcdoc)
|
||||
|
||||
void
|
||||
@ -98,6 +97,10 @@ HTMLIFrameElement::ParseAttribute(int32_t aNamespaceID,
|
||||
if (aAttribute == nsGkAtoms::align) {
|
||||
return ParseAlignValue(aValue, aResult);
|
||||
}
|
||||
if (aAttribute == nsGkAtoms::sandbox) {
|
||||
aResult.ParseAtomArray(aValue);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return nsGenericHTMLFrameElement::ParseAttribute(aNamespaceID, aAttribute,
|
||||
@ -211,20 +214,11 @@ HTMLIFrameElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
||||
const nsAttrValue* aValue,
|
||||
bool aNotify)
|
||||
{
|
||||
if (aName == nsGkAtoms::sandbox && aNameSpaceID == kNameSpaceID_None) {
|
||||
// If we have an nsFrameLoader, parse the new value of the sandbox
|
||||
// attribute and apply the new sandbox flags.
|
||||
if (mFrameLoader) {
|
||||
// If a nullptr aValue is passed in, we want to clear the sandbox flags
|
||||
// which we will do by setting them to 0.
|
||||
uint32_t newFlags = 0;
|
||||
if (aValue) {
|
||||
nsAutoString strValue;
|
||||
aValue->ToString(strValue);
|
||||
newFlags = nsContentUtils::ParseSandboxAttributeToFlags(strValue);
|
||||
}
|
||||
mFrameLoader->ApplySandboxFlags(newFlags);
|
||||
}
|
||||
if (aName == nsGkAtoms::sandbox && aNameSpaceID == kNameSpaceID_None && mFrameLoader) {
|
||||
// If we have an nsFrameLoader, apply the new sandbox flags.
|
||||
// Since this is called after the setter, the sandbox flags have
|
||||
// alreay been updated.
|
||||
mFrameLoader->ApplySandboxFlags(GetSandboxFlags());
|
||||
}
|
||||
return nsGenericHTMLElement::AfterSetAttr(aNameSpaceID, aName, aValue,
|
||||
aNotify);
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "nsGenericHTMLFrameElement.h"
|
||||
#include "nsIDOMHTMLIFrameElement.h"
|
||||
#include "nsDOMSettableTokenList.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
@ -77,9 +78,9 @@ public:
|
||||
{
|
||||
SetHTMLAttr(nsGkAtoms::name, aName, aError);
|
||||
}
|
||||
void GetSandbox(DOMString& aSandbox)
|
||||
nsDOMSettableTokenList* Sandbox()
|
||||
{
|
||||
GetHTMLAttr(nsGkAtoms::sandbox, aSandbox);
|
||||
return GetTokenList(nsGkAtoms::sandbox);
|
||||
}
|
||||
bool AllowFullscreen() const
|
||||
{
|
||||
|
@ -91,8 +91,8 @@ function doTest() {
|
||||
ok_wrapper("sandbox" in ifr, "a new iframe should have a sandbox attribute");
|
||||
|
||||
// passes if good
|
||||
// 11) test that the sandbox attribute's default value is an empty string
|
||||
ok_wrapper(ifr.sandbox === "", "default sandbox attribute should be an empty string");
|
||||
// 11) test that the sandbox attribute's default stringyfied value is an empty string
|
||||
ok_wrapper(ifr.sandbox.length === 0 && ifr.sandbox == "", "default sandbox attribute should be an empty string");
|
||||
|
||||
// passes if good
|
||||
// 12) test that a sandboxed iframe with 'allow-forms' can submit forms
|
||||
|
@ -34,7 +34,5 @@ interface nsIDOMHTMLIFrameElement : nsISupports
|
||||
readonly attribute nsIDOMDocument contentDocument;
|
||||
readonly attribute nsIDOMWindow contentWindow;
|
||||
|
||||
attribute DOMString sandbox;
|
||||
|
||||
attribute boolean allowFullscreen;
|
||||
};
|
||||
|
@ -18,9 +18,7 @@ interface HTMLIFrameElement : HTMLElement {
|
||||
attribute DOMString srcdoc;
|
||||
[SetterThrows, Pure]
|
||||
attribute DOMString name;
|
||||
// [PutForwards=value] readonly attribute DOMSettableTokenList sandbox;
|
||||
// We're implementing sandbox as a string for now, see bug 845057.
|
||||
attribute DOMString sandbox;
|
||||
[PutForwards=value] readonly attribute DOMSettableTokenList sandbox;
|
||||
// attribute boolean seamless;
|
||||
[SetterThrows, Pure]
|
||||
attribute boolean allowFullscreen;
|
||||
|
Loading…
x
Reference in New Issue
Block a user