2 <p>Test of Range.createContextualFragment() with in-scope namespace prefixes on attributes. If the test succeeds you will see the word
"PASS" below.
</p>
4 <script type=
"text/javascript">
5 function onIframeLoad() {
7 testRunner
.dumpAsText();
9 var result
= document
.getElementById("result");
10 result
.textContent
= "FAIL";
12 var iframe
= document
.getElementById("iframe"),
13 doc
= iframe
.contentDocument
,
14 range
= doc
.createRange(),
17 var defs1
= doc
.getElementById("defs1");
18 range
.setStart(defs1
, 0);
19 docFragment
= range
.createContextualFragment("<linearGradient id='gradient1'/>" +
20 "<linearGradient id='gradient2' XL:href='#gradient1' href='otherHref'/>");
21 var gradient2
= docFragment
.lastChild
;
22 if (gradient2
.namespaceURI
!= "http://www.w3.org/2000/svg") {
23 result
.textContent
+= " - #gradient2 has the wrong namespace URI";
26 if (gradient2
.getAttributeNS(defs1
.lookupNamespaceURI("XL"), "href") != "#gradient1") {
27 result
.textContent
+= " - wrong XL:href attribute value on #gradient2";
30 defs1
.appendChild(docFragment
);
31 if (gradient2
.lookupNamespaceURI("XL") != defs1
.lookupNamespaceURI("XL")) {
32 result
.textContent
+= " - #gradient2 returned the incorrect namespace URI for prefix 'XL'";
38 var defs2
= doc
.getElementById("defs2");
39 range
.setStart(defs2
, 0);
40 docFragment
= range
.createContextualFragment("<linearGradient id='gradient3'/>" +
41 "<linearGradient id='gradient4' xLink:href='#gradient3' href='otherHref'/>");
42 defs2
.appendChild(docFragment
);
43 var gradient4
= defs2
.lastChild
;
44 if (gradient4
.namespaceURI
!= "http://www.w3.org/2000/svg") {
45 result
.textContent
+= " - #gradient4 has the wrong namespace URI";
48 if (gradient4
.getAttributeNS(defs2
.lookupNamespaceURI("xLink"), "href") != "#gradient3") {
49 result
.textContent
+= " - wrong xLink:href attribute value on #gradient2";
52 if (gradient4
.lookupNamespaceURI("xLink") != defs2
.lookupNamespaceURI("xLink")) {
53 result
.textContent
+= " - #gradient2 returned the incorrect namespace URI for prefix 'xLink'";
57 // Check that Range.createContextualFragment() fails if an out-of-scope namespace prefix is used.
60 range
.createContextualFragment("<linearGradient id='gradient5' XL:href='#gradient3'/>");
64 if (exception
== null) {
65 result
.textContent
+= " - Range.createContextualFragment() did not raise an exception when attempting to use an out-of-scope namespace prefix";
68 if (String
.prototype.indexOf
.call(exception
.message
, "invalid XML") < 0) {
69 result
.textContent
+= " - wrong exception thrown";
73 result
.textContent
= "PASS";
76 <iframe id=
"iframe" src=
"resources/svg-document-ns1.svg" onload=
"onIframeLoad()"></iframe>