mirror of
https://github.com/tc39/test262.git
synced 2025-05-30 19:50:28 +02:00
Modify $262.uncallableAndIsHTMLDDA() to $262.IsHTMLDDA (#1305)
Modify $262.uncallableAndIsHTMLDDA() to an optional $262.IsHTMLDDA (whose use must be guarded by a feature of the same name), and narrowly/correctly prescribe its requirements consistent with `document.all`'s behavior in HTML.
This commit is contained in:
parent
893013a658
commit
c05138b44c
@ -64,16 +64,16 @@ properties of the global scope prior to test execution.
|
|||||||
6. Return Completion(status).
|
6. Return Completion(status).
|
||||||
|
|
||||||
- **`global`** - a reference to the global object on which `$262` was initially defined
|
- **`global`** - a reference to the global object on which `$262` was initially defined
|
||||||
- **`uncallableAndIsHTMLDDA`** - a function that returns an object *`obj`* for
|
- **`IsHTMLDDA`** - (present only in implementations that can provide it) an
|
||||||
which [Call](https://tc39.github.io/ecma262/#sec-call)(*`obj`*, *any value*, «»)
|
object that 1) has an [[IsHTMLDDA]] internal slot, and 2) when called with
|
||||||
throws a `TypeError`. (The value of [IsCallable]()(*`obj`*) is unspecified:
|
no arguments or with the single argument `""` returns `null`. Use this
|
||||||
a callable *`obj`* that throws a `TypeError` or an uncallable *`obj`* works
|
property to test that ECMAScript algorithms aren't mis-implemented to treat
|
||||||
equally well.) In hosts supporting the
|
`document.all` as being `undefined` or of type Undefined (instead of
|
||||||
[IsHTMLDDA](https://tc39.github.io/ecma262/#sec-IsHTMLDDA-internal-slot)
|
Object). (The peculiar second requirement permits testing algorithms when
|
||||||
internal slot, *`obj`* must also have such a slot. (These highly specific
|
they also call `document.all` with such arguments, so that testing for
|
||||||
behaviors are entirely motivated by the very few tests that use this. Read
|
correct behavior requires knowing how the call behaves. This is rarely
|
||||||
them for an explanation.) Tests that use this function should be marked as
|
necessary.) Tests using this function must be tagged with the `IsHTMLDDA`
|
||||||
using the `uncallableAndIsHTMLDDA` feature.
|
feature so that only hosts supporting this property will run them.
|
||||||
- **`agent`** - an ordinary object with the following properties:
|
- **`agent`** - an ordinary object with the following properties:
|
||||||
- **`start`** - a function that takes a script source string and runs
|
- **`start`** - a function that takes a script source string and runs
|
||||||
the script in a concurrent agent. Will block until that agent is
|
the script in a concurrent agent. Will block until that agent is
|
||||||
|
@ -124,4 +124,4 @@ WeakSet
|
|||||||
# language features, exposed through global-environment functions on the $262
|
# language features, exposed through global-environment functions on the $262
|
||||||
# object, go here.
|
# object, go here.
|
||||||
|
|
||||||
uncallableAndIsHTMLDDA
|
IsHTMLDDA
|
||||||
|
@ -2,18 +2,19 @@
|
|||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
es6id: sec-generator-function-definitions-runtime-semantics-evaluation
|
esid: sec-generator-function-definitions-runtime-semantics-evaluation
|
||||||
description: >
|
description: >
|
||||||
If <iterator>.return is an object emulating `undefined` (e.g. `document.all`
|
If <iterator>.return is an object emulating `undefined` (e.g. `document.all`
|
||||||
in browsers), it shouldn't be treated as if it were actually `undefined` by
|
in browsers), it shouldn't be treated as if it were actually `undefined` by
|
||||||
the yield* operator.
|
the yield* operator.
|
||||||
features: [generators, uncallableAndIsHTMLDDA]
|
features: [generators, IsHTMLDDA]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
|
var IsHTMLDDA = $262.IsHTMLDDA;
|
||||||
var iter = {
|
var iter = {
|
||||||
[Symbol.iterator]() { return this; },
|
[Symbol.iterator]() { return this; },
|
||||||
next() { return {}; },
|
next() { return {}; },
|
||||||
return: $262.uncallableAndIsHTMLDDA(),
|
return: IsHTMLDDA,
|
||||||
};
|
};
|
||||||
|
|
||||||
var outer = (function*() { yield* iter; })();
|
var outer = (function*() { yield* iter; })();
|
||||||
@ -21,11 +22,10 @@ var outer = (function*() { yield* iter; })();
|
|||||||
outer.next();
|
outer.next();
|
||||||
|
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
// This code is expected to throw a TypeError because `iter.return` throws a
|
// `IsHTMLDDA` is called here with `iter` as `this` and `emptyString` as the
|
||||||
// TypeError when invoked with `iter` as `this` and no arguments provided.
|
// sole argument, and it's specified to return `null` under these conditions.
|
||||||
// It's irrelevant that in hosts that support the [[IsHTMLDDA]] internal slot,
|
// As `iter`'s iteration isn't ending because of a throw, the iteration
|
||||||
// this object has that slot: `<iterator>.return` behavior is skipped only if
|
// protocol will then throw a `TypeError` because `null` isn't an object.
|
||||||
// that property is exactly the value `undefined`, not a value loosely equal
|
var emptyString = "";
|
||||||
// to it.
|
outer.return(emptyString);
|
||||||
outer.return();
|
|
||||||
});
|
});
|
||||||
|
@ -7,19 +7,23 @@ description: >
|
|||||||
`GetIterator(obj, ~async~)` must attempt to call `obj[@@asyncIterator]` when
|
`GetIterator(obj, ~async~)` must attempt to call `obj[@@asyncIterator]` when
|
||||||
that value is an object with an [[IsHTMLDDA]] internal slot, not act as if
|
that value is an object with an [[IsHTMLDDA]] internal slot, not act as if
|
||||||
the value were `undefined`.
|
the value were `undefined`.
|
||||||
features: [async-iteration, uncallableAndIsHTMLDDA]
|
features: [async-iteration, IsHTMLDDA]
|
||||||
flags: [async]
|
flags: [async]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
async function f() {
|
async function f() {
|
||||||
var fakeIter = {
|
var IsHTMLDDA = $262.IsHTMLDDA;
|
||||||
[Symbol.asyncIterator]: $262.uncallableAndIsHTMLDDA(),
|
var iter = {
|
||||||
|
[Symbol.asyncIterator]: IsHTMLDDA,
|
||||||
get [Symbol.iterator]() {
|
get [Symbol.iterator]() {
|
||||||
throw new Test262Error("shouldn't touch Symbol.iterator");
|
throw new Test262Error("shouldn't touch Symbol.iterator");
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
for await (var x of fakeIter)
|
// `IsHTMLDDA` is called here with `iter` as `this` and no arguments, and it's
|
||||||
|
// expected to return `null` under these conditions. Then the iteration
|
||||||
|
// protocol throws a `TypeError` because `null` isn't an object.
|
||||||
|
for await (var x of iter)
|
||||||
return "for-await-of body shouldn't be reached";
|
return "for-await-of body shouldn't be reached";
|
||||||
|
|
||||||
return "should have failed earlier";
|
return "should have failed earlier";
|
||||||
@ -28,7 +32,8 @@ async function f() {
|
|||||||
f().then($DONE,
|
f().then($DONE,
|
||||||
function (e) {
|
function (e) {
|
||||||
assert.sameValue(e.constructor, TypeError,
|
assert.sameValue(e.constructor, TypeError,
|
||||||
"expected TypeError from calling " +
|
"expected TypeError because " +
|
||||||
"uncallableAndIsHTMLDDA() value: " + e);
|
"`iter[Symbol.asyncIterator]() returned a " +
|
||||||
|
"non-object: " + e);
|
||||||
})
|
})
|
||||||
.then($DONE, $DONE);
|
.then($DONE, $DONE);
|
||||||
|
@ -2,26 +2,24 @@
|
|||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
es6id: sec-iteratorclose
|
esid: sec-iteratorclose
|
||||||
description: >
|
description: >
|
||||||
If <iterator>.return is an object emulating `undefined` (e.g. `document.all`
|
If <iterator>.return is an object emulating `undefined` (e.g. `document.all`
|
||||||
in browsers), it shouldn't be treated as if it were actually `undefined`.
|
in browsers), it shouldn't be treated as if it were actually `undefined`.
|
||||||
features: [generators, uncallableAndIsHTMLDDA]
|
features: [generators, IsHTMLDDA]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
|
var IsHTMLDDA = $262.IsHTMLDDA;
|
||||||
var iter = {
|
var iter = {
|
||||||
[Symbol.iterator]() { return this; },
|
[Symbol.iterator]() { return this; },
|
||||||
next() { return {}; },
|
next() { return {}; },
|
||||||
return: $262.uncallableAndIsHTMLDDA(),
|
return: IsHTMLDDA,
|
||||||
};
|
};
|
||||||
|
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
// This code is expected to throw a TypeError because `iter.return` throws a
|
// `IsHTMLDDA` is called here with `iter` as `this` and no arguments, and it's
|
||||||
// TypeError when invoked with `iter` as `this` and no arguments provided.
|
// specified to return `null` under these conditions. Then the iteration
|
||||||
// It's irrelevant that in hosts that support the [[IsHTMLDDA]] internal slot,
|
// protocol throws a `TypeError` because `null` isn't an object.
|
||||||
// this object has that slot: `<iterator>.return` behavior is skipped only if
|
|
||||||
// that property is exactly the value `undefined`, not a value loosely equal
|
|
||||||
// to it.
|
|
||||||
for (var x of iter)
|
for (var x of iter)
|
||||||
break;
|
break;
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user