dom/tests/js/attributes.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

     1 <HTML>
     2 <HEAD>
     3   <TITLE>Attributes test</TITLE>
     4 </HEAD>
     5 <BODY bgColor="#ffffff" text="#000000">
     6 <H1>Attributes test</H1>
     8 <P>You should see the following in the console:</P>
     9 <PRE>
    10 attribute.getNamedItem == getAttributeNode: true
    11 attribute BGCOLOR=#ffffff
    12 changing attribute node value changes attribute value: true
    13 return value of removeNamedItem is attribute node: true
    14 removing attribute changes attribute count: true
    15 changing disembodied attribute value works: true
    16 removing attribute node removes attribute: true
    17 </PRE>
    19 <P>The text should turn green and then you should see
    20 the following in the console:</P>
    21 <PRE>
    22 setting an existing attribute returns the old node: true
    23 </PRE>
    25 <SCRIPT>
    26 a = document.body.attributes.getNamedItem("bgcolor")
    27 a2 = document.body.getAttributeNode("bgcolor")
    28 n = document.body.attributes.length;
    29 dump("attribute.getNamedItem == getAttributeNode: " + (a == a2) + "\n");
    31 dump("attribute " + a.name + "=" + a.value + "\n");
    33 a.value = "#00ffff"
    34 dump("changing attribute node value changes attribute value: " + (document.body.getAttribute("bgcolor") == "#00ffff") + "\n");
    36 a = document.body.attributes.removeNamedItem("bgcolor")
    37 dump("return value of removeNamedItem is attribute node: " + (a == a2) + "\n");
    39 dump("removing attribute changes attribute count: " + (document.body.attributes.length == (n-1)) + "\n");
    41 a.value = "#ff0000"
    42 dump("changing disembodied attribute value works: " + (a.value == "#ff0000") + "\n");
    44 dump("removing attribute node removes attribute: " + (document.body.getAttribute("bgcolor") == "") + "\n");
    46 a = document.body.attributes.getNamedItem("TEXT");
    47 a2 = document.createAttribute("text");
    48 a2.value = "#00ff00";
    49 a3 = document.body.attributes.setNamedItem(a2);
    50 dump("setting an existing attribute returns the old node: " + (a == a3) + "\n");
    51 </SCRIPT>
    53 </BODY>
    54 </HTML>

mercurial