editor/libeditor/html/tests/test_bug480972.html

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.

     1 <!DOCTYPE HTML>
     2 <html><head>
     3 <title>Test for bug 480972</title>
     4 <style src="/tests/SimpleTest/test.css" type="text/css"></style>
     5 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     6 <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
     8 <script class="testbody" type="application/javascript">
    10 function runTest() {
    11   function verifyContent(s) {
    12     var e = document.getElementById('i1');
    13     var doc = e.contentDocument;
    14     is(doc.body.innerHTML, s, "");
    15   }
    17   function pasteInto(html,target_id) {
    18     var e = document.getElementById('i1');
    19     var doc = e.contentDocument;
    20     doc.designMode = "on";
    21     doc.body.innerHTML = html;
    22     doc.defaultView.focus();
    23     if (target_id)
    24       e = doc.getElementById(target_id);
    25     else
    26       e = doc.body;
    27     var selection = doc.defaultView.getSelection();
    28     selection.removeAllRanges();
    29     selection.selectAllChildren(e);
    30     selection.collapseToEnd();
    31     SpecialPowers.wrap(doc).execCommand("paste", false, null);
    32    return e;
    33   }
    35   function copyToClipBoard(s,asHTML,target_id) {
    36     var e = document.getElementById('i2');
    37     var doc = e.contentDocument;
    38     if (asHTML) {
    39       doc.body.innerHTML = s;
    40     } else {
    41       var text = doc.createTextNode(s);
    42       doc.body.appendChild(text);
    43     }
    44     doc.designMode = "on";
    45     doc.defaultView.focus();
    46     var selection = doc.defaultView.getSelection();
    47     selection.removeAllRanges();
    48     if (!target_id) {
    49       selection.selectAllChildren(doc.body);
    50     } else {
    51       var range = document.createRange();
    52       range.selectNode(doc.getElementById(target_id));
    53       selection.addRange(range);
    54     }
    55     SpecialPowers.wrap(doc).execCommand("copy", false, null);
    56     return e;
    57   }
    59   copyToClipBoard('<span>Hello</span><span>Kitty</span>', true);
    60   pasteInto('');
    61   verifyContent('<span>Hello</span><span>Kitty</span>');
    63   copyToClipBoard("<dl><dd>Hello Kitty</dd></dl><span>Hello</span><span>Kitty</span>", true);
    64   pasteInto('<ol><li id="paste_here">X</li></ol>',"paste_here");
    65   verifyContent('<ol><li id="paste_here">X<dl><dd>Hello Kitty</dd></dl><span>Hello</span><span>Kitty</span></li></ol>');
    67 // The following test doesn't do what I expected, because the special handling
    68 // of IsList nodes in nsHTMLEditor::InsertHTMLWithContext simply removes
    69 // non-list/item children.  See bug 481177.
    70 //  copyToClipBoard("<ol><li>Hello Kitty</li><span>Hello</span></ol>", true);
    71 //  pasteInto('<ol><li id="paste_here">X</li></ol>',"paste_here");
    72 //  verifyContent('<ol><li id="paste_here">X</li><li>Hello Kitty</li><span>Hello</span></ol>');
    74   copyToClipBoard("<pre>Kitty</pre><span>Hello</span>", true);
    75   pasteInto('<pre id="paste_here">Hello </pre>',"paste_here");
    76   verifyContent('<pre id="paste_here">Hello Kitty<span>Hello</span></pre>');
    78   SimpleTest.finish();
    79 }
    81 SimpleTest.waitForExplicitFinish();
    82 addLoadEvent(runTest);
    83 </script>
    84 </head>
    85 <body>
    86 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=480972">Mozilla Bug 480972</a>
    87 <p id="display"></p>
    89 <pre id="test">
    90 </pre>
    93 <iframe id="i1" width="200" height="100" src="about:blank"></iframe><br>
    94 <iframe id="i2" width="200" height="100" src="about:blank"></iframe><br>
    96 </body>
    97 </html>

mercurial