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 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=995321
5 -->
6 <head>
7 <meta charset="utf-8">
8 <title>Test for Bug 995321 - encodeToStringWithMaxLength</title>
9 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
11 <script type="application/javascript">
12 function getEncoder() {
13 const de = SpecialPowers.Ci.nsIDocumentEncoder;
14 const Cc = SpecialPowers.Cc;
16 // Create a plaintext encoder without flags.
17 var encoder = Cc["@mozilla.org/layout/documentEncoder;1?type=text/plain"]
18 .createInstance(de);
19 encoder.init(document, "text/plain", 0);
20 return encoder;
21 }
23 function testPlaintextSerializerWithMaxLength() {
24 var string = getEncoder().encodeToString();
26 var shorterString = getEncoder().encodeToStringWithMaxLength(1);
27 ok(shorterString.length < 1 + 72,
28 "test length is in the expected range after limiting the length to 1");
29 ok(string.startsWith(shorterString.trimRight()),
30 "the shorter string has the expected content");
32 shorterString = getEncoder().encodeToStringWithMaxLength(300);
33 ok(shorterString.length < 300 + 72,
34 "test length is in the expected range after limiting the length to 300");
35 ok(string.startsWith(shorterString.trimRight()),
36 "the shorter string has the expected content");
38 is(getEncoder().encodeToStringWithMaxLength(0), string,
39 "limiting the length to 0 should be ignored");
41 is(getEncoder().encodeToStringWithMaxLength(10000), string,
42 "limiting the length to a huge value should return the whole page");
44 SimpleTest.finish();
45 }
47 addLoadEvent(testPlaintextSerializerWithMaxLength);
48 SimpleTest.waitForExplicitFinish();
49 </script>
50 </head>
51 <body>
52 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=995321">Mozilla Bug 995321</a>
53 <p id="display"></p>
54 <div id="content" style="display: none">
55 The <em>Mozilla</em> project is a global community of <strong>people</strong> who believe that openness, innovation, and opportunity are key to the continued health of the Internet. We have worked together since 1998 to ensure that the Internet is developed in a way that benefits everyone. We are best known for creating the Mozilla Firefox web browser.
57 The Mozilla project uses a community-based approach to create world-class open source software and to develop new types of collaborative activities. We create communities of people involved in making the Internet experience better for all of us.
59 As a result of these efforts, we have distilled a set of principles that we believe are critical for the Internet to continue to benefit the public good as well as commercial aspects of life. We set out these principles below.
60 </div>
61 <pre id="test">
62 </pre>
63 </body>
64 </html>