editor/libeditor/html/tests/test_bug404320.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>
     3 <!--
     4 https://bugzilla.mozilla.org/show_bug.cgi?id=404320
     5 -->
     6 <head>
     7   <title>Test for Bug 404320</title>
     8   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     9   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    10 </head>
    11 <body>
    12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=404320">Mozilla Bug 404320</a>
    13 <p id="display"></p>
    14 <div id="content">
    15   <iframe id="testIframe"></iframe>
    16 </div>
    17 <pre id="test">
    18 <script class="testbody" type="text/javascript">
    20 /** Test for Bug 404320 **/
    22 SimpleTest.waitForExplicitFinish();
    24 function runTests() {
    25   var win = document.getElementById("testIframe").contentWindow;
    26   var doc = document.getElementById("testIframe").contentDocument;
    28   function testFormatBlock(tag, withAngleBrackets, shouldSucceed)
    29   {
    30     win.getSelection().selectAllChildren(doc.body.firstChild);
    31     doc.execCommand("FormatBlock", false,
    32                     withAngleBrackets ? tag : "<" + tag + ">");
    33     var resultNode;
    34     if (shouldSucceed && (tag == "dd" || tag == "dt")) {
    35       is(doc.body.firstChild.tagName, "DL", "tag was changed");
    36       resultNode = doc.body.firstChild.firstChild;
    37     }
    38     else {
    39       resultNode = doc.body.firstChild;
    40     }
    42     is(resultNode.tagName, shouldSucceed ? tag.toUpperCase() : "P", "tag was changed");
    43   }
    45   function formatBlockTests(tags, shouldSucceed)
    46   {
    47     var html = "<p>Content</p>";
    48     for (var i = 0; i < tags.length; ++i) {
    49       var tag = tags[i];
    50       var resultTag = tag.toUpperCase();
    52       doc.body.innerHTML = html;
    53       testFormatBlock(tag, false, shouldSucceed);
    55       doc.body.innerHTML = html;
    56       testFormatBlock(tag, true, shouldSucceed);
    57     }
    58   }
    60   doc.designMode = "on";
    62   var goodTags = [ "address",
    63                    "blockquote",
    64                    "dd",
    65                    "div",
    66                    "dl",
    67                    "dt",
    68                    "h1",
    69                    "h2",
    70                    "h3",
    71                    "h4",
    72                    "h5",
    73                    "h6",
    74                    "p",
    75                    "pre" ];
    76   var badTags =  [ "b",
    77                    "i",
    78                    "span",
    79                    "foo" ];
    81   formatBlockTests(goodTags, true);
    82   formatBlockTests(badTags, false);
    83   SimpleTest.finish();
    84 }
    86 addLoadEvent(runTests);
    88 </script>
    89 </pre>
    90 </body>
    91 </html>

mercurial