From 715ae6ab553cdd960a588f85ec67bc3419e4dc1f Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Mon, 4 Aug 2014 15:27:56 +0200 Subject: [PATCH] Throw a TypeError when unwrapping an interface argument fails. --- .../script/dom/bindings/codegen/CodegenRust.py | 10 +++++++++- .../wpt/metadata/dom/nodes/Node-insertBefore.html.ini | 11 ++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/components/script/dom/bindings/codegen/CodegenRust.py b/src/components/script/dom/bindings/codegen/CodegenRust.py index 5ee43b18e8c..7de2d949efe 100644 --- a/src/components/script/dom/bindings/codegen/CodegenRust.py +++ b/src/components/script/dom/bindings/codegen/CodegenRust.py @@ -586,7 +586,15 @@ def getJSToNativeConversionTemplate(type, descriptorProvider, failureCode=None, "argument" % descriptor.interface.identifier.name) if failureCode is None: - unwrapFailureCode = "return 0; //XXXjdm return Throw(cx, rv);" + substitutions = { + "sourceDescription": sourceDescription, + "interface": descriptor.interface.identifier.name, + "exceptionCode": exceptionCode, + } + unwrapFailureCode = string.Template( + 'throw_type_error(cx, "${sourceDescription} does not ' + 'implement interface ${interface}.");\n' + '${exceptionCode}').substitute(substitutions) else: unwrapFailureCode = failureCode diff --git a/src/test/wpt/metadata/dom/nodes/Node-insertBefore.html.ini b/src/test/wpt/metadata/dom/nodes/Node-insertBefore.html.ini index abe89d60ac1..fa7f987c0dc 100644 --- a/src/test/wpt/metadata/dom/nodes/Node-insertBefore.html.ini +++ b/src/test/wpt/metadata/dom/nodes/Node-insertBefore.html.ini @@ -1,6 +1,11 @@ [Node-insertBefore.html] type: testharness - expected: TIMEOUT - [Calling insertBefore with a non-Node first argument must throw TypeError.] - expected: TIMEOUT + [If the context node is a document, inserting a document or text node should throw a HierarchyRequestError.] + expected: FAIL + + [If the context node is a DocumentFragment, inserting a document or a doctype should throw a HierarchyRequestError.] + expected: FAIL + + [If the context node is an element, inserting a document or a doctype should throw a HierarchyRequestError.] + expected: FAIL