Diff
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (223031 => 223032)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2017-10-08 10:08:52 UTC (rev 223031)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2017-10-08 17:18:29 UTC (rev 223032)
@@ -1,3 +1,13 @@
+2017-10-08 Darin Adler <[email protected]>
+
+ CustomElementRegistry.define was throwing a _javascript_ syntax error instead of a DOM syntax error
+ https://bugs.webkit.org/show_bug.cgi?id=178055
+
+ Reviewed by Sam Weinig.
+
+ * web-platform-tests/custom-elements/custom-element-registry/define-expected.txt:
+ Updated to expect more tests to pass.
+
2017-10-07 Darin Adler <[email protected]>
Update Document.createEvent for recent DOM specification changes
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/custom-element-registry/define-expected.txt (223031 => 223032)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/custom-element-registry/define-expected.txt 2017-10-08 10:08:52 UTC (rev 223031)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/custom-element-registry/define-expected.txt 2017-10-08 17:18:29 UTC (rev 223032)
@@ -16,78 +16,30 @@
PASS Element names: defining an element named a-0123456789 should succeed
PASS Element names: defining an element named a-漢字 should succeed
PASS Element names: defining an element named a-𠀋 should succeed
-FAIL Element names: defining an element named undefined should throw a SyntaxError assert_throws: function "() => {
- customElements.define(name, class {});
- }" threw object "SyntaxError: Custom element name must contain a hyphen" that is not a DOMException SYNTAX_ERR: property "code" is equal to undefined, expected 12
-FAIL Element names: defining an element named null should throw a SyntaxError assert_throws: function "() => {
- customElements.define(name, class {});
- }" threw object "SyntaxError: Custom element name must contain a hyphen" that is not a DOMException SYNTAX_ERR: property "code" is equal to undefined, expected 12
-FAIL Element names: defining an element named should throw a SyntaxError assert_throws: function "() => {
- customElements.define(name, class {});
- }" threw object "SyntaxError: Custom element name must have a lowercase ASCII letter as its first character" that is not a DOMException SYNTAX_ERR: property "code" is equal to undefined, expected 12
-FAIL Element names: defining an element named - should throw a SyntaxError assert_throws: function "() => {
- customElements.define(name, class {});
- }" threw object "SyntaxError: Custom element name must have a lowercase ASCII letter as its first character" that is not a DOMException SYNTAX_ERR: property "code" is equal to undefined, expected 12
-FAIL Element names: defining an element named a should throw a SyntaxError assert_throws: function "() => {
- customElements.define(name, class {});
- }" threw object "SyntaxError: Custom element name must contain a hyphen" that is not a DOMException SYNTAX_ERR: property "code" is equal to undefined, expected 12
-FAIL Element names: defining an element named input should throw a SyntaxError assert_throws: function "() => {
- customElements.define(name, class {});
- }" threw object "SyntaxError: Custom element name must contain a hyphen" that is not a DOMException SYNTAX_ERR: property "code" is equal to undefined, expected 12
-FAIL Element names: defining an element named mycustomelement should throw a SyntaxError assert_throws: function "() => {
- customElements.define(name, class {});
- }" threw object "SyntaxError: Custom element name must contain a hyphen" that is not a DOMException SYNTAX_ERR: property "code" is equal to undefined, expected 12
-FAIL Element names: defining an element named A should throw a SyntaxError assert_throws: function "() => {
- customElements.define(name, class {});
- }" threw object "SyntaxError: Custom element name must have a lowercase ASCII letter as its first character" that is not a DOMException SYNTAX_ERR: property "code" is equal to undefined, expected 12
-FAIL Element names: defining an element named A- should throw a SyntaxError assert_throws: function "() => {
- customElements.define(name, class {});
- }" threw object "SyntaxError: Custom element name must have a lowercase ASCII letter as its first character" that is not a DOMException SYNTAX_ERR: property "code" is equal to undefined, expected 12
-FAIL Element names: defining an element named 0- should throw a SyntaxError assert_throws: function "() => {
- customElements.define(name, class {});
- }" threw object "SyntaxError: Custom element name must have a lowercase ASCII letter as its first character" that is not a DOMException SYNTAX_ERR: property "code" is equal to undefined, expected 12
-FAIL Element names: defining an element named a-A should throw a SyntaxError assert_throws: function "() => {
- customElements.define(name, class {});
- }" threw object "SyntaxError: Custom element name cannot contain an uppercase ASCII letter" that is not a DOMException SYNTAX_ERR: property "code" is equal to undefined, expected 12
-FAIL Element names: defining an element named a-Z should throw a SyntaxError assert_throws: function "() => {
- customElements.define(name, class {});
- }" threw object "SyntaxError: Custom element name cannot contain an uppercase ASCII letter" that is not a DOMException SYNTAX_ERR: property "code" is equal to undefined, expected 12
-FAIL Element names: defining an element named A-a should throw a SyntaxError assert_throws: function "() => {
- customElements.define(name, class {});
- }" threw object "SyntaxError: Custom element name must have a lowercase ASCII letter as its first character" that is not a DOMException SYNTAX_ERR: property "code" is equal to undefined, expected 12
-FAIL Element names: defining an element named a-a× should throw a SyntaxError assert_throws: function "() => {
- customElements.define(name, class {});
- }" threw object "SyntaxError: Custom element name contains a character that is not allowed" that is not a DOMException SYNTAX_ERR: property "code" is equal to undefined, expected 12
-FAIL Element names: defining an element named a-a should throw a SyntaxError assert_throws: function "() => {
- customElements.define(name, class {});
- }" threw object "SyntaxError: Custom element name contains a character that is not allowed" that is not a DOMException SYNTAX_ERR: property "code" is equal to undefined, expected 12
-FAIL Element names: defining an element named a-a should throw a SyntaxError assert_throws: function "() => {
- customElements.define(name, class {});
- }" threw object "SyntaxError: Custom element name contains a character that is not allowed" that is not a DOMException SYNTAX_ERR: property "code" is equal to undefined, expected 12
-FAIL Element names: defining an element named annotation-xml should throw a SyntaxError assert_throws: function "() => {
- customElements.define(name, class {});
- }" threw object "SyntaxError: Custom element name cannot be same as one of the standard elements" that is not a DOMException SYNTAX_ERR: property "code" is equal to undefined, expected 12
-FAIL Element names: defining an element named color-profile should throw a SyntaxError assert_throws: function "() => {
- customElements.define(name, class {});
- }" threw object "SyntaxError: Custom element name cannot be same as one of the standard elements" that is not a DOMException SYNTAX_ERR: property "code" is equal to undefined, expected 12
-FAIL Element names: defining an element named font-face should throw a SyntaxError assert_throws: function "() => {
- customElements.define(name, class {});
- }" threw object "SyntaxError: Custom element name cannot be same as one of the standard elements" that is not a DOMException SYNTAX_ERR: property "code" is equal to undefined, expected 12
-FAIL Element names: defining an element named font-face-src should throw a SyntaxError assert_throws: function "() => {
- customElements.define(name, class {});
- }" threw object "SyntaxError: Custom element name cannot be same as one of the standard elements" that is not a DOMException SYNTAX_ERR: property "code" is equal to undefined, expected 12
-FAIL Element names: defining an element named font-face-uri should throw a SyntaxError assert_throws: function "() => {
- customElements.define(name, class {});
- }" threw object "SyntaxError: Custom element name cannot be same as one of the standard elements" that is not a DOMException SYNTAX_ERR: property "code" is equal to undefined, expected 12
-FAIL Element names: defining an element named font-face-format should throw a SyntaxError assert_throws: function "() => {
- customElements.define(name, class {});
- }" threw object "SyntaxError: Custom element name cannot be same as one of the standard elements" that is not a DOMException SYNTAX_ERR: property "code" is equal to undefined, expected 12
-FAIL Element names: defining an element named font-face-name should throw a SyntaxError assert_throws: function "() => {
- customElements.define(name, class {});
- }" threw object "SyntaxError: Custom element name cannot be same as one of the standard elements" that is not a DOMException SYNTAX_ERR: property "code" is equal to undefined, expected 12
-FAIL Element names: defining an element named missing-glyph should throw a SyntaxError assert_throws: function "() => {
- customElements.define(name, class {});
- }" threw object "SyntaxError: Custom element name cannot be same as one of the standard elements" that is not a DOMException SYNTAX_ERR: property "code" is equal to undefined, expected 12
+PASS Element names: defining an element named undefined should throw a SyntaxError
+PASS Element names: defining an element named null should throw a SyntaxError
+PASS Element names: defining an element named should throw a SyntaxError
+PASS Element names: defining an element named - should throw a SyntaxError
+PASS Element names: defining an element named a should throw a SyntaxError
+PASS Element names: defining an element named input should throw a SyntaxError
+PASS Element names: defining an element named mycustomelement should throw a SyntaxError
+PASS Element names: defining an element named A should throw a SyntaxError
+PASS Element names: defining an element named A- should throw a SyntaxError
+PASS Element names: defining an element named 0- should throw a SyntaxError
+PASS Element names: defining an element named a-A should throw a SyntaxError
+PASS Element names: defining an element named a-Z should throw a SyntaxError
+PASS Element names: defining an element named A-a should throw a SyntaxError
+PASS Element names: defining an element named a-a× should throw a SyntaxError
+PASS Element names: defining an element named a-a should throw a SyntaxError
+PASS Element names: defining an element named a-a should throw a SyntaxError
+PASS Element names: defining an element named annotation-xml should throw a SyntaxError
+PASS Element names: defining an element named color-profile should throw a SyntaxError
+PASS Element names: defining an element named font-face should throw a SyntaxError
+PASS Element names: defining an element named font-face-src should throw a SyntaxError
+PASS Element names: defining an element named font-face-uri should throw a SyntaxError
+PASS Element names: defining an element named font-face-format should throw a SyntaxError
+PASS Element names: defining an element named font-face-name should throw a SyntaxError
+PASS Element names: defining an element named missing-glyph should throw a SyntaxError
PASS If the name is already defined, should throw a NotSupportedError
PASS If the constructor is already defined, should throw a NotSupportedError
FAIL If extends is a-, should throw a NotSupportedError assert_throws: function "() => {
Modified: trunk/Source/WebCore/ChangeLog (223031 => 223032)
--- trunk/Source/WebCore/ChangeLog 2017-10-08 10:08:52 UTC (rev 223031)
+++ trunk/Source/WebCore/ChangeLog 2017-10-08 17:18:29 UTC (rev 223032)
@@ -1,3 +1,38 @@
+2017-10-08 Darin Adler <[email protected]>
+
+ CustomElementRegistry.define was throwing a _javascript_ syntax error instead of a DOM syntax error
+ https://bugs.webkit.org/show_bug.cgi?id=178055
+
+ Reviewed by Sam Weinig.
+
+ Both the _javascript_ language and the DOM have "syntax error" exceptions, but
+ they are not the same thing.
+
+ Also, since the time a while back where we moved _javascript_ error handling to
+ use WebCore::Exception and WebCore::ExceptionOr, there are a number of functions
+ that are no longer used and can be deleted.
+
+ * bindings/js/JSCustomElementRegistryCustom.cpp:
+ (WebCore::validateCustomElementNameAndThrowIfNeeded): Call throwDOMSyntaxError
+ instead of throwSyntaxError.
+
+ * bindings/js/JSDOMExceptionHandling.cpp:
+ (WebCore::reportDeprecatedGetterError): Deleted. Unused.
+ (WebCore::reportDeprecatedSetterError): Deleted. Unused.
+ (WebCore::throwNotSupportedError): Deleted the overload without an error message,
+ since it's unused. Changed the other overload to take an ASCIILiteral, since
+ that is what all the callers need.
+ (WebCore::throwInvalidStateError): Take ASCIILiteral as above.
+ (WebCore::throwArrayElementTypeError): Deleted. Unused.
+ (WebCore::throwDOMSyntaxError): Added an ASCIILiteral message argument. This
+ function was unused; it's now being used above, always with a literal message.
+ (WebCore::throwIndexSizeError): Deleted. Unused.
+ (WebCore::throwTypeMismatchError): Deleted. Unused.
+ * bindings/js/JSDOMExceptionHandling.h: Updated for the changes above.
+
+ * bindings/js/JSHTMLElementCustom.cpp:
+ (WebCore::constructJSHTMLElement): Fixed a typo in the error message.
+
2017-10-08 Ryosuke Niwa <[email protected]>
dragenter and dragleave shouldn't use the same data transfer object
Modified: trunk/Source/WebCore/bindings/js/JSCustomElementRegistryCustom.cpp (223031 => 223032)
--- trunk/Source/WebCore/bindings/js/JSCustomElementRegistryCustom.cpp 2017-10-08 10:08:52 UTC (rev 223031)
+++ trunk/Source/WebCore/bindings/js/JSCustomElementRegistryCustom.cpp 2017-10-08 17:18:29 UTC (rev 223032)
@@ -63,19 +63,19 @@
case CustomElementNameValidationStatus::Valid:
return true;
case CustomElementNameValidationStatus::FirstCharacterIsNotLowercaseASCIILetter:
- throwSyntaxError(&state, scope, ASCIILiteral("Custom element name must have a lowercase ASCII letter as its first character"));
+ throwDOMSyntaxError(state, scope, ASCIILiteral("Custom element name must have a lowercase ASCII letter as its first character"));
return false;
case CustomElementNameValidationStatus::ContainsUppercaseASCIILetter:
- throwSyntaxError(&state, scope, ASCIILiteral("Custom element name cannot contain an uppercase ASCII letter"));
+ throwDOMSyntaxError(state, scope, ASCIILiteral("Custom element name cannot contain an uppercase ASCII letter"));
return false;
case CustomElementNameValidationStatus::ContainsNoHyphen:
- throwSyntaxError(&state, scope, ASCIILiteral("Custom element name must contain a hyphen"));
+ throwDOMSyntaxError(state, scope, ASCIILiteral("Custom element name must contain a hyphen"));
return false;
case CustomElementNameValidationStatus::ContainsDisallowedCharacter:
- throwSyntaxError(&state, scope, ASCIILiteral("Custom element name contains a character that is not allowed"));
+ throwDOMSyntaxError(state, scope, ASCIILiteral("Custom element name contains a character that is not allowed"));
return false;
case CustomElementNameValidationStatus::ConflictsWithStandardElementName:
- throwSyntaxError(&state, scope, ASCIILiteral("Custom element name cannot be same as one of the standard elements"));
+ throwDOMSyntaxError(state, scope, ASCIILiteral("Custom element name cannot be same as one of the standard elements"));
return false;
}
ASSERT_NOT_REACHED();
Modified: trunk/Source/WebCore/bindings/js/JSDOMExceptionHandling.cpp (223031 => 223032)
--- trunk/Source/WebCore/bindings/js/JSDOMExceptionHandling.cpp 2017-10-08 10:08:52 UTC (rev 223031)
+++ trunk/Source/WebCore/bindings/js/JSDOMExceptionHandling.cpp 2017-10-08 17:18:29 UTC (rev 223032)
@@ -189,32 +189,13 @@
builder.appendLiteral(" must be ");
}
-JSC::EncodedJSValue reportDeprecatedGetterError(JSC::ExecState& state, const char* interfaceName, const char* attributeName)
+void throwNotSupportedError(JSC::ExecState& state, JSC::ThrowScope& scope, ASCIILiteral message)
{
- auto& context = *jsCast<JSDOMGlobalObject*>(state.lexicalGlobalObject())->scriptExecutionContext();
- context.addConsoleMessage(MessageSource::JS, MessageLevel::Error, makeString("Deprecated attempt to access property '", attributeName, "' on a non-", interfaceName, " object."));
- return JSValue::encode(jsUndefined());
-}
-
-void reportDeprecatedSetterError(JSC::ExecState& state, const char* interfaceName, const char* attributeName)
-{
- auto& context = *jsCast<JSDOMGlobalObject*>(state.lexicalGlobalObject())->scriptExecutionContext();
- context.addConsoleMessage(MessageSource::JS, MessageLevel::Error, makeString("Deprecated attempt to set property '", attributeName, "' on a non-", interfaceName, " object."));
-}
-
-void throwNotSupportedError(JSC::ExecState& state, JSC::ThrowScope& scope)
-{
scope.assertNoException();
- throwException(&state, scope, createDOMException(&state, NotSupportedError));
-}
-
-void throwNotSupportedError(JSC::ExecState& state, JSC::ThrowScope& scope, const char* message)
-{
- scope.assertNoException();
throwException(&state, scope, createDOMException(&state, NotSupportedError, message));
}
-void throwInvalidStateError(JSC::ExecState& state, JSC::ThrowScope& scope, const char* message)
+void throwInvalidStateError(JSC::ExecState& state, JSC::ThrowScope& scope, ASCIILiteral message)
{
scope.assertNoException();
throwException(&state, scope, createDOMException(&state, InvalidStateError, message));
@@ -252,11 +233,6 @@
return throwVMTypeError(&state, scope, builder.toString());
}
-void throwArrayElementTypeError(JSC::ExecState& state, JSC::ThrowScope& scope)
-{
- throwTypeError(state, scope, ASCIILiteral("Invalid Array element type"));
-}
-
void throwAttributeTypeError(JSC::ExecState& state, JSC::ThrowScope& scope, const char* interfaceName, const char* attributeName, const char* expectedType)
{
throwTypeError(state, scope, makeString("The ", interfaceName, '.', attributeName, " attribute must be an instance of ", expectedType));
@@ -331,10 +307,10 @@
return createRejectedPromiseWithTypeError(state, makeThisTypeErrorMessage(interfaceName, methodName));
}
-void throwDOMSyntaxError(JSC::ExecState& state, JSC::ThrowScope& scope)
+void throwDOMSyntaxError(JSC::ExecState& state, JSC::ThrowScope& scope, ASCIILiteral message)
{
scope.assertNoException();
- throwException(&state, scope, createDOMException(&state, SyntaxError));
+ throwException(&state, scope, createDOMException(&state, SyntaxError, message));
}
void throwDataCloneError(JSC::ExecState& state, JSC::ThrowScope& scope)
@@ -343,16 +319,4 @@
throwException(&state, scope, createDOMException(&state, DataCloneError));
}
-void throwIndexSizeError(JSC::ExecState& state, JSC::ThrowScope& scope)
-{
- scope.assertNoException();
- throwException(&state, scope, createDOMException(&state, IndexSizeError));
-}
-
-void throwTypeMismatchError(JSC::ExecState& state, JSC::ThrowScope& scope)
-{
- scope.assertNoException();
- throwException(&state, scope, createDOMException(&state, TypeMismatchError));
-}
-
} // namespace WebCore
Modified: trunk/Source/WebCore/bindings/js/JSDOMExceptionHandling.h (223031 => 223032)
--- trunk/Source/WebCore/bindings/js/JSDOMExceptionHandling.h 2017-10-08 10:08:52 UTC (rev 223031)
+++ trunk/Source/WebCore/bindings/js/JSDOMExceptionHandling.h 2017-10-08 17:18:29 UTC (rev 223032)
@@ -1,6 +1,6 @@
/*
* Copyright (C) 1999-2001 Harri Porten ([email protected])
- * Copyright (C) 2003-2006, 2008-2009, 2013, 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2003-2017 Apple Inc. All rights reserved.
* Copyright (C) 2007 Samuel Weinig <[email protected]>
* Copyright (C) 2009 Google, Inc. All rights reserved.
* Copyright (C) 2012 Ericsson AB. All rights reserved.
@@ -43,23 +43,16 @@
String sourceURL;
};
-WEBCORE_EXPORT JSC::EncodedJSValue reportDeprecatedGetterError(JSC::ExecState&, const char* interfaceName, const char* attributeName);
-WEBCORE_EXPORT void reportDeprecatedSetterError(JSC::ExecState&, const char* interfaceName, const char* attributeName);
-
void throwAttributeTypeError(JSC::ExecState&, JSC::ThrowScope&, const char* interfaceName, const char* attributeName, const char* expectedType);
WEBCORE_EXPORT bool throwSetterTypeError(JSC::ExecState&, JSC::ThrowScope&, const char* interfaceName, const char* attributeName);
-void throwArrayElementTypeError(JSC::ExecState&, JSC::ThrowScope&);
void throwDataCloneError(JSC::ExecState&, JSC::ThrowScope&);
-void throwDOMSyntaxError(JSC::ExecState&, JSC::ThrowScope&); // Not the same as a _javascript_ syntax error.
-void throwIndexSizeError(JSC::ExecState&, JSC::ThrowScope&);
-void throwInvalidStateError(JSC::ExecState&, JSC::ThrowScope&, const char* message);
+void throwDOMSyntaxError(JSC::ExecState&, JSC::ThrowScope&, ASCIILiteral); // Not the same as a _javascript_ syntax error.
+void throwInvalidStateError(JSC::ExecState&, JSC::ThrowScope&, ASCIILiteral);
WEBCORE_EXPORT void throwNonFiniteTypeError(JSC::ExecState&, JSC::ThrowScope&);
-void throwNotSupportedError(JSC::ExecState&, JSC::ThrowScope&);
-void throwNotSupportedError(JSC::ExecState&, JSC::ThrowScope&, const char* message);
+void throwNotSupportedError(JSC::ExecState&, JSC::ThrowScope&, ASCIILiteral);
void throwSecurityError(JSC::ExecState&, JSC::ThrowScope&, const String& message);
WEBCORE_EXPORT void throwSequenceTypeError(JSC::ExecState&, JSC::ThrowScope&);
-void throwTypeMismatchError(JSC::ExecState&, JSC::ThrowScope&);
WEBCORE_EXPORT JSC::EncodedJSValue throwArgumentMustBeEnumError(JSC::ExecState&, JSC::ThrowScope&, unsigned argumentIndex, const char* argumentName, const char* functionInterfaceName, const char* functionName, const char* expectedValues);
WEBCORE_EXPORT JSC::EncodedJSValue throwArgumentMustBeFunctionError(JSC::ExecState&, JSC::ThrowScope&, unsigned argumentIndex, const char* argumentName, const char* functionInterfaceName, const char* functionName);
Modified: trunk/Source/WebCore/bindings/js/JSHTMLElementCustom.cpp (223031 => 223032)
--- trunk/Source/WebCore/bindings/js/JSHTMLElementCustom.cpp 2017-10-08 10:08:52 UTC (rev 223031)
+++ trunk/Source/WebCore/bindings/js/JSHTMLElementCustom.cpp 2017-10-08 17:18:29 UTC (rev 223032)
@@ -89,7 +89,7 @@
Element* elementToUpgrade = elementInterface->lastElementInConstructionStack();
if (!elementToUpgrade) {
- throwInvalidStateError(exec, scope, ASCIILiteral("Cannot instantiate a custom element inside its own constrcutor during upgrades"));
+ throwInvalidStateError(exec, scope, ASCIILiteral("Cannot instantiate a custom element inside its own constructor during upgrades"));
return JSValue::encode(jsUndefined());
}