| 1 |
<svg id="svg-root" width="100%" height="100%" |
| 2 |
viewBox="0 0 480 360" xmlns="http://www.w3.org/2000/svg" |
| 3 |
xmlns:xlink="http://www.w3.org/1999/xlink" onload="test()"> |
| 4 |
<!--======================================================================--> |
| 5 |
<!--= Copyright 2008 World Wide Web Consortium, (Massachusetts =--> |
| 6 |
<!--= Institute of Technology, European Research Consortium for =--> |
| 7 |
<!--= Informatics and Mathematics (ERCIM), Keio University). =--> |
| 8 |
<!--= All Rights Reserved. =--> |
| 9 |
<!--= See http://www.w3.org/Consortium/Legal/. =--> |
| 10 |
<!--======================================================================--> |
| 11 |
<d:SVGTestCase xmlns:d="http://www.w3.org/2000/02/svg/testsuite/description/" |
| 12 |
template-version="1.4" reviewer="DS" author="ED" status="accepted" |
| 13 |
version="$Revision: 1.3 $" testname="$RCSfile: conform-viewers-03-f.svg,v $"> |
| 14 |
<d:testDescription xmlns="http://www.w3.org/1999/xhtml" href="http://www.w3.org/TR/SVG11/conform.html#ConformingSVGViewers"> |
| 15 |
<p> |
| 16 |
This test checks that namespace prefixes are handled correctly. |
| 17 |
</p> |
| 18 |
<p> |
| 19 |
First, a random 20-character string is generated. The string only contains characters that are valid NCName letters. |
| 20 |
This string is then used as a custom prefix for an 'href' attribute in the XLink namespace. |
| 21 |
An 'image' element is created and two image references are added, one is in the "http://www.this.is.not.an/xlink" namespace, |
| 22 |
and one is in the XLink namespace. Only the attribute with the 20-character prefix is actually in the XLink namespace, |
| 23 |
which means that that link should be the one that is used when rendering the 'image' element. This first subtest is |
| 24 |
using the setAttributeNS method. |
| 25 |
</p> |
| 26 |
</d:testDescription> |
| 27 |
<d:operatorScript xmlns="http://www.w3.org/1999/xhtml"> |
| 28 |
<p> |
| 29 |
Run the test. No interaction required. |
| 30 |
</p> |
| 31 |
</d:operatorScript> |
| 32 |
<d:passCriteria xmlns="http://www.w3.org/1999/xhtml"> |
| 33 |
<p> |
| 34 |
The testcase has passed if after the script execution has taken place these conditions are met: |
| 35 |
</p> |
| 36 |
<ul> |
| 37 |
<li>There is one pink image visible.</li> |
| 38 |
<li>The image doesn't show the word "Fail"</li> |
| 39 |
<li>The status message says "No exceptions"</li> |
| 40 |
</ul> |
| 41 |
</d:passCriteria> |
| 42 |
</d:SVGTestCase> |
| 43 |
<title id="test-title">$RCSfile: conform-viewers-03-f.svg,v $</title> |
| 44 |
<defs> |
| 45 |
<font-face |
| 46 |
font-family="SVGFreeSansASCII" |
| 47 |
unicode-range="U+0-7F"> |
| 48 |
<font-face-src> |
| 49 |
<font-face-uri xlink:href="../resources/SVGFreeSans.svg#ascii"/> |
| 50 |
</font-face-src> |
| 51 |
</font-face> |
| 52 |
</defs> |
| 53 |
<g id="test-body-content" font-family="SVGFreeSansASCII,sans-serif" font-size="18"> |
| 54 |
|
| 55 |
<script> |
| 56 |
<![CDATA[ |
| 57 |
/** |
| 58 |
* Generates a 20 character string consisting of characters from the inchars parameter. |
| 59 |
* The output string will have no repetitions of a character. |
| 60 |
*/ |
| 61 |
function generatePrefix(inchars) |
| 62 |
{ |
| 63 |
var ncNameStart = "_abcdefghijklmnopqrstuvwxyzåäöQWERTYUIOPÅÄÖLKJHGFDSAZXCVBNM"; |
| 64 |
|
| 65 |
var prefix = ncNameStart[Math.floor(Math.random()*ncNameStart.length)]; |
| 66 |
var leftchars = inchars; |
| 67 |
var char; |
| 68 |
for(var i = 0; i < 19; i++) |
| 69 |
{ |
| 70 |
char = leftchars[Math.floor(Math.random()*leftchars.length)]; |
| 71 |
leftchars = leftchars.replace(char, ''); |
| 72 |
prefix += char; |
| 73 |
} |
| 74 |
return prefix; |
| 75 |
} |
| 76 |
|
| 77 |
/** |
| 78 |
* The main body of the test. |
| 79 |
*/ |
| 80 |
function test() |
| 81 |
{ |
| 82 |
var letters = "abcdefghijklmnopqrstuvwxyzåäö_-.QWERTYUIOPÅÄÖLKJHGFDSAZXCVBNM0123456789"; |
| 83 |
var prefix = generatePrefix(letters); |
| 84 |
var g = document.getElementById("test-body-content"); |
| 85 |
var t = document.getElementById("prefix"); |
| 86 |
t.textContent = prefix; |
| 87 |
|
| 88 |
var elm = document.createElementNS("http://www.w3.org/2000/svg", "image"); |
| 89 |
elm.setAttributeNS(null, "width", 100); |
| 90 |
elm.setAttributeNS(null, "height", 100); |
| 91 |
elm.setAttributeNS(null, "x", 100); |
| 92 |
elm.setAttributeNS(null, "y", 100); |
| 93 |
elm.setAttributeNS("http://www.w3.org/1999/xlink", prefix+":href", "../images/pinksquidj.png"); |
| 94 |
elm.setAttributeNS("http://www.this.is.not.an/xlink", "xlink:href", "../images/purplesquidj.png"); |
| 95 |
g.appendChild(elm); |
| 96 |
} |
| 97 |
]]> |
| 98 |
</script> |
| 99 |
|
| 100 |
<text y="100" x="50" display="none"> |
| 101 |
Generated prefix 1: <tspan id="prefix">...</tspan> |
| 102 |
</text> |
| 103 |
<text y="220" x="50"> |
| 104 |
Status: <tspan id="status">No exceptions.</tspan> |
| 105 |
</text> |
| 106 |
|
| 107 |
<g xmlns:xlink="http://example.net/bar"> |
| 108 |
<image id="image2" width="100" height="100" x="210" y="100" xlink:href="../images/purplesquidj.png"/> |
| 109 |
</g> |
| 110 |
|
| 111 |
</g> |
| 112 |
<g font-family="SVGFreeSansASCII,sans-serif" font-size="32"> |
| 113 |
<text id="revision" x="10" y="340" stroke="none" |
| 114 |
fill="black">$Revision: 1.3 $</text> |
| 115 |
</g> |
| 116 |
<rect id="test-frame" x="1" y="1" width="478" height="358" fill="none" stroke="#000"/> |
| 117 |
<!-- comment out this watermark once the test is approved |
| 118 |
<g id="draft-watermark"> |
| 119 |
<rect x="1" y="1" width="478" height="20" fill="red" stroke="black" stroke-width="1"/> |
| 120 |
<text font-family="SVGFreeSansASCII,sans-serif" font-weight="bold" font-size="20" x="240" |
| 121 |
text-anchor="middle" y="18" stroke-width="0.5" stroke="black" fill="white">DRAFT</text> |
| 122 |
</g> --> |
| 123 |
</svg> |