dom/tests/mochitest/dom-level2-core/test_elementsetattributenodens01.html

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
michael@0 2 <html>
michael@0 3 <head>
michael@0 4 <META http-equiv="Content-Type" content="text/html; charset=UTF-8">
michael@0 5 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
michael@0 6 <title>http://www.w3.org/2001/DOM-Test-Suite/level2/core/elementsetattributenodens01</title>
michael@0 7 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css">
michael@0 8 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 9 <script type="text/javascript" src="DOMTestCase.js"></script>
michael@0 10 <script type="text/javascript" src="exclusions.js"></script>
michael@0 11 <script type="text/javascript">
michael@0 12 // expose test function names
michael@0 13 function exposeTestFunctionNames()
michael@0 14 {
michael@0 15 return ['elementsetattributenodens01'];
michael@0 16 }
michael@0 17
michael@0 18 var docsLoaded = -1000000;
michael@0 19 var builder = null;
michael@0 20
michael@0 21 //
michael@0 22 // This function is called by the testing framework before
michael@0 23 // running the test suite.
michael@0 24 //
michael@0 25 // If there are no configuration exceptions, asynchronous
michael@0 26 // document loading is started. Otherwise, the status
michael@0 27 // is set to complete and the exception is immediately
michael@0 28 // raised when entering the body of the test.
michael@0 29 //
michael@0 30 function setUpPage() {
michael@0 31 setUpPageStatus = 'running';
michael@0 32 try {
michael@0 33 //
michael@0 34 // creates test document builder, may throw exception
michael@0 35 //
michael@0 36 builder = createConfiguredBuilder();
michael@0 37 setImplementationAttribute("namespaceAware", true);
michael@0 38
michael@0 39 docsLoaded = 0;
michael@0 40
michael@0 41 var docRef = null;
michael@0 42 if (typeof(this.doc) != 'undefined') {
michael@0 43 docRef = this.doc;
michael@0 44 }
michael@0 45 docsLoaded += preload(docRef, "doc", "staff");
michael@0 46
michael@0 47 if (docsLoaded == 1) {
michael@0 48 setUpPage = 'complete';
michael@0 49 }
michael@0 50 } catch(ex) {
michael@0 51 catchInitializationError(builder, ex);
michael@0 52 setUpPage = 'complete';
michael@0 53 }
michael@0 54 }
michael@0 55
michael@0 56 //
michael@0 57 // This method is called on the completion of
michael@0 58 // each asychronous load started in setUpTests.
michael@0 59 //
michael@0 60 // When every synchronous loaded document has completed,
michael@0 61 // the page status is changed which allows the
michael@0 62 // body of the test to be executed.
michael@0 63 function loadComplete() {
michael@0 64 if (++docsLoaded == 1) {
michael@0 65 setUpPageStatus = 'complete';
michael@0 66 runJSUnitTests();
michael@0 67 markTodos();
michael@0 68 SimpleTest.finish();
michael@0 69 }
michael@0 70 }
michael@0 71
michael@0 72 var docName = 'elementsetattributenodens01';
michael@0 73
michael@0 74
michael@0 75 /**
michael@0 76 *
michael@0 77 Testing Element.setAttributeNodeNS: If an attribute with that local name
michael@0 78 and that namespace URI is already present in the element, it is replaced
michael@0 79 by the new one.
michael@0 80
michael@0 81 Create a new element and two new attribute nodes (in the same namespace
michael@0 82 and same localNames).
michael@0 83 Add the two new attribute nodes to the element node using the
michael@0 84 setAttributeNodeNS method. Check that only one attribute is added, check
michael@0 85 the value of this attribute.
michael@0 86
michael@0 87 * @author IBM
michael@0 88 * @author Neil Delima
michael@0 89 * @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElSetAtNodeNS
michael@0 90 */
michael@0 91 function elementsetattributenodens01() {
michael@0 92 var success;
michael@0 93 if(checkInitialization(builder, "elementsetattributenodens01") != null) return;
michael@0 94 var doc;
michael@0 95 var element;
michael@0 96 var attribute1;
michael@0 97 var attribute2;
michael@0 98 var attrNode;
michael@0 99 var attrName;
michael@0 100 var attrNS;
michael@0 101 var attrValue;
michael@0 102 var attributes;
michael@0 103 var newAttribute;
michael@0 104 var length;
michael@0 105
michael@0 106 var docRef = null;
michael@0 107 if (typeof(this.doc) != 'undefined') {
michael@0 108 docRef = this.doc;
michael@0 109 }
michael@0 110 doc = load(docRef, "doc", "staff");
michael@0 111 element = doc.createElementNS("http://www.w3.org/DOM/Test/Level2","new:element");
michael@0 112 attribute1 = doc.createAttributeNS("http://www.w3.org/DOM/Test/att1","p1:att");
michael@0 113 attribute2 = doc.createAttributeNS("http://www.w3.org/DOM/Test/att1","p2:att");
michael@0 114 attribute2.value = "value2";
michael@0 115
michael@0 116 newAttribute = element.setAttributeNodeNS(attribute1);
michael@0 117 newAttribute = element.setAttributeNodeNS(attribute2);
michael@0 118 attrNode = element.getAttributeNodeNS("http://www.w3.org/DOM/Test/att1","att");
michael@0 119 attrName = attrNode.nodeName;
michael@0 120
michael@0 121 attrNS = attrNode.namespaceURI;
michael@0 122
michael@0 123 assertEquals("elementsetattributenodens01_attrName","p2:att",attrName);
michael@0 124 assertEquals("elementsetattributenodens01_attrNS","http://www.w3.org/DOM/Test/att1",attrNS);
michael@0 125 attributes = element.attributes;
michael@0 126
michael@0 127 length = attributes.length;
michael@0 128
michael@0 129 assertEquals("length",1,length);
michael@0 130
michael@0 131 }
michael@0 132
michael@0 133 </script>
michael@0 134 </head>
michael@0 135 <body>
michael@0 136 <h2>Test http://www.w3.org/2001/DOM-Test-Suite/level2/core/elementsetattributenodens01</h2>
michael@0 137 <p></p>
michael@0 138 <p>
michael@0 139 Copyright (c) 2001-2004 World Wide Web Consortium,
michael@0 140 (Massachusetts Institute of Technology, European Research Consortium
michael@0 141 for Informatics and Mathematics, Keio University). All
michael@0 142 Rights Reserved. This work is distributed under the <a href="http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231">W3C(r) Software License</a> in the
michael@0 143 hope that it will be useful, but WITHOUT ANY WARRANTY; without even
michael@0 144 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
michael@0 145 </p>
michael@0 146 </body>
michael@0 147 </html>

mercurial