aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPierre Louis Aublin <pierrelouis.aublin@gmail.com>2014-07-01 15:48:02 +0200
committerMs2ger <ms2ger@gmail.com>2014-09-04 14:45:24 +0200
commitcf734b01b75d3ec7db29c3de68219a7c2f31ce89 (patch)
treeba3feaa9c93bebbf079b41e2e24fd804b7d69857 /src
parentff97135ab974ae3059c1bfe00779b128aad5be34 (diff)
downloadservo-cf734b01b75d3ec7db29c3de68219a7c2f31ce89.tar.gz
servo-cf734b01b75d3ec7db29c3de68219a7c2f31ce89.zip
Throw TypeErrors instead of uncatcheable exceptions in CodegenRust.py (fixes #347, #3065).
Diffstat (limited to 'src')
-rw-r--r--src/components/script/dom/bindings/codegen/CodegenRust.py11
-rw-r--r--src/test/wpt/metadata/XMLHttpRequest/interfaces.html.ini47
2 files changed, 50 insertions, 8 deletions
diff --git a/src/components/script/dom/bindings/codegen/CodegenRust.py b/src/components/script/dom/bindings/codegen/CodegenRust.py
index 28b8809380d..1666589940e 100644
--- a/src/components/script/dom/bindings/codegen/CodegenRust.py
+++ b/src/components/script/dom/bindings/codegen/CodegenRust.py
@@ -377,7 +377,8 @@ class CGMethodCall(CGThing):
overloadCGThings.append(
CGSwitch("argcount",
argCountCases,
- CGGeneric("return 0; //XXXjdm throw stuff\n//return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, %s);\n" % methodName)))
+ CGGeneric("throw_type_error(cx, \"Not enough arguments to %s.\");\n"
+ "return 0;\n" % methodName)))
#XXXjdm Avoid unreachable statement warnings
#overloadCGThings.append(
# CGGeneric('fail!("We have an always-returning default case");\n'
@@ -520,7 +521,7 @@ def getJSToNativeConversionTemplate(type, descriptorProvider, failureCode=None,
return CGWrapper(
CGGeneric(
failureCode or
- ('//XXXjdm ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "%s", "%s")\n;'
+ ('throw_type_error(cx, \"%s does not implement interface %s.\");\n'
'%s' % (firstCap(sourceDescription), typeName,
exceptionCode))),
post="\n")
@@ -528,7 +529,7 @@ def getJSToNativeConversionTemplate(type, descriptorProvider, failureCode=None,
return CGWrapper(
CGGeneric(
failureCode or
- ('//XXXjdm ThrowErrorMessage(cx, MSG_NOT_CALLABLE, "%s");\n'
+ ('throw_type_error(cx, \"%s is not callable.\");\n'
'%s' % (firstCap(sourceDescription), exceptionCode))),
post="\n")
@@ -2656,7 +2657,7 @@ class CGStaticSetter(CGAbstractStaticBindingMethod):
checkForArg = CGGeneric(
"let argv = JS_ARGV(cx, vp);\n"
"if (argc == 0) {\n"
- " // XXXjdmreturn ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, \"%s setter\");\n"
+ " throw_type_error(cx, \"Not enough arguments to %s setter.\");\n"
" return 0;\n"
"}\n" % self.attr.identifier.name)
call = CGSetterCall([], self.attr.type, nativeName, self.descriptor,
@@ -4311,7 +4312,7 @@ class CGDictionary(CGThing):
" } else if val.is_object() {\n"
" val.to_object()\n"
" } else {\n"
- " //XXXjdm throw properly here\n"
+ " throw_type_error(cx, \"Value not an object.\");\n"
" return Err(());\n"
" };\n"
" Ok(${selfName} {\n"
diff --git a/src/test/wpt/metadata/XMLHttpRequest/interfaces.html.ini b/src/test/wpt/metadata/XMLHttpRequest/interfaces.html.ini
index c79bd41c3cd..de4343bec98 100644
--- a/src/test/wpt/metadata/XMLHttpRequest/interfaces.html.ini
+++ b/src/test/wpt/metadata/XMLHttpRequest/interfaces.html.ini
@@ -1,6 +1,5 @@
[interfaces.html]
type: testharness
- expected: TIMEOUT
[XMLHttpRequest interface: operation open(ByteString,DOMString)]
expected: FAIL
@@ -13,6 +12,48 @@
[XMLHttpRequest interface: operation overrideMimeType(DOMString)]
expected: FAIL
- [XMLHttpRequest interface: calling open(ByteString,DOMString) on new XMLHttpRequest() with too few arguments must throw TypeError]
- expected: TIMEOUT
+ [XMLHttpRequest interface: calling open(ByteString,DOMString,boolean,DOMString,DOMString) on new XMLHttpRequest() with too few arguments must throw TypeError]
+ expected: FAIL
+
+ [XMLHttpRequest interface: new XMLHttpRequest() must inherit property "statusText" with the proper type (16)]
+ expected: FAIL
+
+ [XMLHttpRequest interface: new XMLHttpRequest() must inherit property "overrideMimeType" with the proper type (19)]
+ expected: FAIL
+
+ [XMLHttpRequest interface: calling overrideMimeType(DOMString) on new XMLHttpRequest() with too few arguments must throw TypeError]
+ expected: FAIL
+
+ [FormData interface: existence and properties of interface object]
+ expected: FAIL
+
+ [FormData interface object length]
+ expected: FAIL
+
+ [FormData interface: operation append(DOMString,Blob,DOMString)]
+ expected: FAIL
+
+ [FormData interface: operation append(DOMString,DOMString)]
+ expected: FAIL
+
+ [FormData interface: operation getAll(DOMString)]
+ expected: FAIL
+
+ [FormData interface: operation set(DOMString,Blob,DOMString)]
+ expected: FAIL
+
+ [FormData interface: operation set(DOMString,DOMString)]
+ expected: FAIL
+
+ [FormData interface: new FormData() must inherit property "getAll" with the proper type (4)]
+ expected: FAIL
+
+ [FormData interface: calling getAll(DOMString) on new FormData() with too few arguments must throw TypeError]
+ expected: FAIL
+
+ [FormData interface: new FormData(form) must inherit property "getAll" with the proper type (4)]
+ expected: FAIL
+
+ [FormData interface: calling getAll(DOMString) on new FormData(form) with too few arguments must throw TypeError]
+ expected: FAIL