Skip to content

Commit e4ad0e3

Browse files
author
shvaikalesh@gmail.com
committed
[WebIDL] Align property order of DOM constructors with ECMA-262 counterparts
https://bugs.webkit.org/show_bug.cgi?id=230584 Reviewed by Alex Christensen. LayoutTests/imported/w3c: This is being upstreamed at web-platform-tests/wpt#30333. * web-platform-tests/WebIDL/ecmascript-binding/builtin-function-properties.any-expected.txt: Added. * web-platform-tests/WebIDL/ecmascript-binding/builtin-function-properties.any.html: Added. * web-platform-tests/WebIDL/ecmascript-binding/builtin-function-properties.any.js: Added. * web-platform-tests/WebIDL/ecmascript-binding/builtin-function-properties.any.worker-expected.txt: Added. * web-platform-tests/WebIDL/ecmascript-binding/builtin-function-properties.any.worker.html: Added. Source/WebCore: This patch implements spec proposal [1] on matching property order of DOM constructors with ECMA-262 functions: "length", "name", "prototype". Aligns WebKit with Blink and Gecko. Also, groups property puts to remove 2 extra `$interface->isNamespaceObject` checks. No behavior change except for enumeration order. [1] whatwg/webidl#914 Tests: imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/builtin-function-properties.any.html imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/builtin-function-properties.any.worker.html * bindings/scripts/CodeGeneratorJS.pm: (GenerateConstructorHelperMethods): * bindings/scripts/test/JS/*: Updated. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@283233 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent c9fee8e commit e4ad0e3

File tree

89 files changed

+258
-187
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+258
-187
lines changed

LayoutTests/imported/w3c/ChangeLog

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
2021-09-29 Alexey Shvayka <shvaikalesh@gmail.com>
2+
3+
[WebIDL] Align property order of DOM constructors with ECMA-262 counterparts
4+
https://bugs.webkit.org/show_bug.cgi?id=230584
5+
6+
Reviewed by Alex Christensen.
7+
8+
This is being upstreamed at https://github.com/web-platform-tests/wpt/pull/30333.
9+
10+
* web-platform-tests/WebIDL/ecmascript-binding/builtin-function-properties.any-expected.txt: Added.
11+
* web-platform-tests/WebIDL/ecmascript-binding/builtin-function-properties.any.html: Added.
12+
* web-platform-tests/WebIDL/ecmascript-binding/builtin-function-properties.any.js: Added.
13+
* web-platform-tests/WebIDL/ecmascript-binding/builtin-function-properties.any.worker-expected.txt: Added.
14+
* web-platform-tests/WebIDL/ecmascript-binding/builtin-function-properties.any.worker.html: Added.
15+
116
2021-09-29 Aditya Keerthi <akeerthi@apple.com>
217

318
Update css-ui WPT
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
PASS Constructor property enumeration order of "length", "name", and "prototype"
3+
PASS Method property enumeration order of "length" and "name"
4+
PASS Getter property enumeration order of "length" and "name"
5+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<!-- This file is required for WebKit test infrastructure to run the templated test -->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
"use strict";
2+
3+
test(() => {
4+
const ownPropKeys = Reflect.ownKeys(Blob).slice(0, 3);
5+
assert_array_equals(ownPropKeys, ["length", "name", "prototype"]);
6+
}, 'Constructor property enumeration order of "length", "name", and "prototype"');
7+
8+
test(() => {
9+
assert_own_property(Blob.prototype, "slice");
10+
11+
const ownPropKeys = Reflect.ownKeys(Blob.prototype.slice).slice(0, 2);
12+
assert_array_equals(ownPropKeys, ["length", "name"]);
13+
}, 'Method property enumeration order of "length" and "name"');
14+
15+
test(() => {
16+
assert_own_property(Blob.prototype, "size");
17+
18+
const desc = Reflect.getOwnPropertyDescriptor(Blob.prototype, "size");
19+
assert_equals(typeof desc.get, "function");
20+
21+
const ownPropKeys = Reflect.ownKeys(desc.get).slice(0, 2);
22+
assert_array_equals(ownPropKeys, ["length", "name"]);
23+
}, 'Getter property enumeration order of "length" and "name"');
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
PASS Constructor property enumeration order of "length", "name", and "prototype"
3+
PASS Method property enumeration order of "length" and "name"
4+
PASS Getter property enumeration order of "length" and "name"
5+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<!-- This file is required for WebKit test infrastructure to run the templated test -->

Source/WebCore/ChangeLog

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
2021-09-29 Alexey Shvayka <shvaikalesh@gmail.com>
2+
3+
[WebIDL] Align property order of DOM constructors with ECMA-262 counterparts
4+
https://bugs.webkit.org/show_bug.cgi?id=230584
5+
6+
Reviewed by Alex Christensen.
7+
8+
This patch implements spec proposal [1] on matching property order of DOM constructors
9+
with ECMA-262 functions: "length", "name", "prototype". Aligns WebKit with Blink and Gecko.
10+
Also, groups property puts to remove 2 extra `$interface->isNamespaceObject` checks.
11+
12+
No behavior change except for enumeration order.
13+
14+
[1] https://github.com/heycam/webidl/pull/914
15+
16+
Tests: imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/builtin-function-properties.any.html
17+
imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/builtin-function-properties.any.worker.html
18+
19+
* bindings/scripts/CodeGeneratorJS.pm:
20+
(GenerateConstructorHelperMethods):
21+
* bindings/scripts/test/JS/*: Updated.
22+
123
2021-09-29 Olivier Blin <olivier.blin@softathome.com>
224

325
Fix typo in RenderSVGBlock::updateFromStyle comment

Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7795,36 +7795,35 @@ sub GenerateConstructorHelperMethods
77957795
push(@$outputArray, "template<> void ${constructorClassName}::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)\n");
77967796
push(@$outputArray, "{\n");
77977797

7798-
# There must exist an interface prototype object for every non-callback interface defined, regardless
7799-
# of whether the interface was declared with the [LegacyNoInterfaceObject] extended attribute.
7800-
# https://heycam.github.io/webidl/#interface-prototype-object
7801-
if (ShouldUseGlobalObjectPrototype($interface)) {
7802-
push(@$outputArray, " putDirect(vm, vm.propertyNames->prototype, globalObject.getPrototypeDirect(vm), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);\n");
7803-
} elsif ($interface->isCallback) {
7804-
push(@$outputArray, " UNUSED_PARAM(globalObject);\n");
7805-
} elsif ($interface->isNamespaceObject) {
7798+
assert("jsNontrivialString() requires strings two or more characters long") if length($visibleInterfaceName) < 2;
7799+
if ($interface->isNamespaceObject) {
78067800
push(@$outputArray, " JSC_TO_STRING_TAG_WITHOUT_TRANSITION();\n");
78077801
} else {
7808-
push(@$outputArray, " putDirect(vm, vm.propertyNames->prototype, ${className}::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);\n");
7809-
}
7802+
# FIXME: Remove TextTrackCue constructor along with [LegacyFactoryFunctionEnabledBySetting] extended attribute.
7803+
# https://bugs.webkit.org/show_bug.cgi?id=129615
7804+
if ($interface->extendedAttributes->{LegacyFactoryFunctionEnabledBySetting}) {
7805+
my $runtimeEnableConditionalString = GenerateRuntimeEnableConditionalString($interface, $interface, "&globalObject");
7806+
push(@$outputArray, " int constructorLength = ${leastConstructorLength};\n");
7807+
push(@$outputArray, " if (!${runtimeEnableConditionalString})\n");
7808+
push(@$outputArray, " constructorLength = 0;\n");
7809+
push(@$outputArray, " putDirect(vm, vm.propertyNames->length, jsNumber(constructorLength), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);\n");
7810+
} else {
7811+
push(@$outputArray, " putDirect(vm, vm.propertyNames->length, jsNumber(${leastConstructorLength}), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);\n");
7812+
}
78107813

7811-
assert("jsNontrivialString() requires strings two or more characters long") if length($visibleInterfaceName) < 2;
7812-
if (!$interface->isNamespaceObject) {
7813-
# FIXME: Align property order of DOM constructors with ECMA-262 counterparts
7814-
# https://bugs.webkit.org/show_bug.cgi?id=230584
78157814
push(@$outputArray, " JSString* nameString = jsNontrivialString(vm, \"$visibleInterfaceName\"_s);\n");
78167815
push(@$outputArray, " m_originalName.set(vm, this, nameString);\n");
78177816
push(@$outputArray, " putDirect(vm, vm.propertyNames->name, nameString, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);\n");
7818-
}
78197817

7820-
if ($interface->extendedAttributes->{LegacyFactoryFunctionEnabledBySetting}) {
7821-
my $runtimeEnableConditionalString = GenerateRuntimeEnableConditionalString($interface, $interface, "&globalObject");
7822-
push(@$outputArray, " int constructorLength = ${leastConstructorLength};\n");
7823-
push(@$outputArray, " if (!${runtimeEnableConditionalString})\n");
7824-
push(@$outputArray, " constructorLength = 0;\n");
7825-
push(@$outputArray, " putDirect(vm, vm.propertyNames->length, jsNumber(constructorLength), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);\n");
7826-
} elsif (!$interface->isNamespaceObject) {
7827-
push(@$outputArray, " putDirect(vm, vm.propertyNames->length, jsNumber(${leastConstructorLength}), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);\n");
7818+
# There must exist an interface prototype object for every non-callback interface defined, regardless
7819+
# of whether the interface was declared with the [LegacyNoInterfaceObject] extended attribute.
7820+
# https://heycam.github.io/webidl/#interface-prototype-object
7821+
if ($interface->isCallback) {
7822+
push(@$outputArray, " UNUSED_PARAM(globalObject);\n");
7823+
} else {
7824+
my $prototype = ShouldUseGlobalObjectPrototype($interface) ? "globalObject.getPrototypeDirect(vm)" : "${className}::prototype(vm, globalObject)";
7825+
push(@$outputArray, " putDirect(vm, vm.propertyNames->prototype, ${prototype}, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::DontDelete);\n");
7826+
}
78287827
}
78297828

78307829
my $classForThis = "${className}::info()";

Source/WebCore/bindings/scripts/test/JS/JSDOMWindow.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,11 @@ template<> JSValue JSDOMWindowDOMConstructor::prototypeForStructure(JSC::VM& vm,
152152

153153
template<> void JSDOMWindowDOMConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
154154
{
155-
putDirect(vm, vm.propertyNames->prototype, globalObject.getPrototypeDirect(vm), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
155+
putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
156156
JSString* nameString = jsNontrivialString(vm, "DOMWindow"_s);
157157
m_originalName.set(vm, this, nameString);
158158
putDirect(vm, vm.propertyNames->name, nameString, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
159-
putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
159+
putDirect(vm, vm.propertyNames->prototype, globalObject.getPrototypeDirect(vm), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::DontDelete);
160160
}
161161

162162
/* Hash table for prototype */

Source/WebCore/bindings/scripts/test/JS/JSDedicatedWorkerGlobalScope.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,11 @@ template<> JSValue JSDedicatedWorkerGlobalScopeDOMConstructor::prototypeForStruc
7676

7777
template<> void JSDedicatedWorkerGlobalScopeDOMConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
7878
{
79-
putDirect(vm, vm.propertyNames->prototype, globalObject.getPrototypeDirect(vm), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
79+
putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
8080
JSString* nameString = jsNontrivialString(vm, "DedicatedWorkerGlobalScope"_s);
8181
m_originalName.set(vm, this, nameString);
8282
putDirect(vm, vm.propertyNames->name, nameString, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
83-
putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
83+
putDirect(vm, vm.propertyNames->prototype, globalObject.getPrototypeDirect(vm), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::DontDelete);
8484
}
8585

8686
/* Hash table for prototype */

0 commit comments

Comments
 (0)