mirror of
https://github.com/servo/servo.git
synced 2025-08-10 16:05:43 +01:00
Update web-platform-tests to revision 4a5223502fa660ce03e470af6a61c8bc26c5a8ee
This commit is contained in:
parent
c5f7c9ccf3
commit
e891345f26
1328 changed files with 36632 additions and 20588 deletions
|
@ -91,6 +91,159 @@ test(function () {
|
|||
|
||||
}, 'HTMLElement constructor must allow subclassing an user-defined subclass of HTMLElement');
|
||||
|
||||
test(function() {
|
||||
class SomeCustomElement extends HTMLElement {};
|
||||
var getCount = 0;
|
||||
var countingProxy = new Proxy(SomeCustomElement, {
|
||||
get: function(target, prop, receiver) {
|
||||
if (prop == "prototype") {
|
||||
++getCount;
|
||||
}
|
||||
return Reflect.get(target, prop, receiver);
|
||||
}
|
||||
});
|
||||
customElements.define("success-counting-element-1", countingProxy);
|
||||
// define() gets the prototype of the constructor it's passed, so
|
||||
// reset the counter.
|
||||
getCount = 0;
|
||||
var instance = new countingProxy();
|
||||
assert_equals(getCount, 1, "Should have gotten .prototype once");
|
||||
assert_true(instance instanceof countingProxy);
|
||||
assert_true(instance instanceof HTMLElement);
|
||||
assert_true(instance instanceof SomeCustomElement);
|
||||
assert_equals(instance.localName, "success-counting-element-1");
|
||||
assert_equals(instance.nodeName, "SUCCESS-COUNTING-ELEMENT-1");
|
||||
}, 'HTMLElement constructor must only get .prototype once, calling proxy constructor directly');
|
||||
|
||||
test(function() {
|
||||
class SomeCustomElement extends HTMLElement {};
|
||||
var getCount = 0;
|
||||
var countingProxy = new Proxy(SomeCustomElement, {
|
||||
get: function(target, prop, receiver) {
|
||||
if (prop == "prototype") {
|
||||
++getCount;
|
||||
}
|
||||
return Reflect.get(target, prop, receiver);
|
||||
}
|
||||
});
|
||||
customElements.define("success-counting-element-2", countingProxy);
|
||||
// define() gets the prototype of the constructor it's passed, so
|
||||
// reset the counter.
|
||||
getCount = 0;
|
||||
var instance = Reflect.construct(HTMLElement, [], countingProxy);
|
||||
assert_equals(getCount, 1, "Should have gotten .prototype once");
|
||||
assert_true(instance instanceof countingProxy);
|
||||
assert_true(instance instanceof HTMLElement);
|
||||
assert_true(instance instanceof SomeCustomElement);
|
||||
assert_equals(instance.localName, "success-counting-element-2");
|
||||
assert_equals(instance.nodeName, "SUCCESS-COUNTING-ELEMENT-2");
|
||||
}, 'HTMLElement constructor must only get .prototype once, calling proxy constructor via Reflect');
|
||||
|
||||
test(function() {
|
||||
class SomeCustomElement {};
|
||||
var getCount = 0;
|
||||
var countingProxy = new Proxy(SomeCustomElement, {
|
||||
get: function(target, prop, receiver) {
|
||||
if (prop == "prototype") {
|
||||
++getCount;
|
||||
}
|
||||
return Reflect.get(target, prop, receiver);
|
||||
}
|
||||
});
|
||||
customElements.define("success-counting-element-3", countingProxy);
|
||||
// define() gets the prototype of the constructor it's passed, so
|
||||
// reset the counter.
|
||||
getCount = 0;
|
||||
var instance = Reflect.construct(HTMLElement, [], countingProxy);
|
||||
assert_equals(getCount, 1, "Should have gotten .prototype once");
|
||||
assert_true(instance instanceof countingProxy);
|
||||
assert_true(instance instanceof SomeCustomElement);
|
||||
assert_equals(instance.localName, undefined);
|
||||
assert_equals(instance.nodeName, undefined);
|
||||
}, 'HTMLElement constructor must only get .prototype once, calling proxy constructor via Reflect with no inheritance');
|
||||
|
||||
test(function() {
|
||||
class SomeCustomElement extends HTMLElement {};
|
||||
var getCount = 0;
|
||||
var countingProxy = new Proxy(SomeCustomElement, {
|
||||
get: function(target, prop, receiver) {
|
||||
if (prop == "prototype") {
|
||||
++getCount;
|
||||
}
|
||||
return Reflect.get(target, prop, receiver);
|
||||
}
|
||||
});
|
||||
customElements.define("failure-counting-element-1", countingProxy,
|
||||
{ extends: "button" });
|
||||
// define() gets the prototype of the constructor it's passed, so
|
||||
// reset the counter.
|
||||
getCount = 0;
|
||||
assert_throws({'name': 'TypeError'},
|
||||
function () { new countingProxy() },
|
||||
"Should not be able to construct an HTMLElement named 'button'");
|
||||
assert_equals(getCount, 0, "Should never have gotten .prototype");
|
||||
}, 'HTMLElement constructor must not get .prototype until it finishes its extends sanity checks, calling proxy constructor directly');
|
||||
|
||||
test(function() {
|
||||
class SomeCustomElement extends HTMLElement {};
|
||||
var getCount = 0;
|
||||
var countingProxy = new Proxy(SomeCustomElement, {
|
||||
get: function(target, prop, receiver) {
|
||||
if (prop == "prototype") {
|
||||
++getCount;
|
||||
}
|
||||
return Reflect.get(target, prop, receiver);
|
||||
}
|
||||
});
|
||||
customElements.define("failure-counting-element-2", countingProxy,
|
||||
{ extends: "button" });
|
||||
// define() gets the prototype of the constructor it's passed, so
|
||||
// reset the counter.
|
||||
getCount = 0;
|
||||
assert_throws({'name': 'TypeError'},
|
||||
function () { Reflect.construct(HTMLElement, [], countingProxy) },
|
||||
"Should not be able to construct an HTMLElement named 'button'");
|
||||
assert_equals(getCount, 0, "Should never have gotten .prototype");
|
||||
}, 'HTMLElement constructor must not get .prototype until it finishes its extends sanity checks, calling via Reflect');
|
||||
|
||||
test(function() {
|
||||
class SomeCustomElement extends HTMLElement {};
|
||||
var getCount = 0;
|
||||
var countingProxy = new Proxy(SomeCustomElement, {
|
||||
get: function(target, prop, receiver) {
|
||||
if (prop == "prototype") {
|
||||
++getCount;
|
||||
}
|
||||
return Reflect.get(target, prop, receiver);
|
||||
}
|
||||
});
|
||||
|
||||
// Purposefully don't register it.
|
||||
assert_throws({'name': 'TypeError'},
|
||||
function () { new countingProxy() },
|
||||
"Should not be able to construct an HTMLElement named 'button'");
|
||||
assert_equals(getCount, 0, "Should never have gotten .prototype");
|
||||
}, 'HTMLElement constructor must not get .prototype until it finishes its registration sanity checks, calling proxy constructor directly');
|
||||
|
||||
test(function() {
|
||||
class SomeCustomElement extends HTMLElement {};
|
||||
var getCount = 0;
|
||||
var countingProxy = new Proxy(SomeCustomElement, {
|
||||
get: function(target, prop, receiver) {
|
||||
if (prop == "prototype") {
|
||||
++getCount;
|
||||
}
|
||||
return Reflect.get(target, prop, receiver);
|
||||
}
|
||||
});
|
||||
|
||||
// Purposefully don't register it.
|
||||
assert_throws({'name': 'TypeError'},
|
||||
function () { Reflect.construct(HTMLElement, [], countingProxy) },
|
||||
"Should not be able to construct an HTMLElement named 'button'");
|
||||
assert_equals(getCount, 0, "Should never have gotten .prototype");
|
||||
}, 'HTMLElement constructor must not get .prototype until it finishes its registration sanity checks, calling via Reflect');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
|
|
@ -124,5 +124,46 @@ test_with_window(w => {
|
|||
}, "If prototype is not object (" + notAnObject + "), derives the fallback from NewTarget's realm (customized built-in elements)");
|
||||
});
|
||||
|
||||
test_with_window(w => {
|
||||
class SomeCustomElement extends HTMLParagraphElement {};
|
||||
var getCount = 0;
|
||||
var countingProxy = new Proxy(SomeCustomElement, {
|
||||
get: function(target, prop, receiver) {
|
||||
if (prop == "prototype") {
|
||||
++getCount;
|
||||
}
|
||||
return Reflect.get(target, prop, receiver);
|
||||
}
|
||||
});
|
||||
w.customElements.define("failure-counting-element", countingProxy);
|
||||
// define() gets the prototype of the constructor it's passed, so
|
||||
// reset the counter.
|
||||
getCount = 0;
|
||||
assert_throws({'name': 'TypeError'},
|
||||
function () { new countingProxy() },
|
||||
"Should not be able to construct an HTMLParagraphElement not named 'p'");
|
||||
assert_equals(getCount, 0, "Should never have gotten .prototype");
|
||||
}, 'HTMLParagraphElement constructor must not get .prototype until it finishes its extends sanity checks, calling proxy constructor directly');
|
||||
|
||||
test_with_window(w => {
|
||||
class SomeCustomElement extends HTMLParagraphElement {};
|
||||
var getCount = 0;
|
||||
var countingProxy = new Proxy(SomeCustomElement, {
|
||||
get: function(target, prop, receiver) {
|
||||
if (prop == "prototype") {
|
||||
++getCount;
|
||||
}
|
||||
return Reflect.get(target, prop, receiver);
|
||||
}
|
||||
});
|
||||
w.customElements.define("failure-counting-element", countingProxy);
|
||||
// define() gets the prototype of the constructor it's passed, so
|
||||
// reset the counter.
|
||||
getCount = 0;
|
||||
assert_throws({'name': 'TypeError'},
|
||||
function () { Reflect.construct(HTMLParagraphElement, [], countingProxy) },
|
||||
"Should not be able to construct an HTMLParagraphElement not named 'p'");
|
||||
assert_equals(getCount, 0, "Should never have gotten .prototype");
|
||||
}, 'HTMLParagraphElement constructor must not get .prototype until it finishes its extends sanity checks, calling via Reflect');
|
||||
</script>
|
||||
</body>
|
||||
</body>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue