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 | <?xml version="1.0"?> |
michael@0 | 2 | <?xml-stylesheet href="chrome://global/skin" type="text/css"?> |
michael@0 | 3 | <?xml-stylesheet href="/tests/SimpleTest/test.css" type="text/css"?> |
michael@0 | 4 | |
michael@0 | 5 | <window title="Popup Reflow Tests" |
michael@0 | 6 | xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
michael@0 | 7 | |
michael@0 | 8 | <panel id="testPanel" |
michael@0 | 9 | type="arrow" |
michael@0 | 10 | noautohide="true"> |
michael@0 | 11 | </panel> |
michael@0 | 12 | |
michael@0 | 13 | <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 14 | |
michael@0 | 15 | <script> |
michael@0 | 16 | <![CDATA[ |
michael@0 | 17 | const {classes: Cc, interfaces: Ci, utils: Cu} = Components; |
michael@0 | 18 | |
michael@0 | 19 | Cu.import("resource://gre/modules/XPCOMUtils.jsm"); |
michael@0 | 20 | Cu.import("resource://gre/modules/Promise.jsm"); |
michael@0 | 21 | |
michael@0 | 22 | let panel, anchor, arrow; |
michael@0 | 23 | |
michael@0 | 24 | // A reflow observer - it just remembers the stack trace of all sync reflows |
michael@0 | 25 | // done by the panel. |
michael@0 | 26 | let observer = { |
michael@0 | 27 | reflows: [], |
michael@0 | 28 | reflow: function (start, end) { |
michael@0 | 29 | this.reflows.push(new Error().stack); |
michael@0 | 30 | }, |
michael@0 | 31 | |
michael@0 | 32 | reflowInterruptible: function (start, end) { |
michael@0 | 33 | // We're not interested in interruptible reflows. Why, you ask? Because |
michael@0 | 34 | // we've simply cargo-culted this test from browser_tabopen_reflows.js! |
michael@0 | 35 | }, |
michael@0 | 36 | |
michael@0 | 37 | QueryInterface: XPCOMUtils.generateQI([Ci.nsIReflowObserver, |
michael@0 | 38 | Ci.nsISupportsWeakReference]) |
michael@0 | 39 | }; |
michael@0 | 40 | |
michael@0 | 41 | // A test utility that counts the reflows caused by a test function. If the |
michael@0 | 42 | // count of reflows isn't what is expected, it causes a test failure and logs |
michael@0 | 43 | // the stack trace of all seen reflows. |
michael@0 | 44 | function countReflows(testfn, expected) { |
michael@0 | 45 | let deferred = Promise.defer(); |
michael@0 | 46 | observer.reflows = []; |
michael@0 | 47 | let docShell = panel.ownerDocument.defaultView |
michael@0 | 48 | .QueryInterface(Components.interfaces.nsIInterfaceRequestor) |
michael@0 | 49 | .getInterface(Components.interfaces.nsIWebNavigation) |
michael@0 | 50 | .QueryInterface(Components.interfaces.nsIDocShell); |
michael@0 | 51 | docShell.addWeakReflowObserver(observer); |
michael@0 | 52 | testfn().then(() => { |
michael@0 | 53 | docShell.removeWeakReflowObserver(observer); |
michael@0 | 54 | SimpleTest.is(observer.reflows.length, expected, "correct number of reflows"); |
michael@0 | 55 | if (observer.reflows.length != expected) { |
michael@0 | 56 | SimpleTest.info("stack traces of reflows:\n" + observer.reflows.join("\n") + "\n"); |
michael@0 | 57 | } |
michael@0 | 58 | deferred.resolve(); |
michael@0 | 59 | }); |
michael@0 | 60 | return deferred.promise |
michael@0 | 61 | } |
michael@0 | 62 | |
michael@0 | 63 | function openPopup() { |
michael@0 | 64 | let deferred = Promise.defer(); |
michael@0 | 65 | panel.addEventListener("popupshown", function popupshown() { |
michael@0 | 66 | panel.removeEventListener("popupshown", popupshown); |
michael@0 | 67 | deferred.resolve(); |
michael@0 | 68 | }); |
michael@0 | 69 | panel.openPopup(anchor, "before_start"); |
michael@0 | 70 | return deferred.promise |
michael@0 | 71 | } |
michael@0 | 72 | |
michael@0 | 73 | // ******************** |
michael@0 | 74 | // The actual tests... |
michael@0 | 75 | // We only have one atm - simply open a popup. |
michael@0 | 76 | // |
michael@0 | 77 | function testSimplePanel() { |
michael@0 | 78 | return openPopup(); |
michael@0 | 79 | } |
michael@0 | 80 | |
michael@0 | 81 | // ******************** |
michael@0 | 82 | // The test harness... |
michael@0 | 83 | // |
michael@0 | 84 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 85 | |
michael@0 | 86 | addEventListener("load", function() { |
michael@0 | 87 | anchor = document.getElementById("anchor"); |
michael@0 | 88 | panel = document.getElementById("testPanel"); |
michael@0 | 89 | arrow = document.getAnonymousElementByAttribute(panel, "anonid", "arrow"); |
michael@0 | 90 | |
michael@0 | 91 | // Cancel the arrow panel slide-in transition (bug 767133) - we are only |
michael@0 | 92 | // testing reflows in the core panel implementation and not reflows that may |
michael@0 | 93 | // or may not be caused by transitioning.... |
michael@0 | 94 | arrow.style.transition = "none"; |
michael@0 | 95 | |
michael@0 | 96 | // and off we go... |
michael@0 | 97 | countReflows(testSimplePanel, 1).then(SimpleTest.finish); |
michael@0 | 98 | }); |
michael@0 | 99 | ]]> |
michael@0 | 100 | </script> |
michael@0 | 101 | <body xmlns="http://www.w3.org/1999/xhtml"> |
michael@0 | 102 | <p>The anchor --> <span id="anchor">v</span> <--</p> |
michael@0 | 103 | </body> |
michael@0 | 104 | </window> |