Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / dom / Range / create-contextual-fragment-namespaces1.html
blobf1365a84d25e50d11dd9fb9c7aa24237a2033b85
1 <!DOCTYPE html>
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>
3 <p id="result"></p>
4 <script type="text/javascript">
5 function onIframeLoad() {
6 if (window.testRunner)
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(),
15 docFragment;
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";
24 return;
26 if (gradient2.getAttributeNS(defs1.lookupNamespaceURI("XL"), "href") != "#gradient1") {
27 result.textContent += " - wrong XL:href attribute value on #gradient2";
28 return;
30 defs1.appendChild(docFragment);
31 if (gradient2.lookupNamespaceURI("XL") != defs1.lookupNamespaceURI("XL")) {
32 result.textContent += " - #gradient2 returned the incorrect namespace URI for prefix 'XL'";
33 return;
35 gradient2 = null;
36 defs1 = null;
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";
46 return;
48 if (gradient4.getAttributeNS(defs2.lookupNamespaceURI("xLink"), "href") != "#gradient3") {
49 result.textContent += " - wrong xLink:href attribute value on #gradient2";
50 return;
52 if (gradient4.lookupNamespaceURI("xLink") != defs2.lookupNamespaceURI("xLink")) {
53 result.textContent += " - #gradient2 returned the incorrect namespace URI for prefix 'xLink'";
54 return;
57 // Check that Range.createContextualFragment() fails if an out-of-scope namespace prefix is used.
58 var exception;
59 try {
60 range.createContextualFragment("<linearGradient id='gradient5' XL:href='#gradient3'/>");
61 } catch (e) {
62 exception = e;
64 if (exception == null) {
65 result.textContent += " - Range.createContextualFragment() did not raise an exception when attempting to use an out-of-scope namespace prefix";
66 return;
68 if (String.prototype.indexOf.call(exception.message, "invalid XML") < 0) {
69 result.textContent += " - wrong exception thrown";
70 return;
73 result.textContent = "PASS";
75 </script>
76 <iframe id="iframe" src="resources/svg-document-ns1.svg" onload="onIframeLoad()"></iframe>