Bug 1025183 P5 Add tests for ScalarValueString. r=bz

This commit is contained in:
Ben Kelly 2014-08-01 13:57:00 -04:00
parent d24aeaacd8
commit 8d3963af12
8 changed files with 96 additions and 1 deletions

View File

@ -466,6 +466,7 @@ public:
void PassOptionalNullableString(const Optional<nsAString>&);
void PassOptionalNullableStringWithDefaultValue(const nsAString&);
void PassVariadicString(const Sequence<nsString>&);
void ReceiveString(DOMString&);
// ByteString types
void PassByteString(const nsCString&);
@ -474,6 +475,16 @@ public:
void PassOptionalNullableByteString(const Optional<nsCString>&);
void PassVariadicByteString(const Sequence<nsCString>&);
// ScalarValueString types
void PassSVS(const nsAString&);
void PassNullableSVS(const nsAString&);
void PassOptionalSVS(const Optional<nsAString>&);
void PassOptionalSVSWithDefaultValue(const nsAString&);
void PassOptionalNullableSVS(const Optional<nsAString>&);
void PassOptionalNullableSVSWithDefaultValue(const nsAString&);
void PassVariadicSVS(const Sequence<nsString>&);
void ReceiveSVS(DOMString&);
// Enumerated types
void PassEnum(TestEnum);
void PassNullableEnum(const Nullable<TestEnum>&);
@ -591,6 +602,7 @@ public:
void PassUnionWithMozMap(const StringMozMapOrString&);
void PassUnionWithMozMapAndSequence(const StringMozMapOrStringSequence&);
void PassUnionWithSequenceAndMozMap(const StringSequenceOrStringMozMap&);
void PassUnionWithSVS(const ScalarValueStringOrLong&);
#endif
void PassNullableUnion(JSContext*, const Nullable<ObjectOrLong>&);
void PassOptionalUnion(JSContext*, const Optional<ObjectOrLong>&);

View File

@ -423,6 +423,7 @@ interface TestInterface {
void passOptionalNullableString(optional DOMString? arg);
void passOptionalNullableStringWithDefaultValue(optional DOMString? arg = null);
void passVariadicString(DOMString... arg);
DOMString receiveString();
// ByteString types
void passByteString(ByteString arg);
@ -431,6 +432,16 @@ interface TestInterface {
void passOptionalNullableByteString(optional ByteString? arg);
void passVariadicByteString(ByteString... arg);
// ScalarValueString types
void passSVS(ScalarValueString arg);
void passNullableSVS(ScalarValueString? arg);
void passOptionalSVS(optional ScalarValueString arg);
void passOptionalSVSWithDefaultValue(optional ScalarValueString arg = "abc");
void passOptionalNullableSVS(optional ScalarValueString? arg);
void passOptionalNullableSVSWithDefaultValue(optional ScalarValueString? arg = null);
void passVariadicSVS(ScalarValueString... arg);
ScalarValueString receiveSVS();
// Enumerated types
void passEnum(TestEnum arg);
void passNullableEnum(TestEnum? arg);
@ -533,6 +544,7 @@ interface TestInterface {
void passUnionWithMozMap((MozMap<DOMString> or DOMString) arg);
void passUnionWithMozMapAndSequence((MozMap<DOMString> or sequence<DOMString>) arg);
void passUnionWithSequenceAndMozMap((sequence<DOMString> or MozMap<DOMString>) arg);
void passUnionWithSVS((ScalarValueString or long) arg);
#endif
void passUnionWithNullable((object? or long) arg);
void passNullableUnion((object or long)? arg);

View File

@ -325,6 +325,16 @@ interface TestExampleInterface {
void passVariadicByteString(ByteString... arg);
void passUnionByteString((ByteString or long) arg);
// ScalarValueString types
void passSVS(ScalarValueString arg);
void passNullableSVS(ScalarValueString? arg);
void passOptionalSVS(optional ScalarValueString arg);
void passOptionalSVSWithDefaultValue(optional ScalarValueString arg = "abc");
void passOptionalNullableSVS(optional ScalarValueString? arg);
void passOptionalNullableSVSWithDefaultValue(optional ScalarValueString? arg = null);
void passVariadicSVS(ScalarValueString... arg);
ScalarValueString receiveSVS();
// Enumerated types
void passEnum(TestEnum arg);
void passNullableEnum(TestEnum? arg);
@ -421,9 +431,11 @@ interface TestExampleInterface {
void passUnion21((MozMap<long> or long) arg);
void passUnion22((MozMap<object> or long) arg);
void passUnionWithCallback((EventHandler or long) arg);
void passUnionWithByteString((ByteString or long) arg);
void passUnionWithMozMap((MozMap<DOMString> or DOMString) arg);
void passUnionWithMozMapAndSequence((MozMap<DOMString> or sequence<DOMString>) arg);
void passUnionWithSequenceAndMozMap((sequence<DOMString> or MozMap<DOMString>) arg);
void passUnionWithSVS((ScalarValueString or long) arg);
#endif
void passUnionWithNullable((object? or long) arg);
void passNullableUnion((object or long)? arg);

View File

@ -45,7 +45,9 @@ TestInterfaceJS.prototype = {
pingPongAny: function(any) { checkGlobal(any); return any; },
pingPongObject: function(obj) { checkGlobal(obj); return obj; },
getCallerPrincipal: function() { return Cu.getWebIDLCallerPrincipal().origin; }
getCallerPrincipal: function() { return Cu.getWebIDLCallerPrincipal().origin; },
convertSVS: function(svs) { return svs; }
};
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([TestInterfaceJS])

View File

@ -348,6 +348,16 @@ interface TestJSImplInterface {
void passVariadicByteString(ByteString... arg);
void PassUnionByteString((ByteString or long) arg);
// ScalarValueString types
void passSVS(ScalarValueString arg);
void passNullableSVS(ScalarValueString? arg);
void passOptionalSVS(optional ScalarValueString arg);
void passOptionalSVSWithDefaultValue(optional ScalarValueString arg = "abc");
void passOptionalNullableSVS(optional ScalarValueString? arg);
void passOptionalNullableSVSWithDefaultValue(optional ScalarValueString? arg = null);
void passVariadicSVS(ScalarValueString... arg);
ScalarValueString receiveSVS();
// Enumerated types
void passEnum(MyTestEnum arg);
void passNullableEnum(MyTestEnum? arg);
@ -445,9 +455,11 @@ interface TestJSImplInterface {
void passUnion21((MozMap<long> or long) arg);
void passUnion22((MozMap<object> or long) arg);
void passUnionWithCallback((EventHandler or long) arg);
void passUnionWithByteString((ByteString or long) arg);
void passUnionWithMozMap((MozMap<DOMString> or DOMString) arg);
void passUnionWithMozMapAndSequence((MozMap<DOMString> or sequence<DOMString>) arg);
void passUnionWithSequenceAndMozMap((sequence<DOMString> or MozMap<DOMString>) arg);
void passUnionWithSVS((ScalarValueString or long) arg);
#endif
void passUnionWithNullable((object? or long) arg);
void passNullableUnion((object or long)? arg);

View File

@ -40,6 +40,8 @@ skip-if = (toolkit == 'gonk' && debug) #debug-only failure; bug 926547
[test_named_getter_enumerability.html]
[test_Object.prototype_props.html]
[test_queryInterface.html]
[test_scalarvaluestring.html]
skip-if = debug == false
[test_sequence_wrapping.html]
[test_throwing_method_noDCE.html]
[test_treat_non_object_as_null.html]

View File

@ -0,0 +1,41 @@
<!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
<!DOCTYPE HTML>
<html>
<head>
<title>Test ScalarValueString</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<script class="testbody" type="application/javascript">
SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv({set: [['dom.expose_test_interfaces', true]]}, function() {
var testInterfaceJS = new TestInterfaceJS();
ok(testInterfaceJS, "got a TestInterfaceJS object");
// For expected values, see algorithm definition here:
// http://heycam.github.io/webidl/#dfn-obtain-unicode
var testList = [
{ string: "foo",
expected: "foo" },
{ string: "This is U+2070E: \ud841\udf0e",
expected: "This is U+2070E: \ud841\udf0e" },
{ string: "Missing low surrogate: \ud841",
expected: "Missing low surrogate: \ufffd" },
{ string: "Missing low surrogate with trailer: \ud841!!",
expected: "Missing low surrogate with trailer: \ufffd!!" },
{ string: "Missing high surrogate: \udf0e",
expected: "Missing high surrogate: \ufffd" },
{ string: "Missing high surrogate with trailer: \udf0e!!",
expected: "Missing high surrogate with trailer: \ufffd!!" },
{ string: "U+2070E after malformed: \udf0e\ud841\udf0e",
expected: "U+2070E after malformed: \ufffd\ud841\udf0e" }
];
testList.forEach(function(test) {
is(testInterfaceJS.convertSVS(test.string), test.expected, "Convert '" + test.string + "'");
});
SimpleTest.finish();
});
</script>
</body>
</html>

View File

@ -17,4 +17,6 @@ interface TestInterfaceJS {
// For testing bug 968335.
DOMString getCallerPrincipal();
DOMString convertSVS(ScalarValueString svs);
};