Update web-platform-tests to revision 8a2ceb5f18911302b7a5c1cd2791f4ab50ad4326

This commit is contained in:
Josh Matthews 2017-10-12 09:25:50 -04:00
parent 462c272380
commit 1f531f66ea
5377 changed files with 174916 additions and 84369 deletions

View file

@ -0,0 +1,91 @@
<!doctype html>
<meta charset=utf-8>
<title>Adopting an image updates the image data</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<!-- tests -->
<div id="adoptTest1"></div>
<picture id="adoptTest2">
<source srcset="/images/green-2x2.png">
</picture>
<script>
function resolve(url) {
if (url === "") {
return url;
}
var a = document.createElement('a');
a.href = url;
return a.href;
}
function t(desc, data, expect) {
async_test(function(t) {
var d = (new DOMParser()).parseFromString(data, 'text/html');
var i = d.querySelector('img');
i.onerror = this.unreached_func('got unexpected error event');
i.onload = this.step_func_done(function() {
assert_equals(i.currentSrc, resolve(expect));
});
var n = d.querySelector('[adopt-node]');
document.adoptNode(n);
}, desc);
}
onload = function() {
t('img (src only)',
'<img src="/images/green-1x1.png" adopt-node>',
'/images/green-1x1.png');
t('img (src only), parent is picture',
'<picture adopt-node><img src="/images/green-1x1.png"></picture>',
'/images/green-1x1.png');
t('img (src only), previous sibling is source',
'<picture adopt-node><source srcset="/images/green-1x1.png"><img src="/images/green-2x2.png"></picture>',
'/images/green-1x1.png');
t('img (srcset 1 cand)',
'<img srcset="/images/green-1x1.png" adopt-node>',
'/images/green-1x1.png');
t('img (srcset 1 cand), parent is picture',
'<picture adopt-node><img srcset="/images/green-1x1.png"></picture>',
'/images/green-1x1.png');
t('img (srcset 1 cand), previous sibling is source',
'<picture adopt-node><source srcset="/images/green-1x1.png"><img srcset="/images/green-2x2.png"></picture>',
'/images/green-1x1.png');
async_test(function(t) {
var d = (new DOMParser()).parseFromString('<template><img src="/images/green-1x1.png"></template>', 'text/html');
var i = d.querySelector('template').content.querySelector('img').cloneNode(1);
i.onerror = this.unreached_func('got unexpected error event');
i.onload = this.step_func_done(function() {
assert_equals(i.currentSrc, resolve('/images/green-1x1.png'));
});
document.getElementById('adoptTest1').appendChild(i);
}, 'adopt a cloned img in template');
async_test(function(t) {
var preload = new Image();
preload.src = '/images/green-1x1.png?' + Math.random();
preload.onload = t.step_func(function() {
var d = (new DOMParser()).parseFromString('<img src="' + preload.src + '">', 'text/html');
var i = d.querySelector('img');
i.onerror = this.unreached_func('got unexpected error event');
i.onload = this.step_func_done(function() {
assert_equals(i.currentSrc, resolve("/images/green-2x2.png"));
});
var p = document.getElementById('adoptTest2');
p.appendChild(i);
});
}, 'adoption is from appendChild');
};
</script>

View file

@ -0,0 +1,54 @@
<!DOCTYPE html>
<meta charset=utf-8>
<meta name="timeout" content="long">
<title>HTMLImageElement.prototype.decode(), iframe tests.</title>
<link rel="author" title="Vladimir Levin" href="mailto:vmpstr@chromium.org">
<link rel=help href="https://html.spec.whatwg.org/multipage/embedded-content.html#dom-img-decode">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<iframe id="frame_loaded" srcdoc="iframe"></iframe>
<iframe id="frame_notloaded" srcdoc="iframe"></iframe>
<iframe id="frame_notloaded2" srcdoc="iframe"></iframe>
<script>
"use strict";
promise_test(function() {
return new Promise(function(resolve, reject) {
var frame = document.getElementById("frame_loaded");
var img = frame.contentDocument.createElement("img");
img.src = "/images/green.png";
img.onload = function() {
// At this point the frame which created the img is removed, so decode() should fail.
frame.parentNode.removeChild(frame);
img.decode().then(function() {
assert_false(true, "Unexpected success");
}, function() {
resolve();
});
};
});
}, document.title + " Decode from removed iframe fails (loaded img)");
promise_test(function(t) {
var frame = document.getElementById("frame_notloaded");
var img = frame.contentDocument.createElement("img");
img.src = "/images/green.png";
frame.parentNode.removeChild(frame);
var promise = img.decode();
return promise_rejects(t, "EncodingError", promise);
}, document.title + " Decode from removed iframe fails (img not loaded)");
promise_test(function(t) {
var frame = document.getElementById("frame_notloaded2");
var img = frame.contentDocument.createElement("img");
img.src = "/images/green.png";
// First request a promise, then remove the iframe.
var promise = img.decode();
frame.parentNode.removeChild(frame);
return promise_rejects(t, "EncodingError", promise);
}, document.title + " Decode from iframe, later removed, fails (img not loaded)");
</script>

View file

@ -0,0 +1,82 @@
<!DOCTYPE html>
<meta charset=utf-8>
<meta name="timeout" content="long">
<title>SVGImageElement.prototype.decode(), href mutation tests.</title>
<link rel="author" title="Vladimir Levin" href="mailto:vmpstr@chromium.org">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
"use strict";
// src tests
// -------------------
promise_test(function(t) {
var img = document.createElementNS('http://www.w3.org/2000/svg', 'image');
img.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', "/images/green.png");
var promise = img.decode();
img.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', "/images/green.svg");
return promise_rejects(t, "EncodingError", promise);
}, document.title + " xlink:href changes fail decode.");
promise_test(function(t) {
var img = document.createElementNS('http://www.w3.org/2000/svg', 'image');
img.setAttribute('href', "/images/green.png");
var promise = img.decode();
img.setAttribute('href', "/images/green.svg");
return promise_rejects(t, "EncodingError", promise);
}, document.title + " href changes fail decode.");
promise_test(function(t) {
var img = document.createElementNS('http://www.w3.org/2000/svg', 'image');
img.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', "/images/green.png");
var first_promise = img.decode();
img.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', "/images/green.svg");
var second_promise = img.decode();
assert_not_equals(first_promise, second_promise);
return Promise.all([
promise_rejects(t, "EncodingError", first_promise),
second_promise
]);
}, document.title + " xlink:href changes fail decode; following good decode succeeds.");
promise_test(function(t) {
var img = document.createElementNS('http://www.w3.org/2000/svg', 'image');
img.setAttribute('href', "/images/green.png");
var first_promise = img.decode();
img.setAttribute('href', "/images/green.svg");
var second_promise = img.decode();
assert_not_equals(first_promise, second_promise);
return Promise.all([
promise_rejects(t, "EncodingError", first_promise),
second_promise
]);
}, document.title + " href changes fail decode; following good decode succeeds.");
promise_test(function(t) {
var img = document.createElementNS('http://www.w3.org/2000/svg', 'image');
img.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', "/images/green.png");
var first_promise = img.decode();
img.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', "/non/existent/path.png");
var second_promise = img.decode();
assert_not_equals(first_promise, second_promise);
return Promise.all([
promise_rejects(t, "EncodingError", first_promise),
promise_rejects(t, "EncodingError", second_promise)
]);
}, document.title + " xlink:href changes fail decode; following bad decode fails.");
promise_test(function(t) {
var img = document.createElementNS('http://www.w3.org/2000/svg', 'image');
img.setAttribute('href', "/images/green.png");
var first_promise = img.decode();
img.setAttribute('href', "/non/existent/path.png");
var second_promise = img.decode();
assert_not_equals(first_promise, second_promise);
return Promise.all([
promise_rejects(t, "EncodingError", first_promise),
promise_rejects(t, "EncodingError", second_promise)
]);
}, document.title + " href changes fail decode; following bad decode fails.");
</script>

View file

@ -0,0 +1,121 @@
<!DOCTYPE html>
<meta charset=utf-8>
<meta name="timeout" content="long">
<title>HTMLImageElement.prototype.decode(), src/srcset mutation tests.</title>
<link rel="author" title="Vladimir Levin" href="mailto:vmpstr@chromium.org">
<link rel=help href="https://html.spec.whatwg.org/multipage/embedded-content.html#dom-img-decode">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
"use strict";
// src tests
// -------------------
promise_test(function(t) {
var img = new Image();
img.src = "/images/green.png";
var promise = img.decode();
img.src = "/images/green.svg";
return promise_rejects(t, "EncodingError", promise);
}, document.title + " src changes fail decode.");
promise_test(function(t) {
var img = new Image();
img.src = "/images/green.png";
var first_promise = img.decode();
img.src = "/images/blue.png";
var second_promise = img.decode();
assert_not_equals(first_promise, second_promise);
return Promise.all([
promise_rejects(t, "EncodingError", first_promise),
second_promise
]);
}, document.title + " src changes fail decode; following good png decode succeeds.");
promise_test(function(t) {
var img = new Image();
img.src = "/images/green.png";
var first_promise = img.decode();
img.src = "/images/green.svg";
var second_promise = img.decode();
assert_not_equals(first_promise, second_promise);
return Promise.all([
promise_rejects(t, "EncodingError", first_promise),
second_promise
]);
}, document.title + " src changes fail decode; following good svg decode succeeds.");
promise_test(function(t) {
var img = new Image();
img.src = "/images/green.png";
var first_promise = img.decode();
img.src = "/non/existent/path.png";
var second_promise = img.decode();
assert_not_equals(first_promise, second_promise);
return Promise.all([
promise_rejects(t, "EncodingError", first_promise),
promise_rejects(t, "EncodingError", second_promise)
]);
}, document.title + " src changes fail decode; following bad decode fails.");
promise_test(function(t) {
return new Promise(function(resolve, reject) {
var img = new Image();
// We wait for an onload, since the "Updating the image data" spec states
// that if a new microtask is scheduled, the old one is canceled so
// without the onload, the first decode request would be requested when the
// img.src is empty. With an onload, we ensure that the img.src is set and
// the image exists before issuing the first decode, then we verify that the
// src change to the same value does not prevent that request from
// succeeding.
img.onload = t.step_func(function() {
img.onload = null;
var first_promise = img.decode();
img.src = "/images/green.png";
var second_promise = img.decode();
assert_not_equals(first_promise, second_promise);
resolve(Promise.all([first_promise, second_promise]));
});
img.src = "/images/green.png";
});
}, document.title + " src changes to the same path succeed.");
// srcset tests
// -------------------
promise_test(function(t) {
var img = new Image();
img.srcset = "/images/green.png 100w";
var promise = img.decode();
img.srcset = "/images/green.svg 100w";
return promise_rejects(t, "EncodingError", promise);
}, document.title + " srcset changes fail decode.");
promise_test(function(t) {
var img = new Image();
img.srcset = "/images/green.png 100w";
var first_promise = img.decode();
img.srcset = "/images/green.svg 100w";
var second_promise = img.decode();
assert_not_equals(first_promise, second_promise);
return Promise.all([
promise_rejects(t, "EncodingError", first_promise),
second_promise
]);
}, document.title + " srcset changes fail decode; following good decode succeeds.");
promise_test(function(t) {
var img = new Image();
img.srcset = "/images/green.png 100w";
var first_promise = img.decode();
img.srcset = "/non/existent/path.png 100w";
var second_promise = img.decode();
assert_not_equals(first_promise, second_promise);
return Promise.all([
promise_rejects(t, "EncodingError", first_promise),
promise_rejects(t, "EncodingError", second_promise)
]);
}, document.title + " srcset changes fail decode; following bad decode fails.");
</script>

View file

@ -0,0 +1,133 @@
<!DOCTYPE html>
<meta charset=utf-8>
<meta name="timeout" content="long">
<title>HTMLImageElement.prototype.decode(), picture tests.</title>
<link rel="author" title="Vladimir Levin" href="mailto:vmpstr@chromium.org">
<link rel=help href="https://html.spec.whatwg.org/multipage/embedded-content.html#dom-img-decode">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<picture>
<source srcset="/images/green.png">
<source srcset="/images/blue.png">
<img id="testimg">
</picture>
<script>
"use strict";
promise_test(function() {
var picture = document.createElement("picture");
var source = document.createElement("source");
var img = document.createElement("img");
picture.appendChild(source);
picture.appendChild(img);
source.srcset = "/images/green.png";
return img.decode().then(function(arg) {
assert_equals(arg, undefined);
});
}, document.title + " Image with PNG source decodes with undefined.");
promise_test(function() {
var img = document.getElementById("testimg");
return img.decode().then(function(arg) {
assert_equals(arg, undefined);
});
}, document.title + " Image with multiple sources decodes with undefined.");
promise_test(function() {
var picture = document.createElement("picture");
var source = document.createElement("source");
var img = document.createElement("img");
picture.appendChild(source);
picture.appendChild(img);
source.srcset = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAIA" +
"AAD91JpzAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4QUSEioKsy" +
"AgywAAABl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggR0lNUFeBDhcAAAAW" +
"SURBVAjXY9y3bx8DAwPL58+fGRgYACktBRltLfebAAAAAElFTkSuQmCC";
return img.decode().then(function(arg) {
assert_equals(arg, undefined);
});
}, document.title + " Image with PNG data URL source decodes with undefined.");
promise_test(function() {
var picture = document.createElement("picture");
var source = document.createElement("source");
var img = document.createElement("img");
picture.appendChild(source);
picture.appendChild(img);
source.srcset = "/images/green.svg";
return img.decode().then(function(arg) {
assert_equals(arg, undefined);
});
}, document.title + " Image with SVG source decodes with undefined.");
promise_test(function(t) {
var picture = document.createElement("picture");
var source = document.createElement("source");
var img = document.createElement("img");
picture.appendChild(source);
picture.appendChild(img);
source.srcset = "/non/existent/path.png";
var promise = img.decode();
return promise_rejects(t, "EncodingError", promise);
}, document.title + " Non-existent source fails decode.");
promise_test(function(t) {
var picture = document.createElement("picture");
var source = document.createElement("source");
var img = document.createElement("img");
picture.appendChild(source);
picture.appendChild(img);
source.srcset = "data:image/png;base64,iVBO00PDR0BADBEEF00KGg";
var promise = img.decode();
return promise_rejects(t, "EncodingError", promise);
}, document.title + " Corrupt image in src fails decode.");
promise_test(function(t) {
var picture = document.createElement("picture");
var source = document.createElement("source");
var img = document.createElement("img");
picture.appendChild(source);
picture.appendChild(img);
var promise = img.decode();
return promise_rejects(t, "EncodingError", promise);
}, document.title + " Image without srcset fails decode.");
promise_test(function() {
var picture = document.createElement("picture");
var source = document.createElement("source");
var img = document.createElement("img");
picture.appendChild(source);
picture.appendChild(img);
source.srcset = "/images/green.png";
var first_promise = img.decode();
var second_promise = img.decode();
assert_not_equals(first_promise, second_promise);
return Promise.all([
first_promise,
second_promise
]);
}, document.title + " Multiple decodes for images with src succeed.");
</script>

View file

@ -0,0 +1,128 @@
<!DOCTYPE html>
<meta charset=utf-8>
<meta name="timeout" content="long">
<title>SVGImageElement.prototype.decode(), basic tests.</title>
<link rel="author" title="Vladimir Levin" href="mailto:vmpstr@chromium.org">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
"use strict";
// src tests
// -------------------
promise_test(function() {
var img = document.createElementNS('http://www.w3.org/2000/svg', 'image');
img.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', "/images/green.png");
return img.decode().then(function(arg) {
assert_equals(arg, undefined);
});
}, document.title + " Image with PNG xlink:href decodes with undefined.");
promise_test(function() {
var img = document.createElementNS('http://www.w3.org/2000/svg', 'image');
img.setAttribute('href', "/images/green.png");
return img.decode().then(function(arg) {
assert_equals(arg, undefined);
});
}, document.title + " Image with PNG href decodes with undefined.");
promise_test(function() {
var img = document.createElementNS('http://www.w3.org/2000/svg', 'image');
img.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href',
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAIAAA" +
"D91JpzAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4QUSEioKsyAgyw" +
"AAABl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggR0lNUFeBDhcAAAAWSURBVA" +
"jXY9y3bx8DAwPL58+fGRgYACktBRltLfebAAAAAElFTkSuQmCC");
return img.decode().then(function(arg) {
assert_equals(arg, undefined);
});
}, document.title + " Image with PNG data URL xlink:href decodes with undefined.");
promise_test(function() {
var img = document.createElementNS('http://www.w3.org/2000/svg', 'image');
img.setAttribute('href',
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAIAAA" +
"D91JpzAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4QUSEioKsyAgyw" +
"AAABl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggR0lNUFeBDhcAAAAWSURBVA" +
"jXY9y3bx8DAwPL58+fGRgYACktBRltLfebAAAAAElFTkSuQmCC");
return img.decode().then(function(arg) {
assert_equals(arg, undefined);
});
}, document.title + " Image with PNG data URL href decodes with undefined.");
promise_test(function() {
var img = document.createElementNS('http://www.w3.org/2000/svg', 'image');
img.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', "/images/green.svg");
return img.decode().then(function(arg) {
assert_equals(arg, undefined);
});
}, document.title + " Image with SVG xlink:href decodes with undefined.");
promise_test(function() {
var img = document.createElementNS('http://www.w3.org/2000/svg', 'image');
img.setAttribute('href', "/images/green.svg");
return img.decode().then(function(arg) {
assert_equals(arg, undefined);
});
}, document.title + " Image with SVG href decodes with undefined.");
promise_test(function(t) {
var img = document.createElementNS('http://www.w3.org/2000/svg', 'image');
img.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', "/non/existent/path.png");
var promise = img.decode();
return promise_rejects(t, "EncodingError", promise);
}, document.title + " Non-existent xlink:href fails decode.");
promise_test(function(t) {
var img = document.createElementNS('http://www.w3.org/2000/svg', 'image');
img.setAttribute('href', "/non/existent/path.png");
var promise = img.decode();
return promise_rejects(t, "EncodingError", promise);
}, document.title + " Non-existent href fails decode.");
promise_test(function(t) {
var img = document.createElementNS('http://www.w3.org/2000/svg', 'image');
img.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', "data:image/png;base64,iVBO00PDR0BADBEEF00KGg");
var promise = img.decode();
return promise_rejects(t, "EncodingError", promise);
}, document.title + " Corrupt image in xlink:href fails decode.");
promise_test(function(t) {
var img = document.createElementNS('http://www.w3.org/2000/svg', 'image');
img.setAttribute('href', "data:image/png;base64,iVBO00PDR0BADBEEF00KGg");
var promise = img.decode();
return promise_rejects(t, "EncodingError", promise);
}, document.title + " Corrupt image in href fails decode.");
promise_test(function(t) {
var img = document.createElementNS('http://www.w3.org/2000/svg', 'image');
var promise = img.decode();
return promise_rejects(t, "EncodingError", promise);
}, document.title + " Image without xlink:href or href fails decode.");
promise_test(function() {
var img = document.createElementNS('http://www.w3.org/2000/svg', 'image');
img.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', "/images/green.png");
var first_promise = img.decode();
var second_promise = img.decode();
assert_not_equals(first_promise, second_promise);
return Promise.all([
first_promise,
second_promise
]);
}, document.title + " Multiple decodes with a xlink:href succeed.");
promise_test(function() {
var img = document.createElementNS('http://www.w3.org/2000/svg', 'image');
img.setAttribute('href', "/images/green.png");
var first_promise = img.decode();
var second_promise = img.decode();
assert_not_equals(first_promise, second_promise);
return Promise.all([
first_promise,
second_promise
]);
}, document.title + " Multiple decodes with a href succeed.");
</script>

View file

@ -0,0 +1,138 @@
<!DOCTYPE html>
<meta charset=utf-8>
<meta name="timeout" content="long">
<title>HTMLImageElement.prototype.decode(), basic tests.</title>
<link rel="author" title="Vladimir Levin" href="mailto:vmpstr@chromium.org">
<link rel=help href="https://html.spec.whatwg.org/multipage/embedded-content.html#dom-img-decode">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
"use strict";
// src tests
// -------------------
promise_test(function() {
var img = new Image();
img.src = "/images/green.png";
return img.decode().then(function(arg) {
assert_equals(arg, undefined);
});
}, document.title + " Image with PNG src decodes with undefined.");
promise_test(function() {
var img = new Image();
img.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAIAAA" +
"D91JpzAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4QUSEioKsyAgyw" +
"AAABl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggR0lNUFeBDhcAAAAWSURBVA" +
"jXY9y3bx8DAwPL58+fGRgYACktBRltLfebAAAAAElFTkSuQmCC";
return img.decode().then(function(arg) {
assert_equals(arg, undefined);
});
}, document.title + " Image with PNG data URL src decodes with undefined.");
promise_test(function() {
var img = new Image();
img.src = "/images/green.svg";
return img.decode().then(function(arg) {
assert_equals(arg, undefined);
});
}, document.title + " Image with SVG src decodes with undefined.");
promise_test(function(t) {
var img = new Image();
img.src = "/non/existent/path.png";
var promise = img.decode();
return promise_rejects(t, "EncodingError", promise);
}, document.title + " Non-existent src fails decode.");
promise_test(function(t) {
var inactive_doc = document.implementation.createHTMLDocument();
var img = inactive_doc.createElement("img");
img.src = "/images/green.png";
var promise = img.decode();
return promise_rejects(t, "EncodingError", promise);
}, document.title + " Inactive document fails decode.");
promise_test(function(t) {
var inactive_doc = document.implementation.createHTMLDocument();
var img = document.createElement("img");
img.src = "/images/green.png";
var promise = img.decode();
inactive_doc.body.appendChild(img);
return promise_rejects(t, "EncodingError", promise);
}, document.title + " Adopted active image into inactive document fails decode.");
promise_test(function() {
var inactive_doc = document.implementation.createHTMLDocument();
var img = inactive_doc.createElement("img");
img.src = "/images/green.png";
document.body.appendChild(img);
return img.decode().then(function(arg) {
assert_equals(arg, undefined);
});
}, document.title + " Adopted inactive image into active document succeeds.");
promise_test(function(t) {
var img = new Image();
img.src = "data:image/png;base64,iVBO00PDR0BADBEEF00KGg";
var promise = img.decode();
return promise_rejects(t, "EncodingError", promise);
}, document.title + " Corrupt image in src fails decode.");
promise_test(function(t) {
var img = new Image();
var promise = img.decode();
return promise_rejects(t, "EncodingError", promise);
}, document.title + " Image without src/srcset fails decode.");
promise_test(function() {
var img = new Image();
img.src = "/images/green.png";
var first_promise = img.decode();
var second_promise = img.decode();
assert_not_equals(first_promise, second_promise);
return Promise.all([
first_promise,
second_promise
]);
}, document.title + " Multiple decodes for images with src succeed.");
// srcset tests
// -------------------
promise_test(function() {
var img = new Image();
img.srcset = "/images/green.png 100w";
return img.decode().then(function(arg) {
assert_equals(arg, undefined);
});
}, document.title + " Image with PNG srcset decodes with undefined.");
promise_test(function() {
var img = new Image();
img.srcset = "/images/green.svg 100w";
return img.decode().then(function(arg) {
assert_equals(arg, undefined);
});
}, document.title + " Image with SVG srcset decodes with undefined.");
promise_test(function(t) {
var img = new Image();
img.srcset = "/non/existent/path.png 100w";
var promise = img.decode();
return promise_rejects(t, "EncodingError", promise);
}, document.title + " Non-existent srcset fails decode.");
promise_test(function() {
var img = new Image();
img.srcset = "/images/green.png 100w";
var first_promise = img.decode();
var second_promise = img.decode();
assert_not_equals(first_promise, second_promise);
return Promise.all([
first_promise,
second_promise
]);
}, document.title + " Multiple decodes for images with srcset succeed.");
</script>

View file

@ -0,0 +1,30 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Detached image blocks load</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
var img_loaded = false;
var img = new Image();
img.onload = function() {
img_loaded = true;
};
img.src = "/images/blue.png?pipe=trickle(d2)";
test(function() {
assert_false(img_loaded);
}, "setting img.src is async");
async_test(function(t) {
document.addEventListener("DOMContentLoaded", t.step_func_done(function() {
assert_false(img_loaded);
}));
}, "DOMContentLoaded doesn't wait for images");
async_test(function(t) {
window.addEventListener("load", t.step_func_done(function() {
assert_true(img_loaded);
}));
}, "load waits for images");
</script>

View file

@ -1,17 +1,26 @@
<html>
<head>
<title>Image element delays window's load event</title>
<!DOCTYPE html>
<meta charset="utf-8">
<title>Inline image element blocks load</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<img src="resources/cat.jpg?pipe=trickle(d2)">
<script>
async_test(function(t) {
var saw_img_load = false;
document.querySelector('img').onload = t.step_func(function() {
saw_img_load = true;
});
addEventListener('load', t.step_func_done(function() {
assert_true(saw_img_load);
}));
});
var img_loaded = false;
</script>
<img src="/images/blue.png?pipe=trickle(d2)" onload="img_loaded = true;">
<script>
test(function() {
assert_false(img_loaded);
}, "script execution doesn't wait for the image to load");
async_test(function(t) {
document.addEventListener("DOMContentLoaded", t.step_func_done(function() {
assert_false(img_loaded);
}));
}, "DOMContentLoaded doesn't wait for images");
async_test(function(t) {
window.addEventListener("load", t.step_func_done(function() {
assert_true(img_loaded);
}));
}, "Image element delays window's load event");
</script>

View file

@ -0,0 +1,52 @@
<!doctype html>
<meta charset=utf-8>
<title>img in non-active document should not perform loads</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<!-- Per load the image so that any loads in this test would be cached. -->
<img src=/images/green-1x1.png>
<!-- tests -->
<template>
<img>
</template>
<script>
onload = function() {
async_test(function(t) {
var p = new DOMParser();
var d = p.parseFromString('<img>', 'text/html');
var i = d.querySelector('img');
i.onerror = t.unreached_func('got unexpected error event');
i.onload = t.unreached_func('got unexpected load event');
i.src = '/images/green-1x1.png';
// delay to ensure there is no load/error event fired.
t.step_timeout(t.step_func_done(), 0);
}, "DOMParser");
async_test(function(t) {
var d = document.implementation.createHTMLDocument('');
d.body.innerHTML = '<img>';
var i = d.querySelector('img');
i.onerror = this.unreached_func('got unexpected error event');
i.onload = this.unreached_func('got unexpected load event');
i.src = '/images/green-1x1.png';
// delay to ensure there is no load/error event fired.
t.step_timeout(t.step_func_done(), 0);
}, "createHTMLDocument");
async_test(function(t) {
var template = document.querySelector('template');
var i = template.content.querySelector('img');
i.onerror = this.unreached_func('got unexpected error event');
i.onload = this.unreached_func('got unexpected load event');
i.src = '/images/green-1x1.png';
// delay to ensure there is no load/error event fired.
t.step_timeout(t.step_func_done(), 0);
}, "<template>");
};
</script>

View file

@ -8,54 +8,54 @@
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<img src="/images/threecolors.png" usemap="#sanityCheck" width="100" height="100">
<map name="sanityCheck"><area shape="rect" coords="0,0,100,100"></map>
<img src="/images/threecolors.png" usemap="#sImPlE" width="100" height="100">
<map name="simple"><area shape="rect" coords="0,0,100,100"></map>
<map name="SIMPLE"><area shape="rect" coords="0,0,100,100"></map>
<img src="/images/threecolors.png" usemap="#paSSfield-killroyß" width="100" height="100">
<map name="passfield-killroyß"><area shape="rect" coords="0,0,100,100"></map>
<map name="PASSFIELD-KILLROYß"><area shape="rect" coords="0,0,100,100"></map>
<map name="paſſfield-killroyß"><area shape="rect" coords="0,0,100,100"></map>
<map name="passfield-&#x212a;illroyß"><area shape="rect" coords="0,0,100,100"></map>
<map name="paßfield-killroyß"><area shape="rect" coords="0,0,100,100"></map>
<map name="paẞfield-killroyß"><area shape="rect" coords="0,0,100,100"></map>
<map name="passfield-killroyẞ"><area shape="rect" coords="0,0,100,100"></map>
<map name="passfield-killroyß"><area shape="rect" coords="0,0,100,100"></map>
<map name="passfıeld-killroyß"><area shape="rect" coords="0,0,100,100"></map>
<map name="passfİeld-killroyß"><area shape="rect" coords="0,0,100,100"></map>
<img src="/images/threecolors.png" usemap="#глупый" width="100" height="100">
<map name="глупы&#x438;&#x306;"><area shape="rect" coords="0,0,100,100"></map>
<map name="ГЛУПЫЙ"><area shape="rect" coords="0,0,100,100"></map>
<map name="ГЛУПЫ&#x418;&#x306;"><area shape="rect" coords="0,0,100,100"></map>
<img src="/images/threecolors.png" usemap="#åωk" width="100" height="100">
<map name="ÅΩK"><area shape="rect" coords="0,0,100,100"></map>
<map name="&#x212b;ωk"><area shape="rect" coords="0,0,100,100"></map>
<map name="å&#x2126;k"><area shape="rect" coords="0,0,100,100"></map>
<map name="åω&#x212a;"><area shape="rect" coords="0,0,100,100"></map>
<img src="/images/threecolors.png" usemap="#blah1" width="100" height="100">
<map name="blah&#x2460;"><area shape="rect" coords="0,0,100,100"></map>
<map name="bl&#x24b6;h1"><area shape="rect" coords="0,0,100,100"></map>
<map name="bl&#x24d0;h1"><area shape="rect" coords="0,0,100,100"></map>
<img src="/images/threecolors.png" usemap="#t&Eacute;dz5アパートFi" width="100" height="100">
<map name="T&Eacute;DZ5アパートFi"><area shape="rect" coords="0,0,100,100"></map>
<map name="T&eacute;&#x01F1;&#x2075;アパートFi"><area shape="rect" coords="0,0,100,100"></map>
<map name="t&Eacute;dz5&#x3100;Fi"><area shape="rect" coords="0,0,100,100"></map>
<map name="t&Eacute;dz5&#x30A2;&#x30CF;&#x309A;&#x30FC;&#x30C8;Fi"><area shape="rect" coords="0,0,100,100"></map>
<map name="T&Eacute;DZ⁵アパートFi"><area shape="rect" coords="0,0,100,100"></map>
<map name="T&Eacute;DZ5アパートfi"><area shape="rect" coords="0,0,100,100"></map>
<img src="/images/threecolors.png" usemap="#ΣΣ" width="100" height="100">
<map name="σς"><area shape="rect" coords="0,0,100,100"></map>
<div id="log"></div>
<img src="/images/threecolors.png" usemap="#sanityCheck" width="300" height="300">
<map name="sanityCheck"><area shape="rect" coords="0,0,300,300"></map>
<img src="/images/threecolors.png" usemap="#sImPlE" width="300" height="300">
<map name="simple"><area shape="rect" coords="0,0,300,300"></map>
<map name="SIMPLE"><area shape="rect" coords="0,0,300,300"></map>
<img src="/images/threecolors.png" usemap="#paSSfield-killroyß" width="300" height="300">
<map name="passfield-killroyß"><area shape="rect" coords="0,0,300,300"></map>
<map name="PASSFIELD-KILLROYß"><area shape="rect" coords="0,0,300,300"></map>
<map name="paſſfield-killroyß"><area shape="rect" coords="0,0,300,300"></map>
<map name="passfield-&#x212a;illroyß"><area shape="rect" coords="0,0,300,300"></map>
<map name="paßfield-killroyß"><area shape="rect" coords="0,0,300,300"></map>
<map name="paẞfield-killroyß"><area shape="rect" coords="0,0,300,300"></map>
<map name="passfield-killroyẞ"><area shape="rect" coords="0,0,300,300"></map>
<map name="passfield-killroyß"><area shape="rect" coords="0,0,300,300"></map>
<map name="passfıeld-killroyß"><area shape="rect" coords="0,0,300,300"></map>
<map name="passfİeld-killroyß"><area shape="rect" coords="0,0,300,300"></map>
<img src="/images/threecolors.png" usemap="#глупый" width="300" height="300">
<map name="глупы&#x438;&#x306;"><area shape="rect" coords="0,0,300,300"></map>
<map name="ГЛУПЫЙ"><area shape="rect" coords="0,0,300,300"></map>
<map name="ГЛУПЫ&#x418;&#x306;"><area shape="rect" coords="0,0,300,300"></map>
<img src="/images/threecolors.png" usemap="#åωk" width="300" height="300">
<map name="ÅΩK"><area shape="rect" coords="0,0,300,300"></map>
<map name="&#x212b;ωk"><area shape="rect" coords="0,0,300,300"></map>
<map name="å&#x2126;k"><area shape="rect" coords="0,0,300,300"></map>
<map name="åω&#x212a;"><area shape="rect" coords="0,0,300,300"></map>
<img src="/images/threecolors.png" usemap="#blah1" width="300" height="300">
<map name="blah&#x2460;"><area shape="rect" coords="0,0,300,300"></map>
<map name="bl&#x24b6;h1"><area shape="rect" coords="0,0,300,300"></map>
<map name="bl&#x24d0;h1"><area shape="rect" coords="0,0,300,300"></map>
<img src="/images/threecolors.png" usemap="#t&Eacute;dz5アパートFi" width="300" height="300">
<map name="T&Eacute;DZ5アパートFi"><area shape="rect" coords="0,0,300,300"></map>
<map name="T&eacute;&#x01F1;&#x2075;アパートFi"><area shape="rect" coords="0,0,300,300"></map>
<map name="t&Eacute;dz5&#x3300;Fi"><area shape="rect" coords="0,0,300,300"></map>
<map name="t&Eacute;dz5&#x30A2;&#x30CF;&#x309A;&#x30FC;&#x30C8;Fi"><area shape="rect" coords="0,0,300,300"></map>
<map name="T&Eacute;DZ⁵アパートFi"><area shape="rect" coords="0,0,300,300"></map>
<map name="T&Eacute;DZ5アパートfi"><area shape="rect" coords="0,0,300,300"></map>
<img src="/images/threecolors.png" usemap="#ΣΣ" width="300" height="300">
<map name="σς"><area shape="rect" coords="0,0,300,300"></map>
<script>
"use strict";
setup({ explicit_done: true });