@@ -210,6 +210,90 @@ public void forEach() throws Exception {
210210 loadPageVerifyTitle2 (html );
211211 }
212212
213+ /**
214+ * @throws Exception if the test fails
215+ */
216+ @ Test
217+ @ Alerts ({"4" , "a" , "b" , "c" , "d" , "4" })
218+ public void forEachAdd () throws Exception {
219+ final String html = DOCTYPE_HTML
220+ + "<html><head><script>\n "
221+ + LOG_TITLE_FUNCTION
222+ + "function test() {\n "
223+ + " var list = document.getElementById('d1').classList;\n "
224+ + " log(list.length);\n "
225+
226+ + " list.forEach((i) => {\n "
227+ + " log(i);\n "
228+ + " if (list.lenght < 7) { list.add('new ' + i); }\n "
229+ + " });\n "
230+
231+ + " log(list.length);\n "
232+ + "}\n "
233+ + "</script></head><body onload='test()'>\n "
234+ + " <div id='d1' class='a b c d'></div>\n "
235+ + "</body></html>" ;
236+
237+ loadPageVerifyTitle2 (html );
238+ }
239+
240+ /**
241+ * @throws Exception if the test fails
242+ */
243+ @ Test
244+ @ Alerts ({"4" , "a" , "c" , "d" , "3" })
245+ public void forEachRemove () throws Exception {
246+ final String html = DOCTYPE_HTML
247+ + "<html><head><script>\n "
248+ + LOG_TITLE_FUNCTION
249+ + "function test() {\n "
250+ + " var list = document.getElementById('d1').classList;\n "
251+ + " log(list.length);\n "
252+
253+ + " list.forEach((i) => {\n "
254+ + " log(i);\n "
255+ + " list.remove('a');\n "
256+ + " });\n "
257+
258+ + " log(list.length);\n "
259+ + "}\n "
260+ + "</script></head><body onload='test()'>\n "
261+ + " <div id='d1' class='a b c d'></div>\n "
262+ + "</body></html>" ;
263+
264+ loadPageVerifyTitle2 (html );
265+ }
266+
267+
268+ /**
269+ * @throws Exception if the test fails
270+ */
271+ @ Test
272+ @ Alerts ({"4" , "a" , "1" })
273+ public void forEachRemove2 () throws Exception {
274+ final String html = DOCTYPE_HTML
275+ + "<html><head><script>\n "
276+ + LOG_TITLE_FUNCTION
277+ + "function test() {\n "
278+ + " var list = document.getElementById('d1').classList;\n "
279+ + " log(list.length);\n "
280+
281+ + " list.forEach((i) => {\n "
282+ + " log(i);\n "
283+ + " list.remove('a');\n "
284+ + " list.remove('c');\n "
285+ + " list.remove('d');\n "
286+ + " });\n "
287+
288+ + " log(list.length);\n "
289+ + "}\n "
290+ + "</script></head><body onload='test()'>\n "
291+ + " <div id='d1' class='a b c d'></div>\n "
292+ + "</body></html>" ;
293+
294+ loadPageVerifyTitle2 (html );
295+ }
296+
213297 /**
214298 * @throws Exception if the test fails
215299 */
0 commit comments