Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Side by Side Diff: third_party/WebKit/LayoutTests/fast/dom/HTMLImageElement/relevant-mutations.html

Issue 1511523002: Align HTMLImageElement relevant mutations to spec (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix removal issue when a text node is between <source> and <img> Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!doctype html>
2 <!-- TODO(yoav): this test is imported from web-platform-tests, but is here due to crbug.com/498120 -->
3 <title>img relevant mutations</title>
4 <script src="../../../resources/testharness.js"></script>
5 <script src="../../../resources/testharnessreport.js"></script>
6 <div id=log></div>
7
8 <!-- should invoke update the image data -->
9
10 <img data-desc="src set">
11 <img src="images/green-2x2.png" data-desc="src changed">
12 <img src="images/green-2x2.png" data-desc="src removed">
13
14 <img data-desc="srcset set">
15 <img srcset="images/green-2x2.png" data-desc="srcset changed">
16 <img srcset="images/green-2x2.png" data-desc="srcset removed">
17
18 <img data-desc="sizes set">
19 <img sizes="" data-desc="sizes changed">
20 <img sizes="" data-desc="sizes removed">
21
22 <img src="images/green-2x2.png" data-desc="src set to same value">
23
24 <img data-desc="crossorigin absent to empty">
25 <img data-desc="crossorigin absent to anonymous">
26 <img data-desc="crossorigin absent to use-credentials">
27 <img crossorigin data-desc="crossorigin empty to absent">
28 <img crossorigin data-desc="crossorigin empty to use-credentials">
29 <img crossorigin=anonymous data-desc="crossorigin anonymous to absent">
30 <img crossorigin=anonymous data-desc="crossorigin anonymous to use-credentials">
31 <img crossorigin=use-credentials data-desc="crossorigin use-credentials to absen t">
32 <img crossorigin=use-credentials data-desc="crossorigin use-credentials to empty ">
33 <img crossorigin=use-credentials data-desc="crossorigin use-credentials to anony mous">
34
35 <img src="images/green-2x2.png" data-desc="inserted into picture"><picture></pic ture>
36
37 <picture><img src="images/green-2x2.png" data-desc="removed from picture"></pict ure>
38
39 <picture><img src="images/green-2x2.png" data-desc="parent is picture, previous source inserted"></picture>
40
41 <picture><source><img src="images/green-2x2.png" data-desc="parent is picture, p revious source removed"></picture>
42
43 <picture><source><img src="images/green-2x2.png" data-desc="parent is picture, p revious source has srcset set"></picture>
44 <picture><source srcset=""><img src="images/green-2x2.png" data-desc="parent is picture, previous source has srcset changed"></picture>
45 <picture><source srcset=""><img src="images/green-2x2.png" data-desc="parent is picture, previous source has srcset removed"></picture>
46
47 <picture><source><img src="images/green-2x2.png" data-desc="parent is picture, p revious source has sizes set"></picture>
48 <picture><source sizes=""><img src="images/green-2x2.png" data-desc="parent is p icture, previous source has sizes changed"></picture>
49 <picture><source sizes=""><img src="images/green-2x2.png" data-desc="parent is p icture, previous source has sizes removed"></picture>
50
51 <picture><source><img src="images/green-2x2.png" data-desc="parent is picture, p revious source has media set"></picture>
52 <picture><source media=""><img src="images/green-2x2.png" data-desc="parent is p icture, previous source has media changed"></picture>
53 <picture><source media=""><img src="images/green-2x2.png" data-desc="parent is p icture, previous source has media removed"></picture>
54
55 <picture><source><img src="images/green-2x2.png" data-desc="parent is picture, p revious source has type set"></picture>
56 <picture><source type=""><img src="images/green-2x2.png" data-desc="parent is pi cture, previous source has type changed"></picture>
57 <picture><source type=""><img src="images/green-2x2.png" data-desc="parent is pi cture, previous source has type removed"></picture>
58
59 <!-- should not invoke update the image data -->
60
61 <img srcset="images/green-2x2.png" data-desc="srcset is set to same value">
62 <img srcset="images/green-2x2.png" sizes data-desc="sizes is set to same value">
63
64 <img src="images/green-2x2.png" data-desc="crossorigin state not changed: absent , removeAttribute">
65 <img src="images/green-2x2.png" crossorigin data-desc="crossorigin state not cha nged: empty to anonymous">
66 <img src="images/green-2x2.png" crossorigin=anonymous data-desc="crossorigin sta te not changed: anonymous to foobar">
67 <img src="images/green-2x2.png" crossorigin=use-credentials data-desc="crossorig in state not changed: use-credentials to USE-CREDENTIALS">
68
69 <img src="images/green-2x2.png" data-desc="inserted into picture ancestor"><pict ure><span></span></picture>
70 <picture><span><img src="images/green-2x2.png" data-desc="removed from picture a ncestor"></span></picture>
71
72 <picture><span><img src="images/green-2x2.png" data-desc="ancestor picture has a source inserted"></span></picture>
73 <picture><source><span><img src="images/green-2x2.png" data-desc="ancestor pictu re has a source removed"></span></picture>
74
75 <picture><span><img src="images/green-2x2.png" data-desc="ancestor picture; prev ious sibling source inserted"></span></picture>
76 <picture><span><source><img src="images/green-2x2.png" data-desc="ancestor pictu re; previous sibling source removed"></span></picture>
77
78 <picture><img src="images/green-2x2.png" data-desc="parent is picture, following sibling source inserted"></picture>
79 <picture><img src="images/green-2x2.png" data-desc="parent is picture, following sibling source removed"><source></picture>
80
81 <picture><img src="images/green-2x2.png" data-desc="parent is picture, following sibling source has srcset set"><source></picture>
82
83 <img src="images/green-2x2.png" data-desc="media on img set">
84 <img src="images/green-2x2.png" data-desc="type on img set">
85 <img src="images/green-2x2.png" data-desc="class on img set">
86 <img src="images/green-2x2.png" data-desc="alt on img set">
87
88 <picture><source><img src="images/green-2x2.png" data-desc="src on previous sibl ing source set"></picture>
89 <picture><source><img src="images/green-2x2.png" data-desc="class on previous si bling source set"></picture>
90
91 <img src="images/green-2x2.png" data-desc="inserted/removed children of img">
92
93 <picture><img src="images/green-2x2.png" data-desc="picture is inserted"></pictu re><span></span>
94 <picture><img src="images/green-2x2.png" data-desc="picture is removed"></pictur e>
95
96 <picture><img src="images/green-2x2.png" data-desc="parent is picture, following img inserted"></picture>
97 <picture><img src="images/green-2x2.png" data-desc="parent is picture, following img removed"><img></picture>
98 <picture><img src="images/green-2x2.png" data-desc="parent is picture, following img has src set"><img></picture>
99 <picture><img src="images/green-2x2.png" data-desc="parent is picture, following img has srcset set"><img></picture>
100 <picture><img src="images/green-2x2.png" data-desc="parent is picture, following img has sizes set"><img></picture>
101
102
103 <script>
104 setup({explicit_done:true});
105
106 function t(desc, func, expect) {
107 async_test(function() {
108 var img = document.querySelector('[data-desc="' + desc + '"]');
109 img.onload = img.onerror = this.unreached_func('update the image data was ru n');
110 if (expect == 'timeout') {
111 setTimeout(this.step_func_done(), 1000);
112 } else {
113 img['on' + expect] = this.step_func_done(function() {});
114 }
115 func.call(this, img);
116 }, desc);
117 }
118
119 onload = function() {
120
121 t('src set', function(img) {
122 img.src = 'images/green-2x2.png';
123 }, 'load');
124
125 t('src changed', function(img) {
126 img.src = 'images/green-2x2.png ';
127 }, 'load');
128
129 t('src removed', function(img) {
130 img.removeAttribute('src');
131 }, 'timeout');
132
133 t('srcset set', function(img) {
134 img.srcset = 'images/green-2x2.png';
135 }, 'load');
136
137 t('srcset changed', function(img) {
138 img.srcset = 'images/green-2x2.png ';
139 }, 'load');
140
141 t('srcset removed', function(img) {
142 img.removeAttribute('srcset');
143 }, 'timeout');
144
145 t('sizes set', function(img) {
146 img.sizes = '';
147 }, 'timeout');
148
149 t('sizes changed', function(img) {
150 img.sizes = ' ';
151 }, 'timeout');
152
153 t('sizes removed', function(img) {
154 img.removeAttribute('sizes');
155 }, 'timeout');
156
157 t('src set to same value', function(img) {
158 img.src = 'images/green-2x2.png';
159 }, 'load');
160
161 t('crossorigin absent to empty', function(img) {
162 img.crossOrigin = '';
163 }, 'timeout');
164
165 t('crossorigin absent to anonymous', function(img) {
166 img.crossOrigin = 'anonymous';
167 }, 'timeout');
168
169 t('crossorigin absent to use-credentials', function(img) {
170 img.crossOrigin = 'use-credentials';
171 }, 'timeout');
172
173 t('crossorigin empty to absent', function(img) {
174 img.removeAttribute('crossorigin');
175 }, 'timeout');
176
177 t('crossorigin empty to use-credentials', function(img) {
178 img.crossOrigin = 'use-credentials';
179 }, 'timeout');
180
181 t('crossorigin anonymous to absent', function(img) {
182 img.removeAttribute('crossorigin');
183 }, 'timeout');
184
185 t('crossorigin anonymous to use-credentials', function(img) {
186 img.crossOrigin = 'use-credentials';
187 }, 'timeout');
188
189 t('crossorigin use-credentials to absent', function(img) {
190 img.removeAttribute('crossorigin');
191 }, 'timeout');
192
193 t('crossorigin use-credentials to empty', function(img) {
194 img.crossOrigin = '';
195 }, 'timeout');
196
197 t('crossorigin use-credentials to anonymous', function(img) {
198 img.crossOrigin = 'anonymous';
199 }, 'timeout');
200
201 t('inserted into picture', function(img) {
202 img.nextSibling.appendChild(img);
203 }, 'load');
204
205 t('removed from picture', function(img) {
206 img.parentNode.removeChild(img);
207 }, 'load');
208
209 t('parent is picture, previous source inserted', function(img) {
210 img.parentNode.insertBefore(document.createElement('source'), img);
211 }, 'load');
212
213 t('parent is picture, previous source removed', function(img) {
214 img.parentNode.removeChild(img.previousSibling);
215 }, 'load');
216
217 t('parent is picture, previous source has srcset set', function(img) {
218 img.previousSibling.srcset = '';
219 }, 'load');
220
221 t('parent is picture, previous source has srcset changed', function(img) {
222 img.previousSibling.srcset = ' ';
223 }, 'load');
224
225 t('parent is picture, previous source has srcset removed', function(img) {
226 img.previousSibling.removeAttribute('srcset');
227 }, 'load');
228
229 t('parent is picture, previous source has sizes set', function(img) {
230 img.previousSibling.sizes = '';
231 }, 'load');
232
233 t('parent is picture, previous source has sizes changed', function(img) {
234 img.previousSibling.sizes = ' ';
235 }, 'load');
236
237 t('parent is picture, previous source has sizes removed', function(img) {
238 img.previousSibling.removeAttribute('sizes');
239 }, 'load');
240
241 t('parent is picture, previous source has media set', function(img) {
242 img.previousSibling.media = '';
243 }, 'load');
244
245 t('parent is picture, previous source has media changed', function(img) {
246 img.previousSibling.media = ' ';
247 }, 'load');
248
249 t('parent is picture, previous source has media removed', function(img) {
250 img.previousSibling.removeAttribute('media');
251 }, 'load');
252
253 t('parent is picture, previous source has type set', function(img) {
254 img.previousSibling.type = '';
255 }, 'load');
256
257 t('parent is picture, previous source has type changed', function(img) {
258 img.previousSibling.type = ' ';
259 }, 'load');
260
261 t('parent is picture, previous source has type removed', function(img) {
262 img.previousSibling.removeAttribute('type');
263 }, 'load');
264
265 t('srcset is set to same value', function(img) {
266 img.srcset = "images/green-2x2.png";
267 }, 'timeout');
268
269 t('sizes is set to same value', function(img) {
270 img.sizes = '';
271 }, 'timeout');
272
273 t('crossorigin state not changed: absent, removeAttribute', function(img) {
274 img.removeAttribute('crossorigin');
275 }, 'timeout');
276
277 t('crossorigin state not changed: empty to anonymous', function(img) {
278 img.crossOrigin = 'anonymous';
279 }, 'timeout');
280
281 t('crossorigin state not changed: anonymous to foobar', function(img) {
282 img.crossOrigin = 'foobar';
283 }, 'timeout');
284
285 t('crossorigin state not changed: use-credentials to USE-CREDENTIALS', functio n(img) {
286 img.crossOrigin = 'USE-CREDENTIALS';
287 }, 'timeout');
288
289 t('inserted into picture ancestor', function(img) {
290 img.nextSibling.firstChild.appendChild(img);
291 }, 'timeout');
292
293 t('removed from picture ancestor', function(img) {
294 img.parentNode.removeChild(img);
295 }, 'timeout');
296
297 t('ancestor picture has a source inserted', function(img) {
298 img.parentNode.parentNode.insertBefore(document.createElement('source'), img .parentNode);
299 }, 'timeout');
300
301 t('ancestor picture has a source removed', function(img) {
302 img.parentNode.parentNode.removeChild(img.parentNode.previousSibling);
303 }, 'timeout');
304
305 t('ancestor picture; previous sibling source inserted', function(img) {
306 img.parentNode.insertBefore(document.createElement('source'), img);
307 }, 'timeout');
308
309 t('ancestor picture; previous sibling source removed', function(img) {
310 img.parentNode.removeChild(img.previousSibling);
311 }, 'timeout');
312
313 t('parent is picture, following sibling source inserted', function(img) {
314 img.parentNode.appendChild(document.createElement('source'));
315 }, 'timeout');
316
317 t('parent is picture, following sibling source removed', function(img) {
318 img.parentNode.removeChild(img.nextSibling);
319 }, 'timeout');
320
321 t('parent is picture, following sibling source has srcset set', function(img) {
322 img.nextSibling.srcset = '';
323 }, 'timeout');
324
325 t('media on img set', function(img) {
326 img.setAttribute('media', '');
327 }, 'timeout');
328
329 t('type on img set', function(img) {
330 img.setAttribute('type', '');
331 }, 'timeout');
332
333 t('class on img set', function(img) {
334 img.className = '';
335 }, 'timeout');
336
337 t('alt on img set', function(img) {
338 img.alt = '';
339 }, 'timeout');
340
341 t('src on previous sibling source set', function(img) {
342 img.previousSibling.setAttribute('src', '');
343 }, 'timeout');
344
345 t('class on previous sibling source set', function(img) {
346 img.previousSibling.className = '';
347 }, 'timeout');
348
349 t('inserted/removed children of img', function(img) {
350 img.appendChild(document.createElement('source'));
351 setTimeout(this.step_func(function() {
352 img.removeChild(img.firstChild);
353 }), 0);
354 }, 'timeout');
355
356 t('picture is inserted', function(img) {
357 img.parentNode.nextSibling.appendChild(img.parentNode);
358 }, 'timeout');
359
360 t('picture is removed', function(img) {
361 img.parentNode.parentNode.removeChild(img.parentNode);
362 }, 'timeout');
363
364 t('parent is picture, following img inserted', function(img) {
365 img.parentNode.appendChild(document.createElement('img'));
366 }, 'timeout');
367
368 t('parent is picture, following img removed', function(img) {
369 img.parentNode.removeChild(img.nextSibling);
370 }, 'timeout');
371
372 t('parent is picture, following img has src set', function(img) {
373 img.nextSibling.src = '';
374 }, 'timeout');
375
376 t('parent is picture, following img has srcset set', function(img) {
377 img.nextSibling.srcset = '';
378 }, 'timeout');
379
380 t('parent is picture, following img has sizes set', function(img) {
381 img.nextSibling.sizes = '';
382 }, 'timeout');
383
384 done();
385 };
386 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698