This commit is contained in:
Ryan VanderMeulen 2012-10-14 16:39:23 -04:00
Родитель 1a160d7b3f df0e84f199
Коммит 409f1f5ca2
173 изменённых файлов: 2845 добавлений и 1476 удалений

Просмотреть файл

@ -273,7 +273,7 @@ Accessible::Name(nsString& aName)
return eNameOK;
}
nsresult rv = GetNameInternal(aName);
ENameValueFlag nameFlag = NativeName(aName);
if (!aName.IsEmpty())
return eNameOK;
@ -292,7 +292,7 @@ Accessible::Name(nsString& aName)
return eNameOK;
}
if (rv != NS_OK_EMPTY_NAME)
if (nameFlag != eNoNameOnPurpose)
aName.SetIsVoid(true);
return eNameOK;
@ -1055,26 +1055,19 @@ Accessible::TakeFocus()
return NS_OK;
}
nsresult
Accessible::GetHTMLName(nsAString& aLabel)
void
Accessible::GetHTMLName(nsString& aLabel)
{
nsAutoString label;
Accessible* labelAcc = nullptr;
HTMLLabelIterator iter(Document(), this);
while ((labelAcc = iter.Next())) {
nsresult rv = nsTextEquivUtils::
AppendTextEquivFromContent(this, labelAcc->GetContent(), &label);
NS_ENSURE_SUCCESS(rv, rv);
label.CompressWhitespace();
nsTextEquivUtils::AppendTextEquivFromContent(this, labelAcc->GetContent(),
&aLabel);
aLabel.CompressWhitespace();
}
if (label.IsEmpty())
return nsTextEquivUtils::GetNameFromSubtree(this, aLabel);
aLabel = label;
return NS_OK;
if (aLabel.IsEmpty())
nsTextEquivUtils::GetNameFromSubtree(this, aLabel);
}
/**
@ -1089,60 +1082,53 @@ Accessible::GetHTMLName(nsAString& aLabel)
* the control that uses the control="controlID" syntax will use
* the child label for its Name.
*/
nsresult
Accessible::GetXULName(nsAString& aLabel)
void
Accessible::GetXULName(nsString& aName)
{
// CASE #1 (via label attribute) -- great majority of the cases
nsresult rv = NS_OK;
nsAutoString label;
nsCOMPtr<nsIDOMXULLabeledControlElement> labeledEl(do_QueryInterface(mContent));
nsCOMPtr<nsIDOMXULLabeledControlElement> labeledEl =
do_QueryInterface(mContent);
if (labeledEl) {
rv = labeledEl->GetLabel(label);
}
else {
nsCOMPtr<nsIDOMXULSelectControlItemElement> itemEl(do_QueryInterface(mContent));
labeledEl->GetLabel(aName);
} else {
nsCOMPtr<nsIDOMXULSelectControlItemElement> itemEl =
do_QueryInterface(mContent);
if (itemEl) {
rv = itemEl->GetLabel(label);
}
else {
nsCOMPtr<nsIDOMXULSelectControlElement> select(do_QueryInterface(mContent));
itemEl->GetLabel(aName);
} else {
nsCOMPtr<nsIDOMXULSelectControlElement> select =
do_QueryInterface(mContent);
// Use label if this is not a select control element which
// uses label attribute to indicate which option is selected
if (!select) {
nsCOMPtr<nsIDOMXULElement> xulEl(do_QueryInterface(mContent));
if (xulEl) {
rv = xulEl->GetAttribute(NS_LITERAL_STRING("label"), label);
}
if (xulEl)
xulEl->GetAttribute(NS_LITERAL_STRING("label"), aName);
}
}
}
// CASES #2 and #3 ------ label as a child or <label control="id" ... > </label>
if (NS_FAILED(rv) || label.IsEmpty()) {
label.Truncate();
if (aName.IsEmpty()) {
Accessible* labelAcc = nullptr;
XULLabelIterator iter(Document(), mContent);
while ((labelAcc = iter.Next())) {
nsCOMPtr<nsIDOMXULLabelElement> xulLabel =
do_QueryInterface(labelAcc->GetContent());
// Check if label's value attribute is used
if (xulLabel && NS_SUCCEEDED(xulLabel->GetValue(label)) && label.IsEmpty()) {
if (xulLabel && NS_SUCCEEDED(xulLabel->GetValue(aName)) && aName.IsEmpty()) {
// If no value attribute, a non-empty label must contain
// children that define its text -- possibly using HTML
nsTextEquivUtils::
AppendTextEquivFromContent(this, labelAcc->GetContent(), &label);
AppendTextEquivFromContent(this, labelAcc->GetContent(), &aName);
}
}
}
// XXX If CompressWhiteSpace worked on nsAString we could avoid a copy
label.CompressWhitespace();
if (!label.IsEmpty()) {
aLabel = label;
return NS_OK;
}
aName.CompressWhitespace();
if (!aName.IsEmpty())
return;
// Can get text from title of <toolbaritem> if we're a child of a <toolbaritem>
nsIContent *bindingParent = mContent->GetBindingParent();
@ -1150,15 +1136,14 @@ Accessible::GetXULName(nsAString& aLabel)
mContent->GetParent();
while (parent) {
if (parent->Tag() == nsGkAtoms::toolbaritem &&
parent->GetAttr(kNameSpaceID_None, nsGkAtoms::title, label)) {
label.CompressWhitespace();
aLabel = label;
return NS_OK;
parent->GetAttr(kNameSpaceID_None, nsGkAtoms::title, aName)) {
aName.CompressWhitespace();
return;
}
parent = parent->GetParent();
}
return nsTextEquivUtils::GetNameFromSubtree(this, aLabel);
nsTextEquivUtils::GetNameFromSubtree(this, aName);
}
nsresult
@ -2433,9 +2418,6 @@ Accessible::Shutdown()
nsAccessNodeWrap::Shutdown();
}
////////////////////////////////////////////////////////////////////////////////
// Accessible public methods
// Accessible protected
void
Accessible::ARIAName(nsAString& aName)
@ -2458,16 +2440,16 @@ Accessible::ARIAName(nsAString& aName)
}
}
nsresult
Accessible::GetNameInternal(nsAString& aName)
// Accessible protected
ENameValueFlag
Accessible::NativeName(nsString& aName)
{
if (mContent->IsHTML())
return GetHTMLName(aName);
GetHTMLName(aName);
else if (mContent->IsXUL())
GetXULName(aName);
if (mContent->IsXUL())
return GetXULName(aName);
return NS_OK;
return eNameOK;
}
// Accessible protected
@ -2490,6 +2472,7 @@ Accessible::BindToParent(Accessible* aParent, uint32_t aIndexInParent)
mIndexInParent = aIndexInParent;
}
// Accessible protected
void
Accessible::UnbindFromParent()
{
@ -2499,6 +2482,9 @@ Accessible::UnbindFromParent()
mGroupInfo = nullptr;
}
////////////////////////////////////////////////////////////////////////////////
// Accessible public methods
void
Accessible::InvalidateChildren()
{

Просмотреть файл

@ -49,10 +49,19 @@ enum ENameValueFlag {
* Name either
* a) present (not empty): !name.IsEmpty()
* b) no name (was missed): name.IsVoid()
* c) was left empty by the author on demand: name.IsEmpty() && !name.IsVoid()
*/
eNameOK,
eNameFromTooltip // Tooltip was used as a name
/**
* Name was left empty by the author on purpose:
* name.IsEmpty() && !name.IsVoid().
*/
eNoNameOnPurpose,
/**
* Tooltip was used as a name.
*/
eNameFromTooltip
};
/**
@ -132,6 +141,9 @@ public:
/**
* Get the name of this accessible.
*
* Note: aName.IsVoid() when name was left empty by the author on purpose.
* aName.IsEmpty() when the author missed name, AT can try to repair a name.
*/
virtual mozilla::a11y::ENameValueFlag Name(nsString& aName);
@ -155,18 +167,6 @@ public:
*/
virtual void ApplyARIAState(uint64_t* aState) const;
/**
* Returns the accessible name provided by native markup. It doesn't take
* into account ARIA markup used to specify the name.
*
* @param aName [out] the accessible name
*
* @return NS_OK_EMPTY_NAME points empty name was specified by native markup
* explicitly (see nsIAccessible::name attribute for
* details)
*/
virtual nsresult GetNameInternal(nsAString& aName);
/**
* Return enumerated accessible role (see constants in Role.h).
*/
@ -793,20 +793,22 @@ protected:
//////////////////////////////////////////////////////////////////////////////
// Name helpers
/**
* Return the accessible name provided by native markup. It doesn't take
* into account ARIA markup used to specify the name.
*/
virtual mozilla::a11y::ENameValueFlag NativeName(nsString& aName);
/**
* Returns the accessible name specified by ARIA.
*/
void ARIAName(nsAString& aName);
/**
* Compute the name of HTML node.
* Compute the name of HTML/XUL node.
*/
nsresult GetHTMLName(nsAString& aName);
/**
* Compute the name for XUL node.
*/
nsresult GetXULName(nsAString& aName);
void GetHTMLName(nsString& aName);
void GetXULName(nsString& aName);
// helper method to verify frames
static nsresult GetFullKeyName(const nsAString& aModifierName, const nsAString& aKeyName, nsAString& aStringOut);

Просмотреть файл

@ -1949,23 +1949,20 @@ HyperTextAccessible::ScrollSubstringToPoint(int32_t aStartIndex,
////////////////////////////////////////////////////////////////////////////////
// Accessible public
nsresult
HyperTextAccessible::GetNameInternal(nsAString& aName)
// Accessible protected
ENameValueFlag
HyperTextAccessible::NativeName(nsString& aName)
{
nsresult rv = AccessibleWrap::GetNameInternal(aName);
NS_ENSURE_SUCCESS(rv, rv);
AccessibleWrap::NativeName(aName);
// Get name from title attribute for HTML abbr and acronym elements making it
// a valid name from markup. Otherwise their name isn't picked up by recursive
// name computation algorithm. See NS_OK_NAME_FROM_TOOLTIP.
if (aName.IsEmpty() && IsAbbreviation()) {
nsAutoString name;
if (mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::title, name)) {
name.CompressWhitespace();
aName = name;
}
}
return NS_OK;
if (aName.IsEmpty() && IsAbbreviation() &&
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::title, aName))
aName.CompressWhitespace();
return eNameOK;
}
void

Просмотреть файл

@ -52,7 +52,6 @@ public:
// Accessible
virtual int32_t GetLevelInternal();
virtual nsresult GetAttributesInternal(nsIPersistentProperties *aAttributes);
virtual nsresult GetNameInternal(nsAString& aName);
virtual mozilla::a11y::role NativeRole();
virtual uint64_t NativeState();
@ -243,6 +242,9 @@ public:
virtual already_AddRefed<nsIEditor> GetEditor() const;
protected:
// Accessible
virtual mozilla::a11y::ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
// HyperTextAccessible
/**

Просмотреть файл

@ -69,26 +69,24 @@ ImageAccessible::NativeState()
return state;
}
nsresult
ImageAccessible::GetNameInternal(nsAString& aName)
ENameValueFlag
ImageAccessible::NativeName(nsString& aName)
{
bool hasAltAttrib =
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::alt, aName);
if (!aName.IsEmpty())
return NS_OK;
nsresult rv = Accessible::GetNameInternal(aName);
NS_ENSURE_SUCCESS(rv, rv);
return eNameOK;
Accessible::NativeName(aName);
if (aName.IsEmpty() && hasAltAttrib) {
// No accessible name but empty 'alt' attribute is present. If further name
// computation algorithm doesn't provide non empty name then it means
// an empty 'alt' attribute was used to indicate a decorative image (see
// nsIAccessible::name attribute for details).
return NS_OK_EMPTY_NAME;
return eNoNameOnPurpose;
}
return NS_OK;
return eNameOK;
}
role

Просмотреть файл

@ -36,7 +36,6 @@ public:
NS_DECL_NSIACCESSIBLEIMAGE
// Accessible
virtual nsresult GetNameInternal(nsAString& aName);
virtual a11y::role NativeRole();
virtual uint64_t NativeState();
virtual nsresult GetAttributesInternal(nsIPersistentProperties *aAttributes);
@ -44,6 +43,10 @@ public:
// ActionAccessible
virtual uint8_t ActionCount();
protected:
// Accessible
virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
private:
/**
* Return whether the element has a longdesc URI.

Просмотреть файл

@ -41,11 +41,11 @@ HTMLBRAccessible::NativeState()
return states::READONLY;
}
nsresult
HTMLBRAccessible::GetNameInternal(nsAString& aName)
ENameValueFlag
HTMLBRAccessible::NativeName(nsString& aName)
{
aName = static_cast<PRUnichar>('\n'); // Newline char
return NS_OK;
return eNameOK;
}
////////////////////////////////////////////////////////////////////////////////
@ -54,10 +54,11 @@ HTMLBRAccessible::GetNameInternal(nsAString& aName)
NS_IMPL_ISUPPORTS_INHERITED0(HTMLLabelAccessible, HyperTextAccessible)
nsresult
HTMLLabelAccessible::GetNameInternal(nsAString& aName)
ENameValueFlag
HTMLLabelAccessible::NativeName(nsString& aName)
{
return nsTextEquivUtils::GetNameFromSubtree(this, aName);
nsTextEquivUtils::GetNameFromSubtree(this, aName);
return eNameOK;
}
role

Просмотреть файл

@ -32,14 +32,16 @@ public:
class HTMLBRAccessible : public LeafAccessible
{
public:
HTMLBRAccessible(nsIContent* aContent, DocAccessible* aDoc) :
LeafAccessible(aContent, aDoc) {};
// Accessible
virtual nsresult GetNameInternal(nsAString& aName);
virtual a11y::role NativeRole();
virtual uint64_t NativeState();
protected:
// Accessible
virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
};
/**
@ -55,8 +57,10 @@ public:
NS_DECL_ISUPPORTS_INHERITED
// Accessible
virtual nsresult GetNameInternal(nsAString& aName);
virtual a11y::role NativeRole();
protected:
virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
};
/**

Просмотреть файл

@ -256,37 +256,32 @@ HTMLButtonAccessible::NativeRole()
return roles::PUSHBUTTON;
}
nsresult
HTMLButtonAccessible::GetNameInternal(nsAString& aName)
ENameValueFlag
HTMLButtonAccessible::NativeName(nsString& aName)
{
Accessible::GetNameInternal(aName);
Accessible::NativeName(aName);
if (!aName.IsEmpty() || mContent->Tag() != nsGkAtoms::input)
return NS_OK;
return eNameOK;
// No name from HTML or ARIA
nsAutoString name;
if (!mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::value,
name) &&
!mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::alt,
name)) {
if (!mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::value, aName) &&
!mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::alt, aName)) {
// Use the button's (default) label if nothing else works
nsIFrame* frame = GetFrame();
if (frame) {
nsIFormControlFrame* fcFrame = do_QueryFrame(frame);
if (fcFrame)
fcFrame->GetFormProperty(nsGkAtoms::defaultLabel, name);
fcFrame->GetFormProperty(nsGkAtoms::defaultLabel, aName);
}
}
if (name.IsEmpty() &&
!mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::src, name)) {
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::data, name);
if (aName.IsEmpty() &&
!mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::src, aName)) {
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::data, aName);
}
name.CompressWhitespace();
aName = name;
return NS_OK;
aName.CompressWhitespace();
return eNameOK;
}
////////////////////////////////////////////////////////////////////////////////
@ -325,17 +320,14 @@ HTMLTextFieldAccessible::NativeRole()
return roles::ENTRY;
}
nsresult
HTMLTextFieldAccessible::GetNameInternal(nsAString& aName)
ENameValueFlag
HTMLTextFieldAccessible::NativeName(nsString& aName)
{
nsresult rv = Accessible::GetNameInternal(aName);
NS_ENSURE_SUCCESS(rv, rv);
Accessible::NativeName(aName);
if (!aName.IsEmpty())
return NS_OK;
return eNameOK;
if (mContent->GetBindingParent())
{
if (mContent->GetBindingParent()) {
// XXX: bug 459640
// There's a binding parent.
// This means we're part of another control, so use parent accessible for name.
@ -347,12 +339,11 @@ HTMLTextFieldAccessible::GetNameInternal(nsAString& aName)
}
if (!aName.IsEmpty())
return NS_OK;
return eNameOK;
// text inputs and textareas might have useful placeholder text
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::placeholder, aName);
return NS_OK;
return eNameOK;
}
void
@ -619,22 +610,18 @@ HTMLGroupboxAccessible::GetLegend()
return nullptr;
}
nsresult
HTMLGroupboxAccessible::GetNameInternal(nsAString& aName)
ENameValueFlag
HTMLGroupboxAccessible::NativeName(nsString& aName)
{
nsresult rv = Accessible::GetNameInternal(aName);
NS_ENSURE_SUCCESS(rv, rv);
Accessible::NativeName(aName);
if (!aName.IsEmpty())
return NS_OK;
return eNameOK;
nsIContent *legendContent = GetLegend();
if (legendContent) {
return nsTextEquivUtils::
AppendTextEquivFromContent(this, legendContent, &aName);
}
nsIContent* legendContent = GetLegend();
if (legendContent)
nsTextEquivUtils::AppendTextEquivFromContent(this, legendContent, &aName);
return NS_OK;
return eNameOK;
}
Relation
@ -706,22 +693,18 @@ HTMLFigureAccessible::NativeRole()
return roles::FIGURE;
}
nsresult
HTMLFigureAccessible::GetNameInternal(nsAString& aName)
ENameValueFlag
HTMLFigureAccessible::NativeName(nsString& aName)
{
nsresult rv = HyperTextAccessibleWrap::GetNameInternal(aName);
NS_ENSURE_SUCCESS(rv, rv);
HyperTextAccessibleWrap::NativeName(aName);
if (!aName.IsEmpty())
return NS_OK;
return eNameOK;
nsIContent* captionContent = Caption();
if (captionContent) {
return nsTextEquivUtils::
AppendTextEquivFromContent(this, captionContent, &aName);
}
if (captionContent)
nsTextEquivUtils::AppendTextEquivFromContent(this, captionContent, &aName);
return NS_OK;
return eNameOK;
}
Relation

Просмотреть файл

@ -77,7 +77,6 @@ public:
NS_IMETHOD DoAction(uint8_t index);
// Accessible
virtual nsresult GetNameInternal(nsAString& aName);
virtual mozilla::a11y::role NativeRole();
virtual uint64_t State();
virtual uint64_t NativeState();
@ -87,6 +86,10 @@ public:
// Widgets
virtual bool IsWidget() const;
protected:
// Accessible
virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
};
@ -113,7 +116,6 @@ public:
// Accessible
virtual void Value(nsString& aValue);
virtual void ApplyARIAState(uint64_t* aState) const;
virtual nsresult GetNameInternal(nsAString& aName);
virtual mozilla::a11y::role NativeRole();
virtual uint64_t State();
virtual uint64_t NativeState();
@ -124,6 +126,10 @@ public:
// Widgets
virtual bool IsWidget() const;
virtual Accessible* ContainerWidget() const;
protected:
// Accessible
virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
};
@ -149,11 +155,14 @@ public:
HTMLGroupboxAccessible(nsIContent* aContent, DocAccessible* aDoc);
// Accessible
virtual nsresult GetNameInternal(nsAString& aName);
virtual mozilla::a11y::role NativeRole();
virtual Relation RelationByType(uint32_t aType);
protected:
// Accessible
virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
// HTMLGroupboxAccessible
nsIContent* GetLegend();
};
@ -181,11 +190,14 @@ public:
// Accessible
virtual nsresult GetAttributesInternal(nsIPersistentProperties* aAttributes);
virtual nsresult GetNameInternal(nsAString& aName);
virtual mozilla::a11y::role NativeRole();
virtual Relation RelationByType(uint32_t aType);
protected:
// Accessible
virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
// HTMLLegendAccessible
nsIContent* Caption() const;
};

Просмотреть файл

@ -160,19 +160,17 @@ HTMLAreaAccessible::
////////////////////////////////////////////////////////////////////////////////
// HTMLAreaAccessible: nsIAccessible
nsresult
HTMLAreaAccessible::GetNameInternal(nsAString& aName)
ENameValueFlag
HTMLAreaAccessible::NativeName(nsString& aName)
{
nsresult rv = Accessible::GetNameInternal(aName);
NS_ENSURE_SUCCESS(rv, rv);
Accessible::NativeName(aName);
if (!aName.IsEmpty())
return NS_OK;
return eNameOK;
if (!mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::alt, aName))
return GetValue(aName);
GetValue(aName);
return NS_OK;
return eNameOK;
}
void

Просмотреть файл

@ -55,7 +55,6 @@ public:
// Accessible
virtual void Description(nsString& aDescription);
virtual nsresult GetNameInternal(nsAString& aName);
virtual Accessible* ChildAtPoint(int32_t aX, int32_t aY,
EWhichChildAtPoint aWhichChild);
virtual void GetBoundsRect(nsRect& aBounds, nsIFrame** aBoundingFrame);
@ -65,8 +64,8 @@ public:
virtual uint32_t EndOffset();
protected:
// Accessible
virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
virtual void CacheChildren();
};

Просмотреть файл

@ -185,34 +185,24 @@ HTMLSelectOptionAccessible::NativeRole()
return roles::OPTION;
}
nsresult
HTMLSelectOptionAccessible::GetNameInternal(nsAString& aName)
ENameValueFlag
HTMLSelectOptionAccessible::NativeName(nsString& aName)
{
// CASE #1 -- great majority of the cases
// find the label attribute - this is what the W3C says we should use
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::label, aName);
if (!aName.IsEmpty())
return NS_OK;
return eNameOK;
// CASE #2 -- no label parameter, get the first child,
// use it if it is a text node
nsIContent* text = mContent->GetFirstChild();
if (!text)
return NS_OK;
if (text->IsNodeOfType(nsINode::eTEXT)) {
nsAutoString txtValue;
nsresult rv = nsTextEquivUtils::
AppendTextEquivFromTextContent(text, &txtValue);
NS_ENSURE_SUCCESS(rv, rv);
// Temp var (txtValue) needed until CompressWhitespace built for nsAString
txtValue.CompressWhitespace();
aName.Assign(txtValue);
return NS_OK;
if (text && text->IsNodeOfType(nsINode::eTEXT)) {
nsTextEquivUtils::AppendTextEquivFromTextContent(text, &aName);
aName.CompressWhitespace();
}
return NS_OK;
return eNameOK;
}
uint64_t

Просмотреть файл

@ -84,7 +84,6 @@ public:
NS_IMETHOD SetSelected(bool aSelect);
// Accessible
virtual nsresult GetNameInternal(nsAString& aName);
virtual a11y::role NativeRole();
virtual uint64_t NativeState();
virtual uint64_t NativeInteractiveState() const;
@ -98,6 +97,10 @@ public:
// Widgets
virtual Accessible* ContainerWidget() const;
protected:
// Accessible
virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
private:
/**

Просмотреть файл

@ -385,12 +385,12 @@ HTMLTableAccessible::NativeState()
return Accessible::NativeState() | states::READONLY;
}
nsresult
HTMLTableAccessible::GetNameInternal(nsAString& aName)
ENameValueFlag
HTMLTableAccessible::NativeName(nsString& aName)
{
Accessible::GetNameInternal(aName);
Accessible::NativeName(aName);
if (!aName.IsEmpty())
return NS_OK;
return eNameOK;
// Use table caption as a name.
Accessible* caption = Caption();
@ -399,13 +399,13 @@ HTMLTableAccessible::GetNameInternal(nsAString& aName)
if (captionContent) {
nsTextEquivUtils::AppendTextEquivFromContent(this, captionContent, &aName);
if (!aName.IsEmpty())
return NS_OK;
return eNameOK;
}
}
// If no caption then use summary as a name.
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::summary, aName);
return NS_OK;
return eNameOK;
}
nsresult

Просмотреть файл

@ -143,7 +143,6 @@ public:
// Accessible
virtual TableAccessible* AsTable() { return this; }
virtual void Description(nsString& aDescription);
virtual nsresult GetNameInternal(nsAString& aName);
virtual a11y::role NativeRole();
virtual uint64_t NativeState();
virtual nsresult GetAttributesInternal(nsIPersistentProperties *aAttributes);
@ -163,8 +162,8 @@ public:
nsITableLayout* GetTableLayout();
protected:
// Accessible
virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
virtual void CacheChildren();
// HTMLTableAccessible

Просмотреть файл

@ -264,7 +264,7 @@ __try {
// The name was not provided, e.g. no alt attribute for an image. A screen
// reader may choose to invent its own accessible name, e.g. from an image src
// attribute. Refer to NS_OK_EMPTY_NAME return value.
// attribute. Refer to eNoNameOnPurpose return value.
if (name.IsVoid())
return S_FALSE;

Просмотреть файл

@ -158,11 +158,12 @@ nsXFormsAccessible::NativelyUnavailable() const
return !isRelevant;
}
nsresult
nsXFormsAccessible::GetNameInternal(nsAString& aName)
ENameValueFlag
nsXFormsAccessible::NativeName(nsString& aName)
{
// search the xforms:label element
return GetBoundChildElementValue(NS_LITERAL_STRING("label"), aName);
GetBoundChildElementValue(NS_LITERAL_STRING("label"), aName);
return eNameOK;
}
void

Просмотреть файл

@ -46,9 +46,6 @@ public:
// Returns value of instance node that xforms element is bound to.
virtual void Value(nsString& aValue);
// Returns value of child xforms 'label' element.
virtual nsresult GetNameInternal(nsAString& aName);
// Returns state of xforms element taking into account state of instance node
// that it is bound to.
virtual uint64_t NativeState();
@ -58,7 +55,12 @@ public:
// always returning false value.
virtual bool CanHaveAnonChildren();
protected:
// Accessible
// Returns value of child xforms 'label' element.
virtual mozilla::a11y::ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
// Returns value of first child xforms element by tagname that is bound to
// instance node.
nsresult GetBoundChildElementValue(const nsAString& aTagName,

Просмотреть файл

@ -27,11 +27,11 @@ nsXFormsLabelAccessible::NativeRole()
return roles::LABEL;
}
nsresult
nsXFormsLabelAccessible::GetNameInternal(nsAString& aName)
ENameValueFlag
nsXFormsLabelAccessible::NativeName(nsString& aName)
{
// XXX Correct name calculation for this, see bug 453594.
return NS_OK;
return eNameOK;
}
void

Просмотреть файл

@ -19,8 +19,11 @@ public:
// Accessible
virtual void Description(nsString& aDescription);
virtual nsresult GetNameInternal(nsAString& aName);
virtual mozilla::a11y::role NativeRole();
protected:
// Accessible
virtual mozilla::a11y::ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
};
/**

Просмотреть файл

@ -133,12 +133,12 @@ nsXFormsComboboxPopupWidgetAccessible::NativeInteractiveState() const
return NativelyUnavailable() ? states::UNAVAILABLE : states::FOCUSABLE;
}
nsresult
nsXFormsComboboxPopupWidgetAccessible::GetNameInternal(nsAString& aName)
ENameValueFlag
nsXFormsComboboxPopupWidgetAccessible::NativeName(nsString& aName)
{
// Override nsXFormsAccessible::GetName() to prevent name calculation by
// XForms rules.
return NS_OK;
return eNameOK;
}
void

Просмотреть файл

@ -61,13 +61,13 @@ public:
// Accessible
virtual void Description(nsString& aDescription);
virtual void Value(nsString& aValue);
virtual nsresult GetNameInternal(nsAString& aName);
virtual mozilla::a11y::role NativeRole();
virtual uint64_t NativeState();
virtual uint64_t NativeInteractiveState() const;
protected:
// Accessible
virtual mozilla::a11y::ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
virtual void CacheChildren();
};

Просмотреть файл

@ -32,13 +32,13 @@ XULLabelAccessible::
{
}
nsresult
XULLabelAccessible::GetNameInternal(nsAString& aName)
ENameValueFlag
XULLabelAccessible::NativeName(nsString& aName)
{
// if the value attr doesn't exist, the screen reader must get the accessible text
// from the accessible text interface or from the children
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::value, aName);
return NS_OK;
return eNameOK;
}
role
@ -121,14 +121,14 @@ XULLinkAccessible::Value(nsString& aValue)
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::href, aValue);
}
nsresult
XULLinkAccessible::GetNameInternal(nsAString& aName)
ENameValueFlag
XULLinkAccessible::NativeName(nsString& aName)
{
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::value, aName);
if (!aName.IsEmpty())
return NS_OK;
if (aName.IsEmpty())
nsTextEquivUtils::GetNameFromSubtree(this, aName);
return nsTextEquivUtils::GetNameFromSubtree(this, aName);
return eNameOK;
}
role

Просмотреть файл

@ -21,10 +21,13 @@ public:
XULLabelAccessible(nsIContent* aContent, DocAccessible* aDoc);
// Accessible
virtual nsresult GetNameInternal(nsAString& aName);
virtual a11y::role NativeRole();
virtual uint64_t NativeState();
virtual Relation RelationByType(uint32_t aRelationType);
protected:
// Accessible
virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
};
/**
@ -55,7 +58,6 @@ public:
// Accessible
virtual void Value(nsString& aValue);
virtual nsresult GetNameInternal(nsAString& aName);
virtual a11y::role NativeRole();
virtual uint64_t NativeLinkState() const;
@ -69,6 +71,9 @@ public:
virtual already_AddRefed<nsIURI> AnchorURIAt(uint32_t aAnchorIndex);
protected:
// Accessible
virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
enum { eAction_Jump = 0 };
};

Просмотреть файл

@ -413,16 +413,16 @@ XULGroupboxAccessible::NativeRole()
return roles::GROUPING;
}
nsresult
XULGroupboxAccessible::GetNameInternal(nsAString& aName)
ENameValueFlag
XULGroupboxAccessible::NativeName(nsString& aName)
{
// XXX: we use the first related accessible only.
Accessible* label =
RelationByType(nsIAccessibleRelation::RELATION_LABELLED_BY).Next();
if (label)
return label->GetName(aName);
return label->Name(aName);
return NS_OK;
return eNameOK;
}
Relation
@ -639,16 +639,13 @@ XULToolbarAccessible::NativeRole()
return roles::TOOLBAR;
}
nsresult
XULToolbarAccessible::GetNameInternal(nsAString& aName)
ENameValueFlag
XULToolbarAccessible::NativeName(nsString& aName)
{
nsAutoString name;
if (mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::toolbarname, name)) {
name.CompressWhitespace();
aName = name;
}
if (mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::toolbarname, aName))
aName.CompressWhitespace();
return NS_OK;
return eNameOK;
}

Просмотреть файл

@ -117,8 +117,11 @@ public:
// Accessible
virtual mozilla::a11y::role NativeRole();
virtual nsresult GetNameInternal(nsAString& aName);
virtual Relation RelationByType(uint32_t aRelationType);
protected:
// Accessible
virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
};
/**
@ -194,7 +197,10 @@ public:
// Accessible
virtual mozilla::a11y::role NativeRole();
virtual nsresult GetNameInternal(nsAString& aName);
protected:
// Accessible
virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
};
/**

Просмотреть файл

@ -622,18 +622,20 @@ XULListitemAccessible::Description(nsString& aDesc)
* If there is a Listcell as a child ( not anonymous ) use it, otherwise
* default to getting the name from GetXULName
*/
nsresult
XULListitemAccessible::GetNameInternal(nsAString& aName)
ENameValueFlag
XULListitemAccessible::NativeName(nsString& aName)
{
nsIContent* childContent = mContent->GetFirstChild();
if (childContent) {
if (childContent->NodeInfo()->Equals(nsGkAtoms::listcell,
kNameSpaceID_XUL)) {
childContent->GetAttr(kNameSpaceID_None, nsGkAtoms::label, aName);
return NS_OK;
return eNameOK;
}
}
return GetXULName(aName);
GetXULName(aName);
return eNameOK;
}
role

Просмотреть файл

@ -131,7 +131,6 @@ public:
// Accessible
virtual void Description(nsString& aDesc);
virtual nsresult GetNameInternal(nsAString& aName);
virtual a11y::role NativeRole();
virtual uint64_t NativeState();
virtual uint64_t NativeInteractiveState() const;
@ -141,6 +140,11 @@ public:
virtual Accessible* ContainerWidget() const;
protected:
// Accessible
virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
// XULListitemAccessible
/**
* Return listbox accessible for the listitem.
*/

Просмотреть файл

@ -134,11 +134,11 @@ XULMenuitemAccessible::NativeInteractiveState() const
return states::FOCUSABLE | states::SELECTABLE;
}
nsresult
XULMenuitemAccessible::GetNameInternal(nsAString& aName)
ENameValueFlag
XULMenuitemAccessible::NativeName(nsString& aName)
{
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::label, aName);
return NS_OK;
return eNameOK;
}
void
@ -396,10 +396,10 @@ XULMenuSeparatorAccessible::NativeState()
(states::OFFSCREEN | states::INVISIBLE);
}
nsresult
XULMenuSeparatorAccessible::GetNameInternal(nsAString& aName)
ENameValueFlag
XULMenuSeparatorAccessible::NativeName(nsString& aName)
{
return NS_OK;
return eNameOK;
}
role
@ -469,16 +469,16 @@ XULMenupopupAccessible::NativeState()
return state;
}
nsresult
XULMenupopupAccessible::GetNameInternal(nsAString& aName)
ENameValueFlag
XULMenupopupAccessible::NativeName(nsString& aName)
{
nsIContent *content = mContent;
nsIContent* content = mContent;
while (content && aName.IsEmpty()) {
content->GetAttr(kNameSpaceID_None, nsGkAtoms::label, aName);
content = content->GetParent();
}
return NS_OK;
return eNameOK;
}
role
@ -572,11 +572,11 @@ XULMenubarAccessible::
{
}
nsresult
XULMenubarAccessible::GetNameInternal(nsAString& aName)
ENameValueFlag
XULMenubarAccessible::NativeName(nsString& aName)
{
aName.AssignLiteral("Application");
return NS_OK;
return eNameOK;
}
role

Просмотреть файл

@ -29,7 +29,6 @@ public:
// Accessible
virtual void Description(nsString& aDescription);
virtual nsresult GetNameInternal(nsAString& aName);
virtual a11y::role NativeRole();
virtual uint64_t NativeState();
virtual uint64_t NativeInteractiveState() const;
@ -46,6 +45,10 @@ public:
virtual bool IsActiveWidget() const;
virtual bool AreItemsOperable() const;
virtual Accessible* ContainerWidget() const;
protected:
// Accessible
virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
};
/**
@ -61,12 +64,15 @@ public:
NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
// Accessible
virtual nsresult GetNameInternal(nsAString& aName);
virtual a11y::role NativeRole();
virtual uint64_t NativeState();
// ActionAccessible
virtual uint8_t ActionCount();
protected:
// Accessible
virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
};
@ -79,7 +85,6 @@ public:
XULMenupopupAccessible(nsIContent* aContent, DocAccessible* aDoc);
// Accessible
virtual nsresult GetNameInternal(nsAString& aName);
virtual a11y::role NativeRole();
virtual uint64_t NativeState();
@ -89,6 +94,10 @@ public:
virtual bool AreItemsOperable() const;
virtual Accessible* ContainerWidget() const;
protected:
// Accessible
virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
};
/**
@ -100,7 +109,6 @@ public:
XULMenubarAccessible(nsIContent* aContent, DocAccessible* aDoc);
// Accessible
virtual nsresult GetNameInternal(nsAString& aName);
virtual a11y::role NativeRole();
// Widget
@ -108,6 +116,10 @@ public:
virtual bool AreItemsOperable() const;
virtual Accessible* CurrentItem();
virtual void SetCurrentItem(Accessible* aItem);
protected:
// Accessible
virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
};
} // namespace a11y

Просмотреть файл

@ -154,11 +154,11 @@ XULTabsAccessible::Value(nsString& aValue)
aValue.Truncate();
}
nsresult
XULTabsAccessible::GetNameInternal(nsAString& aName)
ENameValueFlag
XULTabsAccessible::NativeName(nsString& aName)
{
// no name
return NS_OK;
return eNameOK;
}

Просмотреть файл

@ -48,11 +48,14 @@ public:
// Accessible
virtual void Value(nsString& aValue);
virtual nsresult GetNameInternal(nsAString& aName);
virtual a11y::role NativeRole();
// ActionAccessible
virtual uint8_t ActionCount();
protected:
// Accessible
virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
};

Просмотреть файл

@ -3784,13 +3784,6 @@ AC_CHECK_FUNCS(strndup posix_memalign memalign valloc)
dnl See if compiler supports some gcc-style attributes
AC_CACHE_CHECK(for __attribute__((always_inline)),
ac_cv_attribute_always_inline,
[AC_TRY_COMPILE([inline void f(void) __attribute__((always_inline));],
[],
ac_cv_attribute_always_inline=yes,
ac_cv_attribute_always_inline=no)])
AC_CACHE_CHECK(for __attribute__((malloc)),
ac_cv_attribute_malloc,
[AC_TRY_COMPILE([void* f(int) __attribute__((malloc));],
@ -3842,12 +3835,6 @@ dnl are defined in build/autoconf/altoptions.m4.
dnl If the compiler supports these attributes, define them as
dnl convenience macros.
if test "$ac_cv_attribute_always_inline" = yes ; then
AC_DEFINE(NS_ALWAYS_INLINE, [__attribute__((always_inline))])
else
AC_DEFINE(NS_ALWAYS_INLINE,)
fi
if test "$ac_cv_attribute_malloc" = yes ; then
AC_DEFINE(NS_ATTR_MALLOC, [__attribute__((malloc))])
else
@ -7152,6 +7139,8 @@ if test -n "$_WRAP_MALLOC"; then
dnl Wrap operator new and operator delete on Android.
if test "$OS_TARGET" = "Android"; then
WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=_Znwj,--wrap=_Znaj,--wrap=_ZdlPv,--wrap=_ZdaPv"
dnl Wrap the nothrow variants too.
WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=_ZnwjRKSt9nothrow_t,--wrap=_ZnajRKSt9nothrow_t,--wrap=_ZdlPvRKSt9nothrow_t,--wrap=_ZdaPvRKSt9nothrow_t"
fi
else
AC_MSG_ERROR([--enable-wrap-malloc is not supported for non-GNU toolchains])

Просмотреть файл

@ -1295,8 +1295,9 @@ public:
#ifdef DEBUG
static bool AreJSObjectsHeld(void* aScriptObjectHolder);
static void CheckCCWrapperTraversal(nsISupports* aScriptObjectHolder,
nsWrapperCache* aCache);
static void CheckCCWrapperTraversal(void* aScriptObjectHolder,
nsWrapperCache* aCache,
nsScriptObjectTracer* aTracer);
#endif
static void PreserveWrapper(nsISupports* aScriptObjectHolder,
@ -1309,15 +1310,23 @@ public:
MOZ_ASSERT(ccISupports);
nsXPCOMCycleCollectionParticipant* participant;
CallQueryInterface(ccISupports, &participant);
HoldJSObjects(ccISupports, participant);
PreserveWrapper(ccISupports, aCache, participant);
}
}
static void PreserveWrapper(void* aScriptObjectHolder,
nsWrapperCache* aCache,
nsScriptObjectTracer* aTracer)
{
if (!aCache->PreservingWrapper()) {
HoldJSObjects(aScriptObjectHolder, aTracer);
aCache->SetPreservingWrapper(true);
#ifdef DEBUG
// Make sure the cycle collector will be able to traverse to the wrapper.
CheckCCWrapperTraversal(ccISupports, aCache);
CheckCCWrapperTraversal(aScriptObjectHolder, aCache, aTracer);
#endif
}
}
static void ReleaseWrapper(nsISupports* aScriptObjectHolder,
static void ReleaseWrapper(void* aScriptObjectHolder,
nsWrapperCache* aCache);
static void TraceWrapper(nsWrapperCache* aCache, TraceCallback aCallback,
void *aClosure);

Просмотреть файл

@ -278,7 +278,7 @@ public:
NS_ASSERTION(!mListenerManager, "caller must release and disconnect ELM");
}
private:
protected: // declared protected to silence clang warnings
const void *mKey; // must be first, to look like PLDHashEntryStub
public:
@ -6395,26 +6395,24 @@ DebugWrapperTraceCallback(void *p, const char *name, void *closure)
// static
void
nsContentUtils::CheckCCWrapperTraversal(nsISupports* aScriptObjectHolder,
nsWrapperCache* aCache)
nsContentUtils::CheckCCWrapperTraversal(void* aScriptObjectHolder,
nsWrapperCache* aCache,
nsScriptObjectTracer* aTracer)
{
JSObject* wrapper = aCache->GetWrapper();
if (!wrapper) {
return;
}
nsXPCOMCycleCollectionParticipant* participant;
CallQueryInterface(aScriptObjectHolder, &participant);
DebugWrapperTraversalCallback callback(wrapper);
participant->Traverse(aScriptObjectHolder, callback);
aTracer->Traverse(aScriptObjectHolder, callback);
NS_ASSERTION(callback.mFound,
"Cycle collection participant didn't traverse to preserved "
"wrapper! This will probably crash.");
callback.mFound = false;
participant->Trace(aScriptObjectHolder, DebugWrapperTraceCallback, &callback);
aTracer->Trace(aScriptObjectHolder, DebugWrapperTraceCallback, &callback);
NS_ASSERTION(callback.mFound,
"Cycle collection participant didn't trace preserved wrapper! "
"This will probably crash.");
@ -6933,7 +6931,7 @@ nsContentUtils::GetRootDocument(nsIDocument* aDoc)
// static
void
nsContentUtils::ReleaseWrapper(nsISupports* aScriptObjectHolder,
nsContentUtils::ReleaseWrapper(void* aScriptObjectHolder,
nsWrapperCache* aCache)
{
if (aCache->PreservingWrapper()) {

Просмотреть файл

@ -4941,6 +4941,7 @@ NS_IMETHODIMP
nsDocument::GetCharacterSet(nsAString& aCharacterSet)
{
CopyASCIItoUTF16(GetDocumentCharacterSet(), aCharacterSet);
ToLowerCase(aCharacterSet);
return NS_OK;
}
@ -6075,7 +6076,35 @@ nsDocument::GetDocumentURI(nsAString& aDocumentURI)
mDocumentURI->GetSpec(uri);
CopyUTF8toUTF16(uri, aDocumentURI);
} else {
SetDOMStringToNull(aDocumentURI);
aDocumentURI.Truncate();
}
return NS_OK;
}
// Alias of above
NS_IMETHODIMP
nsDocument::GetURL(nsAString& aURL)
{
return GetDocumentURI(aURL);
}
// readonly attribute DOMString compatMode;
// Returns "BackCompat" if we are in quirks mode, "CSS1Compat" if we are
// in almost standards or full standards mode. See bug 105640. This was
// implemented to match MSIE's compatMode property.
NS_IMETHODIMP
nsDocument::GetCompatMode(nsAString& aCompatMode)
{
NS_ASSERTION(mCompatMode == eCompatibility_NavQuirks ||
mCompatMode == eCompatibility_AlmostStandards ||
mCompatMode == eCompatibility_FullStandards,
"mCompatMode is neither quirks nor strict for this document");
if (mCompatMode == eCompatibility_NavQuirks) {
aCompatMode.AssignLiteral("BackCompat");
} else {
aCompatMode.AssignLiteral("CSS1Compat");
}
return NS_OK;

Просмотреть файл

@ -854,8 +854,10 @@ nsObjectLoadingContent::OnStopRequest(nsIRequest *aRequest,
mChannel = nullptr;
if (mFinalListener) {
mFinalListener->OnStopRequest(aRequest, aContext, aStatusCode);
// This may re-enter in the case of plugin listeners
nsCOMPtr<nsIStreamListener> listenerGrip(mFinalListener);
mFinalListener = nullptr;
listenerGrip->OnStopRequest(aRequest, aContext, aStatusCode);
}
// Return value doesn't matter
@ -877,8 +879,10 @@ nsObjectLoadingContent::OnDataAvailable(nsIRequest *aRequest,
}
if (mFinalListener) {
return mFinalListener->OnDataAvailable(aRequest, aContext, aInputStream,
aOffset, aCount);
// This may re-enter in the case of plugin listeners
nsCOMPtr<nsIStreamListener> listenerGrip(mFinalListener);
return listenerGrip->OnDataAvailable(aRequest, aContext, aInputStream,
aOffset, aCount);
}
// We shouldn't have a connected channel with no final listener
@ -1678,10 +1682,10 @@ nsObjectLoadingContent::LoadObject(bool aNotify,
///
/// Attempt to load new type
///
// Remove blocker on entering into instantiate
mIsLoading = false;
// We don't set mFinalListener until OnStartRequest has been called, to
// prevent re-entry ugliness with CloseChannel()
nsCOMPtr<nsIStreamListener> finalListener;
switch (mType) {
case eType_Image:
if (!mChannel) {
@ -1691,14 +1695,8 @@ nsObjectLoadingContent::LoadObject(bool aNotify,
rv = NS_ERROR_UNEXPECTED;
break;
}
rv = LoadImageWithChannel(mChannel, getter_AddRefs(mFinalListener));
if (mFinalListener) {
// Note that LoadObject is called from mChannel's OnStartRequest
// when loading with a channel
mSrcStreamLoading = true;
rv = mFinalListener->OnStartRequest(mChannel, nullptr);
mSrcStreamLoading = false;
}
rv = LoadImageWithChannel(mChannel, getter_AddRefs(finalListener));
// finalListener will receive OnStartRequest below
break;
case eType_Plugin:
{
@ -1725,18 +1723,8 @@ nsObjectLoadingContent::LoadObject(bool aNotify,
}
rv = pluginHost->NewEmbeddedPluginStreamListener(mURI, this, nullptr,
getter_AddRefs(mFinalListener));
if (NS_SUCCEEDED(rv)) {
// Note that LoadObject is called from mChannel's OnStartRequest
// when loading with a channel
mSrcStreamLoading = true;
rv = mFinalListener->OnStartRequest(mChannel, nullptr);
mSrcStreamLoading = false;
if (NS_SUCCEEDED(rv)) {
NotifyContentObjectWrapper();
}
}
getter_AddRefs(finalListener));
// finalListener will receive OnStartRequest below
} else {
rv = AsyncStartPluginInstance();
}
@ -1792,14 +1780,8 @@ nsObjectLoadingContent::LoadObject(bool aNotify,
break;
}
rv = uriLoader->OpenChannel(mChannel, nsIURILoader::DONT_RETARGET, req,
getter_AddRefs(mFinalListener));
if (NS_SUCCEEDED(rv)) {
// Note that LoadObject is called from mChannel's OnStartRequest
// when loading with a channel
mSrcStreamLoading = true;
rv = mFinalListener->OnStartRequest(mChannel, nullptr);
mSrcStreamLoading = false;
}
getter_AddRefs(finalListener));
// finalListener will receive OnStartRequest below
}
break;
case eType_Loading:
@ -1814,13 +1796,16 @@ nsObjectLoadingContent::LoadObject(bool aNotify,
break;
};
//
// Loaded, handle notifications and fallback
//
if (NS_FAILED(rv)) {
// If we failed in the loading hunk above, switch to fallback
LOG(("OBJLC [%p]: Loading failed, switching to fallback", this));
mType = eType_Null;
}
// Switching to fallback state
// If we didn't load anything, handle switching to fallback state
if (mType == eType_Null) {
LOG(("OBJLC [%p]: Loading fallback, type %u", this, fallbackType));
NS_ASSERTION(!mFrameLoader && !mInstanceOwner,
@ -1828,7 +1813,6 @@ nsObjectLoadingContent::LoadObject(bool aNotify,
if (mChannel) {
// If we were loading with a channel but then failed over, throw it away
// (this also closes mFinalListener)
CloseChannel();
}
@ -1839,7 +1823,7 @@ nsObjectLoadingContent::LoadObject(bool aNotify,
// Notify of our final state if we haven't already
NotifyStateChanged(oldType, oldState, false, aNotify);
if (mType == eType_Null && !mContentType.IsEmpty() &&
mFallbackType != eFallbackAlternate) {
// if we have a content type and are not showing alternate
@ -1848,26 +1832,48 @@ nsObjectLoadingContent::LoadObject(bool aNotify,
FirePluginError(mFallbackType);
}
//
// Pass load on to finalListener if loading with a channel
//
// If we re-entered and loaded something else, that load will have cleaned up
// our our listener.
if (!mIsLoading) {
LOG(("OBJLC [%p]: Re-entered before dispatching to final listener", this));
} else if (finalListener) {
NS_ASSERTION(mType != eType_Null && mType != eType_Loading,
"We should not have a final listener with a non-loaded type");
// Note that we always enter into LoadObject() from ::OnStartRequest when
// loading with a channel.
mSrcStreamLoading = true;
// Remove blocker on entering into instantiate
// (this is otherwise unset by the stack class)
mIsLoading = false;
mFinalListener = finalListener;
finalListener->OnStartRequest(mChannel, nullptr);
mSrcStreamLoading = false;
}
return NS_OK;
}
// This call can re-enter when dealing with plugin listeners
nsresult
nsObjectLoadingContent::CloseChannel()
{
if (mChannel) {
LOG(("OBJLC [%p]: Closing channel\n", this));
// These three statements are carefully ordered:
// - onStopRequest should get a channel whose status is the same as the
// status argument
// - onStopRequest must get a non-null channel
mChannel->Cancel(NS_BINDING_ABORTED);
if (mFinalListener) {
// NOTE mFinalListener is only created when we load with a channel, which
// LoadObject() requires come from a OnStartRequest call
mFinalListener->OnStopRequest(mChannel, nullptr, NS_BINDING_ABORTED);
mFinalListener = nullptr;
}
// Null the values before potentially-reentering, and ensure they survive
// the call
nsCOMPtr<nsIChannel> channelGrip(mChannel);
nsCOMPtr<nsIStreamListener> listenerGrip(mFinalListener);
mChannel = nullptr;
mFinalListener = nullptr;
channelGrip->Cancel(NS_BINDING_ABORTED);
if (listenerGrip) {
// mFinalListener is only set by LoadObject after OnStartRequest
listenerGrip->OnStopRequest(channelGrip, nullptr, NS_BINDING_ABORTED);
}
}
return NS_OK;
}
@ -1973,7 +1979,11 @@ nsObjectLoadingContent::UnloadObject(bool aResetState)
}
if (aResetState) {
CloseChannel();
if (mType != eType_Plugin) {
// This can re-enter when dealing with plugins, and StopPluginInstance
// will handle it
CloseChannel();
}
mChannelLoaded = false;
mType = eType_Loading;
mURI = mOriginalURI = mBaseURI = nullptr;

Просмотреть файл

@ -30,7 +30,7 @@ xhr = new XMLHttpRequest();
xhr.open("GET", "file_XHRSendData_doc.xml", false);
xhr.send();
testDoc1 = xhr.responseXML;
is(testDoc1.inputEncoding, "ISO-8859-1", "wrong encoding");
is(testDoc1.inputEncoding, "iso-8859-1", "wrong encoding");
testDoc2 = document.implementation.createDocument("", "", null);
testDoc2.appendChild(testDoc2.createComment(" doc 2 "));
@ -121,17 +121,17 @@ tests = [{ body: null,
},
{ body: testDoc1,
resBody: "<!-- comment -->\n<out>hi</out>",
resContentType: "application/xml; charset=ISO-8859-1",
resContentType: "application/xml; charset=iso-8859-1",
},
{ body: testDoc1,
contentType: "foo/bar",
resBody: "<!-- comment -->\n<out>hi</out>",
resContentType: "foo/bar; charset=ISO-8859-1",
resContentType: "foo/bar; charset=iso-8859-1",
},
{ body: testDoc1,
contentType: "foo/bar; charset=ascii; baz=bin",
resBody: "<!-- comment -->\n<out>hi</out>",
resContentType: "foo/bar; charset=ISO-8859-1; baz=bin",
resContentType: "foo/bar; charset=iso-8859-1; baz=bin",
},
{ body: testDoc1,
contentType: "foo/bar; charset=IsO-8859-1",

Просмотреть файл

@ -62,17 +62,17 @@ function xhrDoc(idx) {
// inputEncoding expected for that document.
var tests = [
[ frameDoc("one"), "ISO-8859-1", "ISO-8859-1" ],
[ frameDoc("two"), "UTF-8", "UTF-8" ],
[ frameDoc("three"), "ISO-8859-1", "ISO-8859-1" ],
[ frameDoc("four"), "UTF-8", "UTF-8" ],
[ frameDoc("five"), "UTF-8", "UTF-8" ],
[ frameDoc("six"), "UTF-8", "UTF-8" ],
[ frameDoc("seven"), "ISO-8859-1", "ISO-8859-1" ],
[ createDoc, "UTF-8", null ],
[ xhrDoc(4), "UTF-8", "UTF-8" ],
[ xhrDoc(5), "UTF-8", "UTF-8" ],
[ xhrDoc(6), "ISO-8859-1", "ISO-8859-1" ],
[ frameDoc("one"), "iso-8859-1", "iso-8859-1" ],
[ frameDoc("two"), "utf-8", "utf-8" ],
[ frameDoc("three"), "iso-8859-1", "iso-8859-1" ],
[ frameDoc("four"), "utf-8", "utf-8" ],
[ frameDoc("five"), "utf-8", "utf-8" ],
[ frameDoc("six"), "utf-8", "utf-8" ],
[ frameDoc("seven"), "iso-8859-1", "iso-8859-1" ],
[ createDoc, "utf-8", null ],
[ xhrDoc(4), "utf-8", "utf-8" ],
[ xhrDoc(5), "utf-8", "utf-8" ],
[ xhrDoc(6), "iso-8859-1", "iso-8859-1" ],
];
function doTest(idx) {

Просмотреть файл

@ -3262,8 +3262,8 @@ nsEventStateManager::PostHandleEvent(nsPresContext* aPresContext,
!nsContentUtils::IsChromeDoc(mDocument)) {
nsCOMPtr<nsIDOMWindow> currentTop;
nsCOMPtr<nsIDOMWindow> newTop;
currentWindow->GetScriptableTop(getter_AddRefs(currentTop));
mDocument->GetWindow()->GetScriptableTop(getter_AddRefs(newTop));
currentWindow->GetTop(getter_AddRefs(currentTop));
mDocument->GetWindow()->GetTop(getter_AddRefs(newTop));
nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(currentWindow);
nsCOMPtr<nsIDocument> currentDoc = do_QueryInterface(win->GetExtantDocument());
if (nsContentUtils::IsChromeDoc(currentDoc) ||

Двоичные данные
content/html/content/test/test_bug615595.html

Двоичный файл не отображается.

Просмотреть файл

@ -1002,20 +1002,6 @@ nsHTMLDocument::SetDomain(const nsAString& aDomain)
return NodePrincipal()->SetDomain(newURI);
}
NS_IMETHODIMP
nsHTMLDocument::GetURL(nsAString& aURL)
{
nsAutoCString str;
if (mDocumentURI) {
mDocumentURI->GetSpec(str);
}
CopyUTF8toUTF16(str, aURL);
return NS_OK;
}
nsIContent*
nsHTMLDocument::GetBody()
{
@ -2046,27 +2032,6 @@ nsHTMLDocument::RouteEvent(nsIDOMEvent* aEvt)
return NS_OK;
}
// readonly attribute DOMString compatMode;
// Returns "BackCompat" if we are in quirks mode, "CSS1Compat" if we are
// in almost standards or full standards mode. See bug 105640. This was
// implemented to match MSIE's compatMode property
NS_IMETHODIMP
nsHTMLDocument::GetCompatMode(nsAString& aCompatMode)
{
NS_ASSERTION(mCompatMode == eCompatibility_NavQuirks ||
mCompatMode == eCompatibility_AlmostStandards ||
mCompatMode == eCompatibility_FullStandards,
"mCompatMode is neither quirks nor strict for this document");
if (mCompatMode == eCompatibility_NavQuirks) {
aCompatMode.AssignLiteral("BackCompat");
} else {
aCompatMode.AssignLiteral("CSS1Compat");
}
return NS_OK;
}
// Mapped to document.embeds for NS4 compatibility
NS_IMETHODIMP
nsHTMLDocument::GetPlugins(nsIDOMHTMLCollection** aPlugins)

Просмотреть файл

@ -25,7 +25,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=255820
/** Test for Bug 255820 **/
SimpleTest.waitForExplicitFinish();
is(document.characterSet, "UTF-8",
is(document.characterSet, "utf-8",
"Unexpected character set for our document");
var testsLeft = 4;
@ -63,26 +63,26 @@ function f3Continue() {
'is(doc.defaultView.getComputedStyle(doc.body, "").color, ' +
' "rgb(0, 180, 0)",' +
' "Wrong color after reload");' +
"charsetTestFinished('f1', this.contentDocument, 'UTF-8')");
"charsetTestFinished('f1', this.contentDocument, 'utf-8')");
$("f3").contentWindow.location.reload();
}
function runTest() {
var doc = $("f1").contentDocument;
is(doc.characterSet, "UTF-8",
is(doc.characterSet, "utf-8",
"Unexpected initial character set for first frame");
doc.open();
doc.write('<html></html>');
doc.close();
is(doc.characterSet, "UTF-8",
is(doc.characterSet, "utf-8",
"Unexpected character set for first frame after write");
$("f1").
setAttribute("onload",
"charsetTestFinished('f1', this.contentDocument, 'UTF-8')");
"charsetTestFinished('f1', this.contentDocument, 'utf-8')");
$("f1").contentWindow.location.reload();
doc = $("f2").contentDocument;
is(doc.characterSet, "UTF-8",
is(doc.characterSet, "utf-8",
"Unexpected initial character set for second frame");
doc.open();
var str = '<html><head>';
@ -92,15 +92,15 @@ function runTest() {
str += '</body></html>';
doc.write(str);
doc.close();
is(doc.characterSet, "UTF-8",
is(doc.characterSet, "utf-8",
"Unexpected character set for second frame after write");
$("f2").
setAttribute("onload",
"charsetTestFinished('f2', this.contentDocument, 'UTF-8');" +
"charsetTestFinished('f2', this.contentDocument, 'utf-8');" +
"f2Continue()");
doc = $("f3").contentDocument;
is(doc.characterSet, "UTF-8",
is(doc.characterSet, "utf-8",
"Unexpected initial character set for first frame");
doc.open();
var str = '<html><head>';
@ -110,7 +110,7 @@ function runTest() {
str += '</body></html>';
doc.write(str);
doc.close();
is(doc.characterSet, "UTF-8",
is(doc.characterSet, "utf-8",
"Unexpected character set for first frame after write");
$("f3").setAttribute("onload", "f3Continue()");
}

Просмотреть файл

@ -21,11 +21,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=380383
<pre id="test">
<script class="testbody" type="text/javascript">
/** Test for Bug 380383 **/
is($("f1").contentDocument.characterSet, "UTF-8",
is($("f1").contentDocument.characterSet, "utf-8",
"Unexpected charset for f1");
function runTest() {
is($("f2").contentDocument.characterSet, "UTF-8",
is($("f2").contentDocument.characterSet, "utf-8",
"Unexpected charset for f2");
}

Просмотреть файл

@ -24,7 +24,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(AudioBuffer)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(AudioBuffer)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mContext)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NATIVE_MEMBER(mContext, AudioContext)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END

Просмотреть файл

@ -16,13 +16,22 @@
namespace mozilla {
namespace dom {
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_2(AudioContext, mWindow, mDestination)
NS_IMPL_CYCLE_COLLECTING_ADDREF(AudioContext)
NS_IMPL_CYCLE_COLLECTING_RELEASE(AudioContext)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(AudioContext)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTION_CLASS(AudioContext)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_NATIVE(AudioContext)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mWindow)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mDestination)
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER_NATIVE
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NATIVE_BEGIN(AudioContext)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mWindow)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mDestination)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_TRACE_NATIVE_BEGIN(AudioContext)
NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER
NS_IMPL_CYCLE_COLLECTION_TRACE_END
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(AudioContext, AddRef)
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(AudioContext, Release)
AudioContext::AudioContext(nsIDOMWindow* aWindow)
: mWindow(aWindow)

Просмотреть файл

@ -26,8 +26,7 @@ class AudioDestinationNode;
class AudioBufferSourceNode;
class AudioBuffer;
class AudioContext MOZ_FINAL : public nsISupports,
public nsWrapperCache,
class AudioContext MOZ_FINAL : public nsWrapperCache,
public EnableWebAudioCheck
{
explicit AudioContext(nsIDOMWindow* aParentWindow);
@ -35,8 +34,8 @@ class AudioContext MOZ_FINAL : public nsISupports,
public:
virtual ~AudioContext();
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(AudioContext)
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(AudioContext)
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(AudioContext)
nsIDOMWindow* GetParentObject() const
{

Просмотреть файл

@ -35,7 +35,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(AudioNode)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(AudioNode)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mContext)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NATIVE_MEMBER(mContext, AudioContext)
TraverseElements(cb, tmp->mInputs, "mInputs[i]");
TraverseElements(cb, tmp->mOutputs, "mOutputs[i]");
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS

Просмотреть файл

@ -58,23 +58,6 @@ nsSVGDocument::GetDomain(nsAString& aDomain)
return NS_OK;
}
/* readonly attribute DOMString URL; */
NS_IMETHODIMP
nsSVGDocument::GetURL(nsAString& aURL)
{
SetDOMStringToNull(aURL);
if (mDocumentURI) {
nsAutoCString url;
nsresult rv = mDocumentURI->GetSpec(url);
if (url.IsEmpty() || NS_FAILED(rv))
return rv;
CopyUTF8toUTF16(url, aURL);
}
return NS_OK;
}
/* readonly attribute SVGSVGElement rootElement; */
NS_IMETHODIMP
nsSVGDocument::GetRootElement(nsIDOMSVGSVGElement** aRootElement)

Просмотреть файл

@ -36,7 +36,7 @@ using namespace mozilla;
static nsINativeKeyBindings *sNativeEditorBindings = nullptr;
class nsXBLSpecialDocInfo
class nsXBLSpecialDocInfo : public nsIObserver
{
public:
nsRefPtr<nsXBLDocumentInfo> mHTMLBindings;
@ -48,6 +48,9 @@ public:
bool mInitialized;
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIOBSERVER
void LoadDocInfo();
void GetAllHandlers(const char* aType,
nsXBLPrototypeHandler** handler,
@ -57,16 +60,38 @@ public:
nsXBLPrototypeHandler** aResult);
nsXBLSpecialDocInfo() : mInitialized(false) {}
virtual ~nsXBLSpecialDocInfo() {}
};
const char nsXBLSpecialDocInfo::sHTMLBindingStr[] =
"chrome://global/content/platformHTMLBindings.xml";
NS_IMPL_ISUPPORTS1(nsXBLSpecialDocInfo, nsIObserver)
NS_IMETHODIMP
nsXBLSpecialDocInfo::Observe(nsISupports* aSubject,
const char* aTopic,
const PRUnichar* aData)
{
MOZ_ASSERT(!strcmp(aTopic, "xpcom-shutdown"), "wrong topic");
// On shutdown, clear our fields to avoid an extra cycle collection.
mHTMLBindings = nullptr;
mUserHTMLBindings = nullptr;
mInitialized = false;
nsContentUtils::UnregisterShutdownObserver(this);
return NS_OK;
}
void nsXBLSpecialDocInfo::LoadDocInfo()
{
if (mInitialized)
return;
mInitialized = true;
nsContentUtils::RegisterShutdownObserver(this);
nsXBLService* xblService = nsXBLService::GetInstance();
if (!xblService)
@ -155,8 +180,7 @@ nsXBLWindowKeyHandler::~nsXBLWindowKeyHandler()
--sRefCnt;
if (!sRefCnt) {
delete sXBLSpecialDocInfo;
sXBLSpecialDocInfo = nullptr;
NS_IF_RELEASE(sXBLSpecialDocInfo);
}
}
@ -221,13 +245,9 @@ nsXBLWindowKeyHandler::EnsureHandlers(bool *aIsEditor)
nsCOMPtr<nsIContent> content(do_QueryInterface(el));
BuildHandlerChain(content, &mHandler);
} else { // We are an XBL file of handlers.
if (!sXBLSpecialDocInfo)
sXBLSpecialDocInfo = new nsXBLSpecialDocInfo();
if (!sXBLSpecialDocInfo) {
if (aIsEditor) {
*aIsEditor = false;
}
return NS_ERROR_OUT_OF_MEMORY;
sXBLSpecialDocInfo = new nsXBLSpecialDocInfo();
NS_ADDREF(sXBLSpecialDocInfo);
}
sXBLSpecialDocInfo->LoadDocInfo();

Просмотреть файл

@ -226,6 +226,9 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsWrapperCache, NS_WRAPPERCACHE_IID)
#define NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER \
nsContentUtils::ReleaseWrapper(s, tmp);
#define NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER_NATIVE \
nsContentUtils::ReleaseWrapper(tmp, tmp);
#define NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(_class) \
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(_class) \
NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER \

Просмотреть файл

@ -8,6 +8,7 @@
#include "BindingUtils.h"
#include "AccessCheck.h"
#include "WrapperFactory.h"
#include "xpcprivate.h"
#include "XPCQuickStubs.h"
@ -140,8 +141,8 @@ static JSObject*
CreateInterfaceObject(JSContext* cx, JSObject* global, JSObject* receiver,
JSClass* constructorClass, JSNative constructorNative,
unsigned ctorNargs, JSObject* proto,
Prefable<JSFunctionSpec>* staticMethods,
Prefable<ConstantSpec>* constants,
const NativeProperties* properties,
const NativeProperties* chromeOnlyProperties,
const char* name)
{
JSObject* constructor;
@ -164,10 +165,6 @@ CreateInterfaceObject(JSContext* cx, JSObject* global, JSObject* receiver,
return NULL;
}
if (staticMethods && !DefinePrefable(cx, constructor, staticMethods)) {
return NULL;
}
if (constructorClass) {
JSFunction* toString = js::DefineFunctionWithReserved(cx, constructor,
"toString",
@ -189,8 +186,28 @@ CreateInterfaceObject(JSContext* cx, JSObject* global, JSObject* receiver,
STRING_TO_JSVAL(str));
}
if (constants && !DefinePrefable(cx, constructor, constants)) {
return NULL;
if (properties) {
if (properties->staticMethods &&
!DefinePrefable(cx, constructor, properties->staticMethods)) {
return nullptr;
}
if (properties->constants &&
!DefinePrefable(cx, constructor, properties->constants)) {
return nullptr;
}
}
if (chromeOnlyProperties) {
if (chromeOnlyProperties->staticMethods &&
!DefinePrefable(cx, constructor, chromeOnlyProperties->staticMethods)) {
return nullptr;
}
if (chromeOnlyProperties->constants &&
!DefinePrefable(cx, constructor, chromeOnlyProperties->constants)) {
return nullptr;
}
}
if (proto && !JS_LinkConstructorAndPrototype(cx, constructor, proto)) {
@ -215,9 +232,8 @@ CreateInterfaceObject(JSContext* cx, JSObject* global, JSObject* receiver,
static JSObject*
CreateInterfacePrototypeObject(JSContext* cx, JSObject* global,
JSObject* parentProto, JSClass* protoClass,
Prefable<JSFunctionSpec>* methods,
Prefable<JSPropertySpec>* properties,
Prefable<ConstantSpec>* constants)
const NativeProperties* properties,
const NativeProperties* chromeOnlyProperties)
{
JSObject* ourProto = JS_NewObjectWithUniqueType(cx, protoClass, parentProto,
global);
@ -225,16 +241,38 @@ CreateInterfacePrototypeObject(JSContext* cx, JSObject* global,
return NULL;
}
if (methods && !DefinePrefable(cx, ourProto, methods)) {
return NULL;
if (properties) {
if (properties->methods &&
!DefinePrefable(cx, ourProto, properties->methods)) {
return nullptr;
}
if (properties->attributes &&
!DefinePrefable(cx, ourProto, properties->attributes)) {
return nullptr;
}
if (properties->constants &&
!DefinePrefable(cx, ourProto, properties->constants)) {
return nullptr;
}
}
if (properties && !DefinePrefable(cx, ourProto, properties)) {
return NULL;
}
if (chromeOnlyProperties) {
if (chromeOnlyProperties->methods &&
!DefinePrefable(cx, ourProto, chromeOnlyProperties->methods)) {
return nullptr;
}
if (constants && !DefinePrefable(cx, ourProto, constants)) {
return NULL;
if (chromeOnlyProperties->attributes &&
!DefinePrefable(cx, ourProto, chromeOnlyProperties->attributes)) {
return nullptr;
}
if (chromeOnlyProperties->constants &&
!DefinePrefable(cx, ourProto, chromeOnlyProperties->constants)) {
return nullptr;
}
}
return ourProto;
@ -245,16 +283,21 @@ CreateInterfaceObjects(JSContext* cx, JSObject* global, JSObject *receiver,
JSObject* protoProto, JSClass* protoClass,
JSClass* constructorClass, JSNative constructor,
unsigned ctorNargs, const DOMClass* domClass,
Prefable<JSFunctionSpec>* methods,
Prefable<JSPropertySpec>* properties,
Prefable<ConstantSpec>* constants,
Prefable<JSFunctionSpec>* staticMethods, const char* name)
const NativeProperties* properties,
const NativeProperties* chromeOnlyProperties,
const char* name)
{
MOZ_ASSERT(protoClass || constructorClass || constructor,
"Need at least one class or a constructor!");
MOZ_ASSERT(!(methods || properties) || protoClass,
MOZ_ASSERT(!((properties &&
(properties->methods || properties->attributes)) ||
(chromeOnlyProperties &&
(chromeOnlyProperties->methods ||
chromeOnlyProperties->attributes))) || protoClass,
"Methods or properties but no protoClass!");
MOZ_ASSERT(!staticMethods || constructorClass || constructor,
MOZ_ASSERT(!((properties && properties->staticMethods) ||
(chromeOnlyProperties && chromeOnlyProperties->staticMethods)) ||
constructorClass || constructor,
"Static methods but no constructorClass or constructor!");
MOZ_ASSERT(bool(name) == bool(constructorClass || constructor),
"Must have name precisely when we have an interface object");
@ -263,7 +306,7 @@ CreateInterfaceObjects(JSContext* cx, JSObject* global, JSObject *receiver,
JSObject* proto;
if (protoClass) {
proto = CreateInterfacePrototypeObject(cx, global, protoProto, protoClass,
methods, properties, constants);
properties, chromeOnlyProperties);
if (!proto) {
return NULL;
}
@ -279,7 +322,7 @@ CreateInterfaceObjects(JSContext* cx, JSObject* global, JSObject *receiver,
if (constructorClass || constructor) {
interface = CreateInterfaceObject(cx, global, receiver, constructorClass,
constructor, ctorNargs, proto,
staticMethods, constants, name);
properties, chromeOnlyProperties, name);
if (!interface) {
return NULL;
}
@ -420,104 +463,100 @@ ThrowingConstructor(JSContext* cx, unsigned argc, JS::Value* vp)
return ThrowErrorMessage(cx, MSG_ILLEGAL_CONSTRUCTOR);
}
bool
static bool
XrayResolveProperty(JSContext* cx, JSObject* wrapper, jsid id,
JSPropertyDescriptor* desc,
// And the things we need to determine the descriptor
Prefable<JSFunctionSpec>* methods,
jsid* methodIds,
JSFunctionSpec* methodSpecs,
size_t methodCount,
Prefable<JSPropertySpec>* attributes,
jsid* attributeIds,
JSPropertySpec* attributeSpecs,
size_t attributeCount,
Prefable<ConstantSpec>* constants,
jsid* constantIds,
ConstantSpec* constantSpecs,
size_t constantCount)
const NativeProperties* nativeProperties)
{
for (size_t prefIdx = 0; prefIdx < methodCount; ++prefIdx) {
MOZ_ASSERT(methods[prefIdx].specs);
if (methods[prefIdx].enabled) {
// Set i to be the index into our full list of ids/specs that we're
// looking at now.
size_t i = methods[prefIdx].specs - methodSpecs;
for ( ; methodIds[i] != JSID_VOID; ++i) {
if (id == methodIds[i]) {
JSFunction *fun = JS_NewFunctionById(cx, methodSpecs[i].call.op,
methodSpecs[i].nargs, 0,
wrapper, id);
if (!fun) {
return false;
if (nativeProperties->methods) {
Prefable<JSFunctionSpec>* method;
for (method = nativeProperties->methods; method->specs; ++method) {
if (method->enabled) {
// Set i to be the index into our full list of ids/specs that we're
// looking at now.
size_t i = method->specs - nativeProperties->methodsSpecs;
for ( ; nativeProperties->methodIds[i] != JSID_VOID; ++i) {
if (id == nativeProperties->methodIds[i]) {
JSFunctionSpec& methodSpec = nativeProperties->methodsSpecs[i];
JSFunction *fun = JS_NewFunctionById(cx, methodSpec.call.op,
methodSpec.nargs, 0,
wrapper, id);
if (!fun) {
return false;
}
SET_JITINFO(fun, methodSpec.call.info);
JSObject *funobj = JS_GetFunctionObject(fun);
desc->value.setObject(*funobj);
desc->attrs = methodSpec.flags;
desc->obj = wrapper;
desc->setter = nullptr;
desc->getter = nullptr;
return true;
}
SET_JITINFO(fun, methodSpecs[i].call.info);
JSObject *funobj = JS_GetFunctionObject(fun);
desc->value.setObject(*funobj);
desc->attrs = methodSpecs[i].flags;
desc->obj = wrapper;
desc->setter = nullptr;
desc->getter = nullptr;
return true;
}
}
}
}
for (size_t prefIdx = 0; prefIdx < attributeCount; ++prefIdx) {
MOZ_ASSERT(attributes[prefIdx].specs);
if (attributes[prefIdx].enabled) {
// Set i to be the index into our full list of ids/specs that we're
// looking at now.
size_t i = attributes[prefIdx].specs - attributeSpecs;
for ( ; attributeIds[i] != JSID_VOID; ++i) {
if (id == attributeIds[i]) {
// Because of centralization, we need to make sure we fault in the
// JitInfos as well. At present, until the JSAPI changes, the easiest
// way to do this is wrap them up as functions ourselves.
desc->attrs = attributeSpecs[i].flags & ~JSPROP_NATIVE_ACCESSORS;
// They all have getters, so we can just make it.
JSObject *global = JS_GetGlobalForObject(cx, wrapper);
JSFunction *fun = JS_NewFunction(cx, (JSNative)attributeSpecs[i].getter.op,
0, 0, global, NULL);
if (!fun)
return false;
SET_JITINFO(fun, attributeSpecs[i].getter.info);
JSObject *funobj = JS_GetFunctionObject(fun);
desc->getter = js::CastAsJSPropertyOp(funobj);
desc->attrs |= JSPROP_GETTER;
if (attributeSpecs[i].setter.op) {
// We have a setter! Make it.
fun = JS_NewFunction(cx, (JSNative)attributeSpecs[i].setter.op,
1, 0, global, NULL);
if (nativeProperties->attributes) {
Prefable<JSPropertySpec>* attr;
for (attr = nativeProperties->attributes; attr->specs; ++attr) {
if (attr->enabled) {
// Set i to be the index into our full list of ids/specs that we're
// looking at now.
size_t i = attr->specs - nativeProperties->attributeSpecs;
for ( ; nativeProperties->attributeIds[i] != JSID_VOID; ++i) {
if (id == nativeProperties->attributeIds[i]) {
JSPropertySpec& attrSpec = nativeProperties->attributeSpecs[i];
// Because of centralization, we need to make sure we fault in the
// JitInfos as well. At present, until the JSAPI changes, the easiest
// way to do this is wrap them up as functions ourselves.
desc->attrs = attrSpec.flags & ~JSPROP_NATIVE_ACCESSORS;
// They all have getters, so we can just make it.
JSObject *global = JS_GetGlobalForObject(cx, wrapper);
JSFunction *fun = JS_NewFunction(cx, (JSNative)attrSpec.getter.op,
0, 0, global, nullptr);
if (!fun)
return false;
SET_JITINFO(fun, attributeSpecs[i].setter.info);
funobj = JS_GetFunctionObject(fun);
desc->setter = js::CastAsJSStrictPropertyOp(funobj);
desc->attrs |= JSPROP_SETTER;
} else {
desc->setter = NULL;
SET_JITINFO(fun, attrSpec.getter.info);
JSObject *funobj = JS_GetFunctionObject(fun);
desc->getter = js::CastAsJSPropertyOp(funobj);
desc->attrs |= JSPROP_GETTER;
if (attrSpec.setter.op) {
// We have a setter! Make it.
fun = JS_NewFunction(cx, (JSNative)attrSpec.setter.op, 1, 0,
global, nullptr);
if (!fun)
return false;
SET_JITINFO(fun, attrSpec.setter.info);
funobj = JS_GetFunctionObject(fun);
desc->setter = js::CastAsJSStrictPropertyOp(funobj);
desc->attrs |= JSPROP_SETTER;
} else {
desc->setter = nullptr;
}
desc->obj = wrapper;
return true;
}
desc->obj = wrapper;
return true;
}
}
}
}
for (size_t prefIdx = 0; prefIdx < constantCount; ++prefIdx) {
MOZ_ASSERT(constants[prefIdx].specs);
if (constants[prefIdx].enabled) {
// Set i to be the index into our full list of ids/specs that we're
// looking at now.
size_t i = constants[prefIdx].specs - constantSpecs;
for ( ; constantIds[i] != JSID_VOID; ++i) {
if (id == constantIds[i]) {
desc->attrs = JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT;
desc->obj = wrapper;
desc->value = constantSpecs[i].value;
return true;
if (nativeProperties->constants) {
Prefable<ConstantSpec>* constant;
for (constant = nativeProperties->constants; constant->specs; ++constant) {
if (constant->enabled) {
// Set i to be the index into our full list of ids/specs that we're
// looking at now.
size_t i = constant->specs - nativeProperties->constantSpecs;
for ( ; nativeProperties->constantIds[i] != JSID_VOID; ++i) {
if (id == nativeProperties->constantIds[i]) {
desc->attrs = JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT;
desc->obj = wrapper;
desc->value = nativeProperties->constantSpecs[i].value;
return true;
}
}
}
}
@ -527,59 +566,75 @@ XrayResolveProperty(JSContext* cx, JSObject* wrapper, jsid id,
}
bool
XrayEnumerateProperties(JS::AutoIdVector& props,
Prefable<JSFunctionSpec>* methods,
jsid* methodIds,
JSFunctionSpec* methodSpecs,
size_t methodCount,
Prefable<JSPropertySpec>* attributes,
jsid* attributeIds,
JSPropertySpec* attributeSpecs,
size_t attributeCount,
Prefable<ConstantSpec>* constants,
jsid* constantIds,
ConstantSpec* constantSpecs,
size_t constantCount)
XrayResolveProperty(JSContext* cx, JSObject* wrapper, jsid id,
JSPropertyDescriptor* desc,
const NativeProperties* nativeProperties,
const NativeProperties* chromeOnlyNativeProperties)
{
for (size_t prefIdx = 0; prefIdx < methodCount; ++prefIdx) {
MOZ_ASSERT(methods[prefIdx].specs);
if (methods[prefIdx].enabled) {
// Set i to be the index into our full list of ids/specs that we're
// looking at now.
size_t i = methods[prefIdx].specs - methodSpecs;
for ( ; methodIds[i] != JSID_VOID; ++i) {
if ((methodSpecs[i].flags & JSPROP_ENUMERATE) &&
!props.append(methodIds[i])) {
return false;
if (nativeProperties &&
!XrayResolveProperty(cx, wrapper, id, desc, nativeProperties)) {
return false;
}
if (!desc->obj &&
chromeOnlyNativeProperties &&
xpc::AccessCheck::isChrome(js::GetObjectCompartment(wrapper)) &&
!XrayResolveProperty(cx, wrapper, id, desc, chromeOnlyNativeProperties)) {
return false;
}
return true;
}
bool
XrayEnumerateProperties(JS::AutoIdVector& props,
const NativeProperties* nativeProperties)
{
if (nativeProperties->methods) {
Prefable<JSFunctionSpec>* method;
for (method = nativeProperties->methods; method->specs; ++method) {
if (method->enabled) {
// Set i to be the index into our full list of ids/specs that we're
// looking at now.
size_t i = method->specs - nativeProperties->methodsSpecs;
for ( ; nativeProperties->methodIds[i] != JSID_VOID; ++i) {
if ((nativeProperties->methodsSpecs[i].flags & JSPROP_ENUMERATE) &&
!props.append(nativeProperties->methodIds[i])) {
return false;
}
}
}
}
}
for (size_t prefIdx = 0; prefIdx < attributeCount; ++prefIdx) {
MOZ_ASSERT(attributes[prefIdx].specs);
if (attributes[prefIdx].enabled) {
// Set i to be the index into our full list of ids/specs that we're
// looking at now.
size_t i = attributes[prefIdx].specs - attributeSpecs;
for ( ; attributeIds[i] != JSID_VOID; ++i) {
if ((attributeSpecs[i].flags & JSPROP_ENUMERATE) &&
!props.append(attributeIds[i])) {
return false;
if (nativeProperties->attributes) {
Prefable<JSPropertySpec>* attr;
for (attr = nativeProperties->attributes; attr->specs; ++attr) {
if (attr->enabled) {
// Set i to be the index into our full list of ids/specs that we're
// looking at now.
size_t i = attr->specs - nativeProperties->attributeSpecs;
for ( ; nativeProperties->attributeIds[i] != JSID_VOID; ++i) {
if ((nativeProperties->attributeSpecs[i].flags & JSPROP_ENUMERATE) &&
!props.append(nativeProperties->attributeIds[i])) {
return false;
}
}
}
}
}
for (size_t prefIdx = 0; prefIdx < constantCount; ++prefIdx) {
MOZ_ASSERT(constants[prefIdx].specs);
if (constants[prefIdx].enabled) {
// Set i to be the index into our full list of ids/specs that we're
// looking at now.
size_t i = constants[prefIdx].specs - constantSpecs;
for ( ; constantIds[i] != JSID_VOID; ++i) {
if (!props.append(constantIds[i])) {
return false;
if (nativeProperties->constants) {
Prefable<ConstantSpec>* constant;
for (constant = nativeProperties->constants; constant->specs; ++constant) {
if (constant->enabled) {
// Set i to be the index into our full list of ids/specs that we're
// looking at now.
size_t i = constant->specs - nativeProperties->constantSpecs;
for ( ; nativeProperties->constantIds[i] != JSID_VOID; ++i) {
if (!props.append(nativeProperties->constantIds[i])) {
return false;
}
}
}
}
@ -588,6 +643,26 @@ XrayEnumerateProperties(JS::AutoIdVector& props,
return true;
}
bool
XrayEnumerateProperties(JSObject* wrapper,
JS::AutoIdVector& props,
const NativeProperties* nativeProperties,
const NativeProperties* chromeOnlyNativeProperties)
{
if (nativeProperties &&
!XrayEnumerateProperties(props, nativeProperties)) {
return false;
}
if (chromeOnlyNativeProperties &&
xpc::AccessCheck::isChrome(js::GetObjectCompartment(wrapper)) &&
!XrayEnumerateProperties(props, chromeOnlyNativeProperties)) {
return false;
}
return true;
}
bool
GetPropertyOnPrototype(JSContext* cx, JSObject* proxy, jsid id, bool* found,
JS::Value* vp)

Просмотреть файл

@ -344,6 +344,22 @@ struct Prefable {
T* specs;
};
struct NativeProperties
{
Prefable<JSFunctionSpec>* staticMethods;
jsid* staticMethodIds;
JSFunctionSpec* staticMethodsSpecs;
Prefable<JSFunctionSpec>* methods;
jsid* methodIds;
JSFunctionSpec* methodsSpecs;
Prefable<JSPropertySpec>* attributes;
jsid* attributeIds;
JSPropertySpec* attributeSpecs;
Prefable<ConstantSpec>* constants;
jsid* constantIds;
ConstantSpec* constantSpecs;
};
/*
* Create a DOM interface object (if constructorClass is non-null) and/or a
* DOM interface prototype object (if protoClass is non-null).
@ -365,15 +381,14 @@ struct Prefable {
* object of constructorClass, unless that's also null, in which
* case we should not create an interface object at all.
* ctorNargs is the length of the constructor function; 0 if no constructor
* instanceClass is the JSClass of instance objects for this class. This can
* be null if this is not a concrete proto.
* methods and properties are to be defined on the interface prototype object;
* these arguments are allowed to be null if there are no
* methods or properties respectively.
* constants are to be defined on the interface object and on the interface
* prototype object; allowed to be null if there are no constants.
* staticMethods are to be defined on the interface object; allowed to be null
* if there are no static methods.
* domClass is the DOMClass of instance objects for this class. This can be
* null if this is not a concrete proto.
* properties contains the methods, attributes and constants to be defined on
* objects in any compartment.
* chromeProperties contains the methods, attributes and constants to be defined
* on objects in chrome compartments. This must be null if the
* interface doesn't have any ChromeOnly properties or if the
* object is being created in non-chrome compartment.
*
* At least one of protoClass and constructorClass should be non-null.
* If constructorClass is non-null, the resulting interface object will be
@ -388,10 +403,9 @@ CreateInterfaceObjects(JSContext* cx, JSObject* global, JSObject* receiver,
JSObject* protoProto, JSClass* protoClass,
JSClass* constructorClass, JSNative constructor,
unsigned ctorNargs, const DOMClass* domClass,
Prefable<JSFunctionSpec>* methods,
Prefable<JSPropertySpec>* properties,
Prefable<ConstantSpec>* constants,
Prefable<JSFunctionSpec>* staticMethods, const char* name);
const NativeProperties* properties,
const NativeProperties* chromeProperties,
const char* name);
template <class T>
inline bool
@ -621,16 +635,16 @@ GetWrapperCache(const ParentObject& aParentObject)
}
template<class T>
inline nsISupports*
inline T*
GetParentPointer(T* aObject)
{
return ToSupports(aObject);
return aObject;
}
inline nsISupports*
GetParentPointer(const ParentObject& aObject)
{
return ToSupports(aObject.mObject);
return aObject.mObject;
}
template<class T>
@ -729,32 +743,89 @@ bool
WrapCallbackInterface(JSContext *cx, JSObject *scope, nsISupports* callback,
JS::Value* vp);
// This checks whether class T implements WrapObject itself, if so then
// HasWrapObject<T>::Value will be true. Note that if T inherits WrapObject from
// a base class but doesn't override it then HasWrapObject<T>::Value will be
// false. This is a little annoying in some cases (multiple C++ classes using
// the same binding), but it saves us in the case where a class inherits from
// nsWrapperCache but doesn't actually override WrapObject. For now we assume
// that HasWrapObject<T>::Value being false means we have an nsISupports object.
template<typename T>
struct HasWrapObject
{
private:
typedef char yes[1];
typedef char no[2];
typedef JSObject* (T::*WrapObject)(JSContext*, JSObject*, bool*);
template<typename U, U> struct SFINAE;
template <typename V> static yes& Check(SFINAE<WrapObject, &V::WrapObject>*);
template <typename V> static no& Check(...);
public:
static bool const Value = sizeof(Check<T>(nullptr)) == sizeof(yes);
};
template<typename T, bool hasWrapObject=HasWrapObject<T>::Value >
struct WrapNativeParentHelper
{
static inline JSObject* Wrap(JSContext* cx, JSObject* scope, T* parent,
nsWrapperCache* cache)
{
MOZ_ASSERT(cache);
JSObject* obj;
if ((obj = cache->GetWrapper())) {
return obj;
}
bool triedToWrap;
return parent->WrapObject(cx, scope, &triedToWrap);
}
};
template<typename T>
struct WrapNativeParentHelper<T, false>
{
static inline JSObject* Wrap(JSContext* cx, JSObject* scope, T* parent,
nsWrapperCache* cache)
{
JSObject* obj;
if (cache && (obj = cache->GetWrapper())) {
#ifdef DEBUG
qsObjectHelper helper(ToSupports(parent), cache);
JS::Value debugVal;
bool ok = XPCOMObjectToJsval(cx, scope, helper, NULL, false, &debugVal);
NS_ASSERTION(ok && JSVAL_TO_OBJECT(debugVal) == obj,
"Unexpected object in nsWrapperCache");
#endif
return obj;
}
qsObjectHelper helper(ToSupports(parent), cache);
JS::Value v;
return XPCOMObjectToJsval(cx, scope, helper, NULL, false, &v) ?
JSVAL_TO_OBJECT(v) :
NULL;
}
};
template<typename T>
static inline JSObject*
WrapNativeParent(JSContext* cx, JSObject* scope, T* p, nsWrapperCache* cache)
{
if (!p) {
return scope;
}
return WrapNativeParentHelper<T>::Wrap(cx, scope, p, cache);
}
template<typename T>
static inline JSObject*
WrapNativeParent(JSContext* cx, JSObject* scope, const T& p)
{
if (!GetParentPointer(p))
return scope;
nsWrapperCache* cache = GetWrapperCache(p);
JSObject* obj;
if (cache && (obj = cache->GetWrapper())) {
#ifdef DEBUG
qsObjectHelper helper(GetParentPointer(p), cache);
JS::Value debugVal;
bool ok = XPCOMObjectToJsval(cx, scope, helper, NULL, false, &debugVal);
NS_ASSERTION(ok && JSVAL_TO_OBJECT(debugVal) == obj,
"Unexpected object in nsWrapperCache");
#endif
return obj;
}
qsObjectHelper helper(GetParentPointer(p), cache);
JS::Value v;
return XPCOMObjectToJsval(cx, scope, helper, NULL, false, &v) ?
JSVAL_TO_OBJECT(v) :
NULL;
return WrapNativeParent(cx, scope, GetParentPointer(p), GetWrapperCache(p));
}
static inline bool
@ -1121,34 +1192,14 @@ public:
bool
XrayResolveProperty(JSContext* cx, JSObject* wrapper, jsid id,
JSPropertyDescriptor* desc,
// And the things we need to determine the descriptor
Prefable<JSFunctionSpec>* methods,
jsid* methodIds,
JSFunctionSpec* methodSpecs,
size_t methodCount,
Prefable<JSPropertySpec>* attributes,
jsid* attributeIds,
JSPropertySpec* attributeSpecs,
size_t attributeCount,
Prefable<ConstantSpec>* constants,
jsid* constantIds,
ConstantSpec* constantSpecs,
size_t constantCount);
const NativeProperties* nativeProperties,
const NativeProperties* chromeOnlyNativeProperties);
bool
XrayEnumerateProperties(JS::AutoIdVector& props,
Prefable<JSFunctionSpec>* methods,
jsid* methodIds,
JSFunctionSpec* methodSpecs,
size_t methodCount,
Prefable<JSPropertySpec>* attributes,
jsid* attributeIds,
JSPropertySpec* attributeSpecs,
size_t attributeCount,
Prefable<ConstantSpec>* constants,
jsid* constantIds,
ConstantSpec* constantSpecs,
size_t constantCount);
XrayEnumerateProperties(JSObject* wrapper,
JS::AutoIdVector& props,
const NativeProperties* nativeProperties,
const NativeProperties* chromeOnlyNativeProperties);
// Transfer reference in ptr to smartPtr.
template<class T>

Просмотреть файл

@ -89,6 +89,7 @@ DOMInterfaces = {
'mozAudioContext': {
'nativeType': 'AudioContext',
'implicitJSContext': [ 'createBuffer' ],
'nativeOwnership': 'refcounted'
},
'AudioNode' : {

Просмотреть файл

@ -93,11 +93,16 @@ def DOMClass(descriptor):
protoList.extend(['prototypes::id::_ID_Count'] * (descriptor.config.maxProtoChainLength - len(protoList)))
prototypeChainString = ', '.join(protoList)
nativeHooks = "NULL" if descriptor.workers else "&NativeHooks"
if descriptor.workers or descriptor.nativeOwnership != 'refcounted':
participant = "nullptr"
else:
participant = "NS_CYCLE_COLLECTION_PARTICIPANT(%s)" % descriptor.nativeType
return """{
{ %s },
%s, %s
%s, %s, %s
}""" % (prototypeChainString, toStringBool(descriptor.nativeOwnership == 'nsisupports'),
nativeHooks)
nativeHooks,
participant)
class CGDOMJSClass(CGThing):
"""
@ -633,12 +638,13 @@ class CGAddPropertyHook(CGAbstractClassHook):
'JSBool', args)
def generate_code(self):
# FIXME https://bugzilla.mozilla.org/show_bug.cgi?id=774279
# Using a real trace hook might enable us to deal with non-nsISupports
# wrappercached things here.
assert self.descriptor.nativeOwnership == 'nsisupports'
return """ nsContentUtils::PreserveWrapper(reinterpret_cast<nsISupports*>(self), self);
return true;"""
assert not self.descriptor.workers and self.descriptor.wrapperCache
if self.descriptor.nativeOwnership == 'nsisupports':
preserveArgs = "reinterpret_cast<nsISupports*>(self), self"
else:
preserveArgs = "self, self, NS_CYCLE_COLLECTION_PARTICIPANT(%s)" % self.descriptor.nativeType
return """ nsContentUtils::PreserveWrapper(%s);
return true;""" % preserveArgs
def DeferredFinalizeSmartPtr(descriptor):
if descriptor.nativeOwnership == 'owned':
@ -860,9 +866,8 @@ class PropertyDefiner:
Subclasses should implement generateArray to generate the actual arrays of
things we're defining. They should also set self.chrome to the list of
things exposed to chrome and self.regular to the list of things exposed to
web pages. self.chrome must be a superset of self.regular but also include
all the ChromeOnly stuff.
things only exposed to chrome and self.regular to the list of things exposed
to both chrome and web pages.
"""
def __init__(self, descriptor, name):
self.descriptor = descriptor
@ -872,33 +877,31 @@ class PropertyDefiner:
# in as needed.
self.prefCacheData = []
def hasChromeOnly(self):
return len(self.chrome) > len(self.regular)
return len(self.chrome) > 0
def hasNonChromeOnly(self):
return len(self.regular) > 0
def variableName(self, chrome):
if chrome and self.hasChromeOnly():
return "sChrome" + self.name
if self.hasNonChromeOnly():
return "s" + self.name
return "NULL"
def usedForXrays(self, chrome):
# We only need Xrays for methods, attributes and constants. And we only
# need them for the non-chrome ones if we have no chromeonly things.
# Otherwise (we have chromeonly attributes) we need Xrays for the chrome
# methods/attributes/constants. Finally, in workers there are no Xrays.
return ((self.name is "Methods" or self.name is "Attributes" or
self.name is "Constants") and
chrome == self.hasChromeOnly() and
not self.descriptor.workers)
if chrome:
if self.hasChromeOnly():
return "sChrome" + self.name
else:
if self.hasNonChromeOnly():
return "s" + self.name
return "nullptr"
def usedForXrays(self):
# We only need Xrays for methods, attributes and constants, but in
# workers there are no Xrays.
return (self.name is "Methods" or self.name is "Attributes" or
self.name is "Constants") and not self.descriptor.workers
def __str__(self):
# We only need to generate id arrays for things that will end
# up used via ResolveProperty or EnumerateProperties.
str = self.generateArray(self.regular, self.variableName(False),
self.usedForXrays(False))
self.usedForXrays())
if self.hasChromeOnly():
str += self.generateArray(self.chrome, self.variableName(True),
self.usedForXrays(True))
self.usedForXrays())
return str
@staticmethod
@ -1012,7 +1015,7 @@ class MethodDefiner(PropertyDefiner):
"length": methodLength(m),
"flags": "JSPROP_ENUMERATE",
"pref": PropertyDefiner.getControllingPref(m) }
for m in methods]
for m in methods if isChromeOnly(m)]
self.regular = [{"name": m.identifier.name,
"length": methodLength(m),
"flags": "JSPROP_ENUMERATE",
@ -1021,12 +1024,6 @@ class MethodDefiner(PropertyDefiner):
# FIXME Check for an existing iterator on the interface first.
if any(m.isGetter() and m.isIndexed() for m in methods):
self.chrome.append({"name": 'iterator',
"methodInfo": False,
"nativeName": "JS_ArrayIterator",
"length": 0,
"flags": "JSPROP_ENUMERATE",
"pref": None })
self.regular.append({"name": 'iterator',
"methodInfo": False,
"nativeName": "JS_ArrayIterator",
@ -1077,8 +1074,9 @@ class AttrDefiner(PropertyDefiner):
def __init__(self, descriptor, name):
PropertyDefiner.__init__(self, descriptor, name)
self.name = name
self.chrome = [m for m in descriptor.interface.members if m.isAttr()]
self.regular = [m for m in self.chrome if not isChromeOnly(m)]
attributes = [m for m in descriptor.interface.members if m.isAttr()]
self.chrome = [m for m in attributes if isChromeOnly(m)]
self.regular = [m for m in attributes if not isChromeOnly(m)]
def generateArray(self, array, name, doIdArrays):
if len(array) == 0:
@ -1121,8 +1119,9 @@ class ConstDefiner(PropertyDefiner):
def __init__(self, descriptor, name):
PropertyDefiner.__init__(self, descriptor, name)
self.name = name
self.chrome = [m for m in descriptor.interface.members if m.isConst()]
self.regular = [m for m in self.chrome if not isChromeOnly(m)]
constants = [m for m in descriptor.interface.members if m.isConst()]
self.chrome = [m for m in constants if isChromeOnly(m)]
self.regular = [m for m in constants if not isChromeOnly(m)]
def generateArray(self, array, name, doIdArrays):
if len(array) == 0:
@ -1155,19 +1154,49 @@ class PropertyArrays():
return [ "methods", "attrs", "consts" ]
def hasChromeOnly(self):
return reduce(lambda b, a: b or getattr(self, a).hasChromeOnly(),
self.arrayNames(), False)
def variableNames(self, chrome):
names = {}
for array in self.arrayNames():
names[array] = getattr(self, array).variableName(chrome)
return names
return any(getattr(self, a).hasChromeOnly() for a in self.arrayNames())
def hasNonChromeOnly(self):
return any(getattr(self, a).hasNonChromeOnly() for a in self.arrayNames())
def __str__(self):
define = ""
for array in self.arrayNames():
define += str(getattr(self, array))
return define
class CGNativeProperties(CGList):
def __init__(self, descriptor, properties):
def generateNativeProperties(name, chrome):
def check(p):
return p.hasChromeOnly() if chrome else p.hasNonChromeOnly()
nativeProps = []
for array in properties.arrayNames():
propertyArray = getattr(properties, array)
if check(propertyArray):
if descriptor.workers:
props = "%(name)s, nullptr, %(name)s_specs"
else:
if propertyArray.usedForXrays():
ids = "%(name)s_ids"
else:
ids = "nullptr"
props = "%(name)s, " + ids + ", %(name)s_specs"
props = (props %
{ 'name': propertyArray.variableName(chrome) })
else:
props = "nullptr, nullptr, nullptr"
nativeProps.append(CGGeneric(props))
return CGWrapper(CGIndenter(CGList(nativeProps, ",\n")),
pre="static const NativeProperties %s = {\n" % name,
post="\n};")
regular = generateNativeProperties("sNativeProperties", False)
chrome = generateNativeProperties("sChromeOnlyNativeProperties", True)
CGList.__init__(self, [regular, chrome], "\n\n")
def declare(self):
return ""
class CGCreateInterfaceObjectsMethod(CGAbstractMethod):
"""
Generate the CreateInterfaceObjects method for an interface descriptor.
@ -1203,7 +1232,7 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod):
# We only have non-chrome ids to init if we have no chrome ids.
if props.hasChromeOnly():
idsToInit.append(props.variableName(True))
elif props.hasNonChromeOnly():
if props.hasNonChromeOnly():
idsToInit.append(props.variableName(False))
if len(idsToInit) > 0:
initIds = CGList(
@ -1264,32 +1293,34 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod):
else:
domClass = "nullptr"
if self.properties.hasNonChromeOnly():
properties = "&sNativeProperties"
else:
properties = "nullptr"
if self.properties.hasChromeOnly():
if self.descriptor.workers:
accessCheck = "mozilla::dom::workers::GetWorkerPrivateFromContext(aCx)->IsChromeWorker()"
else:
accessCheck = "xpc::AccessCheck::isChrome(aGlobal)"
chromeProperties = accessCheck + " ? &sChromeOnlyNativeProperties : nullptr"
else:
chromeProperties = "nullptr"
call = """return dom::CreateInterfaceObjects(aCx, aGlobal, aReceiver, parentProto,
%s, %s, %s, %d,
%s,
%%(methods)s, %%(attrs)s,
%%(consts)s, %%(staticMethods)s,
%s,
%s,
%s);""" % (
"&PrototypeClass" if needInterfacePrototypeObject else "NULL",
"&InterfaceObjectClass" if needInterfaceObjectClass else "NULL",
constructHook if needConstructor else "NULL",
constructArgs,
domClass,
properties,
chromeProperties,
'"' + self.descriptor.interface.identifier.name + '"' if needInterfaceObject else "NULL")
if self.properties.hasChromeOnly():
if self.descriptor.workers:
accessCheck = "mozilla::dom::workers::GetWorkerPrivateFromContext(aCx)->IsChromeWorker()"
else:
accessCheck = "xpc::AccessCheck::isChrome(js::GetObjectCompartment(aGlobal))"
chrome = CGIfWrapper(CGGeneric(call % self.properties.variableNames(True)),
accessCheck)
chrome = CGWrapper(chrome, pre="\n\n")
else:
chrome = None
functionBody = CGList(
[CGGeneric(getParentProto), initIds, prefCache, chrome,
CGGeneric(call % self.properties.variableNames(False))],
[CGGeneric(getParentProto), initIds, prefCache, CGGeneric(call)],
"\n\n")
return CGIndenter(functionBody).define()
@ -4535,36 +4566,20 @@ class CGXrayHelper(CGAbstractMethod):
self.properties = properties
def definition_body(self):
varNames = self.properties.variableNames(True)
methods = self.properties.methods
if methods.hasNonChromeOnly() or methods.hasChromeOnly():
methodArgs = """// %(methods)s has an end-of-list marker at the end that we ignore
%(methods)s, %(methods)s_ids, %(methods)s_specs, ArrayLength(%(methods)s) - 1""" % varNames
else:
methodArgs = "NULL, NULL, NULL, 0"
methodArgs = CGGeneric(methodArgs)
attrs = self.properties.attrs
if attrs.hasNonChromeOnly() or attrs.hasChromeOnly():
attrArgs = """// %(attrs)s has an end-of-list marker at the end that we ignore
%(attrs)s, %(attrs)s_ids, %(attrs)s_specs, ArrayLength(%(attrs)s) - 1""" % varNames
else:
attrArgs = "NULL, NULL, NULL, 0"
attrArgs = CGGeneric(attrArgs)
consts = self.properties.consts
if consts.hasNonChromeOnly() or consts.hasChromeOnly():
constArgs = """// %(consts)s has an end-of-list marker at the end that we ignore
%(consts)s, %(consts)s_ids, %(consts)s_specs, ArrayLength(%(consts)s) - 1""" % varNames
else:
constArgs = "NULL, NULL, NULL, 0"
constArgs = CGGeneric(constArgs)
prefixArgs = CGGeneric(self.getPrefixArgs())
if self.properties.hasNonChromeOnly():
regular = "&sNativeProperties"
else:
regular = "nullptr"
regular = CGGeneric(regular)
if self.properties.hasChromeOnly():
chrome = "&sChromeOnlyNativeProperties"
else:
chrome = "nullptr"
chrome = CGGeneric(chrome)
return CGIndenter(
CGWrapper(CGList([prefixArgs, methodArgs, attrArgs, constArgs], ",\n"),
CGWrapper(CGList([prefixArgs, regular, chrome], ",\n"),
pre=("return Xray%s(" % self.name),
post=");",
reindent=True)).define()
@ -4589,7 +4604,7 @@ class CGEnumerateProperties(CGXrayHelper):
properties)
def getPrefixArgs(self):
return "props"
return "wrapper, props"
class CGPrototypeTraitsClass(CGClass):
def __init__(self, descriptor, indent=''):
@ -5242,6 +5257,7 @@ class CGDescriptor(CGThing):
properties = PropertyArrays(descriptor)
cgThings.append(CGGeneric(define=str(properties)))
cgThings.append(CGNativeProperties(descriptor, properties))
cgThings.append(CGCreateInterfaceObjectsMethod(descriptor, properties))
if descriptor.interface.hasInterfacePrototypeObject():
cgThings.append(CGGetProtoObjectMethod(descriptor))

Просмотреть файл

@ -266,7 +266,9 @@ class Descriptor(DescriptorProvider):
self.customTrace = desc.get('customTrace', self.workers)
self.customFinalize = desc.get('customFinalize', self.workers)
self.wrapperCache = (not self.interface.isCallback() and
(self.workers or desc.get('wrapperCache', True)))
(self.workers or
(self.nativeOwnership != 'owned' and
desc.get('wrapperCache', True))))
if not self.wrapperCache and self.prefable:
raise TypeError("Descriptor for %s is prefable but not wrappercached" %

Просмотреть файл

@ -11,6 +11,8 @@
#include "mozilla/dom/PrototypeList.h" // auto-generated
class nsCycleCollectionParticipant;
// We use slot 0 for holding the raw object. This is safe for both
// globals and non-globals.
#define DOM_OBJECT_SLOT 0
@ -66,6 +68,11 @@ struct DOMClass
const bool mDOMObjectIsISupports;
const NativePropertyHooks* mNativeHooks;
// This stores the CC participant for the native, null if this class is for a
// worker or for a native inheriting from nsISupports (we can get the CC
// participant by QI'ing in that case).
nsCycleCollectionParticipant* mParticipant;
};
// Special JSClass for reflected DOM objects.

Просмотреть файл

@ -164,8 +164,6 @@
"XMLDocument interface: existence and properties of interface prototype object": true,
"XMLDocument interface: existence and properties of interface prototype object's \"constructor\" property": true,
"Stringification of xmlDoc": "debug",
"Document interface: xmlDoc must inherit property \"URL\" with the proper type (1)": true,
"Document interface: xmlDoc must inherit property \"compatMode\" with the proper type (3)": true,
"Document interface: calling getElementsByTagName(DOMString) on xmlDoc with too few arguments must throw TypeError": true,
"Document interface: calling getElementsByTagNameNS(DOMString,DOMString) on xmlDoc with too few arguments must throw TypeError": true,
"Document interface: calling getElementsByClassName(DOMString) on xmlDoc with too few arguments must throw TypeError": true,

Просмотреть файл

@ -27,7 +27,7 @@ interface nsIDOMLocation;
* http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html
*/
[scriptable, uuid(FDB92F4F-C6B4-4509-A29D-A309981E28AC)]
[scriptable, uuid(22af46a3-64ac-430a-bcc7-d0a9aefe474f)]
interface nsIDOMDocument : nsIDOMNode
{
readonly attribute nsIDOMDocumentType doctype;
@ -68,6 +68,8 @@ interface nsIDOMDocument : nsIDOMNode
readonly attribute DOMString inputEncoding;
// Introduced in DOM Level 3:
readonly attribute DOMString documentURI;
// Alias introduced for all documents in recent DOM standards
readonly attribute DOMString URL;
// Introduced in DOM Level 3:
nsIDOMNode adoptNode(in nsIDOMNode source)
raises(DOMException);
@ -385,4 +387,10 @@ interface nsIDOMDocument : nsIDOMNode
*/
readonly attribute boolean mozHidden;
readonly attribute DOMString mozVisibilityState;
/**
* Returns "BackCompat" if we're in quirks mode or "CSS1Compat" if we're in
* strict mode. (XML documents are always in strict mode.)
*/
readonly attribute DOMString compatMode;
};

Просмотреть файл

@ -13,15 +13,11 @@
*/
interface nsISelection;
[scriptable, uuid(ecae54c6-2ab9-4167-b0ef-61960aadbb68)]
[scriptable, uuid(3f8666a9-76f0-4733-ae11-4aea8753062d)]
interface nsIDOMHTMLDocument : nsIDOMDocument
{
readonly attribute DOMString URL;
attribute DOMString domain;
attribute DOMString cookie;
// returns "BackCompat" if we're in quirks mode,
// or "CSS1Compat" if we're in strict mode
readonly attribute DOMString compatMode;
readonly attribute nsIDOMHTMLHeadElement head;
attribute nsIDOMHTMLElement body;

Просмотреть файл

@ -7,10 +7,9 @@
interface nsIDOMSVGSVGElement;
[scriptable, uuid(4AEBF9E7-F275-4147-AA90-601626476132)]
[scriptable, uuid(8fe506e4-5563-4b16-9228-182071e3f8f8)]
interface nsIDOMSVGDocument : nsIDOMDocument
{
readonly attribute DOMString domain;
readonly attribute DOMString URL;
readonly attribute nsIDOMSVGSVGElement rootElement;
};

Просмотреть файл

@ -17,6 +17,13 @@ SimpleTest.waitForExplicitFinish();
function runTests() {
var pluginElement = document.getElementById("plugin1");
// Poll to see if the plugin is in the right place yet.
// Check if x-coordinate 0 in plugin space is 0 in window space. If it is,
// the plugin hasn't been placed yet.
if (pluginElement.convertPointX(1, 0, 0, 2) == 0) {
setTimeout(runTests, 0);
return;
}
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');

Просмотреть файл

@ -22,6 +22,7 @@ DIRS += \
whatwg \
geolocation \
localstorage \
media \
orientation \
sessionstorage \
storageevent \

Просмотреть файл

@ -50,6 +50,8 @@ MOCHITEST_CHROME_FILES = \
selectAtPoint.html \
test_bug799299.xul \
file_bug799299.xul \
test_bug800817.xul \
file_bug800817.xul \
$(NULL)
ifeq (WINNT,$(OS_ARCH))

Просмотреть файл

@ -0,0 +1,75 @@
<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=800817
-->
<window title="Mozilla Bug 800817"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
<!-- test results are displayed in the html:body -->
<body xmlns="http://www.w3.org/1999/xhtml">
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=800817"
target="_blank">Mozilla Bug 800817</a>
</body>
<!-- test code goes here -->
<script type="application/javascript">
<![CDATA[
/** Test for Bug 800817 **/
function sendClick(win) {
var wu = win.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIDOMWindowUtils);
wu.sendMouseEventToWindow("mousedown", 10, 10, 0, 0, 0);
wu.sendMouseEventToWindow("mouseup", 10, 10, 0, 0, 0);
}
function runTests() {
var b1 = document.getElementById("b1");
var b2 = document.getElementById("b2");
var mozbrowserAttr = opener.wrappedJSObject.testMozBrowser ? "true" : "false";
b1.setAttribute("mozbrowser", mozbrowserAttr);
b2.setAttribute("mozbrowser", mozbrowserAttr);
opener.wrappedJSObject.ok(true, "Testing with mozbrowser="+ mozbrowserAttr);
b1.contentWindow.focus();
opener.wrappedJSObject.is(document.activeElement, b1,
"Focused first iframe");
var didCallDummy = false;
b2.contentWindow.addEventListener("mousedown", function(e) { didCallDummy = true; });
sendClick(b2.contentWindow);
opener.wrappedJSObject.ok(didCallDummy);
opener.wrappedJSObject.is(document.activeElement, b2,
"Focus shifted to second iframe");
b1.contentWindow.focus();
opener.wrappedJSObject.is(document.activeElement, b1,
"Re-focused first iframe for the first time");
var didCallListener = false;
b2.contentWindow.addEventListener("mousedown", function(e) { didCallListener = true; e.preventDefault(); });
sendClick(b2.contentWindow);
opener.wrappedJSObject.ok(didCallListener);
opener.wrappedJSObject.is(document.activeElement, b1,
"Did not move focus to the second iframe");
window.close();
opener.wrappedJSObject.finishedTests();
}
SimpleTest.waitForFocus(runTests);
]]>
</script>
<iframe xmlns="http://www.w3.org/1999/xhtml"
id="b1" type="content" src="about:blank"
style="width: 300px; height: 550px; border: 1px solid black;"/>
<iframe xmlns="http://www.w3.org/1999/xhtml"
id="b2" type="content" src="about:blank"
style="width: 300px; height: 550px; border: 1px solid black;"/>
</window>

Просмотреть файл

@ -0,0 +1,43 @@
<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=800817
-->
<window title="Mozilla Bug 800817" onload="runTests()"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
<!-- test results are displayed in the html:body -->
<body xmlns="http://www.w3.org/1999/xhtml">
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=800817"
target="_blank">Mozilla Bug 800817</a>
</body>
<!-- test code goes here -->
<script type="application/javascript">
<![CDATA[
/** Test for Bug 800817 **/
var testMozBrowser = false;
function runTests() {
// Run a first round of tests for non-mozbrowser iframes.
window.open("file_bug800817.xul", "_blank", "chrome,width=600,height=550");
}
function finishedTests() {
if (!testMozBrowser) {
testMozBrowser = true;
// Run a second round of tests for mozbrowser iframes.
window.open("file_bug800817.xul", "_blank", "chrome,width=600,height=550");
} else {
SimpleTest.finish();
}
}
SimpleTest.waitForExplicitFinish();
]]>
</script>
</window>

Просмотреть файл

@ -0,0 +1,18 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
DEPTH = @DEPTH@
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
relativesrcdir = @relativesrcdir@
include $(DEPTH)/config/autoconf.mk
MOCHITEST_FILES = \
test_getUserMedia_exceptions.html \
head.js \
$(NULL)
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -0,0 +1,22 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
var Cc = SpecialPowers.Cc;
var Ci = SpecialPowers.Ci;
var Cr = SpecialPowers.Cr;
/**
* Setup any Mochitest for WebRTC by enabling the preference for
* peer connections. As by bug 797979 it will also enable mozGetUserMedia().
* Additionally, we disable the permissions prompt for these mochitests.
*
* @param {Function} aCallback Test method to execute after initialization
*/
function runTest(aCallback) {
SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv({'set': [['media.peerconnection.enabled', true],
['media.navigator.permission.disabled', true]]},
aCallback);
}

Просмотреть файл

@ -0,0 +1,86 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=795367
-->
<head>
<meta charset="utf-8">
<title>Test mozGetUserMedia Exceptions</title>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="head.js"></script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=795367">Test mozGetUserMedia Exceptions</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
/**
These tests verify that the appropriate exception is thrown when incorrect
values are provided to the immediate mozGetUserMedia call.
*/
var exceptionTests = [
// Each test here verifies that a caller is required to have all
// three arguments in order to call mozGetUserMedia
{ params: undefined,
error: Cr.NS_ERROR_XPC_NOT_ENOUGH_ARGS,
message: "no arguments specified" },
{ params: [{video: true, fake: true}],
error: Cr.NS_ERROR_XPC_NOT_ENOUGH_ARGS,
message: "one argument specified" },
{ params: [{video: true, fake: true}, unexpectedCall],
error: Cr.NS_ERROR_XPC_NOT_ENOUGH_ARGS,
message: "two arguments specified" },
// Each test here verifies that providing an incorret object
// type to any mozGetUserMedia parameter should throw
// the correct exception specified
{ params: [1, unexpectedCall, unexpectedCall],
error: Cr.NS_ERROR_XPC_BAD_CONVERT_JS,
message: "wrong object type as first parameter" },
{ params: [{video: true, fake: true}, 1, unexpectedCall],
error: Cr.NS_ERROR_XPC_BAD_CONVERT_JS,
message: "wrong object type as second parameter" },
{ params: [{video: true, fake: true}, unexpectedCall, 1],
error: Cr.NS_ERROR_XPC_BAD_CONVERT_JS,
message: "wrong object type as third parameter" }
];
/**
* A callback function that is only called if a particular
* exception was not thrown, resulting in the test failing.
*
* @param {MediaStream} argument ignored
*/
function unexpectedCall(obj) {
ok(false, "Callback should not have been called");
}
/**
* Starts the test run by running through each exception
* test by verifying that the correct exception type specified
* is thrown on the mozGetUserMedia call with the parameters
* specified.
*/
runTest(function () {
exceptionTests.forEach(function (test) {
var exception = false;
try {
navigator.mozGetUserMedia.apply(navigator, test.params);
} catch (e) {
exception = (e.result === test.error);
}
ok(exception, "Exception for " + test.message);
});
SimpleTest.finish();
});
</script>
</pre>
</body>
</html>

Просмотреть файл

@ -6,6 +6,7 @@
#define nsCodingStateMachine_h__
#include "nsPkgInt.h"
#include "mozilla/Util.h"
typedef enum {
eStart = 0,
@ -22,6 +23,9 @@ typedef struct
uint32_t classFactor;
nsPkgInt stateTable;
const uint32_t* charLenTable;
#ifdef DEBUG
const size_t charLenTableLength;
#endif
const char* name;
} SMModel;
@ -34,6 +38,7 @@ public:
if (mCurrentState == eStart)
{
mCurrentBytePos = 0;
MOZ_ASSERT(byteCls < mModel->charLenTableLength);
mCurrentCharLen = mModel->charLenTable[byteCls];
}
//from byte's class and stateTable, we get its next state
@ -68,5 +73,12 @@ extern const SMModel ISO2022CNSMModel;
extern const SMModel ISO2022JPSMModel;
extern const SMModel ISO2022KRSMModel;
#undef CHAR_LEN_TABLE
#ifdef DEBUG
#define CHAR_LEN_TABLE(x) x, mozilla::ArrayLength(x)
#else
#define CHAR_LEN_TABLE(x) x
#endif
#endif /* nsCodingStateMachine_h__ */

Просмотреть файл

@ -55,7 +55,7 @@ const SMModel HZSMModel = {
{eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, HZ_cls },
6,
{eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, HZ_st },
HZCharLenTable,
CHAR_LEN_TABLE(HZCharLenTable),
"HZ-GB-2312",
};
@ -113,7 +113,7 @@ const SMModel ISO2022CNSMModel = {
{eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, ISO2022CN_cls },
9,
{eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, ISO2022CN_st },
ISO2022CNCharLenTable,
CHAR_LEN_TABLE(ISO2022CNCharLenTable),
"ISO-2022-CN",
};
@ -165,13 +165,13 @@ PCK4BITS(eError,eError,eError,eItsMe,eError,eError,eError,eError),//38-3f
PCK4BITS(eError,eError,eError,eError,eItsMe,eError,eStart,eStart) //40-47
};
static const uint32_t ISO2022JPCharLenTable[] = {0, 0, 0, 0, 0, 0, 0, 0};
static const uint32_t ISO2022JPCharLenTable[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
const SMModel ISO2022JPSMModel = {
{eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, ISO2022JP_cls },
10,
{eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, ISO2022JP_st },
ISO2022JPCharLenTable,
CHAR_LEN_TABLE(ISO2022JPCharLenTable),
"ISO-2022-JP",
};
@ -225,7 +225,7 @@ const SMModel ISO2022KRSMModel = {
{eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, ISO2022KR_cls },
6,
{eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, ISO2022KR_st },
ISO2022KRCharLenTable,
CHAR_LEN_TABLE(ISO2022KRCharLenTable),
"ISO-2022-KR",
};

Просмотреть файл

@ -61,7 +61,7 @@ SMModel const Big5SMModel = {
{eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, BIG5_cls },
5,
{eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, BIG5_st },
Big5CharLenTable,
CHAR_LEN_TABLE(Big5CharLenTable),
"Big5",
};
@ -116,7 +116,7 @@ const SMModel EUCJPSMModel = {
{eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, EUCJP_cls },
6,
{eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, EUCJP_st },
EUCJPCharLenTable,
CHAR_LEN_TABLE(EUCJPCharLenTable),
"EUC-JP",
};
@ -168,7 +168,7 @@ const SMModel EUCKRSMModel = {
{eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, EUCKR_cls },
4,
{eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, EUCKR_st },
EUCKRCharLenTable,
CHAR_LEN_TABLE(EUCKRCharLenTable),
"EUC-KR",
};
@ -224,7 +224,7 @@ const SMModel EUCTWSMModel = {
{eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, EUCTW_cls },
7,
{eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, EUCTW_st },
EUCTWCharLenTable,
CHAR_LEN_TABLE(EUCTWCharLenTable),
"x-euc-tw",
};
@ -277,7 +277,7 @@ SMModel GB2312SMModel = {
{eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, GB2312_cls },
4,
{eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, GB2312_st },
GB2312CharLenTable,
CHAR_LEN_TABLE(GB2312CharLenTable),
"GB2312",
};
*/
@ -340,7 +340,7 @@ const SMModel GB18030SMModel = {
{eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, GB18030_cls },
7,
{eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, GB18030_st },
GB18030CharLenTable,
CHAR_LEN_TABLE(GB18030CharLenTable),
"GB18030",
};
@ -397,7 +397,7 @@ const SMModel SJISSMModel = {
{eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, SJIS_cls },
6,
{eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, SJIS_st },
SJISCharLenTable,
CHAR_LEN_TABLE(SJISCharLenTable),
"Shift_JIS",
};
@ -475,7 +475,7 @@ const SMModel UTF8SMModel = {
{eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, UTF8_cls },
16,
{eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, UTF8_st },
UTF8CharLenTable,
CHAR_LEN_TABLE(UTF8CharLenTable),
"UTF-8",
};

Просмотреть файл

@ -49,9 +49,9 @@ function InitDetectorTests()
gExpectedCharset = prefService
.getComplexValue("intl.charset.default",
Ci.nsIPrefLocalizedString)
.data;
.data.toLowerCase();
} catch (e) {
gExpectedCharset = "ISO-8859-8";
gExpectedCharset = "iso-8859-8";
}
}

Просмотреть файл

@ -22,7 +22,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=306272
<script class="testbody" type="text/javascript">
/** Test for Bug 306272 **/
CharsetDetectionTests("bug306272_text.html",
"UTF-8",
"utf-8",
new Array("ja_parallel_state_machine",
"zh_parallel_state_machine",
"zhtw_parallel_state_machine",

Просмотреть файл

@ -22,7 +22,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=426271
<script class="testbody" type="text/javascript">
/** Test for Bug 426271 **/
CharsetDetectionTests("bug426271_text-euc-jp.html",
"EUC-JP",
"euc-jp",
new Array("ja_parallel_state_machine",
"cjk_parallel_state_machine",
"universal_charset_detector"));

Просмотреть файл

@ -22,7 +22,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=426271
<script class="testbody" type="text/javascript">
/** Test for Bug 426271 **/
CharsetDetectionTests("bug426271_text-utf-8.html",
"UTF-8",
"utf-8",
new Array("ja_parallel_state_machine",
"zhtw_parallel_state_machine",
"zhcn_parallel_state_machine",

Просмотреть файл

@ -22,7 +22,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=431054
<script class="testbody" type="text/javascript">
/** Test for Bug 431054 **/
CharsetDetectionTests("bug431054_text.html",
"EUC-JP",
"euc-jp",
new Array("ja_parallel_state_machine"));
</script>
</pre>

Просмотреть файл

@ -22,7 +22,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=488426
<script class="testbody" type="text/javascript">
/** Test for Bug 488426 **/
CharsetDetectionTests("bug488426_text.html",
"TIS-620",
"tis-620",
new Array("universal_charset_detector"));
</script>
</pre>

Просмотреть файл

@ -22,7 +22,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=620106
<script class="testbody" type="text/javascript">
/** Test for Bug 620106 **/
CharsetDetectionTests("bug620106_text.html",
"EUC-JP",
"euc-jp",
new Array("universal_charset_detector"));
</script>
</pre>

Просмотреть файл

@ -23,7 +23,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=631751
/** Test for Bug 631751 **/
/* Note! This test uses the chardet test harness but doesn't test chardet! */
CharsetDetectionTests("bug631751be_text.html",
"UTF-16BE",
"utf-16be",
new Array(""));
</script>
</pre>

Просмотреть файл

@ -23,7 +23,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=631751
/** Test for Bug 631751 **/
/* Note! This test uses the chardet test harness but doesn't test chardet! */
CharsetDetectionTests("bug631751le_text.html",
"UTF-16LE",
"utf-16le",
new Array(""));
</script>
</pre>

Просмотреть файл

@ -23,7 +23,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=638318
/** Test for Bug 638318 **/
/* Note! This test uses the chardet test harness but doesn't test chardet! */
CharsetDetectionTests("bug638318_text.html",
"ISO-8859-1",
"iso-8859-1",
new Array(""));
</script>
</pre>

Просмотреть файл

@ -22,7 +22,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=9357
<script class="testbody" type="text/javascript">
/** Test for Bug 9357 **/
CharsetDetectionTests("bug9357_text.html",
"EUC-KR",
"euc-kr",
new Array("ko_parallel_state_machine",
"cjk_parallel_state_machine",
"universal_charset_detector"));

Просмотреть файл

@ -235,8 +235,8 @@ RasterImage::RasterImage(imgStatusTracker* aStatusTracker) :
mInDecoder(false),
mAnimationFinished(false),
mFinishing(false),
mScaleRequest(this),
mInUpdateImageContainer(false)
mInUpdateImageContainer(false),
mScaleRequest(this)
{
// Set up the discard tracker node.
mDiscardTrackerNode.img = this;

Просмотреть файл

@ -36,7 +36,7 @@ static const uint8_t gASCIIToLower [128] = {
// We want ToLowerCase(uint32_t) and ToLowerCaseASCII(uint32_t) to be fast
// when they're called from within the case-insensitive comparators, so we
// define inlined versions.
static NS_ALWAYS_INLINE uint32_t
static MOZ_ALWAYS_INLINE uint32_t
ToLowerCase_inline(uint32_t aChar)
{
if (IS_ASCII(aChar)) {
@ -46,7 +46,7 @@ ToLowerCase_inline(uint32_t aChar)
return mozilla::unicode::GetLowercase(aChar);
}
static NS_ALWAYS_INLINE uint32_t
static MOZ_ALWAYS_INLINE uint32_t
ToLowerCaseASCII_inline(const uint32_t aChar)
{
if (IS_ASCII(aChar)) {
@ -271,7 +271,7 @@ CaseInsensitiveCompare(const PRUnichar *a,
// the end of the string (as marked by aEnd), returns -1 and does not set
// aNext. Note that this function doesn't check that aStr < aEnd -- it assumes
// you've done that already.
static NS_ALWAYS_INLINE uint32_t
static MOZ_ALWAYS_INLINE uint32_t
GetLowerUTF8Codepoint(const char* aStr, const char* aEnd, const char **aNext)
{
// Convert to unsigned char so that stuffing chars into PRUint32s doesn't

Просмотреть файл

@ -337,7 +337,7 @@ void MessageLoop::RunTask(Task* task) {
}
bool MessageLoop::DeferOrRunPendingTask(const PendingTask& pending_task) {
if (pending_task.nestable || state_->run_depth >= run_depth_base_) {
if (pending_task.nestable || state_->run_depth <= run_depth_base_) {
RunTask(pending_task.task);
// Show that we ran a task (Note: a new one might arrive as a
// consequence!).

Просмотреть файл

@ -85,6 +85,7 @@ class SyncMessage : public Message {
class MessageReplyDeserializer {
public:
bool SerializeOutputParameters(const Message& msg);
virtual ~MessageReplyDeserializer() {}
private:
// Derived classes need to implement this, using the given iterator (which
// is skipped past the header for synchronous messages).

Просмотреть файл

@ -3094,13 +3094,6 @@ AC_CHECK_FUNCS(strndup posix_memalign memalign valloc)
dnl See if compiler supports some gcc-style attributes
AC_CACHE_CHECK(for __attribute__((always_inline)),
ac_cv_attribute_always_inline,
[AC_TRY_COMPILE([inline void f(void) __attribute__((always_inline));],
[],
ac_cv_attribute_always_inline=yes,
ac_cv_attribute_always_inline=no)])
AC_CACHE_CHECK(for __attribute__((malloc)),
ac_cv_attribute_malloc,
[AC_TRY_COMPILE([void* f(int) __attribute__((malloc));],
@ -3152,12 +3145,6 @@ dnl are defined in build/autoconf/altoptions.m4.
dnl If the compiler supports these attributes, define them as
dnl convenience macros.
if test "$ac_cv_attribute_always_inline" = yes ; then
AC_DEFINE(NS_ALWAYS_INLINE, [__attribute__((always_inline))])
else
AC_DEFINE(NS_ALWAYS_INLINE,)
fi
if test "$ac_cv_attribute_malloc" = yes ; then
AC_DEFINE(NS_ATTR_MALLOC, [__attribute__((malloc))])
else

Просмотреть файл

@ -0,0 +1,6 @@
// Test evaluate's catchTermination option.
var x = 0;
assertEq(evaluate('x = 1; terminate(); x = 2;', { catchTermination: true }),
"terminated");
assertEq(x, 1);

Просмотреть файл

@ -1,24 +0,0 @@
// Handle proto-less objects passed to addDebuggee.
var g = newGlobal('new-compartment');
var obj = g.eval("Object.create(null)");
var dbg = new Debugger;
// hasDebuggee and removeDebuggee must tolerate proto-less objects.
assertEq(dbg.hasDebuggee(obj), false);
// addDebuggee may either succeed or throw a TypeError. Don't care.
var added;
try {
dbg.addDebuggee(obj);
added = true;
} catch (exc) {
if (!(exc instanceof TypeError))
throw exc;
added = false;
}
assertEq(dbg.hasDebuggee(obj), added);
assertEq(dbg.getDebuggees().length, added ? 1 : 0);
assertEq(dbg.removeDebuggee(obj), undefined);
assertEq(dbg.hasDebuggee(obj), false);

Просмотреть файл

@ -1,4 +1,3 @@
// addDebuggee(obj), where obj is not global, adds obj's global.
// Adding a debuggee more than once is redundant.
var dbg = new Debugger;
@ -19,18 +18,6 @@ assertEq(dbg.addDebuggee(g), w);
usual();
assertEq(dbg.addDebuggee(w), w);
usual();
dbg.addDebuggee(g.Math);
usual();
dbg.addDebuggee(g.eval("(function () {})"));
usual();
// w2 is a Debugger.Object in g. Treat it like any other object in g; don't auto-unwrap it.
g.g2 = newGlobal('new-compartment');
g.eval("var w2 = new Debugger().addDebuggee(g2)");
dbg.addDebuggee(g.w2);
usual();
assertEq(!dbg.hasDebuggee(g.g2), true);
assertEq(dbg.hasDebuggee(g.w2), true);
// Removing the debuggee once is enough.
assertEq(dbg.removeDebuggee(g), undefined);

Просмотреть файл

@ -1,5 +1,4 @@
// |jit-test| debug
// Random objects can be the argument to hasDebuggee and removeDebuggee.
// If hasDebuggee(x) is false, removeDebuggee(x) does nothing.
var dbg = new Debugger;
@ -12,16 +11,12 @@ function check(obj) {
assertEq(dbg.removeDebuggee(obj), undefined);
}
// objects in this compartment, which we can't debug
check(this);
check({});
// global objects which happen not to be debuggees at the moment
var g1 = newGlobal('same-compartment');
check(g1);
check(g1.eval("({})"));
// objects in a compartment that is already debugging us
var g2 = newGlobal('new-compartment');
g2.parent = this;
g2.eval("var dbg = new Debugger(parent);");
check(g2);
check(g2.dbg);

Просмотреть файл

@ -0,0 +1,26 @@
// addDebuggee, hasDebuggee, and removeDebuggee all throw if presented with
// objects that are not valid global object designators.
load(libdir + 'asserts.js');
var dbg = new Debugger;
function check(bad) {
print("check(" + uneval(bad) + ")");
assertThrowsInstanceOf(function () { dbg.addDebuggee(bad); }, TypeError);
assertEq(dbg.getDebuggees().length, 0);
assertThrowsInstanceOf(function () { dbg.hasDebuggee(bad); }, TypeError);
assertThrowsInstanceOf(function () { dbg.removeDebuggee(bad); }, TypeError);
}
var g = newGlobal();
check(g.Object());
check(g.Object);
check(g.Function(""));
// A Debugger.Object belonging to a different Debugger is not a valid way
// to designate a global, even if its referent is a global.
var g2 = newGlobal();
var dbg2 = new Debugger;
var d2g2 = dbg2.addDebuggee(g2);
check(d2g2);

Просмотреть файл

@ -0,0 +1,117 @@
// Debugger.prototype.{addDebuggee,hasDebuggee,removeDebuggee} recognize globals
// regardless of how they are specified.
var dbg = new Debugger;
// Assert that dbg's debuggees are exactly the set passed as arguments.
// The arguments are assumed to be Debugger.Object instances referring to
// globals without wrappers --- which is the sort returned by addDebuggee.
function assertDebuggees() {
print("assertDebuggees([" + [g.toSource() for each (g in arguments)] + "])");
var debuggees = dbg.getDebuggees();
assertEq(arguments.length, debuggees.length);
for each (g in arguments)
assertEq(debuggees.indexOf(g) != -1, true);
}
var g1 = newGlobal(); g1.toSource = function () { return "[global g1]"; };
var g2 = newGlobal(); g2.toSource = function () { return "[global g2]"; };
assertDebuggees();
// Produce every possible way to designate g1, for us to play with.
// Globals can be designated by any of the following:
//
// - "CCW": a Cross-Compartment Wrapper (CCW) of a global object
// - "D.O": a Debugger.Object whose referent is a global object
// - "D.O of CCW": a Debugger.Object whose referent is a CCW of a
// global object, where the CCW can be securely unwrapped
//
// There's no direct "G", since globals are always in their own
// compartments, never the debugger's; if we ever viewed them directly,
// that would be a compartment violation.
// "dg1" means "Debugger.Object referring (directly) to g1".
var dg1 = dbg.addDebuggee(g1);
dg1.toSource = function() { return "[Debugger.Object for global g1]"; };
assertEq(dg1.global, dg1);
assertEq(dg1.unwrap(), dg1);
assertDebuggees(dg1);
// We need to add g2 as a debuggee; that's the only way to get a D.O referring
// to it without a wrapper.
var dg2 = dbg.addDebuggee(g2);
dg2.toSource = function() { return "[Debugger.Object for global g2]"; };
assertEq(dg2.global, dg2);
assertEq(dg2.unwrap(), dg2);
assertDebuggees(dg1, dg2);
// "dwg1" means "Debugger.Object referring to CCW of g1".
var dwg1 = dg2.makeDebuggeeValue(g1);
assertEq(dwg1.global, dg2);
assertEq(dwg1.unwrap(), dg1);
dwg1.toSource = function() { return "[Debugger.Object for CCW of global g1]"; };
assertDebuggees(dg1, dg2);
assertEq(dbg.removeDebuggee(g1), undefined);
assertEq(dbg.removeDebuggee(g2), undefined);
assertDebuggees();
// Systematically cover all the single-global possibilities:
//
// | added as | designated as | addDebuggee | hasDebuggee | removeDebuggee |
// |-------------+---------------+-------------+-------------+----------------|
// | (not added) | CCW | X | X | X |
// | | D.O | X | X | X |
// | | D.O of CCW | X | X | X |
// |-------------+---------------+-------------+-------------+----------------|
// | CCW | CCW | X | X | X |
// | | D.O | X | X | X |
// | | D.O of CCW | X | X | X |
// |-------------+---------------+-------------+-------------+----------------|
// | D.O | CCW | X | X | X |
// | | D.O | X | X | X |
// | | D.O of CCW | X | X | X |
// |-------------+---------------+-------------+-------------+----------------|
// | D.O of CCW | CCW | X | X | X |
// | | D.O | X | X | X |
// | | D.O of CCW | X | X | X |
// Cover the "(not added)" section of the table, other than "addDebuggee":
assertEq(dbg.hasDebuggee(g1), false);
assertEq(dbg.hasDebuggee(dg1), false);
assertEq(dbg.hasDebuggee(dwg1), false);
assertEq(dbg.removeDebuggee(g1), undefined); assertDebuggees();
assertEq(dbg.removeDebuggee(dg1), undefined); assertDebuggees();
assertEq(dbg.removeDebuggee(dwg1), undefined); assertDebuggees();
// Try all operations adding the debuggee using |addAs|, and operating on it
// using |designateAs|, thereby covering one row of the table (outside the '(not
// added)' section), and one case in the '(not added)', 'designated as' section.
//
// |Direct| should be the Debugger.Object referring directly to the debuggee
// global, for checking the results from addDebuggee and getDebuggees.
function combo(addAs, designateAs, direct) {
print("combo(" + uneval(addAs) + ", " + uneval(designateAs) + ")");
assertDebuggees();
assertEq(dbg.addDebuggee(addAs), direct);
assertDebuggees(direct);
assertEq(dbg.addDebuggee(designateAs), direct);
assertDebuggees(direct);
assertEq(dbg.hasDebuggee(designateAs), true);
assertEq(dbg.removeDebuggee(designateAs), undefined);
assertDebuggees();
}
combo(g1, g1, dg1);
combo(dg1, g1, dg1);
combo(dwg1, g1, dg1);
combo(g1, dg1, dg1);
combo(dg1, dg1, dg1);
combo(dwg1, dg1, dg1);
combo(g1, dwg1, dg1);
combo(dg1, dwg1, dg1);
combo(dwg1, dwg1, dg1);

Просмотреть файл

@ -0,0 +1,24 @@
// Debugger.prototype.findAllGlobals surface.
load(libdir + 'asserts.js');
var dbg = new Debugger;
var d = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(dbg), 'findAllGlobals');
assertEq(d.configurable, true);
assertEq(d.enumerable, false);
assertEq(d.writable, true);
assertEq(typeof d.value, 'function');
assertEq(dbg.findAllGlobals.length, 0);
assertEq(dbg.findAllGlobals.name, 'findAllGlobals');
// findAllGlobals can only be applied to real Debugger instances.
assertThrowsInstanceOf(function() {
Debugger.prototype.findAllGlobals.call(Debugger.prototype);
},
TypeError);
var a = dbg.findAllGlobals();
assertEq(a instanceof Array, true);
assertEq(a.length > 0, true);
for (g of a) {
assertEq(g instanceof Debugger.Object, true);
}

Просмотреть файл

@ -0,0 +1,27 @@
// Debugger.prototype.findAllGlobals finds ALL the globals!
var g1 = newGlobal(); // Created before the Debugger; debuggee.
var g2 = newGlobal(); // Created before the Debugger; not debuggee.
var dbg = new Debugger;
var g3 = newGlobal(); // Created after the Debugger; debuggee.
var g4 = newGlobal(); // Created after the Debugger; not debuggee.
var g1w = dbg.addDebuggee(g1);
var g3w = dbg.addDebuggee(g3);
var a = dbg.findAllGlobals();
// Get Debugger.Objects viewing the globals from their own compartments;
// this is the sort that findAllGlobals and addDebuggee return.
var g2w = g1w.makeDebuggeeValue(g2).unwrap();
var g4w = g1w.makeDebuggeeValue(g4).unwrap();
var thisw = g1w.makeDebuggeeValue(this).unwrap();
// Check that they're all there.
assertEq(a.indexOf(g1w) != -1, true);
assertEq(a.indexOf(g2w) != -1, true);
assertEq(a.indexOf(g3w) != -1, true);
assertEq(a.indexOf(g4w) != -1, true);
assertEq(a.indexOf(thisw) != -1, true);

Просмотреть файл

@ -5,10 +5,11 @@ g.eval('function f(){}');
g.eval('function g(){}');
g.eval('function h(){}');
var dbg = new Debugger(g);
var fw = dbg.addDebuggee(g.f);
var gw = dbg.addDebuggee(g.g);
var hw = dbg.addDebuggee(g.h);
var dbg = new Debugger();
var gw = dbg.addDebuggee(g);
var fw = gw.makeDebuggeeValue(g.f);
var gw = gw.makeDebuggeeValue(g.g);
var hw = gw.makeDebuggeeValue(g.h);
assertEq(dbg.findScripts().indexOf(fw.script) != -1, true);
assertEq(dbg.findScripts().indexOf(gw.script) != -1, true);

Просмотреть файл

@ -1,12 +1,13 @@
// findScripts' result includes scripts for nested functions.
var g = newGlobal('new-compartment');
var dbg = new Debugger(g);
var dbg = new Debugger();
var gw = dbg.addDebuggee(g);
var log;
g.eval('function f() { return function g() { return function h() { return "Squee!"; } } }');
var fw = dbg.addDebuggee(g.f);
var gw = dbg.addDebuggee(g.f());
var hw = dbg.addDebuggee(g.f()());
var fw = gw.makeDebuggeeValue(g.f);
var gw = gw.makeDebuggeeValue(g.f());
var hw = gw.makeDebuggeeValue(g.f()());
assertEq(fw.script != gw.script, true);
assertEq(fw.script != hw.script, true);

Просмотреть файл

@ -1,11 +1,13 @@
// In a debugger with multiple debuggees, findScripts finds scripts across all debuggees.
var g1 = newGlobal('new-compartment');
var g2 = newGlobal('new-compartment');
var dbg = new Debugger(g1, g2);
var dbg = new Debugger();
var g1w = dbg.addDebuggee(g1);
var g2w = dbg.addDebuggee(g2);
g1.eval('function f() {}');
g2.eval('function g() {}');
var scripts = dbg.findScripts();
assertEq(scripts.indexOf(dbg.addDebuggee(g1.f).script) != -1, true);
assertEq(scripts.indexOf(dbg.addDebuggee(g2.g).script) != -1, true);
assertEq(scripts.indexOf(g1w.makeDebuggeeValue(g1.f).script) != -1, true);
assertEq(scripts.indexOf(g2w.makeDebuggeeValue(g2.g).script) != -1, true);

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше