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 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
3 <?xml-stylesheet
4 href="chrome://mochikit/content/tests/SimpleTest/test.css"
5 type="text/css"?>
6 <!--
7 https://bugzilla.mozilla.org/show_bug.cgi?id=253481
8 -->
9 <window title="Mozilla Bug 253481"
10 xmlns:html="http://www.w3.org/1999/xhtml"
11 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
13 <script type="application/javascript"
14 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
15 <script type="application/javascript"
16 src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
18 <body xmlns="http://www.w3.org/1999/xhtml">
19 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=253481">Mozilla Bug 253481</a>
20 <p id="display"></p>
21 <div id="content" style="display: none">
23 </div>
24 </body>
26 <description>
27 Tests pasting of multi-line content into a single-line xul:textbox.
28 </description>
30 <vbox>
31 <textbox id="pasteintact" newlines="pasteintact"/>
32 <textbox id="pastetofirst" newlines="pastetofirst"/>
33 <textbox id="replacewithspaces" newlines="replacewithspaces"/>
34 <textbox id="strip" newlines="strip"/>
35 <textbox id="replacewithcommas" newlines="replacewithcommas"/>
36 <textbox id="stripsurroundingwhitespace" newlines="stripsurroundingwhitespace"/>
37 </vbox>
38 <script class="testbody" type="application/javascript;version=1.7">
39 <![CDATA[
40 /** Test for Bug 253481 **/
41 function testPaste(name, element, expected) {
42 element.value = "";
43 element.focus();
44 synthesizeKey("v", { accelKey: true });
45 is(element.value, expected, name);
46 }
48 SimpleTest.waitForExplicitFinish();
50 SimpleTest.waitForFocus(function() {
51 setTimeout(function() {
52 var testString = "\n hello hello \n world\nworld \n";
53 var expectedResults = {
54 // even "pasteintact" strips leading/trailing newlines
55 "pasteintact": testString.replace(/^\n/, '').replace(/\n$/, ''),
56 // "pastetofirst" strips leading newlines
57 "pastetofirst": testString.replace(/^\n/, '').split(/\n/)[0],
58 // "replacewithspaces" strips trailing newlines first - bug 432415
59 "replacewithspaces": testString.replace(/\n$/, '').replace(/\n/g,' '),
60 // "strip" is pretty straightforward
61 "strip": testString.replace(/\n/g,''),
62 // "replacewithcommas" strips leading and trailing newlines first
63 "replacewithcommas": testString.replace(/^\n/, '').replace(/\n$/, '').replace(/\n/g,','),
64 // "stripsurroundingwhitespace" strips all newlines and whitespace around them
65 "stripsurroundingwhitespace": testString.replace(/\s*\n\s*/g,'')
66 };
68 // Put a multi-line string in the clipboard
69 SimpleTest.waitForClipboard(testString, function() {
70 var clip = Components.classes["@mozilla.org/widget/clipboardhelper;1"]
71 .getService(Components.interfaces.nsIClipboardHelper);
72 clip.copyString(testString, document);
73 }, function() {
74 for (let [item, expected] in Iterator(expectedResults)) {
75 testPaste(item, $(item), expected);
76 }
78 SimpleTest.finish();
79 }, function() {
80 ok(false, "Could not copy the string to clipboard, giving up");
82 SimpleTest.finish();
83 });
84 }, 0);
85 });
87 ]]>
88 </script>
90 </window>