diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index 3fc5bde830b..883aeb7c8d6 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -662,12 +662,17 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None, '%s' % (firstCap(sourceDescription), exceptionCode))), post="\n") + def onFailureInvalidEnumValue(failureCode): + return CGGeneric( + failureCode or + ('throw_type_error(cx, "%s is not a valid enum value."); %s' + % (firstCap(sourceDescription), exceptionCode))) + def onFailureNotCallable(failureCode): - return CGWrapper( - CGGeneric( - failureCode or - ('throw_type_error(cx, \"%s is not callable.\");\n' - '%s' % (firstCap(sourceDescription), exceptionCode)))) + return CGGeneric( + failureCode or + ('throw_type_error(cx, \"%s is not callable.\");\n' + '%s' % (firstCap(sourceDescription), exceptionCode))) # A helper function for handling null default values. Checks that the # default value, if it exists, is null. @@ -868,7 +873,7 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None, "yet") enum = type.inner.identifier.name if invalidEnumValueFatal: - handleInvalidEnumValueCode = exceptionCode + handleInvalidEnumValueCode = onFailureInvalidEnumValue(failureCode).define() else: handleInvalidEnumValueCode = "return true;" diff --git a/tests/wpt/metadata/FileAPI/file/File-constructor.html.ini b/tests/wpt/metadata/FileAPI/file/File-constructor.html.ini index a0c942de8ce..7087a621261 100644 --- a/tests/wpt/metadata/FileAPI/file/File-constructor.html.ini +++ b/tests/wpt/metadata/FileAPI/file/File-constructor.html.ini @@ -11,3 +11,4 @@ [Using special character in fileName] expected: FAIL + diff --git a/tests/wpt/metadata/domparsing/DOMParser-parseFromString-xml.html.ini b/tests/wpt/metadata/domparsing/DOMParser-parseFromString-xml.html.ini index 66597d94001..c5f9f1fdb9b 100644 --- a/tests/wpt/metadata/domparsing/DOMParser-parseFromString-xml.html.ini +++ b/tests/wpt/metadata/domparsing/DOMParser-parseFromString-xml.html.ini @@ -1,9 +1,41 @@ [DOMParser-parseFromString-xml.html] type: testharness - expected: TIMEOUT [Should return an error document for XML wellformedness errors in type text/xml] expected: FAIL [Should parse correctly in type application/xml] - expected: TIMEOUT + expected: FAIL + + [XMLDocument interface for correctly parsed document with type application/xml] + expected: FAIL + + [Should return an error document for XML wellformedness errors in type application/xml] + expected: FAIL + + [XMLDocument interface for incorrectly parsed document with type application/xml] + expected: FAIL + + [Should parse correctly in type application/xhtml+xml] + expected: FAIL + + [XMLDocument interface for correctly parsed document with type application/xhtml+xml] + expected: FAIL + + [Should return an error document for XML wellformedness errors in type application/xhtml+xml] + expected: FAIL + + [XMLDocument interface for incorrectly parsed document with type application/xhtml+xml] + expected: FAIL + + [Should parse correctly in type image/svg+xml] + expected: FAIL + + [XMLDocument interface for correctly parsed document with type image/svg+xml] + expected: FAIL + + [Should return an error document for XML wellformedness errors in type image/svg+xml] + expected: FAIL + + [XMLDocument interface for incorrectly parsed document with type image/svg+xml] + expected: FAIL diff --git a/tests/wpt/metadata/html/browsers/the-window-object/Document-defaultView.html.ini b/tests/wpt/metadata/html/browsers/the-window-object/Document-defaultView.html.ini index 9ba1c81088c..6ba3fcf80dd 100644 --- a/tests/wpt/metadata/html/browsers/the-window-object/Document-defaultView.html.ini +++ b/tests/wpt/metadata/html/browsers/the-window-object/Document-defaultView.html.ini @@ -1,6 +1,5 @@ [Document-defaultView.html] type: testharness - expected: TIMEOUT [Document created with the Document constructor] expected: FAIL @@ -11,5 +10,8 @@ expected: FAIL [Document created with XML DOMParser] - expected: TIMEOUT + expected: FAIL + + [Document created with HTML DOMParser] + expected: FAIL diff --git a/tests/wpt/web-platform-tests/domparsing/DOMParser-parseFromString-html.html b/tests/wpt/web-platform-tests/domparsing/DOMParser-parseFromString-html.html index fcaa44a391b..96c4a02333c 100644 --- a/tests/wpt/web-platform-tests/domparsing/DOMParser-parseFromString-html.html +++ b/tests/wpt/web-platform-tests/domparsing/DOMParser-parseFromString-html.html @@ -61,4 +61,10 @@ test(function() { assert_equals(htmldoc.documentElement.localName, "html"); assert_equals(htmldoc.documentElement.namespaceURI, "http://www.w3.org/1999/xhtml"); }, "DOMParser parses HTML tag soup with no problems"); + +test(function() { + assert_throws(new TypeError(), function() { + new DOMParser().parseFromString("", "text/foo-this-is-invalid"); + }) +}, "DOMParser throws on an invalid enum value")