author | Sylvestre Ledru <sledru@mozilla.com> |
Fri, 14 Dec 2018 18:10:35 +0000 | |
changeset 450554 | 09c71a7cf75aeaf2963050e315276fb9a866fd62 |
parent 450553 | e5079e6a5c13fbec7b95ec31cf98866b82d44fb5 |
child 450555 | 039a7c0c18fb28371d0ee7b2b673b8dd605f24b7 |
push id | 35207 |
push user | aciure@mozilla.com |
push date | Sat, 15 Dec 2018 02:27:37 +0000 |
treeherder | mozilla-central@d8a944c012a7 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | Ehsan |
bugs | 1513205 |
milestone | 66.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/dom/base/test/gtest/TestContentUtils.cpp +++ b/dom/base/test/gtest/TestContentUtils.cpp @@ -6,35 +6,33 @@ #include "gtest/gtest.h" #include "jsapi.h" #include "nsContentUtils.h" #include "mozilla/CycleCollectedJSContext.h" #include "mozilla/dom/SimpleGlobalObject.h" -TEST(DOM_Base_ContentUtils, StringifyJSON_EmptyValue) -{ - JSObject* globalObject = - mozilla::dom::SimpleGlobalObject::Create(mozilla::dom::SimpleGlobalObject::GlobalType::BindingDetail); +TEST(DOM_Base_ContentUtils, StringifyJSON_EmptyValue) { + JSObject* globalObject = mozilla::dom::SimpleGlobalObject::Create( + mozilla::dom::SimpleGlobalObject::GlobalType::BindingDetail); mozilla::dom::AutoJSAPI jsAPI; ASSERT_TRUE(jsAPI.Init(globalObject)); JSContext* cx = jsAPI.cx(); nsAutoString serializedValue; JS::RootedValue jsValue(cx); ASSERT_TRUE(nsContentUtils::StringifyJSON(cx, &jsValue, serializedValue)); ASSERT_TRUE(serializedValue.EqualsLiteral("null")); } -TEST(DOM_Base_ContentUtils, StringifyJSON_Object) -{ - JSObject* globalObject = - mozilla::dom::SimpleGlobalObject::Create(mozilla::dom::SimpleGlobalObject::GlobalType::BindingDetail); +TEST(DOM_Base_ContentUtils, StringifyJSON_Object) { + JSObject* globalObject = mozilla::dom::SimpleGlobalObject::Create( + mozilla::dom::SimpleGlobalObject::GlobalType::BindingDetail); mozilla::dom::AutoJSAPI jsAPI; ASSERT_TRUE(jsAPI.Init(globalObject)); JSContext* cx = jsAPI.cx(); nsAutoString serializedValue; JS::RootedObject jsObj(cx, JS_NewPlainObject(cx)); JS::RootedString valueStr(cx, JS_NewStringCopyZ(cx, "Hello World!")); ASSERT_TRUE(JS_DefineProperty(cx, jsObj, "key1", valueStr, JSPROP_ENUMERATE));
--- a/dom/base/test/gtest/TestMimeType.cpp +++ b/dom/base/test/gtest/TestMimeType.cpp @@ -6,721 +6,669 @@ #include "gtest/gtest.h" #include "MimeType.h" #include "nsString.h" 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"; + 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"; + 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"; + 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"; + 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"; + 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"; + 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"; + 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"; + 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"; + 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"; + 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"; + 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"; + 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"; + 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"; + 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"; + 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"; + 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"; + 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"; + 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"; + 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"; + 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"; + ASSERT_FALSE(parsed) << "Non-latin1 media type #2"; } -TEST(MimeType, MultipleParameters) -{ - const auto in = NS_LITERAL_STRING("text/html;charset=gbk;no=1;charset_=gbk_;yes=2"); +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"; nsString out; parsed->Serialize(out); - ASSERT_TRUE(out.Equals(NS_LITERAL_STRING("text/html;charset=gbk;no=1;charset_=gbk_;yes=2"))) << - "Multiple parameters"; + ASSERT_TRUE(out.Equals( + NS_LITERAL_STRING("text/html;charset=gbk;no=1;charset_=gbk_;yes=2"))) + << "Multiple parameters"; } -TEST(MimeType, DuplicateParameter1) -{ - const auto in = NS_LITERAL_STRING("text/html;charset=gbk;charset=windows-1255"); +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"; nsString out; parsed->Serialize(out); - ASSERT_TRUE(out.Equals(NS_LITERAL_STRING("text/html;charset=gbk"))) << - "Duplicate parameter #1"; + ASSERT_TRUE(out.Equals(NS_LITERAL_STRING("text/html;charset=gbk"))) + << "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"; nsString out; parsed->Serialize(out); - ASSERT_TRUE(out.Equals(NS_LITERAL_STRING("text/html;charset=\"()\""))) << - "Duplicate parameter #2"; + ASSERT_TRUE(out.Equals(NS_LITERAL_STRING("text/html;charset=\"()\""))) + << "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"; nsCString out; parsed->Serialize(out); - ASSERT_TRUE(out.Equals(NS_LITERAL_CSTRING("text/html;charset=\"()\""))) << - "Duplicate parameter #2"; + ASSERT_TRUE(out.Equals(NS_LITERAL_CSTRING("text/html;charset=\"()\""))) + << "Duplicate parameter #2"; } #ifdef _MSC_VER #pragma warning(push) -#pragma warning(disable:4819) +#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"; nsString out; parsed->Serialize(out); - ASSERT_TRUE(out.Equals(NS_LITERAL_STRING("text/html;test=\"\x00FF\\\\\";charset=gbk"))) << - "Non-alphanumeric parameters are quoted"; + ASSERT_TRUE(out.Equals( + NS_LITERAL_STRING("text/html;test=\"\x00FF\\\\\";charset=gbk"))) + << "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"; nsAutoString out; parsed->Serialize(out); - ASSERT_TRUE(out.EqualsLiteral("text/html;charset=\" g\\\\\\\"bk\"")) << - "Parameter is quoted if has leading whitespace #1"; + ASSERT_TRUE(out.EqualsLiteral("text/html;charset=\" g\\\\\\\"bk\"")) + << "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"; nsAutoString out; parsed->Serialize(out); - ASSERT_TRUE(out.EqualsLiteral("text/html;charset=\" \\\"g\\\\bk\\\"\"")) << - "Parameter is quoted if has leading whitespace #2"; + ASSERT_TRUE(out.EqualsLiteral("text/html;charset=\" \\\"g\\\\bk\\\"\"")) + << "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"; nsAutoString out; parsed->Serialize(out); - ASSERT_TRUE(out.EqualsLiteral("text/html;charset=\"g \\\\b\\\"k\"")) << - "Parameter is quoted if has internal whitespace"; + ASSERT_TRUE(out.EqualsLiteral("text/html;charset=\"g \\\\b\\\"k\"")) + << "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"; nsAutoString out; parsed->Serialize(out); - ASSERT_TRUE(out.EqualsLiteral("x/x;test=\"\"")) << - "Improperly-quoted parameter is handled properly #1"; + ASSERT_TRUE(out.EqualsLiteral("x/x;test=\"\"")) + << "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"; nsAutoString out; parsed->Serialize(out); - ASSERT_TRUE(out.EqualsLiteral("x/x;test=\"\\\\\"")) << - "Improperly-quoted parameter is handled properly #2"; + ASSERT_TRUE(out.EqualsLiteral("x/x;test=\"\\\\\"")) + << "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"; nsAutoString out; parsed->Serialize(out); - ASSERT_TRUE(out.EqualsLiteral("x/x;x=x")) << - "Non latin-1 parameters are ignored"; + ASSERT_TRUE(out.EqualsLiteral("x/x;x=x")) + << "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"; nsAutoString out; parsed->Serialize(out); - ASSERT_TRUE(out.EqualsLiteral("text/html;charset=123")) << - "Parameter ignored if whitespace in name #1"; + ASSERT_TRUE(out.EqualsLiteral("text/html;charset=123")) + << "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"; nsAutoString out; parsed->Serialize(out); - ASSERT_TRUE(out.EqualsLiteral("text/html;charset=123")) << - "Parameter ignored if whitespace in name #2"; + ASSERT_TRUE(out.EqualsLiteral("text/html;charset=123")) + << "Parameter ignored if whitespace in name #2"; } -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 "); +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"; nsAutoString out; parsed->Serialize(out); - ASSERT_TRUE(out.EqualsLiteral("text/plain;charset=123")) << - "Whitespace appropriately ignored"; + ASSERT_TRUE(out.EqualsLiteral("text/plain;charset=123")) + << "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"; nsAutoString out; parsed->Serialize(out); - ASSERT_TRUE(out.EqualsLiteral("x/x")) << - "Whitespace-only parameter is ignored"; + ASSERT_TRUE(out.EqualsLiteral("x/x")) + << "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"; 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"; 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"; 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"; nsAutoString out; parsed->Serialize(out); - ASSERT_TRUE(out.EqualsLiteral("text/html;charset=gbk")) << - "Incomplete parameter is ignored #4"; + ASSERT_TRUE(out.EqualsLiteral("text/html;charset=gbk")) + << "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"; nsAutoString out; parsed->Serialize(out); - ASSERT_TRUE(out.EqualsLiteral("text/html;charset=gbk")) << - "Incomplete parameter is ignored #5"; + ASSERT_TRUE(out.EqualsLiteral("text/html;charset=gbk")) + << "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"; nsAutoString out; parsed->Serialize(out); - ASSERT_TRUE(out.EqualsLiteral("text/html;charset=gbk")) << - "Empty parameter ignored #1"; + ASSERT_TRUE(out.EqualsLiteral("text/html;charset=gbk")) + << "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"; nsAutoString out; parsed->Serialize(out); - ASSERT_TRUE(out.EqualsLiteral("text/html;charset=gbk")) << - "Empty parameter ignored #2"; + ASSERT_TRUE(out.EqualsLiteral("text/html;charset=gbk")) + << "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"; nsAutoString out; parsed->Serialize(out); - ASSERT_TRUE(out.EqualsLiteral("text/html;charset=gbk")) << - "Invalid parameter ignored #1"; + ASSERT_TRUE(out.EqualsLiteral("text/html;charset=gbk")) + << "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"; nsAutoString out; parsed->Serialize(out); - ASSERT_TRUE(out.EqualsLiteral("text/html;charset=gbk")) << - "Invalid parameter ignored #2"; + ASSERT_TRUE(out.EqualsLiteral("text/html;charset=gbk")) + << "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"; nsAutoString out; parsed->Serialize(out); - ASSERT_TRUE(out.EqualsLiteral("text/html;charset=GBK")) << - "Invalid parameter ignored #3"; + ASSERT_TRUE(out.EqualsLiteral("text/html;charset=GBK")) + << "Invalid parameter ignored #3"; } -TEST(MimeType, InvalidParameterIgnored4) -{ - const auto in = NS_LITERAL_STRING("text/html;charset=\"\u007F;charset=foo\";charset=GBK;charset="); +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"; nsAutoString out; parsed->Serialize(out); - ASSERT_TRUE(out.EqualsLiteral("text/html;charset=GBK")) << - "Invalid parameter ignored #4"; + ASSERT_TRUE(out.EqualsLiteral("text/html;charset=GBK")) + << "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"; nsAutoString out; parsed->Serialize(out); - ASSERT_TRUE(out.EqualsLiteral("text/html;charset='gbk'")) << - "Single quotes handled properly #1"; + ASSERT_TRUE(out.EqualsLiteral("text/html;charset='gbk'")) + << "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"; nsAutoString out; parsed->Serialize(out); - ASSERT_TRUE(out.EqualsLiteral("text/html;charset='gbk")) << - "Single quotes handled properly #2"; + ASSERT_TRUE(out.EqualsLiteral("text/html;charset='gbk")) + << "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"; nsAutoString out; parsed->Serialize(out); - ASSERT_TRUE(out.EqualsLiteral("text/html;charset=gbk'")) << - "Single quotes handled properly #3"; + ASSERT_TRUE(out.EqualsLiteral("text/html;charset=gbk'")) + << "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"; nsAutoString out; parsed->Serialize(out); - ASSERT_TRUE(out.EqualsLiteral("text/html;charset='")) << - "Single quotes handled properly #4"; + ASSERT_TRUE(out.EqualsLiteral("text/html;charset='")) + << "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"; nsAutoString out; parsed->Serialize(out); - ASSERT_TRUE(out.EqualsLiteral("text/html;charset='''")) << - "Single quotes handled properly #5"; + ASSERT_TRUE(out.EqualsLiteral("text/html;charset='''")) + << "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"; nsAutoString out; parsed->Serialize(out); - ASSERT_TRUE(out.EqualsLiteral("text/html;charset=gbk")) << - "Double quotes handled properly #1"; + ASSERT_TRUE(out.EqualsLiteral("text/html;charset=gbk")) + << "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"; nsAutoString out; parsed->Serialize(out); - ASSERT_TRUE(out.EqualsLiteral("text/html;charset=gbk")) << - "Double quotes handled properly #2"; + ASSERT_TRUE(out.EqualsLiteral("text/html;charset=gbk")) + << "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"; nsAutoString out; parsed->Serialize(out); - ASSERT_TRUE(out.EqualsLiteral("text/html;charset=\"gbk\\\"\"")) << - "Double quotes handled properly #3"; + ASSERT_TRUE(out.EqualsLiteral("text/html;charset=\"gbk\\\"\"")) + << "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"; nsAutoString out; parsed->Serialize(out); - ASSERT_TRUE(out.EqualsLiteral("text/html;charset=\" gbk\"")) << - "Double quotes handled properly #4"; + ASSERT_TRUE(out.EqualsLiteral("text/html;charset=\" gbk\"")) + << "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"; nsAutoString out; parsed->Serialize(out); - ASSERT_TRUE(out.EqualsLiteral("text/html;charset=\"gbk \"")) << - "Double quotes handled properly #5"; + ASSERT_TRUE(out.EqualsLiteral("text/html;charset=\"gbk \"")) + << "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"; nsAutoString out; parsed->Serialize(out); - ASSERT_TRUE(out.EqualsLiteral("text/html;charset=\" gbk\"")) << - "Double quotes handled properly #6"; + ASSERT_TRUE(out.EqualsLiteral("text/html;charset=\" gbk\"")) + << "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"; nsAutoString out; parsed->Serialize(out); - ASSERT_TRUE(out.EqualsLiteral("text/html;charset=gbk")) << - "Double quotes handled properly #7"; + ASSERT_TRUE(out.EqualsLiteral("text/html;charset=gbk")) + << "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"; nsAutoString out; parsed->Serialize(out); - ASSERT_TRUE(out.EqualsLiteral("text/html;charset=gbk")) << - "Double quotes handled properly #8"; + ASSERT_TRUE(out.EqualsLiteral("text/html;charset=gbk")) + << "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"; nsAutoString out; parsed->Serialize(out); - ASSERT_TRUE(out.EqualsLiteral("text/html;charset=\"\"")) << - "Double quotes handled properly #9"; + ASSERT_TRUE(out.EqualsLiteral("text/html;charset=\"\"")) + << "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"; nsAutoString out; parsed->Serialize(out); - ASSERT_TRUE(out.EqualsLiteral("text/html;charset=\";charset=GBK\"")) << - "Double quotes handled properly #10"; + ASSERT_TRUE(out.EqualsLiteral("text/html;charset=\";charset=GBK\"")) + << "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"; nsAutoString out; parsed->Serialize(out); - ASSERT_TRUE(out.EqualsLiteral("text/html;charset=\"{gbk}\"")) << - "Unexpected code points handled properly"; + ASSERT_TRUE(out.EqualsLiteral("text/html;charset=\"{gbk}\"")) + << "Unexpected code points handled properly"; } -TEST(MimeType, LongTypesSubtypesAccepted) -{ - const auto in = NS_LITERAL_STRING("0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789/0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"); +TEST(MimeType, LongTypesSubtypesAccepted) { + const auto in = NS_LITERAL_STRING( + "012345678901234567890123456789012345678901234567890123456789012345678901" + "2345678901234567890123456789012345678901234567890123456789/" + "012345678901234567890123456789012345678901234567890123456789012345678901" + "2345678901234567890123456789012345678901234567890123456789"); + UniquePtr<MimeType> parsed = MimeType::Parse(in); + ASSERT_TRUE(parsed) << "Parsing succeeded"; + nsAutoString out; + parsed->Serialize(out); + ASSERT_TRUE(out.Equals(in)) << "Long type/subtype accepted"; +} + +TEST(MimeType, LongParametersAccepted) { + const auto in = NS_LITERAL_STRING( + "text/" + "html;" + "012345678901234567890123456789012345678901234567890123456789012345678901" + "2345678901234567890123456789012345678901234567890123456789=x;charset=" + "gbk"); UniquePtr<MimeType> parsed = MimeType::Parse(in); 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 parameters accepted"; } -TEST(MimeType, LongParametersAccepted) -{ - const auto in = NS_LITERAL_STRING("text/html;0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789=x;charset=gbk"); +TEST(MimeType, AllValidCharactersAccepted1) { + const auto in = NS_LITERAL_STRING( + u"x/x;x=\"\t " + u"!\\\"#$%&'()*+,-./" + u"0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`" + u"abcdefghijklmnopqrstuvwxyz{|}~" + u"\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A" + u"\u008B\u008C\u008D\u008E\u008F\u0090\u0091\u0092\u0093\u0094\u0095" + u"\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F\u00A0" + u"\u00A1\u00A2\u00A3\u00A4\u00A5\u00A6\u00A7\u00A8\u00A9\u00AA\u00AB" + u"\u00AC\u00AD\u00AE\u00AF\u00B0\u00B1\u00B2\u00B3\u00B4\u00B5\u00B6" + u"\u00B7\u00B8\u00B9\u00BA\u00BB\u00BC\u00BD\u00BE\u00BF\u00C0\u00C1" + u"\u00C2\u00C3\u00C4\u00C5\u00C6\u00C7\u00C8\u00C9\u00CA\u00CB\u00CC" + u"\u00CD\u00CE\u00CF\u00D0\u00D1\u00D2\u00D3\u00D4\u00D5\u00D6\u00D7" + u"\u00D8\u00D9\u00DA\u00DB\u00DC\u00DD\u00DE\u00DF\u00E0\u00E1\u00E2" + u"\u00E3\u00E4\u00E5\u00E6\u00E7\u00E8\u00E9\u00EA\u00EB\u00EC\u00ED" + 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"; nsAutoString out; parsed->Serialize(out); - ASSERT_TRUE(out.Equals(in)) << - "Long parameters accepted"; + ASSERT_TRUE(out.Equals(in)) << "All valid characters accepted #1"; } -TEST(MimeType, AllValidCharactersAccepted1) -{ - const auto in = NS_LITERAL_STRING(u"x/x;x=\"\t !\\\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F\u00A0\u00A1\u00A2\u00A3\u00A4\u00A5\u00A6\u00A7\u00A8\u00A9\u00AA\u00AB\u00AC\u00AD\u00AE\u00AF\u00B0\u00B1\u00B2\u00B3\u00B4\u00B5\u00B6\u00B7\u00B8\u00B9\u00BA\u00BB\u00BC\u00BD\u00BE\u00BF\u00C0\u00C1\u00C2\u00C3\u00C4\u00C5\u00C6\u00C7\u00C8\u00C9\u00CA\u00CB\u00CC\u00CD\u00CE\u00CF\u00D0\u00D1\u00D2\u00D3\u00D4\u00D5\u00D6\u00D7\u00D8\u00D9\u00DA\u00DB\u00DC\u00DD\u00DE\u00DF\u00E0\u00E1\u00E2\u00E3\u00E4\u00E5\u00E6\u00E7\u00E8\u00E9\u00EA\u00EB\u00EC\u00ED\u00EE\u00EF\u00F0\u00F1\u00F2\u00F3\u00F4\u00F5\u00F6\u00F7\u00F8\u00F9\u00FA\u00FB\u00FC\u00FD\u00FE\u00FF\""); - UniquePtr<MimeType> parsed = MimeType::Parse(in); - ASSERT_TRUE(parsed) << "Parsing succeeded"; - nsAutoString out; - parsed->Serialize(out); - 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"; nsAutoString out; parsed->Serialize(out); - ASSERT_TRUE(out.EqualsLiteral("text/plain;charset=TEST")) << - "Case normalized properly #1"; + ASSERT_TRUE(out.EqualsLiteral("text/plain;charset=TEST")) + << "Case normalized properly #1"; } -TEST(MimeType, CaseNormalization2) -{ - const auto in = NS_LITERAL_STRING("!#$%&'*+-.^_`|~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz/!#$%&'*+-.^_`|~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz;!#$%&'*+-.^_`|~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz=!#$%&'*+-.^_`|~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"); +TEST(MimeType, CaseNormalization2) { + const auto in = NS_LITERAL_STRING( + "!#$%&'*+-.^_`|~" + "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz/" + "!#$%&'*+-.^_`|~" + "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz;!#$%&'*+-" + ".^_`|~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz=!#$" + "%&'*+-.^_`|~" + "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"); UniquePtr<MimeType> parsed = MimeType::Parse(in); ASSERT_TRUE(parsed) << "Parsing succeeded"; nsAutoString out; parsed->Serialize(out); - ASSERT_TRUE(out.EqualsLiteral("!#$%&'*+-.^_`|~0123456789abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz/!#$%&'*+-.^_`|~0123456789abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz;!#$%&'*+-.^_`|~0123456789abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz=!#$%&'*+-.^_`|~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")) << - "Case normalized properly #2"; + ASSERT_TRUE(out.EqualsLiteral( + "!#$%&'*+-.^_`|~" + "0123456789abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz/" + "!#$%&'*+-.^_`|~" + "0123456789abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz;!#$%&'*+-" + ".^_`|~0123456789abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz=!#$" + "%&'*+-.^_`|~" + "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")) + << "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"; nsAutoString out; parsed->Serialize(out); - ASSERT_TRUE(out.EqualsLiteral("text/html;charset=\"gbk(\"")) << - "Legacy comment syntax #1"; + ASSERT_TRUE(out.EqualsLiteral("text/html;charset=\"gbk(\"")) + << "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"; nsAutoString out; parsed->Serialize(out); - ASSERT_TRUE(out.EqualsLiteral("text/html;x=\"(\";charset=gbk")) << - "Legacy comment syntax #2"; + ASSERT_TRUE(out.EqualsLiteral("text/html;x=\"(\";charset=gbk")) + << "Legacy comment syntax #2"; }
--- a/dom/base/test/gtest/TestPlainTextSerializer.cpp +++ b/dom/base/test/gtest/TestPlainTextSerializer.cpp @@ -7,225 +7,201 @@ #include "gtest/gtest.h" #include "nsServiceManagerUtils.h" #include "nsString.h" #include "nsIDocumentEncoder.h" #include "nsCRT.h" #include "nsIParserUtils.h" -void -ConvertBufToPlainText(nsString &aConBuf, int aFlag) -{ +void ConvertBufToPlainText(nsString &aConBuf, int aFlag) { nsCOMPtr<nsIParserUtils> utils = do_GetService(NS_PARSERUTILS_CONTRACTID); utils->ConvertToPlainText(aConBuf, aFlag, 72, aConBuf); } // Test for ASCII with format=flowed; delsp=yes -TEST(PlainTextSerializer, ASCIIWithFlowedDelSp) -{ +TEST(PlainTextSerializer, ASCIIWithFlowedDelSp) { nsString test; nsString result; - test.AssignLiteral("<html><body>" - "Firefox Firefox Firefox Firefox " - "Firefox Firefox Firefox Firefox " - "Firefox Firefox Firefox Firefox" - "</body></html>"); + test.AssignLiteral( + "<html><body>" + "Firefox Firefox Firefox Firefox " + "Firefox Firefox Firefox Firefox " + "Firefox Firefox Firefox Firefox" + "</body></html>"); ConvertBufToPlainText(test, nsIDocumentEncoder::OutputFormatted | - nsIDocumentEncoder::OutputCRLineBreak | - nsIDocumentEncoder::OutputLFLineBreak | - nsIDocumentEncoder::OutputFormatFlowed | - nsIDocumentEncoder::OutputFormatDelSp); + nsIDocumentEncoder::OutputCRLineBreak | + nsIDocumentEncoder::OutputLFLineBreak | + nsIDocumentEncoder::OutputFormatFlowed | + nsIDocumentEncoder::OutputFormatDelSp); // create result case - result.AssignLiteral("Firefox Firefox Firefox Firefox " - "Firefox Firefox Firefox Firefox " - "Firefox \r\nFirefox Firefox Firefox\r\n"); + result.AssignLiteral( + "Firefox Firefox Firefox Firefox " + "Firefox Firefox Firefox Firefox " + "Firefox \r\nFirefox Firefox Firefox\r\n"); - ASSERT_TRUE(test.Equals(result)) << - "Wrong HTML to ASCII text serialization with format=flowed; delsp=yes"; + ASSERT_TRUE(test.Equals(result)) + << "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; test.AssignLiteral("<html><body>"); for (uint32_t i = 0; i < 40; i++) { // Insert Kanji (U+5341) test.Append(0x5341); } test.AppendLiteral("</body></html>"); ConvertBufToPlainText(test, nsIDocumentEncoder::OutputFormatted | - nsIDocumentEncoder::OutputCRLineBreak | - nsIDocumentEncoder::OutputLFLineBreak | - nsIDocumentEncoder::OutputFormatFlowed | - nsIDocumentEncoder::OutputFormatDelSp); + nsIDocumentEncoder::OutputCRLineBreak | + nsIDocumentEncoder::OutputLFLineBreak | + nsIDocumentEncoder::OutputFormatFlowed | + nsIDocumentEncoder::OutputFormatDelSp); // create result case for (uint32_t i = 0; i < 36; i++) { result.Append(0x5341); } result.AppendLiteral(" \r\n"); for (uint32_t i = 0; i < 4; i++) { result.Append(0x5341); } result.AppendLiteral("\r\n"); - ASSERT_TRUE(test.Equals(result)) << - "Wrong HTML to CJK text serialization with format=flowed; delsp=yes"; + ASSERT_TRUE(test.Equals(result)) + << "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; test.AssignLiteral("<html><body>"); for (uint32_t i = 0; i < 400; i++) { // Insert Kanji (U+5341) test.Append(0x5341); } test.AppendLiteral("</body></html>"); - ConvertBufToPlainText(test, nsIDocumentEncoder::OutputFormatted | - nsIDocumentEncoder::OutputCRLineBreak | - nsIDocumentEncoder::OutputLFLineBreak | - nsIDocumentEncoder::OutputFormatFlowed | - nsIDocumentEncoder::OutputDisallowLineBreaking); + ConvertBufToPlainText(test, + nsIDocumentEncoder::OutputFormatted | + nsIDocumentEncoder::OutputCRLineBreak | + nsIDocumentEncoder::OutputLFLineBreak | + nsIDocumentEncoder::OutputFormatFlowed | + nsIDocumentEncoder::OutputDisallowLineBreaking); // create result case for (uint32_t i = 0; i < 400; i++) { result.Append(0x5341); } result.AppendLiteral("\r\n"); - ASSERT_TRUE(test.Equals(result)) << - "Wrong HTML to CJK text serialization with OutputDisallowLineBreaking"; + ASSERT_TRUE(test.Equals(result)) + << "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; - test.AssignLiteral("<html><body>" - "<span style=\"white-space: pre-wrap;\">" - "> Firefox Firefox Firefox Firefox <br>" - "> Firefox Firefox Firefox Firefox<br>" - "><br>" - ">> Firefox Firefox Firefox Firefox <br>" - ">> Firefox Firefox Firefox Firefox<br>" - "</span></body></html>"); + test.AssignLiteral( + "<html><body>" + "<span style=\"white-space: pre-wrap;\">" + "> Firefox Firefox Firefox Firefox <br>" + "> Firefox Firefox Firefox Firefox<br>" + "><br>" + ">> Firefox Firefox Firefox Firefox <br>" + ">> Firefox Firefox Firefox Firefox<br>" + "</span></body></html>"); ConvertBufToPlainText(test, nsIDocumentEncoder::OutputFormatted | - nsIDocumentEncoder::OutputCRLineBreak | - nsIDocumentEncoder::OutputLFLineBreak | - nsIDocumentEncoder::OutputFormatFlowed); + nsIDocumentEncoder::OutputCRLineBreak | + nsIDocumentEncoder::OutputLFLineBreak | + nsIDocumentEncoder::OutputFormatFlowed); // create result case - result.AssignLiteral("> Firefox Firefox Firefox Firefox \r\n" - "> Firefox Firefox Firefox Firefox\r\n" - ">\r\n" - ">> Firefox Firefox Firefox Firefox \r\n" - ">> Firefox Firefox Firefox Firefox\r\n"); + result.AssignLiteral( + "> Firefox Firefox Firefox Firefox \r\n" + "> Firefox Firefox Firefox Firefox\r\n" + ">\r\n" + ">> 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 - "</body>" NS_LINEBREAK "</html>"); + test.AppendLiteral("<html>" NS_LINEBREAK "<body>" NS_LINEBREAK + " first<br>" NS_LINEBREAK " second<br>" NS_LINEBREAK + "</body>" NS_LINEBREAK "</html>"); ConvertBufToPlainText(test, 0); - ASSERT_TRUE(test.EqualsLiteral("first" NS_LINEBREAK "second" NS_LINEBREAK)) << - "Wrong prettyprinted html to text serialization"; + ASSERT_TRUE(test.EqualsLiteral("first" NS_LINEBREAK "second" NS_LINEBREAK)) + << "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 - " second" NS_LINEBREAK - "</pre>" NS_LINEBREAK - "</body>" NS_LINEBREAK "</html>"); + test.AppendLiteral("<html>" NS_LINEBREAK "<body>" NS_LINEBREAK + "<pre>" NS_LINEBREAK " first" NS_LINEBREAK + " second" NS_LINEBREAK "</pre>" NS_LINEBREAK + "</body>" NS_LINEBREAK "</html>"); ConvertBufToPlainText(test, 0); ASSERT_TRUE(test.EqualsLiteral(" first" NS_LINEBREAK - " second" NS_LINEBREAK NS_LINEBREAK)) << - "Wrong prettyprinted html to text serialization"; + " second" NS_LINEBREAK NS_LINEBREAK)) + << "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 - "</div>" NS_LINEBREAK - "<div>" NS_LINEBREAK - " second" NS_LINEBREAK - "</div>" NS_LINEBREAK - "</body>" NS_LINEBREAK "</html>"); + test.AppendLiteral("<html>" NS_LINEBREAK "<body>" NS_LINEBREAK + "<div>" NS_LINEBREAK " first" NS_LINEBREAK + "</div>" NS_LINEBREAK "<div>" NS_LINEBREAK + " second" NS_LINEBREAK "</div>" NS_LINEBREAK + "</body>" NS_LINEBREAK "</html>"); ConvertBufToPlainText(test, 0); - ASSERT_TRUE(test.EqualsLiteral("first" NS_LINEBREAK "second" NS_LINEBREAK)) << - "Wrong prettyprinted html to text serialization"; + ASSERT_TRUE(test.EqualsLiteral("first" NS_LINEBREAK "second" NS_LINEBREAK)) + << "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( - "<html>" NS_LINEBREAK - "<body style=\"white-space: pre-wrap; width: 10ch;\">" NS_LINEBREAK - "<pre>" NS_LINEBREAK - " first line is too long" NS_LINEBREAK - " second line is even loooonger " NS_LINEBREAK - "</pre>" NS_LINEBREAK - "</body>" NS_LINEBREAK "</html>"); + "<html>" NS_LINEBREAK + "<body style=\"white-space: pre-wrap; width: 10ch;\">" NS_LINEBREAK + "<pre>" NS_LINEBREAK " first line is too long" NS_LINEBREAK + " second line is even loooonger " NS_LINEBREAK "</pre>" NS_LINEBREAK + "</body>" NS_LINEBREAK "</html>"); ConvertBufToPlainText(test, nsIDocumentEncoder::OutputWrap); // "\n\n first\nline is\ntoo long\n second\nline is\neven\nloooonger\n\n\n" - ASSERT_TRUE(test.EqualsLiteral(NS_LINEBREAK NS_LINEBREAK - " 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"; + ASSERT_TRUE(test.EqualsLiteral( + NS_LINEBREAK NS_LINEBREAK + " 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"; } -TEST(PlainTextSerializer, Simple) -{ +TEST(PlainTextSerializer, Simple) { nsString test; - test.AppendLiteral("<html><base>base</base><head><span>span</span></head>" - "<body>body</body></html>"); + 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"; + ASSERT_TRUE(test.EqualsLiteral("basespanbody")) + << "Wrong html to text serialization"; } -
--- a/dom/base/test/gtest/TestXPathGenerator.cpp +++ b/dom/base/test/gtest/TestXPathGenerator.cpp @@ -3,138 +3,139 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "gtest/gtest.h" #include "XPathGenerator.h" #include "nsString.h" -TEST(TestXPathGenerator, TestQuoteArgumentWithoutQuote) -{ +TEST(TestXPathGenerator, TestQuoteArgumentWithoutQuote) { nsAutoString arg; arg.AssignLiteral(u"testing"); nsAutoString expectedResult; expectedResult.AssignLiteral(u"\'testing\'"); nsAutoString result; XPathGenerator::QuoteArgument(arg, result); ASSERT_TRUE(expectedResult.Equals(result)); } -TEST(TestXPathGenerator, TestQuoteArgumentWithSingleQuote) -{ +TEST(TestXPathGenerator, TestQuoteArgumentWithSingleQuote) { nsAutoString arg; arg.AssignLiteral(u"\'testing\'"); nsAutoString expectedResult; expectedResult.AssignLiteral(u"\"\'testing\'\""); nsAutoString result; XPathGenerator::QuoteArgument(arg, result); ASSERT_TRUE(expectedResult.Equals(result)); } -TEST(TestXPathGenerator, TestQuoteArgumentWithDoubleQuote) -{ +TEST(TestXPathGenerator, TestQuoteArgumentWithDoubleQuote) { nsAutoString arg; arg.AssignLiteral(u"\"testing\""); nsAutoString expectedResult; expectedResult.AssignLiteral(u"\'\"testing\"\'"); nsAutoString result; XPathGenerator::QuoteArgument(arg, result); ASSERT_TRUE(expectedResult.Equals(result)); } -TEST(TestXPathGenerator, TestQuoteArgumentWithSingleAndDoubleQuote) -{ +TEST(TestXPathGenerator, TestQuoteArgumentWithSingleAndDoubleQuote) { nsAutoString arg; arg.AssignLiteral(u"\'testing\""); nsAutoString expectedResult; expectedResult.AssignLiteral(u"concat(\'\',\"\'\",\'testing\"\')"); nsAutoString result; XPathGenerator::QuoteArgument(arg, result); - printf("Result: %s\nExpected: %s\n", NS_ConvertUTF16toUTF8(result).get(), NS_ConvertUTF16toUTF8(expectedResult).get()); + printf("Result: %s\nExpected: %s\n", NS_ConvertUTF16toUTF8(result).get(), + NS_ConvertUTF16toUTF8(expectedResult).get()); ASSERT_TRUE(expectedResult.Equals(result)); } -TEST(TestXPathGenerator, TestQuoteArgumentWithDoubleQuoteAndASequenceOfSingleQuote) -{ +TEST(TestXPathGenerator, + TestQuoteArgumentWithDoubleQuoteAndASequenceOfSingleQuote) { nsAutoString arg; arg.AssignLiteral(u"\'\'\'\'testing\""); nsAutoString expectedResult; expectedResult.AssignLiteral(u"concat(\'\',\"\'\'\'\'\",\'testing\"\')"); nsAutoString result; XPathGenerator::QuoteArgument(arg, result); - printf("Result: %s\nExpected: %s\n", NS_ConvertUTF16toUTF8(result).get(), NS_ConvertUTF16toUTF8(expectedResult).get()); + printf("Result: %s\nExpected: %s\n", NS_ConvertUTF16toUTF8(result).get(), + NS_ConvertUTF16toUTF8(expectedResult).get()); ASSERT_TRUE(expectedResult.Equals(result)); } -TEST(TestXPathGenerator, TestQuoteArgumentWithDoubleQuoteAndTwoSequencesOfSingleQuote) -{ +TEST(TestXPathGenerator, + TestQuoteArgumentWithDoubleQuoteAndTwoSequencesOfSingleQuote) { nsAutoString arg; arg.AssignLiteral(u"\'\'\'\'testing\'\'\'\'\'\'\""); nsAutoString expectedResult; - expectedResult.AssignLiteral(u"concat(\'\',\"\'\'\'\'\",\'testing\',\"\'\'\'\'\'\'\",\'\"\')"); + expectedResult.AssignLiteral( + u"concat(\'\',\"\'\'\'\'\",\'testing\',\"\'\'\'\'\'\'\",\'\"\')"); nsAutoString result; XPathGenerator::QuoteArgument(arg, result); - printf("Result: %s\nExpected: %s\n", NS_ConvertUTF16toUTF8(result).get(), NS_ConvertUTF16toUTF8(expectedResult).get()); + printf("Result: %s\nExpected: %s\n", NS_ConvertUTF16toUTF8(result).get(), + NS_ConvertUTF16toUTF8(expectedResult).get()); ASSERT_TRUE(expectedResult.Equals(result)); } -TEST(TestXPathGenerator, TestQuoteArgumentWithDoubleQuoteAndTwoSequencesOfSingleQuoteInMiddle) -{ +TEST(TestXPathGenerator, + TestQuoteArgumentWithDoubleQuoteAndTwoSequencesOfSingleQuoteInMiddle) { nsAutoString arg; arg.AssignLiteral(u"t\'\'\'\'estin\'\'\'\'\'\'\"g"); nsAutoString expectedResult; - expectedResult.AssignLiteral(u"concat(\'t\',\"\'\'\'\'\",\'estin\',\"\'\'\'\'\'\'\",\'\"g\')"); + expectedResult.AssignLiteral( + u"concat(\'t\',\"\'\'\'\'\",\'estin\',\"\'\'\'\'\'\'\",\'\"g\')"); nsAutoString result; XPathGenerator::QuoteArgument(arg, result); - printf("Result: %s\nExpected: %s\n", NS_ConvertUTF16toUTF8(result).get(), NS_ConvertUTF16toUTF8(expectedResult).get()); + printf("Result: %s\nExpected: %s\n", NS_ConvertUTF16toUTF8(result).get(), + NS_ConvertUTF16toUTF8(expectedResult).get()); ASSERT_TRUE(expectedResult.Equals(result)); } -TEST(TestXPathGenerator, TestEscapeNameWithNormalCharacters) -{ +TEST(TestXPathGenerator, TestEscapeNameWithNormalCharacters) { nsAutoString arg; arg.AssignLiteral(u"testing"); nsAutoString expectedResult; expectedResult.AssignLiteral(u"testing"); nsAutoString result; XPathGenerator::EscapeName(arg, result); ASSERT_TRUE(expectedResult.Equals(result)); } -TEST(TestXPathGenerator, TestEscapeNameWithSpecialCharacters) -{ +TEST(TestXPathGenerator, TestEscapeNameWithSpecialCharacters) { nsAutoString arg; arg.AssignLiteral(u"^testing!"); nsAutoString expectedResult; expectedResult.AssignLiteral(u"*[local-name()=\'^testing!\']"); nsAutoString result; XPathGenerator::EscapeName(arg, result); - printf("Result: %s\nExpected: %s\n", NS_ConvertUTF16toUTF8(result).get(), NS_ConvertUTF16toUTF8(expectedResult).get()); + printf("Result: %s\nExpected: %s\n", NS_ConvertUTF16toUTF8(result).get(), + NS_ConvertUTF16toUTF8(expectedResult).get()); ASSERT_TRUE(expectedResult.Equals(result)); }
--- a/dom/bindings/test/TestBindingHeader.h +++ b/dom/bindings/test/TestBindingHeader.h @@ -12,206 +12,203 @@ #include "mozilla/dom/Date.h" #include "mozilla/dom/Record.h" #include "mozilla/dom/TypedArray.h" #include "mozilla/ErrorResult.h" #include "nsCOMPtr.h" #include "nsGenericHTMLElement.h" #include "nsWrapperCache.h" -// Forward declare this before we include TestCodeGenBinding.h, because that header relies on including -// this one for it, for ParentDict. Hopefully it won't begin to rely on it in more fundamental ways. +// Forward declare this before we include TestCodeGenBinding.h, because that +// header relies on including this one for it, for ParentDict. Hopefully it +// won't begin to rely on it in more fundamental ways. namespace mozilla { namespace dom { class DocGroup; class TestExternalInterface; class Promise; -} // namespace dom -} // namespace mozilla +} // namespace dom +} // namespace mozilla // We don't export TestCodeGenBinding.h, but it's right in our parent dir. #ifdef XP_WIN // If we're on windows, simulate including windows.h. This step will cause // compilation failure if NeedsWindowsUndef is not defined. #define NO_ERROR 0x1 #endif #include "../TestCodeGenBinding.h" extern bool TestFuncControlledMember(JSContext*, JSObject*); namespace mozilla { namespace dom { // IID for nsRenamedInterface -#define NS_RENAMED_INTERFACE_IID \ -{ 0xd4b19ef3, 0xe68b, 0x4e3f, \ - { 0x94, 0xbc, 0xc9, 0xde, 0x3a, 0x69, 0xb0, 0xe8 } } +#define NS_RENAMED_INTERFACE_IID \ + { \ + 0xd4b19ef3, 0xe68b, 0x4e3f, { \ + 0x94, 0xbc, 0xc9, 0xde, 0x3a, 0x69, 0xb0, 0xe8 \ + } \ + } -class nsRenamedInterface : public nsISupports, - public nsWrapperCache -{ -public: +class nsRenamedInterface : public nsISupports, public nsWrapperCache { + public: NS_DECLARE_STATIC_IID_ACCESSOR(NS_RENAMED_INTERFACE_IID) NS_DECL_ISUPPORTS // We need a GetParentObject to make binding codegen happy virtual nsISupports* GetParentObject(); }; NS_DEFINE_STATIC_IID_ACCESSOR(nsRenamedInterface, NS_RENAMED_INTERFACE_IID) // IID for the IndirectlyImplementedInterface -#define NS_INDIRECTLY_IMPLEMENTED_INTERFACE_IID \ -{ 0xfed55b69, 0x7012, 0x4849, \ - { 0xaf, 0x56, 0x4b, 0xa9, 0xee, 0x41, 0x30, 0x89 } } +#define NS_INDIRECTLY_IMPLEMENTED_INTERFACE_IID \ + { \ + 0xfed55b69, 0x7012, 0x4849, { \ + 0xaf, 0x56, 0x4b, 0xa9, 0xee, 0x41, 0x30, 0x89 \ + } \ + } class IndirectlyImplementedInterface : public nsISupports, - public nsWrapperCache -{ -public: + public nsWrapperCache { + public: NS_DECLARE_STATIC_IID_ACCESSOR(NS_INDIRECTLY_IMPLEMENTED_INTERFACE_IID) NS_DECL_ISUPPORTS // We need a GetParentObject to make binding codegen happy virtual nsISupports* GetParentObject(); bool IndirectlyImplementedProperty(); void IndirectlyImplementedProperty(bool); void IndirectlyImplementedMethod(); }; -NS_DEFINE_STATIC_IID_ACCESSOR(IndirectlyImplementedInterface, NS_INDIRECTLY_IMPLEMENTED_INTERFACE_IID) +NS_DEFINE_STATIC_IID_ACCESSOR(IndirectlyImplementedInterface, + NS_INDIRECTLY_IMPLEMENTED_INTERFACE_IID) // IID for the TestExternalInterface -#define NS_TEST_EXTERNAL_INTERFACE_IID \ -{ 0xd5ba0c99, 0x9b1d, 0x4e71, \ - { 0x8a, 0x94, 0x56, 0x38, 0x6c, 0xa3, 0xda, 0x3d } } -class TestExternalInterface : public nsISupports -{ -public: +#define NS_TEST_EXTERNAL_INTERFACE_IID \ + { \ + 0xd5ba0c99, 0x9b1d, 0x4e71, { \ + 0x8a, 0x94, 0x56, 0x38, 0x6c, 0xa3, 0xda, 0x3d \ + } \ + } +class TestExternalInterface : public nsISupports { + public: NS_DECLARE_STATIC_IID_ACCESSOR(NS_TEST_EXTERNAL_INTERFACE_IID) NS_DECL_ISUPPORTS }; -NS_DEFINE_STATIC_IID_ACCESSOR(TestExternalInterface, NS_TEST_EXTERNAL_INTERFACE_IID) +NS_DEFINE_STATIC_IID_ACCESSOR(TestExternalInterface, + NS_TEST_EXTERNAL_INTERFACE_IID) -class TestNonWrapperCacheInterface : public nsISupports -{ -public: +class TestNonWrapperCacheInterface : public nsISupports { + public: NS_DECL_ISUPPORTS - bool WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector); + bool WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto, + JS::MutableHandle<JSObject*> aReflector); }; -class OnlyForUseInConstructor : public nsISupports, - public nsWrapperCache -{ -public: +class OnlyForUseInConstructor : public nsISupports, public nsWrapperCache { + public: NS_DECL_ISUPPORTS // We need a GetParentObject to make binding codegen happy virtual nsISupports* GetParentObject(); }; -class TestInterface : public nsISupports, - public nsWrapperCache -{ -public: +class TestInterface : public nsISupports, public nsWrapperCache { + public: NS_DECL_ISUPPORTS // We need a GetParentObject and GetDocGroup to make binding codegen happy virtual nsISupports* GetParentObject(); DocGroup* GetDocGroup() const; // And now our actual WebIDL API // Constructors - static - already_AddRefed<TestInterface> - Constructor(const GlobalObject&, ErrorResult&); - static - already_AddRefed<TestInterface> - Constructor(const GlobalObject&, const nsAString&, ErrorResult&); - static - already_AddRefed<TestInterface> - Constructor(const GlobalObject&, uint32_t, const Nullable<bool>&, - ErrorResult&); - static - already_AddRefed<TestInterface> - Constructor(const GlobalObject&, TestInterface*, ErrorResult&); - static - already_AddRefed<TestInterface> - Constructor(const GlobalObject&, uint32_t, IndirectlyImplementedInterface&, ErrorResult&); + static already_AddRefed<TestInterface> Constructor(const GlobalObject&, + ErrorResult&); + static already_AddRefed<TestInterface> Constructor(const GlobalObject&, + const nsAString&, + ErrorResult&); + static already_AddRefed<TestInterface> Constructor(const GlobalObject&, + uint32_t, + const Nullable<bool>&, + ErrorResult&); + static already_AddRefed<TestInterface> Constructor(const GlobalObject&, + TestInterface*, + ErrorResult&); + static already_AddRefed<TestInterface> Constructor( + const GlobalObject&, uint32_t, IndirectlyImplementedInterface&, + ErrorResult&); - static - already_AddRefed<TestInterface> - Constructor(const GlobalObject&, Date&, ErrorResult&); - static - already_AddRefed<TestInterface> - Constructor(const GlobalObject&, const ArrayBuffer&, ErrorResult&); - static - already_AddRefed<TestInterface> - Constructor(const GlobalObject&, const Uint8Array&, ErrorResult&); + static already_AddRefed<TestInterface> Constructor(const GlobalObject&, Date&, + ErrorResult&); + static already_AddRefed<TestInterface> Constructor(const GlobalObject&, + const ArrayBuffer&, + ErrorResult&); + static already_AddRefed<TestInterface> Constructor(const GlobalObject&, + const Uint8Array&, + ErrorResult&); /* static already_AddRefed<TestInterface> Constructor(const GlobalObject&, uint32_t, uint32_t, const TestInterfaceOrOnlyForUseInConstructor&, ErrorResult&); */ - static - already_AddRefed<TestInterface> Test(const GlobalObject&, ErrorResult&); - static - already_AddRefed<TestInterface> Test(const GlobalObject&, const nsAString&, - ErrorResult&); - static - already_AddRefed<TestInterface> Test(const GlobalObject&, const nsACString&, - ErrorResult&); + static already_AddRefed<TestInterface> Test(const GlobalObject&, + ErrorResult&); + static already_AddRefed<TestInterface> Test(const GlobalObject&, + const nsAString&, ErrorResult&); + static already_AddRefed<TestInterface> Test(const GlobalObject&, + const nsACString&, ErrorResult&); + + static already_AddRefed<TestInterface> Test2( + const GlobalObject&, const DictForConstructor&, JS::Handle<JS::Value>, + JS::Handle<JSObject*>, JS::Handle<JSObject*>, const Sequence<Dict>&, + JS::Handle<JS::Value>, const Optional<JS::Handle<JSObject*>>&, + const Optional<JS::Handle<JSObject*>>&, ErrorResult&); + + static already_AddRefed<TestInterface> Test3(const GlobalObject&, + const LongOrStringAnyRecord&, + ErrorResult&); - static - already_AddRefed<TestInterface> Test2(const GlobalObject&, - const DictForConstructor&, - JS::Handle<JS::Value>, - JS::Handle<JSObject*>, - JS::Handle<JSObject*>, - const Sequence<Dict>&, - JS::Handle<JS::Value>, - const Optional<JS::Handle<JSObject*> >&, - const Optional<JS::Handle<JSObject*> >&, - ErrorResult&); + static already_AddRefed<TestInterface> Test4( + const GlobalObject&, const Record<nsString, Record<nsString, JS::Value>>&, + ErrorResult&); - static - already_AddRefed<TestInterface> Test3(const GlobalObject&, - const LongOrStringAnyRecord&, - ErrorResult&); - - static - already_AddRefed<TestInterface> Test4(const GlobalObject&, - const Record<nsString, Record<nsString, JS::Value>>&, - ErrorResult&); + static already_AddRefed<TestInterface> Test5( + const GlobalObject&, + const Record< + nsString, + Sequence<Record<nsString, + Record<nsString, Sequence<Sequence<JS::Value>>>>>>&, + ErrorResult&); - static - already_AddRefed<TestInterface> Test5(const GlobalObject&, - const Record<nsString, Sequence<Record<nsString, Record<nsString, Sequence<Sequence<JS::Value>>>>>>&, - ErrorResult&); - - static - already_AddRefed<TestInterface> Test6(const GlobalObject&, - const Sequence<Record<nsCString, Sequence<Sequence<Record<nsCString, Record<nsString, JS::Value>>>>>>&, - ErrorResult&); + static already_AddRefed<TestInterface> Test6( + const GlobalObject&, + const Sequence<Record< + nsCString, + Sequence<Sequence<Record<nsCString, Record<nsString, JS::Value>>>>>>&, + ErrorResult&); // Integer types int8_t ReadonlyByte(); int8_t WritableByte(); void SetWritableByte(int8_t); void PassByte(int8_t); int8_t ReceiveByte(); void PassOptionalByte(const Optional<int8_t>&); void PassOptionalByteBeforeRequired(const Optional<int8_t>&, int8_t); void PassOptionalByteWithDefault(int8_t); void PassOptionalByteWithDefaultBeforeRequired(int8_t, int8_t); void PassNullableByte(const Nullable<int8_t>&); - void PassOptionalNullableByte(const Optional< Nullable<int8_t> >&); + void PassOptionalNullableByte(const Optional<Nullable<int8_t>>&); void PassVariadicByte(const Sequence<int8_t>&); int8_t CachedByte(); int8_t CachedConstantByte(); int8_t CachedWritableByte(); void SetCachedWritableByte(int8_t); int8_t SideEffectFreeByte(); void SetSideEffectFreeByte(int8_t); int8_t DomDependentByte(); @@ -295,80 +292,81 @@ public: void SetWritableDouble(double); double WritableUnrestrictedDouble() const; void SetWritableUnrestrictedDouble(double); Nullable<double> GetWritableNullableDouble() const; void SetWritableNullableDouble(const Nullable<double>&); Nullable<double> GetWritableNullableUnrestrictedDouble() const; void SetWritableNullableUnrestrictedDouble(const Nullable<double>&); void PassFloat(float, float, const Nullable<float>&, const Nullable<float>&, - double, double, const Nullable<double>&, const Nullable<double>&, - const Sequence<float>&, const Sequence<float>&, - const Sequence<Nullable<float> >&, - const Sequence<Nullable<float> >&, - const Sequence<double>&, const Sequence<double>&, - const Sequence<Nullable<double> >&, - const Sequence<Nullable<double> >&); - void PassLenientFloat(float, float, const Nullable<float>&, const Nullable<float>&, - double, double, const Nullable<double>&, const Nullable<double>&, + double, double, const Nullable<double>&, + const Nullable<double>&, const Sequence<float>&, + const Sequence<float>&, const Sequence<Nullable<float>>&, + const Sequence<Nullable<float>>&, const Sequence<double>&, + const Sequence<double>&, const Sequence<Nullable<double>>&, + const Sequence<Nullable<double>>&); + void PassLenientFloat(float, float, const Nullable<float>&, + const Nullable<float>&, double, double, + const Nullable<double>&, const Nullable<double>&, const Sequence<float>&, const Sequence<float>&, - const Sequence<Nullable<float> >&, - const Sequence<Nullable<float> >&, + const Sequence<Nullable<float>>&, + const Sequence<Nullable<float>>&, const Sequence<double>&, const Sequence<double>&, - const Sequence<Nullable<double> >&, - const Sequence<Nullable<double> >&); + const Sequence<Nullable<double>>&, + const Sequence<Nullable<double>>&); float LenientFloatAttr() const; void SetLenientFloatAttr(float); double LenientDoubleAttr() const; void SetLenientDoubleAttr(double); - void PassUnrestricted(float arg1, - float arg2, - float arg3, - float arg4, - double arg5, - double arg6, - double arg7, - double arg8); + void PassUnrestricted(float arg1, float arg2, float arg3, float arg4, + double arg5, double arg6, double arg7, double arg8); // Interface types already_AddRefed<TestInterface> ReceiveSelf(); already_AddRefed<TestInterface> ReceiveNullableSelf(); TestInterface* ReceiveWeakSelf(); TestInterface* ReceiveWeakNullableSelf(); void PassSelf(TestInterface&); void PassNullableSelf(TestInterface*); already_AddRefed<TestInterface> NonNullSelf(); void SetNonNullSelf(TestInterface&); already_AddRefed<TestInterface> GetNullableSelf(); already_AddRefed<TestInterface> CachedSelf(); void SetNullableSelf(TestInterface*); - void PassOptionalSelf(const Optional<TestInterface*> &); - void PassOptionalNonNullSelf(const Optional<NonNull<TestInterface> >&); + void PassOptionalSelf(const Optional<TestInterface*>&); + void PassOptionalNonNullSelf(const Optional<NonNull<TestInterface>>&); void PassOptionalSelfWithDefault(TestInterface*); - already_AddRefed<TestNonWrapperCacheInterface> ReceiveNonWrapperCacheInterface(); - already_AddRefed<TestNonWrapperCacheInterface> ReceiveNullableNonWrapperCacheInterface(); - void ReceiveNonWrapperCacheInterfaceSequence(nsTArray<RefPtr<TestNonWrapperCacheInterface> >&); - void ReceiveNullableNonWrapperCacheInterfaceSequence(nsTArray<RefPtr<TestNonWrapperCacheInterface> >&); - void ReceiveNonWrapperCacheInterfaceNullableSequence(Nullable<nsTArray<RefPtr<TestNonWrapperCacheInterface> > >&); - void ReceiveNullableNonWrapperCacheInterfaceNullableSequence(Nullable<nsTArray<RefPtr<TestNonWrapperCacheInterface> > >&); + already_AddRefed<TestNonWrapperCacheInterface> + ReceiveNonWrapperCacheInterface(); + already_AddRefed<TestNonWrapperCacheInterface> + ReceiveNullableNonWrapperCacheInterface(); + void ReceiveNonWrapperCacheInterfaceSequence( + nsTArray<RefPtr<TestNonWrapperCacheInterface>>&); + void ReceiveNullableNonWrapperCacheInterfaceSequence( + nsTArray<RefPtr<TestNonWrapperCacheInterface>>&); + void ReceiveNonWrapperCacheInterfaceNullableSequence( + Nullable<nsTArray<RefPtr<TestNonWrapperCacheInterface>>>&); + void ReceiveNullableNonWrapperCacheInterfaceNullableSequence( + Nullable<nsTArray<RefPtr<TestNonWrapperCacheInterface>>>&); already_AddRefed<IndirectlyImplementedInterface> ReceiveOther(); already_AddRefed<IndirectlyImplementedInterface> ReceiveNullableOther(); IndirectlyImplementedInterface* ReceiveWeakOther(); IndirectlyImplementedInterface* ReceiveWeakNullableOther(); void PassOther(IndirectlyImplementedInterface&); void PassNullableOther(IndirectlyImplementedInterface*); already_AddRefed<IndirectlyImplementedInterface> NonNullOther(); void SetNonNullOther(IndirectlyImplementedInterface&); already_AddRefed<IndirectlyImplementedInterface> GetNullableOther(); void SetNullableOther(IndirectlyImplementedInterface*); void PassOptionalOther(const Optional<IndirectlyImplementedInterface*>&); - void PassOptionalNonNullOther(const Optional<NonNull<IndirectlyImplementedInterface> >&); + void PassOptionalNonNullOther( + const Optional<NonNull<IndirectlyImplementedInterface>>&); void PassOptionalOtherWithDefault(IndirectlyImplementedInterface*); already_AddRefed<TestExternalInterface> ReceiveExternal(); already_AddRefed<TestExternalInterface> ReceiveNullableExternal(); TestExternalInterface* ReceiveWeakExternal(); TestExternalInterface* ReceiveWeakNullableExternal(); void PassExternal(TestExternalInterface*); void PassNullableExternal(TestExternalInterface*); @@ -385,127 +383,167 @@ public: TestCallbackInterface* ReceiveWeakCallbackInterface(); TestCallbackInterface* ReceiveWeakNullableCallbackInterface(); void PassCallbackInterface(TestCallbackInterface&); void PassNullableCallbackInterface(TestCallbackInterface*); already_AddRefed<TestCallbackInterface> NonNullCallbackInterface(); void SetNonNullCallbackInterface(TestCallbackInterface&); already_AddRefed<TestCallbackInterface> GetNullableCallbackInterface(); void SetNullableCallbackInterface(TestCallbackInterface*); - void PassOptionalCallbackInterface(const Optional<RefPtr<TestCallbackInterface> >&); - void PassOptionalNonNullCallbackInterface(const Optional<OwningNonNull<TestCallbackInterface> >&); + void PassOptionalCallbackInterface( + const Optional<RefPtr<TestCallbackInterface>>&); + void PassOptionalNonNullCallbackInterface( + const Optional<OwningNonNull<TestCallbackInterface>>&); void PassOptionalCallbackInterfaceWithDefault(TestCallbackInterface*); - already_AddRefed<IndirectlyImplementedInterface> ReceiveConsequentialInterface(); + already_AddRefed<IndirectlyImplementedInterface> + ReceiveConsequentialInterface(); void PassConsequentialInterface(IndirectlyImplementedInterface&); // Sequence types void GetReadonlySequence(nsTArray<int32_t>&); void GetReadonlySequenceOfDictionaries(JSContext*, nsTArray<Dict>&); - void GetReadonlyNullableSequenceOfDictionaries(JSContext*, Nullable<nsTArray<Dict> >&); + void GetReadonlyNullableSequenceOfDictionaries(JSContext*, + Nullable<nsTArray<Dict>>&); void GetReadonlyFrozenSequence(JSContext*, nsTArray<Dict>&); void GetReadonlyFrozenNullableSequence(JSContext*, Nullable<nsTArray<Dict>>&); void ReceiveSequence(nsTArray<int32_t>&); - void ReceiveNullableSequence(Nullable< nsTArray<int32_t> >&); - void ReceiveSequenceOfNullableInts(nsTArray< Nullable<int32_t> >&); - void ReceiveNullableSequenceOfNullableInts(Nullable< nsTArray< Nullable<int32_t> > >&); - void PassSequence(const Sequence<int32_t> &); - void PassNullableSequence(const Nullable< Sequence<int32_t> >&); - void PassSequenceOfNullableInts(const Sequence<Nullable<int32_t> >&); - void PassOptionalSequenceOfNullableInts(const Optional<Sequence<Nullable<int32_t> > > &); - void PassOptionalNullableSequenceOfNullableInts(const Optional<Nullable<Sequence<Nullable<int32_t> > > > &); - void ReceiveCastableObjectSequence(nsTArray< RefPtr<TestInterface> > &); - void ReceiveCallbackObjectSequence(nsTArray< RefPtr<TestCallbackInterface> > &); - void ReceiveNullableCastableObjectSequence(nsTArray< RefPtr<TestInterface> > &); - void ReceiveNullableCallbackObjectSequence(nsTArray< RefPtr<TestCallbackInterface> > &); - void ReceiveCastableObjectNullableSequence(Nullable< nsTArray< RefPtr<TestInterface> > >&); - void ReceiveNullableCastableObjectNullableSequence(Nullable< nsTArray< RefPtr<TestInterface> > >&); - void ReceiveWeakCastableObjectSequence(nsTArray<RefPtr<TestInterface>> &); - void ReceiveWeakNullableCastableObjectSequence(nsTArray<RefPtr<TestInterface>> &); - void ReceiveWeakCastableObjectNullableSequence(Nullable< nsTArray<RefPtr<TestInterface>> >&); - void ReceiveWeakNullableCastableObjectNullableSequence(Nullable< nsTArray<RefPtr<TestInterface>> >&); - void PassCastableObjectSequence(const Sequence< OwningNonNull<TestInterface> >&); - void PassNullableCastableObjectSequence(const Sequence< RefPtr<TestInterface> > &); - void PassCastableObjectNullableSequence(const Nullable< Sequence< OwningNonNull<TestInterface> > >&); - void PassNullableCastableObjectNullableSequence(const Nullable< Sequence< RefPtr<TestInterface> > >&); - void PassOptionalSequence(const Optional<Sequence<int32_t> >&); - void PassOptionalSequenceWithDefaultValue(const Sequence<int32_t> &); - void PassOptionalNullableSequence(const Optional<Nullable<Sequence<int32_t> > >&); - void PassOptionalNullableSequenceWithDefaultValue(const Nullable< Sequence<int32_t> >&); - void PassOptionalNullableSequenceWithDefaultValue2(const Nullable< Sequence<int32_t> >&); - void PassOptionalObjectSequence(const Optional<Sequence<OwningNonNull<TestInterface> > >&); - void PassExternalInterfaceSequence(const Sequence<RefPtr<TestExternalInterface> >&); - void PassNullableExternalInterfaceSequence(const Sequence<RefPtr<TestExternalInterface> >&); + void ReceiveNullableSequence(Nullable<nsTArray<int32_t>>&); + void ReceiveSequenceOfNullableInts(nsTArray<Nullable<int32_t>>&); + void ReceiveNullableSequenceOfNullableInts( + Nullable<nsTArray<Nullable<int32_t>>>&); + void PassSequence(const Sequence<int32_t>&); + void PassNullableSequence(const Nullable<Sequence<int32_t>>&); + void PassSequenceOfNullableInts(const Sequence<Nullable<int32_t>>&); + void PassOptionalSequenceOfNullableInts( + const Optional<Sequence<Nullable<int32_t>>>&); + void PassOptionalNullableSequenceOfNullableInts( + const Optional<Nullable<Sequence<Nullable<int32_t>>>>&); + void ReceiveCastableObjectSequence(nsTArray<RefPtr<TestInterface>>&); + void ReceiveCallbackObjectSequence(nsTArray<RefPtr<TestCallbackInterface>>&); + void ReceiveNullableCastableObjectSequence(nsTArray<RefPtr<TestInterface>>&); + void ReceiveNullableCallbackObjectSequence( + nsTArray<RefPtr<TestCallbackInterface>>&); + void ReceiveCastableObjectNullableSequence( + Nullable<nsTArray<RefPtr<TestInterface>>>&); + void ReceiveNullableCastableObjectNullableSequence( + Nullable<nsTArray<RefPtr<TestInterface>>>&); + void ReceiveWeakCastableObjectSequence(nsTArray<RefPtr<TestInterface>>&); + void ReceiveWeakNullableCastableObjectSequence( + nsTArray<RefPtr<TestInterface>>&); + void ReceiveWeakCastableObjectNullableSequence( + Nullable<nsTArray<RefPtr<TestInterface>>>&); + void ReceiveWeakNullableCastableObjectNullableSequence( + Nullable<nsTArray<RefPtr<TestInterface>>>&); + void PassCastableObjectSequence( + const Sequence<OwningNonNull<TestInterface>>&); + void PassNullableCastableObjectSequence( + const Sequence<RefPtr<TestInterface>>&); + void PassCastableObjectNullableSequence( + const Nullable<Sequence<OwningNonNull<TestInterface>>>&); + void PassNullableCastableObjectNullableSequence( + const Nullable<Sequence<RefPtr<TestInterface>>>&); + void PassOptionalSequence(const Optional<Sequence<int32_t>>&); + void PassOptionalSequenceWithDefaultValue(const Sequence<int32_t>&); + void PassOptionalNullableSequence( + const Optional<Nullable<Sequence<int32_t>>>&); + void PassOptionalNullableSequenceWithDefaultValue( + const Nullable<Sequence<int32_t>>&); + void PassOptionalNullableSequenceWithDefaultValue2( + const Nullable<Sequence<int32_t>>&); + void PassOptionalObjectSequence( + const Optional<Sequence<OwningNonNull<TestInterface>>>&); + void PassExternalInterfaceSequence( + const Sequence<RefPtr<TestExternalInterface>>&); + void PassNullableExternalInterfaceSequence( + const Sequence<RefPtr<TestExternalInterface>>&); void ReceiveStringSequence(nsTArray<nsString>&); void PassStringSequence(const Sequence<nsString>&); void ReceiveByteStringSequence(nsTArray<nsCString>&); void PassByteStringSequence(const Sequence<nsCString>&); void ReceiveAnySequence(JSContext*, nsTArray<JS::Value>&); - void ReceiveNullableAnySequence(JSContext*, Nullable<nsTArray<JS::Value> >&); - void ReceiveAnySequenceSequence(JSContext*, nsTArray<nsTArray<JS::Value> >&); + void ReceiveNullableAnySequence(JSContext*, Nullable<nsTArray<JS::Value>>&); + void ReceiveAnySequenceSequence(JSContext*, nsTArray<nsTArray<JS::Value>>&); void ReceiveObjectSequence(JSContext*, nsTArray<JSObject*>&); void ReceiveNullableObjectSequence(JSContext*, nsTArray<JSObject*>&); - void PassSequenceOfSequences(const Sequence< Sequence<int32_t> >&); - void PassSequenceOfSequencesOfSequences(const Sequence<Sequence<Sequence<int32_t>>>&); - void ReceiveSequenceOfSequences(nsTArray< nsTArray<int32_t> >&); - void ReceiveSequenceOfSequencesOfSequences(nsTArray<nsTArray<nsTArray<int32_t>>>&); + void PassSequenceOfSequences(const Sequence<Sequence<int32_t>>&); + void PassSequenceOfSequencesOfSequences( + const Sequence<Sequence<Sequence<int32_t>>>&); + void ReceiveSequenceOfSequences(nsTArray<nsTArray<int32_t>>&); + void ReceiveSequenceOfSequencesOfSequences( + nsTArray<nsTArray<nsTArray<int32_t>>>&); // Record types - void PassRecord(const Record<nsString, int32_t> &); - void PassNullableRecord(const Nullable< Record<nsString, int32_t> >&); - void PassRecordOfNullableInts(const Record<nsString, Nullable<int32_t> >&); - void PassOptionalRecordOfNullableInts(const Optional<Record<nsString, Nullable<int32_t> > > &); - void PassOptionalNullableRecordOfNullableInts(const Optional<Nullable<Record<nsString, Nullable<int32_t> > > > &); - void PassCastableObjectRecord(const Record<nsString, OwningNonNull<TestInterface> >&); - void PassNullableCastableObjectRecord(const Record<nsString, RefPtr<TestInterface> > &); - void PassCastableObjectNullableRecord(const Nullable< Record<nsString, OwningNonNull<TestInterface> > >&); - void PassNullableCastableObjectNullableRecord(const Nullable< Record<nsString, RefPtr<TestInterface> > >&); - void PassOptionalRecord(const Optional<Record<nsString, int32_t> >&); - void PassOptionalNullableRecord(const Optional<Nullable<Record<nsString, int32_t> > >&); - void PassOptionalNullableRecordWithDefaultValue(const Nullable< Record<nsString, int32_t> >&); - void PassOptionalObjectRecord(const Optional<Record<nsString, OwningNonNull<TestInterface> > >&); - void PassExternalInterfaceRecord(const Record<nsString, RefPtr<TestExternalInterface> >&); - void PassNullableExternalInterfaceRecord(const Record<nsString, RefPtr<TestExternalInterface> >&); + void PassRecord(const Record<nsString, int32_t>&); + void PassNullableRecord(const Nullable<Record<nsString, int32_t>>&); + void PassRecordOfNullableInts(const Record<nsString, Nullable<int32_t>>&); + void PassOptionalRecordOfNullableInts( + const Optional<Record<nsString, Nullable<int32_t>>>&); + void PassOptionalNullableRecordOfNullableInts( + const Optional<Nullable<Record<nsString, Nullable<int32_t>>>>&); + void PassCastableObjectRecord( + const Record<nsString, OwningNonNull<TestInterface>>&); + void PassNullableCastableObjectRecord( + const Record<nsString, RefPtr<TestInterface>>&); + void PassCastableObjectNullableRecord( + const Nullable<Record<nsString, OwningNonNull<TestInterface>>>&); + void PassNullableCastableObjectNullableRecord( + const Nullable<Record<nsString, RefPtr<TestInterface>>>&); + void PassOptionalRecord(const Optional<Record<nsString, int32_t>>&); + void PassOptionalNullableRecord( + const Optional<Nullable<Record<nsString, int32_t>>>&); + void PassOptionalNullableRecordWithDefaultValue( + const Nullable<Record<nsString, int32_t>>&); + void PassOptionalObjectRecord( + const Optional<Record<nsString, OwningNonNull<TestInterface>>>&); + void PassExternalInterfaceRecord( + const Record<nsString, RefPtr<TestExternalInterface>>&); + void PassNullableExternalInterfaceRecord( + const Record<nsString, RefPtr<TestExternalInterface>>&); void PassStringRecord(const Record<nsString, nsString>&); void PassByteStringRecord(const Record<nsString, nsCString>&); - void PassRecordOfRecords(const Record<nsString, Record<nsString, int32_t> >&); + void PassRecordOfRecords(const Record<nsString, Record<nsString, int32_t>>&); void ReceiveRecord(Record<nsString, int32_t>&); void ReceiveNullableRecord(Nullable<Record<nsString, int32_t>>&); void ReceiveRecordOfNullableInts(Record<nsString, Nullable<int32_t>>&); - void ReceiveNullableRecordOfNullableInts(Nullable<Record<nsString, Nullable<int32_t>>>&); + void ReceiveNullableRecordOfNullableInts( + Nullable<Record<nsString, Nullable<int32_t>>>&); void ReceiveRecordOfRecords(Record<nsString, Record<nsString, int32_t>>&); void ReceiveAnyRecord(JSContext*, Record<nsString, JS::Value>&); // Typed array types void PassArrayBuffer(const ArrayBuffer&); void PassNullableArrayBuffer(const Nullable<ArrayBuffer>&); void PassOptionalArrayBuffer(const Optional<ArrayBuffer>&); - void PassOptionalNullableArrayBuffer(const Optional<Nullable<ArrayBuffer> >&); - void PassOptionalNullableArrayBufferWithDefaultValue(const Nullable<ArrayBuffer>&); + void PassOptionalNullableArrayBuffer(const Optional<Nullable<ArrayBuffer>>&); + void PassOptionalNullableArrayBufferWithDefaultValue( + const Nullable<ArrayBuffer>&); void PassArrayBufferView(const ArrayBufferView&); void PassInt8Array(const Int8Array&); void PassInt16Array(const Int16Array&); void PassInt32Array(const Int32Array&); void PassUint8Array(const Uint8Array&); void PassUint16Array(const Uint16Array&); void PassUint32Array(const Uint32Array&); void PassUint8ClampedArray(const Uint8ClampedArray&); void PassFloat32Array(const Float32Array&); void PassFloat64Array(const Float64Array&); void PassSequenceOfArrayBuffers(const Sequence<ArrayBuffer>&); - void PassSequenceOfNullableArrayBuffers(const Sequence<Nullable<ArrayBuffer> >&); + void PassSequenceOfNullableArrayBuffers( + const Sequence<Nullable<ArrayBuffer>>&); void PassRecordOfArrayBuffers(const Record<nsString, ArrayBuffer>&); - void PassRecordOfNullableArrayBuffers(const Record<nsString, Nullable<ArrayBuffer> >&); + void PassRecordOfNullableArrayBuffers( + const Record<nsString, Nullable<ArrayBuffer>>&); void PassVariadicTypedArray(const Sequence<Float32Array>&); - void PassVariadicNullableTypedArray(const Sequence<Nullable<Float32Array> >&); + void PassVariadicNullableTypedArray(const Sequence<Nullable<Float32Array>>&); void ReceiveUint8Array(JSContext*, JS::MutableHandle<JSObject*>); void SetUint8ArrayAttr(const Uint8Array&); void GetUint8ArrayAttr(JSContext*, JS::MutableHandle<JSObject*>); // DOMString types void PassString(const nsAString&); void PassNullableString(const nsAString&); void PassOptionalString(const Optional<nsAString>&); @@ -536,115 +574,137 @@ public: void PassVariadicUSVS(const Sequence<nsString>&); void ReceiveUSVS(DOMString&); // Enumerated types void PassEnum(TestEnum); void PassNullableEnum(const Nullable<TestEnum>&); void PassOptionalEnum(const Optional<TestEnum>&); void PassEnumWithDefault(TestEnum); - void PassOptionalNullableEnum(const Optional<Nullable<TestEnum> >&); + void PassOptionalNullableEnum(const Optional<Nullable<TestEnum>>&); void PassOptionalNullableEnumWithDefaultValue(const Nullable<TestEnum>&); void PassOptionalNullableEnumWithDefaultValue2(const Nullable<TestEnum>&); TestEnum ReceiveEnum(); Nullable<TestEnum> ReceiveNullableEnum(); TestEnum EnumAttribute(); TestEnum ReadonlyEnumAttribute(); void SetEnumAttribute(TestEnum); // Callback types void PassCallback(TestCallback&); void PassNullableCallback(TestCallback*); - void PassOptionalCallback(const Optional<OwningNonNull<TestCallback> >&); - void PassOptionalNullableCallback(const Optional<RefPtr<TestCallback> >&); + void PassOptionalCallback(const Optional<OwningNonNull<TestCallback>>&); + void PassOptionalNullableCallback(const Optional<RefPtr<TestCallback>>&); void PassOptionalNullableCallbackWithDefaultValue(TestCallback*); already_AddRefed<TestCallback> ReceiveCallback(); already_AddRefed<TestCallback> ReceiveNullableCallback(); void PassNullableTreatAsNullCallback(TestTreatAsNullCallback*); - void PassOptionalNullableTreatAsNullCallback(const Optional<RefPtr<TestTreatAsNullCallback> >&); - void PassOptionalNullableTreatAsNullCallbackWithDefaultValue(TestTreatAsNullCallback*); + void PassOptionalNullableTreatAsNullCallback( + const Optional<RefPtr<TestTreatAsNullCallback>>&); + void PassOptionalNullableTreatAsNullCallbackWithDefaultValue( + TestTreatAsNullCallback*); void SetTreatAsNullCallback(TestTreatAsNullCallback&); already_AddRefed<TestTreatAsNullCallback> TreatAsNullCallback(); void SetNullableTreatAsNullCallback(TestTreatAsNullCallback*); already_AddRefed<TestTreatAsNullCallback> GetNullableTreatAsNullCallback(); - void ForceCallbackGeneration(TestIntegerReturn&, - TestNullableIntegerReturn&, - TestBooleanReturn&, - TestFloatReturn&, - TestStringReturn&, - TestEnumReturn&, - TestInterfaceReturn&, - TestNullableInterfaceReturn&, - TestExternalInterfaceReturn&, - TestNullableExternalInterfaceReturn&, - TestCallbackInterfaceReturn&, - TestNullableCallbackInterfaceReturn&, - TestCallbackReturn&, - TestNullableCallbackReturn&, - TestObjectReturn&, - TestNullableObjectReturn&, - TestTypedArrayReturn&, - TestNullableTypedArrayReturn&, - TestSequenceReturn&, - TestNullableSequenceReturn&, - TestIntegerArguments&, - TestInterfaceArguments&, - TestStringEnumArguments&, - TestObjectArguments&, - TestOptionalArguments&); + void ForceCallbackGeneration( + TestIntegerReturn&, TestNullableIntegerReturn&, TestBooleanReturn&, + TestFloatReturn&, TestStringReturn&, TestEnumReturn&, + TestInterfaceReturn&, TestNullableInterfaceReturn&, + TestExternalInterfaceReturn&, TestNullableExternalInterfaceReturn&, + TestCallbackInterfaceReturn&, TestNullableCallbackInterfaceReturn&, + TestCallbackReturn&, TestNullableCallbackReturn&, TestObjectReturn&, + TestNullableObjectReturn&, TestTypedArrayReturn&, + TestNullableTypedArrayReturn&, TestSequenceReturn&, + TestNullableSequenceReturn&, TestIntegerArguments&, + TestInterfaceArguments&, TestStringEnumArguments&, TestObjectArguments&, + TestOptionalArguments&); // Any types void PassAny(JSContext*, JS::Handle<JS::Value>); void PassVariadicAny(JSContext*, const Sequence<JS::Value>&); void PassOptionalAny(JSContext*, JS::Handle<JS::Value>); void PassAnyDefaultNull(JSContext*, JS::Handle<JS::Value>); void PassSequenceOfAny(JSContext*, const Sequence<JS::Value>&); - void PassNullableSequenceOfAny(JSContext*, const Nullable<Sequence<JS::Value> >&); - void PassOptionalSequenceOfAny(JSContext*, const Optional<Sequence<JS::Value> >&); - void PassOptionalNullableSequenceOfAny(JSContext*, const Optional<Nullable<Sequence<JS::Value> > >&); - void PassOptionalSequenceOfAnyWithDefaultValue(JSContext*, const Nullable<Sequence<JS::Value> >&); - void PassSequenceOfSequenceOfAny(JSContext*, const Sequence<Sequence<JS::Value> >&); - void PassSequenceOfNullableSequenceOfAny(JSContext*, const Sequence<Nullable<Sequence<JS::Value> > >&); - void PassNullableSequenceOfNullableSequenceOfAny(JSContext*, const Nullable<Sequence<Nullable<Sequence<JS::Value> > > >&); - void PassOptionalNullableSequenceOfNullableSequenceOfAny(JSContext*, const Optional<Nullable<Sequence<Nullable<Sequence<JS::Value> > > > >&); + void PassNullableSequenceOfAny(JSContext*, + const Nullable<Sequence<JS::Value>>&); + void PassOptionalSequenceOfAny(JSContext*, + const Optional<Sequence<JS::Value>>&); + void PassOptionalNullableSequenceOfAny( + JSContext*, const Optional<Nullable<Sequence<JS::Value>>>&); + void PassOptionalSequenceOfAnyWithDefaultValue( + JSContext*, const Nullable<Sequence<JS::Value>>&); + void PassSequenceOfSequenceOfAny(JSContext*, + const Sequence<Sequence<JS::Value>>&); + void PassSequenceOfNullableSequenceOfAny( + JSContext*, const Sequence<Nullable<Sequence<JS::Value>>>&); + void PassNullableSequenceOfNullableSequenceOfAny( + JSContext*, const Nullable<Sequence<Nullable<Sequence<JS::Value>>>>&); + void PassOptionalNullableSequenceOfNullableSequenceOfAny( + JSContext*, + const Optional<Nullable<Sequence<Nullable<Sequence<JS::Value>>>>>&); void PassRecordOfAny(JSContext*, const Record<nsString, JS::Value>&); - void PassNullableRecordOfAny(JSContext*, const Nullable<Record<nsString, JS::Value> >&); - void PassOptionalRecordOfAny(JSContext*, const Optional<Record<nsString, JS::Value> >&); - void PassOptionalNullableRecordOfAny(JSContext*, const Optional<Nullable<Record<nsString, JS::Value> > >&); - void PassOptionalRecordOfAnyWithDefaultValue(JSContext*, const Nullable<Record<nsString, JS::Value> >&); - void PassRecordOfRecordOfAny(JSContext*, const Record<nsString, Record<nsString, JS::Value> >&); - void PassRecordOfNullableRecordOfAny(JSContext*, const Record<nsString, Nullable<Record<nsString, JS::Value> > >&); - void PassNullableRecordOfNullableRecordOfAny(JSContext*, const Nullable<Record<nsString, Nullable<Record<nsString, JS::Value> > > >&); - void PassOptionalNullableRecordOfNullableRecordOfAny(JSContext*, const Optional<Nullable<Record<nsString, Nullable<Record<nsString, JS::Value>>>>>&); - void PassOptionalNullableRecordOfNullableSequenceOfAny(JSContext*, const Optional<Nullable<Record<nsString, Nullable<Sequence<JS::Value>>>>>&); - void PassOptionalNullableSequenceOfNullableRecordOfAny(JSContext*, const Optional<Nullable<Sequence<Nullable<Record<nsString, JS::Value>>>>>&); + void PassNullableRecordOfAny(JSContext*, + const Nullable<Record<nsString, JS::Value>>&); + void PassOptionalRecordOfAny(JSContext*, + const Optional<Record<nsString, JS::Value>>&); + void PassOptionalNullableRecordOfAny( + JSContext*, const Optional<Nullable<Record<nsString, JS::Value>>>&); + void PassOptionalRecordOfAnyWithDefaultValue( + JSContext*, const Nullable<Record<nsString, JS::Value>>&); + void PassRecordOfRecordOfAny( + JSContext*, const Record<nsString, Record<nsString, JS::Value>>&); + void PassRecordOfNullableRecordOfAny( + JSContext*, + const Record<nsString, Nullable<Record<nsString, JS::Value>>>&); + void PassNullableRecordOfNullableRecordOfAny( + JSContext*, + const Nullable<Record<nsString, Nullable<Record<nsString, JS::Value>>>>&); + void PassOptionalNullableRecordOfNullableRecordOfAny( + JSContext*, + const Optional< + Nullable<Record<nsString, Nullable<Record<nsString, JS::Value>>>>>&); + void PassOptionalNullableRecordOfNullableSequenceOfAny( + JSContext*, + const Optional< + Nullable<Record<nsString, Nullable<Sequence<JS::Value>>>>>&); + void PassOptionalNullableSequenceOfNullableRecordOfAny( + JSContext*, + const Optional< + Nullable<Sequence<Nullable<Record<nsString, JS::Value>>>>>&); void ReceiveAny(JSContext*, JS::MutableHandle<JS::Value>); // object types void PassObject(JSContext*, JS::Handle<JSObject*>); void PassVariadicObject(JSContext*, const Sequence<JSObject*>&); void PassNullableObject(JSContext*, JS::Handle<JSObject*>); void PassVariadicNullableObject(JSContext*, const Sequence<JSObject*>&); - void PassOptionalObject(JSContext*, const Optional<JS::Handle<JSObject*> >&); - void PassOptionalNullableObject(JSContext*, const Optional<JS::Handle<JSObject*> >&); - void PassOptionalNullableObjectWithDefaultValue(JSContext*, JS::Handle<JSObject*>); + void PassOptionalObject(JSContext*, const Optional<JS::Handle<JSObject*>>&); + void PassOptionalNullableObject(JSContext*, + const Optional<JS::Handle<JSObject*>>&); + void PassOptionalNullableObjectWithDefaultValue(JSContext*, + JS::Handle<JSObject*>); void PassSequenceOfObject(JSContext*, const Sequence<JSObject*>&); void PassSequenceOfNullableObject(JSContext*, const Sequence<JSObject*>&); - void PassNullableSequenceOfObject(JSContext*, const Nullable<Sequence<JSObject*> >&); - void PassOptionalNullableSequenceOfNullableSequenceOfObject(JSContext*, const Optional<Nullable<Sequence<Nullable<Sequence<JSObject*> > > > >&); - void PassOptionalNullableSequenceOfNullableSequenceOfNullableObject(JSContext*, const Optional<Nullable<Sequence<Nullable<Sequence<JSObject*> > > > >&); + void PassNullableSequenceOfObject(JSContext*, + const Nullable<Sequence<JSObject*>>&); + void PassOptionalNullableSequenceOfNullableSequenceOfObject( + JSContext*, + const Optional<Nullable<Sequence<Nullable<Sequence<JSObject*>>>>>&); + void PassOptionalNullableSequenceOfNullableSequenceOfNullableObject( + JSContext*, + const Optional<Nullable<Sequence<Nullable<Sequence<JSObject*>>>>>&); void PassRecordOfObject(JSContext*, const Record<nsString, JSObject*>&); void ReceiveObject(JSContext*, JS::MutableHandle<JSObject*>); void ReceiveNullableObject(JSContext*, JS::MutableHandle<JSObject*>); // Union types void PassUnion(JSContext*, const ObjectOrLong& arg); - void PassUnionWithNullable(JSContext* cx, const ObjectOrNullOrLong& arg) - { + void PassUnionWithNullable(JSContext* cx, const ObjectOrNullOrLong& arg) { OwningObjectOrLong returnValue; if (arg.IsNull()) { } else if (arg.IsObject()) { JS::Rooted<JSObject*> obj(cx, arg.GetAsObject()); JS_GetClass(obj); returnValue.SetAsObject() = obj; } else { int32_t i = arg.GetAsLong(); @@ -678,30 +738,35 @@ public: void PassUnion24(const ImageDataOrNullSequenceOrLong&); void PassUnion25(const ImageDataSequenceSequenceOrLong&); void PassUnion26(const ImageDataOrNullSequenceSequenceOrLong&); void PassUnion27(const StringSequenceOrEventInit&); void PassUnion28(const EventInitOrStringSequence&); void PassUnionWithCallback(const EventHandlerNonNullOrNullOrLong& arg); void PassUnionWithByteString(const ByteStringOrLong&); void PassUnionWithRecord(const StringStringRecordOrString&); - void PassUnionWithRecordAndSequence(const StringStringRecordOrStringSequence&); - void PassUnionWithSequenceAndRecord(const StringSequenceOrStringStringRecord&); + void PassUnionWithRecordAndSequence( + const StringStringRecordOrStringSequence&); + void PassUnionWithSequenceAndRecord( + const StringSequenceOrStringStringRecord&); void PassUnionWithUSVS(const USVStringOrLong&); #endif void PassNullableUnion(JSContext*, const Nullable<ObjectOrLong>&); void PassOptionalUnion(JSContext*, const Optional<ObjectOrLong>&); - void PassOptionalNullableUnion(JSContext*, const Optional<Nullable<ObjectOrLong> >&); - void PassOptionalNullableUnionWithDefaultValue(JSContext*, const Nullable<ObjectOrLong>&); - //void PassUnionWithInterfaces(const TestInterfaceOrTestExternalInterface& arg); - //void PassUnionWithInterfacesAndNullable(const TestInterfaceOrNullOrTestExternalInterface& arg); + void PassOptionalNullableUnion(JSContext*, + const Optional<Nullable<ObjectOrLong>>&); + void PassOptionalNullableUnionWithDefaultValue(JSContext*, + const Nullable<ObjectOrLong>&); + // void PassUnionWithInterfaces(const TestInterfaceOrTestExternalInterface& + // arg); void PassUnionWithInterfacesAndNullable(const + // TestInterfaceOrNullOrTestExternalInterface& arg); void PassUnionWithArrayBuffer(const ArrayBufferOrLong&); void PassUnionWithString(JSContext*, const StringOrObject&); void PassUnionWithEnum(JSContext*, const SupportedTypeOrObject&); - //void PassUnionWithCallback(JSContext*, const TestCallbackOrLong&); + // void PassUnionWithCallback(JSContext*, const TestCallbackOrLong&); void PassUnionWithObject(JSContext*, const ObjectOrLong&); void PassUnionWithDefaultValue1(const DoubleOrString& arg); void PassUnionWithDefaultValue2(const DoubleOrString& arg); void PassUnionWithDefaultValue3(const DoubleOrString& arg); void PassUnionWithDefaultValue4(const FloatOrString& arg); void PassUnionWithDefaultValue5(const FloatOrString& arg); void PassUnionWithDefaultValue6(const FloatOrString& arg); @@ -723,65 +788,90 @@ public: void PassUnionWithDefaultValue22(const DoubleOrUSVString& arg); void PassNullableUnionWithDefaultValue1(const Nullable<DoubleOrString>& arg); void PassNullableUnionWithDefaultValue2(const Nullable<DoubleOrString>& arg); void PassNullableUnionWithDefaultValue3(const Nullable<DoubleOrString>& arg); void PassNullableUnionWithDefaultValue4(const Nullable<FloatOrString>& arg); void PassNullableUnionWithDefaultValue5(const Nullable<FloatOrString>& arg); void PassNullableUnionWithDefaultValue6(const Nullable<FloatOrString>& arg); - void PassNullableUnionWithDefaultValue7(const Nullable<UnrestrictedDoubleOrString>& arg); - void PassNullableUnionWithDefaultValue8(const Nullable<UnrestrictedDoubleOrString>& arg); - void PassNullableUnionWithDefaultValue9(const Nullable<UnrestrictedDoubleOrString>& arg); - void PassNullableUnionWithDefaultValue10(const Nullable<UnrestrictedFloatOrString>& arg); - void PassNullableUnionWithDefaultValue11(const Nullable<UnrestrictedFloatOrString>& arg); - void PassNullableUnionWithDefaultValue12(const Nullable<UnrestrictedFloatOrString>& arg); - void PassNullableUnionWithDefaultValue13(const Nullable<DoubleOrByteString>& arg); - void PassNullableUnionWithDefaultValue14(const Nullable<DoubleOrByteString>& arg); - void PassNullableUnionWithDefaultValue15(const Nullable<DoubleOrByteString>& arg); - void PassNullableUnionWithDefaultValue16(const Nullable<DoubleOrByteString>& arg); - void PassNullableUnionWithDefaultValue17(const Nullable<DoubleOrSupportedType>& arg); - void PassNullableUnionWithDefaultValue18(const Nullable<DoubleOrSupportedType>& arg); - void PassNullableUnionWithDefaultValue19(const Nullable<DoubleOrSupportedType>& arg); - void PassNullableUnionWithDefaultValue20(const Nullable<DoubleOrSupportedType>& arg); - void PassNullableUnionWithDefaultValue21(const Nullable<DoubleOrUSVString>& arg); - void PassNullableUnionWithDefaultValue22(const Nullable<DoubleOrUSVString>& arg); - void PassNullableUnionWithDefaultValue23(const Nullable<DoubleOrUSVString>& arg); - void PassNullableUnionWithDefaultValue24(const Nullable<DoubleOrUSVString>& arg); + void PassNullableUnionWithDefaultValue7( + const Nullable<UnrestrictedDoubleOrString>& arg); + void PassNullableUnionWithDefaultValue8( + const Nullable<UnrestrictedDoubleOrString>& arg); + void PassNullableUnionWithDefaultValue9( + const Nullable<UnrestrictedDoubleOrString>& arg); + void PassNullableUnionWithDefaultValue10( + const Nullable<UnrestrictedFloatOrString>& arg); + void PassNullableUnionWithDefaultValue11( + const Nullable<UnrestrictedFloatOrString>& arg); + void PassNullableUnionWithDefaultValue12( + const Nullable<UnrestrictedFloatOrString>& arg); + void PassNullableUnionWithDefaultValue13( + const Nullable<DoubleOrByteString>& arg); + void PassNullableUnionWithDefaultValue14( + const Nullable<DoubleOrByteString>& arg); + void PassNullableUnionWithDefaultValue15( + const Nullable<DoubleOrByteString>& arg); + void PassNullableUnionWithDefaultValue16( + const Nullable<DoubleOrByteString>& arg); + void PassNullableUnionWithDefaultValue17( + const Nullable<DoubleOrSupportedType>& arg); + void PassNullableUnionWithDefaultValue18( + const Nullable<DoubleOrSupportedType>& arg); + void PassNullableUnionWithDefaultValue19( + const Nullable<DoubleOrSupportedType>& arg); + void PassNullableUnionWithDefaultValue20( + const Nullable<DoubleOrSupportedType>& arg); + void PassNullableUnionWithDefaultValue21( + const Nullable<DoubleOrUSVString>& arg); + void PassNullableUnionWithDefaultValue22( + const Nullable<DoubleOrUSVString>& arg); + void PassNullableUnionWithDefaultValue23( + const Nullable<DoubleOrUSVString>& arg); + void PassNullableUnionWithDefaultValue24( + const Nullable<DoubleOrUSVString>& arg); - void PassSequenceOfUnions(const Sequence<OwningCanvasPatternOrCanvasGradient>&); + void PassSequenceOfUnions( + const Sequence<OwningCanvasPatternOrCanvasGradient>&); void PassSequenceOfUnions2(JSContext*, const Sequence<OwningObjectOrLong>&); void PassVariadicUnion(const Sequence<OwningCanvasPatternOrCanvasGradient>&); - void PassSequenceOfNullableUnions(const Sequence<Nullable<OwningCanvasPatternOrCanvasGradient>>&); - void PassVariadicNullableUnion(const Sequence<Nullable<OwningCanvasPatternOrCanvasGradient>>&); - void PassRecordOfUnions(const Record<nsString, OwningCanvasPatternOrCanvasGradient>&); - void PassRecordOfUnions2(JSContext*, const Record<nsString, OwningObjectOrLong>&); + void PassSequenceOfNullableUnions( + const Sequence<Nullable<OwningCanvasPatternOrCanvasGradient>>&); + void PassVariadicNullableUnion( + const Sequence<Nullable<OwningCanvasPatternOrCanvasGradient>>&); + void PassRecordOfUnions( + const Record<nsString, OwningCanvasPatternOrCanvasGradient>&); + void PassRecordOfUnions2(JSContext*, + const Record<nsString, OwningObjectOrLong>&); void ReceiveUnion(OwningCanvasPatternOrCanvasGradient&); void ReceiveUnion2(JSContext*, OwningObjectOrLong&); void ReceiveUnionContainingNull(OwningCanvasPatternOrNullOrCanvasGradient&); void ReceiveNullableUnion(Nullable<OwningCanvasPatternOrCanvasGradient>&); void ReceiveNullableUnion2(JSContext*, Nullable<OwningObjectOrLong>&); void GetWritableUnion(OwningCanvasPatternOrCanvasGradient&); void SetWritableUnion(const CanvasPatternOrCanvasGradient&); - void GetWritableUnionContainingNull(OwningCanvasPatternOrNullOrCanvasGradient&); - void SetWritableUnionContainingNull(const CanvasPatternOrNullOrCanvasGradient&); + void GetWritableUnionContainingNull( + OwningCanvasPatternOrNullOrCanvasGradient&); + void SetWritableUnionContainingNull( + const CanvasPatternOrNullOrCanvasGradient&); void GetWritableNullableUnion(Nullable<OwningCanvasPatternOrCanvasGradient>&); void SetWritableNullableUnion(const Nullable<CanvasPatternOrCanvasGradient>&); // Date types void PassDate(Date); void PassNullableDate(const Nullable<Date>&); void PassOptionalDate(const Optional<Date>&); - void PassOptionalNullableDate(const Optional<Nullable<Date> >&); + void PassOptionalNullableDate(const Optional<Nullable<Date>>&); void PassOptionalNullableDateWithDefaultValue(const Nullable<Date>&); void PassDateSequence(const Sequence<Date>&); void PassDateRecord(const Record<nsString, Date>&); - void PassNullableDateSequence(const Sequence<Nullable<Date> >&); + void PassNullableDateSequence(const Sequence<Nullable<Date>>&); Date ReceiveDate(); Nullable<Date> ReceiveNullableDate(); // Promise types void PassPromise(Promise&); void PassOptionalPromise(const Optional<OwningNonNull<Promise>>&); void PassPromiseSequence(const Sequence<OwningNonNull<Promise>>&); void PassPromiseRecord(const Record<nsString, RefPtr<Promise>>&); @@ -838,17 +928,18 @@ public: static bool StaticAttribute(const GlobalObject&); static void SetStaticAttribute(const GlobalObject&, bool); static void Assert(const GlobalObject&, bool); // Deprecated static methods and attributes static int8_t StaticDeprecatedAttribute(const GlobalObject&); static void SetStaticDeprecatedAttribute(const GlobalObject&, int8_t); static void StaticDeprecatedMethod(const GlobalObject&); - static void StaticDeprecatedMethodWithContext(const GlobalObject&, const JS::Value&); + static void StaticDeprecatedMethodWithContext(const GlobalObject&, + const JS::Value&); // Overload resolution tests bool Overload1(TestInterface&); TestInterface* Overload1(const nsAString&, TestInterface&); void Overload2(TestInterface&); void Overload2(JSContext*, const Dict&); void Overload2(bool); void Overload2(const nsAString&); @@ -876,31 +967,31 @@ public: void Overload11(const nsAString&); void Overload12(int32_t); void Overload12(const Nullable<bool>&); void Overload13(const Nullable<int32_t>&); void Overload13(bool); void Overload14(const Optional<int32_t>&); void Overload14(TestInterface&); void Overload15(int32_t); - void Overload15(const Optional<NonNull<TestInterface> >&); + void Overload15(const Optional<NonNull<TestInterface>>&); void Overload16(int32_t); void Overload16(const Optional<TestInterface*>&); void Overload17(const Sequence<int32_t>&); void Overload17(const Record<nsString, int32_t>&); void Overload18(const Record<nsString, nsString>&); void Overload18(const Sequence<nsString>&); void Overload19(const Sequence<int32_t>&); void Overload19(JSContext*, const Dict&); void Overload20(JSContext*, const Dict&); void Overload20(const Sequence<int32_t>&); // Variadic handling void PassVariadicThirdArg(const nsAString&, int32_t, - const Sequence<OwningNonNull<TestInterface> >&); + const Sequence<OwningNonNull<TestInterface>>&); // Conditionally exposed methods/attributes bool Prefable1(); bool Prefable2(); bool Prefable3(); bool Prefable4(); bool Prefable5(); bool Prefable6(); @@ -1008,145 +1099,164 @@ public: void DontEnforceRangeOrClamp(int8_t); void DoEnforceRange(int8_t); void DoClamp(int8_t); void SetEnforcedByte(int8_t); int8_t EnforcedByte(); void SetClampedByte(int8_t); int8_t ClampedByte(); -private: + private: // We add signatures here that _could_ start matching if the codegen // got data types wrong. That way if it ever does we'll have a call // to these private deleted methods and compilation will fail. void SetReadonlyByte(int8_t) = delete; - template<typename T> + template <typename T> void SetWritableByte(T) = delete; - template<typename T> + template <typename T> void PassByte(T) = delete; void PassNullableByte(Nullable<int8_t>&) = delete; - template<typename T> + template <typename T> void PassOptionalByte(const Optional<T>&) = delete; - template<typename T> + template <typename T> void PassOptionalByteWithDefault(T) = delete; void PassVariadicByte(Sequence<int8_t>&) = delete; void SetReadonlyShort(int16_t) = delete; - template<typename T> + template <typename T> void SetWritableShort(T) = delete; - template<typename T> + template <typename T> void PassShort(T) = delete; - template<typename T> + template <typename T> void PassOptionalShort(const Optional<T>&) = delete; - template<typename T> + template <typename T> void PassOptionalShortWithDefault(T) = delete; void SetReadonlyLong(int32_t) = delete; - template<typename T> + template <typename T> void SetWritableLong(T) = delete; - template<typename T> + template <typename T> void PassLong(T) = delete; - template<typename T> + template <typename T> void PassOptionalLong(const Optional<T>&) = delete; - template<typename T> + template <typename T> void PassOptionalLongWithDefault(T) = delete; void SetReadonlyLongLong(int64_t) = delete; - template<typename T> + template <typename T> void SetWritableLongLong(T) = delete; - template<typename T> + template <typename T> void PassLongLong(T) = delete; - template<typename T> + template <typename T> void PassOptionalLongLong(const Optional<T>&) = delete; - template<typename T> + template <typename T> void PassOptionalLongLongWithDefault(T) = delete; void SetReadonlyOctet(uint8_t) = delete; - template<typename T> + template <typename T> void SetWritableOctet(T) = delete; - template<typename T> + template <typename T> void PassOctet(T) = delete; - template<typename T> + template <typename T> void PassOptionalOctet(const Optional<T>&) = delete; - template<typename T> + template <typename T> void PassOptionalOctetWithDefault(T) = delete; void SetReadonlyUnsignedShort(uint16_t) = delete; - template<typename T> + template <typename T> void SetWritableUnsignedShort(T) = delete; - template<typename T> + template <typename T> void PassUnsignedShort(T) = delete; - template<typename T> + template <typename T> void PassOptionalUnsignedShort(const Optional<T>&) = delete; - template<typename T> + template <typename T> void PassOptionalUnsignedShortWithDefault(T) = delete; void SetReadonlyUnsignedLong(uint32_t) = delete; - template<typename T> + template <typename T> void SetWritableUnsignedLong(T) = delete; - template<typename T> + template <typename T> void PassUnsignedLong(T) = delete; - template<typename T> + template <typename T> void PassOptionalUnsignedLong(const Optional<T>&) = delete; - template<typename T> + template <typename T> void PassOptionalUnsignedLongWithDefault(T) = delete; void SetReadonlyUnsignedLongLong(uint64_t) = delete; - template<typename T> + template <typename T> void SetWritableUnsignedLongLong(T) = delete; - template<typename T> + template <typename T> void PassUnsignedLongLong(T) = delete; - template<typename T> + template <typename T> void PassOptionalUnsignedLongLong(const Optional<T>&) = delete; - template<typename T> + template <typename T> void PassOptionalUnsignedLongLongWithDefault(T) = delete; // Enforce that only const things are passed for sequences - void PassSequence(Sequence<int32_t> &) = delete; - void PassNullableSequence(Nullable< Sequence<int32_t> >&) = delete; - void PassOptionalNullableSequenceWithDefaultValue(Nullable< Sequence<int32_t> >&) = delete; + void PassSequence(Sequence<int32_t>&) = delete; + void PassNullableSequence(Nullable<Sequence<int32_t>>&) = delete; + void PassOptionalNullableSequenceWithDefaultValue( + Nullable<Sequence<int32_t>>&) = delete; void PassSequenceOfAny(JSContext*, Sequence<JS::Value>&) = delete; - void PassNullableSequenceOfAny(JSContext*, Nullable<Sequence<JS::Value> >&) = delete; - void PassOptionalSequenceOfAny(JSContext*, Optional<Sequence<JS::Value> >&) = delete; - void PassOptionalNullableSequenceOfAny(JSContext*, Optional<Nullable<Sequence<JS::Value> > >&) = delete; - void PassOptionalSequenceOfAnyWithDefaultValue(JSContext*, Nullable<Sequence<JS::Value> >&) = delete; - void PassSequenceOfSequenceOfAny(JSContext*, Sequence<Sequence<JS::Value> >&) = delete; - void PassSequenceOfNullableSequenceOfAny(JSContext*, Sequence<Nullable<Sequence<JS::Value> > >&) = delete; - void PassNullableSequenceOfNullableSequenceOfAny(JSContext*, Nullable<Sequence<Nullable<Sequence<JS::Value> > > >&) = delete; - void PassOptionalNullableSequenceOfNullableSequenceOfAny(JSContext*, Optional<Nullable<Sequence<Nullable<Sequence<JS::Value> > > > >&) = delete; + void PassNullableSequenceOfAny(JSContext*, + Nullable<Sequence<JS::Value>>&) = delete; + void PassOptionalSequenceOfAny(JSContext*, + Optional<Sequence<JS::Value>>&) = delete; + void PassOptionalNullableSequenceOfAny( + JSContext*, Optional<Nullable<Sequence<JS::Value>>>&) = delete; + void PassOptionalSequenceOfAnyWithDefaultValue( + JSContext*, Nullable<Sequence<JS::Value>>&) = delete; + void PassSequenceOfSequenceOfAny(JSContext*, + Sequence<Sequence<JS::Value>>&) = delete; + void PassSequenceOfNullableSequenceOfAny( + JSContext*, Sequence<Nullable<Sequence<JS::Value>>>&) = delete; + void PassNullableSequenceOfNullableSequenceOfAny( + JSContext*, Nullable<Sequence<Nullable<Sequence<JS::Value>>>>&) = delete; + void PassOptionalNullableSequenceOfNullableSequenceOfAny( + JSContext*, + Optional<Nullable<Sequence<Nullable<Sequence<JS::Value>>>>>&) = delete; void PassSequenceOfObject(JSContext*, Sequence<JSObject*>&) = delete; void PassSequenceOfNullableObject(JSContext*, Sequence<JSObject*>&) = delete; - void PassOptionalNullableSequenceOfNullableSequenceOfObject(JSContext*, Optional<Nullable<Sequence<Nullable<Sequence<JSObject*> > > > >&) = delete; - void PassOptionalNullableSequenceOfNullableSequenceOfNullableObject(JSContext*, Optional<Nullable<Sequence<Nullable<Sequence<JSObject*> > > > >&) = delete; + void PassOptionalNullableSequenceOfNullableSequenceOfObject( + JSContext*, + Optional<Nullable<Sequence<Nullable<Sequence<JSObject*>>>>>&) = delete; + void PassOptionalNullableSequenceOfNullableSequenceOfNullableObject( + JSContext*, + Optional<Nullable<Sequence<Nullable<Sequence<JSObject*>>>>>&) = delete; // Enforce that only const things are passed for optional void PassOptionalByte(Optional<int8_t>&) = delete; - void PassOptionalNullableByte(Optional<Nullable<int8_t> >&) = delete; + void PassOptionalNullableByte(Optional<Nullable<int8_t>>&) = delete; void PassOptionalShort(Optional<int16_t>&) = delete; void PassOptionalLong(Optional<int32_t>&) = delete; void PassOptionalLongLong(Optional<int64_t>&) = delete; void PassOptionalOctet(Optional<uint8_t>&) = delete; void PassOptionalUnsignedShort(Optional<uint16_t>&) = delete; void PassOptionalUnsignedLong(Optional<uint32_t>&) = delete; void PassOptionalUnsignedLongLong(Optional<uint64_t>&) = delete; - void PassOptionalSelf(Optional<TestInterface*> &) = delete; - void PassOptionalNonNullSelf(Optional<NonNull<TestInterface> >&) = delete; + void PassOptionalSelf(Optional<TestInterface*>&) = delete; + void PassOptionalNonNullSelf(Optional<NonNull<TestInterface>>&) = delete; void PassOptionalOther(Optional<IndirectlyImplementedInterface*>&); - void PassOptionalNonNullOther(Optional<NonNull<IndirectlyImplementedInterface> >&); + void PassOptionalNonNullOther( + Optional<NonNull<IndirectlyImplementedInterface>>&); void PassOptionalExternal(Optional<TestExternalInterface*>&) = delete; void PassOptionalNonNullExternal(Optional<TestExternalInterface*>&) = delete; - void PassOptionalSequence(Optional<Sequence<int32_t> >&) = delete; - void PassOptionalNullableSequence(Optional<Nullable<Sequence<int32_t> > >&) = delete; - void PassOptionalObjectSequence(Optional<Sequence<OwningNonNull<TestInterface> > >&) = delete; + void PassOptionalSequence(Optional<Sequence<int32_t>>&) = delete; + void PassOptionalNullableSequence(Optional<Nullable<Sequence<int32_t>>>&) = + delete; + void PassOptionalObjectSequence( + Optional<Sequence<OwningNonNull<TestInterface>>>&) = delete; void PassOptionalArrayBuffer(Optional<ArrayBuffer>&) = delete; void PassOptionalNullableArrayBuffer(Optional<ArrayBuffer*>&) = delete; void PassOptionalEnum(Optional<TestEnum>&) = delete; - void PassOptionalCallback(JSContext*, Optional<OwningNonNull<TestCallback> >&) = delete; - void PassOptionalNullableCallback(JSContext*, Optional<RefPtr<TestCallback> >&) = delete; - void PassOptionalAny(Optional<JS::Handle<JS::Value> >&) = delete; + void PassOptionalCallback(JSContext*, + Optional<OwningNonNull<TestCallback>>&) = delete; + void PassOptionalNullableCallback(JSContext*, + Optional<RefPtr<TestCallback>>&) = delete; + void PassOptionalAny(Optional<JS::Handle<JS::Value>>&) = delete; // And test that string stuff is always const void PassString(nsAString&) = delete; void PassNullableString(nsAString&) = delete; void PassOptionalString(Optional<nsAString>&) = delete; void PassOptionalStringWithDefaultValue(nsAString&) = delete; void PassOptionalNullableString(Optional<nsAString>&) = delete; void PassOptionalNullableStringWithDefaultValue(nsAString&) = delete; @@ -1172,335 +1282,308 @@ private: // Make sure various nullable things are always const void PassNullableEnum(Nullable<TestEnum>&) = delete; // Make sure unions are always const void PassUnion(JSContext*, ObjectOrLong& arg) = delete; void PassUnionWithNullable(JSContext*, ObjectOrNullOrLong& arg) = delete; void PassNullableUnion(JSContext*, Nullable<ObjectOrLong>&) = delete; void PassOptionalUnion(JSContext*, Optional<ObjectOrLong>&) = delete; - void PassOptionalNullableUnion(JSContext*, Optional<Nullable<ObjectOrLong> >&) = delete; - void PassOptionalNullableUnionWithDefaultValue(JSContext*, Nullable<ObjectOrLong>&) = delete; + void PassOptionalNullableUnion(JSContext*, + Optional<Nullable<ObjectOrLong>>&) = delete; + void PassOptionalNullableUnionWithDefaultValue( + JSContext*, Nullable<ObjectOrLong>&) = delete; // Make sure various date stuff is const as needed void PassNullableDate(Nullable<Date>&) = delete; void PassOptionalDate(Optional<Date>&) = delete; - void PassOptionalNullableDate(Optional<Nullable<Date> >&) = delete; + void PassOptionalNullableDate(Optional<Nullable<Date>>&) = delete; void PassOptionalNullableDateWithDefaultValue(Nullable<Date>&) = delete; void PassDateSequence(Sequence<Date>&) = delete; - void PassNullableDateSequence(Sequence<Nullable<Date> >&) = delete; + void PassNullableDateSequence(Sequence<Nullable<Date>>&) = delete; // Make sure variadics are const as needed void PassVariadicAny(JSContext*, Sequence<JS::Value>&) = delete; void PassVariadicObject(JSContext*, Sequence<JSObject*>&) = delete; void PassVariadicNullableObject(JSContext*, Sequence<JSObject*>&) = delete; // Ensure NonNull does not leak in void PassSelf(NonNull<TestInterface>&) = delete; void PassSelf(OwningNonNull<TestInterface>&) = delete; void PassSelf(const NonNull<TestInterface>&) = delete; void PassSelf(const OwningNonNull<TestInterface>&) = delete; void PassOther(NonNull<IndirectlyImplementedInterface>&) = delete; void PassOther(const NonNull<IndirectlyImplementedInterface>&) = delete; void PassOther(OwningNonNull<IndirectlyImplementedInterface>&) = delete; void PassOther(const OwningNonNull<IndirectlyImplementedInterface>&) = delete; void PassCallbackInterface(OwningNonNull<TestCallbackInterface>&) = delete; - void PassCallbackInterface(const OwningNonNull<TestCallbackInterface>&) = delete; + void PassCallbackInterface(const OwningNonNull<TestCallbackInterface>&) = + delete; void PassCallbackInterface(NonNull<TestCallbackInterface>&) = delete; void PassCallbackInterface(const NonNull<TestCallbackInterface>&) = delete; void PassCallback(OwningNonNull<TestCallback>&) = delete; void PassCallback(const OwningNonNull<TestCallback>&) = delete; void PassCallback(NonNull<TestCallback>&) = delete; void PassCallback(const NonNull<TestCallback>&) = delete; void PassString(const NonNull<nsAString>&) = delete; void PassString(NonNull<nsAString>&) = delete; void PassString(const OwningNonNull<nsAString>&) = delete; void PassString(OwningNonNull<nsAString>&) = delete; }; -class TestIndexedGetterInterface : public nsISupports, - public nsWrapperCache -{ -public: +class TestIndexedGetterInterface : public nsISupports, public nsWrapperCache { + public: NS_DECL_ISUPPORTS // We need a GetParentObject to make binding codegen happy virtual nsISupports* GetParentObject(); uint32_t IndexedGetter(uint32_t, bool&); uint32_t IndexedGetter(uint32_t&) = delete; uint32_t Item(uint32_t&); uint32_t Item(uint32_t, bool&) = delete; uint32_t Length(); void LegacyCall(JS::Handle<JS::Value>); int32_t CachedAttr(); int32_t StoreInSlotAttr(); }; -class TestNamedGetterInterface : public nsISupports, - public nsWrapperCache -{ -public: +class TestNamedGetterInterface : public nsISupports, public nsWrapperCache { + public: NS_DECL_ISUPPORTS // We need a GetParentObject to make binding codegen happy virtual nsISupports* GetParentObject(); void NamedGetter(const nsAString&, bool&, nsAString&); void GetSupportedNames(nsTArray<nsString>&); }; -class TestIndexedGetterAndSetterAndNamedGetterInterface : public nsISupports, - public nsWrapperCache -{ -public: +class TestIndexedGetterAndSetterAndNamedGetterInterface + : public nsISupports, + public nsWrapperCache { + public: NS_DECL_ISUPPORTS // We need a GetParentObject to make binding codegen happy virtual nsISupports* GetParentObject(); void NamedGetter(const nsAString&, bool&, nsAString&); void GetSupportedNames(nsTArray<nsString>&); int32_t IndexedGetter(uint32_t, bool&); void IndexedSetter(uint32_t, int32_t); uint32_t Length(); }; class TestIndexedAndNamedGetterInterface : public nsISupports, - public nsWrapperCache -{ -public: + public nsWrapperCache { + public: NS_DECL_ISUPPORTS // We need a GetParentObject to make binding codegen happy virtual nsISupports* GetParentObject(); uint32_t IndexedGetter(uint32_t, bool&); void NamedGetter(const nsAString&, bool&, nsAString&); void NamedItem(const nsAString&, nsAString&); uint32_t Length(); void GetSupportedNames(nsTArray<nsString>&); }; -class TestIndexedSetterInterface : public nsISupports, - public nsWrapperCache -{ -public: +class TestIndexedSetterInterface : public nsISupports, public nsWrapperCache { + public: NS_DECL_ISUPPORTS // We need a GetParentObject to make binding codegen happy virtual nsISupports* GetParentObject(); void IndexedSetter(uint32_t, const nsAString&); void IndexedGetter(uint32_t, bool&, nsString&); uint32_t Length(); void SetItem(uint32_t, const nsAString&); }; -class TestNamedSetterInterface : public nsISupports, - public nsWrapperCache -{ -public: +class TestNamedSetterInterface : public nsISupports, public nsWrapperCache { + public: NS_DECL_ISUPPORTS // We need a GetParentObject to make binding codegen happy virtual nsISupports* GetParentObject(); void NamedSetter(const nsAString&, TestIndexedSetterInterface&); TestIndexedSetterInterface* NamedGetter(const nsAString&, bool&); void GetSupportedNames(nsTArray<nsString>&); }; class TestIndexedAndNamedSetterInterface : public nsISupports, - public nsWrapperCache -{ -public: + public nsWrapperCache { + public: NS_DECL_ISUPPORTS // We need a GetParentObject to make binding codegen happy virtual nsISupports* GetParentObject(); void IndexedSetter(uint32_t, TestIndexedSetterInterface&); TestIndexedSetterInterface* IndexedGetter(uint32_t, bool&); uint32_t Length(); void NamedSetter(const nsAString&, TestIndexedSetterInterface&); TestIndexedSetterInterface* NamedGetter(const nsAString&, bool&); void SetNamedItem(const nsAString&, TestIndexedSetterInterface&); void GetSupportedNames(nsTArray<nsString>&); }; -class TestIndexedAndNamedGetterAndSetterInterface : public TestIndexedSetterInterface -{ -public: +class TestIndexedAndNamedGetterAndSetterInterface + : public TestIndexedSetterInterface { + public: uint32_t IndexedGetter(uint32_t, bool&); uint32_t Item(uint32_t); void NamedGetter(const nsAString&, bool&, nsAString&); void NamedItem(const nsAString&, nsAString&); void IndexedSetter(uint32_t, int32_t&); void IndexedSetter(uint32_t, const nsAString&) = delete; void NamedSetter(const nsAString&, const nsAString&); void Stringify(nsAString&); uint32_t Length(); void GetSupportedNames(nsTArray<nsString>&); }; class TestCppKeywordNamedMethodsInterface : public nsISupports, - public nsWrapperCache -{ -public: + public nsWrapperCache { + public: NS_DECL_ISUPPORTS // We need a GetParentObject to make binding codegen happy virtual nsISupports* GetParentObject(); bool Continue(); bool Delete(); int32_t Volatile(); }; -class TestNamedDeleterInterface : public nsISupports, - public nsWrapperCache -{ -public: +class TestNamedDeleterInterface : public nsISupports, public nsWrapperCache { + public: NS_DECL_ISUPPORTS // We need a GetParentObject to make binding codegen happy virtual nsISupports* GetParentObject(); void NamedDeleter(const nsAString&, bool&); long NamedGetter(const nsAString&, bool&); void GetSupportedNames(nsTArray<nsString>&); }; class TestNamedDeleterWithRetvalInterface : public nsISupports, - public nsWrapperCache -{ -public: + public nsWrapperCache { + public: NS_DECL_ISUPPORTS // We need a GetParentObject to make binding codegen happy virtual nsISupports* GetParentObject(); bool NamedDeleter(const nsAString&, bool&); bool NamedDeleter(const nsAString&) = delete; long NamedGetter(const nsAString&, bool&); bool DelNamedItem(const nsAString&); bool DelNamedItem(const nsAString&, bool&) = delete; void GetSupportedNames(nsTArray<nsString>&); }; -class TestParentInterface : public nsISupports, - public nsWrapperCache -{ -public: +class TestParentInterface : public nsISupports, public nsWrapperCache { + public: NS_DECL_ISUPPORTS // We need a GetParentObject to make binding codegen happy virtual nsISupports* GetParentObject(); }; -class TestChildInterface : public TestParentInterface -{ -}; +class TestChildInterface : public TestParentInterface {}; -class TestDeprecatedInterface : public nsISupports, public nsWrapperCache -{ -public: +class TestDeprecatedInterface : public nsISupports, public nsWrapperCache { + public: NS_DECL_ISUPPORTS - static - already_AddRefed<TestDeprecatedInterface> - Constructor(const GlobalObject&, ErrorResult&); + static already_AddRefed<TestDeprecatedInterface> Constructor( + const GlobalObject&, ErrorResult&); static void AlsoDeprecated(const GlobalObject&); virtual nsISupports* GetParentObject(); }; -class TestInterfaceWithPromiseConstructorArg : public nsISupports, public nsWrapperCache -{ -public: +class TestInterfaceWithPromiseConstructorArg : public nsISupports, + public nsWrapperCache { + public: NS_DECL_ISUPPORTS - static - already_AddRefed<TestInterfaceWithPromiseConstructorArg> - Constructor(const GlobalObject&, Promise&, ErrorResult&); + static already_AddRefed<TestInterfaceWithPromiseConstructorArg> Constructor( + const GlobalObject&, Promise&, ErrorResult&); virtual nsISupports* GetParentObject(); }; -class TestSecureContextInterface : public nsISupports, public nsWrapperCache -{ -public: +class TestSecureContextInterface : public nsISupports, public nsWrapperCache { + public: NS_DECL_ISUPPORTS - static - already_AddRefed<TestSecureContextInterface> - Constructor(const GlobalObject&, ErrorResult&); + static already_AddRefed<TestSecureContextInterface> Constructor( + const GlobalObject&, ErrorResult&); static void AlsoSecureContext(const GlobalObject&); virtual nsISupports* GetParentObject(); }; class TestNamespace { -public: + public: static bool Foo(const GlobalObject&); static int32_t Bar(const GlobalObject&); static void Baz(const GlobalObject&); }; -class TestRenamedNamespace { -}; +class TestRenamedNamespace {}; -class TestProtoObjectHackedNamespace { -}; +class TestProtoObjectHackedNamespace {}; -class TestWorkerExposedInterface : public nsISupports, - public nsWrapperCache -{ -public: +class TestWorkerExposedInterface : public nsISupports, public nsWrapperCache { + public: NS_DECL_ISUPPORTS // We need a GetParentObject to make binding codegen happy nsISupports* GetParentObject(); void NeedsSubjectPrincipalMethod(Maybe<nsIPrincipal*>); bool NeedsSubjectPrincipalAttr(Maybe<nsIPrincipal*>); void SetNeedsSubjectPrincipalAttr(bool, Maybe<nsIPrincipal*>); void NeedsCallerTypeMethod(CallerType); bool NeedsCallerTypeAttr(CallerType); void SetNeedsCallerTypeAttr(bool, CallerType); void NeedsNonSystemSubjectPrincipalMethod(Maybe<nsIPrincipal*>); bool NeedsNonSystemSubjectPrincipalAttr(Maybe<nsIPrincipal*>); void SetNeedsNonSystemSubjectPrincipalAttr(bool, Maybe<nsIPrincipal*>); }; -class TestHTMLConstructorInterface : public nsGenericHTMLElement -{ -public: +class TestHTMLConstructorInterface : public nsGenericHTMLElement { + public: virtual nsISupports* GetParentObject(); }; -class TestCEReactionsInterface : public nsISupports, - public nsWrapperCache -{ -public: +class TestCEReactionsInterface : public nsISupports, public nsWrapperCache { + public: NS_DECL_ISUPPORTS // We need a GetParentObject and GetDocGroup to make binding codegen happy virtual nsISupports* GetParentObject(); DocGroup* GetDocGroup() const; int32_t Item(uint32_t); uint32_t Length() const; - int32_t IndexedGetter(uint32_t, bool &); + int32_t IndexedGetter(uint32_t, bool&); void IndexedSetter(uint32_t, int32_t); - void NamedDeleter(const nsAString&, bool &); - void NamedGetter(const nsAString&, bool &, nsString&); + void NamedDeleter(const nsAString&, bool&); + void NamedGetter(const nsAString&, bool&, nsString&); void NamedSetter(const nsAString&, const nsAString&); void GetSupportedNames(nsTArray<nsString>&); }; -} // namespace dom -} // namespace mozilla +} // namespace dom +} // namespace mozilla #endif /* TestBindingHeader_h */
--- a/dom/bindings/test/TestCImplementedInterface.h +++ b/dom/bindings/test/TestCImplementedInterface.h @@ -8,37 +8,30 @@ #ifndef TestCImplementedInterface_h #define TestCImplementedInterface_h #include "../TestJSImplGenBinding.h" namespace mozilla { namespace dom { -class TestCImplementedInterface : public TestJSImplInterface -{ -public: +class TestCImplementedInterface : public TestJSImplInterface { + public: TestCImplementedInterface(JS::Handle<JSObject*> aJSImpl, JS::Handle<JSObject*> aJSImplGlobal, nsIGlobalObject* aParent) - : TestJSImplInterface(aJSImpl, aJSImplGlobal, aParent) - {} + : TestJSImplInterface(aJSImpl, aJSImplGlobal, aParent) {} }; -class TestCImplementedInterface2 : public nsISupports, - public nsWrapperCache -{ -public: - explicit TestCImplementedInterface2(nsIGlobalObject* aParent) - {} +class TestCImplementedInterface2 : public nsISupports, public nsWrapperCache { + public: + explicit TestCImplementedInterface2(nsIGlobalObject* aParent) {} NS_DECL_CYCLE_COLLECTING_ISUPPORTS NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(TestCImplementedInterface2) // We need a GetParentObject to make binding codegen happy nsISupports* GetParentObject(); }; - +} // namespace dom +} // namespace mozilla -} // namespace dom -} // namespace mozilla - -#endif // TestCImplementedInterface_h +#endif // TestCImplementedInterface_h
--- a/dom/bindings/test/TestFunctions.cpp +++ b/dom/bindings/test/TestFunctions.cpp @@ -10,67 +10,55 @@ #include "mozilla/dom/WrapperCachedNonISupportsTestInterface.h" #include "nsStringBuffer.h" #include "mozITestInterfaceJS.h" #include "nsComponentManagerUtils.h" namespace mozilla { namespace dom { -/* static */ TestFunctions* -TestFunctions::Constructor(GlobalObject& aGlobal, ErrorResult& aRv) -{ +/* static */ TestFunctions* TestFunctions::Constructor(GlobalObject& aGlobal, + ErrorResult& aRv) { return new TestFunctions; } -/* static */ void -TestFunctions::ThrowUncatchableException(GlobalObject& aGlobal, - ErrorResult& aRv) -{ +/* static */ void TestFunctions::ThrowUncatchableException( + GlobalObject& aGlobal, ErrorResult& aRv) { aRv.ThrowUncatchableException(); } -/* static */ Promise* -TestFunctions::PassThroughPromise(GlobalObject& aGlobal, Promise& aPromise) -{ +/* static */ Promise* TestFunctions::PassThroughPromise(GlobalObject& aGlobal, + Promise& aPromise) { return &aPromise; } /* static */ already_AddRefed<Promise> TestFunctions::PassThroughCallbackPromise(GlobalObject& aGlobal, PromiseReturner& aCallback, - ErrorResult& aRv) -{ + ErrorResult& aRv) { return aCallback.Call(aRv); } -void -TestFunctions::SetStringData(const nsAString& aString) -{ +void TestFunctions::SetStringData(const nsAString& aString) { mStringData = aString; } -void -TestFunctions::GetStringDataAsAString(nsAString& aString) -{ +void TestFunctions::GetStringDataAsAString(nsAString& aString) { aString = mStringData; } -void -TestFunctions::GetStringDataAsAString(uint32_t aLength, nsAString& aString) -{ +void TestFunctions::GetStringDataAsAString(uint32_t aLength, + nsAString& aString) { MOZ_RELEASE_ASSERT(aLength <= mStringData.Length(), "Bogus test passing in a too-big length"); aString.Assign(mStringData.BeginReading(), aLength); } -void -TestFunctions::GetStringDataAsDOMString(const Optional<uint32_t>& aLength, - DOMString& aString) -{ +void TestFunctions::GetStringDataAsDOMString(const Optional<uint32_t>& aLength, + DOMString& aString) { uint32_t length; if (aLength.WasPassed()) { length = aLength.Value(); MOZ_RELEASE_ASSERT(length <= mStringData.Length(), "Bogus test passing in a too-big length"); } else { length = mStringData.Length(); } @@ -82,54 +70,39 @@ TestFunctions::GetStringDataAsDOMString( } // We better have an empty mStringData; otherwise why did we not have a string // buffer? MOZ_RELEASE_ASSERT(length == 0, "Why no stringbuffer?"); // No need to do anything here; aString is already empty. } -void -TestFunctions::TestThrowNsresult(ErrorResult& aError) -{ +void TestFunctions::TestThrowNsresult(ErrorResult& aError) { nsCOMPtr<mozITestInterfaceJS> impl = - do_CreateInstance("@mozilla.org/dom/test-interface-js;1"); + do_CreateInstance("@mozilla.org/dom/test-interface-js;1"); aError = impl->TestThrowNsresult(); } -void -TestFunctions::TestThrowNsresultFromNative(ErrorResult& aError) -{ +void TestFunctions::TestThrowNsresultFromNative(ErrorResult& aError) { nsCOMPtr<mozITestInterfaceJS> impl = - do_CreateInstance("@mozilla.org/dom/test-interface-js;1"); + do_CreateInstance("@mozilla.org/dom/test-interface-js;1"); aError = impl->TestThrowNsresultFromNative(); } -already_AddRefed<Promise> -TestFunctions::ThrowToRejectPromise(GlobalObject& aGlobal, ErrorResult& aError) -{ +already_AddRefed<Promise> TestFunctions::ThrowToRejectPromise( + GlobalObject& aGlobal, ErrorResult& aError) { aError.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); return nullptr; } -int32_t -TestFunctions::One() const -{ - return 1; -} +int32_t TestFunctions::One() const { return 1; } -int32_t -TestFunctions::Two() const -{ - return 2; -} +int32_t TestFunctions::Two() const { return 2; } -bool -TestFunctions::ObjectFromAboutBlank(JSContext* aCx, JSObject* aObj) -{ +bool TestFunctions::ObjectFromAboutBlank(JSContext* aCx, JSObject* aObj) { // We purposefully don't use WindowOrNull here, because we want to // demonstrate the incorrect behavior we get, not just fail some asserts. RefPtr<nsGlobalWindowInner> win; UNWRAP_OBJECT(Window, aObj, win); if (!win) { return false; } @@ -137,25 +110,24 @@ TestFunctions::ObjectFromAboutBlank(JSCo if (!doc) { return false; } return doc->GetDocumentURI()->GetSpecOrDefault().EqualsLiteral("about:blank"); } WrapperCachedNonISupportsTestInterface* -TestFunctions::WrapperCachedNonISupportsObject() -{ +TestFunctions::WrapperCachedNonISupportsObject() { if (!mWrapperCachedNonISupportsTestInterface) { - mWrapperCachedNonISupportsTestInterface = new WrapperCachedNonISupportsTestInterface(); + mWrapperCachedNonISupportsTestInterface = + new WrapperCachedNonISupportsTestInterface(); } return mWrapperCachedNonISupportsTestInterface; } -bool -TestFunctions::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto, - JS::MutableHandle<JSObject*> aWrapper) -{ +bool TestFunctions::WrapObject(JSContext* aCx, + JS::Handle<JSObject*> aGivenProto, + JS::MutableHandle<JSObject*> aWrapper) { return TestFunctions_Binding::Wrap(aCx, this, aGivenProto, aWrapper); } -} -} +} // namespace dom +} // namespace mozilla
--- a/dom/bindings/test/TestFunctions.h +++ b/dom/bindings/test/TestFunctions.h @@ -15,53 +15,51 @@ namespace mozilla { namespace dom { class Promise; class PromiseReturner; class WrapperCachedNonISupportsTestInterface; class TestFunctions : public NonRefcountedDOMObject { -public: + public: static TestFunctions* Constructor(GlobalObject& aGlobal, ErrorResult& aRv); - static void - ThrowUncatchableException(GlobalObject& aGlobal, ErrorResult& aRv); + static void ThrowUncatchableException(GlobalObject& aGlobal, + ErrorResult& aRv); - static Promise* - PassThroughPromise(GlobalObject& aGlobal, Promise& aPromise); + static Promise* PassThroughPromise(GlobalObject& aGlobal, Promise& aPromise); - static already_AddRefed<Promise> - PassThroughCallbackPromise(GlobalObject& aGlobal, - PromiseReturner& aCallback, - ErrorResult& aRv); + static already_AddRefed<Promise> PassThroughCallbackPromise( + GlobalObject& aGlobal, PromiseReturner& aCallback, ErrorResult& aRv); void SetStringData(const nsAString& aString); void GetStringDataAsAString(nsAString& aString); void GetStringDataAsAString(uint32_t aLength, nsAString& aString); void GetStringDataAsDOMString(const Optional<uint32_t>& aLength, DOMString& aString); void TestThrowNsresult(ErrorResult& aError); void TestThrowNsresultFromNative(ErrorResult& aError); - static already_AddRefed<Promise> - ThrowToRejectPromise(GlobalObject& aGlobal, - ErrorResult& aError); + static already_AddRefed<Promise> ThrowToRejectPromise(GlobalObject& aGlobal, + ErrorResult& aError); int32_t One() const; int32_t Two() const; static bool ObjectFromAboutBlank(JSContext* aCx, JSObject* aObj); WrapperCachedNonISupportsTestInterface* WrapperCachedNonISupportsObject(); bool WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aWrapper); -private: + + private: nsString mStringData; - RefPtr<WrapperCachedNonISupportsTestInterface> mWrapperCachedNonISupportsTestInterface; + RefPtr<WrapperCachedNonISupportsTestInterface> + mWrapperCachedNonISupportsTestInterface; }; -} // namespace dom -} // namespace mozilla +} // namespace dom +} // namespace mozilla -#endif // mozilla_dom_TestFunctions_h +#endif // mozilla_dom_TestFunctions_h
--- a/dom/bindings/test/TestInterfaceIterableDouble.cpp +++ b/dom/bindings/test/TestInterfaceIterableDouble.cpp @@ -13,72 +13,64 @@ namespace mozilla { namespace dom { NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(TestInterfaceIterableDouble, mParent) NS_IMPL_CYCLE_COLLECTING_ADDREF(TestInterfaceIterableDouble) NS_IMPL_CYCLE_COLLECTING_RELEASE(TestInterfaceIterableDouble) NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TestInterfaceIterableDouble) -NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY -NS_INTERFACE_MAP_ENTRY(nsISupports) + NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY + NS_INTERFACE_MAP_ENTRY(nsISupports) NS_INTERFACE_MAP_END -TestInterfaceIterableDouble::TestInterfaceIterableDouble(nsPIDOMWindowInner* aParent) - : mParent(aParent) -{ +TestInterfaceIterableDouble::TestInterfaceIterableDouble( + nsPIDOMWindowInner* aParent) + : mParent(aParent) { mValues.AppendElement(std::pair<nsString, nsString>(NS_LITERAL_STRING("a"), NS_LITERAL_STRING("b"))); mValues.AppendElement(std::pair<nsString, nsString>(NS_LITERAL_STRING("c"), NS_LITERAL_STRING("d"))); mValues.AppendElement(std::pair<nsString, nsString>(NS_LITERAL_STRING("e"), NS_LITERAL_STRING("f"))); } -//static +// static already_AddRefed<TestInterfaceIterableDouble> TestInterfaceIterableDouble::Constructor(const GlobalObject& aGlobal, - ErrorResult& aRv) -{ - nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(aGlobal.GetAsSupports()); + ErrorResult& aRv) { + nsCOMPtr<nsPIDOMWindowInner> window = + do_QueryInterface(aGlobal.GetAsSupports()); if (!window) { aRv.Throw(NS_ERROR_FAILURE); return nullptr; } - RefPtr<TestInterfaceIterableDouble> r = new TestInterfaceIterableDouble(window); + RefPtr<TestInterfaceIterableDouble> r = + new TestInterfaceIterableDouble(window); return r.forget(); } -JSObject* -TestInterfaceIterableDouble::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) -{ +JSObject* TestInterfaceIterableDouble::WrapObject( + JSContext* aCx, JS::Handle<JSObject*> aGivenProto) { return TestInterfaceIterableDouble_Binding::Wrap(aCx, this, aGivenProto); } -nsPIDOMWindowInner* -TestInterfaceIterableDouble::GetParentObject() const -{ +nsPIDOMWindowInner* TestInterfaceIterableDouble::GetParentObject() const { return mParent; } -size_t -TestInterfaceIterableDouble::GetIterableLength() -{ +size_t TestInterfaceIterableDouble::GetIterableLength() { return mValues.Length(); } -nsAString& -TestInterfaceIterableDouble::GetKeyAtIndex(uint32_t aIndex) -{ +nsAString& TestInterfaceIterableDouble::GetKeyAtIndex(uint32_t aIndex) { MOZ_ASSERT(aIndex < mValues.Length()); return mValues.ElementAt(aIndex).first; } -nsAString& -TestInterfaceIterableDouble::GetValueAtIndex(uint32_t aIndex) -{ +nsAString& TestInterfaceIterableDouble::GetValueAtIndex(uint32_t aIndex) { MOZ_ASSERT(aIndex < mValues.Length()); return mValues.ElementAt(aIndex).second; } -} // namespace dom -} // namespace mozilla +} // namespace dom +} // namespace mozilla
--- a/dom/bindings/test/TestInterfaceIterableDouble.h +++ b/dom/bindings/test/TestInterfaceIterableDouble.h @@ -19,34 +19,34 @@ class ErrorResult; namespace dom { class GlobalObject; // Implementation of test binding for webidl iterable interfaces, using // primitives for value type class TestInterfaceIterableDouble final : public nsISupports, - public nsWrapperCache -{ -public: + public nsWrapperCache { + public: NS_DECL_CYCLE_COLLECTING_ISUPPORTS NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(TestInterfaceIterableDouble) explicit TestInterfaceIterableDouble(nsPIDOMWindowInner* aParent); nsPIDOMWindowInner* GetParentObject() const; virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override; - static already_AddRefed<TestInterfaceIterableDouble> - Constructor(const GlobalObject& aGlobal, ErrorResult& rv); + static already_AddRefed<TestInterfaceIterableDouble> Constructor( + const GlobalObject& aGlobal, ErrorResult& rv); size_t GetIterableLength(); nsAString& GetKeyAtIndex(uint32_t aIndex); nsAString& GetValueAtIndex(uint32_t aIndex); -private: + + private: virtual ~TestInterfaceIterableDouble() {} nsCOMPtr<nsPIDOMWindowInner> mParent; nsTArray<std::pair<nsString, nsString>> mValues; }; -} // namespace dom -} // namespace mozilla +} // namespace dom +} // namespace mozilla -#endif // mozilla_dom_TestInterfaceIterableDouble_h +#endif // mozilla_dom_TestInterfaceIterableDouble_h
--- a/dom/bindings/test/TestInterfaceIterableDoubleUnion.cpp +++ b/dom/bindings/test/TestInterfaceIterableDoubleUnion.cpp @@ -13,73 +13,66 @@ namespace mozilla { namespace dom { NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(TestInterfaceIterableDoubleUnion, mParent) NS_IMPL_CYCLE_COLLECTING_ADDREF(TestInterfaceIterableDoubleUnion) NS_IMPL_CYCLE_COLLECTING_RELEASE(TestInterfaceIterableDoubleUnion) NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TestInterfaceIterableDoubleUnion) -NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY -NS_INTERFACE_MAP_ENTRY(nsISupports) + NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY + NS_INTERFACE_MAP_ENTRY(nsISupports) NS_INTERFACE_MAP_END -TestInterfaceIterableDoubleUnion::TestInterfaceIterableDoubleUnion(nsPIDOMWindowInner* aParent) - : mParent(aParent) -{ +TestInterfaceIterableDoubleUnion::TestInterfaceIterableDoubleUnion( + nsPIDOMWindowInner* aParent) + : mParent(aParent) { OwningStringOrLong a; a.SetAsLong() = 1; - mValues.AppendElement(std::pair<nsString, OwningStringOrLong>(NS_LITERAL_STRING("long"), - a)); + mValues.AppendElement( + std::pair<nsString, OwningStringOrLong>(NS_LITERAL_STRING("long"), a)); a.SetAsString() = NS_LITERAL_STRING("a"); - mValues.AppendElement(std::pair<nsString, OwningStringOrLong>(NS_LITERAL_STRING("string"), - a)); + mValues.AppendElement( + std::pair<nsString, OwningStringOrLong>(NS_LITERAL_STRING("string"), a)); } -//static +// static already_AddRefed<TestInterfaceIterableDoubleUnion> TestInterfaceIterableDoubleUnion::Constructor(const GlobalObject& aGlobal, - ErrorResult& aRv) -{ - nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(aGlobal.GetAsSupports()); + ErrorResult& aRv) { + nsCOMPtr<nsPIDOMWindowInner> window = + do_QueryInterface(aGlobal.GetAsSupports()); if (!window) { aRv.Throw(NS_ERROR_FAILURE); return nullptr; } - RefPtr<TestInterfaceIterableDoubleUnion> r = new TestInterfaceIterableDoubleUnion(window); + RefPtr<TestInterfaceIterableDoubleUnion> r = + new TestInterfaceIterableDoubleUnion(window); return r.forget(); } -JSObject* -TestInterfaceIterableDoubleUnion::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) -{ +JSObject* TestInterfaceIterableDoubleUnion::WrapObject( + JSContext* aCx, JS::Handle<JSObject*> aGivenProto) { return TestInterfaceIterableDoubleUnion_Binding::Wrap(aCx, this, aGivenProto); } -nsPIDOMWindowInner* -TestInterfaceIterableDoubleUnion::GetParentObject() const -{ +nsPIDOMWindowInner* TestInterfaceIterableDoubleUnion::GetParentObject() const { return mParent; } -size_t -TestInterfaceIterableDoubleUnion::GetIterableLength() -{ +size_t TestInterfaceIterableDoubleUnion::GetIterableLength() { return mValues.Length(); } -nsAString& -TestInterfaceIterableDoubleUnion::GetKeyAtIndex(uint32_t aIndex) -{ +nsAString& TestInterfaceIterableDoubleUnion::GetKeyAtIndex(uint32_t aIndex) { MOZ_ASSERT(aIndex < mValues.Length()); return mValues.ElementAt(aIndex).first; } -OwningStringOrLong& -TestInterfaceIterableDoubleUnion::GetValueAtIndex(uint32_t aIndex) -{ +OwningStringOrLong& TestInterfaceIterableDoubleUnion::GetValueAtIndex( + uint32_t aIndex) { MOZ_ASSERT(aIndex < mValues.Length()); return mValues.ElementAt(aIndex).second; } -} // namespace dom -} // namespace mozilla +} // namespace dom +} // namespace mozilla
--- a/dom/bindings/test/TestInterfaceIterableDoubleUnion.h +++ b/dom/bindings/test/TestInterfaceIterableDoubleUnion.h @@ -19,34 +19,34 @@ class ErrorResult; namespace dom { class GlobalObject; // Implementation of test binding for webidl iterable interfaces, using // primitives for value type class TestInterfaceIterableDoubleUnion final : public nsISupports, - public nsWrapperCache -{ -public: + public nsWrapperCache { + public: NS_DECL_CYCLE_COLLECTING_ISUPPORTS NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(TestInterfaceIterableDoubleUnion) explicit TestInterfaceIterableDoubleUnion(nsPIDOMWindowInner* aParent); nsPIDOMWindowInner* GetParentObject() const; virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override; - static already_AddRefed<TestInterfaceIterableDoubleUnion> - Constructor(const GlobalObject& aGlobal, ErrorResult& rv); + static already_AddRefed<TestInterfaceIterableDoubleUnion> Constructor( + const GlobalObject& aGlobal, ErrorResult& rv); size_t GetIterableLength(); nsAString& GetKeyAtIndex(uint32_t aIndex); OwningStringOrLong& GetValueAtIndex(uint32_t aIndex); -private: + + private: virtual ~TestInterfaceIterableDoubleUnion() {} nsCOMPtr<nsPIDOMWindowInner> mParent; nsTArray<std::pair<nsString, OwningStringOrLong>> mValues; }; -} // namespace dom -} // namespace mozilla +} // namespace dom +} // namespace mozilla -#endif // mozilla_dom_TestInterfaceIterableDoubleUnion_h +#endif // mozilla_dom_TestInterfaceIterableDoubleUnion_h
--- a/dom/bindings/test/TestInterfaceIterableSingle.cpp +++ b/dom/bindings/test/TestInterfaceIterableSingle.cpp @@ -13,67 +13,62 @@ namespace mozilla { namespace dom { NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(TestInterfaceIterableSingle, mParent) NS_IMPL_CYCLE_COLLECTING_ADDREF(TestInterfaceIterableSingle) NS_IMPL_CYCLE_COLLECTING_RELEASE(TestInterfaceIterableSingle) NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TestInterfaceIterableSingle) -NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY -NS_INTERFACE_MAP_ENTRY(nsISupports) + NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY + NS_INTERFACE_MAP_ENTRY(nsISupports) NS_INTERFACE_MAP_END -TestInterfaceIterableSingle::TestInterfaceIterableSingle(nsPIDOMWindowInner* aParent) - : mParent(aParent) -{ +TestInterfaceIterableSingle::TestInterfaceIterableSingle( + nsPIDOMWindowInner* aParent) + : mParent(aParent) { for (int i = 0; i < 3; ++i) { mValues.AppendElement(i); } } -//static +// static already_AddRefed<TestInterfaceIterableSingle> TestInterfaceIterableSingle::Constructor(const GlobalObject& aGlobal, - ErrorResult& aRv) -{ - nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(aGlobal.GetAsSupports()); + ErrorResult& aRv) { + nsCOMPtr<nsPIDOMWindowInner> window = + do_QueryInterface(aGlobal.GetAsSupports()); if (!window) { aRv.Throw(NS_ERROR_FAILURE); return nullptr; } - RefPtr<TestInterfaceIterableSingle> r = new TestInterfaceIterableSingle(window); + RefPtr<TestInterfaceIterableSingle> r = + new TestInterfaceIterableSingle(window); return r.forget(); } -JSObject* -TestInterfaceIterableSingle::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) -{ +JSObject* TestInterfaceIterableSingle::WrapObject( + JSContext* aCx, JS::Handle<JSObject*> aGivenProto) { return TestInterfaceIterableSingle_Binding::Wrap(aCx, this, aGivenProto); } -nsPIDOMWindowInner* -TestInterfaceIterableSingle::GetParentObject() const -{ +nsPIDOMWindowInner* TestInterfaceIterableSingle::GetParentObject() const { return mParent; } -uint32_t -TestInterfaceIterableSingle::Length() const -{ +uint32_t TestInterfaceIterableSingle::Length() const { return mValues.Length(); } -int32_t -TestInterfaceIterableSingle::IndexedGetter(uint32_t aIndex, bool& aFound) const -{ +int32_t TestInterfaceIterableSingle::IndexedGetter(uint32_t aIndex, + bool& aFound) const { if (aIndex >= mValues.Length()) { aFound = false; return 0; } aFound = true; return mValues[aIndex]; } -} // namespace dom -} // namespace mozilla +} // namespace dom +} // namespace mozilla
--- a/dom/bindings/test/TestInterfaceIterableSingle.h +++ b/dom/bindings/test/TestInterfaceIterableSingle.h @@ -19,34 +19,33 @@ class ErrorResult; namespace dom { class GlobalObject; // Implementation of test binding for webidl iterable interfaces, using // primitives for value type class TestInterfaceIterableSingle final : public nsISupports, - public nsWrapperCache -{ -public: + public nsWrapperCache { + public: NS_DECL_CYCLE_COLLECTING_ISUPPORTS NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(TestInterfaceIterableSingle) explicit TestInterfaceIterableSingle(nsPIDOMWindowInner* aParent); nsPIDOMWindowInner* GetParentObject() const; virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override; - static already_AddRefed<TestInterfaceIterableSingle> - Constructor(const GlobalObject& aGlobal, ErrorResult& rv); + static already_AddRefed<TestInterfaceIterableSingle> Constructor( + const GlobalObject& aGlobal, ErrorResult& rv); uint32_t Length() const; int32_t IndexedGetter(uint32_t aIndex, bool& aFound) const; -private: + private: virtual ~TestInterfaceIterableSingle() {} nsCOMPtr<nsPIDOMWindowInner> mParent; nsTArray<int32_t> mValues; }; -} // namespace dom -} // namespace mozilla +} // namespace dom +} // namespace mozilla -#endif // mozilla_dom_TestInterfaceIterableSingle_h +#endif // mozilla_dom_TestInterfaceIterableSingle_h
--- a/dom/bindings/test/TestInterfaceMaplike.cpp +++ b/dom/bindings/test/TestInterfaceMaplike.cpp @@ -13,74 +13,60 @@ namespace mozilla { namespace dom { NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(TestInterfaceMaplike, mParent) NS_IMPL_CYCLE_COLLECTING_ADDREF(TestInterfaceMaplike) NS_IMPL_CYCLE_COLLECTING_RELEASE(TestInterfaceMaplike) NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TestInterfaceMaplike) -NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY -NS_INTERFACE_MAP_ENTRY(nsISupports) + NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY + NS_INTERFACE_MAP_ENTRY(nsISupports) NS_INTERFACE_MAP_END TestInterfaceMaplike::TestInterfaceMaplike(nsPIDOMWindowInner* aParent) -: mParent(aParent) -{ -} + : mParent(aParent) {} -//static -already_AddRefed<TestInterfaceMaplike> -TestInterfaceMaplike::Constructor(const GlobalObject& aGlobal, - ErrorResult& aRv) -{ - nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(aGlobal.GetAsSupports()); +// static +already_AddRefed<TestInterfaceMaplike> TestInterfaceMaplike::Constructor( + const GlobalObject& aGlobal, ErrorResult& aRv) { + nsCOMPtr<nsPIDOMWindowInner> window = + do_QueryInterface(aGlobal.GetAsSupports()); if (!window) { aRv.Throw(NS_ERROR_FAILURE); return nullptr; } RefPtr<TestInterfaceMaplike> r = new TestInterfaceMaplike(window); return r.forget(); } -JSObject* -TestInterfaceMaplike::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) -{ +JSObject* TestInterfaceMaplike::WrapObject(JSContext* aCx, + JS::Handle<JSObject*> aGivenProto) { return TestInterfaceMaplike_Binding::Wrap(aCx, this, aGivenProto); } -nsPIDOMWindowInner* -TestInterfaceMaplike::GetParentObject() const -{ +nsPIDOMWindowInner* TestInterfaceMaplike::GetParentObject() const { return mParent; } -void -TestInterfaceMaplike::SetInternal(const nsAString& aKey, int32_t aValue) -{ +void TestInterfaceMaplike::SetInternal(const nsAString& aKey, int32_t aValue) { ErrorResult rv; TestInterfaceMaplike_Binding::MaplikeHelpers::Set(this, aKey, aValue, rv); } -void -TestInterfaceMaplike::ClearInternal() -{ +void TestInterfaceMaplike::ClearInternal() { ErrorResult rv; TestInterfaceMaplike_Binding::MaplikeHelpers::Clear(this, rv); } -bool -TestInterfaceMaplike::DeleteInternal(const nsAString& aKey) -{ +bool TestInterfaceMaplike::DeleteInternal(const nsAString& aKey) { ErrorResult rv; return TestInterfaceMaplike_Binding::MaplikeHelpers::Delete(this, aKey, rv); } -bool -TestInterfaceMaplike::HasInternal(const nsAString& aKey) -{ +bool TestInterfaceMaplike::HasInternal(const nsAString& aKey) { ErrorResult rv; return TestInterfaceMaplike_Binding::MaplikeHelpers::Has(this, aKey, rv); } -} // namespace dom -} // namespace mozilla +} // namespace dom +} // namespace mozilla
--- a/dom/bindings/test/TestInterfaceMaplike.h +++ b/dom/bindings/test/TestInterfaceMaplike.h @@ -17,36 +17,35 @@ namespace mozilla { class ErrorResult; namespace dom { class GlobalObject; // Implementation of test binding for webidl maplike interfaces, using // primitives for key and value types. -class TestInterfaceMaplike final : public nsISupports, - public nsWrapperCache -{ -public: +class TestInterfaceMaplike final : public nsISupports, public nsWrapperCache { + public: NS_DECL_CYCLE_COLLECTING_ISUPPORTS NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(TestInterfaceMaplike) explicit TestInterfaceMaplike(nsPIDOMWindowInner* aParent); nsPIDOMWindowInner* GetParentObject() const; virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override; - static already_AddRefed<TestInterfaceMaplike> - Constructor(const GlobalObject& aGlobal, ErrorResult& rv); + static already_AddRefed<TestInterfaceMaplike> Constructor( + const GlobalObject& aGlobal, ErrorResult& rv); // External access for testing internal convenience functions. void SetInternal(const nsAString& aKey, int32_t aValue); void ClearInternal(); bool DeleteInternal(const nsAString& aKey); bool HasInternal(const nsAString& aKey); -private: + + private: virtual ~TestInterfaceMaplike() {} nsCOMPtr<nsPIDOMWindowInner> mParent; }; -} // namespace dom -} // namespace mozilla +} // namespace dom +} // namespace mozilla -#endif // mozilla_dom_TestInterfaceMaplike_h +#endif // mozilla_dom_TestInterfaceMaplike_h
--- a/dom/bindings/test/TestInterfaceMaplikeObject.cpp +++ b/dom/bindings/test/TestInterfaceMaplikeObject.cpp @@ -14,77 +14,65 @@ namespace mozilla { namespace dom { NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(TestInterfaceMaplikeObject, mParent) NS_IMPL_CYCLE_COLLECTING_ADDREF(TestInterfaceMaplikeObject) NS_IMPL_CYCLE_COLLECTING_RELEASE(TestInterfaceMaplikeObject) NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TestInterfaceMaplikeObject) -NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY -NS_INTERFACE_MAP_ENTRY(nsISupports) + NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY + NS_INTERFACE_MAP_ENTRY(nsISupports) NS_INTERFACE_MAP_END -TestInterfaceMaplikeObject::TestInterfaceMaplikeObject(nsPIDOMWindowInner* aParent) -: mParent(aParent) -{ -} +TestInterfaceMaplikeObject::TestInterfaceMaplikeObject( + nsPIDOMWindowInner* aParent) + : mParent(aParent) {} -//static +// static already_AddRefed<TestInterfaceMaplikeObject> TestInterfaceMaplikeObject::Constructor(const GlobalObject& aGlobal, - ErrorResult& aRv) -{ - nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(aGlobal.GetAsSupports()); + ErrorResult& aRv) { + nsCOMPtr<nsPIDOMWindowInner> window = + do_QueryInterface(aGlobal.GetAsSupports()); if (!window) { aRv.Throw(NS_ERROR_FAILURE); return nullptr; } - RefPtr<TestInterfaceMaplikeObject> r = - new TestInterfaceMaplikeObject(window); + RefPtr<TestInterfaceMaplikeObject> r = new TestInterfaceMaplikeObject(window); return r.forget(); } -JSObject* -TestInterfaceMaplikeObject::WrapObject(JSContext* aCx, - JS::Handle<JSObject*> aGivenProto) -{ +JSObject* TestInterfaceMaplikeObject::WrapObject( + JSContext* aCx, JS::Handle<JSObject*> aGivenProto) { return TestInterfaceMaplikeObject_Binding::Wrap(aCx, this, aGivenProto); } -nsPIDOMWindowInner* -TestInterfaceMaplikeObject::GetParentObject() const -{ +nsPIDOMWindowInner* TestInterfaceMaplikeObject::GetParentObject() const { return mParent; } -void -TestInterfaceMaplikeObject::SetInternal(const nsAString& aKey) -{ +void TestInterfaceMaplikeObject::SetInternal(const nsAString& aKey) { RefPtr<TestInterfaceMaplike> p(new TestInterfaceMaplike(mParent)); ErrorResult rv; TestInterfaceMaplikeObject_Binding::MaplikeHelpers::Set(this, aKey, *p, rv); } -void -TestInterfaceMaplikeObject::ClearInternal() -{ +void TestInterfaceMaplikeObject::ClearInternal() { ErrorResult rv; TestInterfaceMaplikeObject_Binding::MaplikeHelpers::Clear(this, rv); } -bool -TestInterfaceMaplikeObject::DeleteInternal(const nsAString& aKey) -{ +bool TestInterfaceMaplikeObject::DeleteInternal(const nsAString& aKey) { ErrorResult rv; - return TestInterfaceMaplikeObject_Binding::MaplikeHelpers::Delete(this, aKey, rv); + return TestInterfaceMaplikeObject_Binding::MaplikeHelpers::Delete(this, aKey, + rv); } -bool -TestInterfaceMaplikeObject::HasInternal(const nsAString& aKey) -{ +bool TestInterfaceMaplikeObject::HasInternal(const nsAString& aKey) { ErrorResult rv; - return TestInterfaceMaplikeObject_Binding::MaplikeHelpers::Has(this, aKey, rv); + return TestInterfaceMaplikeObject_Binding::MaplikeHelpers::Has(this, aKey, + rv); } -} // namespace dom -} // namespace mozilla +} // namespace dom +} // namespace mozilla
--- a/dom/bindings/test/TestInterfaceMaplikeObject.h +++ b/dom/bindings/test/TestInterfaceMaplikeObject.h @@ -18,35 +18,35 @@ class ErrorResult; namespace dom { class GlobalObject; // Implementation of test binding for webidl maplike interfaces, using // primitives for key types and objects for value types. class TestInterfaceMaplikeObject final : public nsISupports, - public nsWrapperCache -{ -public: + public nsWrapperCache { + public: NS_DECL_CYCLE_COLLECTING_ISUPPORTS NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(TestInterfaceMaplikeObject) explicit TestInterfaceMaplikeObject(nsPIDOMWindowInner* aParent); nsPIDOMWindowInner* GetParentObject() const; virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override; - static already_AddRefed<TestInterfaceMaplikeObject> - Constructor(const GlobalObject& aGlobal,ErrorResult& rv); + static already_AddRefed<TestInterfaceMaplikeObject> Constructor( + const GlobalObject& aGlobal, ErrorResult& rv); // External access for testing internal convenience functions. void SetInternal(const nsAString& aKey); void ClearInternal(); bool DeleteInternal(const nsAString& aKey); bool HasInternal(const nsAString& aKey); -private: + + private: virtual ~TestInterfaceMaplikeObject() {} nsCOMPtr<nsPIDOMWindowInner> mParent; }; -} // namespace dom -} // namespace mozilla +} // namespace dom +} // namespace mozilla -#endif // mozilla_dom_TestInterfaceMaplikeObject_h +#endif // mozilla_dom_TestInterfaceMaplikeObject_h
--- a/dom/bindings/test/TestInterfaceSetlike.cpp +++ b/dom/bindings/test/TestInterfaceSetlike.cpp @@ -13,48 +13,41 @@ namespace mozilla { namespace dom { NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(TestInterfaceSetlike, mParent) NS_IMPL_CYCLE_COLLECTING_ADDREF(TestInterfaceSetlike) NS_IMPL_CYCLE_COLLECTING_RELEASE(TestInterfaceSetlike) NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TestInterfaceSetlike) -NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY -NS_INTERFACE_MAP_ENTRY(nsISupports) + NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY + NS_INTERFACE_MAP_ENTRY(nsISupports) NS_INTERFACE_MAP_END TestInterfaceSetlike::TestInterfaceSetlike(JSContext* aCx, nsPIDOMWindowInner* aParent) -: mParent(aParent) -{ -} + : mParent(aParent) {} -//static -already_AddRefed<TestInterfaceSetlike> -TestInterfaceSetlike::Constructor(const GlobalObject& aGlobal, - ErrorResult& aRv) -{ - nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(aGlobal.GetAsSupports()); +// static +already_AddRefed<TestInterfaceSetlike> TestInterfaceSetlike::Constructor( + const GlobalObject& aGlobal, ErrorResult& aRv) { + nsCOMPtr<nsPIDOMWindowInner> window = + do_QueryInterface(aGlobal.GetAsSupports()); if (!window) { aRv.Throw(NS_ERROR_FAILURE); return nullptr; } RefPtr<TestInterfaceSetlike> r = new TestInterfaceSetlike(nullptr, window); return r.forget(); } -JSObject* -TestInterfaceSetlike::WrapObject(JSContext* aCx, - JS::Handle<JSObject*> aGivenProto) -{ +JSObject* TestInterfaceSetlike::WrapObject(JSContext* aCx, + JS::Handle<JSObject*> aGivenProto) { return TestInterfaceSetlike_Binding::Wrap(aCx, this, aGivenProto); } -nsPIDOMWindowInner* -TestInterfaceSetlike::GetParentObject() const -{ +nsPIDOMWindowInner* TestInterfaceSetlike::GetParentObject() const { return mParent; } -} // namespace dom -} // namespace mozilla +} // namespace dom +} // namespace mozilla
--- a/dom/bindings/test/TestInterfaceSetlike.h +++ b/dom/bindings/test/TestInterfaceSetlike.h @@ -17,30 +17,28 @@ namespace mozilla { class ErrorResult; namespace dom { class GlobalObject; // Implementation of test binding for webidl setlike interfaces, using // primitives for key type. -class TestInterfaceSetlike final : public nsISupports, - public nsWrapperCache -{ -public: +class TestInterfaceSetlike final : public nsISupports, public nsWrapperCache { + public: NS_DECL_CYCLE_COLLECTING_ISUPPORTS NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(TestInterfaceSetlike) - explicit TestInterfaceSetlike(JSContext* aCx, - nsPIDOMWindowInner* aParent); + explicit TestInterfaceSetlike(JSContext* aCx, nsPIDOMWindowInner* aParent); nsPIDOMWindowInner* GetParentObject() const; virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override; - static already_AddRefed<TestInterfaceSetlike> - Constructor(const GlobalObject& aGlobal, ErrorResult& rv); -private: + static already_AddRefed<TestInterfaceSetlike> Constructor( + const GlobalObject& aGlobal, ErrorResult& rv); + + private: virtual ~TestInterfaceSetlike() {} nsCOMPtr<nsPIDOMWindowInner> mParent; }; -} // namespace dom -} // namespace mozilla +} // namespace dom +} // namespace mozilla -#endif // mozilla_dom_TestInterfaceSetlike_h +#endif // mozilla_dom_TestInterfaceSetlike_h
--- a/dom/bindings/test/TestInterfaceSetlikeNode.cpp +++ b/dom/bindings/test/TestInterfaceSetlikeNode.cpp @@ -13,48 +13,43 @@ namespace mozilla { namespace dom { NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(TestInterfaceSetlikeNode, mParent) NS_IMPL_CYCLE_COLLECTING_ADDREF(TestInterfaceSetlikeNode) NS_IMPL_CYCLE_COLLECTING_RELEASE(TestInterfaceSetlikeNode) NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TestInterfaceSetlikeNode) -NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY -NS_INTERFACE_MAP_ENTRY(nsISupports) + NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY + NS_INTERFACE_MAP_ENTRY(nsISupports) NS_INTERFACE_MAP_END TestInterfaceSetlikeNode::TestInterfaceSetlikeNode(JSContext* aCx, nsPIDOMWindowInner* aParent) -: mParent(aParent) -{ -} + : mParent(aParent) {} -//static +// static already_AddRefed<TestInterfaceSetlikeNode> TestInterfaceSetlikeNode::Constructor(const GlobalObject& aGlobal, - ErrorResult& aRv) -{ - nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(aGlobal.GetAsSupports()); + ErrorResult& aRv) { + nsCOMPtr<nsPIDOMWindowInner> window = + do_QueryInterface(aGlobal.GetAsSupports()); if (!window) { aRv.Throw(NS_ERROR_FAILURE); return nullptr; } - RefPtr<TestInterfaceSetlikeNode> r = new TestInterfaceSetlikeNode(nullptr, window); + RefPtr<TestInterfaceSetlikeNode> r = + new TestInterfaceSetlikeNode(nullptr, window); return r.forget(); } -JSObject* -TestInterfaceSetlikeNode::WrapObject(JSContext* aCx, - JS::Handle<JSObject*> aGivenProto) -{ +JSObject* TestInterfaceSetlikeNode::WrapObject( + JSContext* aCx, JS::Handle<JSObject*> aGivenProto) { return TestInterfaceSetlikeNode_Binding::Wrap(aCx, this, aGivenProto); } -nsPIDOMWindowInner* -TestInterfaceSetlikeNode::GetParentObject() const -{ +nsPIDOMWindowInner* TestInterfaceSetlikeNode::GetParentObject() const { return mParent; } -} // namespace dom -} // namespace mozilla +} // namespace dom +} // namespace mozilla
--- a/dom/bindings/test/TestInterfaceSetlikeNode.h +++ b/dom/bindings/test/TestInterfaceSetlikeNode.h @@ -18,29 +18,29 @@ class ErrorResult; namespace dom { class GlobalObject; // Implementation of test binding for webidl setlike interfaces, using // primitives for key type. class TestInterfaceSetlikeNode final : public nsISupports, - public nsWrapperCache -{ -public: + public nsWrapperCache { + public: NS_DECL_CYCLE_COLLECTING_ISUPPORTS NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(TestInterfaceSetlikeNode) explicit TestInterfaceSetlikeNode(JSContext* aCx, nsPIDOMWindowInner* aParent); nsPIDOMWindowInner* GetParentObject() const; virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override; - static already_AddRefed<TestInterfaceSetlikeNode> - Constructor(const GlobalObject& aGlobal, ErrorResult& rv); -private: + static already_AddRefed<TestInterfaceSetlikeNode> Constructor( + const GlobalObject& aGlobal, ErrorResult& rv); + + private: virtual ~TestInterfaceSetlikeNode() {} nsCOMPtr<nsPIDOMWindowInner> mParent; }; -} // namespace dom -} // namespace mozilla +} // namespace dom +} // namespace mozilla -#endif // mozilla_dom_TestInterfaceSetlikeNode_h +#endif // mozilla_dom_TestInterfaceSetlikeNode_h
--- a/dom/bindings/test/WrapperCachedNonISupportsTestInterface.cpp +++ b/dom/bindings/test/WrapperCachedNonISupportsTestInterface.cpp @@ -5,21 +5,23 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "mozilla/dom/WrapperCachedNonISupportsTestInterface.h" #include "mozilla/dom/TestFunctionsBinding.h" namespace mozilla { namespace dom { -NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(WrapperCachedNonISupportsTestInterface, AddRef) -NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(WrapperCachedNonISupportsTestInterface, Release) +NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(WrapperCachedNonISupportsTestInterface, + AddRef) +NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(WrapperCachedNonISupportsTestInterface, + Release) NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(WrapperCachedNonISupportsTestInterface) -JSObject* -WrapperCachedNonISupportsTestInterface::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) -{ - return WrapperCachedNonISupportsTestInterface_Binding::Wrap(aCx, this, aGivenProto); +JSObject* WrapperCachedNonISupportsTestInterface::WrapObject( + JSContext* aCx, JS::Handle<JSObject*> aGivenProto) { + return WrapperCachedNonISupportsTestInterface_Binding::Wrap(aCx, this, + aGivenProto); } -} // namespace dom -} // namespace mozilla +} // namespace dom +} // namespace mozilla
--- a/dom/bindings/test/WrapperCachedNonISupportsTestInterface.h +++ b/dom/bindings/test/WrapperCachedNonISupportsTestInterface.h @@ -9,36 +9,35 @@ #include "js/TypeDecls.h" #include "mozilla/Attributes.h" #include "mozilla/ErrorResult.h" #include "mozilla/dom/BindingDeclarations.h" #include "nsCycleCollectionParticipant.h" #include "nsWrapperCache.h" - namespace mozilla { namespace dom { -class WrapperCachedNonISupportsTestInterface final : public nsWrapperCache -{ -public: - NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WrapperCachedNonISupportsTestInterface) - NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WrapperCachedNonISupportsTestInterface) +class WrapperCachedNonISupportsTestInterface final : public nsWrapperCache { + public: + NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING( + WrapperCachedNonISupportsTestInterface) + NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS( + WrapperCachedNonISupportsTestInterface) -public: + public: WrapperCachedNonISupportsTestInterface() {} -protected: + protected: ~WrapperCachedNonISupportsTestInterface() {} -public: - nsISupports* GetParentObject() const { - return nullptr; - } + public: + nsISupports* GetParentObject() const { return nullptr; } - virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override; + virtual JSObject* WrapObject(JSContext* aCx, + JS::Handle<JSObject*> aGivenProto) override; }; -} // namespace dom -} // namespace mozilla +} // namespace dom +} // namespace mozilla -#endif // mozilla_dom_WrapperCachedNonISupportsTestInterface_h +#endif // mozilla_dom_WrapperCachedNonISupportsTestInterface_h
--- a/dom/media/gtest/GMPTestMonitor.h +++ b/dom/media/gtest/GMPTestMonitor.h @@ -4,44 +4,37 @@ * 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/. */ #include "nsThreadUtils.h" #ifndef __GMPTestMonitor_h__ #define __GMPTestMonitor_h__ -class GMPTestMonitor -{ -public: - GMPTestMonitor() - : mFinished(false) - { - } +class GMPTestMonitor { + public: + GMPTestMonitor() : mFinished(false) {} - void AwaitFinished() - { + void AwaitFinished() { MOZ_ASSERT(NS_IsMainThread()); mozilla::SpinEventLoopUntil([&]() { return mFinished; }); mFinished = false; } -private: - void MarkFinished() - { + private: + void MarkFinished() { MOZ_ASSERT(NS_IsMainThread()); mFinished = true; } -public: - void SetFinished() - { - mozilla::SystemGroup::Dispatch( - mozilla::TaskCategory::Other, - mozilla::NewNonOwningRunnableMethod( - "GMPTestMonitor::MarkFinished", this, &GMPTestMonitor::MarkFinished)); + public: + void SetFinished() { + mozilla::SystemGroup::Dispatch(mozilla::TaskCategory::Other, + mozilla::NewNonOwningRunnableMethod( + "GMPTestMonitor::MarkFinished", this, + &GMPTestMonitor::MarkFinished)); } -private: + private: bool mFinished; }; -#endif // __GMPTestMonitor_h__ +#endif // __GMPTestMonitor_h__
--- a/dom/media/gtest/MockMediaDecoderOwner.h +++ b/dom/media/gtest/MockMediaDecoderOwner.h @@ -3,29 +3,25 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #ifndef MOCK_MEDIA_DECODER_OWNER_H_ #define MOCK_MEDIA_DECODER_OWNER_H_ #include "MediaDecoderOwner.h" #include "mozilla/AbstractThread.h" -namespace mozilla -{ +namespace mozilla { -class MockMediaDecoderOwner : public MediaDecoderOwner -{ -public: +class MockMediaDecoderOwner : public MediaDecoderOwner { + public: void DispatchAsyncEvent(const nsAString& aName) override {} void FireTimeUpdate(bool aPeriodic) override {} bool GetPaused() override { return false; } void MetadataLoaded(const MediaInfo* aInfo, - UniquePtr<const MetadataTags> aTags) override - { - } + UniquePtr<const MetadataTags> aTags) override {} void NetworkError() override {} void DecodeError(const MediaResult& aError) override {} bool HasError() const override { return false; } void LoadAborted() override {} void PlaybackEnded() override {} void SeekStarted() override {} void SeekCompleted() override {} void DownloadProgressed() override {} @@ -34,21 +30,20 @@ public: void DispatchEncrypted(const nsTArray<uint8_t>& aInitData, const nsAString& aInitDataType) override {} void DownloadSuspended() override {} void DownloadResumed(bool aForceNetworkLoading) override {} void NotifySuspendedByCache(bool aIsSuspended) override {} void NotifyDecoderPrincipalChanged() override {} void SetAudibleState(bool aAudible) override {} void NotifyXPCOMShutdown() override {} - AbstractThread* AbstractMainThread() const override - { + AbstractThread* AbstractMainThread() const override { // Non-DocGroup version for Mock. return AbstractThread::MainThread(); } void ConstructMediaTracks(const MediaInfo* aInfo) {} void RemoveMediaTracks() {} void AsyncResolveSeekDOMPromiseIfExists() override {} void AsyncRejectSeekDOMPromiseIfExists() override {} }; -} +} // namespace mozilla #endif
--- a/dom/media/gtest/MockMediaResource.cpp +++ b/dom/media/gtest/MockMediaResource.cpp @@ -2,47 +2,38 @@ * 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/. */ #include "MockMediaResource.h" #include <sys/types.h> #include <sys/stat.h> -namespace mozilla -{ +namespace mozilla { MockMediaResource::MockMediaResource(const char* aFileName) - : mFileHandle(nullptr) - , mFileName(aFileName) -{ -} + : mFileHandle(nullptr), mFileName(aFileName) {} -nsresult -MockMediaResource::Open() -{ +nsresult MockMediaResource::Open() { mFileHandle = fopen(mFileName, "rb"); if (mFileHandle == nullptr) { printf_stderr("Can't open %s\n", mFileName); return NS_ERROR_FAILURE; } return NS_OK; } -MockMediaResource::~MockMediaResource() -{ +MockMediaResource::~MockMediaResource() { if (mFileHandle != nullptr) { fclose(mFileHandle); } } -nsresult -MockMediaResource::ReadAt(int64_t aOffset, char* aBuffer, uint32_t aCount, - uint32_t* aBytes) -{ +nsresult MockMediaResource::ReadAt(int64_t aOffset, char* aBuffer, + uint32_t aCount, uint32_t* aBytes) { if (mFileHandle == nullptr) { return NS_ERROR_FAILURE; } // Make it fail if we're re-entrant if (mEntry++) { MOZ_ASSERT(false); return NS_ERROR_FAILURE; @@ -51,64 +42,50 @@ MockMediaResource::ReadAt(int64_t aOffse fseek(mFileHandle, aOffset, SEEK_SET); *aBytes = fread(aBuffer, 1, aCount, mFileHandle); mEntry--; return ferror(mFileHandle) ? NS_ERROR_FAILURE : NS_OK; } -int64_t -MockMediaResource::GetLength() -{ +int64_t MockMediaResource::GetLength() { if (mFileHandle == nullptr) { return -1; } fseek(mFileHandle, 0, SEEK_END); return ftell(mFileHandle); } -void -MockMediaResource::MockClearBufferedRanges() -{ - mRanges.Clear(); -} +void MockMediaResource::MockClearBufferedRanges() { mRanges.Clear(); } -void -MockMediaResource::MockAddBufferedRange(int64_t aStart, int64_t aEnd) -{ +void MockMediaResource::MockAddBufferedRange(int64_t aStart, int64_t aEnd) { mRanges += MediaByteRange(aStart, aEnd); } -int64_t -MockMediaResource::GetNextCachedData(int64_t aOffset) -{ +int64_t MockMediaResource::GetNextCachedData(int64_t aOffset) { if (!aOffset) { return mRanges.Length() ? mRanges[0].mStart : -1; } for (size_t i = 0; i < mRanges.Length(); i++) { if (aOffset == mRanges[i].mStart) { ++i; return i < mRanges.Length() ? mRanges[i].mStart : -1; } } return -1; } -int64_t -MockMediaResource::GetCachedDataEnd(int64_t aOffset) -{ +int64_t MockMediaResource::GetCachedDataEnd(int64_t aOffset) { for (size_t i = 0; i < mRanges.Length(); i++) { if (aOffset == mRanges[i].mStart) { return mRanges[i].mEnd; } } return aOffset; } -nsresult -MockMediaResource::GetCachedRanges(MediaByteRangeSet& aRanges) -{ +nsresult MockMediaResource::GetCachedRanges(MediaByteRangeSet& aRanges) { aRanges = mRanges; return NS_OK; } -} // namespace mozilla +} // namespace mozilla
--- a/dom/media/gtest/MockMediaResource.h +++ b/dom/media/gtest/MockMediaResource.h @@ -8,55 +8,49 @@ #include "MediaResource.h" #include "nsTArray.h" #include "mozilla/Atomics.h" namespace mozilla { DDLoggedTypeDeclNameAndBase(MockMediaResource, MediaResource); -class MockMediaResource - : public MediaResource - , public DecoderDoctorLifeLogger<MockMediaResource> -{ -public: +class MockMediaResource : public MediaResource, + public DecoderDoctorLifeLogger<MockMediaResource> { + public: explicit MockMediaResource(const char* aFileName); nsresult ReadAt(int64_t aOffset, char* aBuffer, uint32_t aCount, uint32_t* aBytes) override; // Data stored in file, caching recommended. bool ShouldCacheReads() override { return true; } void Pin() override {} void Unpin() override {} int64_t GetLength() override; int64_t GetNextCachedData(int64_t aOffset) override; int64_t GetCachedDataEnd(int64_t aOffset) override; - bool IsDataCachedToEndOfResource(int64_t aOffset) override - { - return false; - } + bool IsDataCachedToEndOfResource(int64_t aOffset) override { return false; } nsresult ReadFromCache(char* aBuffer, int64_t aOffset, - uint32_t aCount) override - { + uint32_t aCount) override { uint32_t bytesRead = 0; nsresult rv = ReadAt(aOffset, aBuffer, aCount, &bytesRead); NS_ENSURE_SUCCESS(rv, rv); return bytesRead == aCount ? NS_OK : NS_ERROR_FAILURE; } nsresult Open(); nsresult GetCachedRanges(MediaByteRangeSet& aRanges) override; void MockClearBufferedRanges(); void MockAddBufferedRange(int64_t aStart, int64_t aEnd); -protected: + protected: virtual ~MockMediaResource(); -private: + private: FILE* mFileHandle; const char* mFileName; MediaByteRangeSet mRanges; Atomic<int> mEntry; }; -} // namespace mozilla +} // namespace mozilla #endif
--- a/dom/media/gtest/TestAudioBuffers.cpp +++ b/dom/media/gtest/TestAudioBuffers.cpp @@ -5,18 +5,17 @@ #include <stdint.h> #include "AudioBufferUtils.h" #include "gtest/gtest.h" #include <vector> const uint32_t FRAMES = 256; -void test_for_number_of_channels(const uint32_t channels) -{ +void test_for_number_of_channels(const uint32_t channels) { const uint32_t samples = channels * FRAMES; mozilla::AudioCallbackBufferWrapper<float> mBuffer(channels); mozilla::SpillBuffer<float, 128> b(channels); std::vector<float> fromCallback(samples, 0.0); std::vector<float> other(samples, 1.0); // Set the buffer in the wrapper from the callback @@ -36,25 +35,24 @@ void test_for_number_of_channels(const u ASSERT_TRUE(mBuffer.Available() == FRAMES - 32); // Fill the buffer with the rest of the data mBuffer.WriteFrames(other.data() + 32 * channels, FRAMES - 32); // Check the buffer is now full ASSERT_TRUE(mBuffer.Available() == 0); - for (uint32_t i = 0 ; i < samples; i++) { - ASSERT_TRUE(fromCallback[i] == 1.0) << - "Difference at " << i << " (" << fromCallback[i] << " != " << 1.0 << - ")\n"; + for (uint32_t i = 0; i < samples; i++) { + ASSERT_TRUE(fromCallback[i] == 1.0) + << "Difference at " << i << " (" << fromCallback[i] << " != " << 1.0 + << ")\n"; } ASSERT_TRUE(b.Fill(other.data(), FRAMES) == 128); ASSERT_TRUE(b.Fill(other.data(), FRAMES) == 0); 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); } }
--- a/dom/media/gtest/TestAudioCompactor.cpp +++ b/dom/media/gtest/TestAudioCompactor.cpp @@ -8,57 +8,52 @@ #include "nsIMemoryReporter.h" using mozilla::AudioCompactor; using mozilla::AudioData; using mozilla::AudioDataValue; using mozilla::MediaQueue; class MemoryFunctor : public nsDequeFunctor { -public: + public: MemoryFunctor() : mSize(0) {} MOZ_DEFINE_MALLOC_SIZE_OF(MallocSizeOf); - void operator()(void* aObject) override - { - const AudioData* audioData = static_cast<const AudioData*>(aObject); + void operator()(void *aObject) override { + const AudioData *audioData = static_cast<const AudioData *>(aObject); mSize += audioData->SizeOfIncludingThis(MallocSizeOf); } size_t mSize; }; -class TestCopy -{ -public: - TestCopy(uint32_t aFrames, uint32_t aChannels, - uint32_t &aCallCount, uint32_t &aFrameCount) - : mFrames(aFrames) - , mChannels(aChannels) - , mCallCount(aCallCount) - , mFrameCount(aFrameCount) - { } +class TestCopy { + public: + TestCopy(uint32_t aFrames, uint32_t aChannels, uint32_t &aCallCount, + uint32_t &aFrameCount) + : mFrames(aFrames), + mChannels(aChannels), + mCallCount(aCallCount), + mFrameCount(aFrameCount) {} - uint32_t operator()(AudioDataValue *aBuffer, uint32_t aSamples) - { + uint32_t operator()(AudioDataValue *aBuffer, uint32_t aSamples) { mCallCount += 1; uint32_t frames = std::min(mFrames - mFrameCount, aSamples / mChannels); mFrameCount += frames; return frames; } -private: + private: const uint32_t mFrames; const uint32_t mChannels; uint32_t &mCallCount; uint32_t &mFrameCount; }; -static void TestAudioCompactor(size_t aBytes) -{ +static void TestAudioCompactor(size_t aBytes) { MediaQueue<AudioData> queue; AudioCompactor compactor(queue); uint64_t offset = 0; uint64_t time = 0; uint32_t sampleRate = 44000; uint32_t channels = 2; uint32_t frames = aBytes / (channels * sizeof(AudioDataValue)); @@ -75,38 +70,25 @@ static void TestAudioCompactor(size_t aB MemoryFunctor memoryFunc; queue.LockedForEach(memoryFunc); size_t allocSize = memoryFunc.mSize - (callCount * sizeof(AudioData)); size_t slop = allocSize - 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); const uint32_t srcFrames = srcSamples / channels; uint8_t src[srcBytes]; for (uint32_t i = 0; i < srcBytes; ++i) { src[i] = i;
--- a/dom/media/gtest/TestAudioDeviceEnumerator.cpp +++ b/dom/media/gtest/TestAudioDeviceEnumerator.cpp @@ -11,130 +11,109 @@ #include "nsTArray.h" using namespace mozilla; const bool DEBUG_PRINTS = false; // Keep those and the struct definition in sync with cubeb.h and // cubeb-internal.h -void -cubeb_mock_destroy(cubeb* context); -static int -cubeb_mock_enumerate_devices(cubeb* context, - cubeb_device_type type, - cubeb_device_collection* out); +void cubeb_mock_destroy(cubeb* context); +static int cubeb_mock_enumerate_devices(cubeb* context, cubeb_device_type type, + cubeb_device_collection* out); -static int -cubeb_mock_device_collection_destroy(cubeb* context, - cubeb_device_collection* collection); +static int cubeb_mock_device_collection_destroy( + cubeb* context, cubeb_device_collection* collection); -static int -cubeb_mock_register_device_collection_changed( - cubeb* context, - cubeb_device_type devtype, - cubeb_device_collection_changed_callback callback, - void* user_ptr); +static int cubeb_mock_register_device_collection_changed( + cubeb* context, cubeb_device_type devtype, + cubeb_device_collection_changed_callback callback, void* user_ptr); -struct cubeb_ops -{ +struct cubeb_ops { int (*init)(cubeb** context, char const* context_name); char const* (*get_backend_id)(cubeb* context); int (*get_max_channel_count)(cubeb* context, uint32_t* max_channels); - int (*get_min_latency)(cubeb* context, - cubeb_stream_params params, + int (*get_min_latency)(cubeb* context, cubeb_stream_params params, uint32_t* latency_ms); int (*get_preferred_sample_rate)(cubeb* context, uint32_t* rate); - int (*enumerate_devices)(cubeb* context, - cubeb_device_type type, + int (*enumerate_devices)(cubeb* context, cubeb_device_type type, cubeb_device_collection* collection); int (*device_collection_destroy)(cubeb* context, cubeb_device_collection* collection); void (*destroy)(cubeb* context); - int (*stream_init)(cubeb* context, - cubeb_stream** stream, - char const* stream_name, - cubeb_devid input_device, + int (*stream_init)(cubeb* context, cubeb_stream** stream, + char const* stream_name, cubeb_devid input_device, cubeb_stream_params* input_stream_params, cubeb_devid output_device, cubeb_stream_params* output_stream_params, - unsigned int latency, - cubeb_data_callback data_callback, - cubeb_state_callback state_callback, - void* user_ptr); + unsigned int latency, cubeb_data_callback data_callback, + cubeb_state_callback state_callback, void* user_ptr); void (*stream_destroy)(cubeb_stream* stream); int (*stream_start)(cubeb_stream* stream); int (*stream_stop)(cubeb_stream* stream); int (*stream_reset_default_device)(cubeb_stream* stream); int (*stream_get_position)(cubeb_stream* stream, uint64_t* position); int (*stream_get_latency)(cubeb_stream* stream, uint32_t* latency); int (*stream_set_volume)(cubeb_stream* stream, float volumes); int (*stream_set_panning)(cubeb_stream* stream, float panning); int (*stream_get_current_device)(cubeb_stream* stream, cubeb_device** const device); int (*stream_device_destroy)(cubeb_stream* stream, cubeb_device* device); int (*stream_register_device_changed_callback)( - cubeb_stream* stream, - cubeb_device_changed_callback device_changed_callback); + cubeb_stream* stream, + cubeb_device_changed_callback device_changed_callback); int (*register_device_collection_changed)( - cubeb* context, - cubeb_device_type devtype, - cubeb_device_collection_changed_callback callback, - void* user_ptr); + cubeb* context, cubeb_device_type devtype, + cubeb_device_collection_changed_callback callback, void* user_ptr); }; // Mock cubeb impl, only supports device enumeration for now. cubeb_ops const mock_ops = { - /*.init =*/NULL, - /*.get_backend_id =*/NULL, - /*.get_max_channel_count =*/NULL, - /*.get_min_latency =*/NULL, - /*.get_preferred_sample_rate =*/NULL, - /*.enumerate_devices =*/cubeb_mock_enumerate_devices, - /*.device_collection_destroy =*/cubeb_mock_device_collection_destroy, - /*.destroy =*/cubeb_mock_destroy, - /*.stream_init =*/NULL, - /*.stream_destroy =*/NULL, - /*.stream_start =*/NULL, - /*.stream_stop =*/NULL, - /*.stream_reset_default_device =*/NULL, - /*.stream_get_position =*/NULL, - /*.stream_get_latency =*/NULL, - /*.stream_set_volume =*/NULL, - /*.stream_set_panning =*/NULL, - /*.stream_get_current_device =*/NULL, - /*.stream_device_destroy =*/NULL, - /*.stream_register_device_changed_callback =*/NULL, - /*.register_device_collection_changed =*/ - cubeb_mock_register_device_collection_changed -}; + /*.init =*/NULL, + /*.get_backend_id =*/NULL, + /*.get_max_channel_count =*/NULL, + /*.get_min_latency =*/NULL, + /*.get_preferred_sample_rate =*/NULL, + /*.enumerate_devices =*/cubeb_mock_enumerate_devices, + /*.device_collection_destroy =*/cubeb_mock_device_collection_destroy, + /*.destroy =*/cubeb_mock_destroy, + /*.stream_init =*/NULL, + /*.stream_destroy =*/NULL, + /*.stream_start =*/NULL, + /*.stream_stop =*/NULL, + /*.stream_reset_default_device =*/NULL, + /*.stream_get_position =*/NULL, + /*.stream_get_latency =*/NULL, + /*.stream_set_volume =*/NULL, + /*.stream_set_panning =*/NULL, + /*.stream_get_current_device =*/NULL, + /*.stream_device_destroy =*/NULL, + /*.stream_register_device_changed_callback =*/NULL, + /*.register_device_collection_changed =*/ + cubeb_mock_register_device_collection_changed}; // This class has two facets: it is both a fake cubeb backend that is intended // to be used for testing, and passed to Gecko code that expects a normal // backend, but is also controllable by the test code to decide what the backend // should do, depending on what is being tested. -class MockCubeb -{ -public: +class MockCubeb { + public: MockCubeb() - : ops(&mock_ops) - , mInputDeviceCollectionChangeCallback(nullptr) - , mOutputDeviceCollectionChangeCallback(nullptr) - , mInputDeviceCollectionChangeUserPtr(nullptr) - , mOutputDeviceCollectionChangeUserPtr(nullptr) - , mSupportsDeviceCollectionChangedCallback(true) - { - } + : ops(&mock_ops), + mInputDeviceCollectionChangeCallback(nullptr), + mOutputDeviceCollectionChangeCallback(nullptr), + mInputDeviceCollectionChangeUserPtr(nullptr), + mOutputDeviceCollectionChangeUserPtr(nullptr), + mSupportsDeviceCollectionChangedCallback(true) {} // Cubeb backend implementation // This allows passing this class as a cubeb* instance. cubeb* AsCubebContext() { return reinterpret_cast<cubeb*>(this); } // Fill in the collection parameter with all devices of aType. int EnumerateDevices(cubeb_device_type aType, - cubeb_device_collection* collection) - { + cubeb_device_collection* collection) { #ifdef ANDROID EXPECT_TRUE(false) << "This is not to be called on Android."; #endif size_t count = 0; if (aType & CUBEB_DEVICE_TYPE_INPUT) { count += mInputDevices.Length(); } if (aType & CUBEB_DEVICE_TYPE_OUTPUT) { @@ -159,20 +138,18 @@ public: return CUBEB_OK; } // For a given device type, add a callback, called with a user pointer, when // the device collection for this backend changes (i.e. a device has been // removed or added). int RegisterDeviceCollectionChangeCallback( - cubeb_device_type aDevType, - cubeb_device_collection_changed_callback aCallback, - void* aUserPtr) - { + cubeb_device_type aDevType, + cubeb_device_collection_changed_callback aCallback, void* aUserPtr) { if (!mSupportsDeviceCollectionChangedCallback) { return CUBEB_ERROR; } if (aDevType & CUBEB_DEVICE_TYPE_INPUT) { mInputDeviceCollectionChangeCallback = aCallback; mInputDeviceCollectionChangeUserPtr = aUserPtr; } @@ -183,203 +160,175 @@ public: return CUBEB_OK; } // Control API // Add an input or output device to this backend. This calls the device // collection invalidation callback if needed. - void AddDevice(cubeb_device_info aDevice) - { + void AddDevice(cubeb_device_info aDevice) { if (aDevice.type == CUBEB_DEVICE_TYPE_INPUT) { mInputDevices.AppendElement(aDevice); } else if (aDevice.type == CUBEB_DEVICE_TYPE_OUTPUT) { mOutputDevices.AppendElement(aDevice); } else { MOZ_CRASH("bad device type when adding a device in mock cubeb backend"); } bool isInput = aDevice.type & CUBEB_DEVICE_TYPE_INPUT; if (isInput && mInputDeviceCollectionChangeCallback) { mInputDeviceCollectionChangeCallback(AsCubebContext(), mInputDeviceCollectionChangeUserPtr); } if (!isInput && mOutputDeviceCollectionChangeCallback) { - mOutputDeviceCollectionChangeCallback(AsCubebContext(), - mOutputDeviceCollectionChangeUserPtr); + mOutputDeviceCollectionChangeCallback( + AsCubebContext(), mOutputDeviceCollectionChangeUserPtr); } } // Remove a specific input or output device to this backend, returns true if // a device was removed. This calls the device collection invalidation // callback if needed. - bool RemoveDevice(cubeb_devid aId) - { + bool RemoveDevice(cubeb_devid aId) { bool foundInput = false; bool foundOutput = false; mInputDevices.RemoveElementsBy( - [aId, &foundInput](cubeb_device_info& aDeviceInfo) { - bool foundThisTime = aDeviceInfo.devid == aId; - foundInput |= foundThisTime; - return foundThisTime; - }); + [aId, &foundInput](cubeb_device_info& aDeviceInfo) { + bool foundThisTime = aDeviceInfo.devid == aId; + foundInput |= foundThisTime; + return foundThisTime; + }); mOutputDevices.RemoveElementsBy( - [aId, &foundOutput](cubeb_device_info& aDeviceInfo) { - bool foundThisTime = aDeviceInfo.devid == aId; - foundOutput |= foundThisTime; - return foundThisTime; - }); + [aId, &foundOutput](cubeb_device_info& aDeviceInfo) { + bool foundThisTime = aDeviceInfo.devid == aId; + foundOutput |= foundThisTime; + return foundThisTime; + }); if (foundInput && mInputDeviceCollectionChangeCallback) { mInputDeviceCollectionChangeCallback(AsCubebContext(), mInputDeviceCollectionChangeUserPtr); } if (foundOutput && mOutputDeviceCollectionChangeCallback) { - mOutputDeviceCollectionChangeCallback(AsCubebContext(), - mOutputDeviceCollectionChangeUserPtr); + mOutputDeviceCollectionChangeCallback( + AsCubebContext(), mOutputDeviceCollectionChangeUserPtr); } // If the device removed was a default device, set another device as the // default, if there are still devices available. bool foundDefault = false; for (uint32_t i = 0; i < mInputDevices.Length(); i++) { foundDefault |= mInputDevices[i].preferred != CUBEB_DEVICE_PREF_NONE; } if (!foundDefault) { if (!mInputDevices.IsEmpty()) { mInputDevices[mInputDevices.Length() - 1].preferred = - CUBEB_DEVICE_PREF_ALL; + CUBEB_DEVICE_PREF_ALL; } } foundDefault = false; for (uint32_t i = 0; i < mOutputDevices.Length(); i++) { foundDefault |= mOutputDevices[i].preferred != CUBEB_DEVICE_PREF_NONE; } if (!foundDefault) { if (!mOutputDevices.IsEmpty()) { mOutputDevices[mOutputDevices.Length() - 1].preferred = - CUBEB_DEVICE_PREF_ALL; + CUBEB_DEVICE_PREF_ALL; } } return foundInput | foundOutput; } // Remove all input or output devices from this backend, without calling the // callback. This is meant to clean up in between tests. - void ClearDevices(cubeb_device_type aType) - { + void ClearDevices(cubeb_device_type aType) { mInputDevices.Clear(); mOutputDevices.Clear(); } // This allows simulating a backend that does not support setting a device // collection invalidation callback, to be able to test the fallback path. - void SetSupportDeviceChangeCallback(bool aSupports) - { + void SetSupportDeviceChangeCallback(bool aSupports) { mSupportsDeviceCollectionChangedCallback = aSupports; } -private: + private: // This needs to have the exact same memory layout as a real cubeb backend. // It's very important for this `ops` member to be the very first member of // the class, and to not have any virtual members (to avoid having a vtable). const cubeb_ops* ops; // The callback to call when the device list has been changed. cubeb_device_collection_changed_callback mInputDeviceCollectionChangeCallback; - cubeb_device_collection_changed_callback mOutputDeviceCollectionChangeCallback; + cubeb_device_collection_changed_callback + mOutputDeviceCollectionChangeCallback; // The pointer to pass in the callback. void* mInputDeviceCollectionChangeUserPtr; void* mOutputDeviceCollectionChangeUserPtr; // Whether or not this backend supports device collection change notification // via a system callback. If not, Gecko is expected to re-query the list every // time. bool mSupportsDeviceCollectionChangedCallback; // Our input and output devices. nsTArray<cubeb_device_info> mInputDevices; nsTArray<cubeb_device_info> mOutputDevices; }; -void -cubeb_mock_destroy(cubeb* context) -{ +void cubeb_mock_destroy(cubeb* context) { delete reinterpret_cast<MockCubeb*>(context); } -static int -cubeb_mock_enumerate_devices(cubeb* context, - cubeb_device_type type, - cubeb_device_collection* out) -{ +static int cubeb_mock_enumerate_devices(cubeb* context, cubeb_device_type type, + cubeb_device_collection* out) { MockCubeb* mock = reinterpret_cast<MockCubeb*>(context); return mock->EnumerateDevices(type, out); } -int -cubeb_mock_device_collection_destroy(cubeb* context, - cubeb_device_collection* collection) -{ +int cubeb_mock_device_collection_destroy(cubeb* context, + cubeb_device_collection* collection) { delete[] collection->device; return CUBEB_OK; } -int -cubeb_mock_register_device_collection_changed( - cubeb* context, - cubeb_device_type devtype, - cubeb_device_collection_changed_callback callback, - void* user_ptr) -{ +int cubeb_mock_register_device_collection_changed( + cubeb* context, cubeb_device_type devtype, + cubeb_device_collection_changed_callback callback, void* user_ptr) { MockCubeb* mock = reinterpret_cast<MockCubeb*>(context); - return mock->RegisterDeviceCollectionChangeCallback( - devtype, callback, user_ptr); + return mock->RegisterDeviceCollectionChangeCallback(devtype, callback, + user_ptr); return CUBEB_OK; } -void -PrintDevice(cubeb_device_info aInfo) -{ - printf("id: %zu\n" - "device_id: %s\n" - "friendly_name: %s\n" - "group_id: %s\n" - "vendor_name: %s\n" - "type: %d\n" - "state: %d\n" - "preferred: %d\n" - "format: %d\n" - "default_format: %d\n" - "max_channels: %d\n" - "default_rate: %d\n" - "max_rate: %d\n" - "min_rate: %d\n" - "latency_lo: %d\n" - "latency_hi: %d\n", - reinterpret_cast<uintptr_t>(aInfo.devid), - aInfo.device_id, - aInfo.friendly_name, - aInfo.group_id, - aInfo.vendor_name, - aInfo.type, - aInfo.state, - aInfo.preferred, - aInfo.format, - aInfo.default_format, - aInfo.max_channels, - aInfo.default_rate, - aInfo.max_rate, - aInfo.min_rate, - aInfo.latency_lo, - aInfo.latency_hi); +void PrintDevice(cubeb_device_info aInfo) { + printf( + "id: %zu\n" + "device_id: %s\n" + "friendly_name: %s\n" + "group_id: %s\n" + "vendor_name: %s\n" + "type: %d\n" + "state: %d\n" + "preferred: %d\n" + "format: %d\n" + "default_format: %d\n" + "max_channels: %d\n" + "default_rate: %d\n" + "max_rate: %d\n" + "min_rate: %d\n" + "latency_lo: %d\n" + "latency_hi: %d\n", + reinterpret_cast<uintptr_t>(aInfo.devid), aInfo.device_id, + aInfo.friendly_name, aInfo.group_id, aInfo.vendor_name, aInfo.type, + aInfo.state, aInfo.preferred, aInfo.format, aInfo.default_format, + aInfo.max_channels, aInfo.default_rate, aInfo.max_rate, aInfo.min_rate, + aInfo.latency_lo, aInfo.latency_hi); } -void -PrintDevice(AudioDeviceInfo* aInfo) -{ +void PrintDevice(AudioDeviceInfo* aInfo) { cubeb_devid id; nsString name; nsString groupid; nsString vendor; uint16_t type; uint16_t state; uint16_t preferred; uint16_t supportedFormat; @@ -402,51 +351,40 @@ PrintDevice(AudioDeviceInfo* aInfo) aInfo->GetDefaultFormat(&defaultFormat); aInfo->GetMaxChannels(&maxChannels); aInfo->GetDefaultRate(&defaultRate); aInfo->GetMaxRate(&maxRate); aInfo->GetMinRate(&minRate); aInfo->GetMinLatency(&minLatency); aInfo->GetMaxLatency(&maxLatency); - printf("device id: %zu\n" - "friendly_name: %s\n" - "group_id: %s\n" - "vendor_name: %s\n" - "type: %d\n" - "state: %d\n" - "preferred: %d\n" - "format: %d\n" - "default_format: %d\n" - "max_channels: %d\n" - "default_rate: %d\n" - "max_rate: %d\n" - "min_rate: %d\n" - "latency_lo: %d\n" - "latency_hi: %d\n", - reinterpret_cast<uintptr_t>(id), - NS_LossyConvertUTF16toASCII(name).get(), - NS_LossyConvertUTF16toASCII(groupid).get(), - NS_LossyConvertUTF16toASCII(vendor).get(), - type, - state, - preferred, - supportedFormat, - defaultFormat, - maxChannels, - defaultRate, - maxRate, - minRate, - minLatency, - maxLatency); + printf( + "device id: %zu\n" + "friendly_name: %s\n" + "group_id: %s\n" + "vendor_name: %s\n" + "type: %d\n" + "state: %d\n" + "preferred: %d\n" + "format: %d\n" + "default_format: %d\n" + "max_channels: %d\n" + "default_rate: %d\n" + "max_rate: %d\n" + "min_rate: %d\n" + "latency_lo: %d\n" + "latency_hi: %d\n", + reinterpret_cast<uintptr_t>(id), NS_LossyConvertUTF16toASCII(name).get(), + NS_LossyConvertUTF16toASCII(groupid).get(), + NS_LossyConvertUTF16toASCII(vendor).get(), type, state, preferred, + supportedFormat, defaultFormat, maxChannels, defaultRate, maxRate, + minRate, minLatency, maxLatency); } -cubeb_device_info -DeviceTemplate(cubeb_devid aId, cubeb_device_type aType) -{ +cubeb_device_info DeviceTemplate(cubeb_devid aId, cubeb_device_type aType) { // A fake input device cubeb_device_info device; device.devid = aId; device.device_id = "nice name"; device.friendly_name = "an even nicer name"; device.group_id = "the physical device"; device.vendor_name = "mozilla"; device.type = aType; @@ -459,42 +397,35 @@ DeviceTemplate(cubeb_devid aId, cubeb_de device.max_rate = 44100; device.min_rate = 16000; device.latency_lo = 256; device.latency_hi = 1024; return device; } -enum DeviceOperation -{ - ADD, - REMOVE -}; +enum DeviceOperation { ADD, REMOVE }; -void -TestEnumeration(MockCubeb* aMock, - uint32_t aExpectedDeviceCount, - DeviceOperation aOperation, - cubeb_device_type aType) -{ - RefPtr<CubebDeviceEnumerator> enumerator = CubebDeviceEnumerator::GetInstance(); +void TestEnumeration(MockCubeb* aMock, uint32_t aExpectedDeviceCount, + DeviceOperation aOperation, cubeb_device_type aType) { + RefPtr<CubebDeviceEnumerator> enumerator = + CubebDeviceEnumerator::GetInstance(); nsTArray<RefPtr<AudioDeviceInfo>> devices; if (aType == CUBEB_DEVICE_TYPE_INPUT) { enumerator->EnumerateAudioInputDevices(devices); } if (aType == CUBEB_DEVICE_TYPE_OUTPUT) { enumerator->EnumerateAudioOutputDevices(devices); } EXPECT_EQ(devices.Length(), aExpectedDeviceCount) - << "Device count is correct when enumerating"; + << "Device count is correct when enumerating"; if (DEBUG_PRINTS) { for (uint32_t i = 0; i < devices.Length(); i++) { printf("=== Before removal\n"); PrintDevice(devices[i]); } } @@ -508,66 +439,62 @@ TestEnumeration(MockCubeb* aMock, enumerator->EnumerateAudioInputDevices(devices); } if (aType == CUBEB_DEVICE_TYPE_OUTPUT) { enumerator->EnumerateAudioOutputDevices(devices); } uint32_t newExpectedDeviceCount = aOperation == DeviceOperation::REMOVE - ? aExpectedDeviceCount - 1 - : aExpectedDeviceCount + 1; + ? aExpectedDeviceCount - 1 + : aExpectedDeviceCount + 1; EXPECT_EQ(devices.Length(), newExpectedDeviceCount) - << "Device count is correct when enumerating after operation"; + << "Device count is correct when enumerating after operation"; if (DEBUG_PRINTS) { for (uint32_t i = 0; i < devices.Length(); i++) { printf("=== After removal\n"); PrintDevice(devices[i]); } } } -void -AddDevices(MockCubeb* mock, - uint32_t device_count, - cubeb_device_type deviceType) -{ +void AddDevices(MockCubeb* mock, uint32_t device_count, + cubeb_device_type deviceType) { mock->ClearDevices(deviceType); // Add a few input devices (almost all the same but it does not really // matter as long as they have distinct IDs and only one is the default // devices) for (uintptr_t i = 0; i < device_count; i++) { cubeb_device_info device = - DeviceTemplate(reinterpret_cast<void*>(i + 1), deviceType); + DeviceTemplate(reinterpret_cast<void*>(i + 1), deviceType); // Make it so that the last device is the default input device. if (i == device_count - 1) { device.preferred = CUBEB_DEVICE_PREF_ALL; } mock->AddDevice(device); } } #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. MockCubeb* mock = new MockCubeb(); mozilla::CubebUtils::ForceSetCubebContext(mock->AsCubebContext()); // We want to test whether CubebDeviceEnumerator works with and without a // backend that can notify of a device collection change via callback. // Additionally, we're testing that both adding and removing a device // invalidates the list correctly. - bool supportsDeviceChangeCallback[2] = { true, false }; - DeviceOperation operations[2] = { DeviceOperation::ADD, - DeviceOperation::REMOVE }; + bool supportsDeviceChangeCallback[2] = {true, false}; + DeviceOperation operations[2] = {DeviceOperation::ADD, + DeviceOperation::REMOVE}; for (bool supports : supportsDeviceChangeCallback) { // Shutdown for `supports` to take effect CubebDeviceEnumerator::Shutdown(); mock->SetSupportDeviceChangeCallback(supports); for (DeviceOperation op : operations) { uint32_t device_count = 4; @@ -579,76 +506,84 @@ TEST(CubebDeviceEnumerator, EnumerateSim AddDevices(mock, device_count, deviceType); TestEnumeration(mock, device_count, op, deviceType); } } // Shutdown to clean up the last `supports` effect CubebDeviceEnumerator::Shutdown(); } -#else // building for Android, which has no device enumeration support -TEST(CubebDeviceEnumerator, EnumerateAndroid) -{ +#else // building for Android, which has no device enumeration support +TEST(CubebDeviceEnumerator, EnumerateAndroid) { MockCubeb* mock = new MockCubeb(); mozilla::CubebUtils::ForceSetCubebContext(mock->AsCubebContext()); - RefPtr<CubebDeviceEnumerator> enumerator = CubebDeviceEnumerator::GetInstance(); + RefPtr<CubebDeviceEnumerator> enumerator = + CubebDeviceEnumerator::GetInstance(); nsTArray<RefPtr<AudioDeviceInfo>> inputDevices; enumerator->EnumerateAudioInputDevices(inputDevices); - EXPECT_EQ(inputDevices.Length(), 1u) << "Android always exposes a single input device."; + EXPECT_EQ(inputDevices.Length(), 1u) + << "Android always exposes a single input device."; EXPECT_EQ(inputDevices[0]->MaxChannels(), 1u) << "With a single channel."; - EXPECT_EQ(inputDevices[0]->DeviceID(), nullptr) << "It's always the default input device."; - EXPECT_TRUE(inputDevices[0]->Preferred()) << "it's always the prefered input device."; + EXPECT_EQ(inputDevices[0]->DeviceID(), nullptr) + << "It's always the default input device."; + EXPECT_TRUE(inputDevices[0]->Preferred()) + << "it's always the prefered input device."; nsTArray<RefPtr<AudioDeviceInfo>> outputDevices; enumerator->EnumerateAudioOutputDevices(outputDevices); - EXPECT_EQ(outputDevices.Length(), 1u) << "Android always exposes a single output device."; + EXPECT_EQ(outputDevices.Length(), 1u) + << "Android always exposes a single output device."; EXPECT_EQ(outputDevices[0]->MaxChannels(), 2u) << "With stereo channels."; - EXPECT_EQ(outputDevices[0]->DeviceID(), nullptr) << "It's always the default output device."; - EXPECT_TRUE(outputDevices[0]->Preferred()) << "it's always the prefered output device."; + EXPECT_EQ(outputDevices[0]->DeviceID(), nullptr) + << "It's always the default output device."; + EXPECT_TRUE(outputDevices[0]->Preferred()) + << "it's always the prefered output device."; } #endif -TEST(CubebDeviceEnumerator, ForceNullCubebContext) -{ +TEST(CubebDeviceEnumerator, ForceNullCubebContext) { mozilla::CubebUtils::ForceSetCubebContext(nullptr); - RefPtr<CubebDeviceEnumerator> enumerator = CubebDeviceEnumerator::GetInstance(); + RefPtr<CubebDeviceEnumerator> enumerator = + CubebDeviceEnumerator::GetInstance(); nsTArray<RefPtr<AudioDeviceInfo>> inputDevices; enumerator->EnumerateAudioInputDevices(inputDevices); - EXPECT_EQ(inputDevices.Length(), 0u) << "Enumeration must fail, input device list must be empty."; + EXPECT_EQ(inputDevices.Length(), 0u) + << "Enumeration must fail, input device list must be empty."; nsTArray<RefPtr<AudioDeviceInfo>> outputDevices; enumerator->EnumerateAudioOutputDevices(outputDevices); - EXPECT_EQ(outputDevices.Length(), 0u) << "Enumeration must fail, output device list must be empty."; + EXPECT_EQ(outputDevices.Length(), 0u) + << "Enumeration must fail, output device list must be empty."; // Shutdown to clean up the null context effect CubebDeviceEnumerator::Shutdown(); } -TEST(CubebDeviceEnumerator, DeviceInfoFromId) -{ +TEST(CubebDeviceEnumerator, DeviceInfoFromId) { MockCubeb* mock = new MockCubeb(); mozilla::CubebUtils::ForceSetCubebContext(mock->AsCubebContext()); uint32_t device_count = 4; cubeb_device_type deviceTypes[2] = {CUBEB_DEVICE_TYPE_INPUT, - CUBEB_DEVICE_TYPE_OUTPUT}; + CUBEB_DEVICE_TYPE_OUTPUT}; - bool supportsDeviceChangeCallback[2] = { true, false }; + bool supportsDeviceChangeCallback[2] = {true, false}; for (bool supports : supportsDeviceChangeCallback) { // Shutdown for `supports` to take effect CubebDeviceEnumerator::Shutdown(); mock->SetSupportDeviceChangeCallback(supports); for (cubeb_device_type& deviceType : deviceTypes) { AddDevices(mock, device_count, deviceType); cubeb_devid id_1 = reinterpret_cast<cubeb_devid>(1); - RefPtr<CubebDeviceEnumerator> enumerator = CubebDeviceEnumerator::GetInstance(); + RefPtr<CubebDeviceEnumerator> enumerator = + CubebDeviceEnumerator::GetInstance(); RefPtr<AudioDeviceInfo> devInfo = enumerator->DeviceInfoFromID(id_1); EXPECT_TRUE(devInfo) << "the device exist"; EXPECT_EQ(devInfo->DeviceID(), id_1) << "verify the device"; mock->RemoveDevice(id_1); devInfo = enumerator->DeviceInfoFromID(id_1); EXPECT_FALSE(devInfo) << "the device does not exist any more";
--- a/dom/media/gtest/TestAudioMixer.cpp +++ b/dom/media/gtest/TestAudioMixer.cpp @@ -6,82 +6,84 @@ #include "AudioMixer.h" #include "gtest/gtest.h" using mozilla::AudioDataValue; using mozilla::AudioSampleFormat; namespace audio_mixer { -struct MixerConsumer : public mozilla::MixerCallbackReceiver -{ -/* In this test, the different audio stream and channels are always created to - * cancel each other. */ - void MixerCallback(AudioDataValue* aData, AudioSampleFormat aFormat, uint32_t aChannels, uint32_t aFrames, uint32_t aSampleRate) - { +struct MixerConsumer : public mozilla::MixerCallbackReceiver { + /* In this test, the different audio stream and channels are always created to + * cancel each other. */ + void MixerCallback(AudioDataValue* aData, AudioSampleFormat aFormat, + uint32_t aChannels, uint32_t aFrames, + uint32_t aSampleRate) { bool silent = true; for (uint32_t i = 0; i < aChannels * aFrames; i++) { if (aData[i] != 0.0) { if (aFormat == mozilla::AUDIO_FORMAT_S16) { - fprintf(stderr, "Sample at %d is not silent: %d\n", i, (short)aData[i]); + fprintf(stderr, "Sample at %d is not silent: %d\n", i, + (short)aData[i]); } else { - fprintf(stderr, "Sample at %d is not silent: %f\n", i, (float)aData[i]); + fprintf(stderr, "Sample at %d is not silent: %f\n", i, + (float)aData[i]); } silent = false; } } ASSERT_TRUE(silent); } }; /* Helper function to give us the maximum and minimum value that don't clip, * for a given sample format (integer or floating-point). */ -template<typename T> +template <typename T> T GetLowValue(); -template<typename T> +template <typename T> T GetHighValue(); -template<> +template <> float GetLowValue<float>() { return -1.0; } -template<> +template <> short GetLowValue<short>() { return -INT16_MAX; } -template<> +template <> float GetHighValue<float>() { return 1.0; } -template<> +template <> short GetHighValue<short>() { return INT16_MAX; } -void FillBuffer(AudioDataValue* aBuffer, uint32_t aLength, AudioDataValue aValue) -{ +void FillBuffer(AudioDataValue* aBuffer, uint32_t aLength, + AudioDataValue aValue) { AudioDataValue* end = aBuffer + aLength; while (aBuffer != end) { *aBuffer++ = aValue; } } -TEST(AudioMixer, Test) -{ +TEST(AudioMixer, Test) { const uint32_t CHANNEL_LENGTH = 256; const uint32_t AUDIO_RATE = 44100; MixerConsumer consumer; AudioDataValue a[CHANNEL_LENGTH * 2]; AudioDataValue b[CHANNEL_LENGTH * 2]; FillBuffer(a, CHANNEL_LENGTH, GetLowValue<AudioDataValue>()); - FillBuffer(a + CHANNEL_LENGTH, CHANNEL_LENGTH, GetHighValue<AudioDataValue>()); + FillBuffer(a + CHANNEL_LENGTH, CHANNEL_LENGTH, + GetHighValue<AudioDataValue>()); FillBuffer(b, CHANNEL_LENGTH, GetHighValue<AudioDataValue>()); FillBuffer(b + CHANNEL_LENGTH, CHANNEL_LENGTH, GetLowValue<AudioDataValue>()); { int iterations = 2; mozilla::AudioMixer mixer; mixer.AddCallback(&consumer); @@ -96,33 +98,39 @@ TEST(AudioMixer, Test) { mozilla::AudioMixer mixer; mixer.AddCallback(&consumer); fprintf(stderr, "Test AudioMixer variable buffer length.\n"); FillBuffer(a, CHANNEL_LENGTH / 2, GetLowValue<AudioDataValue>()); - FillBuffer(a + CHANNEL_LENGTH / 2, CHANNEL_LENGTH / 2, GetLowValue<AudioDataValue>()); + FillBuffer(a + CHANNEL_LENGTH / 2, CHANNEL_LENGTH / 2, + GetLowValue<AudioDataValue>()); FillBuffer(b, CHANNEL_LENGTH / 2, GetHighValue<AudioDataValue>()); - FillBuffer(b + CHANNEL_LENGTH / 2, CHANNEL_LENGTH / 2, GetHighValue<AudioDataValue>()); + FillBuffer(b + CHANNEL_LENGTH / 2, CHANNEL_LENGTH / 2, + GetHighValue<AudioDataValue>()); mixer.Mix(a, 2, CHANNEL_LENGTH / 2, AUDIO_RATE); mixer.Mix(b, 2, CHANNEL_LENGTH / 2, AUDIO_RATE); mixer.FinishMixing(); FillBuffer(a, CHANNEL_LENGTH, GetLowValue<AudioDataValue>()); - FillBuffer(a + CHANNEL_LENGTH, CHANNEL_LENGTH, GetHighValue<AudioDataValue>()); + FillBuffer(a + CHANNEL_LENGTH, CHANNEL_LENGTH, + GetHighValue<AudioDataValue>()); FillBuffer(b, CHANNEL_LENGTH, GetHighValue<AudioDataValue>()); - FillBuffer(b + CHANNEL_LENGTH, CHANNEL_LENGTH, GetLowValue<AudioDataValue>()); + FillBuffer(b + CHANNEL_LENGTH, CHANNEL_LENGTH, + GetLowValue<AudioDataValue>()); mixer.Mix(a, 2, CHANNEL_LENGTH, AUDIO_RATE); mixer.Mix(b, 2, CHANNEL_LENGTH, AUDIO_RATE); mixer.FinishMixing(); FillBuffer(a, CHANNEL_LENGTH / 2, GetLowValue<AudioDataValue>()); - FillBuffer(a + CHANNEL_LENGTH / 2, CHANNEL_LENGTH / 2, GetLowValue<AudioDataValue>()); + FillBuffer(a + CHANNEL_LENGTH / 2, CHANNEL_LENGTH / 2, + GetLowValue<AudioDataValue>()); FillBuffer(b, CHANNEL_LENGTH / 2, GetHighValue<AudioDataValue>()); - FillBuffer(b + CHANNEL_LENGTH / 2, CHANNEL_LENGTH / 2, GetHighValue<AudioDataValue>()); + FillBuffer(b + CHANNEL_LENGTH / 2, CHANNEL_LENGTH / 2, + GetHighValue<AudioDataValue>()); mixer.Mix(a, 2, CHANNEL_LENGTH / 2, AUDIO_RATE); mixer.Mix(b, 2, CHANNEL_LENGTH / 2, AUDIO_RATE); mixer.FinishMixing(); } FillBuffer(a, CHANNEL_LENGTH, GetLowValue<AudioDataValue>()); FillBuffer(b, CHANNEL_LENGTH, GetHighValue<AudioDataValue>()); @@ -157,9 +165,9 @@ TEST(AudioMixer, Test) mixer.Mix(b, 2, CHANNEL_LENGTH, AUDIO_RATE); mixer.FinishMixing(); mixer.Mix(a, 2, CHANNEL_LENGTH, AUDIO_RATE); mixer.Mix(b, 2, CHANNEL_LENGTH, AUDIO_RATE); mixer.FinishMixing(); } } -} // namespace audio_mixer +} // namespace audio_mixer
--- a/dom/media/gtest/TestAudioPacketizer.cpp +++ b/dom/media/gtest/TestAudioPacketizer.cpp @@ -6,66 +6,54 @@ #include <stdint.h> #include <math.h> #include <memory> #include "../AudioPacketizer.h" #include "gtest/gtest.h" using namespace mozilla; -template<typename T> -class AutoBuffer -{ -public: - explicit AutoBuffer(size_t aLength) - { - mStorage = new T[aLength]; - } - ~AutoBuffer() { - delete [] mStorage; - } - T* Get() { - return mStorage; - } -private: +template <typename T> +class AutoBuffer { + public: + explicit AutoBuffer(size_t aLength) { mStorage = new T[aLength]; } + ~AutoBuffer() { delete[] mStorage; } + T* Get() { return mStorage; } + + private: T* mStorage; }; -int16_t Sequence(int16_t* aBuffer, uint32_t aSize, uint32_t aStart = 0) -{ +int16_t Sequence(int16_t* aBuffer, uint32_t aSize, uint32_t aStart = 0) { uint32_t i; for (i = 0; i < aSize; i++) { aBuffer[i] = aStart + i; } return aStart + i; } -void IsSequence(std::unique_ptr<int16_t[]> aBuffer, uint32_t aSize, uint32_t aStart = 0) -{ +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; + ASSERT_TRUE(aBuffer[i] == static_cast<int64_t>(aStart + i)) + << "Buffer is not a sequence at offset " << i << std::endl; } // Buffer is a sequence. } -void Zero(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; + ASSERT_TRUE(aBuffer[i] == 0) + << "Buffer is not null at offset " << i << std::endl; } } -double sine(uint32_t aPhase) { - return sin(aPhase * 2 * M_PI * 440 / 44100); -} +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 { AudioPacketizer<int16_t, int16_t> ap(441, channels); for (int16_t i = 0; i < 10; i++) { std::unique_ptr<int16_t[]> out(ap.Output()); Zero(std::move(out), 441); }
--- a/dom/media/gtest/TestAudioSegment.cpp +++ b/dom/media/gtest/TestAudioSegment.cpp @@ -8,184 +8,171 @@ #include "gtest/gtest.h" using namespace mozilla; namespace audio_segment { /* Helper function to give us the maximum and minimum value that don't clip, * for a given sample format (integer or floating-point). */ -template<typename T> +template <typename T> T GetLowValue(); -template<typename T> +template <typename T> T GetHighValue(); -template<typename T> +template <typename T> T GetSilentValue(); -template<> +template <> float GetLowValue<float>() { return -1.0; } -template<> +template <> int16_t GetLowValue<short>() { return -INT16_MAX; } -template<> +template <> float GetHighValue<float>() { return 1.0; } -template<> +template <> int16_t GetHighValue<short>() { return INT16_MAX; } -template<> +template <> float GetSilentValue() { return 0.0; } -template<> +template <> int16_t GetSilentValue() { return 0; } - // Get an array of planar audio buffers that has the inverse of the index of the // channel (1-indexed) as samples. -template<typename T> -const T* const* GetPlanarChannelArray(size_t aChannels, size_t aSize) -{ +template <typename T> +const T* const* GetPlanarChannelArray(size_t aChannels, size_t aSize) { T** channels = new T*[aChannels]; for (size_t c = 0; c < aChannels; c++) { channels[c] = new T[aSize]; for (size_t i = 0; i < aSize; i++) { channels[c][i] = FloatToAudioSample<T>(1. / (c + 1)); } } return channels; } -template<typename T> -void DeletePlanarChannelsArray(const T* const* aArrays, size_t aChannels) -{ +template <typename T> +void DeletePlanarChannelsArray(const T* const* aArrays, size_t aChannels) { for (size_t channel = 0; channel < aChannels; channel++) { - delete [] aArrays[channel]; + delete[] aArrays[channel]; } - delete [] aArrays; + delete[] aArrays; } -template<typename T> -T** GetPlanarArray(size_t aChannels, size_t aSize) -{ +template <typename T> +T** GetPlanarArray(size_t aChannels, size_t aSize) { T** channels = new T*[aChannels]; for (size_t c = 0; c < aChannels; c++) { channels[c] = new T[aSize]; for (size_t i = 0; i < aSize; i++) { channels[c][i] = 0.0f; } } return channels; } -template<typename T> -void DeletePlanarArray(T** aArrays, size_t aChannels) -{ +template <typename T> +void DeletePlanarArray(T** aArrays, size_t aChannels) { for (size_t channel = 0; channel < aChannels; channel++) { - delete [] aArrays[channel]; + delete[] aArrays[channel]; } - delete [] aArrays; + delete[] aArrays; } // Get an array of audio samples that have the inverse of the index of the // channel (1-indexed) as samples. -template<typename T> -const T* GetInterleavedChannelArray(size_t aChannels, size_t aSize) -{ +template <typename T> +const T* GetInterleavedChannelArray(size_t aChannels, size_t aSize) { size_t sampleCount = aChannels * aSize; T* samples = new T[sampleCount]; for (size_t i = 0; i < sampleCount; i++) { uint32_t channel = (i % aChannels) + 1; samples[i] = FloatToAudioSample<T>(1. / channel); } return samples; } -template<typename T> -void DeleteInterleavedChannelArray(const T* aArray) -{ - delete [] aArray; +template <typename T> +void DeleteInterleavedChannelArray(const T* aArray) { + delete[] aArray; } -bool FuzzyEqual(float aLhs, float aRhs) { - return std::abs(aLhs - aRhs) < 0.01; -} +bool FuzzyEqual(float aLhs, float aRhs) { return std::abs(aLhs - aRhs) < 0.01; } -template<typename SrcT, typename DstT> -void TestInterleaveAndConvert() -{ +template <typename SrcT, typename DstT> +void TestInterleaveAndConvert() { size_t arraySize = 1024; - size_t maxChannels = 8; // 7.1 + size_t maxChannels = 8; // 7.1 for (uint32_t channels = 1; channels < maxChannels; channels++) { const SrcT* const* src = GetPlanarChannelArray<SrcT>(channels, arraySize); DstT* dst = new DstT[channels * arraySize]; InterleaveAndConvertBuffer(src, arraySize, 1.0, channels, dst); uint32_t channelIndex = 0; for (size_t i = 0; i < arraySize * channels; i++) { - ASSERT_TRUE(FuzzyEqual(dst[i], - FloatToAudioSample<DstT>(1. / (channelIndex + 1)))); + ASSERT_TRUE(FuzzyEqual( + dst[i], FloatToAudioSample<DstT>(1. / (channelIndex + 1)))); channelIndex++; channelIndex %= channels; } DeletePlanarChannelsArray(src, channels); - delete [] dst; + delete[] dst; } } -template<typename SrcT, typename DstT> -void TestDeinterleaveAndConvert() -{ +template <typename SrcT, typename DstT> +void TestDeinterleaveAndConvert() { size_t arraySize = 1024; - size_t maxChannels = 8; // 7.1 + size_t maxChannels = 8; // 7.1 for (uint32_t channels = 1; channels < maxChannels; channels++) { const SrcT* src = GetInterleavedChannelArray<SrcT>(channels, arraySize); DstT** dst = GetPlanarArray<DstT>(channels, arraySize); DeinterleaveAndConvertBuffer(src, arraySize, channels, dst); for (size_t channel = 0; channel < channels; channel++) { for (size_t i = 0; i < arraySize; i++) { ASSERT_TRUE(FuzzyEqual(dst[channel][i], - FloatToAudioSample<DstT>(1. / (channel + 1)))); + FloatToAudioSample<DstT>(1. / (channel + 1)))); } } DeleteInterleavedChannelArray(src); DeletePlanarArray(dst, channels); } } uint8_t gSilence[4096] = {0}; -template<typename T> -T* SilentChannel() -{ +template <typename T> +T* SilentChannel() { return reinterpret_cast<T*>(gSilence); } -template<typename T> -void TestUpmixStereo() -{ +template <typename T> +void TestUpmixStereo() { size_t arraySize = 1024; nsTArray<T*> channels; nsTArray<const T*> channelsptr; channels.SetLength(1); channelsptr.SetLength(1); channels[0] = new T[arraySize]; @@ -197,22 +184,21 @@ void TestUpmixStereo() AudioChannelsUpMix(&channelsptr, 2, SilentChannel<T>()); for (size_t channel = 0; channel < 2; channel++) { for (size_t i = 0; i < arraySize; i++) { ASSERT_TRUE(channelsptr[channel][i] == GetHighValue<T>()); } } - delete [] channels[0]; + delete[] channels[0]; } -template<typename T> -void TestDownmixStereo() -{ +template <typename T> +void TestDownmixStereo() { const size_t arraySize = 1024; nsTArray<const T*> inputptr; nsTArray<T*> input; T** output; output = new T*[1]; output[0] = new T[arraySize]; @@ -229,29 +215,28 @@ void TestDownmixStereo() AudioChannelsDownMix(inputptr, output, 1, arraySize); for (size_t i = 0; i < arraySize; i++) { ASSERT_TRUE(output[0][i] == GetSilentValue<T>()); ASSERT_TRUE(output[0][i] == GetSilentValue<T>()); } - delete [] output[0]; - delete [] output; + delete[] output[0]; + delete[] output; } -TEST(AudioSegment, Test) -{ +TEST(AudioSegment, Test) { TestInterleaveAndConvert<float, float>(); TestInterleaveAndConvert<float, int16_t>(); TestInterleaveAndConvert<int16_t, float>(); TestInterleaveAndConvert<int16_t, int16_t>(); TestDeinterleaveAndConvert<float, float>(); TestDeinterleaveAndConvert<float, int16_t>(); TestDeinterleaveAndConvert<int16_t, float>(); TestDeinterleaveAndConvert<int16_t, int16_t>(); TestUpmixStereo<float>(); TestUpmixStereo<int16_t>(); TestDownmixStereo<float>(); TestDownmixStereo<int16_t>(); } -} // namespace audio_segment +} // namespace audio_segment
--- a/dom/media/gtest/TestAudioTrackEncoder.cpp +++ b/dom/media/gtest/TestAudioTrackEncoder.cpp @@ -4,75 +4,67 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "gtest/gtest.h" #include "OpusTrackEncoder.h" #include "SineWaveGenerator.h" using namespace mozilla; -class AudioGenerator -{ -public: +class AudioGenerator { + public: AudioGenerator(int32_t aChannels, int32_t aSampleRate) - : mGenerator(aSampleRate, 1000) - , mChannels(aChannels) - {} + : mGenerator(aSampleRate, 1000), mChannels(aChannels) {} - void Generate(AudioSegment& aSegment, const int32_t& aSamples) - { - RefPtr<SharedBuffer> buffer = SharedBuffer::Create(aSamples * sizeof(int16_t)); + void Generate(AudioSegment& aSegment, const int32_t& aSamples) { + RefPtr<SharedBuffer> buffer = + SharedBuffer::Create(aSamples * sizeof(int16_t)); int16_t* dest = static_cast<int16_t*>(buffer->Data()); mGenerator.generate(dest, aSamples); AutoTArray<const int16_t*, 1> channels; for (int32_t i = 0; i < mChannels; i++) { channels.AppendElement(dest); } - aSegment.AppendFrames(buffer.forget(), channels, aSamples, PRINCIPAL_HANDLE_NONE); + aSegment.AppendFrames(buffer.forget(), channels, aSamples, + PRINCIPAL_HANDLE_NONE); } -private: + private: SineWaveGenerator mGenerator; const int32_t mChannels; }; -class TestOpusTrackEncoder : public OpusTrackEncoder -{ -public: +class TestOpusTrackEncoder : public OpusTrackEncoder { + public: TestOpusTrackEncoder() : OpusTrackEncoder(90000) {} // Return true if it has successfully initialized the Opus encoder. - bool TestOpusRawCreation(int aChannels, int aSamplingRate) - { + bool TestOpusRawCreation(int aChannels, int aSamplingRate) { if (Init(aChannels, aSamplingRate) == NS_OK) { if (IsInitialized()) { return true; } } return false; } // Return the sample rate of data to be fed to the Opus encoder, could be // re-sampled if it was not one of the Opus supported sampling rates. // Init() is expected to be called first. - int TestGetOutputSampleRate() - { + int TestGetOutputSampleRate() { return mInitialized ? GetOutputSampleRate() : 0; } }; -static bool -TestOpusInit(int aChannels, int aSamplingRate) -{ +static bool TestOpusInit(int aChannels, int aSamplingRate) { TestOpusTrackEncoder encoder; 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)); // The Opus format supports up to 8 channels, and supports multitrack audio up // to 255 channels, but the current implementation supports only mono and // stereo, and downmixes any more than that. // Expect false with channels of input signal exceed the max supported number. @@ -92,18 +84,17 @@ TEST(OpusAudioTrackEncoder, InitRaw) EXPECT_FALSE(TestOpusInit(2, 4000)); EXPECT_FALSE(TestOpusInit(2, 7999)); EXPECT_TRUE(TestOpusInit(2, 8000)); EXPECT_TRUE(TestOpusInit(2, 192000)); EXPECT_FALSE(TestOpusInit(2, 192001)); 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 // duration segments, should result in a best effort attempt. The first // attempt should never do this though, even if the duration is long: OpusTrackEncoder encoder(48000); AudioSegment segment; segment.AppendNullData(48000 * 100); @@ -173,58 +164,52 @@ TEST(OpusAudioTrackEncoder, Init) AudioSegment segment; AudioGenerator generator(2, 192000); generator.Generate(segment, 1); encoder.TryInit(segment, segment.GetDuration()); EXPECT_TRUE(encoder.IsInitialized()); } } -static int -TestOpusResampler(int aChannels, int aSamplingRate) -{ +static int TestOpusResampler(int aChannels, int aSamplingRate) { TestOpusTrackEncoder encoder; EXPECT_TRUE(encoder.TestOpusRawCreation(aChannels, 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. EXPECT_TRUE(TestOpusResampler(1, 8000) == 8000); EXPECT_TRUE(TestOpusResampler(1, 12000) == 12000); EXPECT_TRUE(TestOpusResampler(1, 16000) == 16000); EXPECT_TRUE(TestOpusResampler(1, 24000) == 24000); EXPECT_TRUE(TestOpusResampler(1, 48000) == 48000); // Otherwise, it should be resampled to 48kHz by resampler. EXPECT_TRUE(TestOpusResampler(1, 9600) == 48000); EXPECT_TRUE(TestOpusResampler(1, 44100) == 48000); } -TEST(OpusAudioTrackEncoder, FetchMetadata) -{ +TEST(OpusAudioTrackEncoder, FetchMetadata) { const int32_t channels = 1; const int32_t sampleRate = 44100; TestOpusTrackEncoder encoder; EXPECT_TRUE(encoder.TestOpusRawCreation(channels, sampleRate)); RefPtr<TrackMetadataBase> metadata = encoder.GetMetadata(); ASSERT_EQ(TrackMetadataBase::METADATA_OPUS, metadata->GetKind()); - RefPtr<OpusMetadata> opusMeta = - static_cast<OpusMetadata*>(metadata.get()); + RefPtr<OpusMetadata> opusMeta = static_cast<OpusMetadata*>(metadata.get()); EXPECT_EQ(channels, opusMeta->mChannels); EXPECT_EQ(sampleRate, opusMeta->mSamplingFrequency); } -TEST(OpusAudioTrackEncoder, FrameEncode) -{ +TEST(OpusAudioTrackEncoder, FrameEncode) { const int32_t channels = 1; const int32_t sampleRate = 44100; TestOpusTrackEncoder encoder; EXPECT_TRUE(encoder.TestOpusRawCreation(channels, sampleRate)); // Generate five seconds of raw audio data. AudioGenerator generator(channels, sampleRate); AudioSegment segment;
--- a/dom/media/gtest/TestBitWriter.cpp +++ b/dom/media/gtest/TestBitWriter.cpp @@ -5,22 +5,21 @@ #include "gtest/gtest.h" #include "BitReader.h" #include "BitWriter.h" #include "H264.h" using namespace mozilla; -TEST(BitWriter, BitWriter) -{ +TEST(BitWriter, BitWriter) { RefPtr<MediaByteBuffer> test = new MediaByteBuffer(); BitWriter b(test); b.WriteBit(false); - b.WriteBits(~1ULL, 1); // ensure that extra bits don't modify byte buffer. + b.WriteBits(~1ULL, 1); // ensure that extra bits don't modify byte buffer. b.WriteBits(3, 1); b.WriteUE(1280 / 16 - 1); b.WriteUE(720 / 16 - 1); b.WriteUE(1280); b.WriteUE(720); b.WriteBit(true); b.WriteBit(false); b.WriteBit(true); @@ -45,28 +44,27 @@ TEST(BitWriter, BitWriter) EXPECT_EQ(c.ReadBit(), true); EXPECT_EQ(c.ReadBits(8), 7u); EXPECT_EQ(c.ReadU32(), 16356u); EXPECT_EQ(c.ReadU64(), 116356u); EXPECT_EQ(c.ReadBits(16), 0xfffeu); EXPECT_EQ(length, BitReader::GetBitLength(test)); } -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, - 0x00, 0x00, 0x0f, 0x03, 0xc5, 0x0a, 0x44, 0x80, 0x01, - 0x00, 0x04, 0x68, 0xeb, 0xef, 0x20 }; +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, + 0x00, 0x00, 0x0f, 0x03, 0xc5, 0x0a, 0x44, 0x80, 0x01, + 0x00, 0x04, 0x68, 0xeb, 0xef, 0x20}; RefPtr<MediaByteBuffer> extraData = new MediaByteBuffer(); extraData->AppendElements(sps_pps, sizeof(sps_pps)); SPSData spsdata1; bool success = H264::DecodeSPSFromExtraData(extraData, spsdata1); EXPECT_EQ(success, true); RefPtr<MediaByteBuffer> extraData2 = - H264::CreateExtraData(0x42, 0xc0, 0x1e, { 1280, 720 }); + H264::CreateExtraData(0x42, 0xc0, 0x1e, {1280, 720}); SPSData spsdata2; success = H264::DecodeSPSFromExtraData(extraData2, spsdata2); EXPECT_EQ(success, true); }
--- a/dom/media/gtest/TestBlankVideoDataCreator.cpp +++ b/dom/media/gtest/TestBlankVideoDataCreator.cpp @@ -3,27 +3,25 @@ * 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/. */ #include "gtest/gtest.h" #include "BlankDecoderModule.h" using namespace mozilla; -TEST(BlankVideoDataCreator, ShouldNotOverflow) -{ +TEST(BlankVideoDataCreator, ShouldNotOverflow) { RefPtr<MediaRawData> mrd = new MediaRawData(); const uint32_t width = 1; const uint32_t height = 1; BlankVideoDataCreator creater(width, height, nullptr); RefPtr<MediaData> data = creater.Create(mrd); 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; BlankVideoDataCreator creater(width, height, nullptr); RefPtr<MediaData> data = creater.Create(mrd); EXPECT_EQ(data.get(), nullptr); }
--- a/dom/media/gtest/TestCDMStorage.cpp +++ b/dom/media/gtest/TestCDMStorage.cpp @@ -9,283 +9,249 @@ #include "mozilla/RefPtr.h" #include "ChromiumCDMCallback.h" #include "GMPTestMonitor.h" #include "GMPServiceParent.h" #include "MediaResult.h" #include "nsIFile.h" #include "nsISimpleEnumerator.h" -#include "nsNSSComponent.h" //For EnsureNSSInitializedChromeOrContent +#include "nsNSSComponent.h" //For EnsureNSSInitializedChromeOrContent #include "nsThreadUtils.h" using namespace mozilla; using namespace mozilla::gmp; -static already_AddRefed<nsIThread> -GetGMPThread() -{ +static already_AddRefed<nsIThread> GetGMPThread() { RefPtr<GeckoMediaPluginService> service = - GeckoMediaPluginService::GetGeckoMediaPluginService(); + GeckoMediaPluginService::GetGeckoMediaPluginService(); nsCOMPtr<nsIThread> thread; EXPECT_TRUE(NS_SUCCEEDED(service->GetThread(getter_AddRefs(thread)))); return thread.forget(); } -static RefPtr<AbstractThread> -GetAbstractGMPThread() -{ +static RefPtr<AbstractThread> GetAbstractGMPThread() { RefPtr<GeckoMediaPluginService> service = - GeckoMediaPluginService::GetGeckoMediaPluginService(); + GeckoMediaPluginService::GetGeckoMediaPluginService(); return service->GetAbstractGMPThread(); } /** * Enumerate files under |aPath| (non-recursive). */ -template<typename T> -static nsresult -EnumerateDir(nsIFile* aPath, T&& aDirIter) -{ +template <typename T> +static nsresult EnumerateDir(nsIFile* aPath, T&& aDirIter) { nsCOMPtr<nsIDirectoryEnumerator> iter; nsresult rv = aPath->GetDirectoryEntries(getter_AddRefs(iter)); if (NS_FAILED(rv)) { return rv; } nsCOMPtr<nsIFile> entry; while (NS_SUCCEEDED(iter->GetNextFile(getter_AddRefs(entry))) && entry) { aDirIter(entry); } return NS_OK; } /** - * Enumerate files under $profileDir/gmp/$platform/gmp-fake/$aDir/ (non-recursive). + * Enumerate files under $profileDir/gmp/$platform/gmp-fake/$aDir/ + * (non-recursive). */ -template<typename T> -static nsresult -EnumerateCDMStorageDir(const nsACString& aDir, T&& aDirIter) -{ +template <typename T> +static nsresult EnumerateCDMStorageDir(const nsACString& aDir, T&& aDirIter) { RefPtr<GeckoMediaPluginServiceParent> service = - GeckoMediaPluginServiceParent::GetSingleton(); + GeckoMediaPluginServiceParent::GetSingleton(); MOZ_ASSERT(service); // $profileDir/gmp/$platform/ nsCOMPtr<nsIFile> path; nsresult rv = service->GetStorageDir(getter_AddRefs(path)); if (NS_FAILED(rv)) { return rv; } - // $profileDir/gmp/$platform/gmp-fake/ rv = path->Append(NS_LITERAL_STRING("gmp-fake")); if (NS_FAILED(rv)) { return rv; } // $profileDir/gmp/$platform/gmp-fake/$aDir/ rv = path->AppendNative(aDir); if (NS_FAILED(rv)) { return rv; } return EnumerateDir(path, aDirIter); } -class GMPShutdownObserver : public nsIRunnable - , public nsIObserver { -public: +class GMPShutdownObserver : public nsIRunnable, public nsIObserver { + public: GMPShutdownObserver(already_AddRefed<nsIRunnable> aShutdownTask, already_AddRefed<nsIRunnable> Continuation, const nsACString& aNodeId) - : mShutdownTask(aShutdownTask) - , mContinuation(Continuation) - , mNodeId(NS_ConvertUTF8toUTF16(aNodeId)) - {} + : mShutdownTask(aShutdownTask), + mContinuation(Continuation), + mNodeId(NS_ConvertUTF8toUTF16(aNodeId)) {} NS_DECL_THREADSAFE_ISUPPORTS NS_IMETHOD Run() override { MOZ_ASSERT(NS_IsMainThread()); nsCOMPtr<nsIObserverService> observerService = mozilla::services::GetObserverService(); EXPECT_TRUE(observerService); observerService->AddObserver(this, "gmp-shutdown", false); nsCOMPtr<nsIThread> thread(GetGMPThread()); thread->Dispatch(mShutdownTask, NS_DISPATCH_NORMAL); return NS_OK; } - NS_IMETHOD Observe(nsISupports* aSubject, - const char* aTopic, - const char16_t* aSomeData) override - { + NS_IMETHOD Observe(nsISupports* aSubject, const char* aTopic, + const char16_t* aSomeData) override { if (!strcmp(aTopic, "gmp-shutdown") && mNodeId.Equals(nsDependentString(aSomeData))) { nsCOMPtr<nsIObserverService> observerService = mozilla::services::GetObserverService(); EXPECT_TRUE(observerService); observerService->RemoveObserver(this, "gmp-shutdown"); nsCOMPtr<nsIThread> thread(GetGMPThread()); thread->Dispatch(mContinuation, NS_DISPATCH_NORMAL); } return NS_OK; } -private: + private: virtual ~GMPShutdownObserver() {} nsCOMPtr<nsIRunnable> mShutdownTask; nsCOMPtr<nsIRunnable> mContinuation; const nsString mNodeId; }; NS_IMPL_ISUPPORTS(GMPShutdownObserver, nsIRunnable, nsIObserver) class NotifyObserversTask : public Runnable { -public: + public: explicit NotifyObserversTask(const char* aTopic) - : mozilla::Runnable("NotifyObserversTask") - , mTopic(aTopic) - {} + : mozilla::Runnable("NotifyObserversTask"), mTopic(aTopic) {} NS_IMETHOD Run() override { MOZ_ASSERT(NS_IsMainThread()); nsCOMPtr<nsIObserverService> observerService = mozilla::services::GetObserverService(); if (observerService) { observerService->NotifyObservers(nullptr, mTopic, nullptr); } return NS_OK; } const char* mTopic; }; -class ClearCDMStorageTask : public nsIRunnable - , public nsIObserver { -public: +class ClearCDMStorageTask : public nsIRunnable, public nsIObserver { + public: ClearCDMStorageTask(already_AddRefed<nsIRunnable> Continuation, nsIThread* aTarget, PRTime aSince) - : mContinuation(Continuation) - , mTarget(aTarget) - , mSince(aSince) - {} + : mContinuation(Continuation), mTarget(aTarget), mSince(aSince) {} NS_DECL_THREADSAFE_ISUPPORTS NS_IMETHOD Run() override { MOZ_ASSERT(NS_IsMainThread()); nsCOMPtr<nsIObserverService> observerService = mozilla::services::GetObserverService(); EXPECT_TRUE(observerService); observerService->AddObserver(this, "gmp-clear-storage-complete", false); if (observerService) { nsAutoString str; if (mSince >= 0) { str.AppendInt(static_cast<int64_t>(mSince)); } - observerService->NotifyObservers( - nullptr, "browser:purge-session-history", str.Data()); + observerService->NotifyObservers(nullptr, "browser:purge-session-history", + str.Data()); } return NS_OK; } - NS_IMETHOD Observe(nsISupports* aSubject, - const char* aTopic, - const char16_t* aSomeData) override - { + NS_IMETHOD Observe(nsISupports* aSubject, const char* aTopic, + const char16_t* aSomeData) override { if (!strcmp(aTopic, "gmp-clear-storage-complete")) { nsCOMPtr<nsIObserverService> observerService = mozilla::services::GetObserverService(); EXPECT_TRUE(observerService); observerService->RemoveObserver(this, "gmp-clear-storage-complete"); mTarget->Dispatch(mContinuation, NS_DISPATCH_NORMAL); } return NS_OK; } -private: + private: virtual ~ClearCDMStorageTask() {} nsCOMPtr<nsIRunnable> mContinuation; nsCOMPtr<nsIThread> mTarget; const PRTime mSince; }; NS_IMPL_ISUPPORTS(ClearCDMStorageTask, nsIRunnable, nsIObserver) -static void -ClearCDMStorage(already_AddRefed<nsIRunnable> aContinuation, - nsIThread* aTarget, PRTime aSince = -1) -{ +static void ClearCDMStorage(already_AddRefed<nsIRunnable> aContinuation, + nsIThread* aTarget, PRTime aSince = -1) { RefPtr<ClearCDMStorageTask> task( - new ClearCDMStorageTask(std::move(aContinuation), aTarget, aSince)); + new ClearCDMStorageTask(std::move(aContinuation), aTarget, aSince)); SystemGroup::Dispatch(TaskCategory::Other, task.forget()); } -static void -SimulatePBModeExit() -{ +static void SimulatePBModeExit() { // SystemGroup::EventTargetFor() doesn't support NS_DISPATCH_SYNC. - NS_DispatchToMainThread(new NotifyObserversTask("last-pb-context-exited"), NS_DISPATCH_SYNC); + NS_DispatchToMainThread(new NotifyObserversTask("last-pb-context-exited"), + NS_DISPATCH_SYNC); } -class TestGetNodeIdCallback : public GetNodeIdCallback -{ -public: +class TestGetNodeIdCallback : public GetNodeIdCallback { + public: TestGetNodeIdCallback(nsCString& aNodeId, nsresult& aResult) - : mNodeId(aNodeId), - mResult(aResult) - { - } + : mNodeId(aNodeId), mResult(aResult) {} - void Done(nsresult aResult, const nsACString& aNodeId) - { + void Done(nsresult aResult, const nsACString& aNodeId) { mResult = aResult; mNodeId = aNodeId; } -private: + private: nsCString& mNodeId; nsresult& mResult; }; -static NodeId -GetNodeId(const nsAString& aOrigin, - const nsAString& aTopLevelOrigin, - const nsAString & aGmpName, - bool aInPBMode) -{ +static NodeId GetNodeId(const nsAString& aOrigin, + const nsAString& aTopLevelOrigin, + const nsAString& aGmpName, bool aInPBMode) { OriginAttributes attrs; attrs.mPrivateBrowsingId = aInPBMode ? 1 : 0; nsAutoCString suffix; attrs.CreateSuffix(suffix); nsAutoString origin; origin.Assign(aOrigin); origin.Append(NS_ConvertUTF8toUTF16(suffix)); nsAutoString topLevelOrigin; topLevelOrigin.Assign(aTopLevelOrigin); topLevelOrigin.Append(NS_ConvertUTF8toUTF16(suffix)); return NodeId(origin, topLevelOrigin, aGmpName); } -static nsCString -GetNodeId(const nsAString& aOrigin, - const nsAString& aTopLevelOrigin, - bool aInPBMode) -{ +static nsCString GetNodeId(const nsAString& aOrigin, + const nsAString& aTopLevelOrigin, bool aInPBMode) { RefPtr<GeckoMediaPluginServiceParent> service = - GeckoMediaPluginServiceParent::GetSingleton(); + GeckoMediaPluginServiceParent::GetSingleton(); EXPECT_TRUE(service); nsCString nodeId; nsresult result; - UniquePtr<GetNodeIdCallback> callback(new TestGetNodeIdCallback(nodeId, - result)); + UniquePtr<GetNodeIdCallback> callback( + new TestGetNodeIdCallback(nodeId, result)); OriginAttributes attrs; attrs.mPrivateBrowsingId = aInPBMode ? 1 : 0; nsAutoCString suffix; attrs.CreateSuffix(suffix); nsAutoString origin; @@ -293,83 +259,70 @@ GetNodeId(const nsAString& aOrigin, origin.Append(NS_ConvertUTF8toUTF16(suffix)); nsAutoString topLevelOrigin; topLevelOrigin.Assign(aTopLevelOrigin); topLevelOrigin.Append(NS_ConvertUTF8toUTF16(suffix)); // We rely on the fact that the GetNodeId implementation for // GeckoMediaPluginServiceParent is synchronous. - nsresult rv = service->GetNodeId(origin, - topLevelOrigin, - NS_LITERAL_STRING("gmp-fake"), - std::move(callback)); + nsresult rv = + service->GetNodeId(origin, topLevelOrigin, NS_LITERAL_STRING("gmp-fake"), + std::move(callback)); EXPECT_TRUE(NS_SUCCEEDED(rv) && NS_SUCCEEDED(result)); return nodeId; } -static bool -IsCDMStorageIsEmpty() -{ +static bool IsCDMStorageIsEmpty() { RefPtr<GeckoMediaPluginServiceParent> service = - GeckoMediaPluginServiceParent::GetSingleton(); + GeckoMediaPluginServiceParent::GetSingleton(); MOZ_ASSERT(service); nsCOMPtr<nsIFile> storage; nsresult rv = service->GetStorageDir(getter_AddRefs(storage)); EXPECT_TRUE(NS_SUCCEEDED(rv)); bool exists = false; if (storage) { storage->Exists(&exists); } return !exists; } -static void -AssertIsOnGMPThread() -{ +static void AssertIsOnGMPThread() { RefPtr<GeckoMediaPluginService> service = - GeckoMediaPluginService::GetGeckoMediaPluginService(); + GeckoMediaPluginService::GetGeckoMediaPluginService(); MOZ_ASSERT(service); nsCOMPtr<nsIThread> thread; service->GetThread(getter_AddRefs(thread)); MOZ_ASSERT(thread); nsCOMPtr<nsIThread> currentThread; DebugOnly<nsresult> rv = NS_GetCurrentThread(getter_AddRefs(currentThread)); MOZ_ASSERT(NS_SUCCEEDED(rv)); MOZ_ASSERT(currentThread == thread); } -class CDMStorageTest -{ +class CDMStorageTest { NS_INLINE_DECL_THREADSAFE_REFCOUNTING(CDMStorageTest) void DoTest(void (CDMStorageTest::*aTestMethod)()) { EnsureNSSInitializedChromeOrContent(); nsCOMPtr<nsIThread> thread(GetGMPThread()); ClearCDMStorage( - NewRunnableMethod("CDMStorageTest::DoTest", this, aTestMethod), thread); + NewRunnableMethod("CDMStorageTest::DoTest", this, aTestMethod), thread); AwaitFinished(); } - CDMStorageTest() - : mMonitor("CDMStorageTest") - , mFinished(false) - { - } + CDMStorageTest() : mMonitor("CDMStorageTest"), mFinished(false) {} - void - Update(const nsCString& aMessage) - { + void Update(const nsCString& aMessage) { nsTArray<uint8_t> msg; msg.AppendElements(aMessage.get(), aMessage.Length()); mCDM->UpdateSession(NS_LITERAL_CSTRING("fake-session-id"), 1, msg); } - void TestGetNodeId() - { + void TestGetNodeId() { AssertIsOnGMPThread(); EXPECT_TRUE(IsCDMStorageIsEmpty()); const nsString origin1 = NS_LITERAL_STRING("http://example1.com"); const nsString origin2 = NS_LITERAL_STRING("http://example2.org"); nsCString PBnodeId1 = GetNodeId(origin1, origin2, true); @@ -378,645 +331,622 @@ class CDMStorageTest // Node ids for the same origins should be the same in PB mode. EXPECT_TRUE(PBnodeId1.Equals(PBnodeId2)); nsCString PBnodeId3 = GetNodeId(origin2, origin1, true); // Node ids with origin and top level origin swapped should be different. EXPECT_TRUE(!PBnodeId3.Equals(PBnodeId1)); - // Getting node ids in PB mode should not result in the node id being stored. + // Getting node ids in PB mode should not result in the node id being + // stored. EXPECT_TRUE(IsCDMStorageIsEmpty()); nsCString nodeId1 = GetNodeId(origin1, origin2, false); nsCString nodeId2 = GetNodeId(origin1, origin2, false); // NodeIds for the same origin pair in non-pb mode should be the same. EXPECT_TRUE(nodeId1.Equals(nodeId2)); - // Node ids for a given origin pair should be different for the PB origins should be the same in PB mode. + // Node ids for a given origin pair should be different for the PB origins + // should be the same in PB mode. EXPECT_TRUE(!PBnodeId1.Equals(nodeId1)); EXPECT_TRUE(!PBnodeId2.Equals(nodeId2)); nsCOMPtr<nsIThread> thread(GetGMPThread()); - ClearCDMStorage( - NewRunnableMethod<nsCString>("CDMStorageTest::TestGetNodeId_Continuation", - this, - &CDMStorageTest::TestGetNodeId_Continuation, - nodeId1), - thread); + ClearCDMStorage(NewRunnableMethod<nsCString>( + "CDMStorageTest::TestGetNodeId_Continuation", this, + &CDMStorageTest::TestGetNodeId_Continuation, nodeId1), + thread); } void TestGetNodeId_Continuation(nsCString aNodeId1) { EXPECT_TRUE(IsCDMStorageIsEmpty()); // Once we clear storage, the node ids generated for the same origin-pair // should be different. const nsString origin1 = NS_LITERAL_STRING("http://example1.com"); const nsString origin2 = NS_LITERAL_STRING("http://example2.org"); nsCString nodeId3 = GetNodeId(origin1, origin2, false); EXPECT_TRUE(!aNodeId1.Equals(nodeId3)); SetFinished(); } void CreateDecryptor(const nsAString& aOrigin, - const nsAString& aTopLevelOrigin, - bool aInPBMode, - const nsCString& aUpdate) - { + const nsAString& aTopLevelOrigin, bool aInPBMode, + const nsCString& aUpdate) {