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