haikuwebkit/LayoutTests/js/interface-objects-expected.txt

39 lines
1.6 KiB
Plaintext
Raw Permalink Normal View History

[Web IDL] interface objects should be Function objects https://bugs.webkit.org/show_bug.cgi?id=154038 <rdar://problem/24569358> Reviewed by Geoffrey Garen. LayoutTests/imported/w3c: Rebaseline W3C tests now that more checks are passing. Some checks still fail because a lot of our interfaces should inherit EventTarget and currently don't (they duplicate the EventTarget API instead). Also, as per WebIDL, window.NodeFilter's proto should be ObjectPrototype instead of FunctionPrototype but this is an exceptional case and our new behavior is consistent with Firefox and Chrome. * web-platform-tests/XMLHttpRequest/interfaces-expected.txt: * web-platform-tests/dom/events/Event-constructors-expected.txt: * web-platform-tests/dom/historical-expected.txt: * web-platform-tests/dom/interfaces-expected.txt: * web-platform-tests/fetch/api/headers/headers-idl-expected.txt: * web-platform-tests/fetch/api/request/request-idl-expected.txt: * web-platform-tests/html/dom/interfaces-expected.txt: * web-platform-tests/html/semantics/embedded-content/the-audio-element/audio_constructor-expected.txt: Source/JavaScriptCore: Update functionProtoFuncToString() to handle JSObjects that have the TypeOfShouldCallGetCallData flag and are callable, as these behave like functions and use ClassInfo::className() as function name in this case. * runtime/FunctionPrototype.cpp: (JSC::functionProtoFuncToString): Source/WebCore: interface objects should be Function objects as per Web IDL: - http://heycam.github.io/webidl/#interface-object - http://heycam.github.io/webidl/#es-interfaces So window.Event should be a Function object for e.g. but in WebKit it is a regular EventConstructor JSObject. Firefox and Chrome match the specification. Test: js/interface-objects.html * bindings/js/JSDOMBinding.cpp: (WebCore::callThrowTypeError): (WebCore::DOMConstructorObject::getCallData): When calling the interface object as a function, we throw a TypeError with a message asking to use the 'new' operator to match the behavior of Firefox and Chrome. * bindings/js/JSDOMBinding.h: Add JSC::TypeOfShouldCallGetCallData structure flag and implement getCallData() so that typeof returns "function", as per the specification and the behavior of other browsers. (WebCore::DOMConstructorObject::className): Implement className() and return "Function" to match the specification and other browsers. Otherwise, it would fall back to using ClassInfo::className which os the function name and interface name (e.g. "Event"). * bindings/js/JSDOMConstructor.h: (WebCore::JSDOMConstructorNotConstructable::callThrowTypeError): (WebCore::JSDOMConstructorNotConstructable::getCallData): As per the specification, interfaces that do not have a [Constructor] should throw a TypeError when called as a function. Use the "Illegal constructor" error message to match Firefox and Chrome. * bindings/js/JSDOMGlobalObject.h: (WebCore::getDOMConstructor): Instead of using objectPrototype as prototype for all DOM constructors, we now call the prototypeForStructure() static function that is generated for each bindings class. As per the Web IDL specification, The [[Prototype]] internal property of an interface object for a non-callback interface is determined as follows: 1. If the interface inherits from some other interface, the value of [[Prototype]] is the interface object for that other interface. 2. If the interface doesn't inherit from any other interface, the value of [[Prototype]] is %FunctionPrototype% ([ECMA-262], section 6.1.7.4). * bindings/js/JSImageConstructor.cpp: (WebCore::JSImageConstructor::prototypeForStructure): Have the Image's interface object use HTMLElement's interface object as prototype as HTMLImageElement inherits HTMLElement. * bindings/scripts/CodeGenerator.pm: (getInterfaceExtendedAttributesFromName): Add a utility function to cheaply retrieve an interface's IDL extended attributes without actually parsing the IDL. This is used to check if an interface's parent is marked as [NoInterfaceObject] currently. * bindings/scripts/CodeGeneratorJS.pm: (GenerateHeader): (GenerateImplementation): (GenerateCallbackHeader): (GenerateCallbackImplementation): Mark JSGlobalObject* parameter as const as the implementation does not alter the globalObject. (GenerateConstructorHelperMethods): - Generate prototypeForStructure() function for each bindings class that is not marked as [NoInterfaceObject] so getDOMConstructor() knows which prototype to use for the interface object / constructor when constructing it. - Use the interface name for the interface object, without the "Constructor" suffix, to match the behavior of Firefox and Chrome. * bindings/scripts/test/*: Rebaseline bindings tests. LayoutTests: Rebaseline / update existing layout tests now that interface objects are now Function objects. Also add a layout test to cover various aspects of interface objects. * css3/blending/background-blend-mode-property-parsing-expected.txt: * css3/blending/blend-mode-property-parsing-expected.txt: * css3/blending/script-tests/background-blend-mode-property-parsing.js: (shouldBeType): * css3/blending/script-tests/blend-mode-property-parsing.js: (shouldBeType): * css3/filters/backdrop/backdropfilter-property-parsing-expected.txt: * css3/filters/backdrop/script-tests/backdropfilter-property-parsing.js: (shouldBeType): * css3/filters/filter-property-parsing-expected.txt: * css3/filters/script-tests/filter-property-parsing.js: (shouldBeType): * fast/css/image-set-parsing-expected.txt: * fast/css/script-tests/image-set-parsing.js: (shouldBeType): * fast/dom/DOMException/XPathException-expected.txt: * fast/dom/DOMException/prototype-object-expected.txt: * fast/dom/DOMException/prototype-object.html: * fast/dom/DOMException/resources/XPathException.js: * fast/dom/MutationObserver/mutation-record-constructor-expected.txt: * fast/dom/MutationObserver/mutation-record-constructor.html: * fast/dom/Window/element-constructors-on-window-expected.txt: * fast/dom/call-a-constructor-as-a-function-expected.txt: * fast/dom/constructor-proto-expected.txt: * fast/dom/constructor-proto.html: * fast/dom/wrapper-classes-expected.txt: * fast/dom/wrapper-classes.html: * fast/mediastream/MediaStreamConstructor-expected.txt: * fast/mediastream/MediaStreamConstructor.html: * fast/workers/constructor-proto-expected.txt: * fast/workers/worker-location-expected.txt: * http/tests/xmlhttprequest/XMLHttpRequestException-expected.txt: * http/tests/xmlhttprequest/XMLHttpRequestException.html: * js/dom/global-constructors-attributes-dedicated-worker-expected.txt: * js/dom/script-tests/global-constructors-attributes-idb.js: (constructorPropertiesOnGlobalObject): * js/dom/script-tests/global-constructors-attributes.js: (constructorPropertiesOnGlobalObject): * js/interface-objects-expected.txt: Added. * js/interface-objects.html: Added. * media/encrypted-media/encrypted-media-v2-syntax-expected.txt: * media/encrypted-media/encrypted-media-v2-syntax.html: * media/track/track-vttcue-expected.txt: * platform/mac/fast/dom/Window/window-lookup-precedence-expected.txt: * platform/mac/js/dom/global-constructors-attributes-expected.txt: * svg/custom/SVGException-expected.txt: * svg/custom/global-constructors-expected.txt: * svg/custom/script-tests/SVGException.js: * svg/custom/script-tests/global-constructors.js: (shouldBeDefined): * transforms/2d/transform-value-types-expected.txt: * transforms/2d/transform-value-types.html: Canonical link: https://commits.webkit.org/172193@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@196392 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-02-10 21:51:18 +00:00
Tests that interfaces objects have the right type
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
* Interface with constructor
PASS window.Event instanceof Function is true
PASS typeof Event is "function"
PASS Object.getPrototypeOf(Event) is Function.prototype
PASS Event('click') threw exception TypeError: Constructor requires 'new' operator.
PASS Event.call('click') threw exception TypeError: Constructor requires 'new' operator.
PASS new Event('click') did not throw exception.
PASS Event.toString() is "function Event() {\n [native code]\n}"
PASS object.toString.call(Event) is "[object Function]"
* Interface with named constructor
PASS window.Audio instanceof Function is true
PASS typeof Audio is "function"
PASS Object.getPrototypeOf(Audio) is Function.prototype
[Web IDL] interface objects should be Function objects https://bugs.webkit.org/show_bug.cgi?id=154038 <rdar://problem/24569358> Reviewed by Geoffrey Garen. LayoutTests/imported/w3c: Rebaseline W3C tests now that more checks are passing. Some checks still fail because a lot of our interfaces should inherit EventTarget and currently don't (they duplicate the EventTarget API instead). Also, as per WebIDL, window.NodeFilter's proto should be ObjectPrototype instead of FunctionPrototype but this is an exceptional case and our new behavior is consistent with Firefox and Chrome. * web-platform-tests/XMLHttpRequest/interfaces-expected.txt: * web-platform-tests/dom/events/Event-constructors-expected.txt: * web-platform-tests/dom/historical-expected.txt: * web-platform-tests/dom/interfaces-expected.txt: * web-platform-tests/fetch/api/headers/headers-idl-expected.txt: * web-platform-tests/fetch/api/request/request-idl-expected.txt: * web-platform-tests/html/dom/interfaces-expected.txt: * web-platform-tests/html/semantics/embedded-content/the-audio-element/audio_constructor-expected.txt: Source/JavaScriptCore: Update functionProtoFuncToString() to handle JSObjects that have the TypeOfShouldCallGetCallData flag and are callable, as these behave like functions and use ClassInfo::className() as function name in this case. * runtime/FunctionPrototype.cpp: (JSC::functionProtoFuncToString): Source/WebCore: interface objects should be Function objects as per Web IDL: - http://heycam.github.io/webidl/#interface-object - http://heycam.github.io/webidl/#es-interfaces So window.Event should be a Function object for e.g. but in WebKit it is a regular EventConstructor JSObject. Firefox and Chrome match the specification. Test: js/interface-objects.html * bindings/js/JSDOMBinding.cpp: (WebCore::callThrowTypeError): (WebCore::DOMConstructorObject::getCallData): When calling the interface object as a function, we throw a TypeError with a message asking to use the 'new' operator to match the behavior of Firefox and Chrome. * bindings/js/JSDOMBinding.h: Add JSC::TypeOfShouldCallGetCallData structure flag and implement getCallData() so that typeof returns "function", as per the specification and the behavior of other browsers. (WebCore::DOMConstructorObject::className): Implement className() and return "Function" to match the specification and other browsers. Otherwise, it would fall back to using ClassInfo::className which os the function name and interface name (e.g. "Event"). * bindings/js/JSDOMConstructor.h: (WebCore::JSDOMConstructorNotConstructable::callThrowTypeError): (WebCore::JSDOMConstructorNotConstructable::getCallData): As per the specification, interfaces that do not have a [Constructor] should throw a TypeError when called as a function. Use the "Illegal constructor" error message to match Firefox and Chrome. * bindings/js/JSDOMGlobalObject.h: (WebCore::getDOMConstructor): Instead of using objectPrototype as prototype for all DOM constructors, we now call the prototypeForStructure() static function that is generated for each bindings class. As per the Web IDL specification, The [[Prototype]] internal property of an interface object for a non-callback interface is determined as follows: 1. If the interface inherits from some other interface, the value of [[Prototype]] is the interface object for that other interface. 2. If the interface doesn't inherit from any other interface, the value of [[Prototype]] is %FunctionPrototype% ([ECMA-262], section 6.1.7.4). * bindings/js/JSImageConstructor.cpp: (WebCore::JSImageConstructor::prototypeForStructure): Have the Image's interface object use HTMLElement's interface object as prototype as HTMLImageElement inherits HTMLElement. * bindings/scripts/CodeGenerator.pm: (getInterfaceExtendedAttributesFromName): Add a utility function to cheaply retrieve an interface's IDL extended attributes without actually parsing the IDL. This is used to check if an interface's parent is marked as [NoInterfaceObject] currently. * bindings/scripts/CodeGeneratorJS.pm: (GenerateHeader): (GenerateImplementation): (GenerateCallbackHeader): (GenerateCallbackImplementation): Mark JSGlobalObject* parameter as const as the implementation does not alter the globalObject. (GenerateConstructorHelperMethods): - Generate prototypeForStructure() function for each bindings class that is not marked as [NoInterfaceObject] so getDOMConstructor() knows which prototype to use for the interface object / constructor when constructing it. - Use the interface name for the interface object, without the "Constructor" suffix, to match the behavior of Firefox and Chrome. * bindings/scripts/test/*: Rebaseline bindings tests. LayoutTests: Rebaseline / update existing layout tests now that interface objects are now Function objects. Also add a layout test to cover various aspects of interface objects. * css3/blending/background-blend-mode-property-parsing-expected.txt: * css3/blending/blend-mode-property-parsing-expected.txt: * css3/blending/script-tests/background-blend-mode-property-parsing.js: (shouldBeType): * css3/blending/script-tests/blend-mode-property-parsing.js: (shouldBeType): * css3/filters/backdrop/backdropfilter-property-parsing-expected.txt: * css3/filters/backdrop/script-tests/backdropfilter-property-parsing.js: (shouldBeType): * css3/filters/filter-property-parsing-expected.txt: * css3/filters/script-tests/filter-property-parsing.js: (shouldBeType): * fast/css/image-set-parsing-expected.txt: * fast/css/script-tests/image-set-parsing.js: (shouldBeType): * fast/dom/DOMException/XPathException-expected.txt: * fast/dom/DOMException/prototype-object-expected.txt: * fast/dom/DOMException/prototype-object.html: * fast/dom/DOMException/resources/XPathException.js: * fast/dom/MutationObserver/mutation-record-constructor-expected.txt: * fast/dom/MutationObserver/mutation-record-constructor.html: * fast/dom/Window/element-constructors-on-window-expected.txt: * fast/dom/call-a-constructor-as-a-function-expected.txt: * fast/dom/constructor-proto-expected.txt: * fast/dom/constructor-proto.html: * fast/dom/wrapper-classes-expected.txt: * fast/dom/wrapper-classes.html: * fast/mediastream/MediaStreamConstructor-expected.txt: * fast/mediastream/MediaStreamConstructor.html: * fast/workers/constructor-proto-expected.txt: * fast/workers/worker-location-expected.txt: * http/tests/xmlhttprequest/XMLHttpRequestException-expected.txt: * http/tests/xmlhttprequest/XMLHttpRequestException.html: * js/dom/global-constructors-attributes-dedicated-worker-expected.txt: * js/dom/script-tests/global-constructors-attributes-idb.js: (constructorPropertiesOnGlobalObject): * js/dom/script-tests/global-constructors-attributes.js: (constructorPropertiesOnGlobalObject): * js/interface-objects-expected.txt: Added. * js/interface-objects.html: Added. * media/encrypted-media/encrypted-media-v2-syntax-expected.txt: * media/encrypted-media/encrypted-media-v2-syntax.html: * media/track/track-vttcue-expected.txt: * platform/mac/fast/dom/Window/window-lookup-precedence-expected.txt: * platform/mac/js/dom/global-constructors-attributes-expected.txt: * svg/custom/SVGException-expected.txt: * svg/custom/global-constructors-expected.txt: * svg/custom/script-tests/SVGException.js: * svg/custom/script-tests/global-constructors.js: (shouldBeDefined): * transforms/2d/transform-value-types-expected.txt: * transforms/2d/transform-value-types.html: Canonical link: https://commits.webkit.org/172193@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@196392 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-02-10 21:51:18 +00:00
PASS Audio() threw exception TypeError: Constructor requires 'new' operator.
PASS Audio.call() threw exception TypeError: Constructor requires 'new' operator.
PASS new Audio() did not throw exception.
PASS Audio.toString() is "function Audio() {\n [native code]\n}"
PASS object.toString.call(Audio) is "[object Function]"
* Interface without constructor
PASS window.Element instanceof Function is true
PASS typeof Element is "function"
PASS Object.getPrototypeOf(Element) is Node
PASS Element() threw exception TypeError: Illegal constructor.
PASS Element.call() threw exception TypeError: Illegal constructor.
JSDOMConstructorNotConstructable should be a constructor https://bugs.webkit.org/show_bug.cgi?id=215554 <rdar://problem/65770688> Reviewed by Darin Adler. LayoutTests/imported/w3c: * web-platform-tests/FileAPI/file/send-file-form-expected.txt: * web-platform-tests/FileAPI/file/send-file-form-iso-2022-jp.tentative-expected.txt: * web-platform-tests/FileAPI/file/send-file-form-utf-8-expected.txt: * web-platform-tests/FileAPI/file/send-file-form-windows-1252.tentative-expected.txt: * web-platform-tests/FileAPI/file/send-file-form-x-user-defined.tentative-expected.txt: * web-platform-tests/css/cssom/CSSStyleSheet-constructable-baseURL.tentative-expected.txt: * web-platform-tests/css/cssom/CSSStyleSheet-constructable-disabled-regular-sheet-insertion-expected.txt: * web-platform-tests/css/cssom/CSSStyleSheet-constructable-disallow-import.tentative-expected.txt: * web-platform-tests/css/cssom/CSSStyleSheet-constructable-duplicate-expected.txt: * web-platform-tests/css/cssom/CSSStyleSheet-constructable-expected.txt: * web-platform-tests/css/cssom/CSSStyleSheet-modify-after-removal-expected.txt: * web-platform-tests/custom-elements/Document-createElement-expected.txt: * web-platform-tests/custom-elements/Document-createElementNS-expected.txt: * web-platform-tests/custom-elements/HTMLElement-attachInternals-expected.txt: * web-platform-tests/custom-elements/HTMLElement-constructor-expected.txt: * web-platform-tests/custom-elements/builtin-coverage-expected.txt: * web-platform-tests/custom-elements/customized-built-in-constructor-exceptions-expected.txt: * web-platform-tests/custom-elements/htmlconstructor/newtarget-expected.txt: * web-platform-tests/custom-elements/parser/serializing-html-fragments-expected.txt: * web-platform-tests/custom-elements/reactions/HTMLAreaElement-expected.txt: * web-platform-tests/custom-elements/reactions/HTMLBaseElement-expected.txt: * web-platform-tests/custom-elements/reactions/HTMLButtonElement-expected.txt: * web-platform-tests/custom-elements/reactions/HTMLCanvasElement-expected.txt: * web-platform-tests/custom-elements/reactions/HTMLDataElement-expected.txt: * web-platform-tests/custom-elements/reactions/HTMLDetailsElement-expected.txt: * web-platform-tests/custom-elements/reactions/HTMLEmbedElement-expected.txt: * web-platform-tests/custom-elements/reactions/HTMLFieldSetElement-expected.txt: * web-platform-tests/custom-elements/reactions/HTMLImageElement-expected.txt: * web-platform-tests/custom-elements/reactions/HTMLLIElement-expected.txt: * web-platform-tests/custom-elements/reactions/HTMLLabelElement-expected.txt: * web-platform-tests/custom-elements/reactions/HTMLMapElement-expected.txt: * web-platform-tests/custom-elements/reactions/HTMLMediaElement-expected.txt: * web-platform-tests/custom-elements/reactions/HTMLMetaElement-expected.txt: * web-platform-tests/custom-elements/reactions/HTMLMeterElement-expected.txt: * web-platform-tests/custom-elements/reactions/HTMLModElement-expected.txt: * web-platform-tests/custom-elements/reactions/HTMLOListElement-expected.txt: * web-platform-tests/custom-elements/reactions/HTMLOptGroupElement-expected.txt: * web-platform-tests/custom-elements/reactions/HTMLParamElement-expected.txt: * web-platform-tests/custom-elements/reactions/HTMLProgressElement-expected.txt: * web-platform-tests/custom-elements/reactions/HTMLQuoteElement-expected.txt: * web-platform-tests/custom-elements/reactions/HTMLSlotElement-expected.txt: * web-platform-tests/custom-elements/reactions/HTMLStyleElement-expected.txt: * web-platform-tests/custom-elements/reactions/HTMLTableCellElement-expected.txt: * web-platform-tests/custom-elements/reactions/HTMLTableColElement-expected.txt: * web-platform-tests/custom-elements/reactions/HTMLTimeElement-expected.txt: * web-platform-tests/custom-elements/upgrading/Document-importNode-expected.txt: * web-platform-tests/custom-elements/upgrading/Node-cloneNode-expected.txt: * web-platform-tests/dom/nodes/Node-appendChild-cereactions-vs-script.window-expected.txt: * web-platform-tests/html/editing/dnd/datastore/datatransfer-constructor-001-expected.txt: * web-platform-tests/html/editing/dnd/datastore/datatransfer-types-expected.txt: * web-platform-tests/html/semantics/forms/form-submission-0/submit-file.sub-expected.txt: * web-platform-tests/service-workers/service-worker/data-transfer-files.https-expected.txt: * web-platform-tests/shadow-dom/Element-interface-attachShadow-custom-element-expected.txt: * web-platform-tests/user-timing/mark-entry-constructor.any-expected.txt: * web-platform-tests/user-timing/mark-entry-constructor.any.worker-expected.txt: * web-platform-tests/user-timing/structured-serialize-detail.any-expected.txt: * web-platform-tests/user-timing/structured-serialize-detail.any.worker-expected.txt: * web-platform-tests/webrtc/RTCIceTransport-extension.https-expected.txt: Source/WebCore: Test: js/dom/window-is-constructor.html While JSDOMConstructorNotConstructable throws an error, still it should be a constructor, which means, `IsConstructor(JSDOMConstructorNotConstructable)` should be true. To fix it, we add getConstructData which configures a function throwing an error. * bindings/js/JSDOMConstructorNotConstructable.h: LayoutTests: * editing/async-clipboard/clipboard-interfaces-expected.txt: * editing/undo-manager/undo-manager-interfaces-expected.txt: * fast/dom/MutationObserver/mutation-record-constructor-expected.txt: * http/wpt/html/browsers/the-window-object/window-is-constructor-expected.txt: Added. * http/wpt/html/browsers/the-window-object/window-is-constructor.html: Added. * js/interface-objects-expected.txt: * performance-api/paint-timing/paint-timing-apis-expected.txt: * performance-api/performance-observer-api-expected.txt: * performance-api/performance-timeline-api-expected.txt: * performance-api/resource-timing-apis-expected.txt: * performance-api/user-timing-apis-expected.txt: * platform/ios-wk2/imported/w3c/web-platform-tests/custom-elements/builtin-coverage-expected.txt: * platform/ios-wk2/imported/w3c/web-platform-tests/custom-elements/reactions/HTMLInputElement-expected.txt: * platform/mac-wk2/imported/w3c/web-platform-tests/custom-elements/builtin-coverage-expected.txt: Canonical link: https://commits.webkit.org/228320@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@265749 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-08-17 07:37:12 +00:00
PASS new Element() threw exception TypeError: Illegal constructor.
[Web IDL] interface objects should be Function objects https://bugs.webkit.org/show_bug.cgi?id=154038 <rdar://problem/24569358> Reviewed by Geoffrey Garen. LayoutTests/imported/w3c: Rebaseline W3C tests now that more checks are passing. Some checks still fail because a lot of our interfaces should inherit EventTarget and currently don't (they duplicate the EventTarget API instead). Also, as per WebIDL, window.NodeFilter's proto should be ObjectPrototype instead of FunctionPrototype but this is an exceptional case and our new behavior is consistent with Firefox and Chrome. * web-platform-tests/XMLHttpRequest/interfaces-expected.txt: * web-platform-tests/dom/events/Event-constructors-expected.txt: * web-platform-tests/dom/historical-expected.txt: * web-platform-tests/dom/interfaces-expected.txt: * web-platform-tests/fetch/api/headers/headers-idl-expected.txt: * web-platform-tests/fetch/api/request/request-idl-expected.txt: * web-platform-tests/html/dom/interfaces-expected.txt: * web-platform-tests/html/semantics/embedded-content/the-audio-element/audio_constructor-expected.txt: Source/JavaScriptCore: Update functionProtoFuncToString() to handle JSObjects that have the TypeOfShouldCallGetCallData flag and are callable, as these behave like functions and use ClassInfo::className() as function name in this case. * runtime/FunctionPrototype.cpp: (JSC::functionProtoFuncToString): Source/WebCore: interface objects should be Function objects as per Web IDL: - http://heycam.github.io/webidl/#interface-object - http://heycam.github.io/webidl/#es-interfaces So window.Event should be a Function object for e.g. but in WebKit it is a regular EventConstructor JSObject. Firefox and Chrome match the specification. Test: js/interface-objects.html * bindings/js/JSDOMBinding.cpp: (WebCore::callThrowTypeError): (WebCore::DOMConstructorObject::getCallData): When calling the interface object as a function, we throw a TypeError with a message asking to use the 'new' operator to match the behavior of Firefox and Chrome. * bindings/js/JSDOMBinding.h: Add JSC::TypeOfShouldCallGetCallData structure flag and implement getCallData() so that typeof returns "function", as per the specification and the behavior of other browsers. (WebCore::DOMConstructorObject::className): Implement className() and return "Function" to match the specification and other browsers. Otherwise, it would fall back to using ClassInfo::className which os the function name and interface name (e.g. "Event"). * bindings/js/JSDOMConstructor.h: (WebCore::JSDOMConstructorNotConstructable::callThrowTypeError): (WebCore::JSDOMConstructorNotConstructable::getCallData): As per the specification, interfaces that do not have a [Constructor] should throw a TypeError when called as a function. Use the "Illegal constructor" error message to match Firefox and Chrome. * bindings/js/JSDOMGlobalObject.h: (WebCore::getDOMConstructor): Instead of using objectPrototype as prototype for all DOM constructors, we now call the prototypeForStructure() static function that is generated for each bindings class. As per the Web IDL specification, The [[Prototype]] internal property of an interface object for a non-callback interface is determined as follows: 1. If the interface inherits from some other interface, the value of [[Prototype]] is the interface object for that other interface. 2. If the interface doesn't inherit from any other interface, the value of [[Prototype]] is %FunctionPrototype% ([ECMA-262], section 6.1.7.4). * bindings/js/JSImageConstructor.cpp: (WebCore::JSImageConstructor::prototypeForStructure): Have the Image's interface object use HTMLElement's interface object as prototype as HTMLImageElement inherits HTMLElement. * bindings/scripts/CodeGenerator.pm: (getInterfaceExtendedAttributesFromName): Add a utility function to cheaply retrieve an interface's IDL extended attributes without actually parsing the IDL. This is used to check if an interface's parent is marked as [NoInterfaceObject] currently. * bindings/scripts/CodeGeneratorJS.pm: (GenerateHeader): (GenerateImplementation): (GenerateCallbackHeader): (GenerateCallbackImplementation): Mark JSGlobalObject* parameter as const as the implementation does not alter the globalObject. (GenerateConstructorHelperMethods): - Generate prototypeForStructure() function for each bindings class that is not marked as [NoInterfaceObject] so getDOMConstructor() knows which prototype to use for the interface object / constructor when constructing it. - Use the interface name for the interface object, without the "Constructor" suffix, to match the behavior of Firefox and Chrome. * bindings/scripts/test/*: Rebaseline bindings tests. LayoutTests: Rebaseline / update existing layout tests now that interface objects are now Function objects. Also add a layout test to cover various aspects of interface objects. * css3/blending/background-blend-mode-property-parsing-expected.txt: * css3/blending/blend-mode-property-parsing-expected.txt: * css3/blending/script-tests/background-blend-mode-property-parsing.js: (shouldBeType): * css3/blending/script-tests/blend-mode-property-parsing.js: (shouldBeType): * css3/filters/backdrop/backdropfilter-property-parsing-expected.txt: * css3/filters/backdrop/script-tests/backdropfilter-property-parsing.js: (shouldBeType): * css3/filters/filter-property-parsing-expected.txt: * css3/filters/script-tests/filter-property-parsing.js: (shouldBeType): * fast/css/image-set-parsing-expected.txt: * fast/css/script-tests/image-set-parsing.js: (shouldBeType): * fast/dom/DOMException/XPathException-expected.txt: * fast/dom/DOMException/prototype-object-expected.txt: * fast/dom/DOMException/prototype-object.html: * fast/dom/DOMException/resources/XPathException.js: * fast/dom/MutationObserver/mutation-record-constructor-expected.txt: * fast/dom/MutationObserver/mutation-record-constructor.html: * fast/dom/Window/element-constructors-on-window-expected.txt: * fast/dom/call-a-constructor-as-a-function-expected.txt: * fast/dom/constructor-proto-expected.txt: * fast/dom/constructor-proto.html: * fast/dom/wrapper-classes-expected.txt: * fast/dom/wrapper-classes.html: * fast/mediastream/MediaStreamConstructor-expected.txt: * fast/mediastream/MediaStreamConstructor.html: * fast/workers/constructor-proto-expected.txt: * fast/workers/worker-location-expected.txt: * http/tests/xmlhttprequest/XMLHttpRequestException-expected.txt: * http/tests/xmlhttprequest/XMLHttpRequestException.html: * js/dom/global-constructors-attributes-dedicated-worker-expected.txt: * js/dom/script-tests/global-constructors-attributes-idb.js: (constructorPropertiesOnGlobalObject): * js/dom/script-tests/global-constructors-attributes.js: (constructorPropertiesOnGlobalObject): * js/interface-objects-expected.txt: Added. * js/interface-objects.html: Added. * media/encrypted-media/encrypted-media-v2-syntax-expected.txt: * media/encrypted-media/encrypted-media-v2-syntax.html: * media/track/track-vttcue-expected.txt: * platform/mac/fast/dom/Window/window-lookup-precedence-expected.txt: * platform/mac/js/dom/global-constructors-attributes-expected.txt: * svg/custom/SVGException-expected.txt: * svg/custom/global-constructors-expected.txt: * svg/custom/script-tests/SVGException.js: * svg/custom/script-tests/global-constructors.js: (shouldBeDefined): * transforms/2d/transform-value-types-expected.txt: * transforms/2d/transform-value-types.html: Canonical link: https://commits.webkit.org/172193@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@196392 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-02-10 21:51:18 +00:00
PASS Element.toString() is "function Element() {\n [native code]\n}"
PASS object.toString.call(Element) is "[object Function]"
PASS successfullyParsed is true
TEST COMPLETE