content/xul/document/test/test_bug445177.xul

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 <?xml version="1.0"?>
michael@0 2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
michael@0 3 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
michael@0 4 <!--
michael@0 5 https://bugzilla.mozilla.org/show_bug.cgi?id=445177
michael@0 6 -->
michael@0 7 <window title="Test for Bug 445177"
michael@0 8 id="test_bug445177_xul"
michael@0 9 xmlns:html="http://www.w3.org/1999/xhtml"
michael@0 10 xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
michael@0 11 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
michael@0 12
michael@0 13 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
michael@0 14
michael@0 15 <body id="body" xmlns="http://www.w3.org/1999/xhtml">
michael@0 16 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=445177">Mozilla Bug 445177</a>
michael@0 17
michael@0 18
michael@0 19 <hbox id="b1" value="foo"/>
michael@0 20 <hbox id="o1" observes="b1"/>
michael@0 21
michael@0 22 <pre id="test">
michael@0 23 <script class="testbody" type="text/javascript">
michael@0 24 <![CDATA[
michael@0 25 SimpleTest.waitForExplicitFinish();
michael@0 26 function do_test() {
michael@0 27 var b1 = document.getElementById("b1");
michael@0 28 var o1 = document.getElementById("o1");
michael@0 29
michael@0 30 is(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (1)");
michael@0 31
michael@0 32 b1.setAttribute("value", "bar");
michael@0 33 is(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (2)");
michael@0 34
michael@0 35 b1.removeAttribute("value");
michael@0 36 is(o1.hasAttribute("value"), b1.hasAttribute("value"), "Wrong value (3)");
michael@0 37
michael@0 38 o1.setAttribute("value", "foo");
michael@0 39 isnot(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (4)");
michael@0 40
michael@0 41 b1.setAttribute("value", "foobar");
michael@0 42 is(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (5)");
michael@0 43
michael@0 44 //After removing listener, changes to broadcaster shouldn't have any effect.
michael@0 45 o1.parentNode.removeChild(o1);
michael@0 46 b1.setAttribute("value", "foo");
michael@0 47 isnot(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (6)");
michael@0 48
michael@0 49 b1.parentNode.appendChild(o1);
michael@0 50 is(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (7)");
michael@0 51
michael@0 52 o1.parentNode.removeChild(o1);
michael@0 53 o1.removeAttribute("observes");
michael@0 54 o1.removeAttribute("value");
michael@0 55 b1.parentNode.appendChild(o1);
michael@0 56 isnot(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (8)");
michael@0 57
michael@0 58 document.addBroadcastListenerFor(b1, o1, "value");
michael@0 59 is(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (9)");
michael@0 60
michael@0 61 o1.parentNode.removeChild(o1);
michael@0 62 b1.setAttribute("value", "foobar");
michael@0 63 is(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (10)");
michael@0 64
michael@0 65 b1.parentNode.appendChild(o1);
michael@0 66 is(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (11)");
michael@0 67
michael@0 68 o1.setAttribute("observes", "b1");
michael@0 69 is(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (12)");
michael@0 70
michael@0 71 // When broadcaster isn't in document, changes to its attributes aren't
michael@0 72 // reflected to listener.
michael@0 73 b1.parentNode.removeChild(b1);
michael@0 74 b1.setAttribute("value", "foo");
michael@0 75 isnot(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (13)");
michael@0 76
michael@0 77 SimpleTest.finish();
michael@0 78 }
michael@0 79
michael@0 80 addLoadEvent(do_test);
michael@0 81 ]]>
michael@0 82 </script>
michael@0 83 </pre>
michael@0 84 </body>
michael@0 85 </window>

mercurial