Skip to content

Commit a42efbf

Browse files
committed
2 parents b5cf071 + f9ebd54 commit a42efbf

File tree

294 files changed

+2225
-1111
lines changed

Some content is hidden

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

294 files changed

+2225
-1111
lines changed

JSTests/stress/iterator-from.js

Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
//@ requireOptions("--useIteratorHelpers=1")
2+
3+
function assert(a, text) {
4+
if (!a)
5+
throw new Error(`Failed assertion: ${text}`);
6+
}
7+
8+
function sameValue(a, b) {
9+
if (a !== b)
10+
throw new Error(`Expected ${b} but got ${a}`);
11+
}
12+
13+
function shouldThrow(fn, error, message) {
14+
try {
15+
fn();
16+
throw new Error('Expected to throw, but succeeded');
17+
} catch (e) {
18+
if (!(e instanceof error))
19+
throw new Error(`Expected to throw ${error.name} but got ${e.name}`);
20+
if (e.message !== message)
21+
throw new Error(`Expected ${error.name} with '${message}' but got '${e.message}'`);
22+
}
23+
}
24+
25+
{
26+
class Iter {
27+
next() {
28+
return { done: false, value: 1 };
29+
}
30+
}
31+
const iter = new Iter();
32+
const wrapper = Iterator.from(iter);
33+
const result = wrapper.next();
34+
sameValue(result.value, 1);
35+
sameValue(result.done, false);
36+
}
37+
38+
{
39+
const iter = {};
40+
const wrapper = Iterator.from(iter);
41+
const result = wrapper.return();
42+
assert(Object.hasOwn(result, "value"), "Object.hasOwn(result, 'value')");
43+
sameValue(result.value, undefined);
44+
sameValue(result.done, true);
45+
}
46+
47+
{
48+
class Iter {
49+
return() {
50+
return { done: true, value: 5 };
51+
}
52+
}
53+
const iter = new Iter();
54+
const wrapper = Iterator.from(iter);
55+
const result = wrapper.return();
56+
sameValue(result.value, 5);
57+
sameValue(result.done, true);
58+
}
59+
60+
{
61+
class Iter extends Iterator {
62+
next() {
63+
return { done: false, value: 1 };
64+
}
65+
}
66+
const iter = new Iter();
67+
const wrapper = Iterator.from(iter);
68+
assert(wrapper instanceof Iterator, "wrapper instanceof Iterator");
69+
assert(wrapper === iter, "wrapper === iter");
70+
const result = wrapper.next();
71+
sameValue(result.value, 1);
72+
sameValue(result.done, false);
73+
}
74+
75+
{
76+
let nextCount = 0;
77+
let returnCount = 0;
78+
79+
const iter = {
80+
get next() {
81+
nextCount++;
82+
return function () {
83+
return { done: false, value: 1 };
84+
};
85+
},
86+
get return() {
87+
returnCount++;
88+
return function () {
89+
return { done: true, value: 5 };
90+
};
91+
},
92+
};
93+
94+
const wrapper = Iterator.from(iter);
95+
sameValue(nextCount, 1);
96+
sameValue(returnCount, 0);
97+
98+
const nextResult = wrapper.next();
99+
sameValue(nextCount, 1);
100+
sameValue(returnCount, 0);
101+
sameValue(nextResult.value, 1);
102+
sameValue(nextResult.done, false);
103+
104+
const returnResult = wrapper.return();
105+
sameValue(nextCount, 1);
106+
sameValue(returnCount, 1);
107+
sameValue(returnResult.value, 5);
108+
sameValue(returnResult.done, true);
109+
}
110+
111+
{
112+
let nextCount = 0;
113+
let returnCount = 0;
114+
115+
class Iter extends Iterator {}
116+
const iter = new Iter();
117+
Object.defineProperties(iter, {
118+
next: {
119+
get() {
120+
nextCount++;
121+
return function () {
122+
return { done: false, value: 1 };
123+
};
124+
},
125+
},
126+
return: {
127+
get() {
128+
returnCount++;
129+
return function () {
130+
return { done: true, value: 5 };
131+
};
132+
},
133+
},
134+
});
135+
const wrapper = Iterator.from(iter);
136+
assert(wrapper instanceof Iterator);
137+
sameValue(nextCount, 1);
138+
sameValue(returnCount, 0);
139+
140+
const nextResult = wrapper.next();
141+
sameValue(nextCount, 2);
142+
sameValue(returnCount, 0);
143+
sameValue(nextResult.value, 1);
144+
sameValue(nextResult.done, false);
145+
146+
const returnResult = wrapper.return();
147+
sameValue(nextCount, 2);
148+
sameValue(returnCount, 1);
149+
sameValue(returnResult.value, 5);
150+
sameValue(returnResult.done, true);
151+
}
152+
153+
{
154+
const iterator = Iterator.from("string");
155+
sameValue(iterator.toString(), "[object String Iterator]");
156+
}
157+
158+
{
159+
const invalidIterators = [
160+
1,
161+
1n,
162+
true,
163+
false,
164+
null,
165+
undefined,
166+
Symbol("symbol"),
167+
];
168+
for (const invalidIterator of invalidIterators) {
169+
shouldThrow(() => { Iterator.from(invalidIterator) }, TypeError, "Iterafor.from requires an object or string");
170+
}
171+
}
172+
173+
{
174+
const iter = {};
175+
const wrapper = Iterator.from(iter);
176+
const WrapForValidIteratorPrototypeNext = wrapper.next.bind(null);
177+
const WrapForValidIteratorPrototypeReturn = wrapper.return.bind(null);
178+
179+
shouldThrow(() => {
180+
WrapForValidIteratorPrototypeNext.call({})
181+
}, TypeError, "%WrapForValidIteratorPrototype%.next requires that |this| be a WrapForValidIteratorPrototype object")
182+
183+
shouldThrow(() => {
184+
WrapForValidIteratorPrototypeReturn.call({})
185+
}, TypeError, "%WrapForValidIteratorPrototype%.next requires that |this| be a WrapForValidIteratorPrototype object")
186+
}
187+
188+
{
189+
let symbolIteraterGetCount = 0;
190+
const iter = {
191+
get [Symbol.iterator]() {
192+
symbolIteraterGetCount++;
193+
return function() { return this };
194+
},
195+
};
196+
const wrapper = Iterator.from(iter);
197+
sameValue(symbolIteraterGetCount, 1);
198+
}
199+
200+
{
201+
const iter = {
202+
[Symbol.iterator]() {
203+
return 3;
204+
},
205+
};
206+
shouldThrow(() => { Iterator.from(iter); }, TypeError, "Iterator is not an object");
207+
}

JSTests/test262/expectations.yaml

Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -58,48 +58,9 @@ test/built-ins/Function/internals/Construct/derived-this-uninitialized-realm.js:
5858
test/built-ins/Function/prototype/toString/built-in-function-object.js:
5959
default: 'Test262Error: Conforms to NativeFunction Syntax: "function $*() {\n [native code]\n}" (%RegExp%.$*)'
6060
strict mode: 'Test262Error: Conforms to NativeFunction Syntax: "function $*() {\n [native code]\n}" (%RegExp%.$*)'
61-
test/built-ins/Iterator/from/callable.js:
62-
default: "TypeError: Iterator.from is not a function. (In 'Iterator.from(g())', 'Iterator.from' is undefined)"
63-
strict mode: "TypeError: Iterator.from is not a function. (In 'Iterator.from(g())', 'Iterator.from' is undefined)"
6461
test/built-ins/Iterator/from/get-next-method-only-once.js:
65-
default: "TypeError: Iterator.from is not a function. (In 'Iterator.from(iterator)', 'Iterator.from' is undefined)"
66-
strict mode: "TypeError: Iterator.from is not a function. (In 'Iterator.from(iterator)', 'Iterator.from' is undefined)"
67-
test/built-ins/Iterator/from/get-next-method-throws.js:
68-
default: 'Test262Error: Expected a Test262Error but got a TypeError'
69-
strict mode: 'Test262Error: Expected a Test262Error but got a TypeError'
70-
test/built-ins/Iterator/from/is-function.js:
71-
default: 'Test262Error: The value of `typeof Iterator.from` is "function" Expected SameValue(«undefined», «function») to be true'
72-
strict mode: 'Test262Error: The value of `typeof Iterator.from` is "function" Expected SameValue(«undefined», «function») to be true'
73-
test/built-ins/Iterator/from/iterable-primitives.js:
74-
default: "TypeError: Iterator.from is not a function. (In 'Iterator.from(new Number(5))', 'Iterator.from' is undefined)"
75-
strict mode: "TypeError: Iterator.from is not a function. (In 'Iterator.from(new Number(5))', 'Iterator.from' is undefined)"
76-
test/built-ins/Iterator/from/iterable-to-iterator-fallback.js:
77-
default: "TypeError: Iterator.from is not a function. (In 'Iterator.from(iter)', 'Iterator.from' is undefined)"
78-
strict mode: "TypeError: Iterator.from is not a function. (In 'Iterator.from(iter)', 'Iterator.from' is undefined)"
79-
test/built-ins/Iterator/from/length.js:
80-
default: "TypeError: undefined is not an object (evaluating 'Object.getOwnPropertyDescriptor(obj, name)')"
81-
strict mode: "TypeError: undefined is not an object (evaluating 'Object.getOwnPropertyDescriptor(obj, name)')"
82-
test/built-ins/Iterator/from/name.js:
83-
default: "TypeError: undefined is not an object (evaluating 'Object.getOwnPropertyDescriptor(obj, name)')"
84-
strict mode: "TypeError: undefined is not an object (evaluating 'Object.getOwnPropertyDescriptor(obj, name)')"
85-
test/built-ins/Iterator/from/primitives.js:
86-
default: "TypeError: Iterator.from is not a function. (In 'Iterator.from('string')', 'Iterator.from' is undefined)"
87-
strict mode: "TypeError: Iterator.from is not a function. (In 'Iterator.from('string')', 'Iterator.from' is undefined)"
88-
test/built-ins/Iterator/from/prop-desc.js:
89-
default: 'Test262Error: obj should have an own property from'
90-
strict mode: 'Test262Error: obj should have an own property from'
91-
test/built-ins/Iterator/from/proto.js:
92-
default: "TypeError: undefined is not an object (evaluating 'Object.getPrototypeOf(Iterator.from)')"
93-
strict mode: "TypeError: undefined is not an object (evaluating 'Object.getPrototypeOf(Iterator.from)')"
94-
test/built-ins/Iterator/from/result-proto.js:
95-
default: "TypeError: Iterator.from is not a function. (In 'Iterator.from(iter)', 'Iterator.from' is undefined)"
96-
strict mode: "TypeError: Iterator.from is not a function. (In 'Iterator.from(iter)', 'Iterator.from' is undefined)"
97-
test/built-ins/Iterator/from/supports-iterable.js:
98-
default: "TypeError: Iterator.from is not a function. (In 'Iterator.from([0, 1, 2, 3])', 'Iterator.from' is undefined)"
99-
strict mode: "TypeError: Iterator.from is not a function. (In 'Iterator.from([0, 1, 2, 3])', 'Iterator.from' is undefined)"
100-
test/built-ins/Iterator/from/supports-iterator.js:
101-
default: "TypeError: Iterator.from is not a function. (In 'Iterator.from(iter)', 'Iterator.from' is undefined)"
102-
strict mode: "TypeError: Iterator.from is not a function. (In 'Iterator.from(iter)', 'Iterator.from' is undefined)"
62+
default: "TypeError: iterator.toArray is not a function. (In 'iterator.toArray()', 'iterator.toArray' is undefined)"
63+
strict mode: "TypeError: iterator.toArray is not a function. (In 'iterator.toArray()', 'iterator.toArray' is undefined)"
10364
test/built-ins/Iterator/prototype/drop/argument-effect-order.js:
10465
default: "TypeError: undefined is not an object (evaluating 'Iterator.prototype.drop.call')"
10566
strict mode: "TypeError: undefined is not an object (evaluating 'Iterator.prototype.drop.call')"

LayoutTests/TestExpectations

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,7 +1109,6 @@ http/wpt/service-workers/basic-fetch-with-contentfilter.https.html [ Skip ]
11091109
# Reenable it when having a custom gc exposed in service workers.
11101110
[ Debug ] http/wpt/service-workers/fetchEvent.https.html [ Skip ]
11111111

1112-
webkit.org/b/248743 http/wpt/service-workers/fetch-service-worker-preload-download.https.html [ Pass Failure ]
11131112
webkit.org/b/248743 http/wpt/service-workers/file-upload.html [ Pass Failure ]
11141113

11151114
# Test file
@@ -5877,8 +5876,6 @@ imported/w3c/web-platform-tests/css/filter-effects/svg-mutation-single-to-multip
58775876
imported/w3c/web-platform-tests/css/filter-effects/svg-mutation-url-to-function.html [ ImageOnlyFailure ]
58785877
imported/w3c/web-platform-tests/css/filter-effects/svg-shorthand-drop-shadow-001.html [ ImageOnlyFailure ]
58795878
imported/w3c/web-platform-tests/css/filter-effects/svg-shorthand-hue-rotate-001.html [ ImageOnlyFailure ]
5880-
imported/w3c/web-platform-tests/css/filter-effects/svg-unknown-input-001.html [ ImageOnlyFailure ]
5881-
imported/w3c/web-platform-tests/css/filter-effects/svg-unknown-input-002.html [ ImageOnlyFailure ]
58825879
imported/w3c/web-platform-tests/css/filter-effects/tainting-feblend-002.html [ ImageOnlyFailure ]
58835880
imported/w3c/web-platform-tests/css/filter-effects/tainting-fecomponenttransfer-002.html [ ImageOnlyFailure ]
58845881
imported/w3c/web-platform-tests/css/filter-effects/tainting-fecomposite-002.html [ ImageOnlyFailure ]
@@ -5970,12 +5967,6 @@ imported/w3c/web-platform-tests/workers/shared-worker-name-via-options.html [ Du
59705967

59715968
webkit.org/b/242498 svg/resource-invalidation/mask-resource-invalidation.html [ ImageOnlyFailure ]
59725969

5973-
# YouTube plugin replacement
5974-
security/contentSecurityPolicy/object-src-none-blocks-youtube-plugin-replacement.html [ Skip ]
5975-
security/contentSecurityPolicy/plugins-types-allows-youtube-plugin-replacement.html [ Skip ]
5976-
security/contentSecurityPolicy/plugins-types-blocks-youtube-plugin-replacement-without-mime-type.html [ Skip ]
5977-
security/contentSecurityPolicy/plugins-types-blocks-youtube-plugin-replacement.html [ Skip ]
5978-
59795970
webkit.org/b/242983 imported/w3c/web-platform-tests/css/css-scroll-anchoring/fullscreen-crash.html [ Skip ]
59805971
webkit.org/b/261849 imported/w3c/web-platform-tests/css/css-scroll-anchoring/heuristic-with-offset-update-from-scroll-event-listener.html [ Skip ]
59815972
webkit.org/b/261849 imported/w3c/web-platform-tests/css/css-scroll-anchoring/zero-scroll-offset.html [ Skip ]
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<style>
2+
.container {
3+
font-size: 12px;
4+
}
5+
</style>
6+
<pre><b>line-clamp</b> is the shorthand of <i><b>max-lines</b> (where to clamp)</i>, <i><b>block-ellipsis</b> (what to put at break)</i> and <i><b>continue</b> (whether we should stop rendering after break)</i>
7+
</pre>
8+
<div class="container">1<br>2&#x2026;</div>
9+
<pre><b>line-clamp: 2;</b> -clamp at the second line with ellipsis and don't show content after</pre>
10+
<div class="container">1<br>2<br>3<br>4!</div>
11+
<pre><b>line-clamp: 4 '!';</b> -clamp at the forth line with ! and don't show content after</pre>
12+
<div class="container">1<br>2&#x2026;<br>3<br>4&#x2026;</div>
13+
<pre><b>line-clamp: 4 and max-lines: 1 on 'nested'</b>-notice the double clamping</pre>
14+
<pre>
15+
16+
longhands
17+
</pre>
18+
<div class="container">1<br>2<br>3<br>4<br>5?</div>
19+
<pre>
20+
<b>max-lines: 5
21+
block-ellipsis: '?'
22+
continue: discard</b>
23+
</pre>
24+
<div class="container">1<br>2?<br>3<br>4<br>5<br>6</div>
25+
<pre><b>max-lines: 2
26+
block-ellipsis: '?'
27+
continue: auto</b>
28+
</pre>

0 commit comments

Comments
 (0)