Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
1 <?xml version="1.0"?>
2 <html xmlns="http://www.w3.org/1999/xhtml"
3 xmlns:xbl="http://www.mozilla.org/xbl">
4 <!--
5 https://bugzilla.mozilla.org/show_bug.cgi?id=319374
6 -->
7 <head>
8 <title>Test for Bug 319374</title>
9 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
11 <xbl:bindings>
12 <xbl:binding id="test">
13 <xbl:content>
14 <span attr="attribute"><span></span></span><span> anon text </span><br/>
15 </xbl:content>
16 </xbl:binding>
17 </xbl:bindings>
18 </head>
19 <body>
20 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=319374">Mozilla Bug 319374</a>
21 <p id="display"></p>
22 <div id="content"><span style="-moz-binding: url(#test)"/><span style="-moz-binding: url(#test)"/><span style="-moz-binding: url(#test)"/></div>
23 <pre id="test">
24 <script class="testbody" type="text/javascript">
25 <![CDATA[
27 /** Test for Bug 319374 **/
29 function testChangesInAnonymousTree() {
30 // Test 1: Make sure that modifying anonymous content doesn't
31 // cause non-anonymous XPath result to throw exceptions..
32 var counter = 0;
33 var error = null;
34 function getAnonymousNodes(e) {
35 return SpecialPowers.wrap(document).getAnonymousNodes(e);
36 }
37 try {
38 var xp = new XPathEvaluator();
39 var result = xp.evaluate("*",
40 document.getElementById('content'),
41 null,
42 SpecialPowers.Ci.nsIDOMXPathResult.
43 UNORDERED_NODE_ITERATOR_TYPE,
44 null);
45 var res = null;
46 while (res = result.iterateNext()) {
47 ++counter;
48 var anon = getAnonymousNodes(res);
49 anon[0].removeChild(anon[0].firstChild); // Removing a child node
50 anon[0].removeAttribute("attr1"); // Removing an attribute
51 anon[1].firstChild.data = "anon text changed" // Modifying text data
52 }
53 } catch (e) {
54 error = e;
55 }
56 ok(!error, error);
57 ok(counter == 3, "XPathEvaluator should have found 3 elements.")
59 // Test 2: If the context node is in anonymous content, changing some
60 // other anonymous tree shouldn't cause XPath result to throw.
61 var anonAttr1 =
62 getAnonymousNodes(document.getElementById('content').
63 firstChild)[0].getAttributeNode('attr');
64 var anonAttr2 =
65 getAnonymousNodes(document.getElementById('content').
66 lastChild)[0].getAttributeNode('attr');
67 var resultAttr = null;
68 try {
69 var xp2 = SpecialPowers.wrap(xp).evaluate(".",
70 anonAttr1,
71 null,
72 SpecialPowers.Ci.nsIDOMXPathResult.
73 UNORDERED_NODE_ITERATOR_TYPE,
74 null);
75 // Attribute changing in a different anonymous tree.
76 anonAttr2.value = "foo";
77 resultAttr = xp2.iterateNext();
78 ok(SpecialPowers.compare(resultAttr, anonAttr1), "XPathEvaluator returned wrong attribute!")
79 } catch (e) {
80 ok(false, e);
81 }
83 // Test 3: If the anonymous tree in which context node is in is modified,
84 // XPath result should throw when iterateNext() is called.
85 resultAttr = null;
86 try {
87 var xp3 = xp.evaluate(".",
88 anonAttr1,
89 null,
90 SpecialPowers.Ci.nsIDOMXPathResult.
91 UNORDERED_NODE_ITERATOR_TYPE,
92 null);
93 // Attribute changing in the same anonymous tree.
94 anonAttr1.ownerElement.setAttribute("foo", "bar");
95 resultAttr = xp3.iterateNext();
96 ok(resultAttr == anonAttr1,
97 "XPathEvaluator should have thrown an exception!")
98 } catch (e) {
99 ok(true, e);
100 }
102 SimpleTest.finish();
103 }
105 SimpleTest.waitForExplicitFinish();
106 addLoadEvent(testChangesInAnonymousTree);
107 ]]>
108 </script>
109 </pre>
110 </body>
111 </html>