toolkit/content/tests/chrome/test_bug253481.xul

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

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

mercurial