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