dom/tests/js/attributes.html

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

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

mercurial