Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /html/semantics/embedded-content/the-img-element/decode/image-decode-path-changes-svg.tentative.html - WPT Dashboard Interop Dashboard
<!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) {
img.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', "/images/green.png?image-decode-path-changes-1");
var promise = img.decode();
img.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', "/images/green.svg?image-decode-path-changes-1");
return promise_rejects_dom(t, "EncodingError", promise);
}, document.title + " xlink:href changes fail decode.");
promise_test(function(t) {
img.setAttribute('href', "/images/green.png?image-decode-path-changes-2");
var promise = img.decode();
img.setAttribute('href', "/images/green.svg?image-decode-path-changes-2");
return promise_rejects_dom(t, "EncodingError", promise);
}, document.title + " href changes fail decode.");
promise_test(function(t) {
img.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', "/images/green.png?image-decode-path-changes-3");
var first_promise = img.decode();
img.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', "/images/green.svg?image-decode-path-changes-3");
var second_promise = img.decode();
assert_not_equals(first_promise, second_promise);
return Promise.all([
promise_rejects_dom(t, "EncodingError", first_promise),
second_promise
]);
}, document.title + " xlink:href changes fail decode; following good decode succeeds.");
promise_test(function(t) {
img.setAttribute('href', "/images/green.png?image-decode-path-changes-4");
var first_promise = img.decode();
img.setAttribute('href', "/images/green.svg?image-decode-path-changes-4");
var second_promise = img.decode();
assert_not_equals(first_promise, second_promise);
return Promise.all([
promise_rejects_dom(t, "EncodingError", first_promise),
second_promise
]);
}, document.title + " href changes fail decode; following good decode succeeds.");
promise_test(function(t) {
img.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', "/images/green.png?image-decode-path-changes-5");
var first_promise = img.decode();
img.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', "/non/existent/path.png?image-decode-path-changes-5");
var second_promise = img.decode();
assert_not_equals(first_promise, second_promise);
return Promise.all([
promise_rejects_dom(t, "EncodingError", first_promise),
promise_rejects_dom(t, "EncodingError", second_promise)
]);
}, document.title + " xlink:href changes fail decode; following bad decode fails.");
promise_test(function(t) {
img.setAttribute('href', "/images/green.png?image-decode-path-changes-6");
var first_promise = img.decode();
img.setAttribute('href', "/non/existent/path.png?image-decode-path-changes-6");
var second_promise = img.decode();
assert_not_equals(first_promise, second_promise);
return Promise.all([
promise_rejects_dom(t, "EncodingError", first_promise),
promise_rejects_dom(t, "EncodingError", second_promise)
]);
}, document.title + " href changes fail decode; following bad decode fails.");
</script>