editor/libeditor/base/tests/test_bug502673.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 <!-- This Source Code Form is subject to the terms of the Mozilla Public
     3    - License, v. 2.0. If a copy of the MPL was not distributed with this
     4    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
     5 <html>
     6 <!--
     7 https://bugzilla.mozilla.org/show_bug.cgi?id=502673
     8 -->
    10 <head>
    11   <title>Test for Bug 502673</title>
    12   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    13   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    14   <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>  
    15 </head>
    17 <body onload="doTest();">
    18   <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=502673">Mozilla Bug 502673</a>
    19   <p id="display"></p>
    20   <div id="content" style="display: none">
    21   </div>
    23   <pre id="test">
    24     <script type="application/javascript">
    26       /** Test for Bug 502673 **/
    28       SimpleTest.waitForExplicitFinish();
    30       function listener() {
    31       }
    33       listener.prototype =
    34       {
    35         NotifyDocumentWillBeDestroyed: function () {
    36           if (this.input instanceof SpecialPowers.Ci.nsIDOMNSEditableElement) {
    37             var editor = SpecialPowers.wrap(this.input).editor;
    38             editor.removeDocumentStateListener(this);
    39           }
    40         },
    42         NotifyDocumentCreated: function () {
    43         },
    45         NotifyDocumentStateChanged: function (aNowDirty) {
    46           if (this.input instanceof SpecialPowers.Ci.nsIDOMNSEditableElement) {
    47             var editor = SpecialPowers.wrap(this.input).editor;
    48             editor.removeDocumentStateListener(this);
    49           }
    50         },
    52         QueryInterface: function(iid) {
    53           if (iid.equals(SpecialPowers.Ci.nsIDocumentStateListener) ||
    54               iid.equals(SpecialPowers.Ci.nsISupports))
    55             return this;
    56           throw SpecialPowers.Cr.NS_ERROR_NO_INTERFACE;
    57         },
    58       };
    60       function doTest() {
    61         var input = document.getElementById("ip");
    62         if (input instanceof SpecialPowers.Ci.nsIDOMNSEditableElement) {
    63           // Add multiple listeners to the same editor
    64           var editor = SpecialPowers.wrap(input).editor;
    65           var listener1 = new listener();
    66           listener1.input = input;
    67           var listener2 = new listener();
    68           listener2.input = input;
    69           var listener3 = new listener();
    70           listener3.input = input;
    71           editor.addDocumentStateListener(listener1);
    72           editor.addDocumentStateListener(listener2);
    73           editor.addDocumentStateListener(listener3);
    75           // Test 1. Fire NotifyDocumentStateChanged notifications where the
    76           // listeners remove themselves
    77           input.value = "mozilla";
    78           editor.undo(1);
    80           // Report success if we get here - clearly we didn't crash
    81           ok(true, "Multiple listeners removed themselves after " +
    82                    "NotifyDocumentStateChanged notifications - didn't crash");
    84          // Add the listeners again for the next test
    85          editor.addDocumentStateListener(listener1);
    86          editor.addDocumentStateListener(listener2);
    87          editor.addDocumentStateListener(listener3);
    89         }
    91         // Test 2. Fire NotifyDocumentWillBeDestroyed notifications where the
    92         // listeners remove themselves (though in the real world, listeners
    93         // shouldn't do this as nsEditor::PreDestroy removes them as
    94         // listeners anyway)
    95         document.body.removeChild(input);
    96         ok(true, "Multiple listeners removed themselves after " +
    97                  "NotifyDocumentWillBeDestroyed notifications - didn't crash");
    99        // TODO: Test for NotifyDocumentCreated
   101        SimpleTest.finish();
   102       }
   103    </script>
   104   </pre>
   106   <input type="text" id="ip" />
   107 </body>
   108 </html>

mercurial