зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 389b6bbd76db (bug 1519636) for bustages on MarkupMap.h . CLOSED TREE
This commit is contained in:
Родитель
2f1869451d
Коммит
24dbe577a5
|
@ -5,20 +5,20 @@
|
|||
* 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/. */
|
||||
|
||||
MARKUPMAP(
|
||||
a,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
// Only some roles truly enjoy life as HTMLLinkAccessibles, for
|
||||
// details see closed bug 494807.
|
||||
const nsRoleMapEntry* roleMapEntry = aria::GetRoleMap(aElement);
|
||||
if (roleMapEntry && roleMapEntry->role != roles::NOTHING &&
|
||||
roleMapEntry->role != roles::LINK) {
|
||||
return new HyperTextAccessibleWrap(aElement, aContext->Document());
|
||||
}
|
||||
MARKUPMAP(a,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
// Only some roles truly enjoy life as HTMLLinkAccessibles, for
|
||||
// details see closed bug 494807.
|
||||
const nsRoleMapEntry* roleMapEntry = aria::GetRoleMap(aElement);
|
||||
if (roleMapEntry && roleMapEntry->role != roles::NOTHING &&
|
||||
roleMapEntry->role != roles::LINK) {
|
||||
return new HyperTextAccessibleWrap(aElement,
|
||||
aContext->Document());
|
||||
}
|
||||
|
||||
return new HTMLLinkAccessible(aElement, aContext->Document());
|
||||
},
|
||||
roles::LINK);
|
||||
return new HTMLLinkAccessible(aElement, aContext->Document());
|
||||
},
|
||||
roles::LINK)
|
||||
|
||||
MARKUPMAP(abbr, New_HyperText, 0)
|
||||
|
||||
|
@ -30,27 +30,26 @@ MARKUPMAP(aside, New_HyperText, roles::LANDMARK)
|
|||
|
||||
MARKUPMAP(blockquote, New_HyperText, roles::BLOCKQUOTE)
|
||||
|
||||
MARKUPMAP(
|
||||
button,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
return new HTMLButtonAccessible(aElement, aContext->Document());
|
||||
},
|
||||
0)
|
||||
MARKUPMAP(button,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
return new HTMLButtonAccessible(aElement, aContext->Document());
|
||||
},
|
||||
0)
|
||||
|
||||
MARKUPMAP(
|
||||
caption,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
if (aContext->IsTable()) {
|
||||
dom::HTMLTableElement* tableEl =
|
||||
dom::HTMLTableElement::FromNode(aContext->GetContent());
|
||||
if (tableEl && tableEl == aElement->GetParent() &&
|
||||
tableEl->GetCaption() == aElement) {
|
||||
return new HTMLCaptionAccessible(aElement, aContext->Document());
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
},
|
||||
0)
|
||||
MARKUPMAP(caption,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
if (aContext->IsTable()) {
|
||||
dom::HTMLTableElement* tableEl =
|
||||
dom::HTMLTableElement::FromNode(aContext->GetContent());
|
||||
if (tableEl && tableEl == aElement->GetParent() &&
|
||||
tableEl->GetCaption() == aElement) {
|
||||
return new HTMLCaptionAccessible(aElement,
|
||||
aContext->Document());
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
},
|
||||
0)
|
||||
|
||||
MARKUPMAP(dd, New_HTMLDtOrDd<HyperTextAccessibleWrap>, roles::DEFINITION)
|
||||
|
||||
|
@ -121,56 +120,51 @@ MARKUPMAP(
|
|||
},
|
||||
roles::SECTION)
|
||||
|
||||
MARKUPMAP(
|
||||
dl,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
return new HTMLListAccessible(aElement, aContext->Document());
|
||||
},
|
||||
roles::DEFINITION_LIST)
|
||||
MARKUPMAP(dl,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
return new HTMLListAccessible(aElement, aContext->Document());
|
||||
},
|
||||
roles::DEFINITION_LIST)
|
||||
|
||||
MARKUPMAP(dt, New_HTMLDtOrDd<HTMLLIAccessible>, roles::TERM)
|
||||
|
||||
MARKUPMAP(
|
||||
figcaption,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
return new HTMLFigcaptionAccessible(aElement, aContext->Document());
|
||||
},
|
||||
roles::CAPTION)
|
||||
MARKUPMAP(figcaption,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
return new HTMLFigcaptionAccessible(aElement, aContext->Document());
|
||||
},
|
||||
roles::CAPTION)
|
||||
|
||||
MARKUPMAP(
|
||||
figure,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
return new HTMLFigureAccessible(aElement, aContext->Document());
|
||||
},
|
||||
roles::FIGURE, Attr(xmlroles, figure))
|
||||
MARKUPMAP(figure,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
return new HTMLFigureAccessible(aElement, aContext->Document());
|
||||
},
|
||||
roles::FIGURE, Attr(xmlroles, figure))
|
||||
|
||||
MARKUPMAP(
|
||||
fieldset,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
return new HTMLGroupboxAccessible(aElement, aContext->Document());
|
||||
},
|
||||
0)
|
||||
MARKUPMAP(fieldset,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
return new HTMLGroupboxAccessible(aElement, aContext->Document());
|
||||
},
|
||||
0)
|
||||
|
||||
MARKUPMAP(
|
||||
form,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
return new HTMLFormAccessible(aElement, aContext->Document());
|
||||
},
|
||||
0)
|
||||
MARKUPMAP(form,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
return new HTMLFormAccessible(aElement, aContext->Document());
|
||||
},
|
||||
0)
|
||||
|
||||
MARKUPMAP(
|
||||
footer,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
return new HTMLHeaderOrFooterAccessible(aElement, aContext->Document());
|
||||
},
|
||||
0)
|
||||
MARKUPMAP(footer,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
return new HTMLHeaderOrFooterAccessible(aElement,
|
||||
aContext->Document());
|
||||
},
|
||||
0)
|
||||
|
||||
MARKUPMAP(
|
||||
header,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
return new HTMLHeaderOrFooterAccessible(aElement, aContext->Document());
|
||||
},
|
||||
0)
|
||||
MARKUPMAP(header,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
return new HTMLHeaderOrFooterAccessible(aElement,
|
||||
aContext->Document());
|
||||
},
|
||||
0)
|
||||
|
||||
MARKUPMAP(h1, New_HyperText, roles::HEADING)
|
||||
|
||||
|
@ -184,75 +178,71 @@ MARKUPMAP(h5, New_HyperText, roles::HEADING)
|
|||
|
||||
MARKUPMAP(h6, New_HyperText, roles::HEADING)
|
||||
|
||||
MARKUPMAP(
|
||||
hr,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
return new HTMLHRAccessible(aElement, aContext->Document());
|
||||
},
|
||||
0)
|
||||
MARKUPMAP(hr,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
return new HTMLHRAccessible(aElement, aContext->Document());
|
||||
},
|
||||
0)
|
||||
|
||||
MARKUPMAP(
|
||||
input,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
// TODO(emilio): This would be faster if it used
|
||||
// HTMLInputElement's already-parsed representation.
|
||||
if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
|
||||
nsGkAtoms::checkbox, eIgnoreCase)) {
|
||||
return new CheckboxAccessible(aElement, aContext->Document());
|
||||
}
|
||||
if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
|
||||
nsGkAtoms::image, eIgnoreCase)) {
|
||||
return new HTMLButtonAccessible(aElement, aContext->Document());
|
||||
}
|
||||
if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
|
||||
nsGkAtoms::radio, eIgnoreCase)) {
|
||||
return new HTMLRadioButtonAccessible(aElement, aContext->Document());
|
||||
}
|
||||
if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
|
||||
nsGkAtoms::time, eIgnoreCase)) {
|
||||
return new EnumRoleAccessible<roles::GROUPING>(aElement,
|
||||
aContext->Document());
|
||||
}
|
||||
if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
|
||||
nsGkAtoms::date, eIgnoreCase)) {
|
||||
return new EnumRoleAccessible<roles::DATE_EDITOR>(aElement,
|
||||
aContext->Document());
|
||||
}
|
||||
return nullptr;
|
||||
},
|
||||
0)
|
||||
MARKUPMAP(input,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
// TODO(emilio): This would be faster if it used
|
||||
// HTMLInputElement's already-parsed representation.
|
||||
if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
|
||||
nsGkAtoms::checkbox, eIgnoreCase)) {
|
||||
return new CheckboxAccessible(aElement, aContext->Document());
|
||||
}
|
||||
if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
|
||||
nsGkAtoms::image, eIgnoreCase)) {
|
||||
return new HTMLButtonAccessible(aElement, aContext->Document());
|
||||
}
|
||||
if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
|
||||
nsGkAtoms::radio, eIgnoreCase)) {
|
||||
return new HTMLRadioButtonAccessible(aElement,
|
||||
aContext->Document());
|
||||
}
|
||||
if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
|
||||
nsGkAtoms::time, eIgnoreCase)) {
|
||||
return new EnumRoleAccessible<roles::GROUPING>(
|
||||
aElement, aContext->Document());
|
||||
}
|
||||
if (aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
|
||||
nsGkAtoms::date, eIgnoreCase)) {
|
||||
return new EnumRoleAccessible<roles::DATE_EDITOR>(
|
||||
aElement, aContext->Document());
|
||||
}
|
||||
return nullptr;
|
||||
},
|
||||
0)
|
||||
|
||||
MARKUPMAP(ins, New_HyperText, roles::CONTENT_INSERTION)
|
||||
|
||||
MARKUPMAP(
|
||||
label,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
return new HTMLLabelAccessible(aElement, aContext->Document());
|
||||
},
|
||||
roles::LABEL)
|
||||
MARKUPMAP(label,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
return new HTMLLabelAccessible(aElement, aContext->Document());
|
||||
},
|
||||
roles::LABEL)
|
||||
|
||||
MARKUPMAP(
|
||||
legend,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
return new HTMLLegendAccessible(aElement, aContext->Document());
|
||||
},
|
||||
roles::LABEL)
|
||||
MARKUPMAP(legend,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
return new HTMLLegendAccessible(aElement, aContext->Document());
|
||||
},
|
||||
roles::LABEL)
|
||||
|
||||
MARKUPMAP(
|
||||
li,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
// If list item is a child of accessible list then create an
|
||||
// accessible for it unconditionally by tag name. nsBlockFrame
|
||||
// creates the list item accessible for other elements styled as
|
||||
// list items.
|
||||
if (aContext->IsList() &&
|
||||
aContext->GetContent() == aElement->GetParent()) {
|
||||
return new HTMLLIAccessible(aElement, aContext->Document());
|
||||
}
|
||||
MARKUPMAP(li,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
// If list item is a child of accessible list then create an
|
||||
// accessible for it unconditionally by tag name. nsBlockFrame
|
||||
// creates the list item accessible for other elements styled as
|
||||
// list items.
|
||||
if (aContext->IsList() &&
|
||||
aContext->GetContent() == aElement->GetParent()) {
|
||||
return new HTMLLIAccessible(aElement, aContext->Document());
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
},
|
||||
0)
|
||||
return nullptr;
|
||||
},
|
||||
0)
|
||||
|
||||
MARKUPMAP(main, New_HyperText, roles::LANDMARK)
|
||||
|
||||
|
@ -311,34 +301,31 @@ MARKUPMAP(munderover_, New_HyperText, roles::MATHML_UNDER_OVER,
|
|||
|
||||
MARKUPMAP(mmultiscripts_, New_HyperText, roles::MATHML_MULTISCRIPTS)
|
||||
|
||||
MARKUPMAP(
|
||||
mtable_,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
return new HTMLTableAccessible(aElement, aContext->Document());
|
||||
},
|
||||
roles::MATHML_TABLE, AttrFromDOM(align, align),
|
||||
AttrFromDOM(columnlines_, columnlines_), AttrFromDOM(rowlines_, rowlines_))
|
||||
MARKUPMAP(mtable_,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
return new HTMLTableAccessible(aElement, aContext->Document());
|
||||
},
|
||||
roles::MATHML_TABLE, AttrFromDOM(align, align),
|
||||
AttrFromDOM(columnlines_, columnlines_),
|
||||
AttrFromDOM(rowlines_, rowlines_))
|
||||
|
||||
MARKUPMAP(
|
||||
mlabeledtr_,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
return new HTMLTableRowAccessible(aElement, aContext->Document());
|
||||
},
|
||||
roles::MATHML_LABELED_ROW)
|
||||
MARKUPMAP(mlabeledtr_,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
return new HTMLTableRowAccessible(aElement, aContext->Document());
|
||||
},
|
||||
roles::MATHML_LABELED_ROW)
|
||||
|
||||
MARKUPMAP(
|
||||
mtr_,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
return new HTMLTableRowAccessible(aElement, aContext->Document());
|
||||
},
|
||||
roles::MATHML_TABLE_ROW)
|
||||
MARKUPMAP(mtr_,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
return new HTMLTableRowAccessible(aElement, aContext->Document());
|
||||
},
|
||||
roles::MATHML_TABLE_ROW)
|
||||
|
||||
MARKUPMAP(
|
||||
mtd_,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
return new HTMLTableCellAccessible(aElement, aContext->Document());
|
||||
},
|
||||
roles::MATHML_CELL)
|
||||
MARKUPMAP(mtd_,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
return new HTMLTableCellAccessible(aElement, aContext->Document());
|
||||
},
|
||||
roles::MATHML_CELL)
|
||||
|
||||
MARKUPMAP(maction_, New_HyperText, roles::MATHML_ACTION,
|
||||
AttrFromDOM(actiontype_, actiontype_),
|
||||
|
@ -369,183 +356,173 @@ MARKUPMAP(msline_, New_HyperText, roles::MATHML_STACK_LINE,
|
|||
|
||||
MARKUPMAP(nav, New_HyperText, roles::LANDMARK)
|
||||
|
||||
MARKUPMAP(
|
||||
ol,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
return new HTMLListAccessible(aElement, aContext->Document());
|
||||
},
|
||||
roles::LIST)
|
||||
MARKUPMAP(ol,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
return new HTMLListAccessible(aElement, aContext->Document());
|
||||
},
|
||||
roles::LIST)
|
||||
|
||||
MARKUPMAP(
|
||||
option,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
return new HTMLSelectOptionAccessible(aElement, aContext->Document());
|
||||
},
|
||||
0)
|
||||
MARKUPMAP(option,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
return new HTMLSelectOptionAccessible(aElement,
|
||||
aContext->Document());
|
||||
},
|
||||
0)
|
||||
|
||||
MARKUPMAP(
|
||||
optgroup,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
return new HTMLSelectOptGroupAccessible(aElement, aContext->Document());
|
||||
},
|
||||
0)
|
||||
MARKUPMAP(optgroup,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
return new HTMLSelectOptGroupAccessible(aElement,
|
||||
aContext->Document());
|
||||
},
|
||||
0)
|
||||
|
||||
MARKUPMAP(
|
||||
output,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
return new HTMLOutputAccessible(aElement, aContext->Document());
|
||||
},
|
||||
roles::SECTION, Attr(live, polite))
|
||||
MARKUPMAP(output,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
return new HTMLOutputAccessible(aElement, aContext->Document());
|
||||
},
|
||||
roles::SECTION, Attr(live, polite))
|
||||
|
||||
MARKUPMAP(p, nullptr, roles::PARAGRAPH)
|
||||
|
||||
MARKUPMAP(
|
||||
progress,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
return new HTMLProgressAccessible(aElement, aContext->Document());
|
||||
},
|
||||
0)
|
||||
MARKUPMAP(progress,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
return new HTMLProgressAccessible(aElement, aContext->Document());
|
||||
},
|
||||
0)
|
||||
|
||||
MARKUPMAP(q, New_HyperText, 0)
|
||||
|
||||
MARKUPMAP(
|
||||
section,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
return new HTMLSectionAccessible(aElement, aContext->Document());
|
||||
},
|
||||
0)
|
||||
MARKUPMAP(section,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
return new HTMLSectionAccessible(aElement, aContext->Document());
|
||||
},
|
||||
0)
|
||||
|
||||
MARKUPMAP(
|
||||
summary,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
return new HTMLSummaryAccessible(aElement, aContext->Document());
|
||||
},
|
||||
roles::SUMMARY)
|
||||
MARKUPMAP(summary,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
return new HTMLSummaryAccessible(aElement, aContext->Document());
|
||||
},
|
||||
roles::SUMMARY)
|
||||
|
||||
MARKUPMAP(
|
||||
table,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
if (aElement->GetPrimaryFrame() &&
|
||||
aElement->GetPrimaryFrame()->AccessibleType() != eHTMLTableType) {
|
||||
return new ARIAGridAccessibleWrap(aElement, aContext->Document());
|
||||
}
|
||||
return nullptr;
|
||||
},
|
||||
0)
|
||||
MARKUPMAP(table,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
if (aElement->GetPrimaryFrame() &&
|
||||
aElement->GetPrimaryFrame()->AccessibleType() !=
|
||||
eHTMLTableType) {
|
||||
return new ARIAGridAccessibleWrap(aElement, aContext->Document());
|
||||
}
|
||||
return nullptr;
|
||||
},
|
||||
0)
|
||||
|
||||
MARKUPMAP(time, New_HyperText, 0, Attr(xmlroles, time),
|
||||
AttrFromDOM(datetime, datetime))
|
||||
|
||||
MARKUPMAP(
|
||||
tbody,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
// Expose this as a grouping if its frame type is non-standard.
|
||||
if (aElement->GetPrimaryFrame() &&
|
||||
aElement->GetPrimaryFrame()->IsTableRowGroupFrame()) {
|
||||
return nullptr;
|
||||
}
|
||||
return new HyperTextAccessibleWrap(aElement, aContext->Document());
|
||||
},
|
||||
roles::GROUPING)
|
||||
MARKUPMAP(tbody,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
// Expose this as a grouping if its frame type is non-standard.
|
||||
if (aElement->GetPrimaryFrame() &&
|
||||
aElement->GetPrimaryFrame()->IsTableRowGroupFrame()) {
|
||||
return nullptr;
|
||||
}
|
||||
return new HyperTextAccessibleWrap(aElement, aContext->Document());
|
||||
},
|
||||
roles::GROUPING)
|
||||
|
||||
MARKUPMAP(
|
||||
td,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
if (aContext->IsTableRow() &&
|
||||
aContext->GetContent() == aElement->GetParent()) {
|
||||
// If HTML:td element is part of its HTML:table, which has CSS
|
||||
// display style other than 'table', then create a generic table
|
||||
// cell accessible, because there's no underlying table layout and
|
||||
// thus native HTML table cell class doesn't work. The same is
|
||||
// true if the cell itself has CSS display:block;.
|
||||
if (!aContext->IsHTMLTableRow() ||
|
||||
(aElement->GetPrimaryFrame() &&
|
||||
aElement->GetPrimaryFrame()->AccessibleType() !=
|
||||
eHTMLTableCellType)) {
|
||||
return new ARIAGridCellAccessibleWrap(aElement, aContext->Document());
|
||||
}
|
||||
if (aElement->HasAttr(kNameSpaceID_None, nsGkAtoms::scope)) {
|
||||
return new HTMLTableHeaderCellAccessibleWrap(aElement,
|
||||
aContext->Document());
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
},
|
||||
0)
|
||||
MARKUPMAP(td,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
if (aContext->IsTableRow() &&
|
||||
aContext->GetContent() == aElement->GetParent()) {
|
||||
// If HTML:td element is part of its HTML:table, which has CSS
|
||||
// display style other than 'table', then create a generic table
|
||||
// cell accessible, because there's no underlying table layout and
|
||||
// thus native HTML table cell class doesn't work. The same is
|
||||
// true if the cell itself has CSS display:block;.
|
||||
if (!aContext->IsHTMLTableRow() ||
|
||||
(aElement->GetPrimaryFrame() &&
|
||||
aElement->GetPrimaryFrame()->AccessibleType() !=
|
||||
eHTMLTableCellType)) {
|
||||
return new ARIAGridCellAccessibleWrap(aElement,
|
||||
aContext->Document());
|
||||
}
|
||||
if (aElement->HasAttr(kNameSpaceID_None, nsGkAtoms::scope)) {
|
||||
return new HTMLTableHeaderCellAccessibleWrap(
|
||||
aElement, aContext->Document());
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
},
|
||||
0)
|
||||
|
||||
MARKUPMAP(
|
||||
tfoot,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
// Expose this as a grouping if its frame type is non-standard.
|
||||
if (aElement->GetPrimaryFrame() &&
|
||||
aElement->GetPrimaryFrame()->IsTableRowGroupFrame()) {
|
||||
return nullptr;
|
||||
}
|
||||
return new HyperTextAccessibleWrap(aElement, aContext->Document());
|
||||
},
|
||||
roles::GROUPING)
|
||||
MARKUPMAP(tfoot,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
// Expose this as a grouping if its frame type is non-standard.
|
||||
if (aElement->GetPrimaryFrame() &&
|
||||
aElement->GetPrimaryFrame()->IsTableRowGroupFrame()) {
|
||||
return nullptr;
|
||||
}
|
||||
return new HyperTextAccessibleWrap(aElement, aContext->Document());
|
||||
},
|
||||
roles::GROUPING)
|
||||
|
||||
MARKUPMAP(
|
||||
th,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
if (aContext->IsTableRow() &&
|
||||
aContext->GetContent() == aElement->GetParent()) {
|
||||
if (!aContext->IsHTMLTableRow()) {
|
||||
return new ARIAGridCellAccessibleWrap(aElement, aContext->Document());
|
||||
}
|
||||
return new HTMLTableHeaderCellAccessibleWrap(aElement,
|
||||
aContext->Document());
|
||||
}
|
||||
return nullptr;
|
||||
},
|
||||
0)
|
||||
MARKUPMAP(th,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
if (aContext->IsTableRow() &&
|
||||
aContext->GetContent() == aElement->GetParent()) {
|
||||
if (!aContext->IsHTMLTableRow()) {
|
||||
return new ARIAGridCellAccessibleWrap(aElement,
|
||||
aContext->Document());
|
||||
}
|
||||
return new HTMLTableHeaderCellAccessibleWrap(
|
||||
aElement, aContext->Document());
|
||||
}
|
||||
return nullptr;
|
||||
},
|
||||
0)
|
||||
|
||||
MARKUPMAP(
|
||||
tfoot,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
// Expose this as a grouping if its frame type is non-standard.
|
||||
if (aElement->GetPrimaryFrame() &&
|
||||
aElement->GetPrimaryFrame()->IsTableRowGroupFrame()) {
|
||||
return nullptr;
|
||||
}
|
||||
return new HyperTextAccessibleWrap(aElement, aContext->Document());
|
||||
},
|
||||
roles::GROUPING)
|
||||
MARKUPMAP(tfoot,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
// Expose this as a grouping if its frame type is non-standard.
|
||||
if (aElement->GetPrimaryFrame() &&
|
||||
aElement->GetPrimaryFrame()->IsTableRowGroupFrame()) {
|
||||
return nullptr;
|
||||
}
|
||||
return new HyperTextAccessibleWrap(aElement, aContext->Document());
|
||||
},
|
||||
roles::GROUPING)
|
||||
|
||||
MARKUPMAP(
|
||||
tr,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
// If HTML:tr element is part of its HTML:table, which has CSS
|
||||
// display style other than 'table', then create a generic table row
|
||||
// accessible, because there's no underlying table layout and thus
|
||||
// native HTML table row class doesn't work. Refer to
|
||||
// CreateAccessibleByFrameType dual logic.
|
||||
Accessible* table = aContext->IsTable() ? aContext : nullptr;
|
||||
if (!table && aContext->Parent() && aContext->Parent()->IsTable()) {
|
||||
table = aContext->Parent();
|
||||
}
|
||||
if (table) {
|
||||
nsIContent* parentContent = aElement->GetParent();
|
||||
nsIFrame* parentFrame = parentContent->GetPrimaryFrame();
|
||||
if (parentFrame && !parentFrame->IsTableWrapperFrame()) {
|
||||
parentContent = parentContent->GetParent();
|
||||
parentFrame = parentContent->GetPrimaryFrame();
|
||||
if (table->GetContent() == parentContent &&
|
||||
((parentFrame && !parentFrame->IsTableWrapperFrame()) ||
|
||||
(aElement->GetPrimaryFrame() &&
|
||||
aElement->GetPrimaryFrame()->AccessibleType() !=
|
||||
eHTMLTableRowType))) {
|
||||
return new ARIARowAccessible(aElement, aContext->Document());
|
||||
}
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
},
|
||||
0)
|
||||
MARKUPMAP(tr,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
// If HTML:tr element is part of its HTML:table, which has CSS
|
||||
// display style other than 'table', then create a generic table row
|
||||
// accessible, because there's no underlying table layout and thus
|
||||
// native HTML table row class doesn't work. Refer to
|
||||
// CreateAccessibleByFrameType dual logic.
|
||||
Accessible* table = aContext->IsTable() ? aContext : nullptr;
|
||||
if (!table && aContext->Parent() && aContext->Parent()->IsTable()) {
|
||||
table = aContext->Parent();
|
||||
}
|
||||
if (table) {
|
||||
nsIContent* parentContent = aElement->GetParent();
|
||||
nsIFrame* parentFrame = parentContent->GetPrimaryFrame();
|
||||
if (parentFrame && !parentFrame->IsTableWrapperFrame()) {
|
||||
parentContent = parentContent->GetParent();
|
||||
parentFrame = parentContent->GetPrimaryFrame();
|
||||
if (table->GetContent() == parentContent &&
|
||||
((parentFrame && !parentFrame->IsTableWrapperFrame()) ||
|
||||
(aElement->GetPrimaryFrame() &&
|
||||
aElement->GetPrimaryFrame()->AccessibleType() !=
|
||||
eHTMLTableRowType))) {
|
||||
return new ARIARowAccessible(aElement, aContext->Document());
|
||||
}
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
},
|
||||
0)
|
||||
|
||||
MARKUPMAP(
|
||||
ul,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
return new HTMLListAccessible(aElement, aContext->Document());
|
||||
},
|
||||
roles::LIST)
|
||||
MARKUPMAP(ul,
|
||||
[](Element* aElement, Accessible* aContext) -> Accessible* {
|
||||
return new HTMLListAccessible(aElement, aContext->Document());
|
||||
},
|
||||
roles::LIST)
|
||||
|
|
|
@ -17,20 +17,17 @@ static void TestSuffix(const OriginAttributes& attrs) {
|
|||
EXPECT_EQ(attrs, attrsFromSuffix);
|
||||
}
|
||||
|
||||
TEST(OriginAttributes, Suffix_default)
|
||||
{
|
||||
TEST(OriginAttributes, Suffix_default) {
|
||||
OriginAttributes attrs;
|
||||
TestSuffix(attrs);
|
||||
}
|
||||
|
||||
TEST(OriginAttributes, Suffix_appId_inIsolatedMozBrowser)
|
||||
{
|
||||
TEST(OriginAttributes, Suffix_appId_inIsolatedMozBrowser) {
|
||||
OriginAttributes attrs(1, true);
|
||||
TestSuffix(attrs);
|
||||
}
|
||||
|
||||
TEST(OriginAttributes, Suffix_maxAppId_inIsolatedMozBrowser)
|
||||
{
|
||||
TEST(OriginAttributes, Suffix_maxAppId_inIsolatedMozBrowser) {
|
||||
OriginAttributes attrs(4294967295, true);
|
||||
TestSuffix(attrs);
|
||||
}
|
||||
|
|
|
@ -197,7 +197,8 @@ void AnonymousContent::GetComputedStylePropertyValue(
|
|||
aRv = cs->GetPropertyValue(aPropertyName, aResult);
|
||||
}
|
||||
|
||||
void AnonymousContent::GetTargetIdForEvent(Event& aEvent, DOMString& aResult) {
|
||||
void AnonymousContent::GetTargetIdForEvent(Event& aEvent, DOMString& aResult)
|
||||
{
|
||||
nsCOMPtr<Element> el = do_QueryInterface(aEvent.GetOriginalTarget());
|
||||
if (el && el->IsInNativeAnonymousSubtree() && mContentNode->Contains(el)) {
|
||||
aResult.SetKnownLiveAtom(el->GetID(), DOMString::eTreatNullAsNull);
|
||||
|
|
|
@ -143,21 +143,20 @@ RefPtr<PerformanceInfoPromise> DocGroup::ReportPerformanceInfo() {
|
|||
RefPtr<DocGroup> self = this;
|
||||
|
||||
return CollectMemoryInfo(top, mainThread)
|
||||
->Then(
|
||||
mainThread, __func__,
|
||||
[self, host, pid, windowID, duration, isTopLevel,
|
||||
items](const PerformanceMemoryInfo& aMemoryInfo) {
|
||||
PerformanceInfo info =
|
||||
PerformanceInfo(host, pid, windowID, duration,
|
||||
self->mPerformanceCounter->GetID(), false,
|
||||
isTopLevel, aMemoryInfo, items);
|
||||
->Then(mainThread, __func__,
|
||||
[self, host, pid, windowID, duration, isTopLevel,
|
||||
items](const PerformanceMemoryInfo& aMemoryInfo) {
|
||||
PerformanceInfo info =
|
||||
PerformanceInfo(host, pid, windowID, duration,
|
||||
self->mPerformanceCounter->GetID(), false,
|
||||
isTopLevel, aMemoryInfo, items);
|
||||
|
||||
return PerformanceInfoPromise::CreateAndResolve(std::move(info),
|
||||
__func__);
|
||||
},
|
||||
[self](const nsresult rv) {
|
||||
return PerformanceInfoPromise::CreateAndReject(rv, __func__);
|
||||
});
|
||||
return PerformanceInfoPromise::CreateAndResolve(std::move(info),
|
||||
__func__);
|
||||
},
|
||||
[self](const nsresult rv) {
|
||||
return PerformanceInfoPromise::CreateAndReject(rv, __func__);
|
||||
});
|
||||
}
|
||||
|
||||
nsresult DocGroup::Dispatch(TaskCategory aCategory,
|
||||
|
|
|
@ -12621,20 +12621,19 @@ already_AddRefed<mozilla::dom::Promise> Document::RequestStorageAccess(
|
|||
AntiTrackingCommon::AddFirstPartyStorageAccessGrantedFor(
|
||||
NodePrincipal(), inner, AntiTrackingCommon::eStorageAccessAPI,
|
||||
performFinalChecks)
|
||||
->Then(
|
||||
GetCurrentThreadSerialEventTarget(), __func__,
|
||||
[outer, promise] {
|
||||
// Step 10. Grant the document access to cookies and store
|
||||
// that fact for
|
||||
// the purposes of future calls to
|
||||
// hasStorageAccess() and requestStorageAccess().
|
||||
outer->SetHasStorageAccess(true);
|
||||
promise->MaybeResolveWithUndefined();
|
||||
},
|
||||
[outer, promise] {
|
||||
outer->SetHasStorageAccess(false);
|
||||
promise->MaybeRejectWithUndefined();
|
||||
});
|
||||
->Then(GetCurrentThreadSerialEventTarget(), __func__,
|
||||
[outer, promise] {
|
||||
// Step 10. Grant the document access to cookies and store
|
||||
// that fact for
|
||||
// the purposes of future calls to
|
||||
// hasStorageAccess() and requestStorageAccess().
|
||||
outer->SetHasStorageAccess(true);
|
||||
promise->MaybeResolveWithUndefined();
|
||||
},
|
||||
[outer, promise] {
|
||||
outer->SetHasStorageAccess(false);
|
||||
promise->MaybeRejectWithUndefined();
|
||||
});
|
||||
|
||||
return promise.forget();
|
||||
}
|
||||
|
|
|
@ -47,7 +47,8 @@ size_t TreeOrderedArray<Node>::Insert(Node& aNode) {
|
|||
};
|
||||
|
||||
size_t idx;
|
||||
BinarySearchIf(mList, 0, mList.Length(), PositionComparator(aNode), &idx);
|
||||
BinarySearchIf(mList, 0, mList.Length(),
|
||||
PositionComparator(aNode), &idx);
|
||||
mList.InsertElementAt(idx, &aNode);
|
||||
return idx;
|
||||
}
|
||||
|
|
|
@ -51,7 +51,8 @@ void OnPrefChange(const char* aPrefName, void*) {
|
|||
void UIDirectionManager::Initialize() {
|
||||
DebugOnly<nsresult> rv =
|
||||
Preferences::RegisterCallback(OnPrefChange, "intl.uidirection");
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv), "Failed to observe \"intl.uidirection\"");
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv),
|
||||
"Failed to observe \"intl.uidirection\"");
|
||||
}
|
||||
|
||||
/* static */
|
||||
|
|
|
@ -1645,9 +1645,7 @@ MiscContainer* nsAttrValue::ClearMiscContainer() {
|
|||
delete cont->mValue.mIntMargin;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
default: { break; }
|
||||
}
|
||||
}
|
||||
ResetMiscAtomOrString();
|
||||
|
|
|
@ -242,9 +242,7 @@ inline void nsAttrValue::ToString(mozilla::dom::DOMString& aResult) const {
|
|||
aResult.SetKnownLiveAtom(atom, mozilla::dom::DOMString::eNullNotExpected);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
ToString(aResult.AsAString());
|
||||
}
|
||||
default: { ToString(aResult.AsAString()); }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -426,9 +426,7 @@ nsresult nsCCUncollectableMarker::Observe(nsISupports* aSubject,
|
|||
xpc_UnmarkSkippableJSHolders();
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
default: { break; }
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
|
|
@ -11,8 +11,7 @@
|
|||
#include "mozilla/CycleCollectedJSContext.h"
|
||||
#include "mozilla/dom/SimpleGlobalObject.h"
|
||||
|
||||
TEST(DOM_Base_ContentUtils, StringifyJSON_EmptyValue)
|
||||
{
|
||||
TEST(DOM_Base_ContentUtils, StringifyJSON_EmptyValue) {
|
||||
JSObject* globalObject = mozilla::dom::SimpleGlobalObject::Create(
|
||||
mozilla::dom::SimpleGlobalObject::GlobalType::BindingDetail);
|
||||
mozilla::dom::AutoJSAPI jsAPI;
|
||||
|
@ -26,8 +25,7 @@ TEST(DOM_Base_ContentUtils, StringifyJSON_EmptyValue)
|
|||
ASSERT_TRUE(serializedValue.EqualsLiteral("null"));
|
||||
}
|
||||
|
||||
TEST(DOM_Base_ContentUtils, StringifyJSON_Object)
|
||||
{
|
||||
TEST(DOM_Base_ContentUtils, StringifyJSON_Object) {
|
||||
JSObject* globalObject = mozilla::dom::SimpleGlobalObject::Create(
|
||||
mozilla::dom::SimpleGlobalObject::GlobalType::BindingDetail);
|
||||
mozilla::dom::AutoJSAPI jsAPI;
|
||||
|
|
|
@ -11,688 +11,576 @@
|
|||
|
||||
using mozilla::UniquePtr;
|
||||
|
||||
TEST(MimeType, EmptyString)
|
||||
{
|
||||
TEST(MimeType, EmptyString) {
|
||||
const auto in = NS_LITERAL_STRING("");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_FALSE(parsed) << "Empty string";
|
||||
}
|
||||
|
||||
TEST(MimeType, JustWhitespace)
|
||||
{
|
||||
TEST(MimeType, JustWhitespace) {
|
||||
const auto in = NS_LITERAL_STRING(" \t\r\n ");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_FALSE(parsed) << "Just whitespace";
|
||||
}
|
||||
|
||||
TEST(MimeType, JustBackslash)
|
||||
{
|
||||
TEST(MimeType, JustBackslash) {
|
||||
const auto in = NS_LITERAL_STRING("\\");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_FALSE(parsed) << "Just backslash";
|
||||
}
|
||||
|
||||
TEST(MimeType, JustForwardslash)
|
||||
{
|
||||
TEST(MimeType, JustForwardslash) {
|
||||
const auto in = NS_LITERAL_STRING("/");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_FALSE(parsed) << "Just forward slash";
|
||||
}
|
||||
|
||||
TEST(MimeType, MissingType1)
|
||||
{
|
||||
TEST(MimeType, MissingType1) {
|
||||
const auto in = NS_LITERAL_STRING("/bogus");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_FALSE(parsed) << "Missing type #1";
|
||||
}
|
||||
|
||||
TEST(MimeType, MissingType2)
|
||||
{
|
||||
TEST(MimeType, MissingType2) {
|
||||
const auto in = NS_LITERAL_STRING(" \r\n\t/bogus");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_FALSE(parsed) << "Missing type #2";
|
||||
}
|
||||
|
||||
TEST(MimeType, MissingSubtype1)
|
||||
{
|
||||
TEST(MimeType, MissingSubtype1) {
|
||||
const auto in = NS_LITERAL_STRING("bogus");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_FALSE(parsed) << "Missing subtype #1";
|
||||
}
|
||||
|
||||
TEST(MimeType, MissingSubType2)
|
||||
{
|
||||
TEST(MimeType, MissingSubType2) {
|
||||
const auto in = NS_LITERAL_STRING("bogus/");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_FALSE(parsed) << "Missing subtype #2";
|
||||
}
|
||||
|
||||
TEST(MimeType, MissingSubType3)
|
||||
{
|
||||
TEST(MimeType, MissingSubType3) {
|
||||
const auto in = NS_LITERAL_STRING("bogus;");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_FALSE(parsed) << "Missing subtype #3";
|
||||
}
|
||||
|
||||
TEST(MimeType, MissingSubType4)
|
||||
{
|
||||
TEST(MimeType, MissingSubType4) {
|
||||
const auto in = NS_LITERAL_STRING("bogus; \r\n\t");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_FALSE(parsed) << "Missing subtype #3";
|
||||
}
|
||||
|
||||
TEST(MimeType, ExtraForwardSlash)
|
||||
{
|
||||
TEST(MimeType, ExtraForwardSlash) {
|
||||
const auto in = NS_LITERAL_STRING("bogus/bogus/;");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_FALSE(parsed) << "Extra forward slash";
|
||||
}
|
||||
|
||||
TEST(MimeType, WhitespaceInType)
|
||||
{
|
||||
TEST(MimeType, WhitespaceInType) {
|
||||
const auto in = NS_LITERAL_STRING("t\re\nx\tt /html");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_FALSE(parsed) << "Type with whitespace";
|
||||
}
|
||||
|
||||
TEST(MimeType, WhitespaceInSubtype)
|
||||
{
|
||||
TEST(MimeType, WhitespaceInSubtype) {
|
||||
const auto in = NS_LITERAL_STRING("text/ h\rt\nm\tl");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_FALSE(parsed) << "Subtype with whitespace";
|
||||
}
|
||||
|
||||
TEST(MimeType, NonAlphanumericMediaType1)
|
||||
{
|
||||
TEST(MimeType, NonAlphanumericMediaType1) {
|
||||
const auto in = NS_LITERAL_STRING("</>");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_FALSE(parsed) << "Non-alphanumeric media type #1";
|
||||
}
|
||||
|
||||
TEST(MimeType, NonAlphanumericMediaType2)
|
||||
{
|
||||
TEST(MimeType, NonAlphanumericMediaType2) {
|
||||
const auto in = NS_LITERAL_STRING("(/)");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_FALSE(parsed) << "Non-alphanumeric media type #2";
|
||||
}
|
||||
|
||||
TEST(MimeType, NonAlphanumericMediaType3)
|
||||
{
|
||||
TEST(MimeType, NonAlphanumericMediaType3) {
|
||||
const auto in = NS_LITERAL_STRING("{/}");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_FALSE(parsed) << "Non-alphanumeric media type #3";
|
||||
}
|
||||
|
||||
TEST(MimeType, NonAlphanumericMediaType4)
|
||||
{
|
||||
TEST(MimeType, NonAlphanumericMediaType4) {
|
||||
const auto in = NS_LITERAL_STRING("\"/\"");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_FALSE(parsed) << "Non-alphanumeric media type #4";
|
||||
}
|
||||
|
||||
TEST(MimeType, NonAlphanumericMediaType5)
|
||||
{
|
||||
TEST(MimeType, NonAlphanumericMediaType5) {
|
||||
const auto in = NS_LITERAL_STRING("\0/\0");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_FALSE(parsed) << "Non-alphanumeric media type #5";
|
||||
}
|
||||
|
||||
TEST(MimeType, NonAlphanumericMediaType6)
|
||||
{
|
||||
TEST(MimeType, NonAlphanumericMediaType6) {
|
||||
const auto in = NS_LITERAL_STRING("text/html(;doesnot=matter");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_FALSE(parsed) << "Non-alphanumeric media type #6";
|
||||
}
|
||||
|
||||
TEST(MimeType, NonLatin1MediaType1)
|
||||
{
|
||||
TEST(MimeType, NonLatin1MediaType1) {
|
||||
const auto in = NS_LITERAL_STRING("ÿ/ÿ");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_FALSE(parsed) << "Non-latin1 media type #1";
|
||||
}
|
||||
|
||||
TEST(MimeType, NonLatin1MediaType2)
|
||||
{
|
||||
TEST(MimeType, NonLatin1MediaType2) {
|
||||
const auto in = NS_LITERAL_STRING(u"\x0100/\x0100");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_FALSE(parsed) << "Non-latin1 media type #2";
|
||||
}
|
||||
|
||||
TEST(MimeType, MultipleParameters)
|
||||
{
|
||||
TEST(MimeType, MultipleParameters) {
|
||||
const auto in =
|
||||
NS_LITERAL_STRING("text/html;charset=gbk;no=1;charset_=gbk_;yes=2");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
ASSERT_TRUE(parsed) << "Parsing succeeded";
|
||||
nsString out;
|
||||
parsed->Serialize(out);
|
||||
ASSERT_TRUE(out.Equals(
|
||||
NS_LITERAL_STRING("text/html;charset=gbk;no=1;charset_=gbk_;yes=2")))
|
||||
<< "Multiple parameters";
|
||||
<< "Multiple parameters";
|
||||
}
|
||||
|
||||
TEST(MimeType, DuplicateParameter1)
|
||||
{
|
||||
TEST(MimeType, DuplicateParameter1) {
|
||||
const auto in =
|
||||
NS_LITERAL_STRING("text/html;charset=gbk;charset=windows-1255");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
ASSERT_TRUE(parsed) << "Parsing succeeded";
|
||||
nsString out;
|
||||
parsed->Serialize(out);
|
||||
ASSERT_TRUE(out.Equals(NS_LITERAL_STRING("text/html;charset=gbk")))
|
||||
<< "Duplicate parameter #1";
|
||||
<< "Duplicate parameter #1";
|
||||
}
|
||||
|
||||
TEST(MimeType, DuplicateParameter2)
|
||||
{
|
||||
TEST(MimeType, DuplicateParameter2) {
|
||||
const auto in = NS_LITERAL_STRING("text/html;charset=();charset=GBK");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
ASSERT_TRUE(parsed) << "Parsing succeeded";
|
||||
nsString out;
|
||||
parsed->Serialize(out);
|
||||
ASSERT_TRUE(out.Equals(NS_LITERAL_STRING("text/html;charset=\"()\"")))
|
||||
<< "Duplicate parameter #2";
|
||||
<< "Duplicate parameter #2";
|
||||
}
|
||||
|
||||
TEST(MimeType, CString)
|
||||
{
|
||||
TEST(MimeType, CString) {
|
||||
const auto in = NS_LITERAL_CSTRING("text/html;charset=();charset=GBK");
|
||||
UniquePtr<CMimeType> parsed = CMimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
ASSERT_TRUE(parsed) << "Parsing succeeded";
|
||||
nsCString out;
|
||||
parsed->Serialize(out);
|
||||
ASSERT_TRUE(out.Equals(NS_LITERAL_CSTRING("text/html;charset=\"()\"")))
|
||||
<< "Duplicate parameter #2";
|
||||
<< "Duplicate parameter #2";
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable : 4819)
|
||||
#endif
|
||||
TEST(MimeType, NonAlphanumericParametersAreQuoted)
|
||||
{
|
||||
TEST(MimeType, NonAlphanumericParametersAreQuoted) {
|
||||
const auto in = NS_LITERAL_STRING("text/html;test=\x00FF\\;charset=gbk");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
ASSERT_TRUE(parsed) << "Parsing succeeded";
|
||||
nsString out;
|
||||
parsed->Serialize(out);
|
||||
ASSERT_TRUE(out.Equals(
|
||||
NS_LITERAL_STRING("text/html;test=\"\x00FF\\\\\";charset=gbk")))
|
||||
<< "Non-alphanumeric parameters are quoted";
|
||||
<< "Non-alphanumeric parameters are quoted";
|
||||
}
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
TEST(MimeType, ParameterQuotedIfHasLeadingWhitespace1)
|
||||
{
|
||||
TEST(MimeType, ParameterQuotedIfHasLeadingWhitespace1) {
|
||||
const auto in = NS_LITERAL_STRING("text/html;charset= g\\\"bk");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
ASSERT_TRUE(parsed) << "Parsing succeeded";
|
||||
nsAutoString out;
|
||||
parsed->Serialize(out);
|
||||
ASSERT_TRUE(out.EqualsLiteral("text/html;charset=\" g\\\\\\\"bk\""))
|
||||
<< "Parameter is quoted if has leading whitespace #1";
|
||||
<< "Parameter is quoted if has leading whitespace #1";
|
||||
}
|
||||
|
||||
TEST(MimeType, ParameterQuotedIfHasLeadingWhitespace2)
|
||||
{
|
||||
TEST(MimeType, ParameterQuotedIfHasLeadingWhitespace2) {
|
||||
const auto in = NS_LITERAL_STRING("text/html;charset= \"g\\bk\"");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
ASSERT_TRUE(parsed) << "Parsing succeeded";
|
||||
nsAutoString out;
|
||||
parsed->Serialize(out);
|
||||
ASSERT_TRUE(out.EqualsLiteral("text/html;charset=\" \\\"g\\\\bk\\\"\""))
|
||||
<< "Parameter is quoted if has leading whitespace #2";
|
||||
<< "Parameter is quoted if has leading whitespace #2";
|
||||
}
|
||||
|
||||
TEST(MimeType, ParameterQuotedIfHasInternalWhitespace)
|
||||
{
|
||||
TEST(MimeType, ParameterQuotedIfHasInternalWhitespace) {
|
||||
const auto in = NS_LITERAL_STRING("text/html;charset=g \\b\"k");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
ASSERT_TRUE(parsed) << "Parsing succeeded";
|
||||
nsAutoString out;
|
||||
parsed->Serialize(out);
|
||||
ASSERT_TRUE(out.EqualsLiteral("text/html;charset=\"g \\\\b\\\"k\""))
|
||||
<< "Parameter is quoted if has internal whitespace";
|
||||
<< "Parameter is quoted if has internal whitespace";
|
||||
}
|
||||
|
||||
TEST(MimeType, ImproperlyQuotedParameter1)
|
||||
{
|
||||
TEST(MimeType, ImproperlyQuotedParameter1) {
|
||||
const auto in = NS_LITERAL_STRING("x/x;test=\"");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
ASSERT_TRUE(parsed) << "Parsing succeeded";
|
||||
nsAutoString out;
|
||||
parsed->Serialize(out);
|
||||
ASSERT_TRUE(out.EqualsLiteral("x/x;test=\"\""))
|
||||
<< "Improperly-quoted parameter is handled properly #1";
|
||||
<< "Improperly-quoted parameter is handled properly #1";
|
||||
}
|
||||
|
||||
TEST(MimeType, ImproperlyQuotedParameter2)
|
||||
{
|
||||
TEST(MimeType, ImproperlyQuotedParameter2) {
|
||||
const auto in = NS_LITERAL_STRING("x/x;test=\"\\");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
ASSERT_TRUE(parsed) << "Parsing succeeded";
|
||||
nsAutoString out;
|
||||
parsed->Serialize(out);
|
||||
ASSERT_TRUE(out.EqualsLiteral("x/x;test=\"\\\\\""))
|
||||
<< "Improperly-quoted parameter is handled properly #2";
|
||||
<< "Improperly-quoted parameter is handled properly #2";
|
||||
}
|
||||
|
||||
TEST(MimeType, NonLatin1ParameterIgnored)
|
||||
{
|
||||
TEST(MimeType, NonLatin1ParameterIgnored) {
|
||||
const auto in = NS_LITERAL_STRING(u"x/x;test=\xFFFD;x=x");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
ASSERT_TRUE(parsed) << "Parsing succeeded";
|
||||
nsAutoString out;
|
||||
parsed->Serialize(out);
|
||||
ASSERT_TRUE(out.EqualsLiteral("x/x;x=x"))
|
||||
<< "Non latin-1 parameters are ignored";
|
||||
<< "Non latin-1 parameters are ignored";
|
||||
}
|
||||
|
||||
TEST(MimeType, ParameterIgnoredIfWhitespaceInName1)
|
||||
{
|
||||
TEST(MimeType, ParameterIgnoredIfWhitespaceInName1) {
|
||||
const auto in = NS_LITERAL_STRING("text/html;charset =gbk;charset=123");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
ASSERT_TRUE(parsed) << "Parsing succeeded";
|
||||
nsAutoString out;
|
||||
parsed->Serialize(out);
|
||||
ASSERT_TRUE(out.EqualsLiteral("text/html;charset=123"))
|
||||
<< "Parameter ignored if whitespace in name #1";
|
||||
<< "Parameter ignored if whitespace in name #1";
|
||||
}
|
||||
|
||||
TEST(MimeType, ParameterIgnoredIfWhitespaceInName2)
|
||||
{
|
||||
TEST(MimeType, ParameterIgnoredIfWhitespaceInName2) {
|
||||
const auto in = NS_LITERAL_STRING("text/html;cha rset =gbk;charset=123");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
ASSERT_TRUE(parsed) << "Parsing succeeded";
|
||||
nsAutoString out;
|
||||
parsed->Serialize(out);
|
||||
ASSERT_TRUE(out.EqualsLiteral("text/html;charset=123"))
|
||||
<< "Parameter ignored if whitespace in name #2";
|
||||
<< "Parameter ignored if whitespace in name #2";
|
||||
}
|
||||
|
||||
TEST(MimeType, WhitespaceTrimmed)
|
||||
{
|
||||
TEST(MimeType, WhitespaceTrimmed) {
|
||||
const auto in = NS_LITERAL_STRING(
|
||||
"\n\r\t text/plain\n\r\t ;\n\r\t charset=123\n\r\t ");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
ASSERT_TRUE(parsed) << "Parsing succeeded";
|
||||
nsAutoString out;
|
||||
parsed->Serialize(out);
|
||||
ASSERT_TRUE(out.EqualsLiteral("text/plain;charset=123"))
|
||||
<< "Whitespace appropriately ignored";
|
||||
<< "Whitespace appropriately ignored";
|
||||
}
|
||||
|
||||
TEST(MimeType, WhitespaceOnlyParameterIgnored)
|
||||
{
|
||||
TEST(MimeType, WhitespaceOnlyParameterIgnored) {
|
||||
const auto in = NS_LITERAL_STRING("x/x;x= \r\n\t");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
ASSERT_TRUE(parsed) << "Parsing succeeded";
|
||||
nsAutoString out;
|
||||
parsed->Serialize(out);
|
||||
ASSERT_TRUE(out.EqualsLiteral("x/x"))
|
||||
<< "Whitespace-only parameter is ignored";
|
||||
<< "Whitespace-only parameter is ignored";
|
||||
}
|
||||
|
||||
TEST(MimeType, IncompleteParameterIgnored1)
|
||||
{
|
||||
TEST(MimeType, IncompleteParameterIgnored1) {
|
||||
const auto in = NS_LITERAL_STRING("x/x;test");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
ASSERT_TRUE(parsed) << "Parsing succeeded";
|
||||
nsAutoString out;
|
||||
parsed->Serialize(out);
|
||||
ASSERT_TRUE(out.EqualsLiteral("x/x"))
|
||||
<< "Incomplete parameter is ignored #1";
|
||||
ASSERT_TRUE(out.EqualsLiteral("x/x")) << "Incomplete parameter is ignored #1";
|
||||
}
|
||||
|
||||
TEST(MimeType, IncompleteParameterIgnored2)
|
||||
{
|
||||
TEST(MimeType, IncompleteParameterIgnored2) {
|
||||
const auto in = NS_LITERAL_STRING("x/x;test=");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
ASSERT_TRUE(parsed) << "Parsing succeeded";
|
||||
nsAutoString out;
|
||||
parsed->Serialize(out);
|
||||
ASSERT_TRUE(out.EqualsLiteral("x/x"))
|
||||
<< "Incomplete parameter is ignored #2";
|
||||
ASSERT_TRUE(out.EqualsLiteral("x/x")) << "Incomplete parameter is ignored #2";
|
||||
}
|
||||
|
||||
TEST(MimeType, IncompleteParameterIgnored3)
|
||||
{
|
||||
TEST(MimeType, IncompleteParameterIgnored3) {
|
||||
const auto in = NS_LITERAL_STRING("x/x;test= \r\n\t");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
ASSERT_TRUE(parsed) << "Parsing succeeded";
|
||||
nsAutoString out;
|
||||
parsed->Serialize(out);
|
||||
ASSERT_TRUE(out.EqualsLiteral("x/x"))
|
||||
<< "Incomplete parameter is ignored #3";
|
||||
ASSERT_TRUE(out.EqualsLiteral("x/x")) << "Incomplete parameter is ignored #3";
|
||||
}
|
||||
|
||||
TEST(MimeType, IncompleteParameterIgnored4)
|
||||
{
|
||||
TEST(MimeType, IncompleteParameterIgnored4) {
|
||||
const auto in = NS_LITERAL_STRING("text/html;test;charset=gbk");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
ASSERT_TRUE(parsed) << "Parsing succeeded";
|
||||
nsAutoString out;
|
||||
parsed->Serialize(out);
|
||||
ASSERT_TRUE(out.EqualsLiteral("text/html;charset=gbk"))
|
||||
<< "Incomplete parameter is ignored #4";
|
||||
<< "Incomplete parameter is ignored #4";
|
||||
}
|
||||
|
||||
TEST(MimeType, IncompleteParameterIgnored5)
|
||||
{
|
||||
TEST(MimeType, IncompleteParameterIgnored5) {
|
||||
const auto in = NS_LITERAL_STRING("text/html;test=;charset=gbk");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
ASSERT_TRUE(parsed) << "Parsing succeeded";
|
||||
nsAutoString out;
|
||||
parsed->Serialize(out);
|
||||
ASSERT_TRUE(out.EqualsLiteral("text/html;charset=gbk"))
|
||||
<< "Incomplete parameter is ignored #5";
|
||||
<< "Incomplete parameter is ignored #5";
|
||||
}
|
||||
|
||||
TEST(MimeType, EmptyParameterIgnored1)
|
||||
{
|
||||
TEST(MimeType, EmptyParameterIgnored1) {
|
||||
const auto in = NS_LITERAL_STRING("text/html ; ; charset=gbk");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
ASSERT_TRUE(parsed) << "Parsing succeeded";
|
||||
nsAutoString out;
|
||||
parsed->Serialize(out);
|
||||
ASSERT_TRUE(out.EqualsLiteral("text/html;charset=gbk"))
|
||||
<< "Empty parameter ignored #1";
|
||||
<< "Empty parameter ignored #1";
|
||||
}
|
||||
|
||||
TEST(MimeType, EmptyParameterIgnored2)
|
||||
{
|
||||
TEST(MimeType, EmptyParameterIgnored2) {
|
||||
const auto in = NS_LITERAL_STRING("text/html;;;;charset=gbk");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
ASSERT_TRUE(parsed) << "Parsing succeeded";
|
||||
nsAutoString out;
|
||||
parsed->Serialize(out);
|
||||
ASSERT_TRUE(out.EqualsLiteral("text/html;charset=gbk"))
|
||||
<< "Empty parameter ignored #2";
|
||||
<< "Empty parameter ignored #2";
|
||||
}
|
||||
|
||||
TEST(MimeType, InvalidParameterIgnored1)
|
||||
{
|
||||
TEST(MimeType, InvalidParameterIgnored1) {
|
||||
const auto in = NS_LITERAL_STRING("text/html;';charset=gbk");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
ASSERT_TRUE(parsed) << "Parsing succeeded";
|
||||
nsAutoString out;
|
||||
parsed->Serialize(out);
|
||||
ASSERT_TRUE(out.EqualsLiteral("text/html;charset=gbk"))
|
||||
<< "Invalid parameter ignored #1";
|
||||
<< "Invalid parameter ignored #1";
|
||||
}
|
||||
|
||||
TEST(MimeType, InvalidParameterIgnored2)
|
||||
{
|
||||
TEST(MimeType, InvalidParameterIgnored2) {
|
||||
const auto in = NS_LITERAL_STRING("text/html;\";charset=gbk;=123; =321");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
ASSERT_TRUE(parsed) << "Parsing succeeded";
|
||||
nsAutoString out;
|
||||
parsed->Serialize(out);
|
||||
ASSERT_TRUE(out.EqualsLiteral("text/html;charset=gbk"))
|
||||
<< "Invalid parameter ignored #2";
|
||||
<< "Invalid parameter ignored #2";
|
||||
}
|
||||
|
||||
TEST(MimeType, InvalidParameterIgnored3)
|
||||
{
|
||||
TEST(MimeType, InvalidParameterIgnored3) {
|
||||
const auto in = NS_LITERAL_STRING("text/html;charset= \"\u007F;charset=GBK");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
ASSERT_TRUE(parsed) << "Parsing succeeded";
|
||||
nsAutoString out;
|
||||
parsed->Serialize(out);
|
||||
ASSERT_TRUE(out.EqualsLiteral("text/html;charset=GBK"))
|
||||
<< "Invalid parameter ignored #3";
|
||||
<< "Invalid parameter ignored #3";
|
||||
}
|
||||
|
||||
TEST(MimeType, InvalidParameterIgnored4)
|
||||
{
|
||||
TEST(MimeType, InvalidParameterIgnored4) {
|
||||
const auto in = NS_LITERAL_STRING(
|
||||
"text/html;charset=\"\u007F;charset=foo\";charset=GBK;charset=");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
ASSERT_TRUE(parsed) << "Parsing succeeded";
|
||||
nsAutoString out;
|
||||
parsed->Serialize(out);
|
||||
ASSERT_TRUE(out.EqualsLiteral("text/html;charset=GBK"))
|
||||
<< "Invalid parameter ignored #4";
|
||||
<< "Invalid parameter ignored #4";
|
||||
}
|
||||
|
||||
TEST(MimeType, SingleQuotes1)
|
||||
{
|
||||
TEST(MimeType, SingleQuotes1) {
|
||||
const auto in = NS_LITERAL_STRING("text/html;charset='gbk'");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
ASSERT_TRUE(parsed) << "Parsing succeeded";
|
||||
nsAutoString out;
|
||||
parsed->Serialize(out);
|
||||
ASSERT_TRUE(out.EqualsLiteral("text/html;charset='gbk'"))
|
||||
<< "Single quotes handled properly #1";
|
||||
<< "Single quotes handled properly #1";
|
||||
}
|
||||
|
||||
TEST(MimeType, SingleQuotes2)
|
||||
{
|
||||
TEST(MimeType, SingleQuotes2) {
|
||||
const auto in = NS_LITERAL_STRING("text/html;charset='gbk");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
ASSERT_TRUE(parsed) << "Parsing succeeded";
|
||||
nsAutoString out;
|
||||
parsed->Serialize(out);
|
||||
ASSERT_TRUE(out.EqualsLiteral("text/html;charset='gbk"))
|
||||
<< "Single quotes handled properly #2";
|
||||
<< "Single quotes handled properly #2";
|
||||
}
|
||||
|
||||
TEST(MimeType, SingleQuotes3)
|
||||
{
|
||||
TEST(MimeType, SingleQuotes3) {
|
||||
const auto in = NS_LITERAL_STRING("text/html;charset=gbk'");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
ASSERT_TRUE(parsed) << "Parsing succeeded";
|
||||
nsAutoString out;
|
||||
parsed->Serialize(out);
|
||||
ASSERT_TRUE(out.EqualsLiteral("text/html;charset=gbk'"))
|
||||
<< "Single quotes handled properly #3";
|
||||
<< "Single quotes handled properly #3";
|
||||
}
|
||||
|
||||
TEST(MimeType, SingleQuotes4)
|
||||
{
|
||||
TEST(MimeType, SingleQuotes4) {
|
||||
const auto in = NS_LITERAL_STRING("text/html;charset=';charset=GBK");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
ASSERT_TRUE(parsed) << "Parsing succeeded";
|
||||
nsAutoString out;
|
||||
parsed->Serialize(out);
|
||||
ASSERT_TRUE(out.EqualsLiteral("text/html;charset='"))
|
||||
<< "Single quotes handled properly #4";
|
||||
<< "Single quotes handled properly #4";
|
||||
}
|
||||
|
||||
TEST(MimeType, SingleQuotes5)
|
||||
{
|
||||
TEST(MimeType, SingleQuotes5) {
|
||||
const auto in = NS_LITERAL_STRING("text/html;charset=''';charset=GBK");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
ASSERT_TRUE(parsed) << "Parsing succeeded";
|
||||
nsAutoString out;
|
||||
parsed->Serialize(out);
|
||||
ASSERT_TRUE(out.EqualsLiteral("text/html;charset='''"))
|
||||
<< "Single quotes handled properly #5";
|
||||
<< "Single quotes handled properly #5";
|
||||
}
|
||||
|
||||
TEST(MimeType, DoubleQuotes1)
|
||||
{
|
||||
TEST(MimeType, DoubleQuotes1) {
|
||||
const auto in = NS_LITERAL_STRING("text/html;charset=\"gbk\"");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
ASSERT_TRUE(parsed) << "Parsing succeeded";
|
||||
nsAutoString out;
|
||||
parsed->Serialize(out);
|
||||
ASSERT_TRUE(out.EqualsLiteral("text/html;charset=gbk"))
|
||||
<< "Double quotes handled properly #1";
|
||||
<< "Double quotes handled properly #1";
|
||||
}
|
||||
|
||||
TEST(MimeType, DoubleQuotes2)
|
||||
{
|
||||
TEST(MimeType, DoubleQuotes2) {
|
||||
const auto in = NS_LITERAL_STRING("text/html;charset=\"gbk");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
ASSERT_TRUE(parsed) << "Parsing succeeded";
|
||||
nsAutoString out;
|
||||
parsed->Serialize(out);
|
||||
ASSERT_TRUE(out.EqualsLiteral("text/html;charset=gbk"))
|
||||
<< "Double quotes handled properly #2";
|
||||
<< "Double quotes handled properly #2";
|
||||
}
|
||||
|
||||
TEST(MimeType, DoubleQuotes3)
|
||||
{
|
||||
TEST(MimeType, DoubleQuotes3) {
|
||||
const auto in = NS_LITERAL_STRING("text/html;charset=gbk\"");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
ASSERT_TRUE(parsed) << "Parsing succeeded";
|
||||
nsAutoString out;
|
||||
parsed->Serialize(out);
|
||||
ASSERT_TRUE(out.EqualsLiteral("text/html;charset=\"gbk\\\"\""))
|
||||
<< "Double quotes handled properly #3";
|
||||
<< "Double quotes handled properly #3";
|
||||
}
|
||||
|
||||
TEST(MimeType, DoubleQuotes4)
|
||||
{
|
||||
TEST(MimeType, DoubleQuotes4) {
|
||||
const auto in = NS_LITERAL_STRING("text/html;charset=\" gbk\"");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
ASSERT_TRUE(parsed) << "Parsing succeeded";
|
||||
nsAutoString out;
|
||||
parsed->Serialize(out);
|
||||
ASSERT_TRUE(out.EqualsLiteral("text/html;charset=\" gbk\""))
|
||||
<< "Double quotes handled properly #4";
|
||||
<< "Double quotes handled properly #4";
|
||||
}
|
||||
|
||||
TEST(MimeType, DoubleQuotes5)
|
||||
{
|
||||
TEST(MimeType, DoubleQuotes5) {
|
||||
const auto in = NS_LITERAL_STRING("text/html;charset=\"gbk \"");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
ASSERT_TRUE(parsed) << "Parsing succeeded";
|
||||
nsAutoString out;
|
||||
parsed->Serialize(out);
|
||||
ASSERT_TRUE(out.EqualsLiteral("text/html;charset=\"gbk \""))
|
||||
<< "Double quotes handled properly #5";
|
||||
<< "Double quotes handled properly #5";
|
||||
}
|
||||
|
||||
TEST(MimeType, DoubleQuotes6)
|
||||
{
|
||||
TEST(MimeType, DoubleQuotes6) {
|
||||
const auto in = NS_LITERAL_STRING("text/html;charset=\"\\ gbk\"");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
ASSERT_TRUE(parsed) << "Parsing succeeded";
|
||||
nsAutoString out;
|
||||
parsed->Serialize(out);
|
||||
ASSERT_TRUE(out.EqualsLiteral("text/html;charset=\" gbk\""))
|
||||
<< "Double quotes handled properly #6";
|
||||
<< "Double quotes handled properly #6";
|
||||
}
|
||||
|
||||
TEST(MimeType, DoubleQuotes7)
|
||||
{
|
||||
TEST(MimeType, DoubleQuotes7) {
|
||||
const auto in = NS_LITERAL_STRING("text/html;charset=\"\\g\\b\\k\"");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
ASSERT_TRUE(parsed) << "Parsing succeeded";
|
||||
nsAutoString out;
|
||||
parsed->Serialize(out);
|
||||
ASSERT_TRUE(out.EqualsLiteral("text/html;charset=gbk"))
|
||||
<< "Double quotes handled properly #7";
|
||||
<< "Double quotes handled properly #7";
|
||||
}
|
||||
|
||||
TEST(MimeType, DoubleQuotes8)
|
||||
{
|
||||
TEST(MimeType, DoubleQuotes8) {
|
||||
const auto in = NS_LITERAL_STRING("text/html;charset=\"gbk\"x");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
ASSERT_TRUE(parsed) << "Parsing succeeded";
|
||||
nsAutoString out;
|
||||
parsed->Serialize(out);
|
||||
ASSERT_TRUE(out.EqualsLiteral("text/html;charset=gbk"))
|
||||
<< "Double quotes handled properly #8";
|
||||
<< "Double quotes handled properly #8";
|
||||
}
|
||||
|
||||
TEST(MimeType, DoubleQuotes9)
|
||||
{
|
||||
TEST(MimeType, DoubleQuotes9) {
|
||||
const auto in = NS_LITERAL_STRING("text/html;charset=\"\";charset=GBK");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
ASSERT_TRUE(parsed) << "Parsing succeeded";
|
||||
nsAutoString out;
|
||||
parsed->Serialize(out);
|
||||
ASSERT_TRUE(out.EqualsLiteral("text/html;charset=\"\""))
|
||||
<< "Double quotes handled properly #9";
|
||||
<< "Double quotes handled properly #9";
|
||||
}
|
||||
|
||||
TEST(MimeType, DoubleQuotes10)
|
||||
{
|
||||
TEST(MimeType, DoubleQuotes10) {
|
||||
const auto in = NS_LITERAL_STRING("text/html;charset=\";charset=GBK");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
ASSERT_TRUE(parsed) << "Parsing succeeded";
|
||||
nsAutoString out;
|
||||
parsed->Serialize(out);
|
||||
ASSERT_TRUE(out.EqualsLiteral("text/html;charset=\";charset=GBK\""))
|
||||
<< "Double quotes handled properly #10";
|
||||
<< "Double quotes handled properly #10";
|
||||
}
|
||||
|
||||
TEST(MimeType, UnexpectedCodePoints)
|
||||
{
|
||||
TEST(MimeType, UnexpectedCodePoints) {
|
||||
const auto in = NS_LITERAL_STRING("text/html;charset={gbk}");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
ASSERT_TRUE(parsed) << "Parsing succeeded";
|
||||
nsAutoString out;
|
||||
parsed->Serialize(out);
|
||||
ASSERT_TRUE(out.EqualsLiteral("text/html;charset=\"{gbk}\""))
|
||||
<< "Unexpected code points handled properly";
|
||||
<< "Unexpected code points handled properly";
|
||||
}
|
||||
|
||||
TEST(MimeType, LongTypesSubtypesAccepted)
|
||||
{
|
||||
TEST(MimeType, LongTypesSubtypesAccepted) {
|
||||
const auto in = NS_LITERAL_STRING(
|
||||
"012345678901234567890123456789012345678901234567890123456789012345678901"
|
||||
"2345678901234567890123456789012345678901234567890123456789/"
|
||||
"012345678901234567890123456789012345678901234567890123456789012345678901"
|
||||
"2345678901234567890123456789012345678901234567890123456789");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
ASSERT_TRUE(parsed) << "Parsing succeeded";
|
||||
nsAutoString out;
|
||||
parsed->Serialize(out);
|
||||
ASSERT_TRUE(out.Equals(in))
|
||||
<< "Long type/subtype accepted";
|
||||
ASSERT_TRUE(out.Equals(in)) << "Long type/subtype accepted";
|
||||
}
|
||||
|
||||
TEST(MimeType, LongParametersAccepted)
|
||||
{
|
||||
TEST(MimeType, LongParametersAccepted) {
|
||||
const auto in = NS_LITERAL_STRING(
|
||||
"text/"
|
||||
"html;"
|
||||
|
@ -700,16 +588,13 @@ TEST(MimeType, LongParametersAccepted)
|
|||
"2345678901234567890123456789012345678901234567890123456789=x;charset="
|
||||
"gbk");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
ASSERT_TRUE(parsed) << "Parsing succeeded";
|
||||
nsAutoString out;
|
||||
parsed->Serialize(out);
|
||||
ASSERT_TRUE(out.Equals(in))
|
||||
<< "Long parameters accepted";
|
||||
ASSERT_TRUE(out.Equals(in)) << "Long parameters accepted";
|
||||
}
|
||||
|
||||
TEST(MimeType, AllValidCharactersAccepted1)
|
||||
{
|
||||
TEST(MimeType, AllValidCharactersAccepted1) {
|
||||
const auto in = NS_LITERAL_STRING(
|
||||
u"x/x;x=\"\t "
|
||||
u"!\\\"#$%&'()*+,-./"
|
||||
|
@ -728,28 +613,23 @@ TEST(MimeType, AllValidCharactersAccepted1)
|
|||
u"\u00EE\u00EF\u00F0\u00F1\u00F2\u00F3\u00F4\u00F5\u00F6\u00F7\u00F8"
|
||||
u"\u00F9\u00FA\u00FB\u00FC\u00FD\u00FE\u00FF\"");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
ASSERT_TRUE(parsed) << "Parsing succeeded";
|
||||
nsAutoString out;
|
||||
parsed->Serialize(out);
|
||||
ASSERT_TRUE(out.Equals(in))
|
||||
<< "All valid characters accepted #1";
|
||||
ASSERT_TRUE(out.Equals(in)) << "All valid characters accepted #1";
|
||||
}
|
||||
|
||||
TEST(MimeType, CaseNormalization1)
|
||||
{
|
||||
TEST(MimeType, CaseNormalization1) {
|
||||
const auto in = NS_LITERAL_STRING("TEXT/PLAIN;CHARSET=TEST");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
ASSERT_TRUE(parsed) << "Parsing succeeded";
|
||||
nsAutoString out;
|
||||
parsed->Serialize(out);
|
||||
ASSERT_TRUE(out.EqualsLiteral("text/plain;charset=TEST"))
|
||||
<< "Case normalized properly #1";
|
||||
<< "Case normalized properly #1";
|
||||
}
|
||||
|
||||
TEST(MimeType, CaseNormalization2)
|
||||
{
|
||||
TEST(MimeType, CaseNormalization2) {
|
||||
const auto in = NS_LITERAL_STRING(
|
||||
"!#$%&'*+-.^_`|~"
|
||||
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz/"
|
||||
|
@ -759,8 +639,7 @@ TEST(MimeType, CaseNormalization2)
|
|||
"%&'*+-.^_`|~"
|
||||
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
ASSERT_TRUE(parsed) << "Parsing succeeded";
|
||||
nsAutoString out;
|
||||
parsed->Serialize(out);
|
||||
ASSERT_TRUE(out.EqualsLiteral(
|
||||
|
@ -771,29 +650,25 @@ TEST(MimeType, CaseNormalization2)
|
|||
".^_`|~0123456789abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz=!#$"
|
||||
"%&'*+-.^_`|~"
|
||||
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"))
|
||||
<< "Case normalized properly #2";
|
||||
<< "Case normalized properly #2";
|
||||
}
|
||||
|
||||
TEST(MimeType, LegacyCommentSyntax1)
|
||||
{
|
||||
TEST(MimeType, LegacyCommentSyntax1) {
|
||||
const auto in = NS_LITERAL_STRING("text/html;charset=gbk(");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
ASSERT_TRUE(parsed) << "Parsing succeeded";
|
||||
nsAutoString out;
|
||||
parsed->Serialize(out);
|
||||
ASSERT_TRUE(out.EqualsLiteral("text/html;charset=\"gbk(\""))
|
||||
<< "Legacy comment syntax #1";
|
||||
<< "Legacy comment syntax #1";
|
||||
}
|
||||
|
||||
TEST(MimeType, LegacyCommentSyntax2)
|
||||
{
|
||||
TEST(MimeType, LegacyCommentSyntax2) {
|
||||
const auto in = NS_LITERAL_STRING("text/html;x=(;charset=gbk");
|
||||
UniquePtr<MimeType> parsed = MimeType::Parse(in);
|
||||
ASSERT_TRUE(parsed)
|
||||
<< "Parsing succeeded";
|
||||
ASSERT_TRUE(parsed) << "Parsing succeeded";
|
||||
nsAutoString out;
|
||||
parsed->Serialize(out);
|
||||
ASSERT_TRUE(out.EqualsLiteral("text/html;x=\"(\";charset=gbk"))
|
||||
<< "Legacy comment syntax #2";
|
||||
<< "Legacy comment syntax #2";
|
||||
}
|
||||
|
|
|
@ -18,8 +18,7 @@ void ConvertBufToPlainText(nsString &aConBuf, int aFlag) {
|
|||
}
|
||||
|
||||
// Test for ASCII with format=flowed; delsp=yes
|
||||
TEST(PlainTextSerializer, ASCIIWithFlowedDelSp)
|
||||
{
|
||||
TEST(PlainTextSerializer, ASCIIWithFlowedDelSp) {
|
||||
nsString test;
|
||||
nsString result;
|
||||
|
||||
|
@ -43,12 +42,11 @@ TEST(PlainTextSerializer, ASCIIWithFlowedDelSp)
|
|||
"Firefox \r\nFirefox Firefox Firefox\r\n");
|
||||
|
||||
ASSERT_TRUE(test.Equals(result))
|
||||
<< "Wrong HTML to ASCII text serialization with format=flowed; delsp=yes";
|
||||
<< "Wrong HTML to ASCII text serialization with format=flowed; delsp=yes";
|
||||
}
|
||||
|
||||
// Test for CJK with format=flowed; delsp=yes
|
||||
TEST(PlainTextSerializer, CJKWithFlowedDelSp)
|
||||
{
|
||||
TEST(PlainTextSerializer, CJKWithFlowedDelSp) {
|
||||
nsString test;
|
||||
nsString result;
|
||||
|
||||
|
@ -76,12 +74,11 @@ TEST(PlainTextSerializer, CJKWithFlowedDelSp)
|
|||
result.AppendLiteral("\r\n");
|
||||
|
||||
ASSERT_TRUE(test.Equals(result))
|
||||
<< "Wrong HTML to CJK text serialization with format=flowed; delsp=yes";
|
||||
<< "Wrong HTML to CJK text serialization with format=flowed; delsp=yes";
|
||||
}
|
||||
|
||||
// Test for CJK with DisallowLineBreaking
|
||||
TEST(PlainTextSerializer, CJKWithDisallowLineBreaking)
|
||||
{
|
||||
TEST(PlainTextSerializer, CJKWithDisallowLineBreaking) {
|
||||
nsString test;
|
||||
nsString result;
|
||||
|
||||
|
@ -106,12 +103,11 @@ TEST(PlainTextSerializer, CJKWithDisallowLineBreaking)
|
|||
result.AppendLiteral("\r\n");
|
||||
|
||||
ASSERT_TRUE(test.Equals(result))
|
||||
<< "Wrong HTML to CJK text serialization with OutputDisallowLineBreaking";
|
||||
<< "Wrong HTML to CJK text serialization with OutputDisallowLineBreaking";
|
||||
}
|
||||
|
||||
// Test for ASCII with format=flowed; and quoted lines in preformatted span.
|
||||
TEST(PlainTextSerializer, PreformatFlowedQuotes)
|
||||
{
|
||||
TEST(PlainTextSerializer, PreformatFlowedQuotes) {
|
||||
nsString test;
|
||||
nsString result;
|
||||
|
||||
|
@ -138,14 +134,12 @@ TEST(PlainTextSerializer, PreformatFlowedQuotes)
|
|||
">> Firefox Firefox Firefox Firefox \r\n"
|
||||
">> Firefox Firefox Firefox Firefox\r\n");
|
||||
|
||||
ASSERT_TRUE(test.Equals(result))
|
||||
<< "Wrong HTML to ASCII text serialization "
|
||||
"with format=flowed; and quoted "
|
||||
"lines";
|
||||
ASSERT_TRUE(test.Equals(result)) << "Wrong HTML to ASCII text serialization "
|
||||
"with format=flowed; and quoted "
|
||||
"lines";
|
||||
}
|
||||
|
||||
TEST(PlainTextSerializer, PrettyPrintedHtml)
|
||||
{
|
||||
TEST(PlainTextSerializer, PrettyPrintedHtml) {
|
||||
nsString test;
|
||||
test.AppendLiteral("<html>" NS_LINEBREAK "<body>" NS_LINEBREAK
|
||||
" first<br>" NS_LINEBREAK " second<br>" NS_LINEBREAK
|
||||
|
@ -153,11 +147,10 @@ TEST(PlainTextSerializer, PrettyPrintedHtml)
|
|||
|
||||
ConvertBufToPlainText(test, 0);
|
||||
ASSERT_TRUE(test.EqualsLiteral("first" NS_LINEBREAK "second" NS_LINEBREAK))
|
||||
<< "Wrong prettyprinted html to text serialization";
|
||||
<< "Wrong prettyprinted html to text serialization";
|
||||
}
|
||||
|
||||
TEST(PlainTextSerializer, PreElement)
|
||||
{
|
||||
TEST(PlainTextSerializer, PreElement) {
|
||||
nsString test;
|
||||
test.AppendLiteral("<html>" NS_LINEBREAK "<body>" NS_LINEBREAK
|
||||
"<pre>" NS_LINEBREAK " first" NS_LINEBREAK
|
||||
|
@ -167,11 +160,10 @@ TEST(PlainTextSerializer, PreElement)
|
|||
ConvertBufToPlainText(test, 0);
|
||||
ASSERT_TRUE(test.EqualsLiteral(" first" NS_LINEBREAK
|
||||
" second" NS_LINEBREAK NS_LINEBREAK))
|
||||
<< "Wrong prettyprinted html to text serialization";
|
||||
<< "Wrong prettyprinted html to text serialization";
|
||||
}
|
||||
|
||||
TEST(PlainTextSerializer, BlockElement)
|
||||
{
|
||||
TEST(PlainTextSerializer, BlockElement) {
|
||||
nsString test;
|
||||
test.AppendLiteral("<html>" NS_LINEBREAK "<body>" NS_LINEBREAK
|
||||
"<div>" NS_LINEBREAK " first" NS_LINEBREAK
|
||||
|
@ -181,11 +173,10 @@ TEST(PlainTextSerializer, BlockElement)
|
|||
|
||||
ConvertBufToPlainText(test, 0);
|
||||
ASSERT_TRUE(test.EqualsLiteral("first" NS_LINEBREAK "second" NS_LINEBREAK))
|
||||
<< "Wrong prettyprinted html to text serialization";
|
||||
<< "Wrong prettyprinted html to text serialization";
|
||||
}
|
||||
|
||||
TEST(PlainTextSerializer, PreWrapElementForThunderbird)
|
||||
{
|
||||
TEST(PlainTextSerializer, PreWrapElementForThunderbird) {
|
||||
// This test examines the magic pre-wrap setup that Thunderbird relies on.
|
||||
nsString test;
|
||||
test.AppendLiteral(
|
||||
|
@ -202,16 +193,15 @@ TEST(PlainTextSerializer, PreWrapElementForThunderbird)
|
|||
" first" NS_LINEBREAK "line is" NS_LINEBREAK "too long" NS_LINEBREAK
|
||||
" second" NS_LINEBREAK "line is" NS_LINEBREAK "even" NS_LINEBREAK
|
||||
"loooonger" NS_LINEBREAK NS_LINEBREAK NS_LINEBREAK))
|
||||
<< "Wrong prettyprinted html to text serialization";
|
||||
<< "Wrong prettyprinted html to text serialization";
|
||||
}
|
||||
|
||||
TEST(PlainTextSerializer, Simple)
|
||||
{
|
||||
TEST(PlainTextSerializer, Simple) {
|
||||
nsString test;
|
||||
test.AppendLiteral(
|
||||
"<html><base>base</base><head><span>span</span></head>"
|
||||
"<body>body</body></html>");
|
||||
ConvertBufToPlainText(test, 0);
|
||||
ASSERT_TRUE(test.EqualsLiteral("basespanbody"))
|
||||
<< "Wrong html to text serialization";
|
||||
<< "Wrong html to text serialization";
|
||||
}
|
||||
|
|
|
@ -8,8 +8,7 @@
|
|||
#include "XPathGenerator.h"
|
||||
#include "nsString.h"
|
||||
|
||||
TEST(TestXPathGenerator, TestQuoteArgumentWithoutQuote)
|
||||
{
|
||||
TEST(TestXPathGenerator, TestQuoteArgumentWithoutQuote) {
|
||||
nsAutoString arg;
|
||||
arg.AssignLiteral(u"testing");
|
||||
|
||||
|
@ -22,8 +21,7 @@ TEST(TestXPathGenerator, TestQuoteArgumentWithoutQuote)
|
|||
ASSERT_TRUE(expectedResult.Equals(result));
|
||||
}
|
||||
|
||||
TEST(TestXPathGenerator, TestQuoteArgumentWithSingleQuote)
|
||||
{
|
||||
TEST(TestXPathGenerator, TestQuoteArgumentWithSingleQuote) {
|
||||
nsAutoString arg;
|
||||
arg.AssignLiteral(u"\'testing\'");
|
||||
|
||||
|
@ -36,8 +34,7 @@ TEST(TestXPathGenerator, TestQuoteArgumentWithSingleQuote)
|
|||
ASSERT_TRUE(expectedResult.Equals(result));
|
||||
}
|
||||
|
||||
TEST(TestXPathGenerator, TestQuoteArgumentWithDoubleQuote)
|
||||
{
|
||||
TEST(TestXPathGenerator, TestQuoteArgumentWithDoubleQuote) {
|
||||
nsAutoString arg;
|
||||
arg.AssignLiteral(u"\"testing\"");
|
||||
|
||||
|
@ -50,8 +47,7 @@ TEST(TestXPathGenerator, TestQuoteArgumentWithDoubleQuote)
|
|||
ASSERT_TRUE(expectedResult.Equals(result));
|
||||
}
|
||||
|
||||
TEST(TestXPathGenerator, TestQuoteArgumentWithSingleAndDoubleQuote)
|
||||
{
|
||||
TEST(TestXPathGenerator, TestQuoteArgumentWithSingleAndDoubleQuote) {
|
||||
nsAutoString arg;
|
||||
arg.AssignLiteral(u"\'testing\"");
|
||||
|
||||
|
@ -67,8 +63,7 @@ TEST(TestXPathGenerator, TestQuoteArgumentWithSingleAndDoubleQuote)
|
|||
}
|
||||
|
||||
TEST(TestXPathGenerator,
|
||||
TestQuoteArgumentWithDoubleQuoteAndASequenceOfSingleQuote)
|
||||
{
|
||||
TestQuoteArgumentWithDoubleQuoteAndASequenceOfSingleQuote) {
|
||||
nsAutoString arg;
|
||||
arg.AssignLiteral(u"\'\'\'\'testing\"");
|
||||
|
||||
|
@ -84,8 +79,7 @@ TEST(TestXPathGenerator,
|
|||
}
|
||||
|
||||
TEST(TestXPathGenerator,
|
||||
TestQuoteArgumentWithDoubleQuoteAndTwoSequencesOfSingleQuote)
|
||||
{
|
||||
TestQuoteArgumentWithDoubleQuoteAndTwoSequencesOfSingleQuote) {
|
||||
nsAutoString arg;
|
||||
arg.AssignLiteral(u"\'\'\'\'testing\'\'\'\'\'\'\"");
|
||||
|
||||
|
@ -102,8 +96,7 @@ TEST(TestXPathGenerator,
|
|||
}
|
||||
|
||||
TEST(TestXPathGenerator,
|
||||
TestQuoteArgumentWithDoubleQuoteAndTwoSequencesOfSingleQuoteInMiddle)
|
||||
{
|
||||
TestQuoteArgumentWithDoubleQuoteAndTwoSequencesOfSingleQuoteInMiddle) {
|
||||
nsAutoString arg;
|
||||
arg.AssignLiteral(u"t\'\'\'\'estin\'\'\'\'\'\'\"g");
|
||||
|
||||
|
@ -119,8 +112,7 @@ TEST(TestXPathGenerator,
|
|||
ASSERT_TRUE(expectedResult.Equals(result));
|
||||
}
|
||||
|
||||
TEST(TestXPathGenerator, TestEscapeNameWithNormalCharacters)
|
||||
{
|
||||
TEST(TestXPathGenerator, TestEscapeNameWithNormalCharacters) {
|
||||
nsAutoString arg;
|
||||
arg.AssignLiteral(u"testing");
|
||||
|
||||
|
@ -133,8 +125,7 @@ TEST(TestXPathGenerator, TestEscapeNameWithNormalCharacters)
|
|||
ASSERT_TRUE(expectedResult.Equals(result));
|
||||
}
|
||||
|
||||
TEST(TestXPathGenerator, TestEscapeNameWithSpecialCharacters)
|
||||
{
|
||||
TEST(TestXPathGenerator, TestEscapeNameWithSpecialCharacters) {
|
||||
nsAutoString arg;
|
||||
arg.AssignLiteral(u"^testing!");
|
||||
|
||||
|
|
|
@ -437,9 +437,7 @@ Context::QuotaInitRunnable::Run() {
|
|||
}
|
||||
// -----
|
||||
case STATE_WAIT_FOR_DIRECTORY_LOCK:
|
||||
default: {
|
||||
MOZ_CRASH("unexpected state in QuotaInitRunnable");
|
||||
}
|
||||
default: { MOZ_CRASH("unexpected state in QuotaInitRunnable"); }
|
||||
}
|
||||
|
||||
if (resolver->Resolved()) {
|
||||
|
|
|
@ -893,7 +893,7 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(CanvasRenderingContext2D)
|
|||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
CanvasRenderingContext2D::ContextState::ContextState() = default;
|
||||
CanvasRenderingContext2D::ContextState::ContextState() = default;
|
||||
|
||||
CanvasRenderingContext2D::ContextState::ContextState(const ContextState& aOther)
|
||||
: fontGroup(aOther.fontGroup),
|
||||
|
|
|
@ -402,8 +402,8 @@ void WebGLContext::VertexAttribAnyPointer(bool isFuncInt, GLuint index,
|
|||
}
|
||||
|
||||
WebGLVertexAttribData& vd = mBoundVertexArray->mAttribs[index];
|
||||
vd.VertexAttribPointer(isFuncInt, buffer, AutoAssertCast(size), type,
|
||||
normalized, stride, byteOffset);
|
||||
vd.VertexAttribPointer(isFuncInt, buffer, AutoAssertCast(size), type, normalized, stride,
|
||||
byteOffset);
|
||||
mBoundVertexArray->InvalidateCaches();
|
||||
}
|
||||
|
||||
|
|
|
@ -962,7 +962,7 @@ MOZ_ALWAYS_INLINE void
|
|||
pack<WebGLTexelFormat::RGB565, WebGLTexelPremultiplicationOp::None, uint8_t,
|
||||
uint16_t>(const uint8_t* __restrict src, uint16_t* __restrict dst) {
|
||||
*dst = uint16_t(((src[0] & 0xF8) << 8) | ((src[1] & 0xFC) << 3) |
|
||||
((src[2] & 0xF8) >> 3));
|
||||
((src[2] & 0xF8) >> 3));
|
||||
}
|
||||
|
||||
template <>
|
||||
|
@ -974,8 +974,7 @@ pack<WebGLTexelFormat::RGB565, WebGLTexelPremultiplicationOp::Premultiply,
|
|||
uint8_t srcR = static_cast<uint8_t>(src[0] * scaleFactor);
|
||||
uint8_t srcG = static_cast<uint8_t>(src[1] * scaleFactor);
|
||||
uint8_t srcB = static_cast<uint8_t>(src[2] * scaleFactor);
|
||||
*dst = uint16_t(((srcR & 0xF8) << 8) | ((srcG & 0xFC) << 3) |
|
||||
((srcB & 0xF8) >> 3));
|
||||
*dst = uint16_t(((srcR & 0xF8) << 8) | ((srcG & 0xFC) << 3) | ((srcB & 0xF8) >> 3));
|
||||
}
|
||||
|
||||
// FIXME: this routine is lossy and must be removed.
|
||||
|
@ -988,8 +987,7 @@ pack<WebGLTexelFormat::RGB565, WebGLTexelPremultiplicationOp::Unpremultiply,
|
|||
uint8_t srcR = static_cast<uint8_t>(src[0] * scaleFactor);
|
||||
uint8_t srcG = static_cast<uint8_t>(src[1] * scaleFactor);
|
||||
uint8_t srcB = static_cast<uint8_t>(src[2] * scaleFactor);
|
||||
*dst = uint16_t(((srcR & 0xF8) << 8) | ((srcG & 0xFC) << 3) |
|
||||
((srcB & 0xF8) >> 3));
|
||||
*dst = uint16_t(((srcR & 0xF8) << 8) | ((srcG & 0xFC) << 3) | ((srcB & 0xF8) >> 3));
|
||||
}
|
||||
|
||||
template <>
|
||||
|
@ -1123,8 +1121,8 @@ template <>
|
|||
MOZ_ALWAYS_INLINE void
|
||||
pack<WebGLTexelFormat::RGBA4444, WebGLTexelPremultiplicationOp::None, uint8_t,
|
||||
uint16_t>(const uint8_t* __restrict src, uint16_t* __restrict dst) {
|
||||
*dst = uint16_t(((src[0] & 0xF0) << 8) | ((src[1] & 0xF0) << 4) |
|
||||
(src[2] & 0xF0) | (src[3] >> 4));
|
||||
*dst = uint16_t(((src[0] & 0xF0) << 8) | ((src[1] & 0xF0) << 4) | (src[2] & 0xF0) |
|
||||
(src[3] >> 4));
|
||||
}
|
||||
|
||||
template <>
|
||||
|
@ -1137,7 +1135,7 @@ pack<WebGLTexelFormat::RGBA4444, WebGLTexelPremultiplicationOp::Premultiply,
|
|||
uint8_t srcG = static_cast<uint8_t>(src[1] * scaleFactor);
|
||||
uint8_t srcB = static_cast<uint8_t>(src[2] * scaleFactor);
|
||||
*dst = uint16_t(((srcR & 0xF0) << 8) | ((srcG & 0xF0) << 4) | (srcB & 0xF0) |
|
||||
(src[3] >> 4));
|
||||
(src[3] >> 4));
|
||||
}
|
||||
|
||||
// FIXME: this routine is lossy and must be removed.
|
||||
|
@ -1151,7 +1149,7 @@ pack<WebGLTexelFormat::RGBA4444, WebGLTexelPremultiplicationOp::Unpremultiply,
|
|||
uint8_t srcG = static_cast<uint8_t>(src[1] * scaleFactor);
|
||||
uint8_t srcB = static_cast<uint8_t>(src[2] * scaleFactor);
|
||||
*dst = uint16_t(((srcR & 0xF0) << 8) | ((srcG & 0xF0) << 4) | (srcB & 0xF0) |
|
||||
(src[3] >> 4));
|
||||
(src[3] >> 4));
|
||||
}
|
||||
|
||||
template <>
|
||||
|
@ -1159,7 +1157,7 @@ MOZ_ALWAYS_INLINE void
|
|||
pack<WebGLTexelFormat::RGBA5551, WebGLTexelPremultiplicationOp::None, uint8_t,
|
||||
uint16_t>(const uint8_t* __restrict src, uint16_t* __restrict dst) {
|
||||
*dst = uint16_t(((src[0] & 0xF8) << 8) | ((src[1] & 0xF8) << 3) |
|
||||
((src[2] & 0xF8) >> 2) | (src[3] >> 7));
|
||||
((src[2] & 0xF8) >> 2) | (src[3] >> 7));
|
||||
}
|
||||
|
||||
template <>
|
||||
|
@ -1171,8 +1169,8 @@ pack<WebGLTexelFormat::RGBA5551, WebGLTexelPremultiplicationOp::Premultiply,
|
|||
uint8_t srcR = static_cast<uint8_t>(src[0] * scaleFactor);
|
||||
uint8_t srcG = static_cast<uint8_t>(src[1] * scaleFactor);
|
||||
uint8_t srcB = static_cast<uint8_t>(src[2] * scaleFactor);
|
||||
*dst = uint16_t(((srcR & 0xF8) << 8) | ((srcG & 0xF8) << 3) |
|
||||
((srcB & 0xF8) >> 2) | (src[3] >> 7));
|
||||
*dst = uint16_t(((srcR & 0xF8) << 8) | ((srcG & 0xF8) << 3) | ((srcB & 0xF8) >> 2) |
|
||||
(src[3] >> 7));
|
||||
}
|
||||
|
||||
// FIXME: this routine is lossy and must be removed.
|
||||
|
@ -1185,8 +1183,8 @@ pack<WebGLTexelFormat::RGBA5551, WebGLTexelPremultiplicationOp::Unpremultiply,
|
|||
uint8_t srcR = static_cast<uint8_t>(src[0] * scaleFactor);
|
||||
uint8_t srcG = static_cast<uint8_t>(src[1] * scaleFactor);
|
||||
uint8_t srcB = static_cast<uint8_t>(src[2] * scaleFactor);
|
||||
*dst = uint16_t(((srcR & 0xF8) << 8) | ((srcG & 0xF8) << 3) |
|
||||
((srcB & 0xF8) >> 2) | (src[3] >> 7));
|
||||
*dst = uint16_t(((srcR & 0xF8) << 8) | ((srcG & 0xF8) << 3) | ((srcB & 0xF8) >> 2) |
|
||||
(src[3] >> 7));
|
||||
}
|
||||
|
||||
template <>
|
||||
|
|
|
@ -270,8 +270,7 @@ class WebGLTexture final : public nsWrapperCache,
|
|||
case LOCAL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
|
||||
case LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
|
||||
case LOCAL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
|
||||
return AutoAssertCast(rawTexImageTarget -
|
||||
LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_X);
|
||||
return AutoAssertCast(rawTexImageTarget - LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_X);
|
||||
|
||||
default:
|
||||
return 0;
|
||||
|
|
|
@ -60,14 +60,14 @@ inline void* calloc(const ForbidNarrowing<size_t> n,
|
|||
|
||||
namespace detail {
|
||||
|
||||
template <typename From>
|
||||
template<typename From>
|
||||
class AutoAssertCastT final {
|
||||
const From mVal;
|
||||
|
||||
public:
|
||||
explicit AutoAssertCastT(const From val) : mVal(val) {}
|
||||
public:
|
||||
explicit AutoAssertCastT(const From val) : mVal(val) { }
|
||||
|
||||
template <typename To>
|
||||
template<typename To>
|
||||
operator To() const {
|
||||
return AssertedCast<To>(mVal);
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ class AutoAssertCastT final {
|
|||
|
||||
} // namespace detail
|
||||
|
||||
template <typename From>
|
||||
template<typename From>
|
||||
inline auto AutoAssertCast(const From val) {
|
||||
return detail::AutoAssertCastT<From>(val);
|
||||
}
|
||||
|
|
|
@ -720,8 +720,7 @@ class LabData : public SimpleImage<float> {
|
|||
/*
|
||||
* From RGB24.
|
||||
*/
|
||||
TEST(ImageBitmapColorUtils, RGB24ToBGR24_)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, RGB24ToBGR24_) {
|
||||
const RGB24Data srcData;
|
||||
const BGR24Data dstData;
|
||||
SimpleImage<uint8_t> result_(srcData.mWidth, srcData.mHeight,
|
||||
|
@ -746,8 +745,7 @@ TEST(ImageBitmapColorUtils, RGB24ToBGR24_)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, RGB24ToRGBA32)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, RGB24ToRGBA32) {
|
||||
const RGB24Data srcData;
|
||||
const RGBA32Data dstData;
|
||||
SimpleImage<uint8_t> result_(srcData.mWidth, srcData.mHeight,
|
||||
|
@ -775,8 +773,7 @@ TEST(ImageBitmapColorUtils, RGB24ToRGBA32)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, RGB24ToBGRA32)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, RGB24ToBGRA32) {
|
||||
const RGB24Data srcData;
|
||||
const BGRA32Data dstData;
|
||||
|
||||
|
@ -848,8 +845,7 @@ TEST(ImageBitmapColorUtils, RGB24ToBGRA32)
|
|||
// gbaPixel[0], rgbaPixel[1], rgbaPixel[2], rgbaPixel[3]);
|
||||
//}
|
||||
|
||||
TEST(ImageBitmapColorUtils, RGB24ToYUV444P)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, RGB24ToYUV444P) {
|
||||
const RGB24Data srcData;
|
||||
const YUV444PData dstData;
|
||||
|
||||
|
@ -876,8 +872,7 @@ TEST(ImageBitmapColorUtils, RGB24ToYUV444P)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, RGB24ToYUV422P)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, RGB24ToYUV422P) {
|
||||
const RGB24Data srcData;
|
||||
const YUV422PData dstData;
|
||||
|
||||
|
@ -909,8 +904,7 @@ TEST(ImageBitmapColorUtils, RGB24ToYUV422P)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, RGB24ToYUV420P)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, RGB24ToYUV420P) {
|
||||
const RGB24Data srcData;
|
||||
const YUV420PData dstData;
|
||||
|
||||
|
@ -943,8 +937,7 @@ TEST(ImageBitmapColorUtils, RGB24ToYUV420P)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, RGB24ToNV12)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, RGB24ToNV12) {
|
||||
const RGB24Data srcData;
|
||||
const NV12Data dstData;
|
||||
|
||||
|
@ -975,8 +968,7 @@ TEST(ImageBitmapColorUtils, RGB24ToNV12)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, RGB24ToNV21)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, RGB24ToNV21) {
|
||||
const RGB24Data srcData;
|
||||
const NV21Data dstData;
|
||||
|
||||
|
@ -1007,8 +999,7 @@ TEST(ImageBitmapColorUtils, RGB24ToNV21)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, RGB24ToHSV)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, RGB24ToHSV) {
|
||||
const RGB24Data srcData;
|
||||
const HSVData dstData;
|
||||
|
||||
|
@ -1031,8 +1022,7 @@ TEST(ImageBitmapColorUtils, RGB24ToHSV)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, RGB24ToLab)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, RGB24ToLab) {
|
||||
const RGB24Data srcData;
|
||||
const LabData dstData;
|
||||
|
||||
|
@ -1055,8 +1045,7 @@ TEST(ImageBitmapColorUtils, RGB24ToLab)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, RGB24ToGray8)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, RGB24ToGray8) {
|
||||
const RGB24Data srcData;
|
||||
const GrayData dstData;
|
||||
|
||||
|
@ -1079,8 +1068,7 @@ TEST(ImageBitmapColorUtils, RGB24ToGray8)
|
|||
* From BGR24.
|
||||
*/
|
||||
|
||||
TEST(ImageBitmapColorUtils, BGR24ToRGB24_)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, BGR24ToRGB24_) {
|
||||
const BGR24Data srcData;
|
||||
const RGB24Data dstData;
|
||||
SimpleImage<uint8_t> result_(srcData.mWidth, srcData.mHeight,
|
||||
|
@ -1105,8 +1093,7 @@ TEST(ImageBitmapColorUtils, BGR24ToRGB24_)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, BGR24ToRGBA32)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, BGR24ToRGBA32) {
|
||||
const BGR24Data srcData;
|
||||
const RGBA32Data dstData;
|
||||
SimpleImage<uint8_t> result_(srcData.mWidth, srcData.mHeight,
|
||||
|
@ -1134,8 +1121,7 @@ TEST(ImageBitmapColorUtils, BGR24ToRGBA32)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, BGR24ToBGRA32)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, BGR24ToBGRA32) {
|
||||
const BGR24Data srcData;
|
||||
const BGRA32Data dstData;
|
||||
SimpleImage<uint8_t> result_(srcData.mWidth, srcData.mHeight,
|
||||
|
@ -1163,8 +1149,7 @@ TEST(ImageBitmapColorUtils, BGR24ToBGRA32)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, BGR24ToYUV444P)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, BGR24ToYUV444P) {
|
||||
const BGR24Data srcData;
|
||||
const YUV444PData dstData;
|
||||
|
||||
|
@ -1191,8 +1176,7 @@ TEST(ImageBitmapColorUtils, BGR24ToYUV444P)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, BGR24ToYUV422P)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, BGR24ToYUV422P) {
|
||||
const BGR24Data srcData;
|
||||
const YUV422PData dstData;
|
||||
|
||||
|
@ -1224,8 +1208,7 @@ TEST(ImageBitmapColorUtils, BGR24ToYUV422P)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, BGR24ToYUV420P)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, BGR24ToYUV420P) {
|
||||
const BGR24Data srcData;
|
||||
const YUV420PData dstData;
|
||||
|
||||
|
@ -1258,8 +1241,7 @@ TEST(ImageBitmapColorUtils, BGR24ToYUV420P)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, BGR24ToNV12)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, BGR24ToNV12) {
|
||||
const BGR24Data srcData;
|
||||
const NV12Data dstData;
|
||||
|
||||
|
@ -1290,8 +1272,7 @@ TEST(ImageBitmapColorUtils, BGR24ToNV12)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, BGR24ToNV21)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, BGR24ToNV21) {
|
||||
const BGR24Data srcData;
|
||||
const NV21Data dstData;
|
||||
|
||||
|
@ -1322,8 +1303,7 @@ TEST(ImageBitmapColorUtils, BGR24ToNV21)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, BGR24ToHSV)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, BGR24ToHSV) {
|
||||
const BGR24Data srcData;
|
||||
const HSVData dstData;
|
||||
|
||||
|
@ -1346,8 +1326,7 @@ TEST(ImageBitmapColorUtils, BGR24ToHSV)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, BGR24ToLab)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, BGR24ToLab) {
|
||||
const BGR24Data srcData;
|
||||
const LabData dstData;
|
||||
|
||||
|
@ -1370,8 +1349,7 @@ TEST(ImageBitmapColorUtils, BGR24ToLab)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, BGR24ToGray8)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, BGR24ToGray8) {
|
||||
const BGR24Data srcData;
|
||||
const GrayData dstData;
|
||||
|
||||
|
@ -1393,8 +1371,7 @@ TEST(ImageBitmapColorUtils, BGR24ToGray8)
|
|||
/*
|
||||
* From RGBA32.
|
||||
*/
|
||||
TEST(ImageBitmapColorUtils, RGBA32ToRGB24)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, RGBA32ToRGB24) {
|
||||
const RGBA32Data srcData;
|
||||
const RGB24Data dstData;
|
||||
SimpleImage<uint8_t> result_(srcData.mWidth, srcData.mHeight,
|
||||
|
@ -1419,8 +1396,7 @@ TEST(ImageBitmapColorUtils, RGBA32ToRGB24)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, RGBA32ToBGR24)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, RGBA32ToBGR24) {
|
||||
const RGBA32Data srcData;
|
||||
const BGR24Data dstData;
|
||||
SimpleImage<uint8_t> result_(srcData.mWidth, srcData.mHeight,
|
||||
|
@ -1445,8 +1421,7 @@ TEST(ImageBitmapColorUtils, RGBA32ToBGR24)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, RGBA32ToYUV444P)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, RGBA32ToYUV444P) {
|
||||
const RGBA32Data srcData;
|
||||
const YUV444PData dstData;
|
||||
|
||||
|
@ -1473,8 +1448,7 @@ TEST(ImageBitmapColorUtils, RGBA32ToYUV444P)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, RGBA32ToYUV422P)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, RGBA32ToYUV422P) {
|
||||
const RGBA32Data srcData;
|
||||
const YUV422PData dstData;
|
||||
|
||||
|
@ -1506,8 +1480,7 @@ TEST(ImageBitmapColorUtils, RGBA32ToYUV422P)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, RGBA32ToYUV420P)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, RGBA32ToYUV420P) {
|
||||
const RGBA32Data srcData;
|
||||
const YUV420PData dstData;
|
||||
|
||||
|
@ -1540,8 +1513,7 @@ TEST(ImageBitmapColorUtils, RGBA32ToYUV420P)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, RGBA32ToNV12)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, RGBA32ToNV12) {
|
||||
const RGBA32Data srcData;
|
||||
const NV12Data dstData;
|
||||
|
||||
|
@ -1572,8 +1544,7 @@ TEST(ImageBitmapColorUtils, RGBA32ToNV12)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, RGBA32ToNV21)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, RGBA32ToNV21) {
|
||||
const RGBA32Data srcData;
|
||||
const NV21Data dstData;
|
||||
|
||||
|
@ -1604,8 +1575,7 @@ TEST(ImageBitmapColorUtils, RGBA32ToNV21)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, RGBA32ToHSV)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, RGBA32ToHSV) {
|
||||
const RGBA32Data srcData;
|
||||
const HSVData dstData;
|
||||
|
||||
|
@ -1628,8 +1598,7 @@ TEST(ImageBitmapColorUtils, RGBA32ToHSV)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, RGBA32ToLab)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, RGBA32ToLab) {
|
||||
const RGBA32Data srcData;
|
||||
const LabData dstData;
|
||||
|
||||
|
@ -1652,8 +1621,7 @@ TEST(ImageBitmapColorUtils, RGBA32ToLab)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, RGBA32ToGray8)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, RGBA32ToGray8) {
|
||||
const RGBA32Data srcData;
|
||||
const GrayData dstData;
|
||||
|
||||
|
@ -1675,8 +1643,7 @@ TEST(ImageBitmapColorUtils, RGBA32ToGray8)
|
|||
/*
|
||||
* From BGRA32.
|
||||
*/
|
||||
TEST(ImageBitmapColorUtils, BGRA32ToRGB24)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, BGRA32ToRGB24) {
|
||||
const BGRA32Data srcData;
|
||||
const RGB24Data dstData;
|
||||
SimpleImage<uint8_t> result_(srcData.mWidth, srcData.mHeight,
|
||||
|
@ -1701,8 +1668,7 @@ TEST(ImageBitmapColorUtils, BGRA32ToRGB24)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, BGRA32ToBGR24)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, BGRA32ToBGR24) {
|
||||
const BGRA32Data srcData;
|
||||
const BGR24Data dstData;
|
||||
SimpleImage<uint8_t> result_(srcData.mWidth, srcData.mHeight,
|
||||
|
@ -1727,8 +1693,7 @@ TEST(ImageBitmapColorUtils, BGRA32ToBGR24)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, BGRA32ToYUV444P)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, BGRA32ToYUV444P) {
|
||||
const BGRA32Data srcData;
|
||||
const YUV444PData dstData;
|
||||
|
||||
|
@ -1755,8 +1720,7 @@ TEST(ImageBitmapColorUtils, BGRA32ToYUV444P)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, BGRA32ToYUV422P)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, BGRA32ToYUV422P) {
|
||||
const BGRA32Data srcData;
|
||||
const YUV422PData dstData;
|
||||
|
||||
|
@ -1788,8 +1752,7 @@ TEST(ImageBitmapColorUtils, BGRA32ToYUV422P)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, BGRA32ToYUV420P)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, BGRA32ToYUV420P) {
|
||||
const BGRA32Data srcData;
|
||||
const YUV420PData dstData;
|
||||
|
||||
|
@ -1822,8 +1785,7 @@ TEST(ImageBitmapColorUtils, BGRA32ToYUV420P)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, BGRA32ToNV12)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, BGRA32ToNV12) {
|
||||
const BGRA32Data srcData;
|
||||
const NV12Data dstData;
|
||||
|
||||
|
@ -1854,8 +1816,7 @@ TEST(ImageBitmapColorUtils, BGRA32ToNV12)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, BGRA32ToNV21)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, BGRA32ToNV21) {
|
||||
const BGRA32Data srcData;
|
||||
const NV21Data dstData;
|
||||
|
||||
|
@ -1886,8 +1847,7 @@ TEST(ImageBitmapColorUtils, BGRA32ToNV21)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, BGRA32ToHSV)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, BGRA32ToHSV) {
|
||||
const BGRA32Data srcData;
|
||||
const HSVData dstData;
|
||||
|
||||
|
@ -1910,8 +1870,7 @@ TEST(ImageBitmapColorUtils, BGRA32ToHSV)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, BGRA32ToLab)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, BGRA32ToLab) {
|
||||
const BGRA32Data srcData;
|
||||
const LabData dstData;
|
||||
|
||||
|
@ -1934,8 +1893,7 @@ TEST(ImageBitmapColorUtils, BGRA32ToLab)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, BGRA32ToGray8)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, BGRA32ToGray8) {
|
||||
const BGRA32Data srcData;
|
||||
const GrayData dstData;
|
||||
|
||||
|
@ -1957,8 +1915,7 @@ TEST(ImageBitmapColorUtils, BGRA32ToGray8)
|
|||
/*
|
||||
* From YUV444P.
|
||||
*/
|
||||
TEST(ImageBitmapColorUtils, YUV444PToRGB24)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, YUV444PToRGB24) {
|
||||
const YUV444PData srcData;
|
||||
const RGBA32DataFromYUV444PData dstData;
|
||||
SimpleImage<uint8_t> result_(srcData.mYWidth, srcData.mYHeight, 3);
|
||||
|
@ -1984,8 +1941,7 @@ TEST(ImageBitmapColorUtils, YUV444PToRGB24)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, YUV444PToBGR24)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, YUV444PToBGR24) {
|
||||
const YUV444PData srcData;
|
||||
const RGBA32DataFromYUV444PData dstData;
|
||||
SimpleImage<uint8_t> result_(srcData.mYWidth, srcData.mYHeight, 3);
|
||||
|
@ -2011,8 +1967,7 @@ TEST(ImageBitmapColorUtils, YUV444PToBGR24)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, YUV444PToRGBA32)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, YUV444PToRGBA32) {
|
||||
const YUV444PData srcData;
|
||||
const RGBA32DataFromYUV444PData dstData;
|
||||
SimpleImage<uint8_t> result_(srcData.mYWidth, srcData.mYHeight,
|
||||
|
@ -2042,8 +1997,7 @@ TEST(ImageBitmapColorUtils, YUV444PToRGBA32)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, YUV444PToBGRA32)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, YUV444PToBGRA32) {
|
||||
const YUV444PData srcData;
|
||||
const RGBA32DataFromYUV444PData dstData;
|
||||
SimpleImage<uint8_t> result_(srcData.mYWidth, srcData.mYHeight,
|
||||
|
@ -2073,8 +2027,7 @@ TEST(ImageBitmapColorUtils, YUV444PToBGRA32)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, YUV444PToGray8)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, YUV444PToGray8) {
|
||||
const YUV444PData srcData;
|
||||
SimpleImage<uint8_t> result_(srcData.mYWidth, srcData.mYHeight, 1);
|
||||
|
||||
|
@ -2096,8 +2049,7 @@ TEST(ImageBitmapColorUtils, YUV444PToGray8)
|
|||
/*
|
||||
* From YUV422P.
|
||||
*/
|
||||
TEST(ImageBitmapColorUtils, YUV422PToRGB24)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, YUV422PToRGB24) {
|
||||
const YUV422PData srcData;
|
||||
const RGBA32DataFromYUV422PData dstData;
|
||||
SimpleImage<uint8_t> result_(srcData.mYWidth, srcData.mYHeight, 3);
|
||||
|
@ -2123,8 +2075,7 @@ TEST(ImageBitmapColorUtils, YUV422PToRGB24)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, YUV422PToBGR24)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, YUV422PToBGR24) {
|
||||
const YUV422PData srcData;
|
||||
const RGBA32DataFromYUV422PData dstData;
|
||||
SimpleImage<uint8_t> result_(srcData.mYWidth, srcData.mYHeight, 3);
|
||||
|
@ -2150,8 +2101,7 @@ TEST(ImageBitmapColorUtils, YUV422PToBGR24)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, YUV422PToRGBA32)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, YUV422PToRGBA32) {
|
||||
const YUV422PData srcData;
|
||||
const RGBA32DataFromYUV422PData dstData;
|
||||
SimpleImage<uint8_t> result_(srcData.mYWidth, srcData.mYHeight,
|
||||
|
@ -2181,8 +2131,7 @@ TEST(ImageBitmapColorUtils, YUV422PToRGBA32)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, YUV422PToBGRA32)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, YUV422PToBGRA32) {
|
||||
const YUV422PData srcData;
|
||||
const RGBA32DataFromYUV422PData dstData;
|
||||
SimpleImage<uint8_t> result_(srcData.mYWidth, srcData.mYHeight,
|
||||
|
@ -2212,8 +2161,7 @@ TEST(ImageBitmapColorUtils, YUV422PToBGRA32)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, YUV422PToGray8)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, YUV422PToGray8) {
|
||||
const YUV422PData srcData;
|
||||
SimpleImage<uint8_t> result_(srcData.mYWidth, srcData.mYHeight, 1);
|
||||
|
||||
|
@ -2235,8 +2183,7 @@ TEST(ImageBitmapColorUtils, YUV422PToGray8)
|
|||
/*
|
||||
* From YUV420P.
|
||||
*/
|
||||
TEST(ImageBitmapColorUtils, YUV420PToRGB24)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, YUV420PToRGB24) {
|
||||
const YUV420PData srcData;
|
||||
const RGBA32DataFromYUV420PData dstData;
|
||||
SimpleImage<uint8_t> result_(srcData.mYWidth, srcData.mYHeight, 3);
|
||||
|
@ -2262,8 +2209,7 @@ TEST(ImageBitmapColorUtils, YUV420PToRGB24)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, YUV420PToBGR24)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, YUV420PToBGR24) {
|
||||
const YUV420PData srcData;
|
||||
const RGBA32DataFromYUV420PData dstData;
|
||||
SimpleImage<uint8_t> result_(srcData.mYWidth, srcData.mYHeight, 3);
|
||||
|
@ -2289,8 +2235,7 @@ TEST(ImageBitmapColorUtils, YUV420PToBGR24)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, YUV420PToRGBA32)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, YUV420PToRGBA32) {
|
||||
const YUV420PData srcData;
|
||||
const RGBA32DataFromYUV420PData dstData;
|
||||
SimpleImage<uint8_t> result_(srcData.mYWidth, srcData.mYHeight,
|
||||
|
@ -2320,8 +2265,7 @@ TEST(ImageBitmapColorUtils, YUV420PToRGBA32)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, YUV420PToBGRA32)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, YUV420PToBGRA32) {
|
||||
const YUV420PData srcData;
|
||||
const RGBA32DataFromYUV420PData dstData;
|
||||
SimpleImage<uint8_t> result_(srcData.mYWidth, srcData.mYHeight,
|
||||
|
@ -2351,8 +2295,7 @@ TEST(ImageBitmapColorUtils, YUV420PToBGRA32)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, YUV420PToGray8)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, YUV420PToGray8) {
|
||||
const YUV420PData srcData;
|
||||
SimpleImage<uint8_t> result_(srcData.mYWidth, srcData.mYHeight, 1);
|
||||
|
||||
|
@ -2374,8 +2317,7 @@ TEST(ImageBitmapColorUtils, YUV420PToGray8)
|
|||
/*
|
||||
* From NV12.
|
||||
*/
|
||||
TEST(ImageBitmapColorUtils, NV12ToRGB24)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, NV12ToRGB24) {
|
||||
const NV12Data srcData;
|
||||
const RGBA32DataFromYUV420PData dstData;
|
||||
SimpleImage<uint8_t> result_(srcData.mYWidth, srcData.mYHeight, 3);
|
||||
|
@ -2400,8 +2342,7 @@ TEST(ImageBitmapColorUtils, NV12ToRGB24)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, NV12ToBGR24)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, NV12ToBGR24) {
|
||||
const NV12Data srcData;
|
||||
const RGBA32DataFromYUV420PData dstData;
|
||||
SimpleImage<uint8_t> result_(srcData.mYWidth, srcData.mYHeight, 3);
|
||||
|
@ -2426,8 +2367,7 @@ TEST(ImageBitmapColorUtils, NV12ToBGR24)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, NV12ToRGBA32)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, NV12ToRGBA32) {
|
||||
const NV12Data srcData;
|
||||
const RGBA32DataFromYUV420PData dstData;
|
||||
SimpleImage<uint8_t> result_(srcData.mYWidth, srcData.mYHeight,
|
||||
|
@ -2456,8 +2396,7 @@ TEST(ImageBitmapColorUtils, NV12ToRGBA32)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, NV12ToBGRA32)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, NV12ToBGRA32) {
|
||||
const NV12Data srcData;
|
||||
const RGBA32DataFromYUV420PData dstData;
|
||||
SimpleImage<uint8_t> result_(srcData.mYWidth, srcData.mYHeight,
|
||||
|
@ -2486,8 +2425,7 @@ TEST(ImageBitmapColorUtils, NV12ToBGRA32)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, NV12ToGray8)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, NV12ToGray8) {
|
||||
const NV12Data srcData;
|
||||
SimpleImage<uint8_t> result_(srcData.mYWidth, srcData.mYHeight, 1);
|
||||
|
||||
|
@ -2508,8 +2446,7 @@ TEST(ImageBitmapColorUtils, NV12ToGray8)
|
|||
/*
|
||||
* From NV21.
|
||||
*/
|
||||
TEST(ImageBitmapColorUtils, NV21ToRGB24)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, NV21ToRGB24) {
|
||||
const NV21Data srcData;
|
||||
const RGBA32DataFromYUV420PData dstData;
|
||||
SimpleImage<uint8_t> result_(srcData.mYWidth, srcData.mYHeight, 3);
|
||||
|
@ -2534,8 +2471,7 @@ TEST(ImageBitmapColorUtils, NV21ToRGB24)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, NV21ToBGR24)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, NV21ToBGR24) {
|
||||
const NV21Data srcData;
|
||||
const RGBA32DataFromYUV420PData dstData;
|
||||
SimpleImage<uint8_t> result_(srcData.mYWidth, srcData.mYHeight, 3);
|
||||
|
@ -2560,8 +2496,7 @@ TEST(ImageBitmapColorUtils, NV21ToBGR24)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, NV21ToRGBA32)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, NV21ToRGBA32) {
|
||||
const NV21Data srcData;
|
||||
const RGBA32DataFromYUV420PData dstData;
|
||||
SimpleImage<uint8_t> result_(srcData.mYWidth, srcData.mYHeight,
|
||||
|
@ -2590,8 +2525,7 @@ TEST(ImageBitmapColorUtils, NV21ToRGBA32)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, NV21ToBGRA32)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, NV21ToBGRA32) {
|
||||
const NV21Data srcData;
|
||||
const RGBA32DataFromYUV420PData dstData;
|
||||
SimpleImage<uint8_t> result_(srcData.mYWidth, srcData.mYHeight,
|
||||
|
@ -2620,8 +2554,7 @@ TEST(ImageBitmapColorUtils, NV21ToBGRA32)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, NV21ToGray8)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, NV21ToGray8) {
|
||||
const NV21Data srcData;
|
||||
SimpleImage<uint8_t> result_(srcData.mYWidth, srcData.mYHeight, 1);
|
||||
|
||||
|
@ -2642,8 +2575,7 @@ TEST(ImageBitmapColorUtils, NV21ToGray8)
|
|||
/*
|
||||
* From HSV.
|
||||
*/
|
||||
TEST(ImageBitmapColorUtils, HSVToRGB24)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, HSVToRGB24) {
|
||||
const HSVData srcData;
|
||||
const RGB24Data dstData;
|
||||
SimpleImage<uint8_t> result_(srcData.mWidth, srcData.mHeight,
|
||||
|
@ -2664,8 +2596,7 @@ TEST(ImageBitmapColorUtils, HSVToRGB24)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, HSVToBGR24)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, HSVToBGR24) {
|
||||
const HSVData srcData;
|
||||
const BGR24Data dstData;
|
||||
SimpleImage<uint8_t> result_(srcData.mWidth, srcData.mHeight,
|
||||
|
@ -2686,8 +2617,7 @@ TEST(ImageBitmapColorUtils, HSVToBGR24)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, HSVToRGBA32)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, HSVToRGBA32) {
|
||||
const HSVData srcData;
|
||||
const RGBA32Data dstData;
|
||||
SimpleImage<uint8_t> result_(srcData.mWidth, srcData.mHeight,
|
||||
|
@ -2708,8 +2638,7 @@ TEST(ImageBitmapColorUtils, HSVToRGBA32)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, HSVToBGRA32)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, HSVToBGRA32) {
|
||||
const HSVData srcData;
|
||||
const BGRA32Data dstData;
|
||||
SimpleImage<uint8_t> result_(srcData.mWidth, srcData.mHeight,
|
||||
|
@ -2733,8 +2662,7 @@ TEST(ImageBitmapColorUtils, HSVToBGRA32)
|
|||
/*
|
||||
* From Lab.
|
||||
*/
|
||||
TEST(ImageBitmapColorUtils, LabToRGB24)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, LabToRGB24) {
|
||||
const LabData srcData;
|
||||
const RGB24Data dstData;
|
||||
SimpleImage<uint8_t> result_(srcData.mWidth, srcData.mHeight,
|
||||
|
@ -2757,8 +2685,7 @@ TEST(ImageBitmapColorUtils, LabToRGB24)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, LabToBGR24)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, LabToBGR24) {
|
||||
const LabData srcData;
|
||||
const BGR24Data dstData;
|
||||
SimpleImage<uint8_t> result_(srcData.mWidth, srcData.mHeight,
|
||||
|
@ -2781,8 +2708,7 @@ TEST(ImageBitmapColorUtils, LabToBGR24)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, LabToRGBA32)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, LabToRGBA32) {
|
||||
const LabData srcData;
|
||||
const RGBA32Data dstData;
|
||||
SimpleImage<uint8_t> result_(srcData.mWidth, srcData.mHeight,
|
||||
|
@ -2805,8 +2731,7 @@ TEST(ImageBitmapColorUtils, LabToRGBA32)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ImageBitmapColorUtils, LabToBGRA32)
|
||||
{
|
||||
TEST(ImageBitmapColorUtils, LabToBGRA32) {
|
||||
const LabData srcData;
|
||||
const BGRA32Data dstData;
|
||||
SimpleImage<uint8_t> result_(srcData.mWidth, srcData.mHeight,
|
||||
|
|
|
@ -150,20 +150,19 @@ already_AddRefed<Promise> Client::Focus(ErrorResult& aRv) {
|
|||
MakeRefPtr<DOMMozPromiseRequestHolder<ClientStatePromise>>(mGlobal);
|
||||
|
||||
mHandle->Focus()
|
||||
->Then(
|
||||
mGlobal->EventTargetFor(TaskCategory::Other), __func__,
|
||||
[ipcClientInfo, holder, outerPromise](const ClientState& aResult) {
|
||||
holder->Complete();
|
||||
NS_ENSURE_TRUE_VOID(holder->GetParentObject());
|
||||
RefPtr<Client> newClient =
|
||||
new Client(holder->GetParentObject(),
|
||||
ClientInfoAndState(ipcClientInfo, aResult.ToIPC()));
|
||||
outerPromise->MaybeResolve(newClient);
|
||||
},
|
||||
[holder, outerPromise](nsresult aResult) {
|
||||
holder->Complete();
|
||||
outerPromise->MaybeReject(aResult);
|
||||
})
|
||||
->Then(mGlobal->EventTargetFor(TaskCategory::Other), __func__,
|
||||
[ipcClientInfo, holder, outerPromise](const ClientState& aResult) {
|
||||
holder->Complete();
|
||||
NS_ENSURE_TRUE_VOID(holder->GetParentObject());
|
||||
RefPtr<Client> newClient = new Client(
|
||||
holder->GetParentObject(),
|
||||
ClientInfoAndState(ipcClientInfo, aResult.ToIPC()));
|
||||
outerPromise->MaybeResolve(newClient);
|
||||
},
|
||||
[holder, outerPromise](nsresult aResult) {
|
||||
holder->Complete();
|
||||
outerPromise->MaybeReject(aResult);
|
||||
})
|
||||
->Track(*holder);
|
||||
|
||||
return outerPromise.forget();
|
||||
|
|
|
@ -32,16 +32,15 @@ void StartClientManagerOp(Func aFunc, const Arg& aArg, nsIGlobalObject* aGlobal,
|
|||
MakeRefPtr<DOMMozPromiseRequestHolder<ClientOpPromise>>(aGlobal);
|
||||
|
||||
aFunc(aArg, target)
|
||||
->Then(
|
||||
target, __func__,
|
||||
[aResolve, holder](const ClientOpResult& aResult) {
|
||||
holder->Complete();
|
||||
aResolve(aResult);
|
||||
},
|
||||
[aReject, holder](nsresult aResult) {
|
||||
holder->Complete();
|
||||
aReject(aResult);
|
||||
})
|
||||
->Then(target, __func__,
|
||||
[aResolve, holder](const ClientOpResult& aResult) {
|
||||
holder->Complete();
|
||||
aResolve(aResult);
|
||||
},
|
||||
[aReject, holder](nsresult aResult) {
|
||||
holder->Complete();
|
||||
aReject(aResult);
|
||||
})
|
||||
->Track(*holder);
|
||||
}
|
||||
|
||||
|
|
|
@ -80,31 +80,30 @@ already_AddRefed<Promise> Clients::Get(const nsAString& aClientID,
|
|||
MakeRefPtr<DOMMozPromiseRequestHolder<ClientOpPromise>>(mGlobal);
|
||||
|
||||
innerPromise
|
||||
->Then(
|
||||
target, __func__,
|
||||
[outerPromise, holder, scope](const ClientOpResult& aResult) {
|
||||
holder->Complete();
|
||||
NS_ENSURE_TRUE_VOID(holder->GetParentObject());
|
||||
RefPtr<Client> client = new Client(
|
||||
holder->GetParentObject(), aResult.get_ClientInfoAndState());
|
||||
if (client->GetStorageAccess() ==
|
||||
nsContentUtils::StorageAccess::eAllow) {
|
||||
outerPromise->MaybeResolve(std::move(client));
|
||||
return;
|
||||
}
|
||||
nsCOMPtr<nsIRunnable> r = NS_NewRunnableFunction(
|
||||
"Clients::Get() storage denied", [scope] {
|
||||
ServiceWorkerManager::LocalizeAndReportToAllClients(
|
||||
scope, "ServiceWorkerGetClientStorageError",
|
||||
nsTArray<nsString>());
|
||||
});
|
||||
SystemGroup::Dispatch(TaskCategory::Other, r.forget());
|
||||
outerPromise->MaybeResolveWithUndefined();
|
||||
},
|
||||
[outerPromise, holder](nsresult aResult) {
|
||||
holder->Complete();
|
||||
outerPromise->MaybeResolveWithUndefined();
|
||||
})
|
||||
->Then(target, __func__,
|
||||
[outerPromise, holder, scope](const ClientOpResult& aResult) {
|
||||
holder->Complete();
|
||||
NS_ENSURE_TRUE_VOID(holder->GetParentObject());
|
||||
RefPtr<Client> client = new Client(
|
||||
holder->GetParentObject(), aResult.get_ClientInfoAndState());
|
||||
if (client->GetStorageAccess() ==
|
||||
nsContentUtils::StorageAccess::eAllow) {
|
||||
outerPromise->MaybeResolve(std::move(client));
|
||||
return;
|
||||
}
|
||||
nsCOMPtr<nsIRunnable> r = NS_NewRunnableFunction(
|
||||
"Clients::Get() storage denied", [scope] {
|
||||
ServiceWorkerManager::LocalizeAndReportToAllClients(
|
||||
scope, "ServiceWorkerGetClientStorageError",
|
||||
nsTArray<nsString>());
|
||||
});
|
||||
SystemGroup::Dispatch(TaskCategory::Other, r.forget());
|
||||
outerPromise->MaybeResolveWithUndefined();
|
||||
},
|
||||
[outerPromise, holder](nsresult aResult) {
|
||||
holder->Complete();
|
||||
outerPromise->MaybeResolveWithUndefined();
|
||||
})
|
||||
->Track(*holder);
|
||||
|
||||
return outerPromise.forget();
|
||||
|
|
|
@ -110,14 +110,13 @@ RefPtr<GenericPromise> ClientHandle::Control(
|
|||
MOZ_RELEASE_ASSERT(ClientMatchPrincipalInfo(mClientInfo.PrincipalInfo(),
|
||||
aServiceWorker.PrincipalInfo()));
|
||||
|
||||
StartOp(
|
||||
ClientControlledArgs(aServiceWorker.ToIPC()),
|
||||
[outerPromise](const ClientOpResult& aResult) {
|
||||
outerPromise->Resolve(true, __func__);
|
||||
},
|
||||
[outerPromise](const ClientOpResult& aResult) {
|
||||
outerPromise->Reject(aResult.get_nsresult(), __func__);
|
||||
});
|
||||
StartOp(ClientControlledArgs(aServiceWorker.ToIPC()),
|
||||
[outerPromise](const ClientOpResult& aResult) {
|
||||
outerPromise->Resolve(true, __func__);
|
||||
},
|
||||
[outerPromise](const ClientOpResult& aResult) {
|
||||
outerPromise->Reject(aResult.get_nsresult(), __func__);
|
||||
});
|
||||
|
||||
return outerPromise.forget();
|
||||
}
|
||||
|
@ -126,15 +125,14 @@ RefPtr<ClientStatePromise> ClientHandle::Focus() {
|
|||
RefPtr<ClientStatePromise::Private> outerPromise =
|
||||
new ClientStatePromise::Private(__func__);
|
||||
|
||||
StartOp(
|
||||
ClientFocusArgs(),
|
||||
[outerPromise](const ClientOpResult& aResult) {
|
||||
outerPromise->Resolve(
|
||||
ClientState::FromIPC(aResult.get_IPCClientState()), __func__);
|
||||
},
|
||||
[outerPromise](const ClientOpResult& aResult) {
|
||||
outerPromise->Reject(aResult.get_nsresult(), __func__);
|
||||
});
|
||||
StartOp(ClientFocusArgs(),
|
||||
[outerPromise](const ClientOpResult& aResult) {
|
||||
outerPromise->Resolve(
|
||||
ClientState::FromIPC(aResult.get_IPCClientState()), __func__);
|
||||
},
|
||||
[outerPromise](const ClientOpResult& aResult) {
|
||||
outerPromise->Reject(aResult.get_nsresult(), __func__);
|
||||
});
|
||||
|
||||
return outerPromise.forget();
|
||||
}
|
||||
|
@ -158,14 +156,13 @@ RefPtr<GenericPromise> ClientHandle::PostMessage(
|
|||
RefPtr<GenericPromise::Private> outerPromise =
|
||||
new GenericPromise::Private(__func__);
|
||||
|
||||
StartOp(
|
||||
args,
|
||||
[outerPromise](const ClientOpResult& aResult) {
|
||||
outerPromise->Resolve(true, __func__);
|
||||
},
|
||||
[outerPromise](const ClientOpResult& aResult) {
|
||||
outerPromise->Reject(aResult.get_nsresult(), __func__);
|
||||
});
|
||||
StartOp(args,
|
||||
[outerPromise](const ClientOpResult& aResult) {
|
||||
outerPromise->Resolve(true, __func__);
|
||||
},
|
||||
[outerPromise](const ClientOpResult& aResult) {
|
||||
outerPromise->Reject(aResult.get_nsresult(), __func__);
|
||||
});
|
||||
|
||||
return outerPromise.forget();
|
||||
}
|
||||
|
|
|
@ -62,16 +62,15 @@ void ClientHandleOpParent::Init(const ClientOpConstructorArgs& aArgs) {
|
|||
// Capturing 'this' is safe here because we disconnect the promise in
|
||||
// ActorDestroy() which ensures neither lambda is called if the actor
|
||||
// is destroyed before the source operation completes.
|
||||
p->Then(
|
||||
GetCurrentThreadSerialEventTarget(), __func__,
|
||||
[this](const ClientOpResult& aResult) {
|
||||
mPromiseRequestHolder.Complete();
|
||||
Unused << PClientHandleOpParent::Send__delete__(this, aResult);
|
||||
},
|
||||
[this](nsresult aRv) {
|
||||
mPromiseRequestHolder.Complete();
|
||||
Unused << PClientHandleOpParent::Send__delete__(this, aRv);
|
||||
})
|
||||
p->Then(GetCurrentThreadSerialEventTarget(), __func__,
|
||||
[this](const ClientOpResult& aResult) {
|
||||
mPromiseRequestHolder.Complete();
|
||||
Unused << PClientHandleOpParent::Send__delete__(this, aResult);
|
||||
},
|
||||
[this](nsresult aRv) {
|
||||
mPromiseRequestHolder.Complete();
|
||||
Unused << PClientHandleOpParent::Send__delete__(this, aRv);
|
||||
})
|
||||
->Track(mPromiseRequestHolder);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,16 +24,15 @@ void ClientManagerOpParent::DoServiceOp(Method aMethod, Args&&... aArgs) {
|
|||
// Capturing `this` is safe here because we disconnect the promise in
|
||||
// ActorDestroy() which ensures neither lambda is called if the actor
|
||||
// is destroyed before the source operation completes.
|
||||
p->Then(
|
||||
GetCurrentThreadSerialEventTarget(), __func__,
|
||||
[this](const mozilla::dom::ClientOpResult& aResult) {
|
||||
mPromiseRequestHolder.Complete();
|
||||
Unused << PClientManagerOpParent::Send__delete__(this, aResult);
|
||||
},
|
||||
[this](nsresult aRv) {
|
||||
mPromiseRequestHolder.Complete();
|
||||
Unused << PClientManagerOpParent::Send__delete__(this, aRv);
|
||||
})
|
||||
p->Then(GetCurrentThreadSerialEventTarget(), __func__,
|
||||
[this](const mozilla::dom::ClientOpResult& aResult) {
|
||||
mPromiseRequestHolder.Complete();
|
||||
Unused << PClientManagerOpParent::Send__delete__(this, aResult);
|
||||
},
|
||||
[this](nsresult aRv) {
|
||||
mPromiseRequestHolder.Complete();
|
||||
Unused << PClientManagerOpParent::Send__delete__(this, aRv);
|
||||
})
|
||||
->Track(mPromiseRequestHolder);
|
||||
}
|
||||
|
||||
|
|
|
@ -287,16 +287,15 @@ void ClientNavigateOpChild::Init(const ClientNavigateOpConstructorArgs& aArgs) {
|
|||
// Capturing `this` is safe here since we clear the mPromiseRequestHolder in
|
||||
// ActorDestroy.
|
||||
promise
|
||||
->Then(
|
||||
mSerialEventTarget, __func__,
|
||||
[this](const ClientOpResult& aResult) {
|
||||
mPromiseRequestHolder.Complete();
|
||||
PClientNavigateOpChild::Send__delete__(this, aResult);
|
||||
},
|
||||
[this](nsresult aResult) {
|
||||
mPromiseRequestHolder.Complete();
|
||||
PClientNavigateOpChild::Send__delete__(this, aResult);
|
||||
})
|
||||
->Then(mSerialEventTarget, __func__,
|
||||
[this](const ClientOpResult& aResult) {
|
||||
mPromiseRequestHolder.Complete();
|
||||
PClientNavigateOpChild::Send__delete__(this, aResult);
|
||||
},
|
||||
[this](nsresult aResult) {
|
||||
mPromiseRequestHolder.Complete();
|
||||
PClientNavigateOpChild::Send__delete__(this, aResult);
|
||||
})
|
||||
->Track(mPromiseRequestHolder);
|
||||
}
|
||||
|
||||
|
|
|
@ -22,16 +22,15 @@ void ClientOpenWindowOpChild::ActorDestroy(ActorDestroyReason aReason) {
|
|||
|
||||
void ClientOpenWindowOpChild::Init(const ClientOpenWindowArgs& aArgs) {
|
||||
DoOpenWindow(aArgs)
|
||||
->Then(
|
||||
SystemGroup::EventTargetFor(TaskCategory::Other), __func__,
|
||||
[this](const ClientOpResult& aResult) {
|
||||
mPromiseRequestHolder.Complete();
|
||||
PClientOpenWindowOpChild::Send__delete__(this, aResult);
|
||||
},
|
||||
[this](nsresult aResult) {
|
||||
mPromiseRequestHolder.Complete();
|
||||
PClientOpenWindowOpChild::Send__delete__(this, aResult);
|
||||
})
|
||||
->Then(SystemGroup::EventTargetFor(TaskCategory::Other), __func__,
|
||||
[this](const ClientOpResult& aResult) {
|
||||
mPromiseRequestHolder.Complete();
|
||||
PClientOpenWindowOpChild::Send__delete__(this, aResult);
|
||||
},
|
||||
[this](nsresult aResult) {
|
||||
mPromiseRequestHolder.Complete();
|
||||
PClientOpenWindowOpChild::Send__delete__(this, aResult);
|
||||
})
|
||||
->Track(mPromiseRequestHolder);
|
||||
}
|
||||
|
||||
|
|
|
@ -302,10 +302,9 @@ void WaitForLoad(const ClientOpenWindowArgs& aArgs,
|
|||
}
|
||||
|
||||
// Hold the listener alive until the promise settles
|
||||
ref->Then(
|
||||
aOuterWindow->EventTargetFor(TaskCategory::Other), __func__,
|
||||
[listener](const ClientOpResult& aResult) {},
|
||||
[listener](nsresult aResult) {});
|
||||
ref->Then(aOuterWindow->EventTargetFor(TaskCategory::Other), __func__,
|
||||
[listener](const ClientOpResult& aResult) {},
|
||||
[listener](nsresult aResult) {});
|
||||
}
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
|
|
|
@ -35,9 +35,7 @@ bool ClientMatchPrincipalInfo(const PrincipalInfo& aLeft,
|
|||
// null principal never matches
|
||||
return false;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
default: { break; }
|
||||
}
|
||||
|
||||
// Clients (windows/workers) should never have an expanded principal type.
|
||||
|
|
|
@ -603,16 +603,15 @@ RefPtr<ClientOpPromise> ClientSource::Claim(const ClientClaimArgs& aArgs) {
|
|||
auto holder = MakeRefPtr<DOMMozPromiseRequestHolder<GenericPromise>>(global);
|
||||
|
||||
innerPromise
|
||||
->Then(
|
||||
mEventTarget, __func__,
|
||||
[outerPromise, holder](bool aResult) {
|
||||
holder->Complete();
|
||||
outerPromise->Resolve(NS_OK, __func__);
|
||||
},
|
||||
[outerPromise, holder](nsresult aResult) {
|
||||
holder->Complete();
|
||||
outerPromise->Reject(aResult, __func__);
|
||||
})
|
||||
->Then(mEventTarget, __func__,
|
||||
[outerPromise, holder](bool aResult) {
|
||||
holder->Complete();
|
||||
outerPromise->Resolve(NS_OK, __func__);
|
||||
},
|
||||
[outerPromise, holder](nsresult aResult) {
|
||||
holder->Complete();
|
||||
outerPromise->Reject(aResult, __func__);
|
||||
})
|
||||
->Track(*holder);
|
||||
|
||||
return outerPromise.forget();
|
||||
|
|
|
@ -56,16 +56,15 @@ void ClientSourceOpChild::DoSourceOp(Method aMethod, const Args& aArgs) {
|
|||
// If the ClientSource is doing something async it may throw away the
|
||||
// promise on its side if the global is closed.
|
||||
promise
|
||||
->Then(
|
||||
target, __func__,
|
||||
[this, promise](const mozilla::dom::ClientOpResult& aResult) {
|
||||
mPromiseRequestHolder.Complete();
|
||||
Unused << PClientSourceOpChild::Send__delete__(this, aResult);
|
||||
},
|
||||
[this, promise](nsresult aRv) {
|
||||
mPromiseRequestHolder.Complete();
|
||||
Unused << PClientSourceOpChild::Send__delete__(this, aRv);
|
||||
})
|
||||
->Then(target, __func__,
|
||||
[this, promise](const mozilla::dom::ClientOpResult& aResult) {
|
||||
mPromiseRequestHolder.Complete();
|
||||
Unused << PClientSourceOpChild::Send__delete__(this, aResult);
|
||||
},
|
||||
[this, promise](nsresult aRv) {
|
||||
mPromiseRequestHolder.Complete();
|
||||
Unused << PClientSourceOpChild::Send__delete__(this, aRv);
|
||||
})
|
||||
->Track(mPromiseRequestHolder);
|
||||
}
|
||||
|
||||
|
|
|
@ -68,8 +68,8 @@ class ClientThing {
|
|||
|
||||
// Conditionally execute the given callable based on the current state.
|
||||
template <typename Callable>
|
||||
void MaybeExecute(
|
||||
const Callable& aSuccess, const std::function<void()>& aFailure = [] {}) {
|
||||
void MaybeExecute(const Callable& aSuccess,
|
||||
const std::function<void()>& aFailure = [] {}) {
|
||||
AssertIsValid();
|
||||
if (mShutdown) {
|
||||
aFailure();
|
||||
|
|
|
@ -58,9 +58,7 @@ bool ClientIsValidPrincipalInfo(const PrincipalInfo& aPrincipalInfo) {
|
|||
// cases in the future.
|
||||
return specOrigin == originOrigin;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
default: { break; }
|
||||
}
|
||||
|
||||
// Windows and workers should not have expanded URLs, etc.
|
||||
|
@ -146,9 +144,7 @@ bool ClientIsValidCreationURL(const PrincipalInfo& aPrincipalInfo,
|
|||
// queries anyway.
|
||||
return true;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
default: { break; }
|
||||
}
|
||||
|
||||
// Clients (windows/workers) should never have an expanded principal type.
|
||||
|
|
|
@ -29,12 +29,11 @@ static NotNull<const Encoding*> SearchEncodingProp(
|
|||
const EncodingProp (&aProperties)[N], const nsACString& aKey) {
|
||||
const nsCString& flat = PromiseFlatCString(aKey);
|
||||
size_t index;
|
||||
if (!BinarySearchIf(
|
||||
aProperties, 0, ArrayLength(aProperties),
|
||||
[&flat](const EncodingProp& aProperty) {
|
||||
return flat.Compare(aProperty.mKey);
|
||||
},
|
||||
&index)) {
|
||||
if (!BinarySearchIf(aProperties, 0, ArrayLength(aProperties),
|
||||
[&flat](const EncodingProp& aProperty) {
|
||||
return flat.Compare(aProperty.mKey);
|
||||
},
|
||||
&index)) {
|
||||
return WINDOWS_1252_ENCODING;
|
||||
}
|
||||
return aProperties[index].mValue;
|
||||
|
|
|
@ -1296,9 +1296,7 @@ void EventStateManager::DispatchCrossProcessEvent(WidgetEvent* aEvent,
|
|||
remote->SendPluginEvent(*aEvent->AsPluginEvent());
|
||||
return;
|
||||
}
|
||||
default: {
|
||||
MOZ_CRASH("Attempt to send non-whitelisted event?");
|
||||
}
|
||||
default: { MOZ_CRASH("Attempt to send non-whitelisted event?"); }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6450,25 +6450,24 @@ bool HTMLMediaElement::TryRemoveMediaKeysAssociation() {
|
|||
if (mDecoder) {
|
||||
RefPtr<HTMLMediaElement> self = this;
|
||||
mDecoder->SetCDMProxy(nullptr)
|
||||
->Then(
|
||||
mAbstractMainThread, __func__,
|
||||
[self]() {
|
||||
self->mSetCDMRequest.Complete();
|
||||
->Then(mAbstractMainThread, __func__,
|
||||
[self]() {
|
||||
self->mSetCDMRequest.Complete();
|
||||
|
||||
self->RemoveMediaKeys();
|
||||
if (self->AttachNewMediaKeys()) {
|
||||
// No incoming MediaKeys object or MediaDecoder is not
|
||||
// created yet.
|
||||
self->MakeAssociationWithCDMResolved();
|
||||
}
|
||||
},
|
||||
[self](const MediaResult& aResult) {
|
||||
self->mSetCDMRequest.Complete();
|
||||
// 5.2.4 If the preceding step failed, let this object's
|
||||
// attaching media keys value be false and reject promise with
|
||||
// a new DOMException whose name is the appropriate error name.
|
||||
self->SetCDMProxyFailure(aResult);
|
||||
})
|
||||
self->RemoveMediaKeys();
|
||||
if (self->AttachNewMediaKeys()) {
|
||||
// No incoming MediaKeys object or MediaDecoder is not
|
||||
// created yet.
|
||||
self->MakeAssociationWithCDMResolved();
|
||||
}
|
||||
},
|
||||
[self](const MediaResult& aResult) {
|
||||
self->mSetCDMRequest.Complete();
|
||||
// 5.2.4 If the preceding step failed, let this object's
|
||||
// attaching media keys value be false and reject promise with
|
||||
// a new DOMException whose name is the appropriate error name.
|
||||
self->SetCDMProxyFailure(aResult);
|
||||
})
|
||||
->Track(mSetCDMRequest);
|
||||
return false;
|
||||
}
|
||||
|
@ -6524,16 +6523,15 @@ bool HTMLMediaElement::TryMakeAssociationWithCDM(CDMProxy* aProxy) {
|
|||
// HTMLMediaElement should resolve or reject the DOM promise.
|
||||
RefPtr<HTMLMediaElement> self = this;
|
||||
mDecoder->SetCDMProxy(aProxy)
|
||||
->Then(
|
||||
mAbstractMainThread, __func__,
|
||||
[self]() {
|
||||
self->mSetCDMRequest.Complete();
|
||||
self->MakeAssociationWithCDMResolved();
|
||||
},
|
||||
[self](const MediaResult& aResult) {
|
||||
self->mSetCDMRequest.Complete();
|
||||
self->SetCDMProxyFailure(aResult);
|
||||
})
|
||||
->Then(mAbstractMainThread, __func__,
|
||||
[self]() {
|
||||
self->mSetCDMRequest.Complete();
|
||||
self->MakeAssociationWithCDMResolved();
|
||||
},
|
||||
[self](const MediaResult& aResult) {
|
||||
self->mSetCDMRequest.Complete();
|
||||
self->SetCDMProxyFailure(aResult);
|
||||
})
|
||||
->Track(mSetCDMRequest);
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1720,14 +1720,13 @@ mozilla::ipc::IPCResult BackgroundFactoryRequestChild::RecvPermissionChallenge(
|
|||
IPC::Principal ipcPrincipal(principal);
|
||||
|
||||
tabChild->SendIndexedDBPermissionRequest(ipcPrincipal)
|
||||
->Then(
|
||||
GetCurrentThreadSerialEventTarget(), __func__,
|
||||
[this](const uint32_t& aPermission) {
|
||||
this->AssertIsOnOwningThread();
|
||||
MaybeCollectGarbageOnIPCMessage();
|
||||
this->SendPermissionRetry();
|
||||
},
|
||||
[](const mozilla::ipc::ResponseRejectReason) {});
|
||||
->Then(GetCurrentThreadSerialEventTarget(), __func__,
|
||||
[this](const uint32_t& aPermission) {
|
||||
this->AssertIsOnOwningThread();
|
||||
MaybeCollectGarbageOnIPCMessage();
|
||||
this->SendPermissionRetry();
|
||||
},
|
||||
[](const mozilla::ipc::ResponseRejectReason) {});
|
||||
|
||||
return IPC_OK();
|
||||
}
|
||||
|
|
|
@ -67,12 +67,11 @@ bool SharedStringMap::Get(const nsCString& aKey, nsAString& aValue) {
|
|||
bool SharedStringMap::Find(const nsCString& aKey, size_t* aIndex) {
|
||||
const auto& keys = KeyTable();
|
||||
|
||||
return BinarySearchIf(
|
||||
Entries(), 0, EntryCount(),
|
||||
[&](const Entry& aEntry) {
|
||||
return aKey.Compare(keys.GetBare(aEntry.mKey));
|
||||
},
|
||||
aIndex);
|
||||
return BinarySearchIf(Entries(), 0, EntryCount(),
|
||||
[&](const Entry& aEntry) {
|
||||
return aKey.Compare(keys.GetBare(aEntry.mKey));
|
||||
},
|
||||
aIndex);
|
||||
}
|
||||
|
||||
void SharedStringMapBuilder::Add(const nsCString& aKey,
|
||||
|
|
|
@ -219,9 +219,7 @@ MaybeInvalidTabContext::MaybeInvalidTabContext(const IPCTabContext& aParams)
|
|||
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
MOZ_CRASH();
|
||||
}
|
||||
default: { MOZ_CRASH(); }
|
||||
}
|
||||
|
||||
bool rv;
|
||||
|
|
|
@ -158,8 +158,7 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TabParent)
|
|||
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsITabParent)
|
||||
NS_INTERFACE_MAP_END
|
||||
NS_IMPL_CYCLE_COLLECTION(TabParent, mFrameElement, mBrowserDOMWindow,
|
||||
mLoadContext, mFrameLoader, mBrowsingContext)
|
||||
NS_IMPL_CYCLE_COLLECTION(TabParent, mFrameElement, mBrowserDOMWindow, mLoadContext, mFrameLoader, mBrowsingContext)
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(TabParent)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(TabParent)
|
||||
|
||||
|
@ -3048,19 +3047,18 @@ TabParent::GetContentBlockingLog(Promise** aPromise) {
|
|||
copy.forget(aPromise);
|
||||
|
||||
auto cblPromise = SendGetContentBlockingLog();
|
||||
cblPromise->Then(
|
||||
GetMainThreadSerialEventTarget(), __func__,
|
||||
[jsPromise](Tuple<nsCString, bool>&& aResult) {
|
||||
if (Get<1>(aResult)) {
|
||||
NS_ConvertUTF8toUTF16 utf16(Get<0>(aResult));
|
||||
jsPromise->MaybeResolve(std::move(utf16));
|
||||
} else {
|
||||
jsPromise->MaybeRejectWithUndefined();
|
||||
}
|
||||
},
|
||||
[jsPromise](ResponseRejectReason&& aReason) {
|
||||
jsPromise->MaybeRejectWithUndefined();
|
||||
});
|
||||
cblPromise->Then(GetMainThreadSerialEventTarget(), __func__,
|
||||
[jsPromise](Tuple<nsCString, bool>&& aResult) {
|
||||
if (Get<1>(aResult)) {
|
||||
NS_ConvertUTF8toUTF16 utf16(Get<0>(aResult));
|
||||
jsPromise->MaybeResolve(std::move(utf16));
|
||||
} else {
|
||||
jsPromise->MaybeRejectWithUndefined();
|
||||
}
|
||||
},
|
||||
[jsPromise](ResponseRejectReason&& aReason) {
|
||||
jsPromise->MaybeRejectWithUndefined();
|
||||
});
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -3160,14 +3158,13 @@ void TabParent::RequestRootPaint(gfx::CrossProcessPaint* aPaint, IntRect aRect,
|
|||
|
||||
RefPtr<gfx::CrossProcessPaint> paint(aPaint);
|
||||
TabId tabId(GetTabId());
|
||||
promise->Then(
|
||||
GetMainThreadSerialEventTarget(), __func__,
|
||||
[paint, tabId](PaintFragment&& aFragment) {
|
||||
paint->ReceiveFragment(tabId, std::move(aFragment));
|
||||
},
|
||||
[paint, tabId](ResponseRejectReason&& aReason) {
|
||||
paint->LostFragment(tabId);
|
||||
});
|
||||
promise->Then(GetMainThreadSerialEventTarget(), __func__,
|
||||
[paint, tabId](PaintFragment&& aFragment) {
|
||||
paint->ReceiveFragment(tabId, std::move(aFragment));
|
||||
},
|
||||
[paint, tabId](ResponseRejectReason&& aReason) {
|
||||
paint->LostFragment(tabId);
|
||||
});
|
||||
}
|
||||
|
||||
void TabParent::RequestSubPaint(gfx::CrossProcessPaint* aPaint, float aScale,
|
||||
|
@ -3176,14 +3173,13 @@ void TabParent::RequestSubPaint(gfx::CrossProcessPaint* aPaint, float aScale,
|
|||
|
||||
RefPtr<gfx::CrossProcessPaint> paint(aPaint);
|
||||
TabId tabId(GetTabId());
|
||||
promise->Then(
|
||||
GetMainThreadSerialEventTarget(), __func__,
|
||||
[paint, tabId](PaintFragment&& aFragment) {
|
||||
paint->ReceiveFragment(tabId, std::move(aFragment));
|
||||
},
|
||||
[paint, tabId](ResponseRejectReason&& aReason) {
|
||||
paint->LostFragment(tabId);
|
||||
});
|
||||
promise->Then(GetMainThreadSerialEventTarget(), __func__,
|
||||
[paint, tabId](PaintFragment&& aFragment) {
|
||||
paint->ReceiveFragment(tabId, std::move(aFragment));
|
||||
},
|
||||
[paint, tabId](ResponseRejectReason&& aReason) {
|
||||
paint->LostFragment(tabId);
|
||||
});
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult TabParent::RecvPaintWhileInterruptingJSNoOp(
|
||||
|
|
|
@ -69,25 +69,21 @@ void CheckGeneratedOriginKey(nsIPrincipal* aPrincipal, const char* aOriginKey) {
|
|||
|
||||
} // namespace
|
||||
|
||||
TEST(LocalStorage, OriginKey)
|
||||
{
|
||||
TEST(LocalStorage, OriginKey) {
|
||||
// Check the system principal.
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan =
|
||||
nsContentUtils::GetSecurityManager();
|
||||
ASSERT_TRUE(secMan)
|
||||
<< "GetSecurityManager() should not fail";
|
||||
ASSERT_TRUE(secMan) << "GetSecurityManager() should not fail";
|
||||
|
||||
nsCOMPtr<nsIPrincipal> principal;
|
||||
secMan->GetSystemPrincipal(getter_AddRefs(principal));
|
||||
ASSERT_TRUE(principal)
|
||||
<< "GetSystemPrincipal() should not fail";
|
||||
ASSERT_TRUE(principal) << "GetSystemPrincipal() should not fail";
|
||||
|
||||
CheckGeneratedOriginKey(principal, nullptr);
|
||||
|
||||
// Check the null principal.
|
||||
principal = NullPrincipal::CreateWithoutOriginAttributes();
|
||||
ASSERT_TRUE(principal)
|
||||
<< "CreateWithoutOriginAttributes() should not fail";
|
||||
ASSERT_TRUE(principal) << "CreateWithoutOriginAttributes() should not fail";
|
||||
|
||||
CheckGeneratedOriginKey(principal, nullptr);
|
||||
|
||||
|
@ -110,8 +106,7 @@ TEST(LocalStorage, OriginKey)
|
|||
|
||||
for (const auto& test : tests) {
|
||||
principal = GetCodebasePrincipal(test.mSpec);
|
||||
ASSERT_TRUE(principal)
|
||||
<< "GetCodebasePrincipal() should not fail";
|
||||
ASSERT_TRUE(principal) << "GetCodebasePrincipal() should not fail";
|
||||
|
||||
CheckGeneratedOriginKey(principal, test.mOriginKey);
|
||||
}
|
||||
|
|
|
@ -282,15 +282,15 @@ void BenchmarkPlayback::GlobalShutdown() {
|
|||
|
||||
if (mDecoder) {
|
||||
RefPtr<Benchmark> ref(mGlobalState);
|
||||
mDecoder->Flush()->Then(
|
||||
Thread(), __func__,
|
||||
[ref, this]() {
|
||||
mDecoder->Shutdown()->Then(
|
||||
Thread(), __func__, [ref, this]() { FinalizeShutdown(); },
|
||||
[]() { MOZ_CRASH("not reached"); });
|
||||
mDecoder = nullptr;
|
||||
},
|
||||
[]() { MOZ_CRASH("not reached"); });
|
||||
mDecoder->Flush()->Then(Thread(), __func__,
|
||||
[ref, this]() {
|
||||
mDecoder->Shutdown()->Then(
|
||||
Thread(), __func__,
|
||||
[ref, this]() { FinalizeShutdown(); },
|
||||
[]() { MOZ_CRASH("not reached"); });
|
||||
mDecoder = nullptr;
|
||||
},
|
||||
[]() { MOZ_CRASH("not reached"); });
|
||||
} else {
|
||||
FinalizeShutdown();
|
||||
}
|
||||
|
@ -345,36 +345,34 @@ void BenchmarkPlayback::InputExhausted() {
|
|||
mSampleIndex++;
|
||||
if (mSampleIndex == mSamples.Length() && !ref->mParameters.mStopAtFrame) {
|
||||
// Complete current frame decode then drain if still necessary.
|
||||
p->Then(
|
||||
Thread(), __func__,
|
||||
[ref, this](MediaDataDecoder::DecodedData&& aResults) {
|
||||
Output(std::move(aResults));
|
||||
if (!mFinished) {
|
||||
mDecoder->Drain()->Then(
|
||||
Thread(), __func__,
|
||||
[ref, this](MediaDataDecoder::DecodedData&& aResults) {
|
||||
mDrained = true;
|
||||
Output(std::move(aResults));
|
||||
MOZ_ASSERT(mFinished, "We must be done now");
|
||||
},
|
||||
[ref, this](const MediaResult& aError) { Error(aError); });
|
||||
}
|
||||
},
|
||||
[ref, this](const MediaResult& aError) { Error(aError); });
|
||||
p->Then(Thread(), __func__,
|
||||
[ref, this](MediaDataDecoder::DecodedData&& aResults) {
|
||||
Output(std::move(aResults));
|
||||
if (!mFinished) {
|
||||
mDecoder->Drain()->Then(
|
||||
Thread(), __func__,
|
||||
[ref, this](MediaDataDecoder::DecodedData&& aResults) {
|
||||
mDrained = true;
|
||||
Output(std::move(aResults));
|
||||
MOZ_ASSERT(mFinished, "We must be done now");
|
||||
},
|
||||
[ref, this](const MediaResult& aError) { Error(aError); });
|
||||
}
|
||||
},
|
||||
[ref, this](const MediaResult& aError) { Error(aError); });
|
||||
} else {
|
||||
if (mSampleIndex == mSamples.Length() && ref->mParameters.mStopAtFrame) {
|
||||
mSampleIndex = 0;
|
||||
}
|
||||
// Continue decoding
|
||||
p->Then(
|
||||
Thread(), __func__,
|
||||
[ref, this](MediaDataDecoder::DecodedData&& aResults) {
|
||||
Output(std::move(aResults));
|
||||
if (!mFinished) {
|
||||
InputExhausted();
|
||||
}
|
||||
},
|
||||
[ref, this](const MediaResult& aError) { Error(aError); });
|
||||
p->Then(Thread(), __func__,
|
||||
[ref, this](MediaDataDecoder::DecodedData&& aResults) {
|
||||
Output(std::move(aResults));
|
||||
if (!mFinished) {
|
||||
InputExhausted();
|
||||
}
|
||||
},
|
||||
[ref, this](const MediaResult& aError) { Error(aError); });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -387,20 +387,19 @@ void ChannelMediaDecoder::DownloadProgressed() {
|
|||
MediaStatistics stats = GetStatistics(rate, res, pos);
|
||||
return StatsPromise::CreateAndResolve(stats, __func__);
|
||||
})
|
||||
->Then(
|
||||
mAbstractMainThread, __func__,
|
||||
[=,
|
||||
self = RefPtr<ChannelMediaDecoder>(this)](MediaStatistics aStats) {
|
||||
if (IsShutdown()) {
|
||||
return;
|
||||
}
|
||||
mCanPlayThrough = aStats.CanPlayThrough();
|
||||
GetStateMachine()->DispatchCanPlayThrough(mCanPlayThrough);
|
||||
mResource->ThrottleReadahead(ShouldThrottleDownload(aStats));
|
||||
// Update readyState since mCanPlayThrough might have changed.
|
||||
GetOwner()->UpdateReadyState();
|
||||
},
|
||||
[]() { MOZ_ASSERT_UNREACHABLE("Promise not resolved"); });
|
||||
->Then(mAbstractMainThread, __func__,
|
||||
[=, self = RefPtr<ChannelMediaDecoder>(this)](
|
||||
MediaStatistics aStats) {
|
||||
if (IsShutdown()) {
|
||||
return;
|
||||
}
|
||||
mCanPlayThrough = aStats.CanPlayThrough();
|
||||
GetStateMachine()->DispatchCanPlayThrough(mCanPlayThrough);
|
||||
mResource->ThrottleReadahead(ShouldThrottleDownload(aStats));
|
||||
// Update readyState since mCanPlayThrough might have changed.
|
||||
GetOwner()->UpdateReadyState();
|
||||
},
|
||||
[]() { MOZ_ASSERT_UNREACHABLE("Promise not resolved"); });
|
||||
}
|
||||
|
||||
/* static */ ChannelMediaDecoder::PlaybackRateInfo
|
||||
|
|
|
@ -1055,12 +1055,11 @@ void DOMMediaStream::BlockPlaybackTrack(TrackPort* aTrack) {
|
|||
RefPtr<DOMMediaStream> that = this;
|
||||
aTrack
|
||||
->BlockSourceTrackId(aTrack->GetTrack()->mTrackID, BlockingMode::CREATION)
|
||||
->Then(
|
||||
GetCurrentThreadSerialEventTarget(), __func__,
|
||||
[this, that](bool aIgnore) { NotifyPlaybackTrackBlocked(); },
|
||||
[](const nsresult& aIgnore) {
|
||||
NS_ERROR("Could not remove track from MSG");
|
||||
});
|
||||
->Then(GetCurrentThreadSerialEventTarget(), __func__,
|
||||
[this, that](bool aIgnore) { NotifyPlaybackTrackBlocked(); },
|
||||
[](const nsresult& aIgnore) {
|
||||
NS_ERROR("Could not remove track from MSG");
|
||||
});
|
||||
}
|
||||
|
||||
void DOMMediaStream::NotifyPlaybackTrackBlocked() {
|
||||
|
|
|
@ -316,12 +316,11 @@ class MediaDecoderStateMachine::DecodeMetadataState
|
|||
// a raw pointer here.
|
||||
Reader()
|
||||
->ReadMetadata()
|
||||
->Then(
|
||||
OwnerThread(), __func__,
|
||||
[this](MetadataHolder&& aMetadata) {
|
||||
OnMetadataRead(std::move(aMetadata));
|
||||
},
|
||||
[this](const MediaResult& aError) { OnMetadataNotRead(aError); })
|
||||
->Then(OwnerThread(), __func__,
|
||||
[this](MetadataHolder&& aMetadata) {
|
||||
OnMetadataRead(std::move(aMetadata));
|
||||
},
|
||||
[this](const MediaResult& aError) { OnMetadataNotRead(aError); })
|
||||
->Track(mMetadataRequest);
|
||||
}
|
||||
|
||||
|
@ -711,13 +710,12 @@ class MediaDecoderStateMachine::DecodingState
|
|||
TimeStamp target =
|
||||
TimeStamp::Now() + TimeDuration::FromMilliseconds(timeout);
|
||||
|
||||
mDormantTimer.Ensure(
|
||||
target,
|
||||
[this]() {
|
||||
mDormantTimer.CompleteRequest();
|
||||
SetState<DormantState>();
|
||||
},
|
||||
[this]() { mDormantTimer.CompleteRequest(); });
|
||||
mDormantTimer.Ensure(target,
|
||||
[this]() {
|
||||
mDormantTimer.CompleteRequest();
|
||||
SetState<DormantState>();
|
||||
},
|
||||
[this]() { mDormantTimer.CompleteRequest(); });
|
||||
}
|
||||
|
||||
// Time at which we started decoding.
|
||||
|
@ -820,39 +818,38 @@ class MediaDecoderStateMachine::LoopingDecodingState
|
|||
Reader()->ResetDecode(TrackInfo::kAudioTrack);
|
||||
Reader()
|
||||
->Seek(SeekTarget(media::TimeUnit::Zero(), SeekTarget::Accurate))
|
||||
->Then(
|
||||
OwnerThread(), __func__,
|
||||
[this]() -> void {
|
||||
mAudioSeekRequest.Complete();
|
||||
SLOG(
|
||||
"seeking completed, start to request first sample, "
|
||||
"queueing audio task - queued=%zu, decoder-queued=%zu",
|
||||
AudioQueue().GetSize(), Reader()->SizeOfAudioQueueInFrames());
|
||||
->Then(OwnerThread(), __func__,
|
||||
[this]() -> void {
|
||||
mAudioSeekRequest.Complete();
|
||||
SLOG(
|
||||
"seeking completed, start to request first sample, "
|
||||
"queueing audio task - queued=%zu, decoder-queued=%zu",
|
||||
AudioQueue().GetSize(),
|
||||
Reader()->SizeOfAudioQueueInFrames());
|
||||
|
||||
Reader()
|
||||
->RequestAudioData()
|
||||
->Then(
|
||||
OwnerThread(), __func__,
|
||||
[this](RefPtr<AudioData> aAudio) {
|
||||
mIsReachingAudioEOS = false;
|
||||
mAudioDataRequest.Complete();
|
||||
SLOG(
|
||||
"got audio decoded sample "
|
||||
"[%" PRId64 ",%" PRId64 "]",
|
||||
aAudio->mTime.ToMicroseconds(),
|
||||
aAudio->GetEndTime().ToMicroseconds());
|
||||
HandleAudioDecoded(aAudio);
|
||||
},
|
||||
[this](const MediaResult& aError) {
|
||||
mAudioDataRequest.Complete();
|
||||
HandleError(aError);
|
||||
})
|
||||
->Track(mAudioDataRequest);
|
||||
},
|
||||
[this](const SeekRejectValue& aReject) -> void {
|
||||
mAudioSeekRequest.Complete();
|
||||
HandleError(aReject.mError);
|
||||
})
|
||||
Reader()
|
||||
->RequestAudioData()
|
||||
->Then(OwnerThread(), __func__,
|
||||
[this](RefPtr<AudioData> aAudio) {
|
||||
mIsReachingAudioEOS = false;
|
||||
mAudioDataRequest.Complete();
|
||||
SLOG(
|
||||
"got audio decoded sample "
|
||||
"[%" PRId64 ",%" PRId64 "]",
|
||||
aAudio->mTime.ToMicroseconds(),
|
||||
aAudio->GetEndTime().ToMicroseconds());
|
||||
HandleAudioDecoded(aAudio);
|
||||
},
|
||||
[this](const MediaResult& aError) {
|
||||
mAudioDataRequest.Complete();
|
||||
HandleError(aError);
|
||||
})
|
||||
->Track(mAudioDataRequest);
|
||||
},
|
||||
[this](const SeekRejectValue& aReject) -> void {
|
||||
mAudioSeekRequest.Complete();
|
||||
HandleError(aReject.mError);
|
||||
})
|
||||
->Track(mAudioSeekRequest);
|
||||
}
|
||||
|
||||
|
@ -1236,18 +1233,17 @@ class MediaDecoderStateMachine::AccurateSeekingState
|
|||
|
||||
Reader()
|
||||
->WaitForData(aReject.mType)
|
||||
->Then(
|
||||
OwnerThread(), __func__,
|
||||
[this](MediaData::Type aType) {
|
||||
SLOG("OnSeekRejected wait promise resolved");
|
||||
mWaitRequest.Complete();
|
||||
DemuxerSeek();
|
||||
},
|
||||
[this](const WaitForDataRejectValue& aRejection) {
|
||||
SLOG("OnSeekRejected wait promise rejected");
|
||||
mWaitRequest.Complete();
|
||||
mMaster->DecodeError(NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA);
|
||||
})
|
||||
->Then(OwnerThread(), __func__,
|
||||
[this](MediaData::Type aType) {
|
||||
SLOG("OnSeekRejected wait promise resolved");
|
||||
mWaitRequest.Complete();
|
||||
DemuxerSeek();
|
||||
},
|
||||
[this](const WaitForDataRejectValue& aRejection) {
|
||||
SLOG("OnSeekRejected wait promise rejected");
|
||||
mWaitRequest.Complete();
|
||||
mMaster->DecodeError(NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA);
|
||||
})
|
||||
->Track(mWaitRequest);
|
||||
return;
|
||||
}
|
||||
|
@ -2135,10 +2131,9 @@ void MediaDecoderStateMachine::StateObject::HandleResumeVideoDecoding(
|
|||
RefPtr<AbstractThread> mainThread = mMaster->mAbstractMainThread;
|
||||
|
||||
SetSeekingState(std::move(seekJob), EventVisibility::Suppressed)
|
||||
->Then(
|
||||
mainThread, __func__,
|
||||
[start, info, hw]() { ReportRecoveryTelemetry(start, info, hw); },
|
||||
[]() {});
|
||||
->Then(mainThread, __func__,
|
||||
[start, info, hw]() { ReportRecoveryTelemetry(start, info, hw); },
|
||||
[]() {});
|
||||
}
|
||||
|
||||
RefPtr<MediaDecoder::SeekPromise>
|
||||
|
@ -2973,9 +2968,9 @@ void MediaDecoderStateMachine::SetVideoDecodeModeInternal(
|
|||
TimeStamp target = TimeStamp::Now() + SuspendBackgroundVideoDelay();
|
||||
|
||||
RefPtr<MediaDecoderStateMachine> self = this;
|
||||
mVideoDecodeSuspendTimer.Ensure(
|
||||
target, [=]() { self->OnSuspendTimerResolved(); },
|
||||
[]() { MOZ_DIAGNOSTIC_ASSERT(false); });
|
||||
mVideoDecodeSuspendTimer.Ensure(target,
|
||||
[=]() { self->OnSuspendTimerResolved(); },
|
||||
[]() { MOZ_DIAGNOSTIC_ASSERT(false); });
|
||||
mOnPlaybackEvent.Notify(MediaPlaybackEvent::StartVideoSuspendTimer);
|
||||
return;
|
||||
}
|
||||
|
@ -3069,37 +3064,36 @@ void MediaDecoderStateMachine::RequestAudioData() {
|
|||
|
||||
RefPtr<MediaDecoderStateMachine> self = this;
|
||||
mReader->RequestAudioData()
|
||||
->Then(
|
||||
OwnerThread(), __func__,
|
||||
[this, self](RefPtr<AudioData> aAudio) {
|
||||
MOZ_ASSERT(aAudio);
|
||||
mAudioDataRequest.Complete();
|
||||
// audio->GetEndTime() is not always mono-increasing in chained
|
||||
// ogg.
|
||||
mDecodedAudioEndTime =
|
||||
std::max(aAudio->GetEndTime(), mDecodedAudioEndTime);
|
||||
LOGV("OnAudioDecoded [%" PRId64 ",%" PRId64 "]",
|
||||
aAudio->mTime.ToMicroseconds(),
|
||||
aAudio->GetEndTime().ToMicroseconds());
|
||||
mStateObj->HandleAudioDecoded(aAudio);
|
||||
},
|
||||
[this, self](const MediaResult& aError) {
|
||||
LOGV("OnAudioNotDecoded aError=%s", aError.ErrorName().get());
|
||||
mAudioDataRequest.Complete();
|
||||
switch (aError.Code()) {
|
||||
case NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA:
|
||||
mStateObj->HandleWaitingForAudio();
|
||||
break;
|
||||
case NS_ERROR_DOM_MEDIA_CANCELED:
|
||||
mStateObj->HandleAudioCanceled();
|
||||
break;
|
||||
case NS_ERROR_DOM_MEDIA_END_OF_STREAM:
|
||||
mStateObj->HandleEndOfAudio();
|
||||
break;
|
||||
default:
|
||||
DecodeError(aError);
|
||||
}
|
||||
})
|
||||
->Then(OwnerThread(), __func__,
|
||||
[this, self](RefPtr<AudioData> aAudio) {
|
||||
MOZ_ASSERT(aAudio);
|
||||
mAudioDataRequest.Complete();
|
||||
// audio->GetEndTime() is not always mono-increasing in chained
|
||||
// ogg.
|
||||
mDecodedAudioEndTime =
|
||||
std::max(aAudio->GetEndTime(), mDecodedAudioEndTime);
|
||||
LOGV("OnAudioDecoded [%" PRId64 ",%" PRId64 "]",
|
||||
aAudio->mTime.ToMicroseconds(),
|
||||
aAudio->GetEndTime().ToMicroseconds());
|
||||
mStateObj->HandleAudioDecoded(aAudio);
|
||||
},
|
||||
[this, self](const MediaResult& aError) {
|
||||
LOGV("OnAudioNotDecoded aError=%s", aError.ErrorName().get());
|
||||
mAudioDataRequest.Complete();
|
||||
switch (aError.Code()) {
|
||||
case NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA:
|
||||
mStateObj->HandleWaitingForAudio();
|
||||
break;
|
||||
case NS_ERROR_DOM_MEDIA_CANCELED:
|
||||
mStateObj->HandleAudioCanceled();
|
||||
break;
|
||||
case NS_ERROR_DOM_MEDIA_END_OF_STREAM:
|
||||
mStateObj->HandleEndOfAudio();
|
||||
break;
|
||||
default:
|
||||
DecodeError(aError);
|
||||
}
|
||||
})
|
||||
->Track(mAudioDataRequest);
|
||||
}
|
||||
|
||||
|
@ -3118,36 +3112,35 @@ void MediaDecoderStateMachine::RequestVideoData(
|
|||
TimeStamp videoDecodeStartTime = TimeStamp::Now();
|
||||
RefPtr<MediaDecoderStateMachine> self = this;
|
||||
mReader->RequestVideoData(aCurrentTime)
|
||||
->Then(
|
||||
OwnerThread(), __func__,
|
||||
[this, self, videoDecodeStartTime](RefPtr<VideoData> aVideo) {
|
||||
MOZ_ASSERT(aVideo);
|
||||
mVideoDataRequest.Complete();
|
||||
// Handle abnormal or negative timestamps.
|
||||
mDecodedVideoEndTime =
|
||||
std::max(mDecodedVideoEndTime, aVideo->GetEndTime());
|
||||
LOGV("OnVideoDecoded [%" PRId64 ",%" PRId64 "]",
|
||||
aVideo->mTime.ToMicroseconds(),
|
||||
aVideo->GetEndTime().ToMicroseconds());
|
||||
mStateObj->HandleVideoDecoded(aVideo, videoDecodeStartTime);
|
||||
},
|
||||
[this, self](const MediaResult& aError) {
|
||||
LOGV("OnVideoNotDecoded aError=%s", aError.ErrorName().get());
|
||||
mVideoDataRequest.Complete();
|
||||
switch (aError.Code()) {
|
||||
case NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA:
|
||||
mStateObj->HandleWaitingForVideo();
|
||||
break;
|
||||
case NS_ERROR_DOM_MEDIA_CANCELED:
|
||||
mStateObj->HandleVideoCanceled();
|
||||
break;
|
||||
case NS_ERROR_DOM_MEDIA_END_OF_STREAM:
|
||||
mStateObj->HandleEndOfVideo();
|
||||
break;
|
||||
default:
|
||||
DecodeError(aError);
|
||||
}
|
||||
})
|
||||
->Then(OwnerThread(), __func__,
|
||||
[this, self, videoDecodeStartTime](RefPtr<VideoData> aVideo) {
|
||||
MOZ_ASSERT(aVideo);
|
||||
mVideoDataRequest.Complete();
|
||||
// Handle abnormal or negative timestamps.
|
||||
mDecodedVideoEndTime =
|
||||
std::max(mDecodedVideoEndTime, aVideo->GetEndTime());
|
||||
LOGV("OnVideoDecoded [%" PRId64 ",%" PRId64 "]",
|
||||
aVideo->mTime.ToMicroseconds(),
|
||||
aVideo->GetEndTime().ToMicroseconds());
|
||||
mStateObj->HandleVideoDecoded(aVideo, videoDecodeStartTime);
|
||||
},
|
||||
[this, self](const MediaResult& aError) {
|
||||
LOGV("OnVideoNotDecoded aError=%s", aError.ErrorName().get());
|
||||
mVideoDataRequest.Complete();
|
||||
switch (aError.Code()) {
|
||||
case NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA:
|
||||
mStateObj->HandleWaitingForVideo();
|
||||
break;
|
||||
case NS_ERROR_DOM_MEDIA_CANCELED:
|
||||
mStateObj->HandleVideoCanceled();
|
||||
break;
|
||||
case NS_ERROR_DOM_MEDIA_END_OF_STREAM:
|
||||
mStateObj->HandleEndOfVideo();
|
||||
break;
|
||||
default:
|
||||
DecodeError(aError);
|
||||
}
|
||||
})
|
||||
->Track(mVideoDataRequest);
|
||||
}
|
||||
|
||||
|
@ -3158,31 +3151,29 @@ void MediaDecoderStateMachine::WaitForData(MediaData::Type aType) {
|
|||
RefPtr<MediaDecoderStateMachine> self = this;
|
||||
if (aType == MediaData::Type::AUDIO_DATA) {
|
||||
mReader->WaitForData(MediaData::Type::AUDIO_DATA)
|
||||
->Then(
|
||||
OwnerThread(), __func__,
|
||||
[self](MediaData::Type aType) {
|
||||
self->mAudioWaitRequest.Complete();
|
||||
MOZ_ASSERT(aType == MediaData::Type::AUDIO_DATA);
|
||||
self->mStateObj->HandleAudioWaited(aType);
|
||||
},
|
||||
[self](const WaitForDataRejectValue& aRejection) {
|
||||
self->mAudioWaitRequest.Complete();
|
||||
self->DecodeError(NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA);
|
||||
})
|
||||
->Then(OwnerThread(), __func__,
|
||||
[self](MediaData::Type aType) {
|
||||
self->mAudioWaitRequest.Complete();
|
||||
MOZ_ASSERT(aType == MediaData::Type::AUDIO_DATA);
|
||||
self->mStateObj->HandleAudioWaited(aType);
|
||||
},
|
||||
[self](const WaitForDataRejectValue& aRejection) {
|
||||
self->mAudioWaitRequest.Complete();
|
||||
self->DecodeError(NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA);
|
||||
})
|
||||
->Track(mAudioWaitRequest);
|
||||
} else {
|
||||
mReader->WaitForData(MediaData::Type::VIDEO_DATA)
|
||||
->Then(
|
||||
OwnerThread(), __func__,
|
||||
[self](MediaData::Type aType) {
|
||||
self->mVideoWaitRequest.Complete();
|
||||
MOZ_ASSERT(aType == MediaData::Type::VIDEO_DATA);
|
||||
self->mStateObj->HandleVideoWaited(aType);
|
||||
},
|
||||
[self](const WaitForDataRejectValue& aRejection) {
|
||||
self->mVideoWaitRequest.Complete();
|
||||
self->DecodeError(NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA);
|
||||
})
|
||||
->Then(OwnerThread(), __func__,
|
||||
[self](MediaData::Type aType) {
|
||||
self->mVideoWaitRequest.Complete();
|
||||
MOZ_ASSERT(aType == MediaData::Type::VIDEO_DATA);
|
||||
self->mStateObj->HandleVideoWaited(aType);
|
||||
},
|
||||
[self](const WaitForDataRejectValue& aRejection) {
|
||||
self->mVideoWaitRequest.Complete();
|
||||
self->DecodeError(NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA);
|
||||
})
|
||||
->Track(mVideoWaitRequest);
|
||||
}
|
||||
}
|
||||
|
@ -3473,13 +3464,12 @@ void MediaDecoderStateMachine::ScheduleStateMachineIn(const TimeUnit& aTime) {
|
|||
// It is OK to capture 'this' without causing UAF because the callback
|
||||
// always happens before shutdown.
|
||||
RefPtr<MediaDecoderStateMachine> self = this;
|
||||
mDelayedScheduler.Ensure(
|
||||
target,
|
||||
[self]() {
|
||||
self->mDelayedScheduler.CompleteRequest();
|
||||
self->RunStateMachine();
|
||||
},
|
||||
[]() { MOZ_DIAGNOSTIC_ASSERT(false); });
|
||||
mDelayedScheduler.Ensure(target,
|
||||
[self]() {
|
||||
self->mDelayedScheduler.CompleteRequest();
|
||||
self->RunStateMachine();
|
||||
},
|
||||
[]() { MOZ_DIAGNOSTIC_ASSERT(false); });
|
||||
}
|
||||
|
||||
bool MediaDecoderStateMachine::OnTaskQueue() const {
|
||||
|
|
|
@ -65,21 +65,20 @@ already_AddRefed<Promise> MediaDevices::GetUserMedia(
|
|||
RefPtr<MediaDevices> self(this);
|
||||
MediaManager::Get()
|
||||
->GetUserMedia(GetOwner(), aConstraints, aCallerType)
|
||||
->Then(
|
||||
GetCurrentThreadSerialEventTarget(), __func__,
|
||||
[this, self, p](RefPtr<DOMMediaStream>&& aStream) {
|
||||
if (!GetWindowIfCurrent()) {
|
||||
return; // Leave Promise pending after navigation by design.
|
||||
}
|
||||
p->MaybeResolve(std::move(aStream));
|
||||
},
|
||||
[this, self, p](const RefPtr<MediaMgrError>& error) {
|
||||
nsPIDOMWindowInner* window = GetWindowIfCurrent();
|
||||
if (!window) {
|
||||
return; // Leave Promise pending after navigation by design.
|
||||
}
|
||||
p->MaybeReject(MakeRefPtr<MediaStreamError>(window, *error));
|
||||
});
|
||||
->Then(GetCurrentThreadSerialEventTarget(), __func__,
|
||||
[this, self, p](RefPtr<DOMMediaStream>&& aStream) {
|
||||
if (!GetWindowIfCurrent()) {
|
||||
return; // Leave Promise pending after navigation by design.
|
||||
}
|
||||
p->MaybeResolve(std::move(aStream));
|
||||
},
|
||||
[this, self, p](const RefPtr<MediaMgrError>& error) {
|
||||
nsPIDOMWindowInner* window = GetWindowIfCurrent();
|
||||
if (!window) {
|
||||
return; // Leave Promise pending after navigation by design.
|
||||
}
|
||||
p->MaybeReject(MakeRefPtr<MediaStreamError>(window, *error));
|
||||
});
|
||||
return p.forget();
|
||||
}
|
||||
|
||||
|
@ -93,41 +92,40 @@ already_AddRefed<Promise> MediaDevices::EnumerateDevices(CallerType aCallerType,
|
|||
RefPtr<MediaDevices> self(this);
|
||||
MediaManager::Get()
|
||||
->EnumerateDevices(GetOwner(), aCallerType)
|
||||
->Then(
|
||||
GetCurrentThreadSerialEventTarget(), __func__,
|
||||
[this, self,
|
||||
p](RefPtr<MediaManager::MediaDeviceSetRefCnt>&& aDevices) {
|
||||
nsPIDOMWindowInner* window = GetWindowIfCurrent();
|
||||
if (!window) {
|
||||
return; // Leave Promise pending after navigation by design.
|
||||
}
|
||||
auto windowId = window->WindowID();
|
||||
nsTArray<RefPtr<MediaDeviceInfo>> infos;
|
||||
for (auto& device : *aDevices) {
|
||||
MOZ_ASSERT(device->mKind == dom::MediaDeviceKind::Audioinput ||
|
||||
device->mKind == dom::MediaDeviceKind::Videoinput ||
|
||||
device->mKind == dom::MediaDeviceKind::Audiooutput);
|
||||
// Include name only if page currently has a gUM stream active
|
||||
// or persistent permissions (audio or video) have been granted
|
||||
nsString label;
|
||||
if (MediaManager::Get()->IsActivelyCapturingOrHasAPermission(
|
||||
windowId) ||
|
||||
Preferences::GetBool("media.navigator.permission.disabled",
|
||||
false)) {
|
||||
label = device->mName;
|
||||
}
|
||||
infos.AppendElement(MakeRefPtr<MediaDeviceInfo>(
|
||||
device->mID, device->mKind, label, device->mGroupID));
|
||||
}
|
||||
p->MaybeResolve(std::move(infos));
|
||||
},
|
||||
[this, self, p](const RefPtr<MediaMgrError>& error) {
|
||||
nsPIDOMWindowInner* window = GetWindowIfCurrent();
|
||||
if (!window) {
|
||||
return; // Leave Promise pending after navigation by design.
|
||||
}
|
||||
p->MaybeReject(MakeRefPtr<MediaStreamError>(window, *error));
|
||||
});
|
||||
->Then(GetCurrentThreadSerialEventTarget(), __func__,
|
||||
[this, self,
|
||||
p](RefPtr<MediaManager::MediaDeviceSetRefCnt>&& aDevices) {
|
||||
nsPIDOMWindowInner* window = GetWindowIfCurrent();
|
||||
if (!window) {
|
||||
return; // Leave Promise pending after navigation by design.
|
||||
}
|
||||
auto windowId = window->WindowID();
|
||||
nsTArray<RefPtr<MediaDeviceInfo>> infos;
|
||||
for (auto& device : *aDevices) {
|
||||
MOZ_ASSERT(device->mKind == dom::MediaDeviceKind::Audioinput ||
|
||||
device->mKind == dom::MediaDeviceKind::Videoinput ||
|
||||
device->mKind == dom::MediaDeviceKind::Audiooutput);
|
||||
// Include name only if page currently has a gUM stream active
|
||||
// or persistent permissions (audio or video) have been granted
|
||||
nsString label;
|
||||
if (MediaManager::Get()->IsActivelyCapturingOrHasAPermission(
|
||||
windowId) ||
|
||||
Preferences::GetBool("media.navigator.permission.disabled",
|
||||
false)) {
|
||||
label = device->mName;
|
||||
}
|
||||
infos.AppendElement(MakeRefPtr<MediaDeviceInfo>(
|
||||
device->mID, device->mKind, label, device->mGroupID));
|
||||
}
|
||||
p->MaybeResolve(std::move(infos));
|
||||
},
|
||||
[this, self, p](const RefPtr<MediaMgrError>& error) {
|
||||
nsPIDOMWindowInner* window = GetWindowIfCurrent();
|
||||
if (!window) {
|
||||
return; // Leave Promise pending after navigation by design.
|
||||
}
|
||||
p->MaybeReject(MakeRefPtr<MediaStreamError>(window, *error));
|
||||
});
|
||||
return p.forget();
|
||||
}
|
||||
|
||||
|
@ -141,21 +139,20 @@ already_AddRefed<Promise> MediaDevices::GetDisplayMedia(
|
|||
RefPtr<MediaDevices> self(this);
|
||||
MediaManager::Get()
|
||||
->GetDisplayMedia(GetOwner(), aConstraints, aCallerType)
|
||||
->Then(
|
||||
GetCurrentThreadSerialEventTarget(), __func__,
|
||||
[this, self, p](RefPtr<DOMMediaStream>&& aStream) {
|
||||
if (!GetWindowIfCurrent()) {
|
||||
return; // leave promise pending after navigation.
|
||||
}
|
||||
p->MaybeResolve(std::move(aStream));
|
||||
},
|
||||
[this, self, p](RefPtr<MediaMgrError>&& error) {
|
||||
nsPIDOMWindowInner* window = GetWindowIfCurrent();
|
||||
if (!window) {
|
||||
return; // leave promise pending after navigation.
|
||||
}
|
||||
p->MaybeReject(MakeRefPtr<MediaStreamError>(window, *error));
|
||||
});
|
||||
->Then(GetCurrentThreadSerialEventTarget(), __func__,
|
||||
[this, self, p](RefPtr<DOMMediaStream>&& aStream) {
|
||||
if (!GetWindowIfCurrent()) {
|
||||
return; // leave promise pending after navigation.
|
||||
}
|
||||
p->MaybeResolve(std::move(aStream));
|
||||
},
|
||||
[this, self, p](RefPtr<MediaMgrError>&& error) {
|
||||
nsPIDOMWindowInner* window = GetWindowIfCurrent();
|
||||
if (!window) {
|
||||
return; // leave promise pending after navigation.
|
||||
}
|
||||
p->MaybeReject(MakeRefPtr<MediaStreamError>(window, *error));
|
||||
});
|
||||
return p.forget();
|
||||
}
|
||||
|
||||
|
|
|
@ -336,18 +336,17 @@ void MediaFormatReader::DecoderFactory::RunStage(Data& aData) {
|
|||
case Stage::None: {
|
||||
MOZ_ASSERT(!aData.mToken);
|
||||
aData.mPolicy->Alloc()
|
||||
->Then(
|
||||
mOwner->OwnerThread(), __func__,
|
||||
[this, &aData](RefPtr<Token> aToken) {
|
||||
aData.mTokenRequest.Complete();
|
||||
aData.mToken = aToken.forget();
|
||||
aData.mStage = Stage::CreateDecoder;
|
||||
RunStage(aData);
|
||||
},
|
||||
[&aData]() {
|
||||
aData.mTokenRequest.Complete();
|
||||
aData.mStage = Stage::None;
|
||||
})
|
||||
->Then(mOwner->OwnerThread(), __func__,
|
||||
[this, &aData](RefPtr<Token> aToken) {
|
||||
aData.mTokenRequest.Complete();
|
||||
aData.mToken = aToken.forget();
|
||||
aData.mStage = Stage::CreateDecoder;
|
||||
RunStage(aData);
|
||||
},
|
||||
[&aData]() {
|
||||
aData.mTokenRequest.Complete();
|
||||
aData.mStage = Stage::None;
|
||||
})
|
||||
->Track(aData.mTokenRequest);
|
||||
aData.mStage = Stage::WaitForToken;
|
||||
break;
|
||||
|
@ -476,33 +475,33 @@ void MediaFormatReader::DecoderFactory::DoInitDecoder(Data& aData) {
|
|||
DDLOGEX2("MediaFormatReader::DecoderFactory", this, DDLogCategory::Log,
|
||||
"initialize_decoder", DDNoValue{});
|
||||
aData.mDecoder->Init()
|
||||
->Then(
|
||||
mOwner->OwnerThread(), __func__,
|
||||
[this, &aData, &ownerData](TrackType aTrack) {
|
||||
aData.mInitRequest.Complete();
|
||||
aData.mStage = Stage::None;
|
||||
MutexAutoLock lock(ownerData.mMutex);
|
||||
ownerData.mDecoder = aData.mDecoder.forget();
|
||||
ownerData.mDescription = ownerData.mDecoder->GetDescriptionName();
|
||||
DDLOGEX2("MediaFormatReader::DecoderFactory", this,
|
||||
DDLogCategory::Log, "decoder_initialized", DDNoValue{});
|
||||
DecoderDoctorLogger::LinkParentAndChild(
|
||||
"MediaFormatReader::DecoderData", &ownerData, "decoder",
|
||||
ownerData.mDecoder.get());
|
||||
mOwner->SetVideoDecodeThreshold();
|
||||
mOwner->ScheduleUpdate(aTrack);
|
||||
},
|
||||
[this, &aData, &ownerData](const MediaResult& aError) {
|
||||
aData.mInitRequest.Complete();
|
||||
MOZ_RELEASE_ASSERT(!ownerData.mDecoder,
|
||||
"Can't have a decoder already set");
|
||||
aData.mStage = Stage::None;
|
||||
mOwner->mShutdownPromisePool->ShutdownDecoder(
|
||||
aData.mDecoder.forget());
|
||||
DDLOGEX2("MediaFormatReader::DecoderFactory", this,
|
||||
DDLogCategory::Log, "initialize_decoder_error", aError);
|
||||
mOwner->NotifyError(aData.mTrack, aError);
|
||||
})
|
||||
->Then(mOwner->OwnerThread(), __func__,
|
||||
[this, &aData, &ownerData](TrackType aTrack) {
|
||||
aData.mInitRequest.Complete();
|
||||
aData.mStage = Stage::None;
|
||||
MutexAutoLock lock(ownerData.mMutex);
|
||||
ownerData.mDecoder = aData.mDecoder.forget();
|
||||
ownerData.mDescription =
|
||||
ownerData.mDecoder->GetDescriptionName();
|
||||
DDLOGEX2("MediaFormatReader::DecoderFactory", this,
|
||||
DDLogCategory::Log, "decoder_initialized", DDNoValue{});
|
||||
DecoderDoctorLogger::LinkParentAndChild(
|
||||
"MediaFormatReader::DecoderData", &ownerData, "decoder",
|
||||
ownerData.mDecoder.get());
|
||||
mOwner->SetVideoDecodeThreshold();
|
||||
mOwner->ScheduleUpdate(aTrack);
|
||||
},
|
||||
[this, &aData, &ownerData](const MediaResult& aError) {
|
||||
aData.mInitRequest.Complete();
|
||||
MOZ_RELEASE_ASSERT(!ownerData.mDecoder,
|
||||
"Can't have a decoder already set");
|
||||
aData.mStage = Stage::None;
|
||||
mOwner->mShutdownPromisePool->ShutdownDecoder(
|
||||
aData.mDecoder.forget());
|
||||
DDLOGEX2("MediaFormatReader::DecoderFactory", this,
|
||||
DDLogCategory::Log, "initialize_decoder_error", aError);
|
||||
mOwner->NotifyError(aData.mTrack, aError);
|
||||
})
|
||||
->Track(aData.mInitRequest);
|
||||
}
|
||||
|
||||
|
@ -654,16 +653,15 @@ class MediaFormatReader::DemuxerProxy::Wrapper : public MediaTrackDemuxer {
|
|||
return InvokeAsync(
|
||||
mTaskQueue, __func__,
|
||||
[self, aTime]() { return self->mTrackDemuxer->Seek(aTime); })
|
||||
->Then(
|
||||
mTaskQueue, __func__,
|
||||
[self](const TimeUnit& aTime) {
|
||||
self->UpdateRandomAccessPoint();
|
||||
return SeekPromise::CreateAndResolve(aTime, __func__);
|
||||
},
|
||||
[self](const MediaResult& aError) {
|
||||
self->UpdateRandomAccessPoint();
|
||||
return SeekPromise::CreateAndReject(aError, __func__);
|
||||
});
|
||||
->Then(mTaskQueue, __func__,
|
||||
[self](const TimeUnit& aTime) {
|
||||
self->UpdateRandomAccessPoint();
|
||||
return SeekPromise::CreateAndResolve(aTime, __func__);
|
||||
},
|
||||
[self](const MediaResult& aError) {
|
||||
self->UpdateRandomAccessPoint();
|
||||
return SeekPromise::CreateAndReject(aError, __func__);
|
||||
});
|
||||
}
|
||||
|
||||
RefPtr<SamplesPromise> GetSamples(int32_t aNumSamples) override {
|
||||
|
@ -672,17 +670,16 @@ class MediaFormatReader::DemuxerProxy::Wrapper : public MediaTrackDemuxer {
|
|||
[self, aNumSamples]() {
|
||||
return self->mTrackDemuxer->GetSamples(aNumSamples);
|
||||
})
|
||||
->Then(
|
||||
mTaskQueue, __func__,
|
||||
[self](RefPtr<SamplesHolder> aSamples) {
|
||||
self->UpdateRandomAccessPoint();
|
||||
return SamplesPromise::CreateAndResolve(aSamples.forget(),
|
||||
__func__);
|
||||
},
|
||||
[self](const MediaResult& aError) {
|
||||
self->UpdateRandomAccessPoint();
|
||||
return SamplesPromise::CreateAndReject(aError, __func__);
|
||||
});
|
||||
->Then(mTaskQueue, __func__,
|
||||
[self](RefPtr<SamplesHolder> aSamples) {
|
||||
self->UpdateRandomAccessPoint();
|
||||
return SamplesPromise::CreateAndResolve(aSamples.forget(),
|
||||
__func__);
|
||||
},
|
||||
[self](const MediaResult& aError) {
|
||||
self->UpdateRandomAccessPoint();
|
||||
return SamplesPromise::CreateAndReject(aError, __func__);
|
||||
});
|
||||
}
|
||||
|
||||
bool GetSamplesMayBlock() const override { return mGetSamplesMayBlock; }
|
||||
|
@ -791,57 +788,56 @@ RefPtr<MediaDataDemuxer::InitPromise> MediaFormatReader::DemuxerProxy::Init() {
|
|||
}
|
||||
return data->mDemuxer->Init();
|
||||
})
|
||||
->Then(
|
||||
taskQueue, __func__,
|
||||
[data, taskQueue]() {
|
||||
if (!data->mDemuxer) { // Was shutdown.
|
||||
return InitPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_CANCELED,
|
||||
__func__);
|
||||
}
|
||||
data->mNumAudioTrack =
|
||||
data->mDemuxer->GetNumberTracks(TrackInfo::kAudioTrack);
|
||||
if (data->mNumAudioTrack) {
|
||||
RefPtr<MediaTrackDemuxer> d =
|
||||
data->mDemuxer->GetTrackDemuxer(TrackInfo::kAudioTrack, 0);
|
||||
if (d) {
|
||||
RefPtr<Wrapper> wrapper =
|
||||
new DemuxerProxy::Wrapper(d, taskQueue);
|
||||
wrapper->UpdateBuffered();
|
||||
data->mAudioDemuxer = wrapper;
|
||||
DecoderDoctorLogger::LinkParentAndChild(
|
||||
data->mDemuxer.get(), "decoder factory wrapper",
|
||||
"MediaFormatReader::DecoderFactory::Wrapper",
|
||||
wrapper.get());
|
||||
}
|
||||
}
|
||||
data->mNumVideoTrack =
|
||||
data->mDemuxer->GetNumberTracks(TrackInfo::kVideoTrack);
|
||||
if (data->mNumVideoTrack) {
|
||||
RefPtr<MediaTrackDemuxer> d =
|
||||
data->mDemuxer->GetTrackDemuxer(TrackInfo::kVideoTrack, 0);
|
||||
if (d) {
|
||||
RefPtr<Wrapper> wrapper =
|
||||
new DemuxerProxy::Wrapper(d, taskQueue);
|
||||
wrapper->UpdateBuffered();
|
||||
data->mVideoDemuxer = wrapper;
|
||||
DecoderDoctorLogger::LinkParentAndChild(
|
||||
data->mDemuxer.get(), "decoder factory wrapper",
|
||||
"MediaFormatReader::DecoderFactory::Wrapper",
|
||||
wrapper.get());
|
||||
}
|
||||
}
|
||||
data->mCrypto = data->mDemuxer->GetCrypto();
|
||||
data->mSeekable = data->mDemuxer->IsSeekable();
|
||||
data->mSeekableOnlyInBufferedRange =
|
||||
data->mDemuxer->IsSeekableOnlyInBufferedRanges();
|
||||
data->mShouldComputeStartTime =
|
||||
data->mDemuxer->ShouldComputeStartTime();
|
||||
data->mInitDone = true;
|
||||
return InitPromise::CreateAndResolve(NS_OK, __func__);
|
||||
},
|
||||
[](const MediaResult& aError) {
|
||||
return InitPromise::CreateAndReject(aError, __func__);
|
||||
});
|
||||
->Then(taskQueue, __func__,
|
||||
[data, taskQueue]() {
|
||||
if (!data->mDemuxer) { // Was shutdown.
|
||||
return InitPromise::CreateAndReject(
|
||||
NS_ERROR_DOM_MEDIA_CANCELED, __func__);
|
||||
}
|
||||
data->mNumAudioTrack =
|
||||
data->mDemuxer->GetNumberTracks(TrackInfo::kAudioTrack);
|
||||
if (data->mNumAudioTrack) {
|
||||
RefPtr<MediaTrackDemuxer> d =
|
||||
data->mDemuxer->GetTrackDemuxer(TrackInfo::kAudioTrack, 0);
|
||||
if (d) {
|
||||
RefPtr<Wrapper> wrapper =
|
||||
new DemuxerProxy::Wrapper(d, taskQueue);
|
||||
wrapper->UpdateBuffered();
|
||||
data->mAudioDemuxer = wrapper;
|
||||
DecoderDoctorLogger::LinkParentAndChild(
|
||||
data->mDemuxer.get(), "decoder factory wrapper",
|
||||
"MediaFormatReader::DecoderFactory::Wrapper",
|
||||
wrapper.get());
|
||||
}
|
||||
}
|
||||
data->mNumVideoTrack =
|
||||
data->mDemuxer->GetNumberTracks(TrackInfo::kVideoTrack);
|
||||
if (data->mNumVideoTrack) {
|
||||
RefPtr<MediaTrackDemuxer> d =
|
||||
data->mDemuxer->GetTrackDemuxer(TrackInfo::kVideoTrack, 0);
|
||||
if (d) {
|
||||
RefPtr<Wrapper> wrapper =
|
||||
new DemuxerProxy::Wrapper(d, taskQueue);
|
||||
wrapper->UpdateBuffered();
|
||||
data->mVideoDemuxer = wrapper;
|
||||
DecoderDoctorLogger::LinkParentAndChild(
|
||||
data->mDemuxer.get(), "decoder factory wrapper",
|
||||
"MediaFormatReader::DecoderFactory::Wrapper",
|
||||
wrapper.get());
|
||||
}
|
||||
}
|
||||
data->mCrypto = data->mDemuxer->GetCrypto();
|
||||
data->mSeekable = data->mDemuxer->IsSeekable();
|
||||
data->mSeekableOnlyInBufferedRange =
|
||||
data->mDemuxer->IsSeekableOnlyInBufferedRanges();
|
||||
data->mShouldComputeStartTime =
|
||||
data->mDemuxer->ShouldComputeStartTime();
|
||||
data->mInitDone = true;
|
||||
return InitPromise::CreateAndResolve(NS_OK, __func__);
|
||||
},
|
||||
[](const MediaResult& aError) {
|
||||
return InitPromise::CreateAndReject(aError, __func__);
|
||||
});
|
||||
}
|
||||
|
||||
RefPtr<MediaFormatReader::NotifyDataArrivedPromise>
|
||||
|
@ -1448,20 +1444,20 @@ void MediaFormatReader::DoDemuxVideo() {
|
|||
|
||||
if (mVideo.mFirstDemuxedSampleTime.isNothing()) {
|
||||
RefPtr<MediaFormatReader> self = this;
|
||||
p = p->Then(
|
||||
OwnerThread(), __func__,
|
||||
[self](RefPtr<MediaTrackDemuxer::SamplesHolder> aSamples) {
|
||||
DDLOGEX(self.get(), DDLogCategory::Log, "video_first_demuxed",
|
||||
DDNoValue{});
|
||||
self->OnFirstDemuxCompleted(TrackInfo::kVideoTrack, aSamples);
|
||||
return SamplesPromise::CreateAndResolve(aSamples.forget(), __func__);
|
||||
},
|
||||
[self](const MediaResult& aError) {
|
||||
DDLOGEX(self.get(), DDLogCategory::Log, "video_first_demuxing_error",
|
||||
aError);
|
||||
self->OnFirstDemuxFailed(TrackInfo::kVideoTrack, aError);
|
||||
return SamplesPromise::CreateAndReject(aError, __func__);
|
||||
});
|
||||
p = p->Then(OwnerThread(), __func__,
|
||||
[self](RefPtr<MediaTrackDemuxer::SamplesHolder> aSamples) {
|
||||
DDLOGEX(self.get(), DDLogCategory::Log, "video_first_demuxed",
|
||||
DDNoValue{});
|
||||
self->OnFirstDemuxCompleted(TrackInfo::kVideoTrack, aSamples);
|
||||
return SamplesPromise::CreateAndResolve(aSamples.forget(),
|
||||
__func__);
|
||||
},
|
||||
[self](const MediaResult& aError) {
|
||||
DDLOGEX(self.get(), DDLogCategory::Log,
|
||||
"video_first_demuxing_error", aError);
|
||||
self->OnFirstDemuxFailed(TrackInfo::kVideoTrack, aError);
|
||||
return SamplesPromise::CreateAndReject(aError, __func__);
|
||||
});
|
||||
}
|
||||
|
||||
p->Then(OwnerThread(), __func__, this,
|
||||
|
@ -1526,20 +1522,20 @@ void MediaFormatReader::DoDemuxAudio() {
|
|||
|
||||
if (mAudio.mFirstDemuxedSampleTime.isNothing()) {
|
||||
RefPtr<MediaFormatReader> self = this;
|
||||
p = p->Then(
|
||||
OwnerThread(), __func__,
|
||||
[self](RefPtr<MediaTrackDemuxer::SamplesHolder> aSamples) {
|
||||
DDLOGEX(self.get(), DDLogCategory::Log, "audio_first_demuxed",
|
||||
DDNoValue{});
|
||||
self->OnFirstDemuxCompleted(TrackInfo::kAudioTrack, aSamples);
|
||||
return SamplesPromise::CreateAndResolve(aSamples.forget(), __func__);
|
||||
},
|
||||
[self](const MediaResult& aError) {
|
||||
DDLOGEX(self.get(), DDLogCategory::Log, "audio_first_demuxing_error",
|
||||
aError);
|
||||
self->OnFirstDemuxFailed(TrackInfo::kAudioTrack, aError);
|
||||
return SamplesPromise::CreateAndReject(aError, __func__);
|
||||
});
|
||||
p = p->Then(OwnerThread(), __func__,
|
||||
[self](RefPtr<MediaTrackDemuxer::SamplesHolder> aSamples) {
|
||||
DDLOGEX(self.get(), DDLogCategory::Log, "audio_first_demuxed",
|
||||
DDNoValue{});
|
||||
self->OnFirstDemuxCompleted(TrackInfo::kAudioTrack, aSamples);
|
||||
return SamplesPromise::CreateAndResolve(aSamples.forget(),
|
||||
__func__);
|
||||
},
|
||||
[self](const MediaResult& aError) {
|
||||
DDLOGEX(self.get(), DDLogCategory::Log,
|
||||
"audio_first_demuxing_error", aError);
|
||||
self->OnFirstDemuxFailed(TrackInfo::kAudioTrack, aError);
|
||||
return SamplesPromise::CreateAndReject(aError, __func__);
|
||||
});
|
||||
}
|
||||
|
||||
p->Then(OwnerThread(), __func__, this,
|
||||
|
@ -1997,47 +1993,46 @@ void MediaFormatReader::InternalSeek(TrackType aTrack,
|
|||
DDLOG(DDLogCategory::Log, "seeking", DDNoValue{});
|
||||
RefPtr<MediaFormatReader> self = this;
|
||||
decoder.mTrackDemuxer->Seek(decoder.mTimeThreshold.ref().Time())
|
||||
->Then(
|
||||
OwnerThread(), __func__,
|
||||
[self, aTrack](TimeUnit aTime) {
|
||||
DDLOGEX(self.get(), DDLogCategory::Log, "seeked", DDNoValue{});
|
||||
auto& decoder = self->GetDecoderData(aTrack);
|
||||
decoder.mSeekRequest.Complete();
|
||||
MOZ_ASSERT(decoder.mTimeThreshold,
|
||||
"Seek promise must be disconnected when "
|
||||
"timethreshold is reset");
|
||||
decoder.mTimeThreshold.ref().mHasSeeked = true;
|
||||
self->SetVideoDecodeThreshold();
|
||||
self->ScheduleUpdate(aTrack);
|
||||
},
|
||||
[self, aTrack](const MediaResult& aError) {
|
||||
auto& decoder = self->GetDecoderData(aTrack);
|
||||
decoder.mSeekRequest.Complete();
|
||||
switch (aError.Code()) {
|
||||
case NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA:
|
||||
DDLOGEX(self.get(), DDLogCategory::Log, "seeking_interrupted",
|
||||
aError);
|
||||
self->NotifyWaitingForData(aTrack);
|
||||
break;
|
||||
case NS_ERROR_DOM_MEDIA_END_OF_STREAM:
|
||||
DDLOGEX(self.get(), DDLogCategory::Log, "seeking_interrupted",
|
||||
aError);
|
||||
decoder.mTimeThreshold.reset();
|
||||
self->NotifyEndOfStream(aTrack);
|
||||
break;
|
||||
case NS_ERROR_DOM_MEDIA_CANCELED:
|
||||
DDLOGEX(self.get(), DDLogCategory::Log, "seeking_interrupted",
|
||||
aError);
|
||||
decoder.mTimeThreshold.reset();
|
||||
break;
|
||||
default:
|
||||
DDLOGEX(self.get(), DDLogCategory::Log, "seeking_error",
|
||||
aError);
|
||||
decoder.mTimeThreshold.reset();
|
||||
self->NotifyError(aTrack, aError);
|
||||
break;
|
||||
}
|
||||
})
|
||||
->Then(OwnerThread(), __func__,
|
||||
[self, aTrack](TimeUnit aTime) {
|
||||
DDLOGEX(self.get(), DDLogCategory::Log, "seeked", DDNoValue{});
|
||||
auto& decoder = self->GetDecoderData(aTrack);
|
||||
decoder.mSeekRequest.Complete();
|
||||
MOZ_ASSERT(decoder.mTimeThreshold,
|
||||
"Seek promise must be disconnected when "
|
||||
"timethreshold is reset");
|
||||
decoder.mTimeThreshold.ref().mHasSeeked = true;
|
||||
self->SetVideoDecodeThreshold();
|
||||
self->ScheduleUpdate(aTrack);
|
||||
},
|
||||
[self, aTrack](const MediaResult& aError) {
|
||||
auto& decoder = self->GetDecoderData(aTrack);
|
||||
decoder.mSeekRequest.Complete();
|
||||
switch (aError.Code()) {
|
||||
case NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA:
|
||||
DDLOGEX(self.get(), DDLogCategory::Log,
|
||||
"seeking_interrupted", aError);
|
||||
self->NotifyWaitingForData(aTrack);
|
||||
break;
|
||||
case NS_ERROR_DOM_MEDIA_END_OF_STREAM:
|
||||
DDLOGEX(self.get(), DDLogCategory::Log,
|
||||
"seeking_interrupted", aError);
|
||||
decoder.mTimeThreshold.reset();
|
||||
self->NotifyEndOfStream(aTrack);
|
||||
break;
|
||||
case NS_ERROR_DOM_MEDIA_CANCELED:
|
||||
DDLOGEX(self.get(), DDLogCategory::Log,
|
||||
"seeking_interrupted", aError);
|
||||
decoder.mTimeThreshold.reset();
|
||||
break;
|
||||
default:
|
||||
DDLOGEX(self.get(), DDLogCategory::Log, "seeking_error",
|
||||
aError);
|
||||
decoder.mTimeThreshold.reset();
|
||||
self->NotifyError(aTrack, aError);
|
||||
break;
|
||||
}
|
||||
})
|
||||
->Track(decoder.mSeekRequest);
|
||||
}
|
||||
|
||||
|
@ -2874,18 +2869,17 @@ void MediaFormatReader::NotifyDataArrived() {
|
|||
|
||||
RefPtr<MediaFormatReader> self = this;
|
||||
mDemuxer->NotifyDataArrived()
|
||||
->Then(
|
||||
OwnerThread(), __func__,
|
||||
[self]() {
|
||||
self->mNotifyDataArrivedPromise.Complete();
|
||||
self->UpdateBuffered();
|
||||
self->NotifyTrackDemuxers();
|
||||
if (self->mPendingNotifyDataArrived) {
|
||||
self->mPendingNotifyDataArrived = false;
|
||||
self->NotifyDataArrived();
|
||||
}
|
||||
},
|
||||
[self]() { self->mNotifyDataArrivedPromise.Complete(); })
|
||||
->Then(OwnerThread(), __func__,
|
||||
[self]() {
|
||||
self->mNotifyDataArrivedPromise.Complete();
|
||||
self->UpdateBuffered();
|
||||
self->NotifyTrackDemuxers();
|
||||
if (self->mPendingNotifyDataArrived) {
|
||||
self->mPendingNotifyDataArrived = false;
|
||||
self->NotifyDataArrived();
|
||||
}
|
||||
},
|
||||
[self]() { self->mNotifyDataArrivedPromise.Complete(); })
|
||||
->Track(mNotifyDataArrivedPromise);
|
||||
}
|
||||
|
||||
|
|
|
@ -3139,46 +3139,46 @@ RefPtr<MediaManager::MgrPromise> MediaManager::EnumerateDevicesImpl(
|
|||
MakeRefPtr<MediaMgrError>(MediaMgrError::Name::AbortError),
|
||||
__func__);
|
||||
})
|
||||
->Then(
|
||||
GetMainThreadSerialEventTarget(), __func__,
|
||||
[aWindowId, originKey, aVideoInputEnumType, aAudioInputEnumType,
|
||||
aVideoInputType, aAudioInputType, aOutDevices](bool) {
|
||||
// Only run if window is still on our active list.
|
||||
MediaManager* mgr = MediaManager::GetIfExists();
|
||||
if (!mgr || !mgr->IsWindowStillActive(aWindowId)) {
|
||||
return MgrPromise::CreateAndReject(
|
||||
MakeRefPtr<MediaMgrError>(MediaMgrError::Name::AbortError),
|
||||
__func__);
|
||||
}
|
||||
->Then(GetMainThreadSerialEventTarget(), __func__,
|
||||
[aWindowId, originKey, aVideoInputEnumType, aAudioInputEnumType,
|
||||
aVideoInputType, aAudioInputType, aOutDevices](bool) {
|
||||
// Only run if window is still on our active list.
|
||||
MediaManager* mgr = MediaManager::GetIfExists();
|
||||
if (!mgr || !mgr->IsWindowStillActive(aWindowId)) {
|
||||
return MgrPromise::CreateAndReject(
|
||||
MakeRefPtr<MediaMgrError>(MediaMgrError::Name::AbortError),
|
||||
__func__);
|
||||
}
|
||||
|
||||
// If we fetched any real cameras or mics, remove the
|
||||
// "default" part of their IDs.
|
||||
if (aVideoInputType == MediaSourceEnum::Camera &&
|
||||
aAudioInputType == MediaSourceEnum::Microphone &&
|
||||
(aVideoInputEnumType != DeviceEnumerationType::Fake ||
|
||||
aAudioInputEnumType != DeviceEnumerationType::Fake)) {
|
||||
mgr->mDeviceIDs.Clear();
|
||||
for (auto& device : *aOutDevices) {
|
||||
nsString id;
|
||||
device->GetId(id);
|
||||
id.ReplaceSubstring(NS_LITERAL_STRING("default: "),
|
||||
NS_LITERAL_STRING(""));
|
||||
if (!mgr->mDeviceIDs.Contains(id)) {
|
||||
mgr->mDeviceIDs.AppendElement(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!mgr->IsWindowStillActive(aWindowId)) {
|
||||
return MgrPromise::CreateAndReject(
|
||||
MakeRefPtr<MediaMgrError>(MediaMgrError::Name::AbortError),
|
||||
__func__);
|
||||
}
|
||||
MediaManager::AnonymizeDevices(*aOutDevices, *originKey, aWindowId);
|
||||
return MgrPromise::CreateAndResolve(false, __func__);
|
||||
},
|
||||
[](RefPtr<MediaMgrError>&& aError) {
|
||||
return MgrPromise::CreateAndReject(std::move(aError), __func__);
|
||||
});
|
||||
// If we fetched any real cameras or mics, remove the
|
||||
// "default" part of their IDs.
|
||||
if (aVideoInputType == MediaSourceEnum::Camera &&
|
||||
aAudioInputType == MediaSourceEnum::Microphone &&
|
||||
(aVideoInputEnumType != DeviceEnumerationType::Fake ||
|
||||
aAudioInputEnumType != DeviceEnumerationType::Fake)) {
|
||||
mgr->mDeviceIDs.Clear();
|
||||
for (auto& device : *aOutDevices) {
|
||||
nsString id;
|
||||
device->GetId(id);
|
||||
id.ReplaceSubstring(NS_LITERAL_STRING("default: "),
|
||||
NS_LITERAL_STRING(""));
|
||||
if (!mgr->mDeviceIDs.Contains(id)) {
|
||||
mgr->mDeviceIDs.AppendElement(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!mgr->IsWindowStillActive(aWindowId)) {
|
||||
return MgrPromise::CreateAndReject(
|
||||
MakeRefPtr<MediaMgrError>(MediaMgrError::Name::AbortError),
|
||||
__func__);
|
||||
}
|
||||
MediaManager::AnonymizeDevices(*aOutDevices, *originKey,
|
||||
aWindowId);
|
||||
return MgrPromise::CreateAndResolve(false, __func__);
|
||||
},
|
||||
[](RefPtr<MediaMgrError>&& aError) {
|
||||
return MgrPromise::CreateAndReject(std::move(aError), __func__);
|
||||
});
|
||||
}
|
||||
|
||||
RefPtr<MediaManager::DevicesPromise> MediaManager::EnumerateDevices(
|
||||
|
@ -3250,21 +3250,21 @@ RefPtr<MediaManager::DevicesPromise> MediaManager::EnumerateDevices(
|
|||
MediaSourceEnum::Microphone, audioOutputType,
|
||||
videoEnumerationType, audioEnumerationType, false,
|
||||
devices)
|
||||
->Then(
|
||||
GetCurrentThreadSerialEventTarget(), __func__,
|
||||
[windowListener, sourceListener, devices](bool) {
|
||||
DebugOnly<bool> rv = windowListener->Remove(sourceListener);
|
||||
MOZ_ASSERT(rv);
|
||||
return DevicesPromise::CreateAndResolve(devices, __func__);
|
||||
},
|
||||
[windowListener, sourceListener](RefPtr<MediaMgrError>&& aError) {
|
||||
// This may fail, if a new doc has been set the OnNavigation
|
||||
// method should have removed all previous active listeners.
|
||||
// Attempt to clean it here, just in case, but ignore the return
|
||||
// value.
|
||||
Unused << windowListener->Remove(sourceListener);
|
||||
return DevicesPromise::CreateAndReject(std::move(aError), __func__);
|
||||
});
|
||||
->Then(GetCurrentThreadSerialEventTarget(), __func__,
|
||||
[windowListener, sourceListener, devices](bool) {
|
||||
DebugOnly<bool> rv = windowListener->Remove(sourceListener);
|
||||
MOZ_ASSERT(rv);
|
||||
return DevicesPromise::CreateAndResolve(devices, __func__);
|
||||
},
|
||||
[windowListener, sourceListener](RefPtr<MediaMgrError>&& aError) {
|
||||
// This may fail, if a new doc has been set the OnNavigation
|
||||
// method should have removed all previous active listeners.
|
||||
// Attempt to clean it here, just in case, but ignore the return
|
||||
// value.
|
||||
Unused << windowListener->Remove(sourceListener);
|
||||
return DevicesPromise::CreateAndReject(std::move(aError),
|
||||
__func__);
|
||||
});
|
||||
}
|
||||
|
||||
RefPtr<SinkInfoPromise> MediaManager::GetSinkDevice(nsPIDOMWindowInner* aWindow,
|
||||
|
@ -3298,32 +3298,31 @@ RefPtr<SinkInfoPromise> MediaManager::GetSinkDevice(nsPIDOMWindowInner* aWindow,
|
|||
MediaSourceEnum::Other, MediaSinkEnum::Speaker,
|
||||
DeviceEnumerationType::Normal,
|
||||
DeviceEnumerationType::Normal, true, devices)
|
||||
->Then(
|
||||
GetCurrentThreadSerialEventTarget(), __func__,
|
||||
[aDeviceId, isSecure, devices](bool) {
|
||||
for (RefPtr<MediaDevice>& device : *devices) {
|
||||
if (aDeviceId.IsEmpty() && device->mSinkInfo->Preferred()) {
|
||||
return SinkInfoPromise::CreateAndResolve(device->mSinkInfo,
|
||||
__func__);
|
||||
}
|
||||
if (device->mID.Equals(aDeviceId)) {
|
||||
// TODO: Check if the application is authorized to play audio
|
||||
// through this device (Bug 1493982).
|
||||
if (isSecure || device->mSinkInfo->Preferred()) {
|
||||
return SinkInfoPromise::CreateAndResolve(device->mSinkInfo,
|
||||
__func__);
|
||||
}
|
||||
return SinkInfoPromise::CreateAndReject(
|
||||
NS_ERROR_DOM_MEDIA_NOT_ALLOWED_ERR, __func__);
|
||||
}
|
||||
}
|
||||
return SinkInfoPromise::CreateAndReject(NS_ERROR_NOT_AVAILABLE,
|
||||
__func__);
|
||||
},
|
||||
[](RefPtr<MediaMgrError>&& aError) {
|
||||
return SinkInfoPromise::CreateAndReject(NS_ERROR_NOT_AVAILABLE,
|
||||
__func__);
|
||||
});
|
||||
->Then(GetCurrentThreadSerialEventTarget(), __func__,
|
||||
[aDeviceId, isSecure, devices](bool) {
|
||||
for (RefPtr<MediaDevice>& device : *devices) {
|
||||
if (aDeviceId.IsEmpty() && device->mSinkInfo->Preferred()) {
|
||||
return SinkInfoPromise::CreateAndResolve(device->mSinkInfo,
|
||||
__func__);
|
||||
}
|
||||
if (device->mID.Equals(aDeviceId)) {
|
||||
// TODO: Check if the application is authorized to play audio
|
||||
// through this device (Bug 1493982).
|
||||
if (isSecure || device->mSinkInfo->Preferred()) {
|
||||
return SinkInfoPromise::CreateAndResolve(device->mSinkInfo,
|
||||
__func__);
|
||||
}
|
||||
return SinkInfoPromise::CreateAndReject(
|
||||
NS_ERROR_DOM_MEDIA_NOT_ALLOWED_ERR, __func__);
|
||||
}
|
||||
}
|
||||
return SinkInfoPromise::CreateAndReject(NS_ERROR_NOT_AVAILABLE,
|
||||
__func__);
|
||||
},
|
||||
[](RefPtr<MediaMgrError>&& aError) {
|
||||
return SinkInfoPromise::CreateAndReject(NS_ERROR_NOT_AVAILABLE,
|
||||
__func__);
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -4175,50 +4174,49 @@ SourceListener::InitializeAsync() {
|
|||
LOG("started all sources");
|
||||
aHolder.Resolve(true, __func__);
|
||||
})
|
||||
->Then(
|
||||
GetMainThreadSerialEventTarget(), __func__,
|
||||
[self = RefPtr<SourceListener>(this), this]() {
|
||||
if (mStopped) {
|
||||
// We were shut down during the async init
|
||||
return SourceListenerPromise::CreateAndResolve(true, __func__);
|
||||
}
|
||||
->Then(GetMainThreadSerialEventTarget(), __func__,
|
||||
[self = RefPtr<SourceListener>(this), this]() {
|
||||
if (mStopped) {
|
||||
// We were shut down during the async init
|
||||
return SourceListenerPromise::CreateAndResolve(true, __func__);
|
||||
}
|
||||
|
||||
for (DeviceState* state :
|
||||
{mAudioDeviceState.get(), mVideoDeviceState.get()}) {
|
||||
if (!state) {
|
||||
continue;
|
||||
}
|
||||
MOZ_DIAGNOSTIC_ASSERT(!state->mTrackEnabled);
|
||||
MOZ_DIAGNOSTIC_ASSERT(!state->mDeviceEnabled);
|
||||
MOZ_DIAGNOSTIC_ASSERT(!state->mStopped);
|
||||
for (DeviceState* state :
|
||||
{mAudioDeviceState.get(), mVideoDeviceState.get()}) {
|
||||
if (!state) {
|
||||
continue;
|
||||
}
|
||||
MOZ_DIAGNOSTIC_ASSERT(!state->mTrackEnabled);
|
||||
MOZ_DIAGNOSTIC_ASSERT(!state->mDeviceEnabled);
|
||||
MOZ_DIAGNOSTIC_ASSERT(!state->mStopped);
|
||||
|
||||
state->mDeviceEnabled = true;
|
||||
state->mTrackEnabled = true;
|
||||
state->mTrackEnabledTime = TimeStamp::Now();
|
||||
}
|
||||
return SourceListenerPromise::CreateAndResolve(true, __func__);
|
||||
},
|
||||
[self = RefPtr<SourceListener>(this),
|
||||
this](RefPtr<MediaMgrError>&& aResult) {
|
||||
if (mStopped) {
|
||||
return SourceListenerPromise::CreateAndReject(std::move(aResult),
|
||||
__func__);
|
||||
}
|
||||
state->mDeviceEnabled = true;
|
||||
state->mTrackEnabled = true;
|
||||
state->mTrackEnabledTime = TimeStamp::Now();
|
||||
}
|
||||
return SourceListenerPromise::CreateAndResolve(true, __func__);
|
||||
},
|
||||
[self = RefPtr<SourceListener>(this),
|
||||
this](RefPtr<MediaMgrError>&& aResult) {
|
||||
if (mStopped) {
|
||||
return SourceListenerPromise::CreateAndReject(
|
||||
std::move(aResult), __func__);
|
||||
}
|
||||
|
||||
for (DeviceState* state :
|
||||
{mAudioDeviceState.get(), mVideoDeviceState.get()}) {
|
||||
if (!state) {
|
||||
continue;
|
||||
}
|
||||
MOZ_DIAGNOSTIC_ASSERT(!state->mTrackEnabled);
|
||||
MOZ_DIAGNOSTIC_ASSERT(!state->mDeviceEnabled);
|
||||
MOZ_DIAGNOSTIC_ASSERT(!state->mStopped);
|
||||
for (DeviceState* state :
|
||||
{mAudioDeviceState.get(), mVideoDeviceState.get()}) {
|
||||
if (!state) {
|
||||
continue;
|
||||
}
|
||||
MOZ_DIAGNOSTIC_ASSERT(!state->mTrackEnabled);
|
||||
MOZ_DIAGNOSTIC_ASSERT(!state->mDeviceEnabled);
|
||||
MOZ_DIAGNOSTIC_ASSERT(!state->mStopped);
|
||||
|
||||
state->mStopped = true;
|
||||
}
|
||||
return SourceListenerPromise::CreateAndReject(std::move(aResult),
|
||||
__func__);
|
||||
});
|
||||
state->mStopped = true;
|
||||
}
|
||||
return SourceListenerPromise::CreateAndReject(std::move(aResult),
|
||||
__func__);
|
||||
});
|
||||
}
|
||||
|
||||
void SourceListener::Stop() {
|
||||
|
|
|
@ -884,14 +884,13 @@ class MediaRecorder::Session : public PrincipalChangeObserver<MediaStreamTrack>,
|
|||
}
|
||||
gSessions.Clear();
|
||||
ShutdownPromise::All(GetCurrentThreadSerialEventTarget(), promises)
|
||||
->Then(
|
||||
GetCurrentThreadSerialEventTarget(), __func__,
|
||||
[ticket]() mutable {
|
||||
MOZ_ASSERT(gSessions.Count() == 0);
|
||||
// Unblock shutdown
|
||||
ticket = nullptr;
|
||||
},
|
||||
[]() { MOZ_CRASH("Not reached"); });
|
||||
->Then(GetCurrentThreadSerialEventTarget(), __func__,
|
||||
[ticket]() mutable {
|
||||
MOZ_ASSERT(gSessions.Count() == 0);
|
||||
// Unblock shutdown
|
||||
ticket = nullptr;
|
||||
},
|
||||
[]() { MOZ_CRASH("Not reached"); });
|
||||
return NS_OK;
|
||||
}
|
||||
};
|
||||
|
@ -1715,16 +1714,15 @@ RefPtr<MediaRecorder::SizeOfPromise> MediaRecorder::SizeOfExcludingThis(
|
|||
}
|
||||
|
||||
SizeOfPromise::All(GetCurrentThreadSerialEventTarget(), promises)
|
||||
->Then(
|
||||
GetCurrentThreadSerialEventTarget(), __func__,
|
||||
[holder](const nsTArray<size_t>& sizes) {
|
||||
size_t total = 0;
|
||||
for (const size_t& size : sizes) {
|
||||
total += size;
|
||||
}
|
||||
holder->Resolve(total, __func__);
|
||||
},
|
||||
[]() { MOZ_CRASH("Unexpected reject"); });
|
||||
->Then(GetCurrentThreadSerialEventTarget(), __func__,
|
||||
[holder](const nsTArray<size_t>& sizes) {
|
||||
size_t total = 0;
|
||||
for (const size_t& size : sizes) {
|
||||
total += size;
|
||||
}
|
||||
holder->Resolve(total, __func__);
|
||||
},
|
||||
[]() { MOZ_CRASH("Unexpected reject"); });
|
||||
|
||||
return promise;
|
||||
}
|
||||
|
|
|
@ -80,19 +80,18 @@ RefPtr<ReaderProxy::VideoDataPromise> ReaderProxy::RequestVideoData(
|
|||
int64_t startTime = StartTime().ToMicroseconds();
|
||||
return InvokeAsync(mReader->OwnerThread(), mReader.get(), __func__,
|
||||
&MediaFormatReader::RequestVideoData, threshold)
|
||||
->Then(
|
||||
mOwnerThread, __func__,
|
||||
[startTime](RefPtr<VideoData> aVideo) {
|
||||
aVideo->AdjustForStartTime(startTime);
|
||||
return aVideo->mTime.IsValid()
|
||||
? VideoDataPromise::CreateAndResolve(aVideo.forget(),
|
||||
__func__)
|
||||
: VideoDataPromise::CreateAndReject(
|
||||
NS_ERROR_DOM_MEDIA_OVERFLOW_ERR, __func__);
|
||||
},
|
||||
[](const MediaResult& aError) {
|
||||
return VideoDataPromise::CreateAndReject(aError, __func__);
|
||||
});
|
||||
->Then(mOwnerThread, __func__,
|
||||
[startTime](RefPtr<VideoData> aVideo) {
|
||||
aVideo->AdjustForStartTime(startTime);
|
||||
return aVideo->mTime.IsValid()
|
||||
? VideoDataPromise::CreateAndResolve(aVideo.forget(),
|
||||
__func__)
|
||||
: VideoDataPromise::CreateAndReject(
|
||||
NS_ERROR_DOM_MEDIA_OVERFLOW_ERR, __func__);
|
||||
},
|
||||
[](const MediaResult& aError) {
|
||||
return VideoDataPromise::CreateAndReject(aError, __func__);
|
||||
});
|
||||
}
|
||||
|
||||
RefPtr<ReaderProxy::SeekPromise> ReaderProxy::Seek(const SeekTarget& aTarget) {
|
||||
|
|
|
@ -93,14 +93,13 @@ class VideoFrameConverter {
|
|||
mLastFrameQueuedForPacing = t;
|
||||
|
||||
mPacingTimer->WaitUntil(t, __func__)
|
||||
->Then(
|
||||
mTaskQueue, __func__,
|
||||
[self = RefPtr<VideoFrameConverter>(this), this,
|
||||
image = RefPtr<layers::Image>(aChunk.mFrame.GetImage()), t, size,
|
||||
aForceBlack]() mutable {
|
||||
QueueForProcessing(std::move(image), t, size, aForceBlack);
|
||||
},
|
||||
[] {});
|
||||
->Then(mTaskQueue, __func__,
|
||||
[self = RefPtr<VideoFrameConverter>(this), this,
|
||||
image = RefPtr<layers::Image>(aChunk.mFrame.GetImage()), t,
|
||||
size, aForceBlack]() mutable {
|
||||
QueueForProcessing(std::move(image), t, size, aForceBlack);
|
||||
},
|
||||
[] {});
|
||||
}
|
||||
|
||||
void SetTrackEnabled(bool aEnabled) {
|
||||
|
|
|
@ -45,8 +45,7 @@ static void TestMultiWriterQueueST(const int loops) {
|
|||
}
|
||||
}
|
||||
|
||||
TEST(MultiWriterQueue, SingleThreaded)
|
||||
{
|
||||
TEST(MultiWriterQueue, SingleThreaded) {
|
||||
TestMultiWriterQueueST<1>(10);
|
||||
TestMultiWriterQueueST<2>(10);
|
||||
TestMultiWriterQueueST<4>(10);
|
||||
|
@ -156,8 +155,7 @@ static void TestMultiWriterQueueMT(int aWriterThreads, int aReaderThreads,
|
|||
q.AllocatedBuffersStats().mWatermark);
|
||||
}
|
||||
|
||||
TEST(MultiWriterQueue, MultiWriterSingleReader)
|
||||
{
|
||||
TEST(MultiWriterQueue, MultiWriterSingleReader) {
|
||||
// Small BufferSize, to exercize the buffer management code.
|
||||
TestMultiWriterQueueMT<
|
||||
MultiWriterQueue<int, 10, MultiWriterQueueReaderLocking_None>>(
|
||||
|
@ -216,8 +214,7 @@ TEST(MultiWriterQueue, MultiWriterSingleReader)
|
|||
// MultiWriterQueueReaderLocking_None>>(64, 2, 2*1024*1024);
|
||||
}
|
||||
|
||||
TEST(MultiWriterQueue, MultiWriterMultiReader)
|
||||
{
|
||||
TEST(MultiWriterQueue, MultiWriterMultiReader) {
|
||||
static_assert(
|
||||
mozilla::IsSame<MultiWriterQueue<int, 10>,
|
||||
MultiWriterQueue<
|
||||
|
@ -346,8 +343,7 @@ struct DequeWrapperMT : DequeWrapperMW {
|
|||
}
|
||||
};
|
||||
|
||||
TEST(MultiWriterQueue, nsDequeBenchmark)
|
||||
{
|
||||
TEST(MultiWriterQueue, nsDequeBenchmark) {
|
||||
TestMultiWriterQueueMT<DequeWrapperST>(1, 0, 2 * 1024 * 1024,
|
||||
"DequeWrapperST ");
|
||||
|
||||
|
|
|
@ -14,8 +14,7 @@
|
|||
|
||||
using RN8 = mozilla::RollingNumber<uint8_t>;
|
||||
|
||||
TEST(RollingNumber, Value)
|
||||
{
|
||||
TEST(RollingNumber, Value) {
|
||||
// Value type should reflect template argument.
|
||||
static_assert(mozilla::IsSame<RN8::ValueType, uint8_t>::value, "");
|
||||
|
||||
|
@ -41,8 +40,7 @@ TEST(RollingNumber, Value)
|
|||
EXPECT_EQ(0, n42.Value());
|
||||
}
|
||||
|
||||
TEST(RollingNumber, Operations)
|
||||
{
|
||||
TEST(RollingNumber, Operations) {
|
||||
RN8 n;
|
||||
EXPECT_EQ(0, n.Value());
|
||||
|
||||
|
@ -92,8 +90,7 @@ TEST(RollingNumber, Operations)
|
|||
EXPECT_EQ(10, n.Value());
|
||||
}
|
||||
|
||||
TEST(RollingNumber, Comparisons)
|
||||
{
|
||||
TEST(RollingNumber, Comparisons) {
|
||||
uint8_t i = 0;
|
||||
do {
|
||||
RN8 n{i};
|
||||
|
|
|
@ -793,9 +793,7 @@ static bool CheckRequirement(const MediaKeysRequirement aRequirement,
|
|||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
return false;
|
||||
}
|
||||
default: { return false; }
|
||||
}
|
||||
|
||||
// Set the requirement member of accumulated configuration to equal
|
||||
|
|
|
@ -233,9 +233,7 @@ nsresult VP8TrackEncoder::GetEncodedPartitions(EncodedFrameContainer& aData) {
|
|||
pkt->data.frame.sz);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
default: { break; }
|
||||
}
|
||||
// End of frame
|
||||
if ((pkt->data.frame.flags & VPX_FRAME_IS_FRAGMENT) == 0) {
|
||||
|
|
|
@ -392,16 +392,15 @@ mozilla::ipc::IPCResult ChromiumCDMChild::RecvInit(
|
|||
mPersistentStateAllowed = aAllowPersistentState;
|
||||
|
||||
RefPtr<ChromiumCDMChild::InitPromise> promise = mInitPromise.Ensure(__func__);
|
||||
promise->Then(
|
||||
mPlugin->GMPMessageLoop()->SerialEventTarget(), __func__,
|
||||
[aResolver](bool /* unused */) { aResolver(true); },
|
||||
[aResolver](nsresult rv) {
|
||||
GMP_LOG(
|
||||
"ChromiumCDMChild::RecvInit() init promise rejected with "
|
||||
"rv=%" PRIu32,
|
||||
static_cast<uint32_t>(rv));
|
||||
aResolver(false);
|
||||
});
|
||||
promise->Then(mPlugin->GMPMessageLoop()->SerialEventTarget(), __func__,
|
||||
[aResolver](bool /* unused */) { aResolver(true); },
|
||||
[aResolver](nsresult rv) {
|
||||
GMP_LOG(
|
||||
"ChromiumCDMChild::RecvInit() init promise rejected with "
|
||||
"rv=%" PRIu32,
|
||||
static_cast<uint32_t>(rv));
|
||||
aResolver(false);
|
||||
});
|
||||
|
||||
if (mCDM) {
|
||||
// Once the CDM is initialized we expect it to resolve mInitPromise via
|
||||
|
|
|
@ -93,21 +93,20 @@ void ChromiumCDMProxy::Init(PromiseId aPromiseId, const nsAString& aOrigin,
|
|||
cdm->Init(self->mCallback.get(),
|
||||
self->mDistinctiveIdentifierRequired,
|
||||
self->mPersistentStateRequired, self->mMainThread)
|
||||
->Then(
|
||||
thread, __func__,
|
||||
[self, aPromiseId, cdm](bool /* unused */) {
|
||||
// CDM init succeeded
|
||||
{
|
||||
MutexAutoLock lock(self->mCDMMutex);
|
||||
self->mCDM = cdm;
|
||||
}
|
||||
self->OnCDMCreated(aPromiseId);
|
||||
},
|
||||
[self, aPromiseId](MediaResult aResult) {
|
||||
// CDM init failed
|
||||
self->RejectPromise(aPromiseId, aResult.Code(),
|
||||
aResult.Message());
|
||||
});
|
||||
->Then(thread, __func__,
|
||||
[self, aPromiseId, cdm](bool /* unused */) {
|
||||
// CDM init succeeded
|
||||
{
|
||||
MutexAutoLock lock(self->mCDMMutex);
|
||||
self->mCDM = cdm;
|
||||
}
|
||||
self->OnCDMCreated(aPromiseId);
|
||||
},
|
||||
[self, aPromiseId](MediaResult aResult) {
|
||||
// CDM init failed
|
||||
self->RejectPromise(aPromiseId, aResult.Code(),
|
||||
aResult.Message());
|
||||
});
|
||||
},
|
||||
[self, aPromiseId](MediaResult rv) {
|
||||
// service->GetCDM failed
|
||||
|
|
|
@ -355,25 +355,24 @@ GeckoMediaPluginService::GetDecryptingGMPVideoDecoder(
|
|||
RefPtr<GMPCrashHelper> helper(aHelper);
|
||||
GetContentParent(aHelper, aNodeId, NS_LITERAL_CSTRING(GMP_API_VIDEO_DECODER),
|
||||
*aTags)
|
||||
->Then(
|
||||
thread, __func__,
|
||||
[rawCallback, helper,
|
||||
aDecryptorId](RefPtr<GMPContentParent::CloseBlocker> wrapper) {
|
||||
RefPtr<GMPContentParent> parent = wrapper->mParent;
|
||||
UniquePtr<GetGMPVideoDecoderCallback> callback(rawCallback);
|
||||
GMPVideoDecoderParent* actor = nullptr;
|
||||
GMPVideoHostImpl* host = nullptr;
|
||||
if (parent && NS_SUCCEEDED(parent->GetGMPVideoDecoder(
|
||||
&actor, aDecryptorId))) {
|
||||
host = &(actor->Host());
|
||||
actor->SetCrashHelper(helper);
|
||||
}
|
||||
callback->Done(actor, host);
|
||||
},
|
||||
[rawCallback] {
|
||||
UniquePtr<GetGMPVideoDecoderCallback> callback(rawCallback);
|
||||
callback->Done(nullptr, nullptr);
|
||||
});
|
||||
->Then(thread, __func__,
|
||||
[rawCallback, helper,
|
||||
aDecryptorId](RefPtr<GMPContentParent::CloseBlocker> wrapper) {
|
||||
RefPtr<GMPContentParent> parent = wrapper->mParent;
|
||||
UniquePtr<GetGMPVideoDecoderCallback> callback(rawCallback);
|
||||
GMPVideoDecoderParent* actor = nullptr;
|
||||
GMPVideoHostImpl* host = nullptr;
|
||||
if (parent && NS_SUCCEEDED(parent->GetGMPVideoDecoder(
|
||||
&actor, aDecryptorId))) {
|
||||
host = &(actor->Host());
|
||||
actor->SetCrashHelper(helper);
|
||||
}
|
||||
callback->Done(actor, host);
|
||||
},
|
||||
[rawCallback] {
|
||||
UniquePtr<GetGMPVideoDecoderCallback> callback(rawCallback);
|
||||
callback->Done(nullptr, nullptr);
|
||||
});
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -396,24 +395,23 @@ GeckoMediaPluginService::GetGMPVideoEncoder(
|
|||
RefPtr<GMPCrashHelper> helper(aHelper);
|
||||
GetContentParent(aHelper, aNodeId, NS_LITERAL_CSTRING(GMP_API_VIDEO_ENCODER),
|
||||
*aTags)
|
||||
->Then(
|
||||
thread, __func__,
|
||||
[rawCallback,
|
||||
helper](RefPtr<GMPContentParent::CloseBlocker> wrapper) {
|
||||
RefPtr<GMPContentParent> parent = wrapper->mParent;
|
||||
UniquePtr<GetGMPVideoEncoderCallback> callback(rawCallback);
|
||||
GMPVideoEncoderParent* actor = nullptr;
|
||||
GMPVideoHostImpl* host = nullptr;
|
||||
if (parent && NS_SUCCEEDED(parent->GetGMPVideoEncoder(&actor))) {
|
||||
host = &(actor->Host());
|
||||
actor->SetCrashHelper(helper);
|
||||
}
|
||||
callback->Done(actor, host);
|
||||
},
|
||||
[rawCallback] {
|
||||
UniquePtr<GetGMPVideoEncoderCallback> callback(rawCallback);
|
||||
callback->Done(nullptr, nullptr);
|
||||
});
|
||||
->Then(thread, __func__,
|
||||
[rawCallback,
|
||||
helper](RefPtr<GMPContentParent::CloseBlocker> wrapper) {
|
||||
RefPtr<GMPContentParent> parent = wrapper->mParent;
|
||||
UniquePtr<GetGMPVideoEncoderCallback> callback(rawCallback);
|
||||
GMPVideoEncoderParent* actor = nullptr;
|
||||
GMPVideoHostImpl* host = nullptr;
|
||||
if (parent && NS_SUCCEEDED(parent->GetGMPVideoEncoder(&actor))) {
|
||||
host = &(actor->Host());
|
||||
actor->SetCrashHelper(helper);
|
||||
}
|
||||
callback->Done(actor, host);
|
||||
},
|
||||
[rawCallback] {
|
||||
UniquePtr<GetGMPVideoEncoderCallback> callback(rawCallback);
|
||||
callback->Done(nullptr, nullptr);
|
||||
});
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -401,18 +401,17 @@ void GeckoMediaPluginServiceParent::InitializePlugins(
|
|||
RefPtr<GenericPromise> p = mInitPromise.Ensure(__func__);
|
||||
InvokeAsync(aAbstractGMPThread, this, __func__,
|
||||
&GeckoMediaPluginServiceParent::LoadFromEnvironment)
|
||||
->Then(
|
||||
aAbstractGMPThread, __func__,
|
||||
[self]() -> void {
|
||||
MonitorAutoLock lock(self->mInitPromiseMonitor);
|
||||
self->mLoadPluginsFromDiskComplete = true;
|
||||
self->mInitPromise.Resolve(true, __func__);
|
||||
},
|
||||
[self]() -> void {
|
||||
MonitorAutoLock lock(self->mInitPromiseMonitor);
|
||||
self->mLoadPluginsFromDiskComplete = true;
|
||||
self->mInitPromise.Reject(NS_ERROR_FAILURE, __func__);
|
||||
});
|
||||
->Then(aAbstractGMPThread, __func__,
|
||||
[self]() -> void {
|
||||
MonitorAutoLock lock(self->mInitPromiseMonitor);
|
||||
self->mLoadPluginsFromDiskComplete = true;
|
||||
self->mInitPromise.Resolve(true, __func__);
|
||||
},
|
||||
[self]() -> void {
|
||||
MonitorAutoLock lock(self->mInitPromiseMonitor);
|
||||
self->mLoadPluginsFromDiskComplete = true;
|
||||
self->mInitPromise.Reject(NS_ERROR_FAILURE, __func__);
|
||||
});
|
||||
}
|
||||
|
||||
void GeckoMediaPluginServiceParent::NotifySyncShutdownComplete() {
|
||||
|
@ -508,12 +507,12 @@ RefPtr<GenericPromise> GeckoMediaPluginServiceParent::LoadFromEnvironment() {
|
|||
|
||||
mScannedPluginOnDisk = true;
|
||||
return GenericPromise::All(thread, promises)
|
||||
->Then(
|
||||
thread, __func__,
|
||||
[]() { return GenericPromise::CreateAndResolve(true, __func__); },
|
||||
[]() {
|
||||
return GenericPromise::CreateAndReject(NS_ERROR_FAILURE, __func__);
|
||||
});
|
||||
->Then(thread, __func__,
|
||||
[]() { return GenericPromise::CreateAndResolve(true, __func__); },
|
||||
[]() {
|
||||
return GenericPromise::CreateAndReject(NS_ERROR_FAILURE,
|
||||
__func__);
|
||||
});
|
||||
}
|
||||
|
||||
class NotifyObserversTask final : public mozilla::Runnable {
|
||||
|
@ -613,24 +612,23 @@ RefPtr<GenericPromise> GeckoMediaPluginServiceParent::AsyncAddPluginDirectory(
|
|||
RefPtr<GeckoMediaPluginServiceParent> self = this;
|
||||
return InvokeAsync(thread, this, __func__,
|
||||
&GeckoMediaPluginServiceParent::AddOnGMPThread, dir)
|
||||
->Then(
|
||||
mMainThread, __func__,
|
||||
[dir, self](bool aVal) {
|
||||
LOGD(
|
||||
("GeckoMediaPluginServiceParent::AsyncAddPluginDirectory %s "
|
||||
"succeeded",
|
||||
NS_ConvertUTF16toUTF8(dir).get()));
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
self->UpdateContentProcessGMPCapabilities();
|
||||
return GenericPromise::CreateAndResolve(aVal, __func__);
|
||||
},
|
||||
[dir](nsresult aResult) {
|
||||
LOGD(
|
||||
("GeckoMediaPluginServiceParent::AsyncAddPluginDirectory %s "
|
||||
"failed",
|
||||
NS_ConvertUTF16toUTF8(dir).get()));
|
||||
return GenericPromise::CreateAndReject(aResult, __func__);
|
||||
});
|
||||
->Then(mMainThread, __func__,
|
||||
[dir, self](bool aVal) {
|
||||
LOGD(
|
||||
("GeckoMediaPluginServiceParent::AsyncAddPluginDirectory %s "
|
||||
"succeeded",
|
||||
NS_ConvertUTF16toUTF8(dir).get()));
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
self->UpdateContentProcessGMPCapabilities();
|
||||
return GenericPromise::CreateAndResolve(aVal, __func__);
|
||||
},
|
||||
[dir](nsresult aResult) {
|
||||
LOGD(
|
||||
("GeckoMediaPluginServiceParent::AsyncAddPluginDirectory %s "
|
||||
"failed",
|
||||
NS_ConvertUTF16toUTF8(dir).get()));
|
||||
return GenericPromise::CreateAndReject(aResult, __func__);
|
||||
});
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
@ -42,8 +42,8 @@ void test_for_number_of_channels(const uint32_t channels) {
|
|||
|
||||
for (uint32_t i = 0; i < samples; i++) {
|
||||
ASSERT_TRUE(fromCallback[i] == 1.0)
|
||||
<< "Difference at " << i << " (" << fromCallback[i] << " != " << 1.0
|
||||
<< ")\n";
|
||||
<< "Difference at " << i << " (" << fromCallback[i] << " != " << 1.0
|
||||
<< ")\n";
|
||||
}
|
||||
|
||||
ASSERT_TRUE(b.Fill(other.data(), FRAMES) == 128);
|
||||
|
@ -51,8 +51,7 @@ void test_for_number_of_channels(const uint32_t channels) {
|
|||
ASSERT_TRUE(b.Empty(mBuffer) == 0);
|
||||
}
|
||||
|
||||
TEST(AudioBuffers, Test)
|
||||
{
|
||||
TEST(AudioBuffers, Test) {
|
||||
for (uint32_t ch = 1; ch <= 8; ++ch) {
|
||||
test_for_number_of_channels(ch);
|
||||
}
|
||||
|
|
|
@ -75,20 +75,15 @@ static void TestAudioCompactor(size_t aBytes) {
|
|||
EXPECT_LE(slop, maxSlop) << "allowed too much allocation slop";
|
||||
}
|
||||
|
||||
TEST(Media, AudioCompactor_4000)
|
||||
{ TestAudioCompactor(4000); }
|
||||
TEST(Media, AudioCompactor_4000) { TestAudioCompactor(4000); }
|
||||
|
||||
TEST(Media, AudioCompactor_4096)
|
||||
{ TestAudioCompactor(4096); }
|
||||
TEST(Media, AudioCompactor_4096) { TestAudioCompactor(4096); }
|
||||
|
||||
TEST(Media, AudioCompactor_5000)
|
||||
{ TestAudioCompactor(5000); }
|
||||
TEST(Media, AudioCompactor_5000) { TestAudioCompactor(5000); }
|
||||
|
||||
TEST(Media, AudioCompactor_5256)
|
||||
{ TestAudioCompactor(5256); }
|
||||
TEST(Media, AudioCompactor_5256) { TestAudioCompactor(5256); }
|
||||
|
||||
TEST(Media, AudioCompactor_NativeCopy)
|
||||
{
|
||||
TEST(Media, AudioCompactor_NativeCopy) {
|
||||
const uint32_t channels = 2;
|
||||
const size_t srcBytes = 32;
|
||||
const uint32_t srcSamples = srcBytes / sizeof(AudioDataValue);
|
||||
|
|
|
@ -482,8 +482,7 @@ void AddDevices(MockCubeb* mock, uint32_t device_count,
|
|||
}
|
||||
|
||||
#ifndef ANDROID
|
||||
TEST(CubebDeviceEnumerator, EnumerateSimple)
|
||||
{
|
||||
TEST(CubebDeviceEnumerator, EnumerateSimple) {
|
||||
// It looks like we're leaking this object, but in fact it will be freed by
|
||||
// gecko sometime later: `cubeb_destroy` is called when layout statics are
|
||||
// shutdown and we cast back to a MockCubeb* and call the dtor.
|
||||
|
@ -519,8 +518,7 @@ TEST(CubebDeviceEnumerator, EnumerateSimple)
|
|||
}
|
||||
|
||||
#else // building for Android, which has no device enumeration support
|
||||
TEST(CubebDeviceEnumerator, EnumerateAndroid)
|
||||
{
|
||||
TEST(CubebDeviceEnumerator, EnumerateAndroid) {
|
||||
MockCubeb* mock = new MockCubeb();
|
||||
mozilla::CubebUtils::ForceSetCubebContext(mock->AsCubebContext());
|
||||
|
||||
|
@ -549,8 +547,7 @@ TEST(CubebDeviceEnumerator, EnumerateAndroid)
|
|||
}
|
||||
#endif
|
||||
|
||||
TEST(CubebDeviceEnumerator, ForceNullCubebContext)
|
||||
{
|
||||
TEST(CubebDeviceEnumerator, ForceNullCubebContext) {
|
||||
mozilla::CubebUtils::ForceSetCubebContext(nullptr);
|
||||
RefPtr<CubebDeviceEnumerator> enumerator =
|
||||
CubebDeviceEnumerator::GetInstance();
|
||||
|
@ -569,8 +566,7 @@ TEST(CubebDeviceEnumerator, ForceNullCubebContext)
|
|||
CubebDeviceEnumerator::Shutdown();
|
||||
}
|
||||
|
||||
TEST(CubebDeviceEnumerator, DeviceInfoFromId)
|
||||
{
|
||||
TEST(CubebDeviceEnumerator, DeviceInfoFromId) {
|
||||
MockCubeb* mock = new MockCubeb();
|
||||
mozilla::CubebUtils::ForceSetCubebContext(mock->AsCubebContext());
|
||||
|
||||
|
@ -608,8 +604,7 @@ TEST(CubebDeviceEnumerator, DeviceInfoFromId)
|
|||
CubebDeviceEnumerator::Shutdown();
|
||||
}
|
||||
|
||||
TEST(CubebDeviceEnumerator, DeviceInfoFromName)
|
||||
{
|
||||
TEST(CubebDeviceEnumerator, DeviceInfoFromName) {
|
||||
MockCubeb* mock = new MockCubeb();
|
||||
mozilla::CubebUtils::ForceSetCubebContext(mock->AsCubebContext());
|
||||
|
||||
|
|
|
@ -70,8 +70,7 @@ void FillBuffer(AudioDataValue* aBuffer, uint32_t aLength,
|
|||
}
|
||||
}
|
||||
|
||||
TEST(AudioMixer, Test)
|
||||
{
|
||||
TEST(AudioMixer, Test) {
|
||||
const uint32_t CHANNEL_LENGTH = 256;
|
||||
const uint32_t AUDIO_RATE = 44100;
|
||||
MixerConsumer consumer;
|
||||
|
|
|
@ -34,7 +34,7 @@ void IsSequence(std::unique_ptr<int16_t[]> aBuffer, uint32_t aSize,
|
|||
uint32_t aStart = 0) {
|
||||
for (uint32_t i = 0; i < aSize; i++) {
|
||||
ASSERT_TRUE(aBuffer[i] == static_cast<int64_t>(aStart + i))
|
||||
<< "Buffer is not a sequence at offset " << i << std::endl;
|
||||
<< "Buffer is not a sequence at offset " << i << std::endl;
|
||||
}
|
||||
// Buffer is a sequence.
|
||||
}
|
||||
|
@ -42,14 +42,13 @@ void IsSequence(std::unique_ptr<int16_t[]> aBuffer, uint32_t aSize,
|
|||
void Zero(std::unique_ptr<int16_t[]> aBuffer, uint32_t aSize) {
|
||||
for (uint32_t i = 0; i < aSize; i++) {
|
||||
ASSERT_TRUE(aBuffer[i] == 0)
|
||||
<< "Buffer is not null at offset " << i << std::endl;
|
||||
<< "Buffer is not null at offset " << i << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
double sine(uint32_t aPhase) { return sin(aPhase * 2 * M_PI * 440 / 44100); }
|
||||
|
||||
TEST(AudioPacketizer, Test)
|
||||
{
|
||||
TEST(AudioPacketizer, Test) {
|
||||
for (int16_t channels = 1; channels < 2; channels++) {
|
||||
// Test that the packetizer returns zero on underrun
|
||||
{
|
||||
|
|
|
@ -224,8 +224,7 @@ void TestDownmixStereo() {
|
|||
delete[] output;
|
||||
}
|
||||
|
||||
TEST(AudioSegment, Test)
|
||||
{
|
||||
TEST(AudioSegment, Test) {
|
||||
TestInterleaveAndConvert<float, float>();
|
||||
TestInterleaveAndConvert<float, int16_t>();
|
||||
TestInterleaveAndConvert<int16_t, float>();
|
||||
|
|
|
@ -59,8 +59,7 @@ static bool TestOpusInit(int aChannels, int aSamplingRate) {
|
|||
return encoder.TestOpusRawCreation(aChannels, aSamplingRate);
|
||||
}
|
||||
|
||||
TEST(OpusAudioTrackEncoder, InitRaw)
|
||||
{
|
||||
TEST(OpusAudioTrackEncoder, InitRaw) {
|
||||
// Expect false with 0 or negative channels of input signal.
|
||||
EXPECT_FALSE(TestOpusInit(0, 16000));
|
||||
EXPECT_FALSE(TestOpusInit(-1, 16000));
|
||||
|
@ -90,8 +89,7 @@ TEST(OpusAudioTrackEncoder, InitRaw)
|
|||
EXPECT_FALSE(TestOpusInit(2, 200000));
|
||||
}
|
||||
|
||||
TEST(OpusAudioTrackEncoder, Init)
|
||||
{
|
||||
TEST(OpusAudioTrackEncoder, Init) {
|
||||
{
|
||||
// The encoder does not normally recieve enough info from null data to
|
||||
// init. However, multiple attempts to do so, with sufficiently long
|
||||
|
@ -177,8 +175,7 @@ static int TestOpusResampler(int aChannels, int aSamplingRate) {
|
|||
return encoder.TestGetOutputSampleRate();
|
||||
}
|
||||
|
||||
TEST(OpusAudioTrackEncoder, Resample)
|
||||
{
|
||||
TEST(OpusAudioTrackEncoder, Resample) {
|
||||
// Sampling rates of data to be fed to Opus encoder, should remain unchanged
|
||||
// if it is one of Opus supported rates (8000, 12000, 16000, 24000 and 48000
|
||||
// (kHz)) at initialization.
|
||||
|
@ -193,8 +190,7 @@ TEST(OpusAudioTrackEncoder, Resample)
|
|||
EXPECT_TRUE(TestOpusResampler(1, 44100) == 48000);
|
||||
}
|
||||
|
||||
TEST(OpusAudioTrackEncoder, FetchMetadata)
|
||||
{
|
||||
TEST(OpusAudioTrackEncoder, FetchMetadata) {
|
||||
const int32_t channels = 1;
|
||||
const int32_t sampleRate = 44100;
|
||||
TestOpusTrackEncoder encoder;
|
||||
|
@ -208,8 +204,7 @@ TEST(OpusAudioTrackEncoder, FetchMetadata)
|
|||
EXPECT_EQ(sampleRate, opusMeta->mSamplingFrequency);
|
||||
}
|
||||
|
||||
TEST(OpusAudioTrackEncoder, FrameEncode)
|
||||
{
|
||||
TEST(OpusAudioTrackEncoder, FrameEncode) {
|
||||
const int32_t channels = 1;
|
||||
const int32_t sampleRate = 44100;
|
||||
TestOpusTrackEncoder encoder;
|
||||
|
|
|
@ -10,8 +10,7 @@
|
|||
|
||||
using namespace mozilla;
|
||||
|
||||
TEST(BitWriter, BitWriter)
|
||||
{
|
||||
TEST(BitWriter, BitWriter) {
|
||||
RefPtr<MediaByteBuffer> test = new MediaByteBuffer();
|
||||
BitWriter b(test);
|
||||
b.WriteBit(false);
|
||||
|
@ -50,8 +49,7 @@ TEST(BitWriter, BitWriter)
|
|||
EXPECT_EQ(length, BitReader::GetBitLength(test));
|
||||
}
|
||||
|
||||
TEST(BitWriter, SPS)
|
||||
{
|
||||
TEST(BitWriter, SPS) {
|
||||
uint8_t sps_pps[] = {0x01, 0x4d, 0x40, 0x0c, 0xff, 0xe1, 0x00, 0x1b, 0x67,
|
||||
0x4d, 0x40, 0x0c, 0xe8, 0x80, 0x80, 0x9d, 0x80, 0xb5,
|
||||
0x01, 0x01, 0x01, 0x40, 0x00, 0x00, 0x03, 0x00, 0x40,
|
||||
|
|
|
@ -8,8 +8,7 @@
|
|||
|
||||
using namespace mozilla;
|
||||
|
||||
TEST(BlankVideoDataCreator, ShouldNotOverflow)
|
||||
{
|
||||
TEST(BlankVideoDataCreator, ShouldNotOverflow) {
|
||||
RefPtr<MediaRawData> mrd = new MediaRawData();
|
||||
const uint32_t width = 1;
|
||||
const uint32_t height = 1;
|
||||
|
@ -18,8 +17,7 @@ TEST(BlankVideoDataCreator, ShouldNotOverflow)
|
|||
EXPECT_NE(data.get(), nullptr);
|
||||
}
|
||||
|
||||
TEST(BlankVideoDataCreator, ShouldOverflow)
|
||||
{
|
||||
TEST(BlankVideoDataCreator, ShouldOverflow) {
|
||||
RefPtr<MediaRawData> mrd = new MediaRawData();
|
||||
const uint32_t width = UINT_MAX;
|
||||
const uint32_t height = UINT_MAX;
|
||||
|
|
|
@ -6,8 +6,7 @@
|
|||
#include "gtest/gtest.h"
|
||||
#include "BufferReader.h"
|
||||
|
||||
TEST(BufferReader, ReaderCursor)
|
||||
{
|
||||
TEST(BufferReader, ReaderCursor) {
|
||||
// Allocate a buffer and create a BufferReader.
|
||||
const size_t BUFFER_SIZE = 10;
|
||||
uint8_t buffer[BUFFER_SIZE] = {0};
|
||||
|
|
|
@ -399,26 +399,24 @@ class CDMStorageTest {
|
|||
RefPtr<gmp::GetCDMParentPromise> promise =
|
||||
service->GetCDM(aNodeId, std::move(tags), nullptr);
|
||||
auto thread = GetAbstractGMPThread();
|
||||
promise->Then(
|
||||
thread, __func__,
|
||||
[self, aUpdates, thread](RefPtr<gmp::ChromiumCDMParent> cdm) {
|
||||
self->mCDM = cdm;
|
||||
EXPECT_TRUE(!!self->mCDM);
|
||||
self->mCallback.reset(new CallbackProxy(self));
|
||||
nsCString failureReason;
|
||||
self->mCDM
|
||||
->Init(self->mCallback.get(), false, true,
|
||||
GetMainThreadEventTarget())
|
||||
->Then(
|
||||
thread, __func__,
|
||||
[self, aUpdates] {
|
||||
for (auto& update : aUpdates) {
|
||||
self->Update(update);
|
||||
}
|
||||
promise->Then(thread, __func__,
|
||||
[self, aUpdates, thread](RefPtr<gmp::ChromiumCDMParent> cdm) {
|
||||
self->mCDM = cdm;
|
||||
EXPECT_TRUE(!!self->mCDM);
|
||||
self->mCallback.reset(new CallbackProxy(self));
|
||||
nsCString failureReason;
|
||||
self->mCDM
|
||||
->Init(self->mCallback.get(), false, true,
|
||||
GetMainThreadEventTarget())
|
||||
->Then(thread, __func__,
|
||||
[self, aUpdates] {
|
||||
for (auto& update : aUpdates) {
|
||||
self->Update(update);
|
||||
}
|
||||
},
|
||||
[](MediaResult rv) { EXPECT_TRUE(false); });
|
||||
},
|
||||
[](MediaResult rv) { EXPECT_TRUE(false); });
|
||||
},
|
||||
[](MediaResult rv) { EXPECT_TRUE(false); });
|
||||
}
|
||||
|
||||
void TestBasicStorage() {
|
||||
|
@ -1030,64 +1028,54 @@ class CDMStorageTest {
|
|||
UniquePtr<CallbackProxy> mCallback;
|
||||
}; // class CDMStorageTest
|
||||
|
||||
TEST(GeckoMediaPlugins, CDMStorageGetNodeId)
|
||||
{
|
||||
TEST(GeckoMediaPlugins, CDMStorageGetNodeId) {
|
||||
RefPtr<CDMStorageTest> runner = new CDMStorageTest();
|
||||
runner->DoTest(&CDMStorageTest::TestGetNodeId);
|
||||
}
|
||||
|
||||
TEST(GeckoMediaPlugins, CDMStorageBasic)
|
||||
{
|
||||
TEST(GeckoMediaPlugins, CDMStorageBasic) {
|
||||
RefPtr<CDMStorageTest> runner = new CDMStorageTest();
|
||||
runner->DoTest(&CDMStorageTest::TestBasicStorage);
|
||||
}
|
||||
|
||||
TEST(GeckoMediaPlugins, CDMStorageForgetThisSite)
|
||||
{
|
||||
TEST(GeckoMediaPlugins, CDMStorageForgetThisSite) {
|
||||
RefPtr<CDMStorageTest> runner = new CDMStorageTest();
|
||||
runner->DoTest(&CDMStorageTest::TestForgetThisSite);
|
||||
}
|
||||
|
||||
TEST(GeckoMediaPlugins, CDMStorageClearRecentHistory1)
|
||||
{
|
||||
TEST(GeckoMediaPlugins, CDMStorageClearRecentHistory1) {
|
||||
RefPtr<CDMStorageTest> runner = new CDMStorageTest();
|
||||
runner->DoTest(&CDMStorageTest::TestClearRecentHistory1);
|
||||
}
|
||||
|
||||
TEST(GeckoMediaPlugins, CDMStorageClearRecentHistory2)
|
||||
{
|
||||
TEST(GeckoMediaPlugins, CDMStorageClearRecentHistory2) {
|
||||
RefPtr<CDMStorageTest> runner = new CDMStorageTest();
|
||||
runner->DoTest(&CDMStorageTest::TestClearRecentHistory2);
|
||||
}
|
||||
|
||||
TEST(GeckoMediaPlugins, CDMStorageClearRecentHistory3)
|
||||
{
|
||||
TEST(GeckoMediaPlugins, CDMStorageClearRecentHistory3) {
|
||||
RefPtr<CDMStorageTest> runner = new CDMStorageTest();
|
||||
runner->DoTest(&CDMStorageTest::TestClearRecentHistory3);
|
||||
}
|
||||
|
||||
TEST(GeckoMediaPlugins, CDMStorageCrossOrigin)
|
||||
{
|
||||
TEST(GeckoMediaPlugins, CDMStorageCrossOrigin) {
|
||||
RefPtr<CDMStorageTest> runner = new CDMStorageTest();
|
||||
runner->DoTest(&CDMStorageTest::TestCrossOriginStorage);
|
||||
}
|
||||
|
||||
TEST(GeckoMediaPlugins, CDMStoragePrivateBrowsing)
|
||||
{
|
||||
TEST(GeckoMediaPlugins, CDMStoragePrivateBrowsing) {
|
||||
RefPtr<CDMStorageTest> runner = new CDMStorageTest();
|
||||
runner->DoTest(&CDMStorageTest::TestPBStorage);
|
||||
}
|
||||
|
||||
#if defined(XP_WIN)
|
||||
TEST(GeckoMediaPlugins, GMPOutputProtection)
|
||||
{
|
||||
TEST(GeckoMediaPlugins, GMPOutputProtection) {
|
||||
RefPtr<CDMStorageTest> runner = new CDMStorageTest();
|
||||
runner->DoTest(&CDMStorageTest::TestOutputProtection);
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST(GeckoMediaPlugins, CDMStorageLongRecordNames)
|
||||
{
|
||||
TEST(GeckoMediaPlugins, CDMStorageLongRecordNames) {
|
||||
RefPtr<CDMStorageTest> runner = new CDMStorageTest();
|
||||
runner->DoTest(&CDMStorageTest::TestLongRecordNames);
|
||||
}
|
||||
|
|
|
@ -14,8 +14,7 @@ struct A {
|
|||
int mValue;
|
||||
};
|
||||
|
||||
TEST(DataMutex, Basic)
|
||||
{
|
||||
TEST(DataMutex, Basic) {
|
||||
{
|
||||
DataMutex<uint32_t> i(1, "1");
|
||||
auto x = i.Lock();
|
||||
|
|
|
@ -198,16 +198,14 @@ void GMPTestRunner::DoTest(
|
|||
monitor.AwaitFinished();
|
||||
}
|
||||
|
||||
TEST(GeckoMediaPlugins, GMPTestCodec)
|
||||
{
|
||||
TEST(GeckoMediaPlugins, GMPTestCodec) {
|
||||
RefPtr<GMPTestRunner> runner = new GMPTestRunner();
|
||||
runner->DoTest(&GMPTestRunner::RunTestGMPTestCodec1);
|
||||
runner->DoTest(&GMPTestRunner::RunTestGMPTestCodec2);
|
||||
runner->DoTest(&GMPTestRunner::RunTestGMPTestCodec3);
|
||||
}
|
||||
|
||||
TEST(GeckoMediaPlugins, GMPCrossOrigin)
|
||||
{
|
||||
TEST(GeckoMediaPlugins, GMPCrossOrigin) {
|
||||
RefPtr<GMPTestRunner> runner = new GMPTestRunner();
|
||||
runner->DoTest(&GMPTestRunner::RunTestGMPCrossOrigin1);
|
||||
runner->DoTest(&GMPTestRunner::RunTestGMPCrossOrigin2);
|
||||
|
|
|
@ -105,8 +105,7 @@ class GMPRemoveTest : public nsIObserver, public GMPVideoDecoderCallbackProxy {
|
|||
/*
|
||||
* Simple test that the plugin is deleted when forcibly removed and deleted.
|
||||
*/
|
||||
TEST(GeckoMediaPlugins, RemoveAndDeleteForcedSimple)
|
||||
{
|
||||
TEST(GeckoMediaPlugins, RemoveAndDeleteForcedSimple) {
|
||||
RefPtr<GMPRemoveTest> test(new GMPRemoveTest());
|
||||
|
||||
test->Setup();
|
||||
|
@ -117,8 +116,7 @@ TEST(GeckoMediaPlugins, RemoveAndDeleteForcedSimple)
|
|||
/*
|
||||
* Simple test that the plugin is deleted when deferred deletion is allowed.
|
||||
*/
|
||||
TEST(GeckoMediaPlugins, RemoveAndDeleteDeferredSimple)
|
||||
{
|
||||
TEST(GeckoMediaPlugins, RemoveAndDeleteDeferredSimple) {
|
||||
RefPtr<GMPRemoveTest> test(new GMPRemoveTest());
|
||||
|
||||
test->Setup();
|
||||
|
@ -130,8 +128,7 @@ TEST(GeckoMediaPlugins, RemoveAndDeleteDeferredSimple)
|
|||
* Test that the plugin is unavailable immediately after a forced
|
||||
* RemoveAndDelete, and that the plugin is deleted afterwards.
|
||||
*/
|
||||
TEST(GeckoMediaPlugins, RemoveAndDeleteForcedInUse)
|
||||
{
|
||||
TEST(GeckoMediaPlugins, RemoveAndDeleteForcedInUse) {
|
||||
RefPtr<GMPRemoveTest> test(new GMPRemoveTest());
|
||||
|
||||
test->Setup();
|
||||
|
@ -155,8 +152,7 @@ TEST(GeckoMediaPlugins, RemoveAndDeleteForcedInUse)
|
|||
* Test that the plugin is still usable after a deferred RemoveAndDelete, and
|
||||
* that the plugin is deleted afterwards.
|
||||
*/
|
||||
TEST(GeckoMediaPlugins, RemoveAndDeleteDeferredInUse)
|
||||
{
|
||||
TEST(GeckoMediaPlugins, RemoveAndDeleteDeferredInUse) {
|
||||
RefPtr<GMPRemoveTest> test(new GMPRemoveTest());
|
||||
|
||||
test->Setup();
|
||||
|
|
|
@ -28,8 +28,7 @@ void TestSplitAt(const char* aInput, const char* aDelims,
|
|||
}
|
||||
}
|
||||
|
||||
TEST(GeckoMediaPlugins, TestSplitAt)
|
||||
{
|
||||
TEST(GeckoMediaPlugins, TestSplitAt) {
|
||||
{
|
||||
const char* input = "1,2,3,4";
|
||||
const char* delims = ",";
|
||||
|
@ -56,8 +55,7 @@ TEST(GeckoMediaPlugins, TestSplitAt)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(GeckoMediaPlugins, ToHexString)
|
||||
{
|
||||
TEST(GeckoMediaPlugins, ToHexString) {
|
||||
struct Test {
|
||||
nsTArray<uint8_t> bytes;
|
||||
string hex;
|
||||
|
|
|
@ -90,8 +90,7 @@ RefPtr<MediaDevice> MakeSpeakerDevice(const nsString& aName,
|
|||
/* Verify that when an audio input device name contains the video input device
|
||||
* name the video device group id is updated to become equal to the audio
|
||||
* device group id. */
|
||||
TEST(TestGroupId, MatchInput_PartOfName)
|
||||
{
|
||||
TEST(TestGroupId, MatchInput_PartOfName) {
|
||||
MediaManager::MediaDeviceSet devices;
|
||||
|
||||
devices.AppendElement(
|
||||
|
@ -111,8 +110,7 @@ TEST(TestGroupId, MatchInput_PartOfName)
|
|||
/* Verify that when an audio input device name is the same as the video input
|
||||
* device name the video device group id is updated to become equal to the audio
|
||||
* device group id. */
|
||||
TEST(TestGroupId, MatchInput_FullName)
|
||||
{
|
||||
TEST(TestGroupId, MatchInput_FullName) {
|
||||
MediaManager::MediaDeviceSet devices;
|
||||
|
||||
devices.AppendElement(
|
||||
|
@ -130,8 +128,7 @@ TEST(TestGroupId, MatchInput_FullName)
|
|||
|
||||
/* Verify that when an audio input device name does not contain the video input
|
||||
* device name the video device group id does not change. */
|
||||
TEST(TestGroupId, NoMatchInput)
|
||||
{
|
||||
TEST(TestGroupId, NoMatchInput) {
|
||||
MediaManager::MediaDeviceSet devices;
|
||||
|
||||
nsString Cam_Model_GroupId = NS_LITERAL_STRING("Cam-Model-GroupId");
|
||||
|
@ -152,8 +149,7 @@ TEST(TestGroupId, NoMatchInput)
|
|||
/* Verify that when more that one audio input and more than one audio output
|
||||
* device name contain the video input device name the video device group id
|
||||
* does not change. */
|
||||
TEST(TestGroupId, NoMatch_TwoIdenticalDevices)
|
||||
{
|
||||
TEST(TestGroupId, NoMatch_TwoIdenticalDevices) {
|
||||
MediaManager::MediaDeviceSet devices;
|
||||
|
||||
nsString Cam_Model_GroupId = NS_LITERAL_STRING("Cam-Model-GroupId");
|
||||
|
@ -188,8 +184,7 @@ TEST(TestGroupId, NoMatch_TwoIdenticalDevices)
|
|||
* input device name the video device group id is not updated by audio input
|
||||
* device group id but it continues looking at audio output devices where it
|
||||
* finds a match so video input group id is updated by audio output group id. */
|
||||
TEST(TestGroupId, Match_TwoIdenticalInputsMatchOutput)
|
||||
{
|
||||
TEST(TestGroupId, Match_TwoIdenticalInputsMatchOutput) {
|
||||
MediaManager::MediaDeviceSet devices;
|
||||
|
||||
nsString Cam_Model_GroupId = NS_LITERAL_STRING("Cam-Model-GroupId");
|
||||
|
@ -216,8 +211,7 @@ TEST(TestGroupId, Match_TwoIdenticalInputsMatchOutput)
|
|||
/* Verify that when more that one audio input and more than one audio output
|
||||
* device names contain the video input device name the video device group id
|
||||
* does not change. */
|
||||
TEST(TestGroupId, NoMatch_ThreeIdenticalDevices)
|
||||
{
|
||||
TEST(TestGroupId, NoMatch_ThreeIdenticalDevices) {
|
||||
MediaManager::MediaDeviceSet devices;
|
||||
|
||||
nsString Cam_Model_GroupId = NS_LITERAL_STRING("Cam-Model-GroupId");
|
||||
|
@ -257,8 +251,7 @@ TEST(TestGroupId, NoMatch_ThreeIdenticalDevices)
|
|||
/* Verify that when an audio output device name contains the video input device
|
||||
* name the video device group id is updated to become equal to the audio
|
||||
* device group id. */
|
||||
TEST(TestGroupId, MatchOutput)
|
||||
{
|
||||
TEST(TestGroupId, MatchOutput) {
|
||||
MediaManager::MediaDeviceSet devices;
|
||||
|
||||
devices.AppendElement(
|
||||
|
@ -281,8 +274,7 @@ TEST(TestGroupId, MatchOutput)
|
|||
/* Verify that when an audio input device name is the same as audio output
|
||||
* device and video input device name the video device group id is updated to
|
||||
* become equal to the audio input device group id. */
|
||||
TEST(TestGroupId, InputOutputSameName)
|
||||
{
|
||||
TEST(TestGroupId, InputOutputSameName) {
|
||||
MediaManager::MediaDeviceSet devices;
|
||||
|
||||
devices.AppendElement(
|
||||
|
@ -305,8 +297,7 @@ TEST(TestGroupId, InputOutputSameName)
|
|||
/* Verify that when an audio input device name contains the video input device
|
||||
* and the audio input group id is an empty string, the video device group id
|
||||
* is updated to become equal to the audio device group id. */
|
||||
TEST(TestGroupId, InputEmptyGroupId)
|
||||
{
|
||||
TEST(TestGroupId, InputEmptyGroupId) {
|
||||
MediaManager::MediaDeviceSet devices;
|
||||
|
||||
devices.AppendElement(
|
||||
|
@ -325,8 +316,7 @@ TEST(TestGroupId, InputEmptyGroupId)
|
|||
/* Verify that when an audio output device name contains the video input device
|
||||
* and the audio output group id is an empty string, the video device group id
|
||||
* is updated to become equal to the audio output device group id. */
|
||||
TEST(TestGroupId, OutputEmptyGroupId)
|
||||
{
|
||||
TEST(TestGroupId, OutputEmptyGroupId) {
|
||||
MediaManager::MediaDeviceSet devices;
|
||||
|
||||
devices.AppendElement(
|
||||
|
|
|
@ -28,8 +28,7 @@ media::IntervalSet<uint8_t> CreateByteIntervalSet(int32_t aStart,
|
|||
return test;
|
||||
}
|
||||
|
||||
TEST(IntervalSet, Constructors)
|
||||
{
|
||||
TEST(IntervalSet, Constructors) {
|
||||
const int32_t start = 1;
|
||||
const int32_t end = 2;
|
||||
const int32_t fuzz = 0;
|
||||
|
@ -74,8 +73,7 @@ media::TimeIntervals CreateTimeIntervals(int32_t aStart, int32_t aEnd) {
|
|||
return test;
|
||||
}
|
||||
|
||||
TEST(IntervalSet, TimeIntervalsConstructors)
|
||||
{
|
||||
TEST(IntervalSet, TimeIntervalsConstructors) {
|
||||
const auto start = media::TimeUnit::FromMicroseconds(1);
|
||||
const auto end = media::TimeUnit::FromMicroseconds(2);
|
||||
const media::TimeUnit fuzz;
|
||||
|
@ -110,14 +108,12 @@ TEST(IntervalSet, TimeIntervalsConstructors)
|
|||
EXPECT_EQ(0u, i0.Length()); // Constructing with an empty time interval.
|
||||
}
|
||||
|
||||
TEST(IntervalSet, Length)
|
||||
{
|
||||
TEST(IntervalSet, Length) {
|
||||
IntInterval i(15, 25);
|
||||
EXPECT_EQ(10, i.Length());
|
||||
}
|
||||
|
||||
TEST(IntervalSet, Intersects)
|
||||
{
|
||||
TEST(IntervalSet, Intersects) {
|
||||
EXPECT_TRUE(IntInterval(1, 5).Intersects(IntInterval(3, 4)));
|
||||
EXPECT_TRUE(IntInterval(1, 5).Intersects(IntInterval(3, 7)));
|
||||
EXPECT_TRUE(IntInterval(1, 5).Intersects(IntInterval(-1, 3)));
|
||||
|
@ -133,8 +129,7 @@ TEST(IntervalSet, Intersects)
|
|||
EXPECT_FALSE(IntInterval(1, 1).Intersects(IntInterval(2, 2)));
|
||||
}
|
||||
|
||||
TEST(IntervalSet, Intersection)
|
||||
{
|
||||
TEST(IntervalSet, Intersection) {
|
||||
IntInterval i0(10, 20);
|
||||
IntInterval i1(15, 25);
|
||||
IntInterval i = i0.Intersection(i1);
|
||||
|
@ -150,8 +145,7 @@ TEST(IntervalSet, Intersection)
|
|||
EXPECT_TRUE(k.IsEmpty());
|
||||
}
|
||||
|
||||
TEST(IntervalSet, Equals)
|
||||
{
|
||||
TEST(IntervalSet, Equals) {
|
||||
IntInterval i0(10, 20);
|
||||
IntInterval i1(10, 20);
|
||||
EXPECT_EQ(i0, i1);
|
||||
|
@ -163,8 +157,7 @@ TEST(IntervalSet, Equals)
|
|||
EXPECT_NE(i0, i2);
|
||||
}
|
||||
|
||||
TEST(IntervalSet, IntersectionIntervalSet)
|
||||
{
|
||||
TEST(IntervalSet, IntersectionIntervalSet) {
|
||||
IntIntervals i0;
|
||||
i0 += IntInterval(5, 10);
|
||||
i0 += IntInterval(20, 25);
|
||||
|
@ -239,8 +232,7 @@ static void GeneratePermutations(const IntIntervals& aI1,
|
|||
} while (std::next_permutation(comb1.begin(), comb1.end()));
|
||||
}
|
||||
|
||||
TEST(IntervalSet, IntersectionNormalizedIntervalSet)
|
||||
{
|
||||
TEST(IntervalSet, IntersectionNormalizedIntervalSet) {
|
||||
IntIntervals i0;
|
||||
i0 += IntInterval(5, 10);
|
||||
i0 += IntInterval(20, 25);
|
||||
|
@ -255,8 +247,7 @@ TEST(IntervalSet, IntersectionNormalizedIntervalSet)
|
|||
GeneratePermutations(i0, i1);
|
||||
}
|
||||
|
||||
TEST(IntervalSet, IntersectionUnorderedNonNormalizedIntervalSet)
|
||||
{
|
||||
TEST(IntervalSet, IntersectionUnorderedNonNormalizedIntervalSet) {
|
||||
IntIntervals i0;
|
||||
i0 += IntInterval(5, 10);
|
||||
i0 += IntInterval(8, 25);
|
||||
|
@ -271,8 +262,7 @@ TEST(IntervalSet, IntersectionUnorderedNonNormalizedIntervalSet)
|
|||
GeneratePermutations(i0, i1);
|
||||
}
|
||||
|
||||
TEST(IntervalSet, IntersectionNonNormalizedInterval)
|
||||
{
|
||||
TEST(IntervalSet, IntersectionNonNormalizedInterval) {
|
||||
IntIntervals i0;
|
||||
i0 += IntInterval(5, 10);
|
||||
i0 += IntInterval(8, 25);
|
||||
|
@ -285,8 +275,7 @@ TEST(IntervalSet, IntersectionNonNormalizedInterval)
|
|||
EXPECT_EQ(i0[0].mEnd, i1.mEnd);
|
||||
}
|
||||
|
||||
TEST(IntervalSet, IntersectionUnorderedNonNormalizedInterval)
|
||||
{
|
||||
TEST(IntervalSet, IntersectionUnorderedNonNormalizedInterval) {
|
||||
IntIntervals i0;
|
||||
i0 += IntInterval(1, 3);
|
||||
i0 += IntInterval(1, 10);
|
||||
|
@ -309,8 +298,7 @@ static IntIntervals Duplicate(const IntIntervals& aValue) {
|
|||
return value;
|
||||
}
|
||||
|
||||
TEST(IntervalSet, Normalize)
|
||||
{
|
||||
TEST(IntervalSet, Normalize) {
|
||||
IntIntervals i;
|
||||
// Test IntervalSet<T> + Interval<T> operator.
|
||||
i = i + IntInterval(20, 30);
|
||||
|
@ -344,8 +332,7 @@ TEST(IntervalSet, Normalize)
|
|||
EXPECT_EQ(1u, ti.Length());
|
||||
}
|
||||
|
||||
TEST(IntervalSet, ContainValue)
|
||||
{
|
||||
TEST(IntervalSet, ContainValue) {
|
||||
IntIntervals i0;
|
||||
i0 += IntInterval(0, 10);
|
||||
i0 += IntInterval(15, 20);
|
||||
|
@ -356,8 +343,7 @@ TEST(IntervalSet, ContainValue)
|
|||
EXPECT_FALSE(i0.Contains(25));
|
||||
}
|
||||
|
||||
TEST(IntervalSet, ContainValueWithFuzz)
|
||||
{
|
||||
TEST(IntervalSet, ContainValueWithFuzz) {
|
||||
IntIntervals i0;
|
||||
i0 += IntInterval(0, 10);
|
||||
i0 += IntInterval(15, 20, 1);
|
||||
|
@ -369,8 +355,7 @@ TEST(IntervalSet, ContainValueWithFuzz)
|
|||
EXPECT_FALSE(i0.Contains(25));
|
||||
}
|
||||
|
||||
TEST(IntervalSet, ContainInterval)
|
||||
{
|
||||
TEST(IntervalSet, ContainInterval) {
|
||||
IntIntervals i0;
|
||||
i0 += IntInterval(0, 10);
|
||||
i0 += IntInterval(15, 20);
|
||||
|
@ -385,8 +370,7 @@ TEST(IntervalSet, ContainInterval)
|
|||
EXPECT_FALSE(i0.Contains(IntInterval(30, 55)));
|
||||
}
|
||||
|
||||
TEST(IntervalSet, ContainIntervalWithFuzz)
|
||||
{
|
||||
TEST(IntervalSet, ContainIntervalWithFuzz) {
|
||||
IntIntervals i0;
|
||||
i0 += IntInterval(0, 10);
|
||||
i0 += IntInterval(15, 20);
|
||||
|
@ -410,8 +394,7 @@ TEST(IntervalSet, ContainIntervalWithFuzz)
|
|||
EXPECT_TRUE(i1.Contains(IntInterval(15, 21)));
|
||||
}
|
||||
|
||||
TEST(IntervalSet, Span)
|
||||
{
|
||||
TEST(IntervalSet, Span) {
|
||||
IntInterval i0(0, 10);
|
||||
IntInterval i1(20, 30);
|
||||
IntInterval i{i0.Span(i1)};
|
||||
|
@ -420,8 +403,7 @@ TEST(IntervalSet, Span)
|
|||
EXPECT_EQ(i.mEnd, 30);
|
||||
}
|
||||
|
||||
TEST(IntervalSet, Union)
|
||||
{
|
||||
TEST(IntervalSet, Union) {
|
||||
IntIntervals i0;
|
||||
i0 += IntInterval(5, 10);
|
||||
i0 += IntInterval(20, 25);
|
||||
|
@ -447,8 +429,7 @@ TEST(IntervalSet, Union)
|
|||
EXPECT_EQ(60, i[2].mEnd);
|
||||
}
|
||||
|
||||
TEST(IntervalSet, UnionNotOrdered)
|
||||
{
|
||||
TEST(IntervalSet, UnionNotOrdered) {
|
||||
IntIntervals i0;
|
||||
i0 += IntInterval(20, 25);
|
||||
i0 += IntInterval(40, 60);
|
||||
|
@ -474,8 +455,7 @@ TEST(IntervalSet, UnionNotOrdered)
|
|||
EXPECT_EQ(60, i[2].mEnd);
|
||||
}
|
||||
|
||||
TEST(IntervalSet, NormalizeFuzz)
|
||||
{
|
||||
TEST(IntervalSet, NormalizeFuzz) {
|
||||
IntIntervals i0;
|
||||
i0 += IntInterval(11, 25, 0);
|
||||
i0 += IntInterval(5, 10, 1);
|
||||
|
@ -490,8 +470,7 @@ TEST(IntervalSet, NormalizeFuzz)
|
|||
EXPECT_EQ(60, i0[1].mEnd);
|
||||
}
|
||||
|
||||
TEST(IntervalSet, UnionFuzz)
|
||||
{
|
||||
TEST(IntervalSet, UnionFuzz) {
|
||||
IntIntervals i0;
|
||||
i0 += IntInterval(5, 10, 1);
|
||||
i0 += IntInterval(11, 25, 0);
|
||||
|
@ -526,16 +505,14 @@ TEST(IntervalSet, UnionFuzz)
|
|||
EXPECT_EQ(60, i[1].mEnd);
|
||||
}
|
||||
|
||||
TEST(IntervalSet, Contiguous)
|
||||
{
|
||||
TEST(IntervalSet, Contiguous) {
|
||||
EXPECT_FALSE(IntInterval(5, 10).Contiguous(IntInterval(11, 25)));
|
||||
EXPECT_TRUE(IntInterval(5, 10).Contiguous(IntInterval(10, 25)));
|
||||
EXPECT_TRUE(IntInterval(5, 10, 1).Contiguous(IntInterval(11, 25)));
|
||||
EXPECT_TRUE(IntInterval(5, 10).Contiguous(IntInterval(11, 25, 1)));
|
||||
}
|
||||
|
||||
TEST(IntervalSet, TimeRangesSeconds)
|
||||
{
|
||||
TEST(IntervalSet, TimeRangesSeconds) {
|
||||
media::TimeIntervals i0;
|
||||
i0 += media::TimeInterval(media::TimeUnit::FromSeconds(20),
|
||||
media::TimeUnit::FromSeconds(25));
|
||||
|
@ -580,8 +557,7 @@ static void CheckTimeRanges(dom::TimeRanges* aTr,
|
|||
}
|
||||
}
|
||||
|
||||
TEST(IntervalSet, TimeRangesConversion)
|
||||
{
|
||||
TEST(IntervalSet, TimeRangesConversion) {
|
||||
RefPtr<dom::TimeRanges> tr = new dom::TimeRanges();
|
||||
tr->Add(20, 25);
|
||||
tr->Add(40, 60);
|
||||
|
@ -599,8 +575,7 @@ TEST(IntervalSet, TimeRangesConversion)
|
|||
CheckTimeRanges(tr2, i1);
|
||||
}
|
||||
|
||||
TEST(IntervalSet, TimeRangesMicroseconds)
|
||||
{
|
||||
TEST(IntervalSet, TimeRangesMicroseconds) {
|
||||
media::TimeIntervals i0;
|
||||
|
||||
i0 += media::TimeInterval(media::TimeUnit::FromMicroseconds(20),
|
||||
|
@ -686,8 +661,7 @@ class Foo {
|
|||
int32_t mArg3;
|
||||
};
|
||||
|
||||
TEST(IntervalSet, FooIntervalSet)
|
||||
{
|
||||
TEST(IntervalSet, FooIntervalSet) {
|
||||
media::Interval<Foo<int>> i(Foo<int>(), Foo<int>(4, 5, 6));
|
||||
media::IntervalSet<Foo<int>> is;
|
||||
is += i;
|
||||
|
@ -700,8 +674,7 @@ TEST(IntervalSet, FooIntervalSet)
|
|||
EXPECT_EQ(Foo<int>(4, 5, 6), is[0].mEnd);
|
||||
}
|
||||
|
||||
TEST(IntervalSet, StaticAssert)
|
||||
{
|
||||
TEST(IntervalSet, StaticAssert) {
|
||||
media::Interval<int> i;
|
||||
|
||||
static_assert(
|
||||
|
@ -714,8 +687,7 @@ TEST(IntervalSet, StaticAssert)
|
|||
"Must use copy constructor");
|
||||
}
|
||||
|
||||
TEST(IntervalSet, Substraction)
|
||||
{
|
||||
TEST(IntervalSet, Substraction) {
|
||||
IntIntervals i0;
|
||||
i0 += IntInterval(5, 10);
|
||||
i0 += IntInterval(20, 25);
|
||||
|
|
|
@ -146,24 +146,22 @@ class MP4DemuxerBinding {
|
|||
virtual ~MP4DemuxerBinding() {}
|
||||
};
|
||||
|
||||
TEST(MP4Demuxer, Seek)
|
||||
{
|
||||
TEST(MP4Demuxer, Seek) {
|
||||
RefPtr<MP4DemuxerBinding> binding = new MP4DemuxerBinding();
|
||||
|
||||
binding->RunTestAndWait([binding]() {
|
||||
binding->mVideoTrack =
|
||||
binding->mDemuxer->GetTrackDemuxer(TrackInfo::kVideoTrack, 0);
|
||||
binding->CheckTrackSamples(binding->mVideoTrack)
|
||||
->Then(
|
||||
binding->mTaskQueue, __func__,
|
||||
[binding]() {
|
||||
binding->CheckTrackKeyFrame(binding->mVideoTrack)
|
||||
->Then(
|
||||
binding->mTaskQueue, __func__,
|
||||
[binding]() { binding->mTaskQueue->BeginShutdown(); },
|
||||
DO_FAIL);
|
||||
},
|
||||
DO_FAIL);
|
||||
->Then(binding->mTaskQueue, __func__,
|
||||
[binding]() {
|
||||
binding->CheckTrackKeyFrame(binding->mVideoTrack)
|
||||
->Then(
|
||||
binding->mTaskQueue, __func__,
|
||||
[binding]() { binding->mTaskQueue->BeginShutdown(); },
|
||||
DO_FAIL);
|
||||
},
|
||||
DO_FAIL);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -189,8 +187,7 @@ static nsCString ToCryptoString(const CryptoSample& aCrypto) {
|
|||
return res;
|
||||
}
|
||||
|
||||
TEST(MP4Demuxer, CENCFragVideo)
|
||||
{
|
||||
TEST(MP4Demuxer, CENCFragVideo) {
|
||||
const char* video[] = {
|
||||
"16 7e571d037e571d037e571d037e571d03 00000000000000000000000000000000 "
|
||||
"5,684 5,16980",
|
||||
|
@ -321,22 +318,21 @@ TEST(MP4Demuxer, CENCFragVideo)
|
|||
binding->mVideoTrack =
|
||||
binding->mDemuxer->GetTrackDemuxer(TrackInfo::kVideoTrack, 0);
|
||||
binding->CheckTrackSamples(binding->mVideoTrack)
|
||||
->Then(
|
||||
binding->mTaskQueue, __func__,
|
||||
[binding, video]() {
|
||||
for (uint32_t i = 0; i < binding->mSamples.Length(); i++) {
|
||||
nsCString text = ToCryptoString(binding->mSamples[i]->mCrypto);
|
||||
EXPECT_STREQ(video[i++], text.get());
|
||||
}
|
||||
EXPECT_EQ(ArrayLength(video), binding->mSamples.Length());
|
||||
binding->mTaskQueue->BeginShutdown();
|
||||
},
|
||||
DO_FAIL);
|
||||
->Then(binding->mTaskQueue, __func__,
|
||||
[binding, video]() {
|
||||
for (uint32_t i = 0; i < binding->mSamples.Length(); i++) {
|
||||
nsCString text =
|
||||
ToCryptoString(binding->mSamples[i]->mCrypto);
|
||||
EXPECT_STREQ(video[i++], text.get());
|
||||
}
|
||||
EXPECT_EQ(ArrayLength(video), binding->mSamples.Length());
|
||||
binding->mTaskQueue->BeginShutdown();
|
||||
},
|
||||
DO_FAIL);
|
||||
});
|
||||
}
|
||||
|
||||
TEST(MP4Demuxer, CENCFragAudio)
|
||||
{
|
||||
TEST(MP4Demuxer, CENCFragAudio) {
|
||||
const char* audio[] = {
|
||||
"16 7e571d047e571d047e571d047e571d04 00000000000000000000000000000000 "
|
||||
"0,281",
|
||||
|
@ -535,23 +531,22 @@ TEST(MP4Demuxer, CENCFragAudio)
|
|||
binding->mAudioTrack =
|
||||
binding->mDemuxer->GetTrackDemuxer(TrackInfo::kAudioTrack, 0);
|
||||
binding->CheckTrackSamples(binding->mAudioTrack)
|
||||
->Then(
|
||||
binding->mTaskQueue, __func__,
|
||||
[binding, audio]() {
|
||||
EXPECT_TRUE(binding->mSamples.Length() > 1);
|
||||
for (uint32_t i = 0; i < binding->mSamples.Length(); i++) {
|
||||
nsCString text = ToCryptoString(binding->mSamples[i]->mCrypto);
|
||||
EXPECT_STREQ(audio[i++], text.get());
|
||||
}
|
||||
EXPECT_EQ(ArrayLength(audio), binding->mSamples.Length());
|
||||
binding->mTaskQueue->BeginShutdown();
|
||||
},
|
||||
DO_FAIL);
|
||||
->Then(binding->mTaskQueue, __func__,
|
||||
[binding, audio]() {
|
||||
EXPECT_TRUE(binding->mSamples.Length() > 1);
|
||||
for (uint32_t i = 0; i < binding->mSamples.Length(); i++) {
|
||||
nsCString text =
|
||||
ToCryptoString(binding->mSamples[i]->mCrypto);
|
||||
EXPECT_STREQ(audio[i++], text.get());
|
||||
}
|
||||
EXPECT_EQ(ArrayLength(audio), binding->mSamples.Length());
|
||||
binding->mTaskQueue->BeginShutdown();
|
||||
},
|
||||
DO_FAIL);
|
||||
});
|
||||
}
|
||||
|
||||
TEST(MP4Demuxer, GetNextKeyframe)
|
||||
{
|
||||
TEST(MP4Demuxer, GetNextKeyframe) {
|
||||
RefPtr<MP4DemuxerBinding> binding = new MP4DemuxerBinding("gizmo-frag.mp4");
|
||||
|
||||
binding->RunTestAndWait([binding]() {
|
||||
|
@ -580,8 +575,7 @@ TEST(MP4Demuxer, GetNextKeyframe)
|
|||
});
|
||||
}
|
||||
|
||||
TEST(MP4Demuxer, ZeroInLastMoov)
|
||||
{
|
||||
TEST(MP4Demuxer, ZeroInLastMoov) {
|
||||
RefPtr<MP4DemuxerBinding> binding =
|
||||
new MP4DemuxerBinding("short-zero-in-moov.mp4");
|
||||
binding->RunTestAndWait([binding]() {
|
||||
|
@ -590,8 +584,7 @@ TEST(MP4Demuxer, ZeroInLastMoov)
|
|||
});
|
||||
}
|
||||
|
||||
TEST(MP4Demuxer, ZeroInMoovQuickTime)
|
||||
{
|
||||
TEST(MP4Demuxer, ZeroInMoovQuickTime) {
|
||||
RefPtr<MP4DemuxerBinding> binding =
|
||||
new MP4DemuxerBinding("short-zero-inband.mov");
|
||||
binding->RunTestAndWait([binding]() {
|
||||
|
@ -600,8 +593,7 @@ TEST(MP4Demuxer, ZeroInMoovQuickTime)
|
|||
});
|
||||
}
|
||||
|
||||
TEST(MP4Demuxer, IgnoreMinus1Duration)
|
||||
{
|
||||
TEST(MP4Demuxer, IgnoreMinus1Duration) {
|
||||
RefPtr<MP4DemuxerBinding> binding =
|
||||
new MP4DemuxerBinding("negative_duration.mp4");
|
||||
binding->RunTestAndWait([binding]() {
|
||||
|
|
|
@ -44,8 +44,7 @@ class BenchmarkRunner {
|
|||
RefPtr<Benchmark> mBenchmark;
|
||||
};
|
||||
|
||||
TEST(MediaDataDecoder, H264)
|
||||
{
|
||||
TEST(MediaDataDecoder, H264) {
|
||||
if (!DecoderTraits::IsMP4SupportedType(
|
||||
MediaContainerType(MEDIAMIMETYPE(VIDEO_MP4)),
|
||||
/* DecoderDoctorDiagnostics* */ nullptr)) {
|
||||
|
@ -60,8 +59,7 @@ TEST(MediaDataDecoder, H264)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(MediaDataDecoder, VP9)
|
||||
{
|
||||
TEST(MediaDataDecoder, VP9) {
|
||||
if (!WebMDecoder::IsSupportedType(
|
||||
MediaContainerType(MEDIAMIMETYPE(VIDEO_WEBM)))) {
|
||||
EXPECT_TRUE(true);
|
||||
|
|
|
@ -85,16 +85,15 @@ void WaitForShutdown(RefPtr<MediaDataEncoder> aEncoder) {
|
|||
Maybe<bool> result;
|
||||
// media::Await() supports exclusive promises only, but ShutdownPromise is
|
||||
// not.
|
||||
aEncoder->Shutdown()->Then(
|
||||
AbstractThread::MainThread(), __func__,
|
||||
[&result](bool rv) {
|
||||
EXPECT_TRUE(rv);
|
||||
result = Some(true);
|
||||
},
|
||||
[&result]() {
|
||||
FAIL() << "Shutdown should never be rejected";
|
||||
result = Some(false);
|
||||
});
|
||||
aEncoder->Shutdown()->Then(AbstractThread::MainThread(), __func__,
|
||||
[&result](bool rv) {
|
||||
EXPECT_TRUE(rv);
|
||||
result = Some(true);
|
||||
},
|
||||
[&result]() {
|
||||
FAIL() << "Shutdown should never be rejected";
|
||||
result = Some(false);
|
||||
});
|
||||
SpinEventLoopUntil([&result]() { return result; });
|
||||
}
|
||||
|
||||
|
@ -116,13 +115,12 @@ static bool EnsureInit(RefPtr<MediaDataEncoder> aEncoder) {
|
|||
}
|
||||
|
||||
bool succeeded;
|
||||
media::Await(
|
||||
GetMediaThreadPool(MediaThreadType::PLAYBACK), aEncoder->Init(),
|
||||
[&succeeded](TrackInfo::TrackType t) {
|
||||
EXPECT_EQ(TrackInfo::TrackType::kVideoTrack, t);
|
||||
succeeded = true;
|
||||
},
|
||||
[&succeeded](MediaResult r) { succeeded = false; });
|
||||
media::Await(GetMediaThreadPool(MediaThreadType::PLAYBACK), aEncoder->Init(),
|
||||
[&succeeded](TrackInfo::TrackType t) {
|
||||
EXPECT_EQ(TrackInfo::TrackType::kVideoTrack, t);
|
||||
succeeded = true;
|
||||
},
|
||||
[&succeeded](MediaResult r) { succeeded = false; });
|
||||
return succeeded;
|
||||
}
|
||||
|
||||
|
@ -151,13 +149,13 @@ static MediaDataEncoder::EncodedData Encode(
|
|||
kImageSize, 0, TimeUnit::FromMicroseconds(i * 30000),
|
||||
TimeUnit::FromMicroseconds(30000), img, (i & 0xF) == 0,
|
||||
TimeUnit::FromMicroseconds(i * 30000));
|
||||
media::Await(
|
||||
GetMediaThreadPool(MediaThreadType::PLAYBACK), aEncoder->Encode(frame),
|
||||
[&output, &succeeded](MediaDataEncoder::EncodedData encoded) {
|
||||
output.AppendElements(std::move(encoded));
|
||||
succeeded = true;
|
||||
},
|
||||
[&succeeded](MediaResult r) { succeeded = false; });
|
||||
media::Await(GetMediaThreadPool(MediaThreadType::PLAYBACK),
|
||||
aEncoder->Encode(frame),
|
||||
[&output, &succeeded](MediaDataEncoder::EncodedData encoded) {
|
||||
output.AppendElements(std::move(encoded));
|
||||
succeeded = true;
|
||||
},
|
||||
[&succeeded](MediaResult r) { succeeded = false; });
|
||||
EXPECT_TRUE(succeeded);
|
||||
if (!succeeded) {
|
||||
return output;
|
||||
|
@ -179,13 +177,13 @@ static MediaDataEncoder::EncodedData Encode(
|
|||
}
|
||||
|
||||
if (pending > 0) {
|
||||
media::Await(
|
||||
GetMediaThreadPool(MediaThreadType::PLAYBACK), aEncoder->Drain(),
|
||||
[&succeeded](MediaDataEncoder::EncodedData encoded) {
|
||||
EXPECT_EQ(encoded.Length(), 0UL);
|
||||
succeeded = true;
|
||||
},
|
||||
[&succeeded](MediaResult r) { succeeded = false; });
|
||||
media::Await(GetMediaThreadPool(MediaThreadType::PLAYBACK),
|
||||
aEncoder->Drain(),
|
||||
[&succeeded](MediaDataEncoder::EncodedData encoded) {
|
||||
EXPECT_EQ(encoded.Length(), 0UL);
|
||||
succeeded = true;
|
||||
},
|
||||
[&succeeded](MediaResult r) { succeeded = false; });
|
||||
EXPECT_TRUE(succeeded);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,8 +16,7 @@ using namespace mozilla;
|
|||
/*
|
||||
* Test if listeners receive the event data correctly.
|
||||
*/
|
||||
TEST(MediaEventSource, SingleListener)
|
||||
{
|
||||
TEST(MediaEventSource, SingleListener) {
|
||||
RefPtr<TaskQueue> queue =
|
||||
new TaskQueue(GetMediaThreadPool(MediaThreadType::PLAYBACK));
|
||||
|
||||
|
@ -40,8 +39,7 @@ TEST(MediaEventSource, SingleListener)
|
|||
listener.Disconnect();
|
||||
}
|
||||
|
||||
TEST(MediaEventSource, MultiListener)
|
||||
{
|
||||
TEST(MediaEventSource, MultiListener) {
|
||||
RefPtr<TaskQueue> queue =
|
||||
new TaskQueue(GetMediaThreadPool(MediaThreadType::PLAYBACK));
|
||||
|
||||
|
@ -71,8 +69,7 @@ TEST(MediaEventSource, MultiListener)
|
|||
/*
|
||||
* Test if disconnecting a listener prevents events from coming.
|
||||
*/
|
||||
TEST(MediaEventSource, DisconnectAfterNotification)
|
||||
{
|
||||
TEST(MediaEventSource, DisconnectAfterNotification) {
|
||||
RefPtr<TaskQueue> queue =
|
||||
new TaskQueue(GetMediaThreadPool(MediaThreadType::PLAYBACK));
|
||||
|
||||
|
@ -98,8 +95,7 @@ TEST(MediaEventSource, DisconnectAfterNotification)
|
|||
EXPECT_EQ(i, 11);
|
||||
}
|
||||
|
||||
TEST(MediaEventSource, DisconnectBeforeNotification)
|
||||
{
|
||||
TEST(MediaEventSource, DisconnectBeforeNotification) {
|
||||
RefPtr<TaskQueue> queue =
|
||||
new TaskQueue(GetMediaThreadPool(MediaThreadType::PLAYBACK));
|
||||
|
||||
|
@ -130,8 +126,7 @@ TEST(MediaEventSource, DisconnectBeforeNotification)
|
|||
* Test we don't hit the assertion when calling Connect() and Disconnect()
|
||||
* repeatedly.
|
||||
*/
|
||||
TEST(MediaEventSource, DisconnectAndConnect)
|
||||
{
|
||||
TEST(MediaEventSource, DisconnectAndConnect) {
|
||||
RefPtr<TaskQueue> queue;
|
||||
MediaEventProducerExc<int> source;
|
||||
MediaEventListener listener = source.Connect(queue, []() {});
|
||||
|
@ -143,8 +138,7 @@ TEST(MediaEventSource, DisconnectAndConnect)
|
|||
/*
|
||||
* Test void event type.
|
||||
*/
|
||||
TEST(MediaEventSource, VoidEventType)
|
||||
{
|
||||
TEST(MediaEventSource, VoidEventType) {
|
||||
RefPtr<TaskQueue> queue =
|
||||
new TaskQueue(GetMediaThreadPool(MediaThreadType::PLAYBACK));
|
||||
|
||||
|
@ -180,8 +174,7 @@ TEST(MediaEventSource, VoidEventType)
|
|||
/*
|
||||
* Test listeners can take various event types (T, T&&, const T& and void).
|
||||
*/
|
||||
TEST(MediaEventSource, ListenerType1)
|
||||
{
|
||||
TEST(MediaEventSource, ListenerType1) {
|
||||
RefPtr<TaskQueue> queue =
|
||||
new TaskQueue(GetMediaThreadPool(MediaThreadType::PLAYBACK));
|
||||
|
||||
|
@ -208,8 +201,7 @@ TEST(MediaEventSource, ListenerType1)
|
|||
listener3.Disconnect();
|
||||
}
|
||||
|
||||
TEST(MediaEventSource, ListenerType2)
|
||||
{
|
||||
TEST(MediaEventSource, ListenerType2) {
|
||||
RefPtr<TaskQueue> queue =
|
||||
new TaskQueue(GetMediaThreadPool(MediaThreadType::PLAYBACK));
|
||||
|
||||
|
@ -258,8 +250,7 @@ struct SomeEvent {
|
|||
/*
|
||||
* Test we don't have unnecessary copies of the event data.
|
||||
*/
|
||||
TEST(MediaEventSource, CopyEvent1)
|
||||
{
|
||||
TEST(MediaEventSource, CopyEvent1) {
|
||||
RefPtr<TaskQueue> queue =
|
||||
new TaskQueue(GetMediaThreadPool(MediaThreadType::PLAYBACK));
|
||||
|
||||
|
@ -285,8 +276,7 @@ TEST(MediaEventSource, CopyEvent1)
|
|||
listener2.Disconnect();
|
||||
}
|
||||
|
||||
TEST(MediaEventSource, CopyEvent2)
|
||||
{
|
||||
TEST(MediaEventSource, CopyEvent2) {
|
||||
RefPtr<TaskQueue> queue =
|
||||
new TaskQueue(GetMediaThreadPool(MediaThreadType::PLAYBACK));
|
||||
|
||||
|
@ -314,8 +304,7 @@ TEST(MediaEventSource, CopyEvent2)
|
|||
/*
|
||||
* Test move-only types.
|
||||
*/
|
||||
TEST(MediaEventSource, MoveOnly)
|
||||
{
|
||||
TEST(MediaEventSource, MoveOnly) {
|
||||
RefPtr<TaskQueue> queue =
|
||||
new TaskQueue(GetMediaThreadPool(MediaThreadType::PLAYBACK));
|
||||
|
||||
|
@ -348,8 +337,7 @@ struct RefCounter {
|
|||
* Test we should copy instead of move in NonExclusive mode
|
||||
* for each listener must get a copy.
|
||||
*/
|
||||
TEST(MediaEventSource, NoMove)
|
||||
{
|
||||
TEST(MediaEventSource, NoMove) {
|
||||
RefPtr<TaskQueue> queue =
|
||||
new TaskQueue(GetMediaThreadPool(MediaThreadType::PLAYBACK));
|
||||
|
||||
|
@ -373,8 +361,7 @@ TEST(MediaEventSource, NoMove)
|
|||
/*
|
||||
* Rvalue lambda should be moved instead of copied.
|
||||
*/
|
||||
TEST(MediaEventSource, MoveLambda)
|
||||
{
|
||||
TEST(MediaEventSource, MoveLambda) {
|
||||
RefPtr<TaskQueue> queue;
|
||||
MediaEventProducer<void> source;
|
||||
|
||||
|
|
|
@ -9,8 +9,7 @@
|
|||
|
||||
using namespace mozilla;
|
||||
|
||||
TEST(MediaMIMETypes, DependentMIMEType)
|
||||
{
|
||||
TEST(MediaMIMETypes, DependentMIMEType) {
|
||||
static const struct {
|
||||
const char* mString;
|
||||
DependentMediaMIMEType mDependentMediaMIMEType;
|
||||
|
@ -28,8 +27,7 @@ TEST(MediaMIMETypes, DependentMIMEType)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(MediaMIMETypes, MakeMediaMIMEType_bad)
|
||||
{
|
||||
TEST(MediaMIMETypes, MakeMediaMIMEType_bad) {
|
||||
static const char* tests[] = {"", " ", "/", "audio",
|
||||
"audio/", "mp4", "/mp4", "a/b"};
|
||||
|
||||
|
@ -40,8 +38,7 @@ TEST(MediaMIMETypes, MakeMediaMIMEType_bad)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(MediaMIMETypes, MediaMIMEType)
|
||||
{
|
||||
TEST(MediaMIMETypes, MediaMIMEType) {
|
||||
static const struct {
|
||||
const char* mTypeString;
|
||||
const char* mAsString;
|
||||
|
@ -81,8 +78,7 @@ TEST(MediaMIMETypes, MediaMIMEType)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(MediaMIMETypes, MediaCodecs)
|
||||
{
|
||||
TEST(MediaMIMETypes, MediaCodecs) {
|
||||
MediaCodecs empty("");
|
||||
EXPECT_TRUE(empty.IsEmpty());
|
||||
EXPECT_TRUE(empty.AsString().EqualsLiteral(""));
|
||||
|
@ -156,8 +152,7 @@ TEST(MediaMIMETypes, MediaCodecs)
|
|||
EXPECT_FALSE(one.ContainsAll(two));
|
||||
}
|
||||
|
||||
TEST(MediaMIMETypes, MakeMediaExtendedMIMEType_bad)
|
||||
{
|
||||
TEST(MediaMIMETypes, MakeMediaExtendedMIMEType_bad) {
|
||||
static const char* tests[] = {"", " ", "/", "audio",
|
||||
"audio/", "mp4", "/mp4", "a/b"};
|
||||
|
||||
|
@ -168,8 +163,7 @@ TEST(MediaMIMETypes, MakeMediaExtendedMIMEType_bad)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(MediaMIMETypes, MediaExtendedMIMEType)
|
||||
{
|
||||
TEST(MediaMIMETypes, MediaExtendedMIMEType) {
|
||||
// Some generic tests first.
|
||||
static const struct {
|
||||
const char* mTypeString;
|
||||
|
|
|
@ -7,8 +7,7 @@
|
|||
#include "OpusParser.h"
|
||||
#include <algorithm>
|
||||
|
||||
TEST(OpusParser, Mapping2)
|
||||
{
|
||||
TEST(OpusParser, Mapping2) {
|
||||
uint8_t validChannels[] = {1, 3, 4, 6, 9, 11, 16, 18, 25, 27,
|
||||
36, 38, 49, 51, 64, 66, 81, 83, 100, 102,
|
||||
121, 123, 144, 146, 169, 171, 196, 198, 225, 227};
|
||||
|
|
|
@ -3,8 +3,7 @@
|
|||
|
||||
extern "C" uint8_t* test_rust();
|
||||
|
||||
TEST(rust, CallFromCpp)
|
||||
{
|
||||
TEST(rust, CallFromCpp) {
|
||||
auto greeting = test_rust();
|
||||
EXPECT_STREQ(reinterpret_cast<char*>(greeting), "hello from rust.");
|
||||
}
|
||||
|
|
|
@ -10,8 +10,7 @@
|
|||
|
||||
using namespace mozilla;
|
||||
|
||||
TEST(TimeUnit, Rounding)
|
||||
{
|
||||
TEST(TimeUnit, Rounding) {
|
||||
int64_t usecs = 66261715;
|
||||
double seconds = media::TimeUnit::FromMicroseconds(usecs).ToSeconds();
|
||||
EXPECT_EQ(media::TimeUnit::FromSeconds(seconds).ToMicroseconds(), usecs);
|
||||
|
|
|
@ -69,8 +69,7 @@ static const TestFileData testFiles[] = {
|
|||
{"test_case_1224363.vp8.ivf", VPX_CODEC_CORRUPT_FRAME},
|
||||
{"test_case_1224369.vp8.ivf", VPX_CODEC_CORRUPT_FRAME}};
|
||||
|
||||
TEST(libvpx, test_cases)
|
||||
{
|
||||
TEST(libvpx, test_cases) {
|
||||
for (size_t test = 0; test < ArrayLength(testFiles); ++test) {
|
||||
nsTArray<uint8_t> data;
|
||||
ReadVPXFile(testFiles[test].mFilename, data);
|
||||
|
|
|
@ -13,8 +13,7 @@ class Image;
|
|||
} // namespace layer
|
||||
} // namespace mozilla
|
||||
|
||||
TEST(VideoSegment, TestAppendFrameForceBlack)
|
||||
{
|
||||
TEST(VideoSegment, TestAppendFrameForceBlack) {
|
||||
RefPtr<layers::Image> testImage = nullptr;
|
||||
|
||||
VideoSegment segment;
|
||||
|
@ -29,8 +28,7 @@ TEST(VideoSegment, TestAppendFrameForceBlack)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(VideoSegment, TestAppendFrameNotForceBlack)
|
||||
{
|
||||
TEST(VideoSegment, TestAppendFrameNotForceBlack) {
|
||||
RefPtr<layers::Image> testImage = nullptr;
|
||||
|
||||
VideoSegment segment;
|
||||
|
|
|
@ -69,8 +69,7 @@ class TestVP8TrackEncoder : public VP8TrackEncoder {
|
|||
};
|
||||
|
||||
// Init test
|
||||
TEST(VP8VideoTrackEncoder, Initialization)
|
||||
{
|
||||
TEST(VP8VideoTrackEncoder, Initialization) {
|
||||
InitParam params[] = {
|
||||
// Failure cases.
|
||||
{false, 0, 0}, // Height/ width should be larger than 1.
|
||||
|
@ -91,8 +90,7 @@ TEST(VP8VideoTrackEncoder, Initialization)
|
|||
}
|
||||
|
||||
// Get MetaData test
|
||||
TEST(VP8VideoTrackEncoder, FetchMetaData)
|
||||
{
|
||||
TEST(VP8VideoTrackEncoder, FetchMetaData) {
|
||||
InitParam params[] = {
|
||||
// Success cases
|
||||
{true, 640, 480}, // Standard VGA
|
||||
|
@ -115,8 +113,7 @@ TEST(VP8VideoTrackEncoder, FetchMetaData)
|
|||
}
|
||||
|
||||
// Encode test
|
||||
TEST(VP8VideoTrackEncoder, FrameEncode)
|
||||
{
|
||||
TEST(VP8VideoTrackEncoder, FrameEncode) {
|
||||
TestVP8TrackEncoder encoder;
|
||||
TimeStamp now = TimeStamp::Now();
|
||||
|
||||
|
@ -148,8 +145,7 @@ TEST(VP8VideoTrackEncoder, FrameEncode)
|
|||
}
|
||||
|
||||
// Test that encoding a single frame gives useful output.
|
||||
TEST(VP8VideoTrackEncoder, SingleFrameEncode)
|
||||
{
|
||||
TEST(VP8VideoTrackEncoder, SingleFrameEncode) {
|
||||
TestVP8TrackEncoder encoder;
|
||||
TimeStamp now = TimeStamp::Now();
|
||||
YUVBufferGenerator generator;
|
||||
|
@ -183,8 +179,7 @@ TEST(VP8VideoTrackEncoder, SingleFrameEncode)
|
|||
}
|
||||
|
||||
// Test that encoding a couple of identical images gives useful output.
|
||||
TEST(VP8VideoTrackEncoder, SameFrameEncode)
|
||||
{
|
||||
TEST(VP8VideoTrackEncoder, SameFrameEncode) {
|
||||
TestVP8TrackEncoder encoder;
|
||||
TimeStamp now = TimeStamp::Now();
|
||||
YUVBufferGenerator generator;
|
||||
|
@ -219,8 +214,7 @@ TEST(VP8VideoTrackEncoder, SameFrameEncode)
|
|||
}
|
||||
|
||||
// Test encoding a track that has to skip frames.
|
||||
TEST(VP8VideoTrackEncoder, SkippedFrames)
|
||||
{
|
||||
TEST(VP8VideoTrackEncoder, SkippedFrames) {
|
||||
TestVP8TrackEncoder encoder;
|
||||
YUVBufferGenerator generator;
|
||||
generator.Init(mozilla::gfx::IntSize(640, 480));
|
||||
|
@ -255,8 +249,7 @@ TEST(VP8VideoTrackEncoder, SkippedFrames)
|
|||
}
|
||||
|
||||
// Test encoding a track with frames subject to rounding errors.
|
||||
TEST(VP8VideoTrackEncoder, RoundingErrorFramesEncode)
|
||||
{
|
||||
TEST(VP8VideoTrackEncoder, RoundingErrorFramesEncode) {
|
||||
TestVP8TrackEncoder encoder;
|
||||
YUVBufferGenerator generator;
|
||||
generator.Init(mozilla::gfx::IntSize(640, 480));
|
||||
|
@ -297,8 +290,7 @@ TEST(VP8VideoTrackEncoder, RoundingErrorFramesEncode)
|
|||
}
|
||||
|
||||
// Test that we're encoding timestamps rather than durations.
|
||||
TEST(VP8VideoTrackEncoder, TimestampFrameEncode)
|
||||
{
|
||||
TEST(VP8VideoTrackEncoder, TimestampFrameEncode) {
|
||||
TestVP8TrackEncoder encoder;
|
||||
YUVBufferGenerator generator;
|
||||
generator.Init(mozilla::gfx::IntSize(640, 480));
|
||||
|
@ -340,8 +332,7 @@ TEST(VP8VideoTrackEncoder, TimestampFrameEncode)
|
|||
}
|
||||
|
||||
// Test that we're compensating for drift when encoding.
|
||||
TEST(VP8VideoTrackEncoder, DriftingFrameEncode)
|
||||
{
|
||||
TEST(VP8VideoTrackEncoder, DriftingFrameEncode) {
|
||||
TestVP8TrackEncoder encoder;
|
||||
YUVBufferGenerator generator;
|
||||
generator.Init(mozilla::gfx::IntSize(640, 480));
|
||||
|
@ -389,8 +380,7 @@ TEST(VP8VideoTrackEncoder, DriftingFrameEncode)
|
|||
}
|
||||
|
||||
// Test that suspending an encoding works.
|
||||
TEST(VP8VideoTrackEncoder, Suspended)
|
||||
{
|
||||
TEST(VP8VideoTrackEncoder, Suspended) {
|
||||
TestVP8TrackEncoder encoder;
|
||||
TimeStamp now = TimeStamp::Now();
|
||||
YUVBufferGenerator generator;
|
||||
|
@ -451,8 +441,7 @@ TEST(VP8VideoTrackEncoder, Suspended)
|
|||
}
|
||||
|
||||
// Test that ending a track while the video track encoder is suspended works.
|
||||
TEST(VP8VideoTrackEncoder, SuspendedUntilEnd)
|
||||
{
|
||||
TEST(VP8VideoTrackEncoder, SuspendedUntilEnd) {
|
||||
TestVP8TrackEncoder encoder;
|
||||
YUVBufferGenerator generator;
|
||||
generator.Init(mozilla::gfx::IntSize(640, 480));
|
||||
|
@ -501,8 +490,7 @@ TEST(VP8VideoTrackEncoder, SuspendedUntilEnd)
|
|||
}
|
||||
|
||||
// Test that ending a track that was always suspended works.
|
||||
TEST(VP8VideoTrackEncoder, AlwaysSuspended)
|
||||
{
|
||||
TEST(VP8VideoTrackEncoder, AlwaysSuspended) {
|
||||
TestVP8TrackEncoder encoder;
|
||||
YUVBufferGenerator generator;
|
||||
generator.Init(mozilla::gfx::IntSize(640, 480));
|
||||
|
@ -533,8 +521,7 @@ TEST(VP8VideoTrackEncoder, AlwaysSuspended)
|
|||
}
|
||||
|
||||
// Test that encoding a track that is suspended in the beginning works.
|
||||
TEST(VP8VideoTrackEncoder, SuspendedBeginning)
|
||||
{
|
||||
TEST(VP8VideoTrackEncoder, SuspendedBeginning) {
|
||||
TestVP8TrackEncoder encoder;
|
||||
YUVBufferGenerator generator;
|
||||
generator.Init(mozilla::gfx::IntSize(640, 480));
|
||||
|
@ -585,8 +572,7 @@ TEST(VP8VideoTrackEncoder, SuspendedBeginning)
|
|||
|
||||
// Test that suspending and resuming in the middle of already pushed data
|
||||
// works.
|
||||
TEST(VP8VideoTrackEncoder, SuspendedOverlap)
|
||||
{
|
||||
TEST(VP8VideoTrackEncoder, SuspendedOverlap) {
|
||||
TestVP8TrackEncoder encoder;
|
||||
YUVBufferGenerator generator;
|
||||
generator.Init(mozilla::gfx::IntSize(640, 480));
|
||||
|
@ -634,8 +620,7 @@ TEST(VP8VideoTrackEncoder, SuspendedOverlap)
|
|||
}
|
||||
|
||||
// Test that ending a track in the middle of already pushed data works.
|
||||
TEST(VP8VideoTrackEncoder, PrematureEnding)
|
||||
{
|
||||
TEST(VP8VideoTrackEncoder, PrematureEnding) {
|
||||
TestVP8TrackEncoder encoder;
|
||||
YUVBufferGenerator generator;
|
||||
generator.Init(mozilla::gfx::IntSize(640, 480));
|
||||
|
@ -665,8 +650,7 @@ TEST(VP8VideoTrackEncoder, PrematureEnding)
|
|||
}
|
||||
|
||||
// Test that a track that starts at t > 0 works as expected.
|
||||
TEST(VP8VideoTrackEncoder, DelayedStart)
|
||||
{
|
||||
TEST(VP8VideoTrackEncoder, DelayedStart) {
|
||||
TestVP8TrackEncoder encoder;
|
||||
YUVBufferGenerator generator;
|
||||
generator.Init(mozilla::gfx::IntSize(640, 480));
|
||||
|
@ -698,8 +682,7 @@ TEST(VP8VideoTrackEncoder, DelayedStart)
|
|||
|
||||
// Test that a track that starts at t > 0 works as expected, when
|
||||
// SetStartOffset comes after AppendVideoSegment.
|
||||
TEST(VP8VideoTrackEncoder, DelayedStartOtherEventOrder)
|
||||
{
|
||||
TEST(VP8VideoTrackEncoder, DelayedStartOtherEventOrder) {
|
||||
TestVP8TrackEncoder encoder;
|
||||
YUVBufferGenerator generator;
|
||||
generator.Init(mozilla::gfx::IntSize(640, 480));
|
||||
|
@ -730,8 +713,7 @@ TEST(VP8VideoTrackEncoder, DelayedStartOtherEventOrder)
|
|||
}
|
||||
|
||||
// Test that a track that starts at t >>> 0 works as expected.
|
||||
TEST(VP8VideoTrackEncoder, VeryDelayedStart)
|
||||
{
|
||||
TEST(VP8VideoTrackEncoder, VeryDelayedStart) {
|
||||
TestVP8TrackEncoder encoder;
|
||||
YUVBufferGenerator generator;
|
||||
generator.Init(mozilla::gfx::IntSize(640, 480));
|
||||
|
@ -763,8 +745,7 @@ TEST(VP8VideoTrackEncoder, VeryDelayedStart)
|
|||
|
||||
// Test that a video frame that hangs around for a long time gets encoded every
|
||||
// second.
|
||||
TEST(VP8VideoTrackEncoder, LongFramesReEncoded)
|
||||
{
|
||||
TEST(VP8VideoTrackEncoder, LongFramesReEncoded) {
|
||||
TestVP8TrackEncoder encoder;
|
||||
YUVBufferGenerator generator;
|
||||
generator.Init(mozilla::gfx::IntSize(640, 480));
|
||||
|
@ -818,8 +799,7 @@ TEST(VP8VideoTrackEncoder, LongFramesReEncoded)
|
|||
|
||||
// Test that an encoding with a defined key frame interval encodes keyframes
|
||||
// as expected. Short here means shorter than the default (1s).
|
||||
TEST(VP8VideoTrackEncoder, ShortKeyFrameInterval)
|
||||
{
|
||||
TEST(VP8VideoTrackEncoder, ShortKeyFrameInterval) {
|
||||
TestVP8TrackEncoder encoder;
|
||||
YUVBufferGenerator generator;
|
||||
generator.Init(mozilla::gfx::IntSize(640, 480));
|
||||
|
@ -888,8 +868,7 @@ TEST(VP8VideoTrackEncoder, ShortKeyFrameInterval)
|
|||
|
||||
// Test that an encoding with a defined key frame interval encodes keyframes
|
||||
// as expected. Long here means longer than the default (1s).
|
||||
TEST(VP8VideoTrackEncoder, LongKeyFrameInterval)
|
||||
{
|
||||
TEST(VP8VideoTrackEncoder, LongKeyFrameInterval) {
|
||||
TestVP8TrackEncoder encoder;
|
||||
YUVBufferGenerator generator;
|
||||
generator.Init(mozilla::gfx::IntSize(640, 480));
|
||||
|
@ -958,8 +937,7 @@ TEST(VP8VideoTrackEncoder, LongKeyFrameInterval)
|
|||
|
||||
// Test that an encoding with no defined key frame interval encodes keyframes
|
||||
// as expected. Default interval should be 1000ms.
|
||||
TEST(VP8VideoTrackEncoder, DefaultKeyFrameInterval)
|
||||
{
|
||||
TEST(VP8VideoTrackEncoder, DefaultKeyFrameInterval) {
|
||||
TestVP8TrackEncoder encoder;
|
||||
YUVBufferGenerator generator;
|
||||
generator.Init(mozilla::gfx::IntSize(640, 480));
|
||||
|
@ -1026,8 +1004,7 @@ TEST(VP8VideoTrackEncoder, DefaultKeyFrameInterval)
|
|||
|
||||
// Test that an encoding where the key frame interval is updated dynamically
|
||||
// encodes keyframes as expected.
|
||||
TEST(VP8VideoTrackEncoder, DynamicKeyFrameIntervalChanges)
|
||||
{
|
||||
TEST(VP8VideoTrackEncoder, DynamicKeyFrameIntervalChanges) {
|
||||
TestVP8TrackEncoder encoder;
|
||||
YUVBufferGenerator generator;
|
||||
generator.Init(mozilla::gfx::IntSize(640, 480));
|
||||
|
@ -1196,8 +1173,7 @@ TEST(VP8VideoTrackEncoder, DynamicKeyFrameIntervalChanges)
|
|||
|
||||
// Test that an encoding which is disabled on a frame timestamp encodes
|
||||
// frames as expected.
|
||||
TEST(VP8VideoTrackEncoder, DisableOnFrameTime)
|
||||
{
|
||||
TEST(VP8VideoTrackEncoder, DisableOnFrameTime) {
|
||||
TestVP8TrackEncoder encoder;
|
||||
YUVBufferGenerator generator;
|
||||
generator.Init(mozilla::gfx::IntSize(640, 480));
|
||||
|
@ -1241,8 +1217,7 @@ TEST(VP8VideoTrackEncoder, DisableOnFrameTime)
|
|||
|
||||
// Test that an encoding which is disabled between two frame timestamps encodes
|
||||
// frames as expected.
|
||||
TEST(VP8VideoTrackEncoder, DisableBetweenFrames)
|
||||
{
|
||||
TEST(VP8VideoTrackEncoder, DisableBetweenFrames) {
|
||||
TestVP8TrackEncoder encoder;
|
||||
YUVBufferGenerator generator;
|
||||
generator.Init(mozilla::gfx::IntSize(640, 480));
|
||||
|
@ -1286,8 +1261,7 @@ TEST(VP8VideoTrackEncoder, DisableBetweenFrames)
|
|||
|
||||
// Test that an encoding which is enabled on a frame timestamp encodes
|
||||
// frames as expected.
|
||||
TEST(VP8VideoTrackEncoder, EnableOnFrameTime)
|
||||
{
|
||||
TEST(VP8VideoTrackEncoder, EnableOnFrameTime) {
|
||||
TestVP8TrackEncoder encoder;
|
||||
YUVBufferGenerator generator;
|
||||
generator.Init(mozilla::gfx::IntSize(640, 480));
|
||||
|
@ -1333,8 +1307,7 @@ TEST(VP8VideoTrackEncoder, EnableOnFrameTime)
|
|||
|
||||
// Test that an encoding which is enabled between two frame timestamps encodes
|
||||
// frames as expected.
|
||||
TEST(VP8VideoTrackEncoder, EnableBetweenFrames)
|
||||
{
|
||||
TEST(VP8VideoTrackEncoder, EnableBetweenFrames) {
|
||||
TestVP8TrackEncoder encoder;
|
||||
YUVBufferGenerator generator;
|
||||
generator.Init(mozilla::gfx::IntSize(640, 480));
|
||||
|
@ -1379,8 +1352,7 @@ TEST(VP8VideoTrackEncoder, EnableBetweenFrames)
|
|||
}
|
||||
|
||||
// Test that making time go backwards removes any future frames in the encoder.
|
||||
TEST(VP8VideoTrackEncoder, BackwardsTimeResets)
|
||||
{
|
||||
TEST(VP8VideoTrackEncoder, BackwardsTimeResets) {
|
||||
TestVP8TrackEncoder encoder;
|
||||
YUVBufferGenerator generator;
|
||||
generator.Init(mozilla::gfx::IntSize(640, 480));
|
||||
|
@ -1452,8 +1424,7 @@ TEST(VP8VideoTrackEncoder, BackwardsTimeResets)
|
|||
|
||||
// Test that trying to encode a null image removes any future frames in the
|
||||
// encoder.
|
||||
TEST(VP8VideoTrackEncoder, NullImageResets)
|
||||
{
|
||||
TEST(VP8VideoTrackEncoder, NullImageResets) {
|
||||
TestVP8TrackEncoder encoder;
|
||||
YUVBufferGenerator generator;
|
||||
generator.Init(mozilla::gfx::IntSize(640, 480));
|
||||
|
@ -1521,8 +1492,7 @@ TEST(VP8VideoTrackEncoder, NullImageResets)
|
|||
}
|
||||
|
||||
// EOS test
|
||||
TEST(VP8VideoTrackEncoder, EncodeComplete)
|
||||
{
|
||||
TEST(VP8VideoTrackEncoder, EncodeComplete) {
|
||||
TestVP8TrackEncoder encoder;
|
||||
|
||||
// track end notification.
|
||||
|
|
|
@ -10,8 +10,7 @@
|
|||
|
||||
using namespace mozilla;
|
||||
|
||||
TEST(MediaMIMETypes, IsMediaMIMEType)
|
||||
{
|
||||
TEST(MediaMIMETypes, IsMediaMIMEType) {
|
||||
EXPECT_TRUE(IsMediaMIMEType(AUDIO_MP4));
|
||||
EXPECT_TRUE(IsMediaMIMEType(VIDEO_MP4));
|
||||
EXPECT_TRUE(IsMediaMIMEType("application/x-mp4"));
|
||||
|
@ -26,8 +25,7 @@ TEST(MediaMIMETypes, IsMediaMIMEType)
|
|||
EXPECT_FALSE(IsMediaMIMEType("Video/mp4"));
|
||||
}
|
||||
|
||||
TEST(StringListRange, MakeStringListRange)
|
||||
{
|
||||
TEST(StringListRange, MakeStringListRange) {
|
||||
static const struct {
|
||||
const char* mList;
|
||||
const char* mExpectedSkipEmpties;
|
||||
|
@ -77,8 +75,7 @@ TEST(StringListRange, MakeStringListRange)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(StringListRange, StringListContains)
|
||||
{
|
||||
TEST(StringListRange, StringListContains) {
|
||||
static const struct {
|
||||
const char* mList;
|
||||
const char* mItemToSearch;
|
||||
|
|
|
@ -19,8 +19,7 @@ static const uint64_t gTimecodes[] = {66000000, 160000000, 166000000,
|
|||
200000000, 233000000, 320000000};
|
||||
static const int64_t gEndOffsets[] = {501, 772, 1244, 1380, 1543, 2015};
|
||||
|
||||
TEST(WebMBuffered, BasicTests)
|
||||
{
|
||||
TEST(WebMBuffered, BasicTests) {
|
||||
ReentrantMonitor dummy("dummy");
|
||||
WebMBufferedParser parser(0);
|
||||
|
||||
|
@ -58,8 +57,7 @@ static void ReadFile(const char* aPath, nsTArray<uint8_t>& aBuffer) {
|
|||
ASSERT_EQ(r, 0);
|
||||
}
|
||||
|
||||
TEST(WebMBuffered, RealData)
|
||||
{
|
||||
TEST(WebMBuffered, RealData) {
|
||||
ReentrantMonitor dummy("dummy");
|
||||
WebMBufferedParser parser(0);
|
||||
|
||||
|
@ -80,8 +78,7 @@ TEST(WebMBuffered, RealData)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(WebMBuffered, RealDataAppend)
|
||||
{
|
||||
TEST(WebMBuffered, RealDataAppend) {
|
||||
ReentrantMonitor dummy("dummy");
|
||||
WebMBufferedParser parser(0);
|
||||
nsTArray<WebMTimeDataOffset> mapping;
|
||||
|
|
|
@ -94,8 +94,7 @@ class TestWebMWriter : public WebMWriter {
|
|||
uint64_t mTimestamp;
|
||||
};
|
||||
|
||||
TEST(WebMWriter, Metadata)
|
||||
{
|
||||
TEST(WebMWriter, Metadata) {
|
||||
TestWebMWriter writer(ContainerWriter::CREATE_AUDIO_TRACK |
|
||||
ContainerWriter::CREATE_VIDEO_TRACK);
|
||||
|
||||
|
@ -130,8 +129,7 @@ TEST(WebMWriter, Metadata)
|
|||
EXPECT_TRUE(encodedBuf.Length() > 0);
|
||||
}
|
||||
|
||||
TEST(WebMWriter, Cluster)
|
||||
{
|
||||
TEST(WebMWriter, Cluster) {
|
||||
TestWebMWriter writer(ContainerWriter::CREATE_AUDIO_TRACK |
|
||||
ContainerWriter::CREATE_VIDEO_TRACK);
|
||||
// Set opus metadata.
|
||||
|
@ -172,8 +170,7 @@ TEST(WebMWriter, Cluster)
|
|||
EXPECT_TRUE(writer.HaveValidCluster());
|
||||
}
|
||||
|
||||
TEST(WebMWriter, FLUSH_NEEDED)
|
||||
{
|
||||
TEST(WebMWriter, FLUSH_NEEDED) {
|
||||
TestWebMWriter writer(ContainerWriter::CREATE_AUDIO_TRACK |
|
||||
ContainerWriter::CREATE_VIDEO_TRACK);
|
||||
// Set opus metadata.
|
||||
|
@ -292,8 +289,7 @@ static int64_t webm_tell(void* aUserData) {
|
|||
return ioData->offset.isValid() ? ioData->offset.value() : -1;
|
||||
}
|
||||
|
||||
TEST(WebMWriter, bug970774_aspect_ratio)
|
||||
{
|
||||
TEST(WebMWriter, bug970774_aspect_ratio) {
|
||||
TestWebMWriter writer(ContainerWriter::CREATE_AUDIO_TRACK |
|
||||
ContainerWriter::CREATE_VIDEO_TRACK);
|
||||
// Set opus metadata.
|
||||
|
|
|
@ -8,14 +8,12 @@
|
|||
|
||||
using mozilla::MP4Interval;
|
||||
|
||||
TEST(MP4Interval, Length)
|
||||
{
|
||||
TEST(MP4Interval, Length) {
|
||||
MP4Interval<int> i(15, 25);
|
||||
EXPECT_EQ(10, i.Length());
|
||||
}
|
||||
|
||||
TEST(MP4Interval, Intersection)
|
||||
{
|
||||
TEST(MP4Interval, Intersection) {
|
||||
MP4Interval<int> i0(10, 20);
|
||||
MP4Interval<int> i1(15, 25);
|
||||
MP4Interval<int> i = i0.Intersection(i1);
|
||||
|
@ -23,8 +21,7 @@ TEST(MP4Interval, Intersection)
|
|||
EXPECT_EQ(20, i.end);
|
||||
}
|
||||
|
||||
TEST(MP4Interval, Equals)
|
||||
{
|
||||
TEST(MP4Interval, Equals) {
|
||||
MP4Interval<int> i0(10, 20);
|
||||
MP4Interval<int> i1(10, 20);
|
||||
EXPECT_EQ(i0, i1);
|
||||
|
@ -36,8 +33,7 @@ TEST(MP4Interval, Equals)
|
|||
EXPECT_NE(i0, i2);
|
||||
}
|
||||
|
||||
TEST(MP4Interval, IntersectionVector)
|
||||
{
|
||||
TEST(MP4Interval, IntersectionVector) {
|
||||
nsTArray<MP4Interval<int>> i0;
|
||||
i0.AppendElement(MP4Interval<int>(5, 10));
|
||||
i0.AppendElement(MP4Interval<int>(20, 25));
|
||||
|
@ -67,8 +63,7 @@ TEST(MP4Interval, IntersectionVector)
|
|||
EXPECT_EQ(57, i[3].end);
|
||||
}
|
||||
|
||||
TEST(MP4Interval, Normalize)
|
||||
{
|
||||
TEST(MP4Interval, Normalize) {
|
||||
nsTArray<MP4Interval<int>> i;
|
||||
i.AppendElement(MP4Interval<int>(20, 30));
|
||||
i.AppendElement(MP4Interval<int>(1, 8));
|
||||
|
|
|
@ -51,8 +51,7 @@ static intptr_t vector_reader(uint8_t* buffer, uintptr_t size, void* userdata) {
|
|||
return length;
|
||||
}
|
||||
|
||||
TEST(rust, MP4MetadataEmpty)
|
||||
{
|
||||
TEST(rust, MP4MetadataEmpty) {
|
||||
Mp4parseStatus rv;
|
||||
Mp4parseIo io;
|
||||
|
||||
|
@ -106,8 +105,7 @@ TEST(rust, MP4MetadataEmpty)
|
|||
mp4parse_free(context);
|
||||
}
|
||||
|
||||
TEST(rust, MP4Metadata)
|
||||
{
|
||||
TEST(rust, MP4Metadata) {
|
||||
FILE* f = fopen("street.mp4", "rb");
|
||||
ASSERT_TRUE(f != nullptr);
|
||||
// Read just the moov header to work around the parser
|
||||
|
|
|
@ -68,8 +68,7 @@ class TestStream : public ByteStream,
|
|||
size_t mSize;
|
||||
};
|
||||
|
||||
TEST(MP4Metadata, EmptyStream)
|
||||
{
|
||||
TEST(MP4Metadata, EmptyStream) {
|
||||
RefPtr<ByteStream> stream = new TestStream(nullptr, 0);
|
||||
|
||||
MP4Metadata::ResultAndByteBuffer metadataBuffer =
|
||||
|
@ -95,8 +94,7 @@ TEST(MP4Metadata, EmptyStream)
|
|||
EXPECT_FALSE(metadata.Crypto().Ref()->valid);
|
||||
}
|
||||
|
||||
TEST(MoofParser, EmptyStream)
|
||||
{
|
||||
TEST(MoofParser, EmptyStream) {
|
||||
RefPtr<ByteStream> stream = new TestStream(nullptr, 0);
|
||||
|
||||
MoofParser parser(stream, AsVariant(ParseAllTracks{}), false);
|
||||
|
@ -250,8 +248,7 @@ static const TestFileData testFiles[] = {
|
|||
300, 1, 10032000, false, 0, true, true, 2}, // Uses bad track id 0
|
||||
};
|
||||
|
||||
TEST(MP4Metadata, test_case_mp4)
|
||||
{
|
||||
TEST(MP4Metadata, test_case_mp4) {
|
||||
const TestFileData* tests = nullptr;
|
||||
size_t length = 0;
|
||||
|
||||
|
@ -406,8 +403,7 @@ TEST(MP4Metadata, test_case_mp4_subsets) {
|
|||
}
|
||||
#endif
|
||||
|
||||
TEST(MoofParser, test_case_mp4)
|
||||
{
|
||||
TEST(MoofParser, test_case_mp4) {
|
||||
const TestFileData* tests = nullptr;
|
||||
size_t length = 0;
|
||||
|
||||
|
@ -452,8 +448,7 @@ TEST(MoofParser, test_case_mp4)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(MoofParser, test_case_sample_description_entries)
|
||||
{
|
||||
TEST(MoofParser, test_case_sample_description_entries) {
|
||||
const TestFileData* tests = testFiles;
|
||||
size_t length = ArrayLength(testFiles);
|
||||
|
||||
|
@ -500,8 +495,7 @@ TEST(MoofParser, test_case_sample_description_entries)
|
|||
// used id 0 to trigger special handling in the MoofParser to read multiple
|
||||
// track metadata, but since muxers use track id 0 in the wild, we want to
|
||||
// make sure they can't accidentally trigger such handling.
|
||||
TEST(MoofParser, test_case_track_id_0_does_not_read_multitracks)
|
||||
{
|
||||
TEST(MoofParser, test_case_track_id_0_does_not_read_multitracks) {
|
||||
const char* zeroTrackIdFileName =
|
||||
"test_case_1519617-video-has-track_id-0.mp4";
|
||||
nsTArray<uint8_t> buffer = ReadTestFile(zeroTrackIdFileName);
|
||||
|
@ -556,8 +550,7 @@ TEST(MoofParser, test_case_track_id_0_does_not_read_multitracks)
|
|||
// if its crypto member is valid. However, even on files where the pssh isn't
|
||||
// in the init segment, the MoofParser should still read the sinf, as in this
|
||||
// testcase.
|
||||
TEST(MoofParser, test_case_track_id_0_reads_crypto_metadata)
|
||||
{
|
||||
TEST(MoofParser, test_case_track_id_0_reads_crypto_metadata) {
|
||||
const char* zeroTrackIdFileName =
|
||||
"test_case_1519617-cenc-init-with-track_id-0.mp4";
|
||||
nsTArray<uint8_t> buffer = ReadTestFile(zeroTrackIdFileName);
|
||||
|
@ -614,8 +607,7 @@ TEST(MoofParser, test_case_track_id_0_reads_crypto_metadata)
|
|||
// should parse such fragmented media. In this test the metadata contains info
|
||||
// for track ids 1 and 2, but track 2's track fragment headers (traf) have been
|
||||
// over written with free space boxes (free).
|
||||
TEST(MoofParser, test_case_moofs_missing_trafs)
|
||||
{
|
||||
TEST(MoofParser, test_case_moofs_missing_trafs) {
|
||||
const char* noTrafsForTrack2MoofsFileName =
|
||||
"test_case_1519617-track2-trafs-removed.mp4";
|
||||
nsTArray<uint8_t> buffer = ReadTestFile(noTrafsForTrack2MoofsFileName);
|
||||
|
@ -758,8 +750,7 @@ uint8_t media_gtest_video_init_mp4[] = {
|
|||
|
||||
const uint32_t media_gtest_video_init_mp4_len = 745;
|
||||
|
||||
TEST(MP4Metadata, EmptyCTTS)
|
||||
{
|
||||
TEST(MP4Metadata, EmptyCTTS) {
|
||||
RefPtr<MediaByteBuffer> buffer =
|
||||
new MediaByteBuffer(media_gtest_video_init_mp4_len);
|
||||
buffer->AppendElements(media_gtest_video_init_mp4,
|
||||
|
@ -854,7 +845,7 @@ TEST_F(MP4MetadataTelemetryFixture, Telemetry) {
|
|||
"MEDIA_MP4_PARSE_SAMPLE_DESCRIPTION_ENTRIES_HAVE_MULTIPLE_CODECS",
|
||||
snapshot, &multipleCodecsHistogram);
|
||||
ASSERT_TRUE(multipleCodecsHistogram.isObject())
|
||||
<< "Multiple codecs histogram should exist!";
|
||||
<< "Multiple codecs histogram should exist!";
|
||||
|
||||
TelemetryTestHelpers::GetProperty(cx.GetJSContext(), "values",
|
||||
multipleCodecsHistogram, &values);
|
||||
|
@ -879,7 +870,7 @@ TEST_F(MP4MetadataTelemetryFixture, Telemetry) {
|
|||
"MEDIA_MP4_PARSE_SAMPLE_DESCRIPTION_ENTRIES_HAVE_MULTIPLE_CRYPTO",
|
||||
snapshot, &multipleCryptoHistogram);
|
||||
ASSERT_TRUE(multipleCryptoHistogram.isObject())
|
||||
<< "Multiple crypto histogram should exist!";
|
||||
<< "Multiple crypto histogram should exist!";
|
||||
|
||||
TelemetryTestHelpers::GetProperty(cx.GetJSContext(), "values",
|
||||
multipleCryptoHistogram, &values);
|
||||
|
@ -902,7 +893,7 @@ TEST_F(MP4MetadataTelemetryFixture, Telemetry) {
|
|||
cx.GetJSContext(), "MEDIA_MP4_PARSE_NUM_SAMPLE_DESCRIPTION_ENTRIES",
|
||||
snapshot, &numSamplesHistogram);
|
||||
ASSERT_TRUE(numSamplesHistogram.isObject())
|
||||
<< "Num sample description entries histogram should exist!";
|
||||
<< "Num sample description entries histogram should exist!";
|
||||
|
||||
TelemetryTestHelpers::GetProperty(cx.GetJSContext(), "values",
|
||||
numSamplesHistogram, &values);
|
||||
|
|
|
@ -41,22 +41,21 @@ void RemoteDecoderParent::Destroy() {
|
|||
mozilla::ipc::IPCResult RemoteDecoderParent::RecvInit() {
|
||||
MOZ_ASSERT(OnManagerThread());
|
||||
RefPtr<RemoteDecoderParent> self = this;
|
||||
mDecoder->Init()->Then(
|
||||
mManagerTaskQueue, __func__,
|
||||
[self](TrackInfo::TrackType aTrack) {
|
||||
MOZ_ASSERT(aTrack == TrackInfo::kAudioTrack ||
|
||||
aTrack == TrackInfo::kVideoTrack);
|
||||
if (self->mDecoder) {
|
||||
Unused << self->SendInitComplete(aTrack,
|
||||
self->mDecoder->GetDescriptionName(),
|
||||
self->mDecoder->NeedsConversion());
|
||||
}
|
||||
},
|
||||
[self](MediaResult aReason) {
|
||||
if (!self->mDestroyed) {
|
||||
Unused << self->SendInitFailed(aReason);
|
||||
}
|
||||
});
|
||||
mDecoder->Init()->Then(mManagerTaskQueue, __func__,
|
||||
[self](TrackInfo::TrackType aTrack) {
|
||||
MOZ_ASSERT(aTrack == TrackInfo::kAudioTrack ||
|
||||
aTrack == TrackInfo::kVideoTrack);
|
||||
if (self->mDecoder) {
|
||||
Unused << self->SendInitComplete(
|
||||
aTrack, self->mDecoder->GetDescriptionName(),
|
||||
self->mDecoder->NeedsConversion());
|
||||
}
|
||||
},
|
||||
[self](MediaResult aReason) {
|
||||
if (!self->mDestroyed) {
|
||||
Unused << self->SendInitFailed(aReason);
|
||||
}
|
||||
});
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
|
|
|
@ -44,19 +44,18 @@ RefPtr<MediaDataDecoder::InitPromise> RemoteMediaDataDecoder::Init() {
|
|||
RefPtr<RemoteMediaDataDecoder> self = this;
|
||||
return InvokeAsync(mAbstractManagerThread, __func__,
|
||||
[self]() { return self->mChild->Init(); })
|
||||
->Then(
|
||||
mAbstractManagerThread, __func__,
|
||||
[self, this](TrackType aTrack) {
|
||||
mDescription =
|
||||
mChild->GetDescriptionName() + NS_LITERAL_CSTRING(" (remote)");
|
||||
mIsHardwareAccelerated =
|
||||
mChild->IsHardwareAccelerated(mHardwareAcceleratedReason);
|
||||
mConversion = mChild->NeedsConversion();
|
||||
return InitPromise::CreateAndResolve(aTrack, __func__);
|
||||
},
|
||||
[self](const MediaResult& aError) {
|
||||
return InitPromise::CreateAndReject(aError, __func__);
|
||||
});
|
||||
->Then(mAbstractManagerThread, __func__,
|
||||
[self, this](TrackType aTrack) {
|
||||
mDescription = mChild->GetDescriptionName() +
|
||||
NS_LITERAL_CSTRING(" (remote)");
|
||||
mIsHardwareAccelerated =
|
||||
mChild->IsHardwareAccelerated(mHardwareAcceleratedReason);
|
||||
mConversion = mChild->NeedsConversion();
|
||||
return InitPromise::CreateAndResolve(aTrack, __func__);
|
||||
},
|
||||
[self](const MediaResult& aError) {
|
||||
return InitPromise::CreateAndReject(aError, __func__);
|
||||
});
|
||||
}
|
||||
|
||||
RefPtr<MediaDataDecoder::DecodePromise> RemoteMediaDataDecoder::Decode(
|
||||
|
|
|
@ -262,22 +262,21 @@ nsresult VideoSink::Start(const TimeUnit& aStartTime, const MediaInfo& aInfo) {
|
|||
RefPtr<EndedPromise> p = mAudioSink->OnEnded(TrackInfo::kVideoTrack);
|
||||
if (p) {
|
||||
RefPtr<VideoSink> self = this;
|
||||
p->Then(
|
||||
mOwnerThread, __func__,
|
||||
[self]() {
|
||||
self->mVideoSinkEndRequest.Complete();
|
||||
self->TryUpdateRenderedVideoFrames();
|
||||
// It is possible the video queue size is 0 and we have no
|
||||
// frames to render. However, we need to call
|
||||
// MaybeResolveEndPromise() to ensure mEndPromiseHolder is
|
||||
// resolved.
|
||||
self->MaybeResolveEndPromise();
|
||||
},
|
||||
[self]() {
|
||||
self->mVideoSinkEndRequest.Complete();
|
||||
self->TryUpdateRenderedVideoFrames();
|
||||
self->MaybeResolveEndPromise();
|
||||
})
|
||||
p->Then(mOwnerThread, __func__,
|
||||
[self]() {
|
||||
self->mVideoSinkEndRequest.Complete();
|
||||
self->TryUpdateRenderedVideoFrames();
|
||||
// It is possible the video queue size is 0 and we have no
|
||||
// frames to render. However, we need to call
|
||||
// MaybeResolveEndPromise() to ensure mEndPromiseHolder is
|
||||
// resolved.
|
||||
self->MaybeResolveEndPromise();
|
||||
},
|
||||
[self]() {
|
||||
self->mVideoSinkEndRequest.Complete();
|
||||
self->TryUpdateRenderedVideoFrames();
|
||||
self->MaybeResolveEndPromise();
|
||||
})
|
||||
->Track(mVideoSinkEndRequest);
|
||||
}
|
||||
|
||||
|
|
|
@ -328,13 +328,12 @@ void SourceBuffer::RangeRemoval(double aStart, double aEnd) {
|
|||
RefPtr<SourceBuffer> self = this;
|
||||
mTrackBuffersManager
|
||||
->RangeRemoval(TimeUnit::FromSeconds(aStart), TimeUnit::FromSeconds(aEnd))
|
||||
->Then(
|
||||
mAbstractMainThread, __func__,
|
||||
[self](bool) {
|
||||
self->mPendingRemoval.Complete();
|
||||
self->StopUpdating();
|
||||
},
|
||||
[]() { MOZ_ASSERT(false); })
|
||||
->Then(mAbstractMainThread, __func__,
|
||||
[self](bool) {
|
||||
self->mPendingRemoval.Complete();
|
||||
self->StopUpdating();
|
||||
},
|
||||
[]() { MOZ_ASSERT(false); })
|
||||
->Track(mPendingRemoval);
|
||||
}
|
||||
|
||||
|
|
|
@ -811,20 +811,19 @@ void TrackBuffersManager::SegmentParserLoop() {
|
|||
// run the coded frame processing algorithm.
|
||||
RefPtr<TrackBuffersManager> self = this;
|
||||
CodedFrameProcessing()
|
||||
->Then(
|
||||
TaskQueueFromTaskQueue(), __func__,
|
||||
[self](bool aNeedMoreData) {
|
||||
self->mProcessingRequest.Complete();
|
||||
if (aNeedMoreData) {
|
||||
self->NeedMoreData();
|
||||
} else {
|
||||
self->ScheduleSegmentParserLoop();
|
||||
}
|
||||
},
|
||||
[self](const MediaResult& aRejectValue) {
|
||||
self->mProcessingRequest.Complete();
|
||||
self->RejectAppend(aRejectValue, __func__);
|
||||
})
|
||||
->Then(TaskQueueFromTaskQueue(), __func__,
|
||||
[self](bool aNeedMoreData) {
|
||||
self->mProcessingRequest.Complete();
|
||||
if (aNeedMoreData) {
|
||||
self->NeedMoreData();
|
||||
} else {
|
||||
self->ScheduleSegmentParserLoop();
|
||||
}
|
||||
},
|
||||
[self](const MediaResult& aRejectValue) {
|
||||
self->mProcessingRequest.Complete();
|
||||
self->RejectAppend(aRejectValue, __func__);
|
||||
})
|
||||
->Track(mProcessingRequest);
|
||||
return;
|
||||
}
|
||||
|
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче